akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cstdlib>
using namespace std;
#define N 200050
#define mod 1000000007
typedef long long ll;
ll f[N],s[N];
int n,V[N],L[N],R[N];
struct A {
	int x,v;
	bool operator < (const A &p) const {return x<p.x;}
}a[N];
int main() {
	scanf("%d",&n);
	int i,k=1;
	for(i=1;i<=n;i++) scanf("%d%d",&a[i].x,&a[i].v),V[i]=a[i].v;
	sort(V+1,V+n+1);
	for(i=1;i<=n;i++) a[i].v=lower_bound(V+1,V+n+1,a[i].v)-V;
	sort(a+1,a+n+1);
	for(R[0]=0,i=1;i<=n;i++) R[i]=max(R[i-1],a[i].v);
	for(L[n+1]=n+1,i=n;i;i--) L[i]=min(L[i+1],a[i].v);
	for(f[0]=s[0]=1,i=1;i<=n;i++) {
		int l=L[i],r=R[i];
		for(;k<=r;k++) s[k]=s[k-1];  
		if(l>1) f[r]=(f[r]+s[r]-s[l-2]+mod)%mod;
		else f[r]=(f[r]+s[r])%mod;
		s[r]=(s[r-1]+f[r])%mod;
	}
	printf("%lld\n",(f[n]%mod+mod)%mod);
}


Measured memory_bytes: 7168
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int a[105];
int b[105];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n-1;i++)
	{
		scanf("%d",&b[i]);
	}
	a[0]=b[0];
	int sum=b[0];
	for(int i=0;i<n-1;i++)
	{
		if(i!=n-2)
		{	
		a[i+1]=min(b[i],b[i+1]);
		sum+=a[i+1];
		}
		else
		{
		a[i+1]=b[i];
		sum+=a[i+1];
		}
	}
	printf("%d",sum);
}

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

