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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	
	ll n, m;
	cin >> n >> m;

	vector<ll> x;
	vector<ll> y;

	for(int i=0; i<n; i++){
		int t;
		cin >> t;
		x.push_back(t);
	}

	for(int i=0; i<m; i++){
		int t;
		cin >> t;
		y.push_back(t);
	}

	ll xsum = 0;
	ll ysum = 0;

	for(int i=0; i<n; i++){
		xsum += i * x[i] - (n - (i+1)) * x[i];
		xsum %= MOD;
	}

	for(int i=0; i<m; i++){
		ysum += i * y[i] - (m - (i+1)) * y[i];
		ysum %= MOD;
	}

	cout << xsum * ysum % MOD << endl;

	return 0;
}


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

using namespace std;

int main(){
  string s;
  cin >> s;
  int l = s.length() - 2;
  
  cout << s.at(0) << to_string(l) << s.back() << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define mod 1000000007
#define N 500043
#define mp(a,b) make_pair(a,b)
#define loop(a,b) for(int i=a;i<b;i++)
#define test int t; cin >> t; while(t--)
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int x;
    cin >> x;
    int ans;
    if(x>=400&&x<=599)
        ans=8;
    if(x>=600&&x<=799)
        ans=7;
    if(x>=800&&x<=999)
        ans=6;
    if(x>=1000&&x<=1199)
        ans=5;
    if(x>=1200&&x<=1399)
        ans=4;
    if(x>=1400&&x<=1599)
        ans=3;
    if(x>=1600&&x<=1799)
        ans=2;
    if(x>=1800&&x<=1999)
        ans=1;
    cout << ans;
}


Measured memory_bytes: 3664
fun main(args :Array<String>) {
    val c = readLine()!!.toCharArray()[0]
    val chars = ('a'..'z')
    val it = chars.iterator()

    while (it.hasNext()) {

        val e = it.next()
        if(c == e) {
            println(it.next())
            break
        }
    }
}

Measured memory_bytes: 31768
<?php
fscanf(STDIN, '%d %d', $n, $k);
$link_sunukes = '';
$count = 0;
for ($i=0; $i<$k; $i++) {
  fscanf(STDIN, '%d', $d[$i]);
  $sunukes = fgets(STDIN);
  $link_sunukes .= ' '.trim($sunukes);
}
$exploded_numbers = explode(' ', trim($link_sunukes));

for ($j=1; $j<=$n; $j++) {
  $result = array_search($j, array_unique($exploded_numbers));
  if ($result === false) {
    $count++;
  }
}
echo $count;

Measured memory_bytes: 16888
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    double r = sc.nextDouble();
    double pi = Math.PI;
    double area = pi*r*r;
    double length = 2*pi*r;
    System.out.printf("%f %f", area, length);
    sc.close();
  }
}


