akhauriyash/Code-Regression huggingface dataset:
//  実行時間29ms, メモリ896KB
#include <stdio.h>

int main()
{
  int i, j, k, d, n;
  scanf("%d %d", &n, &k);
  
  int h[n+k];
  int cost[n+k];
  for (i=0; i<n; i++)  scanf("%d", &h[i]);
  for (; i<n+k; i++) {
    h[i] = h[n-1];
    cost[i] = 0;
  }

  for (i=n-1; i>=0; i--) {
    cost[i] = h[i]-h[i+k];
    if (cost[i]<0) cost[i]=-cost[i];
    cost[i] += cost[i+k];
    for (j=k-1; j>0; j--) {
      d = h[i]-h[i+j];
      if (d<0) d=-d;
      if (cost[i] > d + cost[i+j])
	cost[i] = d + cost[i+j];
    }
  }
  
  printf("%d\n", cost[0]);

  return 0;
}


Measured memory_bytes: 896
#include<stdio.h>
#define MAX 100005
#define NIL -1
struct Node_struct{int p, l, r;}; /*p: 親(parent), l: 一番左の子(left child), r:右の兄弟(right sibling)*/
typedef struct Node_struct Node;
Node T[MAX];
int D[MAX];

void print(int u){
  int i, c;
  printf("node %d: parent = %d, depth = %d, ", u, T[u].p, D[u]);

  if(T[u].p==-1) printf("root, ");
  else if(T[u].l==-1) printf("leaf, ");
  else printf("internal node, ");
  
  printf("[");
  for (i=0, c = T[u].l; c != NIL; i++, c = T[c].r){
    if(i) printf(", ");
    printf("%d", c);
  }
  printf("]\n");
  
}

void calcDepth(int u, int p){
  D[u] = p;
  if(T[u].r!=-1)calcDepth(T[u].r,p);
  if(T[u].l!=-1) calcDepth(T[u].l,p+1);
}