int main() {
  int n;
  cin>>n;
  ll ans=0;
  rep(i,n){
    int a;
    cin>>a;
    ans+=a-1;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin >> n >> k;

    vector<int> d(k);
    for (int i = 0; i < k; i++)
    {
        cin >> d[i];
    }
    
    int ans = n;
    int i;
    while (1)
    {
        string anss = to_string(ans);
        vector<int> bucket(10, 0);
        for ( i = 0; i < anss.size(); i++)
        {
            bucket[anss[i] - '0']++;
        }
        for (i = 0; i < k; i++)
        {
            if(bucket[d[i]] != 0)break;
        }
        
        if(i == k)break;
        ans++;
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdio>
using namespace std;
int main(){
	string str;
	getline(cin,str);
	str += " ";
    vector<string> word;
    int j = 0;
    for(int i = 0; i < str.size(); i++){
        if(str[i] == ' ' || str[i] == ',' || str[i] == '.'){
            if(3 <= i-j && i-j <= 6){
                word.push_back(str.substr(j,i-j));
            }
            j = i + 1;
        }
    }
    for(int i = 0; i < word.size(); i++){
        cout << word[i];
        printf("%c",i==word.size()-1?'\n':' ');
    }
	return 0;
}

Measured memory_bytes: 1184
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	string S;
	cin >> S;
	int dp[100010][2] = { 0 };
	dp[0][0] = 1;
	REP(i, S.size()) {

		if (S[i] == '0') {
			dp[i + 1][0] = dp[i][0];
			dp[i + 1][1] = dp[i][1];
		}
		else {
			dp[i + 1][1] += (dp[i][0] + dp[i][1]) % mod;
		}

		if (S[i] == '0') {
			dp[i + 1][1] += dp[i][1] * 2 % mod;
		}
		else {
			dp[i + 1][0] += dp[i][0] * 2 % mod;
			dp[i + 1][1] += dp[i][1] * 2 % mod;
		}

	}
	int ans = (dp[S.size()][0] + dp[S.size()][1]) % mod;
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 2000
#include <bits/stdc++.h>    
using namespace std;
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define show(x) cout<<(#x)<<" : "<<x<<endl;
#define ll  long long
#define ld  long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endl "\n"
#define int long long 
const ll MOD     = 1000*1000*1000+7;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7;
const ll MOD2    = 998244353;
const ll N          = 1000*100+5;
const ll N2      = 2000*1000*10;
const ld PI  = 3.14159265;
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);} 
ll power(ll x,ll y,ll p = INF){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;} 
signed main()
{
    fastio();
    //cout<<fixed<<setprecision(20);
    //CHECK for LONG LONG and LONG DOUBLE
    /*comment for all except cc/cf    
    #ifndef ONLINE_JUDGE
           freopen("input.txt","r",stdin);
           freopen("output.txt","w",stdout);
    #endif//*/ 
    char c;
    cin>>c;
    int dum = c;
    dum++;
    cout<<char(dum);
    return 0;
}

Measured memory_bytes: 384
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

ans = 0
for i in range(n):
    if a[i] <=  b[i]:
        ans += a[i]
        b[i] -= a[i]
    else:
        ans += b[i]
        b[i] = 0
    if b[i] > 0:
        if a[i+1] > b[i]:
            ans += b[i]
            a[i+1] -= b[i]
        else:
            ans += a[i+1]
            a[i+1] = 0
print(ans)

Measured memory_bytes: 18476
#include <iostream>
#include <cmath>

using namespace std;


int main() {

	int n;
	cin >> n;
	
	int* r = new int[n];

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

	int min = r[0];
	int res = r[1] - r[0];

	for (int i = 1; i < n; i++)	{

		if (r[i] - min > res) res = r[i] - min;
		if (min > r[i]) min = r[i];

	}

	cout << res << endl;

	delete[] r;
	return 0;
}



Measured memory_bytes: 3620
#include<iostream>
using namespace std;
int main(){
	int p;
	int a;
	int b;
	int c;
	int d;
	int x=0;
	int y=0;
	cin>>a;
	cin>>b;
	cin>>c;
	cin>>d;
	cin>>p;
	x=a*p;
	if(p<c){
		y=b;
	}else{
		y=b+(p-c)*d;
	}
	if(x<y){
		y=x;
	}
	cout<<y<<endl;
}
	

Measured memory_bytes: 3104
import math

H,W = [int(x) for x in input().split()]
N = int(input())
a = [int(x) for x in input().split()]
li = []
for ind,i in enumerate(a):
    for j in range(i):
        li.append(ind+1)
prt = ''
for ind,i in enumerate(li):
    if(math.floor(ind/W)%2 == 0):
        prt+=str(i)+' '
        if(ind%W==W-1):
            prt=prt[:-1]
            print(prt)
            prt=''
    else:
        prt=' '+str(i)+prt
        if(ind%W==W-1):
            prt=prt[1:]
            print(prt)
            prt=''

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

int dp[100000];
int n,m;
vector<int> adj[100000];
bool vis[100000];
int ans = 0;

int dfs(int a){
    
    if(vis[a]) return dp[a];
    vis[a]=1;
    if(adj[a].size()==0){
        dp[a]=0;
        return 0;
    }

    int d = 0;

    for(int i=0;i<adj[a].size();i++){
        d = max(d,dfs(adj[a][i]));
    }

    dp[a]=d+1;
    return dp[a];
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	
    cin>>n>>m;

    memset(dp,0,sizeof(dp));

    for(int i=0;i<n;i++) adj[i].clear();

    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        a--;b--;
        adj[a].push_back(b);
    }

    for(int i=0;i<n;i++){
        if(!vis[i])ans=max(ans,dfs(i));
    }

    cout<<ans;
}

Measured memory_bytes: 11524
#include <bits/stdc++.h>
#define vi vector<int>
#define Vi vector<vector<int>>
#define ll long long
#define P pair<int,int>
#define vp  vector<P>
#define mod 1000000009
using namespace std;
int main(){
	string S;
	cin>>S;
	deque<char>Q;
	for(char i:S)
		Q.push_back(i);
	int t;
	cin>>t;
	int flag=0;
	while(t--){
		int t1;
		cin>>t1;
		if(t1==1){
			flag=(1+flag)%2;
		}else{
			int f1;
			char c;
			cin>>f1>>c;
			if((f1==1 && flag==0) || (f1==2 && flag==1)){
				Q.push_front(c);
			}else{
				Q.push_back(c);
			}
		}
	}
	string ans="";
	for(auto i=Q.begin();i!=Q.end();i++)
		ans+=(*i);
	if(flag)
		reverse(ans.begin(),ans.end());
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1412
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    lis = []
    c = []
    rev = []
    for _ in range(n):
        a,b = input().split()
        b = int(b)
        a = list(a)
        lis.append(a)
        rev.append(a[::-1])
        c.append(b)
    res = defaultdict(lambda : float("inf"))
    q = [(0,[],[])]
    res[(tuple(),tuple())] = 0
    while q:
        d,pre,suf = heappop(q)
        ns = pre+suf[::-1]
        if ns != [] and ns == ns[::-1]:
            print(d)
            return
        if len(pre) <= len(suf):
            k = suf[len(pre):]
            for i in range(n):
                s = lis[i]
                m = min(len(s),len(k))
                if k[:m] == s[:m]:
                    npre = pre+s
                    re = d+c[i]
                    i = tuple(npre)
                    j = tuple(suf)
                    if re < res[(i,j)]:
                        res[(i,j)] = re
                        heappush(q,(re,npre,suf))
        else:
            k = pre[len(suf):]
            for i in range(n):
                s = rev[i]
                m = min(len(s),len(k))
                if k[:m] == s[:m]:
                    nsuf = suf+s
                    re = d+c[i]
                    i = tuple(pre)
                    j = tuple(nsuf)
                    if re < res[(i,j)]:
                        res[(i,j)] = re
                        heappush(q,(re,pre,nsuf))
    print(-1)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 80404
// C++ program to illustrate Edge Coloring 
#include <iostream>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <assert.h>
#include <memory.h>
#include <time.h>
#include <bitset>
using namespace std; 
  
// function to determine the edge colors 
void colorEdges(int ptr, vector<vector<pair<int, int> > >& gra, 
                vector<int>& edgeColors, bool isVisited[]) 
{ 
    queue<int> q; 
    int c = 0; 
  
    set<int> colored; 
  
    // return if isVisited[ptr] is true 
    if (isVisited[ptr]) 
        return; 
  
    // Mark the current node visited 
    isVisited[ptr] = 1; 
  
    // Traverse all edges of current vertex 
    for (int i = 0; i < gra[ptr].size(); i++) { 
        // if already colored, insert it into the set 
        if (edgeColors[gra[ptr][i].second] != -1) 
            colored.insert(edgeColors[gra[ptr][i].second]); 
    } 
  
    for (int i = 0; i < gra[ptr].size(); i++) { 
        // if not visited, inset into the queue 
        if (!isVisited[gra[ptr][i].first]) 
            q.push(gra[ptr][i].first); 
  
        if (edgeColors[gra[ptr][i].second] == -1) { 
            // if col vector -> negative 
            while (colored.find(c) != colored.end()) 
  
                // increment the color 
                c++; 
  
            // copy it in the vector 
            edgeColors[gra[ptr][i].second] = c; 
  
            // then add it to the set 
            colored.insert(c); 
            c++; 
        } 
    } 
  
    // while queue's not empty 
    while (!q.empty()) { 
        int temp = q.front(); 
        q.pop(); 
  
        colorEdges(temp, gra, edgeColors, isVisited); 
    } 
  
    return; 
} 
  
// Driver Function 
int main() 
{ 
    set<int> empty; 
  
    // declaring vector of vector of pairs, to define Graph 
    vector<vector<pair<int, int> > > graph; 
  
    vector<int> edgeColors; 
  
    bool isVisited[100000] = { 0 }; 
    int n;
    cin>>n;
    int i,a[n],b[n];

    // Enter the Number of Vertices 
    // and the number of edges 
    
  
    graph.resize(n); 
    edgeColors.resize(n-1, -1); 
   for(i=0;i<n-1;i++)
   
   {cin>>a[i]>>b[i];
    graph[a[i]-1].push_back(make_pair(b[i]-1, i)); 
    graph[b[i]-1].push_back(make_pair(a[i]-1, i)); 
   }
    // Enter edge & vertices of edge 
    // x--; y--; 
    // Since graph is undirected, push both pairs 
    // (x, y) and (y, x) 
    // graph[x].push_back(make_pair(y, i)); 
    // graph[y].push_back(make_pair(x, i)); 
    
  
    colorEdges(0, graph, edgeColors, isVisited); 
    int max=0;
    for(i=0;i<n-1;i++){
        if(max<edgeColors[i] + 1){
            max=edgeColors[i] + 1;
        }
    }
    cout<<max<< "\n";
    // printing all the edge colors 
    for (int i = 0; i < n-1; i++) {
        cout << edgeColors[i] + 1 << "\n"; 
    }
  
    return 0; 
} 

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

using namespace std;

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

  vector<int> h;
  for (int i = 1; i <= n; i++) {
    int a;
    cin >> a;
    h.push_back(a);
  }

  // for (int i = 0; i < n; i++) {
  //   cout << h[i] << " ";
  // }
  //
  // return 0;

  bool notFinished = true;
  int result = 0;
  while (notFinished) {
    notFinished = false;
    bool zState = true;

    for (int i = 0; i < n; i++) {
      if (zState) {
        if (h[i] == 0) {
          // do nothing
        } else {
          zState = false;
          result++;
          notFinished = true;
          h[i]--;
        }
      } else {
        if (h[i] == 0) {
          zState = true;
        } else {
          h[i]--;
        }
      }
    }
  }

  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int MOD = 1000000007;
typedef long long ll;

template<typename T> void print(const T & v);


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

    int N;
    cin >> N;
    vector<int> p(N);
    rep(i, N) cin >> p[i];
    vector<int> cp = p;
    int cnt1 = 0;
    for(int i = 0; i < N - 1; i++){
        if(p[i] == (i + 1)){
            swap(p[i], p[i + 1]);
            cnt1++;
        }
    }
    if(p[N - 1] == N) cnt1++;
    int cnt2 = 0;
    for(int i = N - 1; i > 0; i--){
        if(cp[i] == (i + 1)){
            swap(cp[i], cp[i - 1]);
            cnt2++;
        }
    }
    if(cp[0] == 1) cnt2++;
    cout << min(cnt1, cnt2) << endl;
    return 0;
}


// Use For Debug
template <typename T>
void print(T const & v){
    for(int i = 0; i < v.size(); i++){
        if(i) cout << " ";
        cout << v[i];
    }
    cout << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
long long fac(ll a){
    long long ans=1;
    while(a>1){
        ans*=a;
        ans%=1000000007;
        a--;
    }
    return ans;
}
int main(){
    ll n;cin >> n;
    ll a = sqrt(n);
    ll ans=INF;
    for(int i=1;i<=a;i++){
        if(n%i==0){
            ll b=i,c=n/i,coub=0,couc=0;
            while(b>0){
                b/=10;coub++;
            }
            while(c>0){
                c/=10;couc++;
            }
            ans = min(ans,max(coub,couc));
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#include<bits/stdc++.h>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ll long long
#define ld long double
#define all(a) a.begin(),a.end()
#define endl '\n'
#define ull unsigned long long
#define y1 ljhadglkjsadf
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define iter set<int>::iterator
#define iter1 set<int>::iterator
#define int long long
using namespace std;
using namespace __gnu_pbds;

template<class T>
using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

template<class T>
using ordered_multiset=tree<T,null_type,less_equal<T>,rb_tree_tag,tree_order_statistics_node_update>;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rnd1(chrono::steady_clock::now().time_since_epoch().count());

//find_by_order
//order_of_key

const int N=2e5+7;
const int inf=1e18+1e9;
const int mod=1e9+7;
const ld eps=1e-9;

//const int MAX_MEM=4e8;
//int mpos=0;
//char mem[MAX_MEM];
//
//inline void * operator new(size_t n){
//    char *res=mem+mpos;
//    mpos+=n;
//    if (mpos>=MAX_MEM){
//        cout<<"BAD"<<endl;
//        exit(0);
//    }
//    return (void*)res;
//}
//
//inline void operator delete(void *) {}

main ()
{
    ios;
    string s;
    cin>>s;
    int ans=0;
    int kol=0;
    for (int i=0;i<s.size();++i){
        if (s[i]=='B')++kol;
        else {
            ans+=kol;
        }
    }
    cout<<ans<<endl;
}
//1
//3 15
//1 4
//3 5


Measured memory_bytes: 3748
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
        String A = scan.next();
        String B = scan.next();
        String C = scan.next();
        
        if(A.charAt(A.length()-1)==B.charAt(0)&&B.charAt(B.length()-1)==C.charAt(0)){
        	System.out.println("YES");
        }else{
        	System.out.println("NO");
        }
	}
}

Measured memory_bytes: 23636
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████   
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████  
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
const double EPS = 1e-9;
#define INF (1LL<<60)
#define fs first
#define sc second
#define pb push_back
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<vector<P> > Graph;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int n;
  cin >> n;

  vec a(n);
  REP(i,n) cin >> a[i];
  
  int ans = 1, cur = 0;
  REP(i,n){
    cur++;
    if(a[i] <= (cur-1)*2){
      ans *= cur;
      ans %= MOD;
      cur--;
    }
  }

  while(cur){
    ans *= cur;
    ans %= MOD;
    cur--;
  }

  cout << ans << endl;

  return 0;
}

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

#define rep(i, s, n) for (Int i = s; i < (Int)(n); i++)
#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

 
double EPS = 1e-8;
Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

Int n;
bool dp[1<<16];
double r[20], sx[20], sy[20], tx[20], ty[20];

typedef complex<double> P;
// 内積 (dot product) : a・b = |a||b|cosΘ
double dot(P a, P b) {
  return (a.real() * b.real() + a.imag() * b.imag());
}
// 外積 (cross product) : a×b = |a||b|sinΘ
double cross(P a, P b) {
  return (a.real() * b.imag() - a.imag() * b.real());
}
// 点a,bを端点とする線分と点cとの距離
double distance_ls_p(P a, P b, P c) {
  if ( dot(b-a, c-a) < EPS ) return abs(c-a);
  if ( dot(a-b, c-b) < EPS ) return abs(c-b);
  return abs(cross(b-a, c-a)) / abs(b-a);
}

bool f(Int x, Int p) {
    bool check = true;
    rep(i, 0, n) {
        if (i == p) continue;
        P a(sx[p], sy[p]);
        P b(tx[p], ty[p]);
        P c;
        if (x & (1<<i)) {
            c.real(tx[i]);
            c.imag(ty[i]);
        } else {
            c.real(sx[i]);
            c.imag(sy[i]);
        }
        if (distance_ls_p(a, b, c) <= r[i] + r[p] + EPS) {
            check = false;
        }
    }
    return check;
}

void rec(Int x) {
    dp[x] = true;
    rep(i, 0, n) {
        if (x & (1<<i)) continue;
        if (f(x, i) and not dp[x | (1<<i)]) {
            //cout << x << " " << i << endl;
            dp[x | (1<<i)] = true;
            rec(x | (1<<i));
        }
    }
}

int main() {
    cin >> n;
    rep(i, 0, n) cin >> r[i] >> sx[i] >> sy[i] >> tx[i] >> ty[i];
    rec(0);
    Int res = 0;
    rep(bit, 0, 1<<n) {
        Int cnt = 0;
        rep(i, 0, n) {
            if (bit & (1<<i)) {
                cnt++;
            }
        }
        if (dp[bit]) {
            res = max(res, cnt);
        }
    }
    dump(res);
    return 0;
}


Measured memory_bytes: 3344
package main

import "fmt"

func main() {
	var S string
	fmt.Scan(&S)
	check := map[rune]bool{}
	for _, s := range S {
		if _, exist := check[s]; exist {
			fmt.Println("no")
			return
		} else {
			check[s] = true
		}
	}
	fmt.Println("yes")
}


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

int main() {
    int N; cin >> N;
    cout << 0 << endl;
    string pres,s;
    int l,r,prei;
    l = N-1; r=0;
    cin >> pres;
    if(pres == "Vacant") return 0;
    else cout << N-1 << endl;
    cin >> s;
    if(s == "Vacant") return 0;
    else{
        cout << (l+r)/2 << endl;
    }
    prei = 0;
    for (int i = 0; i < 30; i++)
    {
        cin >> s;
        if(s == "Vacant") return 0;
        else if(s == pres){
            if(abs((l+r)/2-prei)%2 == 0){
                if(prei == r){
                    prei = (l+r)/2;
                    r = (l+r)/2;
                }else{
                    prei = (l+r)/2;
                    l = (l+r)/2;
                }
            }
            else{
                if(prei == r){
                    prei = (l+r)/2;
                    l = (l+r)/2;
                }else{
                    prei = (l+r)/2;
                    r = (l+r)/2;
                }
            }
        }
        else{
            if(abs((l+r)/2-prei)%2 == 0){
                if(prei == r){
                    prei = (l+r)/2;
                    l = (l+r)/2;
                }else{
                    prei = (l+r)/2;
                    r = (l+r)/2;
                }
            }
            else{
                if(prei == r){
                    prei = (l+r)/2;
                    r = (l+r)/2;
                }else{
                    prei = (l+r)/2;
                    l = (l+r)/2;
                }
            }      
        }
        pres = s;
        cout << (l+r)/2 << endl;
    }
    return -1;
}

Measured memory_bytes: 852
#include <iostream>

using namespace std;

int main(){
	int K, S;
	int sum = 0;

	cin >> K >> S;

	for(int i = 0; i <= K; i++){
		for(int j = 0; j <= K; j++){
			if((S - (i + j) >= 0) && ((S - (i + j) <= K))){
				sum++;
			}
		}
	}

	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c ;    
    cin>>a>>b>>c;
    if(a>b){
        swap(a,b);
    }
    if(b>c){
        swap(b,c);
    }
    if(a>b){
        swap(a,b);
    }
    cout<<a<<" "<<b<<" "<<c<<endl;
    }


Measured memory_bytes: 3104
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
 
using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " << i << std::endl
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}

template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
// const ll MOD = 998244353;
const ll MOD = 1e9 + 7;

ll pow_mod(ll a, ll b, ll mod=-1) {
  if ((a == 0)||(mod!=-1&&a%mod==0)) {
    return 0;
  }

  ll x = 1;

  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}

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

  ll n;
  std::cin>>n;

  std::vector<ll> l(n);
  rep(i,0,n)std::cin>>l[i];

  std::sort(all(l));

  ll ans=0;

  for(ll i=n-1;i>=0;i--){
    for(ll j=i-1;j>=0;j--){
      ll itr=(ll)(std::lower_bound(all(l),l[i]-l[j]+1)-l.begin());

      if(itr<j)ans+=j-itr;
    }
  }

  std::cout<<ans;
 
  return 0;
}

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

