akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int main(){
    int n; cin>>n;
    bool flag = 0;
    for (int i=1; i<=9 && flag ==0; i++){
        if(n%i==0){
            if(1<=n/i && n/i<=9) flag = 1;
        }
    }
    cout << (flag?"Yes":"No") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
typedef long long ll;
/* clang-format off */
#define MOD 1000000007
#define INF 1000000000000000000ll
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
//#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
/* clang-format on */

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n;
  cin >> n;
  vector<vector<ll>> cnt(10, vector<ll>(10, 0));
  for (int i = 1; i <= n; i++) {
    string s = to_string(i);
    int f = s.front() - '0', b = s.back() - '0';
    if (f == 0 || b == 0) continue;
    cnt[f][b]++;
  }
  // REP(i, 10) { DEBUGS(cnt[i]); }
  ll ans = 0;
  REP(i, 10) {
    REP(j, 10) {
      if (j < i) continue;
      if (i == j) {
        ans += cnt[i][i] * cnt[i][i];
      } else {
        ans += cnt[i][j] * cnt[j][i]*2;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3700
#include <bits/stdc++.h>
#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
#include <cstring> 
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define LLONG_MAXs 9223372036854775800

#include <iostream>
#include <cmath>
using namespace std;
 

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
constexpr ll min(ll a,ll b){
if(a>=b)return b;
if(a<b)return a;
}

constexpr ll max(ll a,ll b){
if(a>=b)return a;
if(a<b)return b;
}

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

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {
  //ll ans=LLONG_MAXs;
  ll ans=0;
  ll N;

  cin>>N;
  ll sum=0;
  ll A[N];
  FOR(i,0,N-1){
    cin>>A[i];
    A[i]=A[i]-i;
    sum=sum+A[i];
  }

  sort(A,A+N);
  ll b=A[N/2];
  FOR(i,0,N-1){
    ans=ans+abs(A[i]-b);
  }


cout<<ans<<endl;
return 0;

}
 


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
#define PI 3.141592653589793



int main(){
  ll ans = 0; int N; cin >> N;
  for(int i=1; i<=N; i++){
    if(i%3 && i%5) ans+=(ll)i;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3620
while n = gets
	arr = n.split.map(&:to_f)
	printf("%.3f %.3f\n",(arr[2]*arr[4]-arr[1]*arr[5])/(arr[0]*arr[4]-arr[1]*arr[3])+0.000,(arr[2]*arr[3]-arr[0]*arr[5])/(arr[1]*arr[3]-arr[0]*arr[4])+0.000)
end

Measured memory_bytes: 8684
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int H, W, i, j;
    
    while(1){
        cin >> H >> W;
        
        if (H == 0 && W == 0) break;
        
        for (i=0;i<H;i++){
            if (i==0 || i==H-1) for(j=0;j<W;j++) cout << "#";
            else {
                for (j=0;j<W;j++){
                 if (j==0 || j==W-1) cout << "#";
                 else cout << ".";
                }
            }
            cout << endl;
        }
        cout << endl;
    }
}

Measured memory_bytes: 2952
n,m,x = map(int, input().split())
c = [0]*n
a = [[]]*n
for i in range(n):
    d = [*map(int, input().split())]
    c[i] = d[0]
    a[i] = d[1:]
ans = inf = 10**18

for bit in range(1<<n): #  [0,(2^N)-1] full search
    cost = 0
    skill = [0]*m
    for book in range(n): # [0,N-1] book no.
        if(bit>>book & 1): # buy
            cost += c[book]
            for j in range(m): skill[j] += a[book][j] # skill get
    if min(skill) >= x: ans = min(ans, cost)
if ans == inf: ans = -1
print(ans)


Measured memory_bytes: 9228
#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define   mt         make_tuple
//#define   Y            imag()
//#define   X            real()
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define   angle(n)      atan2((n.imag()),(n.real()))
#define   vec(a,b)       ((b)-(a))
//#define   length(a)      hypot( (a.imag()),(a.real()) )
#define   normalize(a)      (a)/(length(a))
//#define    dp(a,b)          (((conj(a))*(b)).real())
//#define    cp(a,b)          (((conj(a))*(b)).imag())
#define    lengthsqrt(a)       dp(a,a)
#define    rotate0( a,ang)    ((a)*exp( point(0,ang) ))
#define    rotateA(about,p,ang)   (rotate0(vec(about,p),ang)+about)
#define    reflection0(m,v)         (conj((v)/(m))*(m))
#define     reflectionA(m,v,p0)     (conj( (vec(p0,v))/(vec(p0,m)) ) * (vec(p0,m)) ) + p0
//#define     same(p1,p2)               ( dp(  vec(p1,p2),vec(p1,p2)) < eps )
#define     PT                    complex<double>
#define outfile freopen("out.out", "w", stdout);
#define infile  freopen("in.in", "r", stdin);
#define PI acos(-1)
typedef  long long     ll ;
typedef  unsigned long long ull;
const double eps= (1e-9);
using namespace std;
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(int num, int idx) {return ((num >> idx) & 1) == 1;}
int setBit1(int num, int idx) {return num | (1<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(int num, int idx) {return num ^ (1<<idx);}
void FS(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
int n,p,q,X[59],Y[59];
map< pair<int,int> ,int> vis,exist;
set< pair<int,int> > st;
int go(int x,int y)
{
    if(vis[mp(x,y)])
        return 0;
    vis[mp(x,y)]=1;
    if(exist[mp(x-p,y-q)])
    {
        return go(x-p,y-q);
    }
    else
    {
        return 1;
    }
}
int main()
{
    cin>>n;

    for(int i=0;i<n;i++)
    {
        cin>>X[i]>>Y[i];
        exist[mp(X[i],Y[i])]=1;
    }
    if(n==1)
    {
        cout<<"1\n";
        return 0;
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(i==j)
                continue;
            p= (X[i]-X[j]);
            q= (Y[i]-Y[j]);
            st.insert(mp(p,q));
        }
    }
    ll mi=INT_MAX;
    for(auto it=st.begin();it!=st.end();it++)
    {
        p=(*it).first;
        q=(*it).second;
        vis.clear();
        ll ans=0;
        for(int i=0;i<n;i++)
        {
            ans+=go(X[i],Y[i]);
        }
        for(int i=0;i<n;i++)
        {
          if(vis[mp(X[i],Y[i])]==0)
            ans++;
        }

        mi=min(ans,mi);
    }




    cout<<mi<<endl;
}



Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>func(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p;
}

int main() {
  int N;
  string s;
  cin>>N>>s;
  int cnt=0;
  for(int i=0;i<N;i++){
    if(s[i]=='R'){cnt++;}
  }
  if(cnt>N/2){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
  return 0;
}

Measured memory_bytes: 3516
# coding: utf-8
k = int(input())
"""
1,2,3 ... ,9
           10, 11, 12,  21, 22, 23,  ...  98, 99,
100, 101, 110,111,112, 121,122,123
          210,211,212, 221,222,223, 232,233,234
          
...
                                            987,988,989, 998,999
"""
"""
a = ['1','2','3','4','5','6','7','8','9'] # 3*3

b = [] # 3*3*3-1
for i in range(8):
    b += [str(i+1)+str(i), str(i+1)+str(i+1), str(i+1)+str(i+2)]
i = 8
b_ [str(i+1)+str(i), str(i+1)+str(i+1)]
"""
li = []

li_ = []
for i in range(9):
    li_.append(str(i+1))
li += li_

keta = 10
#keta = 4

for t in range(keta-1): #t=0 : 2keta
    li_x = []
    for v in li_:
        i = int(v[-1])
            
        
        if i != 0:
            li_x.append(v+str(i-1))
        li_x.append(v+str(i))
        if i+1 < 10:
            li_x.append(v+str(i+1))
            
    li += li_x
    li_ = li_x
    
    #print(li)
    #print(li_)
    #print(li_x)
    
li = list(map(int, li))
li.sort()
#print(li)
print(li[k-1])

Measured memory_bytes: 26488
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=1; i<=(int)(n); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    vii c(3,vi(3));
    rep(i,3) {
        rep(j,3) {
            cin>>c[i][j];
        }
    }
    bool ok=false;
    int N=c[0][0];
    for(int i=0; i<=N; i++) {
        int a0=i, b0=N-i;
        int a1=c[1][0]-b0;
        int a2=c[2][0]-b0;
        int b1=c[0][1]-a0;
        int b2=c[0][2]-a0;
        if(a1+b1==c[1][1]&&a1+b2==c[1][2]&&a2+b1==c[2][1]&&a2+b2==c[2][2]) ok=true;
    }
    if(ok) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int H, W;
	while(cin >> H >> W  && H != 0 && W != 0){
		for(int j = 0; j < W; j++){
			cout << "#";
		}
		cout << endl;
		for(int i = 1; i < H - 1; i++){
			cout <<"#";
			for(int j = 1; j < W - 1; j++){
				cout << ".";
			}
			cout << "#" << endl;
		}
		for(int j = 0; j < W; j++){
			cout << "#";
		}
		cout << endl << endl;
	}
	return 0;
}


Measured memory_bytes: 2988
#include<iostream>
#include<sstream>
#include<vector>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>
using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define fr(i,c) for(__typeof(c.begin()) i=c.begin();i!=c.end();i++)
#define pb push_back
#define mp make_pair
#define all(c) c.begin(),c.end()

typedef vector<int> vi;
typedef pair<int,int> pi;
typedef long long ll;
const int inf=(int)1e9;
const double EPS=1e-9, INF=1e12;

string in;

int main(){
	cin>>in;
	vi v,tmp;
	rep(i,in.size()){
		if(in[i]=='e')v.pb(0), i+=2;
		else v.pb(1), i+=6;
	}
	vector<vi> vv;
	rep(i,v.size()){
		if(tmp.size()&&tmp.back()==v[i]){
			vv.pb(tmp);
			tmp.clear();
		}
		tmp.pb(v[i]);
	}
	vv.pb(tmp);
	int mx=0, mxi;
	rep(i,vv.size())if((int)vv[i].size()>mx)mx=vv[i].size(),mxi=i;
	if(!vv[mxi].back())cout<<"egg"<<endl;
	else cout<<"chicken"<<endl;
	
	return 0;
	
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
  long N;cin>>N;
  if(N%2==1){cout<<0;return 0;}
  
  long ans=0,t=10;
  for(int i=0;(N/t)>0;i++){ans+=N/t;t*=5;}
  cout<<ans;
}

Measured memory_bytes: 256
//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")


using namespace std;

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

const int N = 3000 + 10;
const ll MOD = 1000000000 + 7;
const ll INF = 1000000010;
const ll LOG = 25;

int n, a[N], W[N];
vi G[N];

void DFS(int v, int p = 0){
	W[v] = 0;
	vi val;
	for (auto u:G[v]){
		if (u == p) continue;
		DFS(u, v);
		if (W[u] == 1) continue;
		val.pb(a[u]);
	}
	for (auto u:val){
		if (a[v] > u) W[v] = 1;
	}
}

int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i];
	for (int i = 0; i < n - 1; i++){
		int v, u;
		cin >> v >> u;
		G[v].pb(u);
		G[u].pb(v);
	}
	for (int i = 1; i <= n; i++){
		memset(W, 0, sizeof W);
		DFS(i);
		if (W[i] == 1) cout << i << ' ';
	}









	return 0;
}


Measured memory_bytes: 4124
#include <iostream>
#include <queue>
#include <algorithm>
#include <string>
#include <utility>
#include <vector>
#include <map>
#include <stack>
#include <iomanip>
#include <set>
#include <sstream>
#include <cmath>
#include <deque>
#include <list>
#include <bitset>
using namespace  std;
typedef pair<long long , long long> P;
typedef long long int64;
typedef long long lint;
#define REP(i, n) for(long long (i)=0; (i)<(n); ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define FST first
#define SND second

signed main(){
    int N;
    cin >> N;
    vector<string> S(N);
    REP(i, N) cin >> S[i];
    lint a=0;
    lint b=0;
    lint c=0;
    lint cnt = 0;
    REP(i, N){
        bool x=false, y=false;
        int m = (int)S[i].size();
        REP(j,m-1) if(S[i][j]=='A' and S[i][j+1]=='B') cnt++;
        if(S[i][0]=='B') x=true;
        if(S[i][m-1]=='A') y=true;
        if(x and y) c++;
        if(x) b++;
        if(y) a++; 
    }
    //cout << a << " " << b << " " << c << " " <<endl;
    //cout << cnt << endl;
    a -= c;
    b -= c;
    if(c>0){
        cnt += c-1;
        if(a>0 and b>0){
            cnt += 2;
            a--, b--;
        }else if(a>0){
            cnt++;
            a--;
        }else if(b>0){
            cnt++;
            b--;
        }
    }
    if(a>0 and b>0) cnt += min(a, b);

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 768
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

int main()
{
	int n;
	cin >> n;
	int a[200001], b[200001];
	int nowb[200001];
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	for(int i = 0; i < n; i++){
		cin >> b[i];
	}
	int ans = 0;
	for(int i = 0; i < 29; i++){
		// xorの2^i桁目の値を求める
		// 2^i桁目に関わるのは2^0, 2^1, ... 2^i桁目の値
		// よってmod 2^(i + 1) した値を考えれば良い
		for(int j = 0; j < n; j++){
			nowb[j] = b[j] % (1 << (i + 1));
		}
		sort(nowb, nowb + n);
		// for(int j = 0; j < n; j++){
		// 	cout << nowb[j] << endl;
		// }
		// cout << endl;
		// 和のi桁目が0になる個数をzeroに記録
		long long int zero = 0;
		for(int j = 0; j < n; j++){
			int nowa = a[j] % (1 << (i + 1));
			// a, bともにmod 2^(i + 1)しているので、和のmaxは2^(i + 2)
			// そのうちi桁目が0になるのは[0, 2^i), [2 * 2^i, 3 * 2^i)
			// lower_bound(itr1, itr2, v) : v以上の値が現れる最初の位置のイテレータを返す
			zero += lower_bound(nowb, nowb + n, (1 << i) - nowa) - nowb;
			zero += lower_bound(nowb, nowb + n, 3 * (1 << i) - nowa) - lower_bound(nowb, nowb + n, 2 * (1 << i) - nowa);
		}
		if(zero % 2 != (n * n) % 2) ans += (1 << i);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
import fractions


n = int(input())
a = list(map(int, input().split()))
nl = set(range(n))
l = [0]
r = [0]
m = []
for i in nl:
    l.append(fractions.gcd(l[i], a[i]))
    r.append(fractions.gcd(r[i], a[-i-1]))
r.reverse()
for i in nl:
    m.append(fractions.gcd(l[i], r[i+1]))
ans = max(m)
print(ans)

Measured memory_bytes: 105568
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


ll H,W,N;
ll ans[10];
typedef pair<ll,ll> P;
set<P> B,LOC;


bool rangeCheck(int row,int col){

	return row >= 0 && row <= H-1 && col >= 0 && col <= W-1;
}


int main(){

	scanf("%lld %lld %lld",&H,&W,&N);

	ll all = (H-2)*(W-2);

	ll row,col;

	for(int i = 0; i < N; i++){

		scanf("%lld %lld",&row,&col);
		row--;
		col--;

		for(ll d_row = -2; d_row <= 0; d_row++){
			for(ll d_col = -2; d_col <= 0; d_col++){

				//3*3の左上
				ll lu_row = row+d_row;
				ll lu_col = col+d_col;
				if(!rangeCheck(lu_row,lu_col)||!rangeCheck(lu_row+2,lu_col+2))continue;

				LOC.insert(make_pair(lu_row,lu_col));
			}
		}

		B.insert(make_pair(row,col));
	}

	for(int i = 0; i < 10; i++){

		ans[i] = 0;
	}

	ans[0] = all-LOC.size();

	for(auto at :LOC){

		row = at.first;
		col = at.second;

		int count = 0;

		for(int d_row = 0; d_row <= 2; d_row++){
			for(int d_col = 0; d_col <= 2; d_col++){

				if(B.count(make_pair(row+d_row,col+d_col))){
					count++;
				}
			}
		}

		ans[count]++;
	}

	for(int i = 0; i <= 9; i++){

		printf("%lld\n",ans[i]);
	}

	return 0;
}


Measured memory_bytes: 62720
#include <iostream>
#include<cmath>
#include<vector>
#include<tuple>
#include <ctime>
#include<algorithm>
#include <initializer_list>
#include <cstring> 
 
#define tii tuple<int,int>
#define vi vector<int>
#define vii vector<vi>
#define ll long long
#define vl vector<ll>
#define vll vector<vl>
 
#define mymod 1000000007
#define mx 99999999
#define mn -99999999
#define sz 101
 
using namespace std;

int main() {
    clock_t tstart = clock();
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    // Start
    int n,m;
    cin>>n>>m;
    vector<string> v(n);
    for(auto&x:v) cin>>x;
    sort(v.begin(), v.end());
    string s = "";
    for(auto x:v) s += x;
    cout<<s;
    // cout<<"\n\nTotal Time Taken : "<<(double)(-tstart + clock())/CLOCKS_PER_SEC<<"sec\n\n";
    return 0;
}
 


Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace  std;
double More_heads( vector< double > &probability,int n)
{
     vector< vector< double > > DP(n+1,vector< double >(n+1,0));
     DP[0][0] = 1.0;
     for(int i=1;i<=n;i++)    DP[i][0] = (1-probability[i])*DP[i-1][0]; //every single one of them is tail for which it maintains 0 coins.
     for(int i=1;i<=n;i++){
          for(int j = 1; j<=i;j++){ //i-th coin can contribute in two different ways on setting j heads allover in a permutation.
               DP[i][j] += probability[i]*DP[i-1][j-1]; //i-th coin as the j-th head.
               DP[i][j] += (1-probability[i])*DP[i-1][j] ;//as j heads already exist,i-th becomes mandatorily tail.
               //cout << DP[i][j] << " ";
          }
          //cout << endl;
     }
     double sum = 0.00;
     for(int i=n/2+1;i<=n;i++){//only taking the permutations with more heads.
          sum += DP[n][i];
     }
     return sum;
}
int main()
{
     //freopen("in.txt","r",stdin);
     int n;
     cin >> n;
     vector< double > probability(n+1);
     for(int i=1;i<=n;i++){
          cin >> probability[i];
         // cout << probability[i] << endl;
     }
     double sum = More_heads(probability,n);
     cout << setprecision(10) << fixed << sum << endl;
}


Measured memory_bytes: 70656
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
using pii = pair<int,int>;
using lli = long long;
using ld = long double;
using pdd = pair<ld, ld>;

const int MAXN=500000;
const ld EPS=1e-10;
int n,L,tem[MAXN],lit[MAXN];
pdd conv[MAXN+2];

int ccw(pdd a,pdd b) {
	ld val = a.fi*b.se - b.fi*a.se;
	if(val > EPS) return 1;
	else if(val < -EPS) return -1;
	else return 0;
}
int ccw(pdd p,pdd a,pdd b) {
	return ccw(pdd(a.fi-p.fi,a.se-p.se), pdd(b.fi-p.fi,b.se-p.se));
}
int main() {
	scanf("%d%d",&n,&L);
	for(int i=0;i<n;i++) scanf("%d%d",tem+i,lit+i);

	int l=0,r=1;
	conv[0] = {-1,0}; conv[1] = {0, 0};
	for(int i=0;i<n;i++) {
		ld x = conv[r-1].fi + lit[i], y = conv[r-1].se + 1ll*tem[i]*lit[i];
		pdd newp(x,y);
		while(conv[l].fi < x - L) l++;
		if(l!=0 && conv[l].fi > x-L+EPS) {
			ld prop = (x-L - conv[l-1].fi) / (conv[l].fi - conv[l-1].fi), y = conv[l-1].se + (conv[l].se - conv[l-1].se)*prop;
			conv[--l] = pdd(x-L, y);
		}
		printf("%.10Lf\n",(y - conv[l].se)/(x - conv[l].fi));
		
		while(r-l>1 && ccw(conv[r-1], newp, conv[r-2])<=0) r--;
		conv[r++] = newp;
	}
	
	return 0;
}


Measured memory_bytes: 30080
#include<bits/stdc++.h>
using namespace std;
int main(){
   string a , b;
  cin>>a>>b;
  string s = a+b;
  int n = stoi(s);
  if( sqrt(n) - floor(sqrt(n)) == 0 )
    cout<<"Yes";
  else
    cout<<"No";

}


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

void sort(int fruets[], int N) 
{
	int i, j, t, lowest, lowkey;
	for (i = 0; i < N - 1; i++) {
		lowest = i;
		lowkey = fruets[i];
		for(j=i+1;j<N;j++)
			if (fruets[j] < lowkey) {
				lowest = j; lowkey = fruets[j];
			}
		t = fruets[i]; fruets[i] = fruets[lowest]; fruets[lowest] = t;
	}
}

int main()
{
	int fruets[1000];
	int N, K;
	int answer = 0;

	cin >> N >> K;

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

	sort(fruets, N);

	for (int i = 0; i < K; i++) {
		answer += fruets[i];
	}

	cout << answer;

	return 0;
	
}

Measured memory_bytes: 3632
#include <cstdio>

int main(void) {
	int souko[10], now=0;
	int input;

	while(scanf("%d", &input) != EOF) {
		if(input == 0) {
			now--;
			printf("%d\n", souko[now]);
		} else {
			souko[now] = input;
			now++;
		}
	}

	return 0;
}

Measured memory_bytes: 0
S = input()
bit = 0
for i in S:
  if i == 'N':
    bit |= 1
  elif i == 'E':
    bit |= 2
  elif i == 'S':
    bit |= 4
  elif i == 'W':
    bit |= 8
  if bit == 15:
    break
if bit % 5 == 0:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
#include<cstdio>
int a[101],cnt,n;
int main(){
    scanf("%d",&n);
    for(int i=0;i<n;++i)scanf("%d",a+i);
    for(int i=0;i<n;++i)
        for(int j=n-1;j>i;--j)
            if(a[j]<a[j-1]){
                int t=a[j];
                a[j]=a[j-1];
                a[j-1]=t;
                ++cnt;
            }
    for(int i=0;i<n-1;++i)printf("%d ",a[i]);
    printf("%d\n%d\n",a[n-1],cnt);
    return 0;
}



Measured memory_bytes: 2764
#include<bits/stdc++.h>
#define pi acos(-1)
#define ll long long
#define pii pair<ll,ll>
#define debug(a) cout<<a<<'\n'
#define maxn 100009 /// Look at me please ... that's what she said
#define MOD 1000000007
using namespace std;
const int INF = 1e6 + 9;
ll mult(ll a, ll b){
    return ((a%MOD)*(b%MOD))%MOD;
}
ll fastpow(ll a, ll b){
    if(b==0)return 1LL;
    if(!(b&1)){
        ll x=fastpow(a,b/2);
        return mult(x,x);
    }
    return mult(fastpow(a,b-1),a);
}
ll fact[3000001];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0); ///activate when submit
    ll x,y;
    cin>>x>>y;
    fact[0]=1;
    for(int i=1;i<3000001;i++){
        fact[i]=mult(i,fact[i-1]);
    }
    ll qtd=0;
    for(ll i=0;i<=3000000;i++){
        if((x-2*i)*2==y-i && y-i>=0){ 
            qtd+=mult(fact[i+(y-i)/2],fastpow(mult(fact[(y-i)/2],fact[i]),MOD-2));
        }
    }
    cout<<qtd<<endl;
    return 0;
}    

Measured memory_bytes: 23808
#include <stdio.h>
#include <stdlib.h>

typedef struct	s_p
{
  	int	n;
  	int	v;
}				t_p;

int	main(void)
{
  	int	N;
  	t_p	*p;
  	int	num;
  	int	i;
  	int	count;
  	int min;
  
  	num = scanf("%d", &N);
  	if (num != 1)
   		return (0);
  
  	p = (t_p *)malloc(sizeof(t_p) * (N + 1));
  	for (i=1; i<=N; i++)
    {
      	num = scanf("%d", &p[i].n);
    	if (num != 1)
          	return (0);
      	p[i].v = 0;
    }
  	
  	min = N;
  	count = 0;
    for (i=1; i<=N; i++)
    {
        if (min >= p[i].n)
        {
            min = p[i].n;
            count++;
        }
        if (min == 1)
            break ;
    }
    printf("%d", count);
}

Measured memory_bytes: 1664
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<deque>
using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const int mod=1000000007;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};
int dyy[]={0,-1,0,1};
int dxx[]={-1,0,1,0};

/*#define int ll*/
signed main(){
    ll x;
    cin>>x;
    if(x%11==0)cout<<(x/11)*2<<endl;
    else if(x%11<=6) cout<<((x/11)+1)*2-1<<endl;
    else cout<<((x/11)+1)*2<<endl;
    return 0;
}

Measured memory_bytes: 256
/**
**	author : Raghav
**	codechef:raghav_456
**	codeforces:raghavramola7
**/
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define endl 			"\n"
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void Raghav()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(10);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int32_t main()
{
	Raghav();
	int a, b;
	cin >> a >> b;
	int ans = ceil((a * 1.0) / b);
	cout << ans;
	return 0;
}

Measured memory_bytes: 3656
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as C
import Debug.Trace
import Data.List
import Control.Monad
import Data.Ord


r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine

rp :: IO (Int,Int)
rp  = toTup . unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine

toTup [a,b] = (a,b)



main :: IO ()
main = do
    ls <- r'
    putStrLn $ if (sum (zipWith (*) ls [100,10,1]) `mod` 4 == 0)
        then "YES" else "NO"



Measured memory_bytes: 380
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
int main(void){

	char a[110];
	int b[100000];
	int c, d;
	int k;
	int n, m;
	int s, t;
	int x, y, z;
	int ans;
	int max;
	ans = 1000;
	for (int i = 0; i < 110; i++)a[i] = 0;
	scanf("%s", a);

	for (int i = 0; i < 26; i++){
		c = 0;
		max = 0;
		for (int j = 0; j < strlen(a); j++){
			if (a[j] == 97 + i){
				if (max < c)max = c;
				c = 0;
			}
			else c++;
		}
		if (max < c)max = c;
		if (ans > max)ans = max;
	}

	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 128
// Problem : D - Widespread
// Contest : AtCoder Regular Contest 075
// URL : https://atcoder.jp/contests/arc075/tasks/arc075_b
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define cerr if(1)cerr
#define size(x) (int)x.size()
#define all(x) x.begin(), x.end()

const int N = 1e6 + 1, mod = 1e9 + 7, inf = 2e9;

int n, a, b, h[N];

bool check(ll x) {
	if (x > LLONG_MAX / b) {
		return 1;
	}
	ll m = 0;
	for (int i = 1; i <= n; i++) {
		if (h[i] > x * b) {
			m += (h[i] - x * b) / (a - b) + !!((h[i] - x * b) % (a - b));
		}
	}
	return m <= x;
}

int main() { cin.tie(0)->sync_with_stdio(0);
	cin >> n >> a >> b;
	for (int i = 1; i <= n; i++) {
		cin >> h[i];
	}
	ll ans = -1;
	for (int i = 46; i >= 0; i--) {
		ans += 1ll << i;
		if (check(ans)) {
			ans -= 1ll << i;
		}
	}
	cout << ans + 1;
}


Measured memory_bytes: 640
n = int(input())
s = list(input())
#print(n,s)
x = s[0]
#y = []
s2 = s.copy()
count = 0
for num,i in enumerate(s[1:n],1):
#  print(x,s2[num],num)
  if x == s2[num]:
#    y.append(s2[num])
#    print('hit')
    count += 1
  x = s2[num]
#print((y))
print(n-count)
    
    
    

Measured memory_bytes: 5432
n = input()
a = map(int, raw_input().split())

c = 0
for i in range(n):
    for j in range(n - 1, i, -1):
        if a[j] < a[j - 1]:
            a[j], a[j - 1] = a[j - 1], a[j]
            c += 1

print(" ".join(map(str, a)))
print(c)

Measured memory_bytes: 4216
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()
#define chmax(a, b) a = max(a, b)


using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;


ll dp[3005][6005];

int main(){
    int n, T;
    cin >> n >> T;
    vector<P> p;
    rep(i, n){
        ll a, b;
        cin >> a >> b;
        p.emplace_back(a, b);
    }
	sort(ALL(p));
    ll res = 0;
    rep(i, n){
        rep(t, T){
            chmax(dp[i + 1][t], dp[i][t]);
            int nt = t + p[i].first;
            if(nt < T)chmax(dp[i + 1][nt], dp[i][t] + p[i].second);
        }
        ll now = dp[i][T - 1] + p[i].second;
        chmax(res, now);
    }
    cout << res << endl;
    //REP(i, 1, n){REP(t, 1, T)cout << dp[i][t] << " ";cout << endl;}
}


Measured memory_bytes: 139648
n = int(input())
a = list(map(int, input().split()))
b = sorted(list(set(a)))
a_to_i = dict()
for i in range(len(b)):
	a_to_i[b[i]] = i

a_count = [0 for _ in range(len(b))]
for x in a:
	a_count[a_to_i[x]] += 1

cum_reversed = [a_count[-1]]
for i in range(len(b)-2, -1, -1):
	cum_reversed.append(cum_reversed[-1] + a_count[i])

dominant = [-1 for _ in range(len(b))]
i = 0
for j in range(n):
	if i == len(b):
		break
	while a[j] >= b[i]:
		dominant[i] = j
		i += 1
		if i == len(b):
			break
b.reverse()
b.append(0)
dominant.reverse()

ans = [0 for _ in range(n)]

for i in range(len(b)-1):
	ans[dominant[i]] += (b[i] - b[i+1]) * cum_reversed[i]

print(*ans, sep="\n")

Measured memory_bytes: 33628
// https://atcoder.jp/contests/dp/tasks/dp_l

#include <iostream>
#include <vector>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <limits>

using namespace std;

void helper(const vector<long long>& points, vector<vector<vector<long long>>>& dp, int l, int r) {
	if (l > r) return;
	if (dp[l][r][0] != numeric_limits<long long>::min()) return;

	helper(points, dp, l + 1, r);
	helper(points, dp, l, r - 1);

	if (l == r) {
		dp[l][r][0] = points[l];
		dp[l][r][1] = -points[l];
	} else {
		dp[l][r][0] = max(dp[l][r - 1][1] + points[r], dp[l + 1][r][1] + points[l]);
		dp[l][r][1] = min(dp[l][r - 1][0] - points[r], dp[l + 1][r][0] - points[l]);
	}
}

int main (int argc, char* argv[]) {
	int n;
	cin >> n;

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

	vector<vector<vector<long long>>> dp(n, vector<vector<long long>>(n, vector<long long>(2, numeric_limits<long long>::min())));
	helper(points, dp, 0, n - 1);

	cout << dp[0][n - 1][0] << endl;
}


Measured memory_bytes: 492928
# ??
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()
ans = len(S)
for i in range(len(S)-1):
	if S[i] != S[i+1]:
		ans = min(ans, max(i+1, len(S)-(i+1)))
print(ans)


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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll A[200005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll K, N;
    cin >> K >> N;
    REP(i, N) {
        cin >> A[i];
    }
    ll ans = K;
    REP(i, N - 1) {
        ans = std::min(ans, K - abs(A[i + 1] - A[i]));
    }

    ans = std::min(ans, K - abs(K - A[N - 1] + A[0]));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main()
{
	int a;
	int b;
	int c;
	scanf("%d%d%d",&a,&b,&c);
	if(a < b) {
		if(b < c) {
			printf("Yes\n");
		}else{
			printf("No\n");
		}
	}else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 1008
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main()
{
    int i;

    int sum = 0;
    char W[11], T[1001];

    scanf("%s", W);
    for( i = 0; W[i]; ++i ) W[i] = tolower(W[i]);
    while( 1 ){
        scanf("%s", T);
        if( strcmp("END_OF_TEXT", T) == 0 ) break;
        for( i = 0; T[i]; ++i ) T[i] = tolower(T[i]);
        if( strcmp(W, T) == 0 ) ++sum;
    }

    printf("%d\n", sum);

    return 0;
}


Measured memory_bytes: 2044
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

int main(void) {
	int N;
	cin >> N;
	vector<int> A(N+1);
	vector<int> dis(N+1);
	A[N] = 0;

	int np = 0;
	int sum = 0;
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
		dis[i] = abs(A[i]-np);
		np = A[i];
		sum += dis[i];
	}
	dis[N] = abs(A[N-1]);
	sum += dis[N];

	for (int i = 0; i < N; ++i) {
		int res = sum;
		res -= (dis[i]+dis[i+1]);
		if (i == 0) {
			np = 0;
		}
		else {
			np = A[i-1];
		}
		res += abs(A[i+1]-np);
		cout << res << endl;
	}
	return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define N 212345
#define MOD 1'000'000'007LL
ll c[N];

int main(){
	int n; scanf("%d", &n);
	REP(i, n) scanf("%lld", c+i);
	sort(c, c+n, greater<ll>());
	ll ans = 0;
	REP(i, n) ans = (ans + c[i] * (i+2)) % MOD;
	REP(i, 2*n-2) ans = ans * 2 % MOD;
	printf("%lld\n", ans);
}


Measured memory_bytes: 1792
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

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

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

int main(){
	
	int N;
	cin >> N;
	
	int a[15], w[15];
	int S1 = 100000, S2 = 100000;
	
	for(int i = 0; i < N; i++){
		cin >> a[i];
	}
	
	for(int i = 0; i < N; i++){
		cin >> w[i];
		if(a[i]){
			S1 = min(S1, w[i]);
		}else{
			S2 = min(S2, w[i]);
		}
	}
	
	if(S1 == 100000 || S2 == 100000){
		cout << 0 << endl;
	}else{
		cout << S1 + S2 << endl;
	}
	
	return 0;
}



Measured memory_bytes: 3100
package main

import (
	"bufio"
	"bytes"
	"fmt"
	"os"
	"strconv"
)

type List struct {
	cursor *Node
	start  *Node
	end    *Node
}

type Node struct {
	prev *Node
	next *Node
	v    int
}

func NewList() List {
	start := &Node{}
	end := &Node{}
	start.next = end
	end.prev = start
	return List{end, start, end}
}

func (l *List) Each() <-chan *Node {
	ch := make(chan *Node)
	go func(chan *Node) {
		node := l.start.next
		for node != l.end {
			ch <- node
			node = node.next
		}
		close(ch)
	}(ch)
	return ch
}

func (l *List) Find(x int) *Node {
	for node := range l.Each() {
		if node.v == x {
			return node
		}
	}
	return nil
}

func (l *List) Insert(x int) {
	node := &Node{l.cursor.prev, l.cursor.prev.next, x}
	l.cursor.prev, l.cursor.prev.next = node, node
	l.cursor = node
}

func (l *List) Move(d int) {
	var offset int
	switch {
	case d > 0:
		offset = 1
	case d < 0:
		offset = -1
	default:
		return
	}

	node := l.cursor
	for d != 0 {
		switch {
		case d > 0:
			node = node.next
		case d < 0:
			node = node.prev
		}
		d -= offset
	}
	l.cursor = node
}

func (l *List) Erace() {
	l.cursor.prev.next, l.cursor.next.prev = l.cursor.next, l.cursor.prev
	l.cursor = l.cursor.next
}

func (l List) String() string {
	var b bytes.Buffer
	for node := range l.Each() {
		if node == l.cursor {
			b.WriteString(fmt.Sprintf("[%d] ", node.v))
		} else {
			b.WriteString(fmt.Sprint(node.v, " "))
		}
	}
	return b.String()
}

func printList(l List) {
	w := bufio.NewWriter(os.Stdout)
	for node := range l.Each() {
		w.WriteString(fmt.Sprintf("%d\n", node.v))
	}
	w.Flush()
}

func NextInt(sc *bufio.Scanner) (int, error) {
	sc.Scan()
	return strconv.Atoi(sc.Text())
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	n, _ := NextInt(sc)
	list := NewList()

	for i := 0; i < n; i++ {
		cmd, _ := NextInt(sc)
		switch cmd {
		case 0:
			d, _ := NextInt(sc)
			list.Insert(d)
		case 1:
			d, _ := NextInt(sc)
			list.Move(d)
		case 2:
			list.Erace()
		}
		// fmt.Println(list)
	}

	printList(list)
}



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

int A, B, X;

void input() {
    cin >> A >> B >> X;
}

int main() {
    input();
    // A <= X <= A+B
    if (A <= X && X <= A+B)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

    return 0;
}


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

using namespace std;

#define MAX 10000000
#define ll long long

int ans[50005];

int main()
{
    memset(ans, -1, sizeof ans);
    for(ll i=1; i<MAX; i++){
        ll val = i*108;
        val = val/100;
        if(val < 50005) ans[val] = i;
    }
    ll n;
    scanf("%lld", &n);
    if(ans[n] == -1) cout << ":(" << endl;
    else cout << ans[n];
}

Measured memory_bytes: 384
A = int(input())
B = int(input())

if A == 1 and B == 2:
  print("3")
if A == 2 and B == 1:
  print("3")
if A == 3 and B == 2:
  print("1")
if A == 2 and B == 3:
  print("1")
if A == 3 and B == 1:
  print("2")
if A == 1 and B == 3:
  print("2")

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <cstdio>
#include <numeric>

using namespace std;

int N;
vector<int> A;

int gcd(int a,int b)
{
    if(b > a)
    {
        swap(a, b);
    }
    while(b != 0)
    {
        int na = b;
        int nb = a % b;
        a = na;
        b = nb;
    }
    return a;
}

int l[100005];
int r[100005];

int main()
{
    cin >> N;
    A.resize(N+1);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i + 1];
    }
    if (N == 2)
    {
        cout << max(A[1], A[2]) << endl;
        return 0;
    }
    l[0] = 0;
    r[N + 1] = 0;
    for (int i = 1; i <= N; i++)
    {
        l[i] = gcd(l[i - 1], A[i]);
        r[N+1-i] = gcd(r[N+2-i], A[N+1-i]);
    }
    int ans = 0;
    for (int i = 1; i <= N; i++)
    {
        ans = max(ans, gcd(l[i-1], r[i+1]));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
# ABC155E

s = input()
d0 = [0,1,2,3,4,5,6,7,8,9]
d1 = [0,1,2,3,4,5,5,4,3,2] # 通常時

a0 = d1[int(s[0])]
a1 = d1[int(s[0]) + 1] if int(s[0])<=8 else 1

for c in s[1:]:
    c = int(c)
    b0 = min(a0 + c, a1 + (10 - c))
    b1 = min(a0 + c + 1, a1 + (9 - c)) if c <=8 else a1
    a0, a1 = b0, b1
    
print(a0)

Measured memory_bytes: 57196
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

int main(void) {
	int64_t X;
	cin >> X;
	int64_t ans = 0;
	ans = 1000 * (X / 500);
	X %= 500;
	ans += 5 * (X / 5);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	
	
	int h, w, n, ans;
	
	scanf("%d", &h);
	scanf("%d", &w);
	scanf("%d", &n);
	
	if(w>=h){
		if(n%w == 0){
			ans = n/w;
		}else if(n%w != 0){
			ans = n/w+1;
		}
	
	}else if(w<=h){
		if(n%h == 0){
			ans = n/h;
		}else if(n%h != 0){
			ans = n/h+1;
		}
	}
	printf("%d", ans);
}

Measured memory_bytes: 1732
/*I wanna be the very best, like no one ever was...*/

#include<bits/stdc++.h>
using namespace std;
/*******  All Required define Pre-Processors and Constants    *******/

#define ll long long
#define ull unsigned long long 
#define ld long double
#define mem(a, b) memset(a, (b), sizeof(a))
#define rep(i, j, k) for (int i = j ; i < k ; ++i)
#define rrep(i, j, k) for (int i = j; i > k; --i)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(i, a) for(auto i: a)
#define forEach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define in(A, B, C) assert( B <= A && A <= C)
#define debug(a) cout << #a << ": " << a << endl
#define Flag(n) cout << "here " << n << endl
#define mp make_pair
#define pb push_back

#define endl '\n';
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll POSITIVE_INFINITY = 9223372036854775807;
const ll NEGATIVE_INFINITY = -9223372036854775807;
const ll MOD = 1000000007;
const ld PI = acos(-1.0);
 

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr<<name<<" : "<<arg1<<endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif



int main() {
    io;
    // freopen("in","r",stdin); 
    // freopen("out","w",stdout);
  

    ll n ,a ,b;
    cin>>n>>a>>b;
    ll sum = 0;
    ll arr[n];
    rep(i,0,n) cin>>arr[i];
    for(ll i = 0;i<n;i++){
        if(i>0)
        sum+=min((arr[i]-arr[i-1])*a, b);
    }
    cout<<sum<<endl;
 
 
    
 
    return 0;
}

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

int main() {
  int X;
  cin >> X;
  int counter500 = 0;
  int counter5 = 0;
  while(500<=X){
    X = X - 500;
    counter500++;
  }
  
  while(5<=X){
    X = X -5;
    counter5++;
  }
  cout <<1000*counter500 + 5*counter5 << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var xs = Console.ReadLine().Split(' ').Select(num => int.Parse(num)).ToArray();
            for (var i = 0; i < xs.Length; i++)
            {
                if (xs[i] == 0)
                {
                    Console.WriteLine(i + 1);
                }
            }
        }
    }
}

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


main()
{
    int ans = 0;
   string s;
   cin>>s;
   int n = s.length();
   for(int i = 0; i<s.length()/2; i++){
    if(s[i] != s[n-i-1])ans++;
   }
   cout<<ans<<endl;



    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <numeric>

using namespace std;

int main(void){
    int N,M;
    int ans=0;
    cin>>N;
    cin>>M;
    vector<int> X(M);
    for(int i=0;i<M;i++){
        cin>>X[i];
    }

    sort(X.begin(),X.end());
    if(M==1||N>=M){
        ans=0;
    }
    else{
        vector<int> X_difference(M-1);
        for(int i=0;i<M-1;i++){
            X_difference[i]=X[i+1]-X[i];
        }

        sort(X_difference.begin(),X_difference.end());

        for(int i=0;i<M-N;i++){
            ans+=X_difference[i];
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <deque>
using namespace std;
int main(){
    int q; cin >> q;
    deque<int> dq;
    for(int i = 0; i < q; ++i){
        int x; cin >> x;
        if(x == 0){
            int d,y; cin >> d >> y;
            if(d == 0) dq.push_front(y);
            else dq.push_back(y);
        }
        else if(x == 1){
            int p; cin >> p;
            cout << dq[p] << endl;
        }
        else if(x == 2){
            int d; cin >> d;
            if(d == 0) dq.pop_front();
            else dq.pop_back();
        }
    }
    return 0;
}


Measured memory_bytes: 4660
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef double db;
#define go(u) for(int i = head[u], v = e[i].to; i; i=e[i].lst, v=e[i].to)
#define rep(i, a, b) for(int i = a; i <= b; ++i)
#define pb push_back
#define re(x) memset(x, 0, sizeof x)
inline int gi() {
    int x = 0,f = 1;
    char ch = getchar();
    while(!isdigit(ch)) { if(ch == '-') f = -1; ch = getchar();}
    while(isdigit(ch)) { x = (x << 3) + (x << 1) + ch - 48; ch = getchar();}
    return x * f;
}
template <typename T> inline bool Max(T &a, T b){return a < b ? a = b, 1 : 0;}
template <typename T> inline bool Min(T &a, T b){return a > b ? a = b, 1 : 0;}
const int N = 2e4 + 7, B = 50000;
int n;
int p[N], a[N], b[N];
int main() {
#ifdef fwat
#endif
	n = gi();
	rep(i, 1, n) p[i] = gi();
	rep(i, 1, n) a[i] = i * B, b[i] = (n - i + 1) * B;
	rep(i, 1, n) a[p[i]] -= n - i;
	rep(i, 1, n) printf("%d%c", a[i], i == n ? '\n':' ');
	rep(i, 1, n) printf("%d%c", b[i], i == n ? '\n':' ');
	return 0;
}

Measured memory_bytes: 896