akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c;  cin >> a >> b >> c;
    int m;
    int maxi = max(a, max(b, c));
    if (maxi % 2 == (a + b + c) % 2) {
      cout << (3 * maxi - (a + b + c)) / 2 << '\n';
    } else {
      cout << (3 * (maxi + 1) - (a + b + c)) / 2 << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
// https://www.youtube.com/watch?v=1CaS4pSpS3c     lana is <3
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back 
#define pop pop_back
#define mp make_pair
#define vii vector < ll >
#define vll vector < ll > 
#define dt cout<<"HERE\n";
#define pii pair < ll , ll >
#define pll pair < ll , ll >
#define vpi vector < pii >
#define vpl vector < pll >
#define fi first
#define se second 
#define sz size 
#define len length 
const ll inf=1e18+1e17;
const ll mod = 1e9+7;

ll modInverse(ll a,ll m){ll m0=m;ll y=0,x=1;if(m == 1)return 0;while(a> 1){ll q=a/m;ll t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=m0;return x;}  
ll powm(ll a,ll b){a=a%mod;ll res=1;while(b){if(b&1)res=(res*a)%mod;a=(a*a)%mod;b>>=1;}return (res%mod);}
ll sub( ll a, ll b){ if ( a-b<0) return a-b+mod; return a-b;}
ll add( ll a, ll b){ if ( a+b>=mod) return a+b-mod; return a+b;}
ll mul( ll a, ll b){ return (a*b)%mod;}
const ll N =2000+5;

void solve(){
	int n;
	cin>>n;
	int arr[n],brr[n];
	for ( int i=0;i<n;i++){
		int aa,bb;
		cin>>aa>>bb;
		arr[i]=aa+bb;
		brr[i]=aa-bb;
	}
	sort( arr,arr+n);
	sort( brr,brr+n);
	cout<<max( arr[n-1]-arr[0],brr[n-1]-brr[0])<<'\n';


}


int main(){

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

	#ifndef ONLINE_JUDGE
		freopen ("INPUT.txt" , "r" , stdin);
		freopen ("OUTPUT.txt", "w" , stdout);
	#endif
	
	int t=1;
	//cin>>t;
	while ( t-- )
		solve();
}

Measured memory_bytes: 5140
/*
 ~ author - Sayan Bose
 ~ Do Good Die Great
*/
#include<bits/stdc++.h>
#define ll long long
#define amaterasu ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
using namespace std;

void solve()
{
	int s=0, w=0;
	cin >> s >> w;
	cout << ((s > w) ? "safe" : "unsafe");
}

int main()
{
	amaterasu
	solve();
	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
    ll n,ar[1000000],cnt[1000000],sum=0;
    cin >>n;
    for(int i=0;i<200005;i++){cnt[i]=0;}
    for(int i=0;i<n;i++){
        cin >> ar[i];
        cnt[ar[i]]++;
    }
    for(int i=0;i<200005;i++){
        ll d=(cnt[i]*(cnt[i]-1))/2;
        sum+=d;
    }
  for(int i=0;i<n;i++){
      ll k=cnt[ar[i]];
      ll t1=(k*(k-1))/2;
      ll t2=((k-1)*(k-2))/2;
      cout << sum-t1+t2 << endl;
  }
    return 0;
}


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

using namespace std;

typedef long long int lli;

lli i,j,k,l,m,n,t,a,b,c,d,x,y,p,q,sum=0,total=0;

#define read(in) freopen("Input.txt","r",stdin)

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

    //read(in);

    string ar;
    cin>>ar;

    sum=0;
    for(i=0 ; i<ar.size() ; i++)
    {
        if(ar[i]=='7')
        {
            sum=1;break;
        }
    }
    if(sum==1)  cout<<"Yes\n";
    else    cout<<"No\n";

}

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

int main() {
  string a,b;
  cin >> a;
  for(int i = 0; i < a.length(); i++) {
    b = a;
    a.erase(i, 1);
    if(a.find(b[i]) != string::npos){
      a.erase(a.find(b[i]), 1);
      i--;
    }else {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
n = int(input())

alphabet = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
ln = []

while True:
    n -= 1
    b = n % 26
    ln.append(alphabet[b])

    if n <= 25:
        break

    a = n//26
    n = a

ln.reverse()
ln=''.join(ln)
print(ln)

Measured memory_bytes: 9092
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<complex>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
#define PI 3.1415926535897932384626433832795028
typedef long long Int;
typedef pair<Int, Int> P;
typedef long double Real;
typedef complex<Real> CP;

int n, m;
string str[2200];
vector<int> ng[2200];
vector<int> col[2200];

class UnionFind{
public:
    int n;
    vector<int> u;
    UnionFind(int _n = 0){
        n = _n;
        u = vector<int>(n, -1);
    }
    int r(int x){
        if(u[x] < 0)return x;
        return u[x] = r(u[x]);
    }
    void unite(int x, int y){
        x = r(x);
        y = r(y);
        if(x == y)return;
        if(-u[x] < -u[y])swap(x,y);
        u[x] += u[y];
        u[y] = x;
    }
    int size(int x){
        return -u[r(x)];
    }
};


int main(){
    cin >> n >> m;
    for(int i = 0;i < n;i++)cin >> str[i];
    for(int i = 0;i < n-1;i++){
        for(int j = 0;j < m-1;j++){
            int cnt = (str[i][j] == '#')
                + (str[i+1][j] == '#')
                + (str[i][j+1] == '#')
                + (str[i+1][j+1] == '#');
            if(cnt % 2){
                col[j].push_back(i);
            }
        }
    }

    int ans = 0;
    
    for(int i = 0;i < n;i++){
        UnionFind uf(m);
        vector<int> walls = {0};
        int last = 0;
        int longest = 1;
        for(int j = 0;j < m;j++){
            auto it = lower_bound(col[j].begin(), col[j].end(), i);
            if(it != col[j].end()){
                ng[*it].push_back(j);                
                while(last <= j){
                    if(last != j){
                        uf.unite(last, last + 1);
                        longest = max(longest, uf.size(last));
                    }
                    last++;
                }         
            }
        }
        while(last <= m-1){
            if(last != m-1){
                uf.unite(last, last + 1);
                longest = max(longest, uf.size(last));
            }
            last++;
        }
        
        for(int j = n-1;j >= i;j--){
            int h = j - i + 1;
            ans = max(ans, h * longest);
            if(j == i)break;
            for(auto p: ng[j-1]){
                uf.unite(p, p+1);
                longest = max(longest, uf.size(p));
            }
            ng[j-1].clear();
        }
    }

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

Measured memory_bytes: 36336
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define mkp make_pair
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repre(i,a,b)for(int i=a;i<=b;i++)
#define clr1(arr) memset(arr,-1,sizeof(arr));
#define clr0(arr) memset(arr,0,sizeof(arr));
#define pi pair<int,int>
#define pii pair<int,pi>
#define aint(v) v.begin(),v.end()
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace __gnu_pbds;
using namespace std;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> orderedSet;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> orderedMSet;
struct custom_hash {
static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define ump gp_hash_table<int,int,custom_hash>
//*p.find_by_order(index) return value at index
//p.order_of_key(key) return index
/*int **dp,in main function,int row,col;dp=new int*[n];rep(i,n)dp[i]=new int[m]*/
//**** Maths Section*******/
int power(int x,int y);
bool isPrime(int n);
int modInv(int a,int b);
int gcdExtended(int a,int b,int *x,int* y);
int mpower(int a,int b,int p);
/***************************/
int32_t main()
{
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  fastio
  int n;
  cin>>n;
  int res=0;
  double d;
  cin>>d;
  repre(i,1,n)
  {
    double a,b;
    cin>>a>>b;
    a=a*a;
    b=b*b;
    double ans=sqrt(a+b);
    if(ans<=d)res++;
  }
  cout<<res<<endl;
  return 0;
}

int modInv(int a, int m)
{
int x, y;
int g = gcdExtended(a, m, &x, &y);
int res = (x%m + m) % m;
return res;
}

int gcdExtended(int a, int b, int *x, int *y)
{
if (a == 0){
    *x = 0, *y = 1;
    return b;
  }
  int x1, y1;
  int gcd = gcdExtended(b%a, a, &x1, &y1);
  *x = y1 - (b/a) * x1;
  *y = x1;
  return gcd;
}

int mpower(int x, int y, int p)
{
int res = 1;
x = x % p;
while(y > 0){
    if(y & 1) res = (res*x) % p;
      y = y>>1;
      x = (x*x) % p;
    }
    return res;
}
int power(int x, int y)
{
int res = 1;
while (y > 0){
    if (y & 1) res = res*x;
      y = y>>1;
      x = x*x;
    }
    return res;
}

bool isPrime(int n)
{
if (n <= 1)  return false;
  if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
      int p=sqrt(n);
      for(int i=5;i<=p;i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
          return false;
      return true;
}


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

int main() {
    long long int n, ans = 1e12;
    cin >> n;
    for(long long int i = 1; i*i <= n; ++i) {
        if(n%i == 0) {
            ans = min(ans, n/i + i - 2);
        }
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cctype>
#include<cstring>
#define maxn 1007
#define SDOI2020 RP++ 
using namespace std;
int n,m,map[maxn][maxn],cut[maxn],ans,sum[maxn][maxn],K,num[17]; 
char s[maxn];
inline int read()
{
	int x=0;
	int flag=0;
	char ch;
	ch=getchar();
	while(!isdigit(ch)) 
	{
		if(ch=='-') flag=1;
	ch=getchar();	
	}
	while(isdigit(ch))
	{
		x=(x<<3)+(x<<1)+ch-48;
		ch=getchar();
		}
		if(flag==1) x=-x;	
		return x;
}

inline void dfs(int x,int cnt)
{
	if(x == n)
	{
		memset(num,0,sizeof(num));
		cut[++cnt] = n;
		int now = cnt - 1;
		for(register int j = 1;j <= m;j++)
		{
			for(register int i = 1;i <= cnt;i++)
			{
				//cout<<j<<endl;
				int pos = sum[cut[i]][j] - sum[cut[i - 1]][j];
				if(pos > K) return ;
				num[i] += pos;
			}
			int flag = 0;
			for(register int i = 1;i <= cnt;i++)
			{
				if(num[i] > K)
				{
					flag = 1;
					break;
				}
			}
			if(flag)
			{
				now++;
				for(register int i = 1;i <= cnt;i++)
				{
					num[i] = sum[cut[i]][j] - sum[cut[i - 1]][j];
				}
			}
		}
		ans = min(ans,now);
		return ;
	}
	cut[cnt + 1] = x;
	dfs(x + 1,cnt + 1);
	cut[cnt + 1] = 0;
	dfs(x + 1,cnt);
}


int main()
{
	n = read();
	m = read();
	K = read();
	for(register int i = 1;i <= n;i++)
	{
		scanf("%s",s + 1);
		for(register int j = 1;j <= m;j++)
		{
			map[i][j] = s[j] - '0';
		}
	}
	for(register int i = 1;i <= n;i++)
	{
		for(register int j = 1;j <= m;j++)
		{
			sum[i][j] = sum[i - 1][j] + map[i][j];
		}
	}
	ans = 1e9 + 7;
	dfs(1,0);
	printf("%d\n",ans);
	return 0;
} 

Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define RANGE(i,n) for(int i=0;i<n;i++)
typedef long long ll;

using namespace std;

signed main() {
    int A, B;
    cin >> A >> B;
    if( A >= 13) cout << B << endl;
    else if(A >=6 ) cout << B/2 << endl;
    else cout << 0 << endl;
}


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

int main() {
  int field[100][100];
  int n,x;
  while (cin >> n) {
    if(n == 0) break;
    int field[100][100] = {0};
    for(int i=0;i<n;i++) {
      for(int j=0;j<n;j++) {
        cin >> x;
        field[i][j] = x;
      }
    }
    for(int i=0;i<n;i++) {
      for(int j=0;j<n;j++) {
        field[i][n] += field[i][j];
      }
    }
    for(int i=0;i<n;i++) {
      for(int j=0;j<n;j++) {
        field[n][i] += field[j][i];
      }
    }
    for(int i=0;i<n;i++) {
      field[n][n] += field[i][n];
    }
    for(int i=0;i<n+1;i++) {
      for(int j=0;j<n+1;j++) {
        printf("%5d",field[i][j]);
      }
      cout <<  endl;
    }
  }
}

Measured memory_bytes: 0
#include<vector>
#include<cstdio>
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
ll N,K;
ll a[2050];
ll f[2050];
ll c[2050];
int main()
{
    memset(f,0,sizeof(f));
    memset(c,0,sizeof(c));
    scanf("%lld%lld",&N,&K);
    for(int i=0;i<N;i++) scanf("%lld",&a[i]);
    for(int i=0;i<N;i++)
    {
        for(int j=0;j<N;j++)
        {
            if(i!=j&&a[i]>a[j]) f[i]++;
        }
        //cout<<f[i]<<endl;
    }
    for(int i=0;i<N-1;i++)
    {
        for(int j=i+1;j<N;j++)
        {
            if(a[i]>a[j]) c[i]++;
        }
        //cout<<c[i]<<endl;
    }
    ll sum=0;
    for(int i=0;i<N;i++)
    {
        sum+=(K*(K-1)/2%mod*f[i]%mod+K*c[i]%mod)%mod;
        //sum+=(f[i]*K%mod*(K-1)/2%mod+K*c[i]%mod)%mod;
        sum=sum%mod;
        //cout<<i<<' '<<sum<<endl;
    }
    cout<<sum<<endl;
}


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

int main(){
    int n, x[1000], y[1000];
    double m;
    
    scanf(" %d", &n);
    for(int i = 0; i < n; i++){
        scanf(" %d", &x[i]);
    }
    for(int i = 0; i < n; i++){
       scanf(" %d", &y[i]);  
    }
    
    for(int i = 1; i <= 3; i++){
        m = 0.0;
        for(int j = 0; j < n; j++){
            m += pow(fabs(x[j] - y[j]), i);
        }
        printf("%lf\n", pow(m, 1.0/i));
    }
    
    double p = 0.0;
    for(int i = 0; i < n; i++){
        if(p < (fabs(x[i] - y[i]))){
            p = fabs(x[i] - y[i]);
        }
    }
    printf("%lf\n", p);
    return 0;
}


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

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;} 
ll lcm(ll x,ll y) {return x/gcd(x,y)*y;}

int main(){
    ll n,k;
    cin >> n >> k;
    ll x,y;
    x=n%k;
    y=k-x;
    cout << (x<y?x:y) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(){
  int a[100]={};
  int n;
  int i,j;
  scanf("%d",&n);
  int m;
  int m_ = 0;
  int b = abs(n);
if(b%2==1){
  a[0]=1;
  n=n-1;
}
while(n!=0){
  m=log2( abs(n) );
  if(m%2==0){
    if(n>0){
      a[m]++;
      n=n-pow(2,m);
      m_=fmax(m_,m);
    }else{
      a[m+1]++;
      n=n+pow(2,m+1);
      m_=fmax(m_,m+1);
    }
  }else{
    if(n>0){
      a[m+1]++;
      n=n-pow(2,m+1);
      m_=fmax(m_,m+1);
    }else{
      a[m]++;
      n=n+pow(2,m);
      m_=fmax(m_,m);
    }
  }
}
  for(i=0;i<m_+1;i++){
    if(a[i]>1){
      a[i]=a[i]-2;
      a[i+1]++;
      a[i+2]++;
      m_=fmax(m_,i+2);
    }
  }

  for(i=0;i<m_+1;i++){
    printf("%d",a[m_-i]);
  }

}

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

typedef long long int lli;
#define pb push_back
#define gcd __gcd
#define MOD 1000000007
#define mod2 998244353
#define forz(i,n) for(long long int i=0;i<n;i++)
char A[51][51];
set<pair<lli,lli>> s1,s2;
set<pair<lli,lli>>::iterator i1,i2;

lli mod(lli a){
    if(a<0) return -1*a;
    return a;
}

bool comp(pair<lli,lli> a,pair<lli,lli> b){
    return 0;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli t=1,u,j;
    //cin>>t;
    for(u=1;u<=t;u++){
        lli n,m,i,j,p=0,c,q=0,k,a,b,x,y,ne=0,p1=0,q1=0;
        cin>>n;
        
        for(j=1;j<=n;j++){
            a=n/j;
            p+=((a*(a+1)*j)/2);
        }
        cout<<p<<endl;
    }
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
random_device rnd;
mt19937 mt(rnd());

const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7;
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

int main()
{
    int p, q;
    cin >> p >> q;
    int tmp = q / gcd(p, q);
    int ans = 1;
    int cur = 2;

    while (cur * cur <= tmp)
    {
        if (tmp % cur == 0)
        {
            ans *= cur;
            while (tmp % cur == 0)
                tmp /= cur;
        }
        cur++;
    }
    ans *= tmp;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3220
def calc_check_digit(my_number)
  q = [0,2,3,4,5,6,7,2,3,4,5,6]
  sum=0
  (1..11).each do |i|
    sum += my_number[i].to_i * q[i]
  end
  mod = sum % 11
  if mod <= 1 then
    return 0 
  else
    return 11 - mod
  end
end

my_number = STDIN.gets.chomp.reverse

if my_number.index('?') == 0 then
  puts calc_check_digit(my_number)
else
  check_digit = my_number[0].to_i
  possible_numbers = []
  (0..9).each do |i|
    tmp = my_number.gsub(/\?/, i.to_s)
    if check_digit == calc_check_digit(tmp) then
      possible_numbers.push(i)
    end
  end 
  if possible_numbers.length > 1 then
    puts 'MULTIPLE'
  else
    puts possible_numbers[0]
  end
end

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

typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
typedef unsigned long long ULL;

#define MP make_pair
#define PB push_back
#define EB emplace_back
#define FOR(i, a, b) for (int i = (a); i<(b); ++i)
#define RFOR(i, b, a) for (int i = (b)-1; i>=(a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)a.size()
#define f first
#define s second
#define FILL(a, b) memset(a, b, sizeof(a))

 
void dout() { cerr << endl; }
 
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}	

int mex(const VI &a)
{
	set<int> st(ALL(a));
	for (int i = 0; ; ++i)
	{
		if (!st.count(i))
		{
			return i;
		}
	}
}

const int MOD = 998244353;

LL binpow(LL a, LL n)
{
	LL res = 1;
	while(n > 0)
	{
		if (n & 1)
		{
			res = res * a % MOD; 
		}
		a = a * a % MOD;
		n >>= 1;
	}
	return res;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(nullptr);
	int n;
	cin >> n;
	VI d(n), cnt(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> d[i];
		cnt[d[i]]++;
	}
	if (mex(d) < *max_element(ALL(d)))
	{
		cout << 0 << "\n";
		return 0;
	}

	for (int i = 1; i < n; ++i)
	{
		if (d[i] == 0)
		{
			cout << 0 << "\n";
			return 0; 
		}
	}

	LL ans = 1;
	for (int i = 1; i + 1 < n; ++i)
	{
		ans *= binpow(cnt[i], cnt[i + 1]);
		ans %= MOD;
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 8660
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from bisect import bisect_left

n = int(readline())
l = sorted(list(map(int, readline().split())))
ans = 0
for i in range(n - 2):
    for j in range(i + 1, n - 1):
        ans += bisect_left(l, l[i] + l[j]) - (j + 1)
print(ans)


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

int main(){
	string str;
	int q, l;
	deque<char> de;
	deque<char> :: iterator it;
	cin >> str >> q;
	l = str.size();
	for(int i = 0; i < l; i++)
		de.push_back(str[i]);
	bool f = false;
	int t, c;
	char s;
	for(int i = 0; i < q; i++){
		scanf("%d",&t);
		if(t == 1) f = !f;	//直接记录翻转 
		else if(t == 2){
			scanf("%d %c", &c, &s);
			if(!f){	
				if(c == 1) de.push_front(s);
				else if(c == 2) de.push_back(s);
			}
			else {
				if(c == 2) de.push_front(s);
				else if(c == 1) de.push_back(s);				
			}
		}
	}
	if(!f){
		for(it = de.begin(); it != de.end(); it++)
			printf("%c", *it);		
	}
	else{
		for(it = de.end() - 1; it != de.begin() - 1; it--)
			printf("%c", *it);			
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 1024
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

def make_divisors(n): # nの約数を列挙
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort(reverse=True)
    return divisors

# 全ての合計の約数が答えの候補、上から可能かどうか見ていく
N, K = lr()
A = np.array(lr())
total = A.sum()
D = make_divisors(total) # 降順
for d in D:
    B = A % d   
    B.sort()
    inc = d - B
    B_cum = B.cumsum()
    inc_cum = inc.cumsum()
    for i in range(N):
        x = B_cum[i]
        y = inc_cum[N-1] - inc_cum[i]
        if x > K or y > K:
            continue
        if (x+y) // 2 <= K:
            print(d); exit()


Measured memory_bytes: 12440
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1000000007;
main(){
    string s;
    cin >> s;
    ll sum = 0;
    for(int i = 0;i < 1LL << (s.length()-1);i++){
        string sub;
        for(int j = 0;j < s.length();j++){
            sub = sub + s[j];
            if((1 << j) & i){
                sum += stoll(sub);
                sub = "";
            }
        }
        sum += stoll(sub);
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
let [|H; W|] = stdin.ReadLine().Split() |> Array.map int

let count = 
    List.sum [ for _ in 1..H -> 
                 stdin.ReadLine().ToCharArray()
                 |> Array.filter (fun x -> x = '#')
                 |> Array.length]

if count = H + W - 1 then "Possible" else "Impossible"
|> stdout.WriteLine


Measured memory_bytes: 13396
import java.util.Scanner;
class Main{
    public static void main(String[] args) {
        Scanner scn= new Scanner(System.in);
        String n = scn.next();
        String answer="Yes";
        if(n.charAt(0)!='9'&&n.charAt(1)!='9') answer="No";
        System.out.println(answer);
    }
}


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

int main()
{
    int n;
    cin >> n;
    vector<int> p(n);
    for (int i = 0; i < n; i++)
    {
        cin >> p.at(i);
    }

    int mn = p.at(0);
    int res = 0;
    for (int i = 0; i < n; i++)
    {
        mn = min(mn, p.at(i));
        if (p.at(i) <= mn)
        {
            res++;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;
//________
#define pb        emplace_back
#define fi        first
#define se        second
#define ALL(x)    x.begin(),x.end()
#define err(...)  fprintf(stderr, __VA_ARGS__ )
#define show(x)   cerr << #x << ':' << (x) << endl
#define outl(x)   cout << (x) << '\n'
#define FAST()    cin.tie(0), ios::sync_with_stdio(false)
#define rep(i,n)     for(int i=0; i<(n); ++i)
#define reps(i,f,n)  for(int i=(f); i<=(n); ++i)
template<class A, class B>inline bool chmax(A &a, B b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, B b){return b<a ? a=b,1 : 0;}
inline bool inside(int y, int x, int H, int W){return(y>=0 && x>=0 && y<H && x<W);}
constexpr int dx[] = {1, 0, -1, 0,  1, 1, -1, -1};
constexpr int dy[] = {0, 1, 0, -1,  -1, 1, 1, -1};
typedef long long ll;
typedef pair<int,int> pii;
#define let const auto
#define INF  0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define NIL -1
//________
//

using pipi = pair<int, pii>;

struct P{
   int a, b, c;
   int cnt = 0;
   P(int a, int b, int c): a(a), b(b), c(c) {}
   P(int a, int b, int c, int P): a(a), b(b), c(c), cnt(P){}

   bool allSame() const {
      return a == b && b == c;
   }
};

int bfs(int A, int B, int C)
{
   queue<P> que;
   set <pipi> memo;
   que.push( P(A,B,C) );

   while (!que.empty())
   {
      const P tmp = que.front(); que.pop();
      pipi hoge;
      hoge.fi = tmp.a;
      hoge.se.fi = tmp.b;
      hoge.se.se = tmp.c;

      if (memo.count(hoge) > 0) {
         continue;
      } else {
         memo.insert(hoge);
      }

      if (tmp.allSame()) {
         return tmp.cnt;
      }

      const int a = tmp.a;
      const int b = tmp.b;
      const int c = tmp.c;
      const int p = tmp.cnt + 1;

      {
         que.push( P(a+1,b+1,c, p) );
         que.push( P(a+1,b,c+1, p) );
         que.push( P(a,b+1,c+1, p) );
      }
      {
         que.push (P(a+2,b,c,p) );
         que.push (P(a,b+2,c,p) );
         que.push (P(a,b,c+2,p) );
      }
   }
   return (-1);
}


signed main()
{
   FAST();
   int A, B, C;

   cin >> A >> B >> C;
   outl( bfs(A,B,C) );
}



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

int main()
{
	int n,k,a[100000],temp;
	while(cin >> n >> k,n || k){
		cin >> a[0];
		for(int i = 1;i < n;i++){
			cin >> temp;
			a[i] = a[i - 1] + temp;
		}
		temp = 0;
		for(int i = 0;i < n - k;i++)
			if(temp < a[i + k] - a[i])
				temp = a[i + k] - a[i];
		cout << temp << endl;
	}
	return 0;
}

Measured memory_bytes: 1548
#include<bits/stdc++.h>
#define de(x) cout<<#x<<"="<<x<<endl
#define dd(x) cout<<#x<<"="<<x<<" "
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define repd(i,a,b) for(int i=a;i>=(b);--i)
#define repp(i,a,b,t) for(int i=a;i<(b);i+=t)
#define mt(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define mp(u,v) make_pair(u,v)
#define sz(a) (int)a.size()
#define pb push_back
#define PI acos(-1.0)
#define qc std::ios::sync_with_stdio(false)
#define all(a) a.begin(),a.end()
using namespace std;
typedef vector<int> vi;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
typedef pair<int,pii> piii;

const ll mod = 1000000007;
const int N = 1e5+6;
const int M = 2e6+6;
const double eps = 1e-6;
const int inf = 0x3f3f3f3f;

bool eq(const db &a, const db &b) { return fabs(a - b) < eps; }
bool ls(const db &a, const db &b) { return a + eps < b; }
bool le(const db &a, const db &b) { return eq(a, b) || ls(a, b); }
ll gcd(ll a,ll b) { return a==0?b:gcd(b%a,a); };
ll lcm(ll a,ll b) { return a/gcd(a,b)*b; }
ll kpow(ll a,ll b) {ll res=1;a%=mod; if(b<0) return 1; for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll read(){
    ll x=0,f=1;char ch=getchar();
    while (ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
//inv[1]=1;
//for(int i=2;i<=n;i++) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
int n, k;
int cnt[N];
vi num;
ll dp[101][N], pre[N];
map<int, int> _map;
void init() {
	num.clear();
	mt(cnt, 0); mt(dp, 0); mt(pre, 0);
	_map.clear();
}
int main() {
	while(~scanf("%d%d",&n,&k)) {
		init();
		int pos = 1;
		// 整除分块
		while(pos <= n) {
			int r = n / (n / pos);
			// de(r);
			cnt[sz(num)] = r - pos + 1;
			num.pb(n / pos);
			pos = r + 1;
		}

		rep(i, 0, sz(num)) _map[num[i]] = i;
		// reverse(all(num));
		// reverse(cnt, cnt + sz(num));
		// rep(i, 0, sz(num)) dd(i), dd(num[i]), de(cnt[i]);

		rep(i, 0, sz(num)) {
			if(!i) dp[1][i] = cnt[i];
			else dp[1][i] = cnt[i] + dp[1][i-1];
		}
		rep(i, 2, k + 1) {
			rep(j, 0, sz(num)) {
				if(j) dp[i][j]  = dp[i][j-1] + dp[i-1][_map[n / num[j]]] * cnt[j];
				else dp[i][j] = dp[i-1][_map[n / num[j]]] * cnt[j];
				dp[i][j] %= mod;
			}
		}

		printf("%lld\n", dp[k][sz(num)-1]);
	}
    return 0;
}


Measured memory_bytes: 83580
//#include <tourist>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <iomanip>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#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, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
//setprecision(15)有効数字15桁
//-std=c++14
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
struct edge {
    int to, cost;
};
ll n, a, b;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n>>a>>b;
    a--;
    b--;
    n--;
    if((b-a)%2==0){
        cout<<(b-a)/2<<"\n";
    }
    else{
        ll ans=n-a;
        ans=min(ans,b);
        ll m=a;
        m=min(m,n-b);
        bool c=false;
        if(m==n-b){
            c=true;
        }
        ll ans1=m+1;
        if(c){
            ll temp=n-a-ans1;
            ans1+=temp/2;
        }
        else{
            ll temp=b-ans1;
            ans1+=temp/2;
        }
        cout<<min(ans,ans1)<<"\n";
    }
}



Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <limits>
#include <cassert>
#include <bitset>
#include <list>
#include <iomanip>
#include <cctype>

#define for0(i, N)    for (long long i = 0  ; i <  (N); ++i)
#define for1n(i, N)   for (long long i = 1  ; i <= (N); ++i)
#define for1(i, N)    for (long long i = 1  ; i <  (N); ++i)
#define forn(i, N)    for (long long i = 0  ; i <= (N); ++i)
#define forx(i, N, x) for (long long i = (x); i <  (N); ++i)
#define forl(i, N, x, a) for (long long i = (x), a = 0; a < (N);    \
                              i = (i + 1) % (N), ++a)
#define int long long

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b, signed){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b + 1;
}

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b++;
    return temp;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b, signed){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b - 1;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b--;
    return temp;
}

long long constexpr inf = std::numeric_limits<long long>::max();

using namespace std;

typedef long long ll;
typedef long double ld;
typedef priority_queue<ll> pq;
typedef priority_queue<ll,vector<ll>, greater<ll>> pql;
typedef stack<ll> stk;
typedef queue<ll> qu;
typedef pair<ll, ll> pll;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;
typedef set<ll> sll;
typedef unordered_set<ll> usll;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<vector<ll>> vvll;


signed main(void){
    cin.tie(0); ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);
    ll n, a, b;
    cin >> n >> a >> b;

    cout << n / (a + b) * a + min(n % (a + b), a) << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
  int x, y;
  cin >> x >> y;

  if(x == 1) { x = 14; }
  if(y == 1) { y = 14; }

  if(x > y) {
    cout << "Alice" << endl;
  } else if(x < y) {
    cout << "Bob" << endl;
  } else {
    cout << "Draw" << endl;
  }
}

Measured memory_bytes: 256
def main():
	from scipy.sparse.csgraph import floyd_warshall
	import numpy as np
	n, m, l, *L = map(int, open(0).read().split())
	abc = L[:3 * m];
	st = L[3 * m + 1:]
	r = [[float("inf")] * n for _ in range(n)]
	for a, b, c in zip(*[iter(abc)] * 3):
		if c <= l: r[a - 1][b - 1] = c
	fw = floyd_warshall(r, 0)
	ans = floyd_warshall(np.where(fw <= l, 1, fw), 0) - 1
	for s, t in zip(*[iter(st)] * 2):
		x = ans[s - 1, t - 1]
		if x == float("inf"):
			print(-1)
		else:
			print(int(x))


if __name__ == "__main__":
	main()

#after contest

Measured memory_bytes: 40888
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1e9 + 7;

int gcd(int x, int y) {
    if (x < y) swap(x, y);
    int r = x%y;
    if (r == 0) {
        return y;
    }
    return gcd(y, r);
}

ll mypow(ll x, ll n) {
    if (n == 0) return 1;
    if (n%2 == 0) return mypow(((x%mod)*(x%mod))%mod, n/2);
    else return ((x%mod) * mypow(((x%mod)*(x%mod))%mod, (n-1)/2))%mod;
}

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> a(N+1);
    for (int i=0; i<N+1; i++) a.at(i) = i;
    ll L_sum = 0, R_sum = 0;
    for (int i=0; i<K-1; i++) {
        L_sum = (L_sum + a.at(i))%mod;
        R_sum = (R_sum + a.at(N-i))%mod;
    }
    ll count = 0;
    for (int i=K; i<=N+1; i++) {
        L_sum = (L_sum + a.at(i-1))%mod;
        R_sum = (R_sum + a.at(N-i+1))%mod;
        count = (count + ((R_sum + mod) - L_sum) + 1)%mod;
    }
    cout << count << endl;
}

Measured memory_bytes: 4048
#include <stdio.h>

int main(){
  int n,a[100],i,j,count=0,flag,x;
  scanf("%d",&n);
 
  for(i=0;i<n;i++) scanf("%d",&a[i]);
 for(j=0;j<n;j++){
   flag=0;   
for(i=n-1;i>j;i--){
     if(a[i]<a[i-1])
       {
	 x=a[i];
	 a[i]=a[i-1];
  a[i-1]=x;
  flag=1;
  count++;
}
}
   if(flag==0)break;

}
for(i=0;i<n-1;i++) printf("%d ",a[i]);
 printf("%d\n",a[n-1]);
printf("%d\n",count);
return 0;
}

Measured memory_bytes: 600
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2) 
const int MGN = 10;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions 

#endif


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

    int N; cin >> N;
    vi B(N - 1); REP(i, N - 1) cin >> B[i];

    vi a(N);
    a[N-1] = B[N-2];
    for(int i=N-2; i>=1; i--) {
        a[i] = min(B[i-1], B[i]);
    }
    a[0] = B[0];

    int ans = 0;
    REP(i, N) ans += a[i];

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
a=int(input())
b=[]
for k in range(1,a+1):
	c=[]
	b.append(c)
	for i in range(a+1):
		if k%(2*i+1)==0:
			c.append(2*i+1)
#print(b)
d=0
for i in b:
	if len(i)==8:
		d=d+1
print(d)


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

int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n)
    {
        ll k;
        cin >> k;
        a[i] = k - 1 - i;
    }
    sort(a.begin(), a.end());
    int b = 0;
    b = a[n / 2];
    ll count = 0;
    rep(i, n)
    {
        count += labs(b - a[i]);
    }
    cout << count << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>          // printf(), getc()
#include <ctype.h>          // islower(), isupper()

int
main(int argc, char** argv)
{
	int x[26];
	int c;
	int i;

	for (i = 0; i < 26; ++i)
		x[i] = 0;

	c = getc(stdin);
	while (c != EOF)
	{
		if (isupper(c))
			x[c - 'A']++;
		else if (islower(c))
			x[c - 'a']++;

		c = getc(stdin);
	}

	for (i = 0; i < 26; ++i)
		printf("%c : %d\n", i + 'a', x[i]);

	return 0;
}

Measured memory_bytes: 524
#include <stdio.h>

int main(){
  int num;
  if(scanf("%d",&num)==1){}
  
  int front,back;
  front = num/100;
  back = num-front*100;
  
  int fj=0;
  int bj=0;//1なら1～12の間。0ならそれ以外
  int i;
  if(1<=front && front<=12){fj=1;}
  if(1<=back && back<=12){bj=1;}
  if(fj==1&&bj==1){
    printf("AMBIGUOUS");
  }else if(fj==1&&bj==0){
    printf("MMYY");
  }else if(fj==0&&bj==1){
    printf("YYMM");
  }else if(fj==0&&bj==0){
    printf("NA");
  }
  
  return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <tuple>

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define co(x) cout << (x) << "\n"
#define pb push_back
#define Never
#define To

using namespace std;

int main(){

	cin.tie(0);
	ios::sync_with_stdio(false);

	string S;

	cin >> S;

	bool ok = true;
	for(int i = 0; i < S.size(); i++){
		if( i % 2 == 0){
			if(S[i] != 'R' && S[i] != 'U' && S[i] != 'D') ok = false; 
		} else {
			if(S[i] != 'L' && S[i] != 'U' && S[i] != 'D') ok = false; 
		}
	}
	if(ok){
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	Never To return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=100010;
string s[N];
char ans[N];
ll n,a,b,c;
bool q;
int main()
{
	//freopen("in.txt","r",stdin);
	scanf("%lld %lld %lld %lld",&n,&a,&b,&c);
	for(ll i=1;i<=n;++i) cin>>s[i];
	if(a+b+c==0) printf("No\n");
	else if(a+b+c==2){
		q=true;
		for(int i=1;i<=n;++i){
			if(s[i]=="AC"){
				if(!a&&!c){
					q=false;
					break;
				}
				if(a==c){
					if(s[i+1]=="AB"){
						ans[i]='A';
						++a,--c;
					}
					else{
						ans[i]='C';
						++c,--a;
					}
				}
				else if(a>c){
					ans[i]='C';
					++c,--a;
				}
				else{
					ans[i]='A';
					++a,--c;
				}
			}
			else if(s[i]=="BC"){
				if(!b&&!c){
					q=false;
					break;
				}
				if(b==c){
					if(s[i+1]=="AC"){
						ans[i]='C';
						++c,--b;
					}
					else{
						ans[i]='B';
						++b,--c;
					}
				}
				else if(b>c){
					ans[i]='C';
					++c,--b;
				}
				else{
					ans[i]='B';
					++b,--c;
				}
			}
			else if(s[i]=="AB"){
				if(!b&&!a){
					q=false;
					break;
				}
				if(b==a){
					if(s[i+1]=="AC"){
						ans[i]='A';
						++a,--b;
					}
					else{
						ans[i]='B';
						++b,--a;
					}
				}
				else if(b>a){
					ans[i]='A';
					++a,--b;
				}
				else{
					ans[i]='B';
					++b,--a;
				}
			}
		}
		if(q){
			printf("Yes\n");
			for(ll i=1;i<=n;++i){
				switch(ans[i]){
					case 'A' : printf("A\n");break;
					case 'B' : printf("B\n");break;
					case 'C' : printf("C\n");break;
				}
			}
		}
		else printf("No\n");
	}
	else{
		q=true;
		for(ll i=1;i<=n;++i){
			if(s[i]=="AC"){
				if(a>c){
					ans[i]='C';
					++c,--a;
				}
				else{
					ans[i]='A';
					++a,--c;
				}
			}
			else if(s[i]=="BC"){
				if(b>c){
					ans[i]='C';
					++c,--b;
				}
				else{
					ans[i]='B';
					++b,--c;
				}
			}
			else if(s[i]=="AB"){
				if(b>a){
					ans[i]='A';
					++a,--b;
				}
				else{
					ans[i]='B';
					++b,--a;
				}
			}
			if(a<0||b<0||c<0){
				q=false;
				break;
			}
		}
		if(q){
			printf("Yes\n");
			for(ll i=1;i<=n;++i){
				switch(ans[i]){
					case 'A' : printf("A\n");break;
					case 'B' : printf("B\n");break;
					case 'C' : printf("C\n");break;
				}
			}
		}
		else printf("No\n");
	}
}

Measured memory_bytes: 6892
//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);
const long double PI=3.14159265358979;

// Required random number generators

// mt19937 gen_rand_int(chrono::steady_clock::now().time_since_epoch().count());
// mt19937_64 gen_rand_ll(chrono::steady_clock::now().time_since_epoch().count());

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

int main()
{
    #ifndef ONLINE_JUDGE
    if (fopen("INPUT.txt", "r"))
    {
        freopen ("INPUT.txt" , "r" , stdin);
        //freopen ("OUTPUT.txt" , "w" , stdout);
    }
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    clock_t clk;
    clk = clock();
//-----------------------------------------------------------------------------------------------------------//

    ll mx=0;
    ll ans=0;
    READV(N);
    FORI(i,0,N)
    {
        READV(x);
        if(x<mx)
        {
            ans+=mx-x;
        }
        else
        {
            mx=x;
        }
    }
    cout<<ans<<endl;

//-----------------------------------------------------------------------------------------------------------//


    clk = clock() - clk;
    cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << endl;

    return 0;
}

Measured memory_bytes: 3804
#include <cmath>
#include <cstdio>
#include <algorithm>

using namespace std;

int a[]={0,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main()
{
    int n;
    scanf("%d",&n);
    printf("%d",a[n]);
    return 0;
}


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

#define ll long long
#define ull unsigned long long
#define pb push_back
#define pf push_front
#define pof pop_front
#define pob pop_back
#define mp make_pair
#define pll pair<ll,ll>
#define pii pair<int,int>
#define all(s) s.begin(),s.end()
#define vll vector<ll>
#define vi vector<int>
#define vpii vector<pii>
#define vpll vector<pll>
#define vd vector<double>
#define vull vector<ull>
#define vc vector<char>
#define vs vector<string>
#define fi first
#define se second
#define sz(x) x.size()
#define cinarr(n,a) for(int i = 0; i < n; i++) cin >> a[i];
#define coutarr(n,a) for(int i = 0; i < n; i++) cout << a[i] << (i+1==n?'\n':' ');
#define fori(i,a,b,x) for(int i = a; i <= b; i+=x)
#define ford(i,a,b,x) for(int i = a; i >= b; i-=x)
#define tc int tt; cin >> tt; for(int cs = 1; cs <= tt; cs++)
#define IOS ios_base::sync_with_stdio(0); cin.tie(NULL);
#define ld long double
#define reset(x,y) memset(x,y,sizeof x);
#define sqr(x) 1LL*(x)*(x)
#define cube(x) 1LL*(x)*(x)*(x)
#define ub(v, a) upper_bound(all(v), a)
#define lb(v, a) lower_bound(all(v), a)
#define EPS 1e-10
#define INF 200000
#define mod 1000000007
#define minof(a) min_element(all(a))
#define maxof(a) max_element(all(a))
#define debug(val) cout << "The value of " << #val << " is = " << val << endl;
#define testing cout << "--------------------------\n";

ll n,q,last[500005],a[500005],fen[500005],ans[500005];
pair<pll,ll> qr[500005];

void upd(ll x, ll v) {
	for(;x<=n;x+=(x&-x)) {
		fen[x]+=v;
	}
}

ll qry(ll x) {
	ll ret=0;
	for(;x;x-=(x&-x)) {
		ret+=fen[x];
	}
	return ret;
}

int main() {
	IOS
	reset(last,-1);
	cin>>n>>q;
	for(int i = 1; i <= n; i++) {
		cin>>a[i];
	}
	for(int i = 0; i < q; i++) {
		cin>>qr[i].fi.se>>qr[i].fi.fi;
		qr[i].se=i;
	}
	sort(qr,qr+q);
	ll idx=0;
	for(int i = 1; i <= n; i++) {
		if(last[a[i]]!=-1) upd(last[a[i]],-1);
		last[a[i]]=i;
		upd(i,1);
		while(qr[idx].fi.fi==i) {
			ans[qr[idx].se]=qry(qr[idx].fi.fi)-qry(qr[idx].fi.se-1);
			idx++;
		}
	}
	for(int i = 0; i < q; i++) {
		cout<<ans[i]<<endl;
	}
}


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

using namespace std;

const int maxn = 1e2 + 5;
const int inf = 1e9 + 5;

inline int read() {
	char ch = getchar(); int u = 0, f = 1;
	while(!isdigit(ch)) {if(ch == '-') f = -1; ch = getchar();}
	while(isdigit(ch)) {u = u * 10 + ch - 48;  ch = getchar();} return u * f;
}

int n, a[maxn], ave, ans0, ans1;

int main() {
	n = read();
	for(register int i = 1; i <= n; i++)
		ave += (a[i] = read());
	ave /= n;
	
	for(register int i = 1; i <= n; i++) {
		ans0 += (a[i] - ave) * (a[i] - ave);
		ans1 += (a[i] - (ave + 1)) * (a[i] - (ave + 1));
	} cout << min(ans0, ans1);
	return 0;
}

Measured memory_bytes: 256