int main(void){
  double x1,y1,x2,y2;
  cin >> x1 >> y1;
  cin >> x2 >> y2;
  double d = pow(x1-x2, 2) + pow(y1-y2, 2);
  cout << fixed << setprecision(5) << sqrt(d);
  cout << endl;
}


Measured memory_bytes: 3276
import           Control.Applicative
import           Control.DeepSeq
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                    as A
import qualified Data.Array.IArray             as IA
import qualified Data.Array.IO                 as AI
import qualified Data.Array.MArray             as MA
import qualified Data.Array.ST                 as STA
import qualified Data.Array.Unboxed            as AU
import           Data.Bits
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import qualified Data.Graph                    as G
import           Data.Int
import qualified Data.IntMap                   as IM
import qualified Data.IntSet                   as IS
import           Data.List
import qualified Data.Map.Strict               as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Sequence                 as SQ
import qualified Data.Set                      as S
import           Data.Time
import qualified Data.Tree                     as T
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as VM
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM

readInt :: IO Int
readInt = fst . fromJust . BS.readInt <$> BS.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readIntLists :: Int -> IO [[Int]]
readIntLists n = replicateM n readInts

readInteger :: IO Integer
readInteger = fst . fromJust . BS.readInteger <$> BS.getLine

readIntegers :: IO [Integer]
readIntegers = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readIntegerLists :: Int -> IO [[Integer]]
readIntegerLists n = replicateM n readIntegers