int main(){
  int i, j, k;
  int n;
  int id, sib, child;
  int root = NIL;
  scanf("%d", &n);
  for(i=0; i<n; i++) T[i].p = T[i].l = T[i].r = NIL;
  
  for(i=0; i<n; i++){
    scanf("%d %d", &id, &k);
    for(j = 0, sib = NIL; j<k; j++){ //子を入力する (input children)
      scanf("%d", &child);
      T[child].p = id;
      if(j == 0) T[id].l = child; //idの一番左の子 (the most left child of id)
      else T[sib].r = child; //左の兄弟に繋げる (connect to left sibling)
      sib = child;//次の子供の左の兄弟 (the left sibling of the next child)
    }
  }

  //根を求める (find the root)
  for(i=0; i<n; i++){
    if(T[i].p == -1) root = i;
  }
  
  //それぞれのノードの深さを求める (find depth of each node)
  calcDepth(root, 0);

  //出力 (output)
  for(i=0; i<n; i++) print(i);
  
  return 0;
}



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

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

  int n,k;
  cin >> n >> k;

  vec a(26,0);
  REP(i,n){
    string s;
    cin >> s;
    a[s[0]-'A']++;
  }

  FOR(i,1,INF){
    int sum = 0;
    REP(j,26) sum += min(a[j],i);
    if(sum < i*k){
      cout << i-1 << endl;
      return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h> 
int main()
{
	int N;
	scanf("%d", &N);
	
	int r;
	int A[N];
	int B[N];
	
	for(r=0; r<N; r++){
		scanf("%d", &A[r]);
		B[A[r]-1] = r+1;
	}
	
	for(r=0; r<N; r++)  printf("%d ", B[r]);
	
	return 0;


}

Measured memory_bytes: 1536
#include<cstdio>
#include<algorithm>
using namespace std;
const static int MOD = 1e9+7;
using ull = unsigned long long;

int main(){
    int N;
    scanf("%d", &N);
    int A[N], B[N];
    for(int i = 0; i < N; ++i){
        scanf("%d", A + i);
        B[i] = abs(i - (N - 1 - i));
    }
    sort(A, A + N);
    sort(B, B + N);
    for(int i = 0; i < N; ++i){
        if(A[i] != B[i]){
            printf("0\n");
            return 0;
        }
    }
    ull answer = 1ULL;
    for(int i = 0; i < N>>1; ++i){
        (answer <<= 1) %= MOD;
    }
    printf("%llu\n", answer);
    return 0;
}

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

using namespace std;
using ll = long long;


int main()
{
	int n; cin >> n;
	vector<string> ss(n); for(int i = 0; i < n; i++)cin >> ss[i];
	int cnt = 0;
	int frb = 0, bca = 0;
	int flag = 0;

	for(int i = 0; i < n; i++) {
		frb += ss[i].front() == 'B';
		bca += ss[i].back() == 'A';
		if(ss[i].front() == 'B' && ss[i].back() != 'A')flag |= 1;
		if(ss[i].back() == 'A' && ss[i].front() != 'B')flag |= 2;

		int n = ss[i].size();
		for(int j = 1; j < n; j++) {
			if(ss[i][j - 1] == 'A' && ss[i][j] == 'B')cnt++;
		}
	}

	cerr << frb << " : " << bca << " :: " << cnt << endl;
	cout << cnt + max(min(frb, bca) - (flag == 0), 0) << endl;

}

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    string s;
    map<string, int> m;

    while (n--)
    {
        cin >> s;
        if(m.find(s) == m.end())
            m.insert(make_pair(s, 1));
        else
            m[s]++;
    }
    cout << m.size() << endl;
    return 0;
}

Measured memory_bytes: 19152
#include<iostream>
#include<algorithm>
#include<map>
#include <vector>
#include <numeric>
#include <functional>
using namespace std;

int main()
{
    int n, tp;
    string ts;
    cin >> n;
    map<pair<string, int>, int> p;

    for(int i=0; i<n; i++){
        cin >> ts >> tp;
        p[make_pair(ts, tp*-1)] = i;
    }
    for(auto i = p.begin(); i != p.end(); i++){
        cout << i->second  + 1 << endl;
    }
    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;
#define MODSIZE 1000000007

int main(){
  char s[15];
  char q[15];
  int head = 0;
  int tail = 0;

  scanf("%s", s);

  int i;
  int n;

  n = strlen(s);
  
  for(i = 0;i < n;i++){
    if(s[i] == '0') q[tail++] = '0';

    else if(s[i] == '1') q[tail++] ='1';

    else{
      if(head != tail) tail--;
    }
  }

  for(i = 0;i < tail;i++) printf("%c", q[i]);
  printf("\n");
  return 0;
}

Measured memory_bytes: 256
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
/*多倍長整数/cpp_intで宣言
#include <boost/multiprecision/cpp_int.hpp>

using namespace boost::multiprecision;
*/

//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0
#define addf(T) [](T a, T b){return (a + b);}
#define minf(T) [](T a, T b){return min(a, b);}
#define maxf(T) [](T a, T b){return max(a, b);}


using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const long double PI = acos(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

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

ll lcm(ll number1, ll number2) {//lcmを求める
	return number1 / gcd(number1, number2) * number2;
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int n, m;
	scanf("%d", &n);
	scanf("%d", &m);
	string s, t;
	rep(i, m)s += to_string(n);
	rep(i, n)t += to_string(m);
	prints(min(s, t));

	Please AC;
}


Measured memory_bytes: 888
#include<iostream>
#include<string>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<climits>
#include<cmath>
#include<map>
#define INF INT_MAX
using namespace std;

int A, B;
int N;
int a;

int main(){
	cin >> N >> A >> B;
	a = A*N;
	if (a < B){
		cout << a << endl;
	}
	else if (a>B){
		cout << B << endl;
	}
	else{
		cout << a << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);cout.precision(20);}} fast;

/* define */
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) (upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X))
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl;
#define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define ctoi(C) (C-'0')
#define pow2(x) ((long long)((long long)1<<x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int,int>;
using pl = pair<long long,long long>;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1,0,-1,0};
const long long dy[] = {0,1,0,-1};
const long long dx8[] = {1,1,0,-1,-1,-1,0,1};
const long long dy8[] = {0,1,1,1,0,-1,-1,-1};
const long long dx9[] = {1,1,0,-1,-1,-1,0,1,0};
const long long dy9[] = {0,1,1,1,0,-1,-1,-1,0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
long long max(long long x,int y){return max(x,(long long)y);}
long long max(int x,long long y){return max((long long)x,y);}
long long min(long long x,int y){return min(x,(long long)y);}
long long min(int x,long long y){return min((long long)x,y);}

/* liblary */



/* main */

ll calc(vi v){
    ll ans = 0;
    for(auto x:v){
        ans = ((ans+9)/10)*10;
        ans += x;
    }
    return ans;
}

signed main(){
    vector<int> v(5);
    FOR(i,0,5)cin >> v[i];
    ll ans = INF;
    sort(ALL(v));
    do{
        chmin(ans,calc(v));
    }while(next_permutation(ALL(v)));
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  long long int n, k, a, c[100010]={};
  double b=0;
  scanf("%lld %lld", &n, &k);

  for(int i=1; i<=n; i++)
  {
      c[i]=n;
  }
  for(int i=1; i<=n; i++)
  {
      for(int j=0; j<=100010; j++)
      {

          if((i<<j)>=k)
         break;
          else
            c[i]=c[i]*2;
      }
    b=b+(1./c[i]);
  }
  printf("%.12f", b);
}


Measured memory_bytes: 896
#include "bits/stdc++.h"

#define rep(a,b) for(int a = 0;a < b;a++)
#define REP(i, x, n) for(int i = x; i < n; i++)
#define P(a) cout << a << endl
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ssort(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define vP(v) for(int i = 0;i < v.size();i++){cout << v[i];if(i != v.size()-1)cout << endl;}
#define vcin(v,n) rep(i,n){int a;cin >> a;v.pb(a);}

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0 };
int dy[] = { 0,  0,  1, -1 };
ll MOD = 1000000007;

void solve(){
	string a,b;
	cin >> a >> b;
	if(a == b)P("H");
	else P("D");
}

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


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>

using namespace std;

#define REP(a, i, n) for (int i = a; i < n; ++i)

int main() {
    int n; cin >> n;
    int p[n]; REP(0, i, n) cin >> p[i];
    int cnt = 0;
    REP(0, i, n - 2) {
        if (p[i] > p[i + 1] && p[i + 1] > p[i + 2]) {
            cnt++;
        } else if (p[i] < p[i + 1] && p[i + 1] < p[i + 2]) {
            cnt++;
        } else {
        }
    }
    cout << cnt << endl;
    return 0;
}


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

int main(){

int N, t, x, y, tt, xx, yy;
  cin >> N;
t = 0;
x = 0;
y = 0; 

bool hantei = true;  
  
  while(N){
    cin >> tt >> xx >> yy;
  if(abs(xx - x) + abs(yy - y) > tt){
  cout << "No" << endl;
  hantei = false;  
    break;
  }
  else if(((tt - t) - (abs(xx - x) + abs(yy - y))) % 2 == 1) {
    cout << "No" << endl;
    hantei = false;
    break;  
  }
  
  t = tt;
  x = xx;
  y = yy;
  N--;
  }

  if(hantei) cout << "Yes" << endl;
return 0;
  
}

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

int main(void){
    set<int> S;
    set<int>::iterator begin,end;
    int q;
    cin >> q;

    for(int i=0; i<q; i++){
        int cmd;
        cin >> cmd;
        if(cmd==0){
            int x;
            cin >> x;
            S.insert(x);
            cout << S.size() << "\n";
        }
        else if(cmd==1){
            int x;
            cin >> x;
            if(S.find(x) != S.end()){
                cout << 1 << "\n";
            }
            else{
                cout << 0 << "\n";
            }
        }
        else if(cmd==2){
            int x;
            cin >> x;
            S.erase(x);
        }
        else if(cmd==3){
            int L,R;
            cin >> L >> R;
            begin = S.lower_bound(L);
            end = S.upper_bound(R);
            for(; begin!=end; begin++){
                cout << *begin << "\n";
            }
        }
    }
    return 0;
}


Measured memory_bytes: 12420
program rotation_sort
  implicit none
  integer :: n, p(5000) = 0, i, j
  integer(8) :: a, b, dp(0:5000,0:5000) = 0_8
  read(*,*) n, a, b
  read(*,*) p(1:n)
  do i = 1, n
    do j = 0, n
      dp(i,j) = dp(i-1,j)
      if (j < p(i)) then
        dp(i,j) = dp(i,j)+a
      else if (j > p(i)) then
        dp(i,j) = dp(i,j)+b
      end if
      if (j > 0) dp(i,j) = min(dp(i,j),dp(i,j-1))
    end do
  end do
  write(*,'(i0)') dp(n,n)
end program rotation_sort

Measured memory_bytes: 195712
#include<bits/stdc++.h>
using namespace std;
#define int long long  
#define mod 1000000007
#define am 998244353
#define INFi 2147483647
#define INFl 9223372036854775807LL
#define fi first
#define se second
#define be begin()
#define en end()
int abs(int a,int b){ 
  int c=max(a,b)-min(a,b);
  return c;
}
int gcd(int a,int b){//最大公約数
  int c=a%b;
  while(true){
    if(c==0) break;
    a=b;
    b=c;
    c=a%b;
  }
  return b;
}
bool IsPrime(int num){
  if (num < 2) return false;
  else if (num == 2) return true;
  else if (num % 2 == 0) return false;
  double sqrtNum = sqrt(num);
  for(int i=3;i<=sqrtNum;i+=2){
    if(num%i==0){
      return false;
    }
  }
}
int lcm(int a,int b){//最小公倍数
    return (a*b)/gcd(a,b);
}	    
signed main(){
// __builtin_ctz(N);      Nを２で何回割り切れるかを返す
//(n+1)*n/2;              １からNまでの総和を求める式
    cin.tie(0);
    ios::sync_with_stdio(false);
    string b,c;
    int a,d;
    cin>>a>>b;
    c=b[b.size()-1];
    for(int i=0;i<b.size();i++){
	b[i]=b[i]+a;
	if(b[i]>'Z') d=b[i]-'Z',b[i]=64+d;
	cout<<b[i];
    }
    cout<<"\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int X; cin>>X;
  int ans=X/500;
  ans*=1000;
  X%=500;
  ans+=X/5*5;
  cout<<ans<<endl;
  }


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

int main() {
    int N, K;
    cin >> N >> K;

    int ans = 0;

    for (int i = 1; i <= N; ++i)
    {
        int h;
        cin >> h;

        if (h >= K) ++ans;
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;

int main(){

  int n,m;
  cin >> n >> m;

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

  vector<int> dist(n, -1);
  queue<int> todo;
  int from[100001];

  dist[0] = 0;
  todo.push(0);

  while(!todo.empty()){
    int now = todo.front();
    todo.pop();

    for(int next : map[now]){
      if(dist[next] != -1) continue;

      from[next] = now;
      dist[next] = dist[now] + 1;
      todo.push(next);
    }
  }

  for(int i = 0; i < n; i++){
    if(dist[i] == -1){
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  for(int i = 1; i < n; i++){
    cout << from[i] + 1 << endl;
  }


  return 0;
}

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

int main(){
    int n;
    cin >> n;
    int res = 0;
    rep(i, n){
        int p, q;
        cin >> p >> q;
        if (p == q) res++;
        else res = 0;
        if (res == 3){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3648
#include <cstdio>
#define rg register
#define lowbit(x) ((x)&(-(x)))
using namespace std;
typedef long long ll;
template <typename Tp> inline int getmin(Tp &x,Tp y){return y<x?x=y,1:0;}
template <typename Tp> inline int getmax(Tp &x,Tp y){return y>x?x=y,1:0;}
template <typename Tp> inline void read(Tp &x)
{
	x=0;int f=0;char ch=getchar();
	while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
	if(ch=='-') f=1,ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	if(f) x=-x;
}
struct Edge{int u,v,w;}e[110];
int l,p,n,tmp;
int main()
{
	read(l);--l;
	for(int i=20;~i;i--)
	  if(l&(1<<i)){n=i+1;break;}
	if((l+1)-lowbit(l+1)==0)
	{
		n++;
		for(int i=1;i<n;i++){e[++p]=(Edge){i,i+1,1<<(n-i-1)};e[++p]=(Edge){i,i+1,0};};
		printf("%d %d\n",n,p);
		for(int i=1;i<=p;i++) printf("%d %d %d\n",e[i].u,e[i].v,e[i].w);
		return 0;
	}
	for(int i=1;i<n;i++){e[++p]=(Edge){i,i+1,1<<(n-i-1)};e[++p]=(Edge){i,i+1,0};}
	for(int i=20;~i;i--)
	  if(l&(1<<i))
	  {
	  	if(tmp) e[++p]=(Edge){1,n-i,tmp};
	  	tmp|=(1<<i);
	  }
	if(tmp) e[++p]=(Edge){1,n,tmp};
	printf("%d %d\n",n,p);
	for(int i=1;i<=p;i++) printf("%d %d %d\n",e[i].u,e[i].v,e[i].w);
	return 0;
}

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

int read()
{
	int s=0;
	char c=getchar(),lc='+';
	while (c<'0'||'9'<c) lc=c,c=getchar();
	while ('0'<=c&&c<='9') s=s*10+c-'0',c=getchar();
	return lc=='-'?-s:s;
}
void write(int x)
{
	if (x<0)
	{
		putchar('-');
		x=-x;
	}
	if (x<10) putchar(x+'0');
	else
	{
		write(x/10);
		putchar(x%10+'0');
	}
}
void print(int x,char c='\n')
{
	write(x);
	putchar(c);
}

signed main()
{
	char a,b,c;
	cin>>a>>b>>c;
	cout<<a<<b<<c;

	return 0;
}

Measured memory_bytes: 3636
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N,X = map(int,input().split())

if X in [1,2*N-1]:
    print('No')
    exit()

if N == 2:
    print('Yes')
    print(*[1,2,3],sep='\n')
    exit()

rest = set(range(1,2*N))
answer = [None] * (2*N-1)
center = N-1
if X <= 2*N-3:
    answer[center-2:center+2] = X+2,X-1,X,X+1
else:
    answer[center-2:center+2] = X-2,X+1,X,X-1
rest -= set(answer[center-2:center+2])
for i in range(2*N-1):
    if answer[i] is None:
        answer[i] = rest.pop()

print('Yes')
print(*answer,sep='\n')



Measured memory_bytes: 25080
X = int(input())
 
ans = 1
p = 2
A = set()
for i in range(2,X):
  if(i in A):
    continue
  p = 1
  while(True):
    p += 1
    power = i ** p
    if(power <= X):
      A.add(power)
      tmp = power
      pass
    else:
      break
  if(ans<tmp):
    ans = tmp
  if(p == 2):
    break
  
print(ans)

Measured memory_bytes: 3064
using System;
using System.Linq;

namespace BC136
{
    class Program
    {
        static void Main(string[] args)
        {
            var p = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();



            Console.WriteLine(p[2] - (p[0] - p[1]) > 0 ? p[2] - (p[0] - p[1]) : 0);
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>

using namespace std;

#define sz(a) static_cast<int>((a).size())
#define f first
#define s second
#define els(v) for (auto &el : (v))


#ifdef KIRYA
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#endif

template<typename T>
void _dbg(const char* _s, T _h) {
    cerr << _s << " = " << _h << "\n";
}

template<typename T, typename... Ts>
void _dbg(const char*_s, T _h, Ts... _t) {
    int _b = 0;

    while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
        cerr << *_s++;

    cerr << " = " << _h << ",";
    _dbg(_s + 1, _t...);
}

const int64_t INF = static_cast<int64_t>(1e9) + 7;
const int64_t LINF = INF * INF;
const int MAXN = static_cast<int>(1e6) + 17;

void solve() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<vector<int>> dp(n, vector<int>(n, 0));
    int ans = 0;
    for (int i = 0; i < n - 1; ++i) {
        dp[i][n - 1] = (s[i] == s[n - 1]);
        ans = max(ans, dp[i][n - 1]);
    }
    for (int j = n - 2; j >= 0; --j) {
        for (int i = 0; i < j; ++i) {
            if (s[i] == s[j]) {
                dp[i][j] = min(j - i, dp[i + 1][j + 1] + 1);
                ans = max(ans, dp[i][j]);
            }
        }
    }
    cout << ans << '\n';
}

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

    int q = 1;

    for (int i = 0; i < q; ++i) {
        solve();
    }
}


Measured memory_bytes: 98176
from collections import deque
INF=10**18
h,w=map(int,input().split())
e=[input() for _ in range(h)]
d=[[INF]*w for _ in range(h)]
q=deque([])
for i in range(h):
  for j in range(w):
    if e[i][j]=='#':
      q.append((i,j))
      d[i][j]=0
dx=[-1,0,1,0]
dy=[0,-1,0,1]
ans=0
while q:
  x,y=q.popleft()
  for i in range(4):
    nx=x+dx[i]
    ny=y+dy[i]
    if 0<=nx<h and 0<=ny<w and e[nx][ny]=='.' and d[nx][ny]==INF:
      q.append((nx,ny))
      d[nx][ny]=d[x][y]+1
      ans=max(d[nx][ny],ans)
print(ans)

Measured memory_bytes: 116144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e9;


int main() {
    int N, K; string S; cin >> N >> S >> K;
    char ch = S[K-1];
    for(int i = 0; i < N; i++) if(S[i] != ch) S[i] = '*';
    cout << S << endl;


}

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

int main() {
	ll n, x, m;
    cin >> n >> x >> m;
    vector<int> a;
    map<int, int> mp;
    int cnt = 0;
    ll tot = 0;
    while(mp.count(x) == 0) {
        a.push_back(x);
        tot += x;
        mp[x] = cnt++;
        x = (x * x) % m;
    }

    if(n <= cnt) {
        ll ans = 0;
        for (int i = 0; i < n; ++i) {
            ans += a[i];
        }
        cout << ans << endl;
        return 0;
    }

    ll cycle = 0;
    int rest = cnt - mp[x];
    for (int i = mp[x]; i < cnt; ++i) {
        cycle += a[i];
    }
    n -= cnt;
    ll ans = tot;
    ans += (n / rest) * cycle;
    n %= rest;
    int si = mp[x];
    for (int i = 0; i < n; ++i) {
        ans += a[si + i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 5920
#include <cstdio>
using namespace std;
#define SENTINEL 2000000000
#define MAX 100000

struct Card
{
	int value;
	char mark;
};
Card L[MAX / 2 + 2], R[MAX / 2 + 2];
int cnt;

void merge(Card A[], int n, int left, int mid, int right)
{
	int n1 = mid - left;
	int n2 = right - mid;
	for (int i = 0; i < n1; i++) {
		L[i] = A[left + i];
	}
	for (int i = 0; i < n2; i++) {
		R[i] = A[mid + i];
	}
	L[n1].value = R[n2].value = SENTINEL;

	int i = 0, j = 0;
	for (int k = left; k < right; k++) {
		cnt++;
		if (L[i].value <= R[j].value) A[k] = L[i++];
		else A[k] = R[j++];
	}
}

void mergeSort(Card A[], int n, int left, int right)
{
	if (left + 1 < right) {
		int mid = (left + right) / 2;
		mergeSort(A, n, left, mid);
		mergeSort(A, n, mid, right);
		merge(A, n, left, mid, right);
	}
}

void show(Card A[], int n)
{
	for (int i = 0; i < n; i++)
		printf("%c %d\n", A[i].mark, A[i].value);
}

int partition(Card A[], int p, int r)
{
	int x = A[r].value;//???????????????????????????????´????
	int i = p - 1;//x??\??????????´????????°??????????
	Card cmp;

	//j???x????????§??????????´????????°??????????
	for (int j = p; j < r; j++) {
		if (A[j].value <= x) {
			i++;
			cmp = A[j];
			A[j] = A[i];
			A[i] = cmp;
		}
	}
	cmp = A[i + 1];
	A[i + 1] = A[r];
	A[r] = cmp;
	return i + 1;
}

void quickSort(Card A[], int p, int r)
{
	if (p < r) {
		int q = partition(A, p, r);
		quickSort(A, p, q - 1);
		quickSort(A, q + 1, r);
	}
}

int main()
{
	static Card A[MAX], B[MAX];
	int n, v;
	char m[10];
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%s %d", m, &v);
		A[i].mark = B[i].mark = m[0];
		A[i].value = B[i].value = v;
	}
	
	mergeSort(A, n, 0, n);
	quickSort(B, 0, n - 1);

	for (int i = 0; i < n; i++) {
		if (A[i].mark != B[i].mark) {
			printf("Not stable\n");
			break;
		}
		if (i == n - 1) printf("Stable\n");
	}
	show(B, n);
	return 0;
}

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

#define get(x) scanf("%d",&x)
#define f(i,n) for (int i = 0; i<n;i++)

int main() {
	int n; 
	get(n);
	vector<int> adj[n];
	f(i,n-1) {
		int a,b;
		get(a); get(b);
		adj[--a].push_back(--b); adj[b].push_back(a);
	}
	int d = 0;
	function<int(int,int)> diameter = [&](int v, int p) {
		int best[2];
		best[0]=best[1]=0;
		for (int w : adj[v])
			if (w!=p) {
				int dd = diameter(w,v);				
				if (dd>best[0]) swap(dd,best[0]);
				if (dd>best[1]) swap(dd,best[1]);
				if (dd>best[0]) swap(dd,best[0]);
			}
		d=max(d,1+best[0]+best[1]);
		return 1+max(best[0],best[1]);
	};
	diameter(0,-1);
	if (d < 2 || (d-2)%3)
		cout << "First" << endl;
	else
		cout << "Second" << endl;

	return 0; 
}

Measured memory_bytes: 29184
#include <stdio.h>
int main()
{
	int A,B,C,D;
	scanf("%d%d%d%d",&A,&B,&C,&D);
	if (A*B>C*D) printf("%d\n",A*B);
	else printf("%d\n",C*D);
	
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <string>
#include <map>
using namespace std;
const int mod=10000;
int n;
int ai[110];
int main()
{
    int i;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%d",&ai[i]);
    }
    ai[n+1]=0;
    int ans=0;
    for(i=2;i<=n;i++)
    {
        if(ai[i]==ai[i-1])
        {
            ans++;
            while(ai[i]==ai[i-1]||ai[i]==ai[i+1])
            {
                ai[i]=ai[i]%mod+1;
            }
        }
    }
    printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int q = sc.nextInt();
		SegmentTree st = new SegmentTree(n);
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < q; i++) {
		    int type = sc.nextInt();
		    int x = sc.nextInt();
		    int y = sc.nextInt();
		    if (type == 0) {
		        st.update(x, y);
		    } else {
		        sb.append(st.query(x, y)).append("\n");
		    }
		}
		System.out.print(sb);
	}
}

class SegmentTree {
    static final int INF = Integer.MAX_VALUE;
    int size;
    int base;
    int[] tree;
    
    public SegmentTree(int size) {
        this.size = size;
        base = 1;
        while (base < size) {
            base <<= 1;
        }
        tree = new int[base * 2 - 1];
        Arrays.fill(tree, Integer.MAX_VALUE);
    }
    
    public void update(int idx, int value) {
        updateTree(idx + base - 1, value);
    }
    
    private void updateTree(int idx, int value) {
        tree[idx] = value;
        if (idx == 0) {
            return;
        }
        
        if (idx % 2 == 1) {
            updateTree((idx - 1) / 2, Math.min(value, tree[idx + 1]));
        } else {
            updateTree((idx - 1) / 2, Math.min(value, tree[idx - 1]));
        }
    }
    
    public int query(int min, int max) {
        return query(min, max, 0, 0, base);
    }
    
    public int query(int min, int max, int idx, int left, int right) {
        if (min >= right || max < left) {
            return INF;
        }
        if (min <= left && right - 1 <= max) {
            return tree[idx];
        }
        int x1 = query(min, max, 2 * idx + 1, left, (left + right) / 2);
        int x2 = query(min, max, 2 * idx + 2, (left + right) / 2, right);
        return Math.min(x1, x2);
    }
 }


Measured memory_bytes: 102668
import math
xyzk = list(map(int,input().split()))
abc = [list(map(int,input().split())) for a in range(3)]
ab=[]
for a in abc[0]:
    for b in abc[1]:
        ab.append(a+b)
ab.sort()
ab.reverse()
abc[2].sort()
abc[2].reverse()
abc2=[]
for c in range(len(abc[2])):
    for a in range(min([math.ceil(xyzk[3]/(c+1)),len(ab)])):
        abc2.append(abc[2][c]+ab[a])
abc2.sort()
abc2.reverse()
for a in range(xyzk[3]):
    print(abc2[a])

Measured memory_bytes: 115152
#include<bits/stdc++.h>
typedef long long int lli;
using namespace std;
 
int main()
{
  lli a, b, ans;
  cin >> a >> b;
  lli num[102]={0};
  for(lli i=0; i<b; i++)
  {
    cin >> ans;
    num[ans]=1;
  }
  if(b==0) cout << a << endl;
  else{
  for(lli i=a,j=a; ;i++,j--)
  {
    if(num[j]==0) {cout << j << endl; break;}
    else if(num[i]==0) {cout << i << endl; break;}
  }
  }
  return 0;
}

Measured memory_bytes: 3652
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if (x < y) x = y; }

int main() {
	int N; int M; int K;
	while (~scanf("%d%d%d", &N, &M, &K)) {
		bool ans = false;
		rer(a, 0, N)rer(b, 0, M)
			ans |= a * (M - b) + (N - a) * b == K;
		puts(ans ? "Yes" : "No");
	}
	return 0;
}


Measured memory_bytes: 256
import java.lang.Math.*

fun main(args: Array<String>){
    val N = readLine()!!.toInt()
    val A = readLine()!!.split(" ").map { it.toLong() }
    val minus = A.filter { it < 0 }
    val plus = A.filter { it >= 0 }
    if(minus.size % 2 == 0){
        println(A.map { abs(it) }.sum())
    }else{
        println(A.map { abs(it) }.sum() - 2 * min(abs(minus.max()!!), plus.min() ?: Long.MAX_VALUE))
    }
}

Measured memory_bytes: 59768
n = int(input())
l_a = list(map(int, input().split()))
high_max = 0
sum_hight = 0
for i in range(n):
    if high_max <= l_a[i]:
        high_max = l_a[i]
    else:
        sum_hight += high_max - l_a[i]

print(sum_hight)

Measured memory_bytes: 105192
//Atcoder ABC147 B

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String S = sc.next();
		int length = S.length();
		char c =' ';
		char d =' ';
		int cnt = 0;

		for(int i=0;i<length/2;i++) {
			c = S.charAt(i);
			d = S.charAt(length-i-1);
			if(c!=d) {
				cnt++;
			}
		}
		System.out.println(cnt);
	}

}


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

#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //0からNまでの(N+1)個の数がある
    //K個以上を選ぶとき,取り得る値の数は?
    ll N, K; cin >> N >> K;
    //K個で作れるもの。上限はN-K+1 + ... + N, 下限は0 + ... + K-1
    ll ulim = 0, dlim = 0;
    rep(i, K) dlim += i;
    for(int i = N-K+1; i <= N; i++) ulim += i;
    ll ans = ulim-dlim+1;
    for(int i = K; i <= N; i++){
        dlim += i;
        ulim += N-i;
        ans = (ans + ulim-dlim+1) % mod;
    }
    cout << ans << endl;
    return 0;
}

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

int main(){

	char moji;
	int alpha[26] = {0};

	while((moji = getchar()) != EOF){
		moji = tolower(moji);
		alpha[moji - 'a']++;
	}

	for(int i = 0; i < 26; i++){
		printf("%c : %d\n", 97+i, alpha[i]);
	}

	return 0;
}


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

int main() {
	int sx,sy,tx,ty;
	cin>>sx>>sy>>tx>>ty;
	int U=0,D=0,R=0,L=0;
	for(int i=sy; i<ty; i++){
		cout<<"U";
		U++;
	}
	for(int i=sx; i<tx; i++){
		cout<<"R";
		R++;
	}
	for(int i=0; i<U; i++){
		cout<<"D";
		D++;
	}
	for(int i=0; i<R; i++){
		cout<<"L";
		L++;
	}
	cout<<"L";
	for(int i=0; i<U+1; i++){
		cout<<"U";
	}
	for(int i=0; i<R+1; i++){
		cout<<"R";
	}
	cout<<"DR";
	for(int i=0; i<D+1; i++){
		cout<<"D";
	}
	for(int i=0; i<R+1; i++){
		cout<<"L";
	}
	cout<<"U";
}
		
		

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
  int n;
  cin >> n;
  
  vector<int> d(n);
  for(int i=0; i<n; i++){
    cin >> d[i];
  }
  // 並べ替える
  sort(d.begin(), d.end());
  
  cout << d.at(n/2)-d.at(n/2-1) << endl;
  return 0;
}

Measured memory_bytes: 640
a = int(input())
array = list(map(int, input().strip().split()))
brk = 0
ok = 0
su = 1
for i in array:
    if su == i:
      ok += 1
      su += 1
    else:
      brk +=1
if brk == 0 and ok != 0:
  print(0)
elif ok == 0:
  print(-1)
else:
  print (brk)


Measured memory_bytes: 77516
#include <stdio.h>


int main (){
	
	int n;
	int ctr = 1000;
	scanf("%d", &n);
	if(n < 1 || n > 10000){
		return 1;
	}
	
	if (n % 1000 == 0){
		printf("0\n");
	} else {
		while (ctr < n){
		ctr += 1000;	
			}
			printf("%d", ctr - n);
		}
	
	return 0;
}

Measured memory_bytes: 1732
# python3.4.2用
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') #無限大
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(sys.stdin.readline()) #整数読み込み
def ifn(): return float(sys.stdin.readline()) #浮動小数点読み込み
def isn(): return sys.stdin.readline().split() #文字列読み込み
def imn(): return map(int, sys.stdin.readline().split()) #整数map取得
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) #整数-1map取得
def fmn(): return map(float, sys.stdin.readline().split()) #浮動小数点map取得
def iln(): return list(map(int, sys.stdin.readline().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, sys.stdin.readline().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD
def lprint(l): print(*l, sep='\n')

# Nが乗客の人数
# Cがバスの定員
# Kが飛行機が到着から起こりだす時間
# Tが到着時刻
# T <= X <= T+Kとする必要あり
N,C,K = imn()
T = sorted([iin() for _ in range(N)])

departure_time = -1
passenger_cnt = 0
ans = 0
if C == 1:
    print(N)
    exit()
    
for i in range(N):
    if departure_time == -1: 
        departure_time = T[i] + K
        passenger_cnt += 1
        ans += 1
    else:
        if departure_time >= T[i]:
            passenger_cnt += 1 
            if passenger_cnt == C:
                departure_time = -1
                passenger_cnt = 0
        else:
            departure_time = T[i]+K
            passenger_cnt = 1
            ans += 1 
print(ans)

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N;
int X[100000];
int L;

int to[20][100000];

signed main(){
    scanf("%lld",&N);
    rep(i,N)scanf("%lld",&X[i]);
    scanf("%lld",&L);
    rep(i,N){
        int lb=i,ub=N;
        while(ub-lb>1){
            int mid=(ub+lb)/2;
            if(X[mid]<=X[i]+L)lb=mid;
            else ub=mid;
        }
        to[0][i]=lb;
    }

    rep(i,19){
        rep(j,N){
            to[i+1][j]=to[i][to[i][j]];
        }
    }

    int Q;scanf("%lld",&Q);
    while(Q--){
        int a,b;
        scanf("%lld%lld",&a,&b);
        a--;b--;
        if(a>b)swap(a,b);
        int ans=0;
        for(int i=19;i>=0;i--){
            if(to[i][a]<b){
                ans+=(1<<i);
                a=to[i][a];
            }
        }
        printf("%lld\n",ans+1);
    }
    return 0;
}


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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n; cin >>n;
	VI a(n+1), b(n);
	rep(i, n+1) cin >>a[i];
	rep(i, n) cin >>b[i];
	ll ans = accumulate(all(a), 0LL);
	rep(i, n){
		int mz = min(b[i], a[i]);
		a[i] -= mz;
		a[i+1] =  max(0, a[i+1]- b[i] + mz);
	}
	ans -= accumulate(all(a), 0LL);
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 3988
from collections import deque, defaultdict
n, x, y = map(int, input().split())
x -= 1
y -= 1
edges = [[] for _ in range(n)]
edges[x].append(y)
edges[y].append(x)
for i in range(n-1):
    edges[i].append(i+1)
    edges[i+1].append(i)


def bfs(init_v):
    queue = deque([init_v])
    INF = 10**10
    dist = [INF]*n
    dist[init_v] = 0
    while queue:
        v = queue.popleft()
        for v2 in edges[v]:
            if dist[v2] <= dist[v]+1:
                continue
            dist[v2] = dist[v]+1
            queue.append(v2)
    return dist


dd = defaultdict(int)
for i in range(n):
    sp = bfs(i)
    for x in sp:
        dd[x] += 1

for i in range(1, n):
    print(dd[i]//2)


Measured memory_bytes: 52188
import java.lang.*;
import java.io.*;
import java.util.*;

class Main{
	public static void main(String args[]) throws FileNotFoundException{
		Scanner sc=new Scanner(System.in);
		int n=Integer.parseInt(sc.nextLine());
		String[] buf=sc.nextLine().split(" ");		
		int[] num=new int[buf.length];
		
		for(int i=0; i<buf.length; i++){
			num[i]=Integer.parseInt(buf[i]);
		}
		
		int idx=1;
		int cnt=1;
		int ans=0;
		
		while(idx<num.length){
			cnt=1;
			if(num[idx-1]!=num[idx]){
				idx++;
			}else{
				while(idx<num.length && num[idx-1]==num[idx]){
					idx++;
					cnt++;
				}
			}
			if(cnt>1){
				ans+=cnt/2;
			}
		}
		System.out.println(ans);
	}
	
	static int rnd(){
		int r=1;
		Random rd=new Random();
		r=rd.nextInt(10000)+1;
		return r;
	}

	static void disp(int[] data){
		for(int i=0; i<data.length; i++){
				System.out.printf("%d ",data[i]);
		}
			System.out.println();
	}
}


Measured memory_bytes: 21844
N, D = map(int, input().split())
XD = [list(map(int, input().split())) for _ in range(N)]

ans = 0


def dist(list1, list2):
    rep = 0
    for k in range(len(list1)):
        rep += (list1[k] - list2[k])**2
    return rep**(1 / 2)


for i in range(N):
    xd1 = XD[i]
    for j in range(i + 1, N):
        xd2 = XD[j]
        if dist(xd1, xd2) == int(dist(xd1, xd2)):
            ans += 1
print(ans)


Measured memory_bytes: 38384
use std::cmp::*;
use std::io::*;
const MOD: u64 = 1_000_000_007;

mod enumeration {
    pub struct Enumeration {
        fact: Vec<u64>,
        finv: Vec<u64>,
        modulo: u64,
    }
    impl Enumeration {
        pub fn new(n: usize, modulo: u64) -> Enumeration {
            let mut fact: Vec<u64> = vec![1; n];
            let mut inv: Vec<u64> = vec![1; n];
            let mut finv: Vec<u64> = vec![1; n];
            for i in 2..n {
                fact[i] = fact[i - 1] * (i as u64) % modulo;
                inv[i] = modulo - (modulo / (i as u64)) * inv[(modulo as usize % i)] % modulo;
                finv[i] = inv[i] * finv[i - 1] % modulo;
            }
            Enumeration {
                fact: fact,
                finv: finv,
                modulo: modulo,
            }
        }
        pub fn c(&self, n: usize, k: usize) -> u64 {
            if n < k {
                return 0;
            }
            self.fact[n] * self.finv[n - k] % self.modulo * self.finv[k] % self.modulo
        }
    }
}

fn main() {
    let mut s: String = String::new();
    stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let r1: usize = itr.next().unwrap().parse().unwrap();
    let c1: usize = itr.next().unwrap().parse().unwrap();
    let r2: usize = itr.next().unwrap().parse().unwrap();
    let c2: usize = itr.next().unwrap().parse().unwrap();
    let en = enumeration::Enumeration::new(2000020, MOD);
    let area1 = en.c(r2 + 1 + c2 + 1, c2 + 1) - 1;
    let area2 = en.c(r1 + c2 + 1, c2 + 1) - 1;
    let area3 = en.c(r2 + 1 + c1, c1) - 1;
    let area4 = en.c(r1 + c1, c1) - 1;
    println!("{}", (area1 + MOD - area2 + MOD - area3 + area4) % MOD);
}


Measured memory_bytes: 53500
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <sstream>
#include <cmath>
#include <queue>

using namespace std;

double g[10][100][100];
double ans[100][100];
double ans_dummy[100][100];

int n, m;

void multi(double a[100][100], double b[100][100], double c[100][100]){
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			double max = 0;
			for(int k = 0; k < n; k++){
				if(a[i][k] * b[k][j] > max){
					max = a[i][k] * b[k][j];
				}
			}
			c[i][j] = max;
		}
	}
}

int main(){
	
	while(true){
		
		cin >> n >> m;
		
		if(n == 0 && m == 0){
			break;
		}
		
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				cin >> g[0][i][j];
				ans[i][j] = 1;
			}
		}
		
		m--;
		
		for(int i = 0; i < 9; i++){
			multi(g[i], g[i], g[i + 1]);
			if(m % 2 == 1){
				multi(ans, g[i], ans_dummy);
				for(int j = 0; j < n; j++){
					for(int k = 0; k < n; k++){
						ans[j][k] = ans_dummy[j][k];
						//cout << ans[j][k] << " ";
					}
					//cout << endl;
				}
			}
			m /= 2;
		}
		
		double max = 0;
		
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				if(max < ans[i][j]){
					max = ans[i][j];
				}
			}
		}
		
		printf("%.2f\n", max);
		
	}
	
	return 0;
}