Measured memory_bytes: 28144
#include <bits/stdc++.h>
using namespace std;
long long w[100001],v[100001],dp[101][100001];
int main() {
	
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    
      long long n,i,j,k,sum=0,count=0,ans=0,x=0,y=0,l,r,m;
      cin>>n>>k;
      long long w[n],v[n];
      for(i=0;i<n;i++)
      {
          cin>>w[i]>>v[i];
          sum+=v[i];
      }
      for(i=0;i<100001;i++)
      {
          for(j=0;j<=n;j++)
          dp[j][i]=1000000000;
      }
    
       for(j=0;j<=n;j++)
     dp[j][0]=0;
      
       for(i=1;i<=sum;i++)
      {
          for(j=1;j<=n;j++)
          {
              if(i>=v[j-1])
              {
                  dp[j][i]=min(dp[j-1][i],dp[j-1][i-v[j-1]]+w[j-1]);
              }          
              else
              {
                   dp[j][i]=dp[j-1][i];
              }
          }
      }
      ans=0;
      
      for(i=sum;i>=1;i--)
      {
          for(j=0;j<=n;j++)
          if(dp[j][i]<=k)
          {
              cout<<i; return 0;
          }
      }
      cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 82468
#include<stdio.h>
int selectionSort(int A[], int N) {
    int i, j, t, sw =0, minj;
    for(i=0;i<N-1;i++) {
        minj = i;
        for(j=i;j<N;j++) {
            if(A[j]<A[minj]) minj = j;
        }
        t=A[i]; A[i]=A[minj]; A[minj]=t;
        if(i!=minj) sw++;
    }
    return sw;
}

int main(void) {
    int A[100], N, i, sw;

    scanf("%d",&N);
    for(i=0;i<N;i++) scanf("%d",&A[i]);

    sw = selectionSort(A,N);

    for(i=0;i<N;i++) {
        if(i>0) printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");
    printf("%d\n",sw);

    return 0;
}


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

int main(){
  int w,h,x,y;
  cin>>w>>h>>x>>y;
  double f=(double)w*h/2;
  int cnt=(w==2*x &&h==2*y)?1:0;
  printf("%.9f %d",f,cnt);
  
  
}

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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

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

struct Edge {
    ll to, rev;
    long double cap;
    Edge(ll _to, long double _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph &G, ll from, ll to, long double cap, bool revFlag,
              long double revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve() {
    int w, h;
    cin >> w >> h;
    vec<ll> p(w), q(h);
    REP(i, w) {
        cin >> p[i];
    }
    REP(i, h) {
        cin >> q[i];
    }

    vec<ll> sq = q;
    sort(all(sq));
    vec<ll> sum(h + 1, 0);
    REP(i, h) {
        sum[i + 1] = sum[i] + sq[i];
    }

    ll ans = 0;
    ans += sum[h];

    REP(i, w) {
        ll con = upper_bound(all(sq), p[i]) - sq.begin();
        ans += sum[con];
        ans += (h + 1 - con) * p[i];
    }
    cout << ans << en;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /*
    ll t;
    cin >> t;
    while(t--)*/
    solve();

    return 0;
}


Measured memory_bytes: 6364
#include <bits/stdc++.h>
typedef long long ll; 
 
using namespace std;
using P = pair<int, int>;

int main() {
	int N;
	cin >> N;
	vector<P> v(N);
	for (int i = 0; i < N; ++i) {
		int a, b;
		cin >> a >> b;
		v[i] = P(a, b);
	}
	sort(v.begin(), v.end());

	int res = v[N - 1].first + v[N - 1].second;
	cout << res << endl;

	return 0;
}


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

using namespace std;
typedef long long ll;
int n;
char mp[305][305];
int vis[305][305];
void solve(int x, int y){
	int rx = x, ry = y, t;
	for(int i = 0; i < n; i ++){
		if(vis[i][0]) continue;
		x = rx + i; y = ry;
		if(x >= n) x -= n;
		t = x; x = y; y = t; x -= i;
		if(x < 0) x += n; 
		if(mp[rx][ry] != mp[x][y]) vis[i][0] = 1;
	}
	for(int j = 1; j < n; j ++){
		if(vis[0][j]) continue;
		x = rx; y = ry + j;
		if(y >= n) y -= n;
		t = x; x = y; y = t; y -= j;
		if(y < 0) y += n;
		if(mp[rx][ry] != mp[x][y]) vis[0][j] = 1;
	}
}
int main(){
	scanf("%d", &n);
	for(int i = 0; i < n; i ++){
		scanf("%s", mp[i]);
	}
	
	for(int i = 0; i < n; i ++){
		for(int j = 0; j < n; j ++){
			solve(i, j);
		}
	}
	int ans = 0;
	for(int i = 1; i < n; i ++){
		if(!vis[i][0]) ans += n - i; 
		if(!vis[0][i]) ans += n - i;
	}
	if(!vis[0][0]) ans += n;
	printf("%d\n", ans);
	return 0;
} 

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

using namespace std;

int main() {
	int a;
	int b;
	scanf("%d%d", &a, &b);
	int t = a;
	while (a / t <= b) a *= 10;
	a += b;
	int tmp = sqrt(a);
	if (tmp * tmp == a) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for(int i =0 ; i < n; ++i)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define pii pair < int, int >
typedef vector<int> vi;
typedef  long long ll;
const int mod =1e9+7;
const int N = (int)2e5 + 5;

void solve(){
	string s;
	cin>>s;
	s[0]='2',s[1]='0',s[2]='1',s[3]='8';
	cout<<s;


}

int main(){
	Red;
	int t=1;
	// cin>>t;
	while(t--)
	solve();
	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iterator>
#include <numeric>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define mp make_pair
#define pb push_back
#define FI first
#define SE second
#define FOR(i,a,b) for(int (i)=((int)a); (i)<((int)b); (i)++) // [a,b)
#define REP(i,N) FOR((i), 0, ((int)N)) // [0,N)
#define INF (1 << 30)
#define icin(x) int x; cin >> x
#define lcin(x) ll x; cin >> x
#define dcin(x) double x; cin >> x
#define scin(s) string s; cin >> s 
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vcin(v,N) vi v(N); REP(i,N) cin >> v[i] // 配列にも使用可能
#define vcinl(v,N) vl v(N); REP(i,N) cin >> v[i]
#define vmax(v) *max_element(all(v)) // 遅い？いつか書き直す
#define vmin(v) *min_element(all(v))
#define vidx(v,it) distance((v).begin(),(it))
#define vsum(v) accumulate(all(v),0)
#define vsumr(v,a,b) accumulate((v).begin()+(a),(v).begin()+(b),0) //[a,b)
#define vfnd(v,val) find(all(v),val) // itrを返す。存在しない場合v.end()を返す
#define vcnt(v,val) count(all(v),val)
#define vrep(v,it) for(auto it=(v).begin(); it != (v).end(); ++it)
#define IOS ios_base::sync_with_stdio(0); cin.tie(0) // IOS;で高速化

// デバッグ用
// dbg(...) printfと同様に使用可能 
// trc(var) (変数名)=(値)と表示
// stopif(val) 条件分が真の時に止まる
// vdbg(v) vの中身を表示
#ifdef LOCAL
    #define dbg(...) fprintf(stderr, __VA_ARGS__)
    #define trc(var) cout << #var << "=" << var << endl;
    #define trc2(v) cout << #v << "={"; 
    #define stopif(val) assert( !(val) )
    #define vdbg(v) vector_debug(v)
#else
    #define dbg(...) 1
    #define trc(var) 1
    #define trc2(v) 1
    #define stopif(val) 1
    #define vdbg(v) 1
#endif

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > vvi;
int gcd(int a, int b){if(a>b) swap(a,b); return a==0 ? b : gcd(b%a,a);}
ll gcd(ll a, ll b){if(a>b) swap(a,b); return a==0 ? b : gcd(b%a,a);}
template<typename C> inline void vector_debug(vector<C> v){trc2(v);ostream_iterator<C> o(cout,",");copy(all(v),o);cout<<"}"<<endl;}
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

// icin(x) ... int x; cin >> x;
// vcin(A,N),vcinl vi(vl) Aを宣言してcinで初期化

int main(){ IOS;
    scin(S);
    int ans = 1000;
    REP(i,sz(S)-2){
        int a = (S[i]-'0')*100+(S[i+1]-'0')*10+(S[i+2]-'0');
        amin(ans, abs(a-753));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BRACK 2
void visit(int);
int t=0,n;
int array[N][N], road_color[N] ,arr1[N], time[N];
int main(){
  int i,j,num1,num2,num3;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      array[i][j] = 0;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d %d",&num1,&num2);
    num1--;
    for(j=0;j<num2;j++){
      scanf("%d",&num3);
      num3--;
      array[num1][num3] = 1;
    }
  }
  for(i=0;i<n;i++) road_color[i] = WHITE;
 
  for(i=0;i<n;i++)  if(road_color[i] == WHITE) visit(i);
 
  for(i=0;i<n;i++) printf("%d %d %d\n", i+1,arr1[i],time[i]);
 
  return 0;
}
void visit(int u){
  int i;
  road_color[u] = GRAY;
  arr1[u] = ++t;
  for(i=0;i<n;i++){
    if(array[u][i] == 0) continue;
    if(road_color[i] == WHITE) visit(i);
  }
    road_color[i] = BRACK;
    time[u]=++t;
}

Measured memory_bytes: 636
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

int main() {
	int N;
	std::cin >> N;
	std::vector<int> A(N);
	for(int i = 0; i < N; i++) {
		std::cin >> A[i];
	}

	const int min = *std::min_element(A.begin(), A.end());
	const int max = *std::max_element(A.begin(), A.end());
	
	std::cout << std::abs(min - max) << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
typedef long long LL;
typedef long double LD;
typedef pair<LL, LL> PLL;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned long long ULL;
//typedef boost::multiprecision::cpp_int bigint;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	LL N, K;
	cin >> N >> K;
	VLL A(N);
	cin >> A[0];
	for (LL n = 1; n < N; n++) {
		cin >> A[n];
		A[n] += A[n - 1];
	}
	VLL B;
	for (LL e = 0; e < N; e++) {
		B.push_back(A[e]);
		for (LL s = 0; s < e; s++) {
			B.push_back(A[e] - A[s]);
		}
	}
	sort(B.begin(), B.end(), [](LL a, LL b) {
		return a > b;
	});
	LL ans = 0;
	N = B.size();
	for (LL ind = 40; ind >= 0; ind--) {
		if (B[K - 1] >= ((LL)1 << ind)) {
			ans += (LL)1 << ind;
			LL s = K - 1, e = N;
			//B[s] >= 2^ind > B[e]
			while (e - s > 1) {
				LL m = (e + s) / 2;
				if (B[m] >= ((LL)1 << ind))s = m;
				else e = m;
			}
			N = e;
		}
		for (LL n = 0; n < N;n++) {
			LL& b = B[n];
			b = b & (((LL)1 << ind) - 1);
		}
		sort(B.begin(), B.begin()+N, [](LL a, LL b) {
			return a > b;
		});
	}
	cout << ans << "\n";
	return 0;
}

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

int main() {
    int X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    vector<ll> A(X + 2000, -10000000000);
    vector<ll> B(Y + 2000, -10000000000);
    vector<ll> C(Z + 2000, -10000000000);
    rep(i, X) cin >> A[i];
    rep(i, Y) cin >> B[i];
    rep(i, Z) cin >> C[i];
    sort(rall(A));
    sort(rall(B));
    sort(rall(C));

    auto comp = [](pair<ll, vector<int>> a, pair<ll, vector<int>> b) {
        return a.first < b.first;
    };

    pair<ll, vector<int>> P;
    P = {A[0] + B[0] + C[0], {0, 0, 0}};
    priority_queue<pair<ll, vector<int>>, vector<pair<ll, vector<int>>>,
                   decltype(comp)>
        pq{comp};
    pq.push(P);
    map<pair<ll, vector<int>>, int> mp;
    mp[P]++;

    vector<ll> ans;
    while (!pq.empty() && ans.size() <= K) {
        pair<ll, vector<int>> q = pq.top();
        ans.push_back(q.first);
        pq.pop();

        vector<pair<ll, vector<int>>> newd(3);
        int a   = q.second[0];
        int b   = q.second[1];
        int c   = q.second[2];
        newd[0] = {A[a + 1] + B[b] + C[c], {a + 1, b, c}};
        newd[1] = {A[a] + B[b + 1] + C[c], {a, b + 1, c}};
        newd[2] = {A[a] + B[b] + C[c + 1], {a, b, c + 1}};

        if (mp[newd[0]] == 0 && a + 1 < X) {
            pq.push(newd[0]);
            mp[newd[0]]++;
        }
        if (mp[newd[1]] == 0 && b + 1 < Y) {
            pq.push(newd[1]);
            mp[newd[1]]++;
        }
        if (mp[newd[2]] == 0 && c + 1 < Z) {
            pq.push(newd[2]);
            mp[newd[2]]++;
        }
    }

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


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <set>
#include <cmath>
#include <math.h>
#include <sstream> 
 
using namespace std;


int main(){
    string s;
    cin>>s;
    int a=0,b=0,c=0;
    for(int i=0;i<3;i++){
        if(s[i]=='a'){
            a++;
        }else if(s[i]=='b'){
            b++;
        }else{
            c++;
        }
    }
    if(a!=1 || b!=1 || c!=1){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
    }
    return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;

int main() {
  int n, l, t, s = 0, m = INT_MAX;
  cin >> n >> l;
  REP(i, n) {
    t = l + i;
    s += t;
    if (abs(t) < abs(m)) m = t;
  }
  cout << s - m << endl;
  return 0;
}

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

typedef long long ll;
const ll INF = 1e9, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define REPR(i,a,b) for(ll i=b;i>=a;i--)
#define repr(i,n) REPR(i,0,n)
#define all(v) (v).begin(), (v).end()
#define pb push_back

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

    ll ans = 0;
    string s;
    cin >> s;
    rep(i,s.size()-1){
        if((s[i]=='B' && s[i+1]=='W') || (s[i]=='W' && s[i+1]=='B')) ans++;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char const *argv[]) {

  int num;
  int *line;
  int i,j;
  int temp;
  int count = 0;

  scanf("%d",&num);

  line = (int *)malloc( num * sizeof(int) );

  for( i = 0 ; i < num ; i++ )
    scanf("%d",&line[i]);

  for( i = 0 ; i < num-1 ; i++ ){
    for( j = num-1 ; j > i ; j-- ){
      if( line[j-1] > line[j] ){
        temp = line[j];
        line[j] = line[j-1];
        line[j-1] = temp;
        count++;
      }
    }
  }

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

  printf("%d\n%d\n",line[num-1],count);

  return 0;
}

Measured memory_bytes: 600
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cassert>

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int n,i;

int main()
{
	cin>>n>>i;
	cout<<n-i+1<<endl;
}

Measured memory_bytes: 256
while True:
    S = input()
    if(S == "-"):break
    m = int(input())
    for i in range(m):
        h = int(input())
        #print(S[h:])
        #print(S[0:h])
        tmp = S[h:] + S[0:h]
        #print(tmp)
        S = tmp
    print(S)


Measured memory_bytes: 5596
n = int(input())
x = list(map(int, input().split()))
if n == 2:
    print(x[1])
    print(x[0])
    exit()
xsort = sorted(x)
center = (xsort[n//2] + xsort[n//2-1]) / 2
for i in range(n):
    if center <= x[i]:
        print(xsort[n//2-1])
    else:
        print(xsort[n//2])


Measured memory_bytes: 25556
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
#%%code
def resolve():
    H,W,K=pin()
    choco=[list(input()) for _ in range(H)]
    #think H<=10:bit full search
    ans=H+W #default
    #print(choco)
    for h in range(1<<(H-1)):#uekara h banme no yoko de waru
        tempans=0

        see=[]

        shiro=[0]
        for i in range(H):
            see.append(tempans)
            if (1<<i)&h:
                tempans+=1 
                shiro.append(0)
            
        #print(see,tempans,bin(h),"sth")
        #print(shiro,";")
        #yokoni krenai nara donkoku de jituhatokeru
        j=0
        while(j<W):
            f=1
            for n,s in enumerate(see):
                shiro[s]+=int(choco[n][j])
                if shiro[s]>K:#suguhidaride kiru
                    if j==0:#kirenai kara nasi                        
                        f=0
                        break
                    tempans+=1
                    shiro=[0]*len(shiro)
                    j-=1
                    break   
            if f==0:
                tempans=H*W
                break
            j+=1
            #print(j,shiro,"tochu") 
            
        #print(tempans,"tempans")
        ans=min(ans,tempans)
    print(ans)
#%%submit!
resolve()

Measured memory_bytes: 42588
N = str(input())
m0 = int(N[0])
m1 = int(N[0]) + 1
M0 = 100*m0 + 10*m0 + m0
M1 = 100*m1 + 10*m1 + m1
if int(N[1])<=int(N[0]) and int(N[2])<=int(N[0]):
    print(M0)
else:
    print(M1)

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

int solve(int N, const vector<int>& s) {
  int sum = 0;
  REP(i,N) sum += s[i];
  if(sum % 10) return sum;

  int sub = 0;
  REP(i,N) {
    if(s[i] % 10) {
      sub = s[i];
      break;
    }
  }
  if(sub) return sum - sub;
  else return 0;
}

int main(){
  int N;
  cin >> N;
  vector<int> s(N);
  REP(i,N) cin >> s[i];
  sort(ALL(s));

  cout << solve(N, s) << endl;
  return 0;
}



Measured memory_bytes: 256
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import math
import collections

PRICES = [0, 300000, 200000, 100000]

X, Y = map(int, sys.stdin.readline().rstrip().split(" "))

price = 0
for x in [X, Y]:
    if x <= 3:
        price += PRICES[x]
if X == 1 and Y == 1:
    price += 400000
print(price)
exit(0)


Measured memory_bytes: 3436
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    try {
      int a = scanner.nextInt();
      int b = scanner.nextInt();

      System.out.println(solve(a,b));
    } finally {
      scanner.close();
    }
  }

  private static int solve(int a, int b) {
    if (a > b) return a - 1;
    return a;
  }
}


Measured memory_bytes: 35804
N = int(input())
As = list(map(int, input().split()))
a,b,c = [0]*N,[0]*N,[0]*N
for i in As:
  a[i-1] += 1
  b[i-1] = a[i-1]*(a[i-1]-1)//2
  c[i-1] = (a[i-1]-1)*(a[i-1]-2)//2

d = sum(b)
print("\n".join([str(d-b[i-1]+c[i-1]) for i in As]))

Measured memory_bytes: 33536
A,B,C,X,Y = map(int,input().split())
achete_A = 0
achete_B = 0
price = 10**100
C = 2 * C #=A,B
for i in range(0,10**5+1):
    price = min(price,i*C + A*max(0,X-i) + B * max(0,Y-i))
print(price)

Measured memory_bytes: 3060
#include <iostream>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <algorithm>
#include <functional>
#include <cstring>
#include <limits.h>

#define FOR(i,k,n)  for (int i=(k); i<(int)(n); ++i)
#define REP(i,n)    FOR(i,0,n)
#define FORIT(i,c)	for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define SZ(i) ((int)i.size())
#define pb          push_back
#define mp          make_pair
#define mt          make_tuple
#define ALL(X)      (X).begin(),(X).end()
#define LLMAX       9223372036854775807
#define LLMIN       -9223372036854775808
#define IMAX        2147483647
#define IMIN        -2147483648
typedef long long LL;

using namespace std;

int main(void){
    int N;LL C;int K;cin>>N>>C>>K;
    vector<LL> T;
    REP(i,N){
        int a;cin>>a;T.pb(a);}
    sort(ALL(T));
    int r=1,b=T[0],c=0;
    REP(i,N){
        c++;
        if(b+K<T[i] || C<c){
            c=1;
            b=T[i];
            r++;
        }
    }
    cout<<r<<endl;
     return 0;
}

Measured memory_bytes: 1400
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a, int b){return a*b/gcd(a,b);}

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    string s;
    cin >> s;
    if((s[6]=='1'&&s[5]=='0')||(s[6]=='2'&&s[5]=='0')||s[6]=='3'||s[6]=='4')
    {
        cout << "Heisei" << endl;
    }
    else
    {
        cout << "TBD" << endl;
    }
}


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

int N, M;
vector<pair<int, int>> v;
vector<bool> visited(51);
vector<unordered_set<int>> vg(51);

void DFS(int k){
  visited[k] = true;
  for(auto x: vg[k]){
    if(visited[x]){
      continue;
    }
    DFS(x);
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    v.emplace_back(a, b);
    vg[a].insert(b);
    vg[b].insert(a);
  }
  long long ans = 0;

  for(int i = 0; i < M; i++){
    fill(visited.begin(), visited.end(), false);
    int a = v[i].first;
    int b = v[i].second;
    vg[a].erase(b);
    vg[b].erase(a);
    visited[0] = true;
    DFS(0);
    vg[a].insert(b);
    vg[b].insert(a);
    for(int j = 0; j < N; j++){
      if(!visited[j]){
        break;
      }
      if(j == N-1){
        ans++;
      }
    }
  }
  cout << M - ans <<endl;
}


Measured memory_bytes: 3640
#include<iostream>
#include<vector>
#include<map>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<set>
#include<bitset>
#include<iomanip>
#define BUG puts("no bug")
#define sci(x) scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define ll long long
#define ull unsigned long long
#define REP(a,b,c) for(int a=b;a<=c;a++)
#define PER(a,b,c) for(int a=b;a>=c;a--)
#define lb(a) (a&(-a))
#define pp (p<<1)
#define ppp (p<<1|1)
#define pi pair<int,int>
#define pii pair<pair<int,int>,int>
using namespace std;
const int MAXN=1e6+5;
int n,m,t;
int v[MAXN];
char s[MAXN];
int main(){
    int head=2e5,tail=2e5,now=0;
    cin>>s+int(2e5);
    head=2e5,tail=2e5+strlen(s+int(2e5));
    cin>>n;
    REP(i,1,n){
        int a;
        sci(a);
        if(a==1)now^=1;
        if(a==2){
            int b;
            sci(b);
            char tmp;
            cin>>tmp;
            if((b==2&&now==0)||(b==1&&now==1)){
                s[tail++]=tmp;
            }
            else s[--head]=tmp;
        }
    }
    s[++tail]='\0';
    if(now==1)reverse(s+head,s+tail-1);
    cout<<s+head;
}

Measured memory_bytes: 896
/*
* @Author: _dp95
* @Date:   2019-02-10 15:23:45
*/
#include "bits/stdc++.h"
using namespace std ;

#define timesaver ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll ;
typedef long double ldb ;

#define mp make_pair
#define pb push_back
#define F first
#define S second
#define nl '\n'

#define all( x ) x.begin(),x.end() 
#define sz( x ) ( int )( x ).size( )
#define mem( a, val ) memset(a, val, sizeof( a ) )
#define deci( x ) cout<<fixed<<setprecision( x );
#define bitcount( x ) __builtin_popcountll( x )

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

const int MAX = 2*1000*1000 + 10 ;
const ll INF = 1e18 ;
const int MOD = 1e9 + 7 ;

ll ar[ MAX ], dp[ MAX ] ;

int main( ){
  timesaver ;
  int n, k ;
  cin >> n >> k ;
  for( int i = 0 ; i < n ; i++ ){
    cin >> ar[ i ] ;
  }
  dp[ 0 ] = 0 ;
  dp[ 1 ] = abs( ar[ 1 ] - ar[ 0 ] ) ;
  for( int i = 2 ; i < n ; i++ )
    dp[ i ] = INF ;
  for( int i = 2 ; i < n ; i++ ){
    for( int j = 1 ; j <= k and i - j >= 0 ; j++ ){
      dp[ i ] = min( dp[ i ], dp[ i - j ] + abs( ar[ i ] - ar[ i - j ] ) ) ;
    }
  }
  cout << dp[ n - 1 ] << nl ;
}

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

using namespace std;
using ll = long long;

int gcd(ll div,ll mod){
    if(div % mod == 0){
        return mod;
    }else{
        return gcd(mod,div % mod);
    }
}

int main() {
    ll a,b = 0;
    cin >> a >> b;
    ll c = gcd(a,b);
    cout << a * b / c << endl;
    return 0;
}

Measured memory_bytes: 256
// 2019/03/08 Tazoe

#include <iostream>
using namespace std;

int main()
{
	int x1, x2;
	cin >> x1 >> x2;

	int d = x1-x2;

	if(d<0){
		d = -d;
	}

	cout << d << endl;

	return 0;
}



Measured memory_bytes: 3088
import itertools
import os
import sys

import numpy as np
from scipy.sparse.csgraph._shortest_path import floyd_warshall

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

N = int(sys.stdin.buffer.readline())
AB = [list(map(int, sys.stdin.buffer.readline().split())) for _ in range(N - 1)]

# plot_graph(AB)

graph = [[] for _ in range(N)]

for a, b in AB:
    graph[a].append(b)
    graph[b].append(a)


def test():
    G = [[0] * N for _ in range(N)]
    for a, b in AB:
        G[a][b] = 1
        G[b][a] = 1
    dist = floyd_warshall(G)
    ret = N
    for choice in itertools.product([True, False], repeat=N):
        k = sum(choice)
        if k == 0:
            continue
        if k >= ret:
            continue
        D = dist[np.array(choice, dtype=bool)]
        s = set()
        for d in D.T:
            s.add(str(d))
        if len(s) == D.shape[1]:
            ret = min(ret, k)
    return ret


def dfs(v, p, forked):
    """
    :param v:
    :param p:
    :param bool forked: 枝分かれしてる頂点が先祖にあるか
    """
    # 枝分かれしてる頂点 (次数が3以上の頂点) について、
    # 枝分かれしてる頂点がない方向が1以下になるようにする
    counts = []
    for u in graph[v]:
        if u == p:
            continue
        cnt = dfs(u, v, forked or len(graph[v]) >= 3)
        counts.append(cnt)
    zeros = counts.count(0) + (not forked)
    return sum(counts) + max(0, zeros - 1)


leaf = 0
for v in range(N):
    if len(graph[v]) == 1:
        leaf = v
        break
ans = dfs(leaf, None, False)
print(ans)
# if ans != test():
#     print(ans, test())
#     print(AB)
#     print()


Measured memory_bytes: 141440
#include <bits/stdc++.h>
 
using namespace std;
 
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
 
const long long INF = 1LL << 60;
#define PI 3.14159265359 
long long MOD = 1000000007;


template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}
 
int gcd(int a, int b){
    if(b == 0) return a;
    else return gcd(b, a%b);
}
 
long long lcm (int a, int b){
    return  (long long) a*b /gcd(a,b);
}

long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }

long long dp[200100];


using namespace std;
using Graph = vector<vector<int>>;

// 深さ優先探索
vector<bool> seen;
void dfs(const Graph &G, int v) {
    seen[v] = true;
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue;
        dfs(G, next_v); // 再帰的に探索
    }
}

int main() {
    // 頂点数と辺数
    int N, M; cin >> N >> M;

    // グラフ入力受取
    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }

    // 全頂点が訪問済みになるまで探索
    int count = 0;
    seen.assign(N, false);
    for (int v = 0; v < N; ++v) {
        if (seen[v]) continue; // v が探索済みだったらスルー
        dfs(G, v); // v が未探索なら v を始点とした DFS を行う
        ++count;
    }
    cout << count-1 << endl;
}





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

#define pp push_back
#define pf push_front
#define mp make_pair
#define fs first
#define sc second
#define sf scanf

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;

const int N = (int) 1e5;
const ll INF = (ll) 1e16 + 7;

int main(int argc, char *argv[])
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	ll a, b, n;
	cin >> a >> b >> n;

	ll l = 0, r = n;
	ll ans = INT_MIN;
	while (l <= r) {
		ll mid = (l + r) / 2;
		ll x = (a * mid) / b - a * (mid / b);
		if (x >= ans) {
			ans = x;
			l = mid + 1;
		}
		else {
			r = mid - 1;
		}
	}

	cout << ans;

	return 0;
}


Measured memory_bytes: 3608
import numpy as np
a, b, h, m = map(int, input().split())
ang = abs((30 * h + .5 * m) % 360 - (6 * m) % 360)
ang *= np.pi / 180
print(np.sqrt(a**2 + b**2 - 2 * a * b * np.cos(ang)))


Measured memory_bytes: 27196
#!/usr/bin/env python3

import sys

debug = False

def solve(ds, n, x, m):
    ds = [d % m for d in ds]

    nr_loop = (n - 1) // len(ds)
    lastloop_remaining = (n - 1) % len(ds)
    a_n = x
    cnt_zero = 0
    for i in range(0, len(ds)):
        dmod = ds[i] % m
        a_n += (dmod) * nr_loop
        if dmod == 0:
            cnt_zero += nr_loop
        if i < lastloop_remaining:
            a_n += dmod
            if dmod == 0:
                cnt_zero += 1
    cnt_decrease = a_n // m - x // m
    return n - 1 - cnt_decrease - cnt_zero


def read_int_list(sep = " "):
    return [int(s) for s in sys.stdin.readline().split(sep)]


def dprint(*args, **kwargs):
    if debug:
        print(*args, **kwargs)
    return


def main():
    k, q = read_int_list()
    d = read_int_list()
    for _ in range(0, q):
        n, x, m = read_int_list()
        print(str(solve(d, n, x, m)))
    

if __name__ == "__main__":
    main()

Measured memory_bytes: 55900
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class ATheNumberOfEvenPairs {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int N, M;
        in>>N>>M;
        out<<N*(N-1)/2+M*(M-1)/2<<'\n';
    }
};


int main() {
	ATheNumberOfEvenPairs solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int k;
int main(){
  cin >> k;
  string s;
  cin >> s;
  cout << s.substr(0,k);
  if(s.size()>k){cout << "...";}
  cout << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <iostream>
#include <locale>
#include <numeric>
#include <string>
#include <vector>
#include <cmath>

using namespace std;

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

    if(13<=n)cout<<m;
    else if(6<=n)cout<<m/2;
    else cout<<0;
    cout<<endl;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

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

	int cnt = 0;
	for (int i = 1; i < n+1; i++) {
		string s = to_string(i);

		if (s.size() % 2 == 1)cnt++;
	}

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

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;

int main()
{
    int A, B, C;
    cin >> A >> B >> C;
    for (int m = 1; m <= B; ++m)
    {
        if (m * A % B == C)
        {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
n,k,q = gets.strip.split.map(&:to_i)
array = Array.new(n,0)
q.times do |i|
  a = gets.to_i
  array[a-1] += 1
end
n.times do |i|
  if k-q+array[i] > 0
    puts "Yes"
  else
    puts "No"
  end
end

Measured memory_bytes: 15128
#include <stdio.h>
main() {
  int i,n,m=100000;
  scanf("%d",&n);
  for(i=0;i<n;i++) {
    m *= 1.05; if(m%1000) m+=1000;
    m/=1000; m*=1000;
  }
  printf("%d\n",m);
}

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

using namespace std;

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

const int MOD = 1000000007;

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

    bool flag = true;
    h[0]--;
    for(int i = 1; i < n; i++) {
        if(h[i - 1] < h[i]) h[i]--;
        else if(h[i - 1] == h[i]) continue;
        else {
            flag = false;
            break;
        }
    }

    cout << (flag? "Yes" : "No") << endl;

    return 0;
}



Measured memory_bytes: 640
#include<iostream>
#include<cstdio>

using namespace std;

int main(){

	int a,b,z;
	char op;

	while(1){
	
	cin >> a >> op >> b;

	if(op == '+'){
		z = a + b;
		
		}
	if(op == '-'){
		z = a - b;
		}
	if(op == '*'){
		z = a * b;
		}
	if(op == '/'){
		z = a / b;
		}
		if( op == '?')break;
	
	cout << z << endl;
	
	}
	

	
	
return 0;
}

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

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


def solve(S: str):
    s_list = list(S)
    for i, s in enumerate(s_list):
        if i % 2 == 1:
            if s not in ['L', 'U', 'D']:
                print('No')
                return
        else:
            if s not in ['R', 'U', 'D']:
                print('No')
                return
    print('Yes')


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>

using namespace std;

int main(){

  char str[200];
  scanf("%s" , str);
  int n = strlen(str);
  for(int i=n-2; i>0; i-=2){
      if(strncmp(str,str+i/2, i/2) == 0){
        printf("%d\n",i);
        return 0;
      }
  }
}


Measured memory_bytes: 128
#include <iostream>
#include <queue>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <numeric>

using namespace std;
using ll = long long;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

int main() {
    int N, K;
    cin >> N >> K;
    int ans = 0;
    for (int i = 0; i < N; i++) {
        int x;
        cin >> x;
        ans += min(x, K-x) * 2;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
const ll INF=1e18+7;
const ll N = 1007;


ll keta(ll x){
	ll ans = 0;
	while(x){
		ans++;
		x/=10;
	}
	return ans;
}



int main(){
	ll n;
	cin>>n;
	ll ans = INF;
	FOR(i,1,sqrt(n)+1){
		if(n % i == 0){
			ans = min(ans,keta(max(i,n/i)));
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
a = int(input())
ar = list(map(int,input().split(" ")))
br = []
if a % 2 == 0:
    for i in range(len(ar)-1,0,-2):
        br.append(ar[i])
    for i in range(0,len(ar)-1,+2):
        br.append(ar[i])
else:
    for i in range(len(ar)-1,-1,-2):
        br.append(ar[i])
    for i in range(1,len(ar)-1,+2):
        br.append(ar[i])
for i in range(a-1):
    print(str(br[i]),end = " ")
print(str(br[a-1]))

Measured memory_bytes: 25748
/*Whose woods these are I think I know.
His house is in the village though;
He will not see me stopping here
To watch his woods fill up with snow.
 
My little horse must think it queer
To stop without a farmhouse near
Between the woods and frozen lake
The darkest evening of the year.
 
He gives his harness bells a shake
To ask if there is some mistake.
The only other sound’s the sweep
Of easy wind and downy flake.
 
The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/
 
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007
const int maxn= 100010;
lli a[10*maxn];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=0,m=0;lli sum=0ll;
    cin>>n>>m;
    for(int i=0;i<m;++i)
	{
		cin>>a[i];
		sum+=a[i];
	}
	if(sum>n)
		cout<<"-1";
	else
		cout<<(n-sum);
	cout<<endl;
}


Measured memory_bytes: 3712
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back

using namespace std;
const long long MOD = (long long)1e9 + 7;

int x, y;

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> x >> y;
    int s = x*3 + y;
    cout << s/2 << "\n";
    //system("pause");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

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

    int sum = 0;
    for(int i = 0; i < n; ++i){
        int val;
        std::cin >> val;
        sum += val;
    }

    if(h <= sum){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main() {
	int n,ans=0; cin >> n;
	for(int i = 0; i < n; ++i) {
		int a, b; cin >> a >> b;
		((a == b) ? ++ans : ans = 0);
		if(ans >= 3)break;
	}
	cout<<(ans >= 3 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3596
n=int(input())
arr=list(input())
arr=[int(arr[i]) for i in range(n)]
if n==1:
  print(arr[0])
if n==2:
  print(abs(arr[0]-arr[1]))
else:
  tmp=[]
  for i in range(n-2):
    tmp.append(abs(abs(arr[i]-arr[i+1])-abs(arr[i+1]-arr[i+2])))
  arr=tmp
  while len(arr)>3:
    tmp=[]
    if len(arr)%2==0:
      for i in range(len(arr)//2):
        tmp.append(abs(arr[2*i]-arr[2*i+1]))
    else:
      for i in range(len(arr)-1):
        tmp.append(abs(arr[i]-arr[i+1]))
    arr=tmp
  if len(arr)==1:
    print(arr[0])
  elif len(arr)==2:
    print(abs(arr[0]-arr[1]))
  elif len(arr)==3:
    print(abs(abs(arr[0]-arr[1])-abs(arr[1]-arr[2])))

Measured memory_bytes: 21364
#!/usr/bin/env python3
import sys
import collections as cl


def II(): return int(sys.stdin.readline())


def MI(): return map(int, sys.stdin.readline().split())


def LI(): return list(map(int, sys.stdin.readline().split()))


def main():
    x, y, a, b, c = MI()
    p = LI()
    q = LI()
    r = LI()

    p.sort(reverse=True)
    q.sort(reverse=True)
    r.sort(reverse=True)

    p_selected = p[:x]
    q_selected = q[:y]

    ans = [*p_selected, *q_selected]

    ans.sort()
    i = 0

    while i < x + y and i < c and ans[i] < r[i]:
        ans[i] = r[i]
        i += 1

    print(sum(ans))


main()


Measured memory_bytes: 100268
n = int(raw_input())
s1 = raw_input().split(" ")
s2 = raw_input().split(" ")
ss1 = []
for i in s1:
  ss1.append(int(i))
s1 = tuple(ss1)

ss2 = []
for i in s2:
  ss2.append(int(i))
s2 = tuple(ss2)

from itertools import permutations

# Get all permutations of [1, 2, 3]
perm = permutations(list(range(1,n+1)))

t= 0
s1c = None
s2c = None
for i in list(perm):
    if s1 == i:
      s1c = t
    if s2 == i:
      s2c = t
    if s1c and s2c:
    	break
    t += 1
print(abs(s1c-s2c))

Measured memory_bytes: 7940