readStrings :: IO [String]
readStrings = map BS.unpack . BS.words <$> BS.getLine

readStringLists :: Int -> IO [[String]]
readStringLists n = replicateM n <$> readStrings

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

count :: Eq a => a -> [a] -> Int
count a as = length $ filter (== a) as

put :: Show a => a -> IO ()
put = putStr . show

putList :: Show a => [a] -> IO ()
putList [n     ] = put n
putList (n : ns) = do
  put n
  putStr " "
  putList ns

putStrList :: [String] -> IO ()
putStrList [n     ] = putStr n
putStrList (n : ns) = do
  putStr n
  putStr " "
  putStrList ns

yesNoUpper b | b         = putStrLn "YES"
             | otherwise = putStrLn "NO"

yesNo b | b         = putStrLn "Yes"
        | otherwise = putStrLn "No"

divCeiling x n | b == 0    = a
               | otherwise = a + 1
  where (a, b) = x `divMod` n

main = do
  [n, p] <- readInts
  a      <- readInts
  print $ solve a p n

solve a p n | all even a = if p == 0 then 2 ^ n else 0
            | otherwise  = 2 ^ (n - 1)


Measured memory_bytes: 380
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define PI 3.14159265359
#define sz(c) (int)c.size()
#define len(c) (int)c.length()
#define hcf(a, b) __gcd(a, b)
#define all(c) c.begin(), c.end()
#define vint vector<int>
#define vll vector<ll>
#define vpint vector<pair<int, int>>
#define vpll vector<pair<ll, ll>>
#define fr(it, a, b) \
    for (int it = (a); it < (b); it++)