Measured memory_bytes: 4092
w, h, n = map(int, input().split())
lx, mx = 0, w
ly, my = 0, h

for _ in range(n):
  x, y, a = map(int, input().split())
  if a == 1:
    lx = max(lx, x)
  elif a == 2:
    mx = min(mx, x)
  elif a == 3:
    ly = max(ly, y)
  elif a == 4:
    my = min(my, y)
print((mx-lx)*(my-ly) if mx > lx and my > ly else 0)

Measured memory_bytes: 3064
#include<iostream>
#include<cmath>
#include<string>
#include<algorithm>
#include<set>
#include<iomanip>
using namespace std;

int main()
{
	int a[111],b[111],m,n,x,y;cin>>n>>m>>x>>y;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(int i=0;i<m;i++)
	{
		cin>>b[i];
	}
	sort(a,a+n);
	sort(b,b+m);
	for(int z=x+1;z<=y;z++)
	{
		if(a[n-1]<z&&z<=b[0])
		{
			cout<<"No ";
			break;
		}
	}
	cout<<"War"<<endl;
	return 0;
}

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

int main() {
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
    return 0;
}


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

using namespace std;

int main() {
    int N,M; cin >> N >> M;
    unordered_map<int,int> mp;

    for(int i=0;i<M;i++) {
        int a,b; cin >> a >> b;
        mp[a] += 1;
        mp[b] += 1;
    }

    bool ans = true;
    for(auto node : mp) {
        ans &= ((node.second&1) == 0);
    }

    cout << (ans ? "YES" : "NO") << endl;

    return 0;
}


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

int main()
{
	long long X;
	scanf("%lld", &X);
	
	int ans = 0;
	long long initialBalance = 100;
	while(initialBalance < X)
	{
		initialBalance += initialBalance / 100;
		ans++;
	}
	
	printf("%d", ans);
}


Measured memory_bytes: 3816