#define tr(con, it) \
    for (auto it = con.begin(); it != con.end(); it++)
#define present(con, ele) (con.find(ele) != con.end())
#define cpresent(con, ele) (find(all(con), ele) != con.end())
#define maximum(a, b, c) (a > b ? (a > c ? a : c) : (b > c ? b : c))
#define minimum(a, b, c) (a < b ? (a < c ? a : c) : (b < c ? b : c))
typedef long long ll;
typedef long double lf;
typedef pair<int, int> pi;
typedef unsigned long long lu;
const ll mod = 1e9 + 7, N = 1e5 + 5;
int32_t main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, q, sum = 0;
    cin >> n;
    vll a(N);
    fr(i, 0, n)
    {
        ll u;
        cin >> u;
        sum += u;
        a[u]++;
    }
    cin >> q;
    fr(i, 0, q)
    {
        ll u, v;
        cin >> u >> v;
        sum += (v - u) * a[u];
        a[v] += a[u];
        a[u] = 0;
        cout << sum << '\n';
    }
    return 0;
}

Measured memory_bytes: 3984
from collections import deque
n,m = map(int, input().split())


graph = [[] for _ in range(n+1)]
for i in range (m):
    a, b = map(int, input().split())
    graph[a].append(b)
    graph[b].append(a)

#print(graph)

dist = [-1]*2 + [0 for i in range (n-1)]
dist[1] = 0
d = deque([1])
#print(d)

while d:
    v = d.popleft()
    for i in graph[v]:
        if dist[i] == 0:
            dist[i] = v
            d.append(i)
            #print(i ," " ,dist[i], d)
            

print("Yes")
ans = dist[2:]
print(*ans, sep="\n")

Measured memory_bytes: 36300
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
//#include <algorithm>
#include <utility>
//#include <set>
#include <map>
#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll n ; cin >> n ;
	vvll g(n*(n-1)/2,vll(0)) ;
	map<pll,ll> m ;
	ll sub = 0 ;
	for(int i=1;i<=n-1;i++){
		for(int j=i+1;j<=n;j++){
			m[{i,j}] = sub ;
			sub++ ;
		}
	}
	vll cnt(n*(n-1)/2,0) ;
	for(int i=1;i<=n;i++){
		ll pre ; cin >> pre ;
		for(int j=1;j<n-1;j++){
			ll cur = i ;
			ll a ; cin >> a ;
			g.at(m[{min(pre,cur),max(pre,cur)}]).emplace_back(m[{min(cur,a),max(cur,a)}]) ;
			cnt.at(m[{min(cur,a),max(cur,a)}])++ ;
			pre = a ;
		}
	}
	vll d(n*(n-1)/2,-1) ;
	queue<ll> q ;
	for(int i=0;i<cnt.size();i++){
		if(cnt.at(i)==0){
			d.at(i) = 1 ;
			q.push(i) ;
		}
	}
	if(q.empty()){
		cout << -1 << endl ;
		return 0 ;
	}
	while(!q.empty()){
		ll p = q.front() ;
		q.pop() ;
		for(int i=0;i<g.at(p).size();i++){
			d.at(g.at(p).at(i)) = d.at(p)+1 ;
			cnt.at(g.at(p).at(i))-- ;
			if(cnt.at(g.at(p).at(i))==0) q.push(g.at(p).at(i)) ;
		}
	}
	ll ans = 0 ;
	for(int i=0;i<d.size();i++){
		if(d.at(i)==-1){
			cout << -1 << endl ;
			return 0 ;
		}
		ans = max(ans,d.at(i)) ;
	}
	cout << ans << endl ;
//	for(int i=0;i<g.size();i++){
//		for(int j=0;j<g.at(i).size();j++){
//			cout << g.at(i).at(j) << " " ;
//		}
//		cout << endl ;
//	}
//	for(auto p:m){
//		cout << p.first.first << " " << p.first.second << " " << p.second << endl ;
//	}
}


Measured memory_bytes: 66688
#include<bits/stdc++.h>
#define watch(x) cout<<(#x)<<" is "<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define pb push_back
#define pq priority_queue
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define elif else if

using namespace std;
using ll=long long;
using ull=unsigned long long;
using ld=long double;
using pll=pair<ll,ll>;
using pss=pair<string,string>;
using pdd=pair<ld,ld>;
using graph=vector<vector<int>>;
using wgraph=vector<vector<pll>>;

const ll MOD=1000000007;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int ex[8]={1,1,0,-1,-1,-1,0,1};
const int ey[8]={0,1,1,1,0,-1,-1,-1};
const ld E=1e-9;

template<class T> void chmin(T &a, T b){a=min(a, b);}
template<class T> void chmax(T &a, T b){a=max(a, b);}

ll abs1(ll a){if(a>=0)return a;else return -a;}
ll pow1(ll a,ll b,ll p=LLONG_MAX){
  ll ret=1;
  while(b!=0){
    if((b&1)==1)ret*=a;
    a*=a;
    if(a>=p)a%=p;if(ret>=p)ret%=p;
    b=b>>1;
  }
  return ret;
}
int digit(ll a,ll b=10){int i=0;while(a!=0){a/=b;i++;}return i;}
ll gcd1(ll a,ll b){
  if(a==0 || b==0)return 0;
  ll n;while(a%b!=0){n=a%b;a=b;b=n;}return b;
}
ll solveLinear(ll n,ll m,ll c){
  if(n==0 && m==0)return 0;
  ll a[100],b[100];a[0]=n;b[0]=m;int i=1;
  while(b[i-1]!=0){a[i]=b[i-1];b[i]=a[i-1]%b[i-1];i++;}
  n=i;if(c%a[n-1]!=0)return 0;
  ll x=c/a[n-1],y=0;
  for(i=1;i<n;i++){ll cnt=x;x=y;y=cnt-(a[n-i-1]/b[n-i-1])*y;}
  return x;
}
ll modRev(ll a,ll p=MOD){
  a%=p;ll n=solveLinear(a,p,1);
  n%=p;if(n<0)return n+p;
  return n;
}
ll fact(ll n,ll p=MOD){
  if(n<0)return 0;
  ll ret=1;
  for(int i=1;i<=n;i++){ret=ret*i;if(ret>=p)ret%=p;}
  return ret;
}
ll perm(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  ll ret=1;
  rep(i,k){ret=ret*(n-i);if(ret>=p)ret%=p;}
  return ret;
}
ll binom(ll n,ll k,ll p=MOD){
  return (perm(n,k,p)*modRev(fact(k)))%p;
}
int bis(vector<int> v,int key){
  int left=-1,right=v.size();
  while(abs1(right-left)>1){
    int mid=left+(right-left)/2;
    if(v[mid]<=key)left=mid;
    else right=mid;
  }
  return left;
}

int main(){
  int i,j,k,cnt=0;
  string s,t="";
  cin>>s;
  rep(i,s.size()){
    t+=s[s.size()-1-i];
  }
  rep(i,t.size()){
    if(t[i]=='b')t[i]='d';
    elif(t[i]=='d')t[i]='b';
    elif(t[i]=='p')t[i]='q';
    elif(t[i]=='q')t[i]='p';
  }
  if(s==t)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


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

int main(){
    int n;
    cin >> n;
    ll res = 0;
    ll ans1 = 0;
    ll ans2 = 0;
    vector<int> a(n);
    rep(i,n){
        cin >> a[i];
        res += a[i];
    }
    res /= n;
    rep(i,n){
        int s = abs(a[i] - res);
        ans1 += s*s;
    }
    rep(i,n){
        int s = abs(a[i] - res - 1);
        ans2 += s*s;
    }
    cout << min(ans1,ans2) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
int main()
{
    ft
    ll t,i,j,n,m,l,r;
    cin>>n>>m;
    ll a[n+2],d[n+2];
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    d[1]=0;
    for(i=2;i<=n;i++)
    {
        d[i]=LLONG_MAX;
        for(j=1;j<=m;j++)
        {
            if((i-j)>0)
            {
                d[i]=min(d[i],abs(a[i]-a[i-j])+d[i-j]);
            }
        }
    }
    cout<<d[n]<<"\n";
    return 0;
}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define DISP1(as)		for(auto it : as) cout<<it.f<<" "<<it.s<<") ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	2e+5 + 99;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, k, l, q, x, y;
string s,t;
ll prime[2000000];

// < ----------- func eh ---------------- ? //

void PRIME() {
	for (ll i = 0; i <= 1000000; i++) {
		prime[i] = i;
	}

	for (ll i = 4; i <= 1000000; i += 2) {
		prime[i] = 2;
	}

	for (ll i = 3; i <= 1000000; i += 2) {
		if (prime[i] == i) {
			for (ll j = i * i; j <= 1000000; j += i) {
				if (prime[j] == j) prime[j] = i;
			}
		}
	}
}

// <------------- Start of main() -------------------> //

void MAIN() {
	cin>>x;
	while(1) {
		if(prime[x] == x) {
			cout<<x;
			return;
		}
		x++;
	}
}

int main() {
	fastio; randomINT;
	PRIME();
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}


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

int main() {
  string S;
  cin >>S;
  int N = S.size() ;
  string A = S;
  reverse(A.begin(),A.end());
  string B = S.substr((N + 1) / 2) ;
  string C = B;
    reverse(C.begin(),C.end());
  
  if(S == A && B == C){
	cout << "Yes" <<endl;
  }
  else {
    cout << "No" <<endl;
  }
  
}


Measured memory_bytes: 256
import sys
from collections import deque
import bisect
import copy
import heapq
import itertools
import math
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


def main():
    N, M = read_values()
    F = [set() for _ in range(N)]
    T = set(i for i in range(N))
    for _ in range(M):
        L, R, D = read_values()
        L -= 1
        R -= 1
        F[L].add((R, D))
        T.discard(R)
    C = [-1] * N
    for t in T:
        S = deque()
        S.append(t)
        C[t] = 0
        while S:
            p = S.popleft()
            for q, d in F[p]:
                if C[q] == -1:
                    S.append(q)
                    C[q] = C[p] + d
                    continue
                if C[p] + d != C[q]:
                    print("No")
                    return
    if C.count(-1) > 0:
        print("No")
    else:
        print("Yes")


if __name__ == "__main__":
    main()


Measured memory_bytes: 113484
#include <bits/stdc++.h>
using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

using ll = long long;
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define tc() int t; cin>>t; while(t--)
#define print(n) cout<<n<<"\n"
#define inp(n) int n; cin>>n
#define all(cont) cont.begin(), cont.end()
#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define mp make_pair
#define pb push_back
#define maxn 1000010
#define mod 1e9+7
#define ff  first
#define ss  second
#define fora(var, start, end) for(int var = start; var < end; var++)
int main()
{
    fast();
    ll k,n;
    cin>>k>>n;
    if(n>k*500)print("No");
    else print("Yes");
    return 0;
}

Measured memory_bytes: 256
from itertools import permutations
def warshal_floyd(weights,N):
    d=weights
    for i in range(N):
        d[i][i]=0
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i][j]=min(d[i][j],d[i][k]+d[k][j])
    return d

if __name__ == '__main__':
    N,M,R=list(map(int,input().split()))
    cities=[r-1 for r in list(map(int,input().split()))]
    weights=[[1e10 for i in range(N)] for j in range(N)]
    for i in range(M):
        a,b,c=list(map(int,input().split()))
        a-=1
        b-=1
        weights[a][b]=c
        weights[b][a]=c

    d=warshal_floyd(weights,N)
    mini_count=1e12
    for c in permutations(cities):
        count=sum(d[i][j] for i,j in zip(c,c[1:]))
        mini_count=min(mini_count,count)
    print(mini_count)


Measured memory_bytes: 60248
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int INF = 0x3f3f3f3f;
const ll inf = 0x3f3f3f3f3f3f3f3f;
const int N = 5e5 + 10;
const ll mod = 1e9 + 7;
int n;
ll a[N], sum[N], ans;
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)scanf("%lld", &a[i]);
	for (int i = n; i >= 1; i--)sum[i] = (sum[i + 1] + a[i]) % mod;
	for (int i = 1; i <= n; i++)ans = (ans + a[i] * sum[i + 1] % mod) % mod;
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 6964
n,m,c = map(int, input().split())
bl = list(map(int, input().split()))

ans = 0
for _ in range(n):
    al = list(map(int, input().split()))
    v = 0
    for a,b in zip(al,bl):
        v += a*b
    v+=c
    if v > 0: ans += 1

print(ans)

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

const int A = 0, G = 1, C = 2, T = 3;

bool check(int i, int j, int k, int l) {
    bool f = true;
    if(j == A && k == G && l == C) f = false;
    if(j == A && k == C && l == G) f = false;
    if(j == G && k == A && l == C) f = false;
    if(i == A && k == G && l == C) f = false;
    if(i == A && j == G && l == C) f = false;

    return f;
}

LL dp[105][4][4][4];

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

    int N;
    cin >> N;
    dp[0][3][3][3] = 1;
    for(int i = 0; i < N; ++i) {
        for(int j = 0; j < 4; ++j) {
            for(int k = 0; k < 4; ++k) {
                for(int l = 0; l < 4; ++l) {
                    for(int m = 0; m < 4; ++m) {
                        if(!check(j, k, l, m)) continue;
                        dp[i + 1][k][l][m] += dp[i][j][k][l];
                        dp[i + 1][k][l][m] %= MOD;

                    }
                }
            }
        }
    }

    LL res = 0;
    for(int i = 0; i < 4; ++i) {
        for(int j = 0; j < 4; ++j) {
            for(int k = 0; k < 4; ++k) {
                res = (res + dp[N][i][j][k]) % MOD;

            }
        }
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256