akhauriyash/Code-Regression huggingface dataset:
n = int(input())
t,a = map(int, input().split())
h = list(map(int, input().split()))

ans = 1000000
cnt = 0
T = [0 for i in range(n)]

for i in range(n) :
    T[i] = t - h[i]*0.006
    q = abs(a - T[i]) 
    if (q < ans) :
        ans = q
        cnt = i+1
print(cnt)

Measured memory_bytes: 9188
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

int main(){
    Stream io;
    
    int X, t;
    io.read(X, t);
    cout << max(0, X - t);
    return 0;
}

Measured memory_bytes: 256
/**
 * @brief ユーザ定義リテラル
 * @author えびちゃん
 */

#ifndef H_int_literals
#define H_int_literals

#include <cstddef>
#include <cstdint>

constexpr intmax_t  operator ""_jd(unsigned long long n) { return n; }
constexpr uintmax_t operator ""_ju(unsigned long long n) { return n; }
constexpr size_t    operator ""_zu(unsigned long long n) { return n; }
constexpr ptrdiff_t operator ""_td(unsigned long long n) { return n; }

#endif  /* !defined(H_int_literals) */

#include <cstdio>
#include <cstdint>
#include <utility>
#include <vector>
#include <string>

int main() {
  size_t n;
  intmax_t a, b;
  scanf("%zu %jd %jd", &n, &a, &b);

  std::vector<intmax_t> h(n);
  for (auto& hi: h) scanf("%jd", &hi);

  auto f = [&](intmax_t x) {
    std::vector<intmax_t> hh = h;
    for (auto& hi: hh) hi -= b*x;
    intmax_t res = 0;
    intmax_t ab = a-b;
    for (auto hi: hh)
      if (hi > 0) res += (hi+ab-1) / ab;
    return res <= x;
  };

  intmax_t lb = 0;
  intmax_t ub = 1e9;
  while (ub-lb > 1) {
    intmax_t mid = (lb+ub) >> 1;
    (f(mid)? ub: lb) = mid;
  }

  printf("%jd\n", ub);
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

int main() {
    int N; cin >> N;
    vector<int> A(N);
    REP(i, 0, N) cin >> A[i];

    vector<int> primes((int)1e6 + 1, 0);
    for (int i = 2; i * i <= (int)1e6; i++) {
        if (primes[i]) continue;
        for (int j = i; j <= (int)1e6; j += i) {
            primes[j] = i;
        }
    }

    int g = 0;
    bool pairwise = true;
    vector<int> factors((int)1e6 + 1, 0);
    REP(i, 0, N) {
        // cout << "# i : " << i << endl;
        g = gcd(g, A[i]);
        while (A[i] != 1) {
            // cout << A[i] << endl;
            int pf = ((primes[A[i]]) ? primes[A[i]] : A[i]);
            if (factors[pf]) pairwise = false;
            while (A[i] % pf == 0) A[i] /= pf;
            factors[pf]++;
        }
    }

    if (pairwise) {
        cout << "pairwise coprime" << endl;
    } else if (g == 1) {
        cout << "setwise coprime" << endl;
    } else {
        cout << "not coprime" << endl;
    }

    return 0;
}

Measured memory_bytes: 14856
#include<iostream>
using namespace std;
void Insert(int);
void Increase(int,int);
int Extract(void);
void maxHeapify(int i);
int H[1000000];
int n=0;

void Insert(int key)
{
  n+=1;
  H[n]=-1;
  Increase(n,key);
}
void Increase(int i,int key){
  int tmp;
  H[i] = key;
  while(i > 1 && H[i/2] < H[i]){
    tmp = H[i];
    H[i] = H[i/2];
    H[i/2] = tmp;
    i = i/2;
  }
}

int Extract(){
  int max = H[1];
  H[1] = H[n];
  n--;
  maxHeapify(1);
  return max;
}

void maxHeapify(int i){
  int r, l, largest, tmp;
  l = i*2;
  r = i*2+1;
  if(l<=n && H[l] > H[i])largest = l;
  else largest = i;
  if(r<=n && H[r] > H[largest])largest = r;
  if(largest != i){
    tmp = H[i];
    H[i] = H[largest];
    H[largest] = tmp;
  maxHeapify(largest);
  }
}

int main(){
  int key, n = 0;
  char ch[10];
  while(true){
    cin >> ch;
    if(ch[0] == 'i'){
      cin >> key;
      Insert(key);
    }
    else if(ch[0] == 'e' && ch[1] == 'x'){
      cout << Extract() <<endl;
    }
    else{
      break;
    }
  }
  for(int i = 0;i < n; i++){
    cout << H[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 6984
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
long long ans;
int n,L;
int st[200005],top,vl[200005],vr[200005];
int sl[200005],sr[200005];
void pop(){
	int len=1,v=st[top];
	while(st[top-1]==v)top--,len++;
	top--;
	if(len<L){
		while(top)pop();
		return;
	}
	int w=len/L;
	sl[0]=0;
	for(int i=1;i<=len;i++)sl[i]=sl[i-1]+vl[i+top];
	sr[0]=0;
	for(int i=1;i<=len;i++)sr[i]=sr[i-1]+vr[i+top];
	for(int i=L;i<=len;i++)ans+=1ll*sl[i-L+1]*vr[i+top];
	for(int i=1;i<=w;i++){
		vl[top+i]=sl[len-L*(w-i+1)+1]-sl[max(len-L*(w-i+2)+1,0)];
		vr[top+i]=sr[min(L*(i+1)-1,len)]-sr[L*i-1];
	}
	for(int i=L,s=0;i<=w;i++)s+=vl[top+i-L+1],ans-=1ll*s*vr[top+i];
	for(int i=1;i<=w;i++)st[++top]=v+1;
}
int main(){
	scanf("%d%d",&n,&L);
	ans=n;
	for(int i=1;i<=n;i++){
		int x;
		scanf("%d",&x);
		while(top&&st[top]<x)pop();
		st[++top]=x;
		vl[top]=vr[top]=1;
		/*
		for(int i=1;i<=top;i++)printf("%d ",st[i]); puts("");
		for(int i=1;i<=top;i++)printf("%d ",vl[i]); puts("");
		for(int i=1;i<=top;i++)printf("%d ",vr[i]); puts("");
		*/
	}
	while(top)pop();
	printf("%lld\n",ans);
}

Measured memory_bytes: 3072
n,k = map(int, input().split())
h = list(map(int, input().split()))
INF = 999999999999999999999999999
dp = [INF] * n
dp[0] = 0
for i in range(1, n):
    for j in range(1, k+1):
        if i - j < 0:
            continue
        dp[i] = min(dp[i], dp[i-j] + abs(h[i] - h[i-j]))
    
print(dp[n-1])

Measured memory_bytes: 84056
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <functional>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long llong;

int main() {
    llong n;
    llong a[100005];

    cin >> n;
    llong minv = 1;
    llong maxv = n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (i && a[i] <= a[i - 1]) minv++;
    }

    cout << minv << endl;
    cout << maxv << endl;

    return 0;
}


Measured memory_bytes: 3880
#include<iostream>
using namespace std;
int main(){
  int x,y,z;
  cin >> x >> y >> z;
  if(z-y<=0){
    cout << "delicious" << endl;
  }
  else if(z-y <= x){
    cout << "safe" << endl;
  }
  else{
    cout << "dangerous" << endl;
  }
 return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
 
int main() {
	// your code goes here
	int a,b;
	cin >> a >> b;
	for (int i=1;i<=1000;i++)
	{
		int so=(int)(i*0.1);
		int so1=(int)(i*0.08);
		//cout << so << " " << so1 << endl;
		if (so1==a&&so==b) {cout << i;exit(0);}
	}
	cout << -1;
}

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

int main() {
   int D(0),T(0),S(0);
   std::string ans;

   cin >> D >> T >> S;
   int dist = T * S;
   if (dist >= D) ans = "Yes";
   else ans = "No";

   cout << ans;

    return 0;
}


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

int main()
{
    ll n;
    cin>>n;
    ll ans=0;
    for(int i=1;i<n;i++)
    {
     for(int j=1;j*i<n;j++)
     ans++;
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 3628
n     = gets.to_i
rains = gets.split.map(&:to_i)
# nが奇数であるとき　x = A5 - A4 + A3 - A2 + A1 - xが成り立つ。
# 移項すると 2x = A5 - A4 + A3 - A2 + A1
# xを求められたらあとは数珠つなぎに各点の降水量を求められる。
x2    = 0
(0 .. n - 1).each { |i| i.even? ? x2 += rains[i] : x2 -= rains[i] }
ans = Array.new(n)
ans[0] = x2 / 2
(0...n-1).each { |i| ans[i+1] = rains[i] - ans[i] }
ans.map! { |i| i *= 2}
puts ans.join(' ')



Measured memory_bytes: 14084
#include<bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n;i>=0;i++)
using namespace std;
signed main(){
  string s;
  ll sum=0,cun=0;
  cin>>s;
  for(int i=0;i<s.size();i++){
    if(s[i]=='A' || s[i]=='C' || s[i]=='G' || s[i]=='T'){
      sum++;
    }else{
      cun=max(sum,cun);
      sum=0;
    }
  }
  cout<<max(cun,sum)<<"\n";
}


Measured memory_bytes: 256
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b?gcd(b,a%b):a;} //最小公倍数

// デフォルト変数定義
int n,m,a,b,c,d,x,y,z;
string s,t;
//

signed main() {
  RAPID;
  IN2(a,b);
  if((a+b)%3==0||a%3==0||b%3==0) OUT("Possible");
  else OUT("Impossible");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int W, H, N;
    cin >> W >> H >> N;
    int x[100], y[100], a[100];
    for(int i=0;i<N;i++)
        cin >> x[i] >> y[i] >> a[i];
    
    int rect[101][101] = {};
    for(int i=0;i<N;i++){
        if(a[i] == 1){
            for(int j=1;j<=x[i];j++)
                for(int k=1;k<=H;k++)
                    rect[j][k] = 1;
        }else if(a[i] == 2){
            for(int j=x[i]+1;j<=W;j++)
                for(int k=1;k<=H;k++)
                    rect[j][k] = 1;
        }else if(a[i] == 3){
            for(int j=1;j<=W;j++)
                for(int k=1;k<=y[i];k++)
                    rect[j][k] = 1;
        }else{
            for(int j=1;j<=W;j++)
                for(int k=y[i]+1;k<=H;k++)
                    rect[j][k] = 1;
        }

        /*
        for(int i=0;i<=W;i++){
            for(int j=0;j<=H;j++){
                cout << rect[i][j];
            }
            cout << endl;
        }
        cout << endl;
        */
    }
    
    int ans = 0;
    for(int i=1;i<=W;i++){
        for(int j=1;j<=H;j++){
            if(rect[i][j] == 0)
                ans++;
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int gcd(ll a, ll b) { return b ? gcd(b, a%b) : a;}

int main()
{
  int n;
  cin >> n;
  vector<ll> vec(n);
  rep(i,n) cin >> vec[i];
  vector<ll> left(n+1, 0), right(n+1, 0);
  rep(i,n) left[i+1] = gcd(left[i], vec[i]);
  for(int i = n-1; i >= 0; i--) {
    right[i] = gcd(right[i+1], vec[i]);
  }
  int ans = 1;
  rep(i, n) {
    ans = max(ans, gcd(left[i], right[i+1]));
  }
  cout << ans << endl;
  
  


  return 0;
}

Measured memory_bytes: 5540
H, W = map(int, input().split())
C = [[int(x) for x in input().split()] for _ in range(10)]
A = [[int(x) for x in input().split()] for _ in range(H)]

import heapq
def dijkstra(adj, n, st=1):
    inf = float('inf')
    dj = [inf] * (n + 1)
    dj[st] = 0
    q = []
    heapq.heappush(q, (0, st))
    while q:
        fc, fn = heapq.heappop(q)
        if dj[fn] < fc: continue
        for tn, lc in adj[fn]:
            if dj[fn] + lc < dj[tn]:
                dj[tn] = dj[fn] + lc
                heapq.heappush(q, (dj[tn], tn))
    return dj

adj = dict((x, []) for x in range(10))
for i in range(10):
    for j in range(10):
        adj[j].append((i, C[i][j]))
costs = dijkstra(adj, 9, 1)

from itertools import chain
print(sum(costs[x] for x in chain(*A) if x != -1))

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

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


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);
// (a+b+c)%MOD
ll madd(ll a, ll b, ll c);
// (a-b)%MOD
ll msub(ll a, ll b);
// (a*b*c)%MOD
ll mtime(ll a, ll b, ll c);


int main() {
    string s;
    cin >> s;
    ll ans = INF;
    rep(i, s.size()-2) {
        string tmp = s.substr(i, 3);
        ll num = stoll(tmp);
        if(my_abs(753-num) < ans) ans = my_abs(753-num);
    }
    cout << ans << endl;
    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

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

ll inv(ll a) {
    return a_n(a, MOD-2);
}

ll madd(ll a, ll b, ll c) {
    ll ret = (a+b) % MOD;
    return (ret+c) % MOD;
}

ll msub(ll a, ll b) {
    if(a < b) return (a-b+MOD) % MOD;
    else return (a-b) % MOD;
}

ll mtime(ll a, ll b, ll c) {
    ll ret = (a*b) % MOD;
    return (ret*c) % MOD;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2")

using namespace std;

#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)

namespace FastIO {
struct Strs {
  char strs[10000 * 4];
  constexpr Strs() : strs() {
    for (int i = 0; i < 10000; ++i) {
      int j = i;
      for (int t = 3; t >= 0; --t) {
        strs[i * 4 + t] = j % 10 + '0';
        j /= 10;
      }
    }
  }
} constexpr strs;
static constexpr size_t buf_size = 1 << 16;
char buf_in[buf_size], buf_out[buf_size];
size_t pt_in = 0, pt_out = 0, tail_in = 0;
inline size_t num_digits(long long x) {
  if (x >= (long long)1e5) return 6;
  if (x >= (long long)1e4) return 5;
  if (x >= (long long)1e3) return 4;
  if (x >= (long long)1e2) return 3;
  if (x >= (long long)1e1) return 2;
  return 1;
}
inline void load() {
  memcpy(buf_in, buf_in + pt_in, tail_in - pt_in);
  size_t width = tail_in - pt_in;
  tail_in = width + fread(buf_in + width, 1, buf_size - width, stdin);
  pt_in = 0;
}
inline void flush() {
  fwrite(buf_out, 1, pt_out, stdout);
  pt_out = 0;
}
inline void scan(char& c) { c = buf_in[pt_in++]; }
template <class T>
inline void scan(T& x) {
  if (pt_in + 32 > tail_in) load();
  char c;
  bool minus = 0;
  x = 0;
  scan(c);
  while (c >= '0') {
    x = x * 10 + (c & 15);
    scan(c);
  }
  if (minus) x = -x;
}
inline void print(char c) { buf_out[pt_out++] = c; }
template <class T>
inline void print(T x) {
  if (pt_out > buf_size - 32) flush();
  if (x < 0) {
    print('-');
    x = -x;
  }
  size_t digits = num_digits(x);
  int i;
  for (i = pt_out + digits - 4; i > (int)pt_out; i -= 4) {
    memcpy(buf_out + i, strs.strs + (x % 10000) * 4, 4);
    x /= 10000;
  }
  memcpy(buf_out + pt_out, strs.strs + x * 4 + (pt_out - i), 4 + i - pt_out);
  pt_out += digits;
}
inline void print(const char* s) {
  if (pt_out > buf_size - 32) flush();
  for (int i = 0; s[i] != 0; ++i) print(s[i]);
}
template <class T>
inline void println(T x) {
  print(x);
  print('\n');
}
struct SetUp {
  SetUp() { load(); }
  ~SetUp() { flush(); }
} setup;
}  // namespace FastIO

using FastIO::print;
using FastIO::println;
using FastIO::scan;

int main() {
  int N;
  scan(N);
  int A[200000], B[200000];
  REP(i, N) scan(A[i]);
  REP(i, N) scan(B[N - 1 - i]);
  int ngs[200000];
  int ngp = 0;
  int ngx = -1;
  REP(i, N) {
    if (A[i] == B[i]) {
      ngs[ngp++] = i;
      ngx = A[i];
      if (ngp > N) {
        println("No");
        return 0;
      }
    }
  }
  int l = 0, r = N - 1, st = 0;
  REP(j, ngp) {
    int i = ngs[j];
    int target;
    if (st == 0) {
      if (A[l] != ngx && B[l] != ngx) {
        target = l++;
      } else {
        st = 1;
      }
    }
    if (st == 1) {
      if (A[r] != ngx && B[r] != ngx) {
        target = r--;
      } else {
        println("No");
        return 0;
      }
    }
    swap(B[i], B[target]);
  }
  println("Yes");
  REP(i, N) println(B[i]);
  return 0;
}

Measured memory_bytes: 5984
# include <bits/stdc++.h>
# define INF 1e9
using namespace std;

int main(){

  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if(abs(c-a) <= d || (abs(a-b)<=d && abs(b-c) <=d)){
    cout << "Yes" << endl;
  } else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args){
		// TODO Auto-generated method stub
		System.err.println("starts...");
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int ans = k;
		for(int i = 1; i < n; i++){
			ans = ans * (k-1);
		}
		System.out.print(ans+"\n");
	}

}

Measured memory_bytes: 9680
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
 
int main() {
  int n;
  string s;
  cin >> n >> s;
  int a = 0, b = 0;
  rep(i,n) if (s[i] == 'R') a++;
  int ans = max(a,b);
  rep(i,n) {
    if (s[i] == 'R') a--;
    else b++;
    int now = max(a,b);
    ans = min(ans, now);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(x) cerr << "[(" << __LINE__ << ") " << (#x) << "]: " << x << endl;

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

    int n;
    cin >> n;
    int a = 1000 - (n%1000);
    if (a == 1000) a = 0;
    cout << a << "\n";
}


Measured memory_bytes: 3632
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
    int n;
    int i;
    cin >> n;
    int a[n];
    int ans[n];
    for(i=0; i<n; i++){
        cin >> a[i];
    };
    
    for(i=0; i<(n+1)/2; i++){
        ans[i] = a[n-2*i-1];
    };
    for(i=0; i<n/2; i++){
        ans[(n+1)/2+i] = a[2*i+n%2];
    };
    
    for(i=0; i<n; i++){
        if(i!=0){
            cout << " " ;
        };
        cout << ans[i] ;
    };
    cout << endl;
    
    return 0;
}

Measured memory_bytes: 3712
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};

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

struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};


void solve(){
    string s,t,u;
    cin>>s>>t;
    ll n=s.size();
    u=s;
    bool ok=false;
    if(u==t) ok=true;
    rep(i,n){
        u[0]=s[n-1];
        rep2(j,1,n){
            u[j]=s[j-1];
        }
        if(u==t) ok=true;
        // cout<<u<<endl;
        s=u;
    }
    if(ok) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}



signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
    
    solve();

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
class Main{
    public static void main(String[]args){
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            int x=sc.nextInt(),sum=0;
            for(int i=x;i<600;i+=x){
             	sum+=i*i*x;
            }
            System.out.println(sum);
        }
    }
}

Measured memory_bytes: 15344
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.root = [-1]*(n+1)
        self.rnk = [0]*(n+1)
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    def Unite(self, x, y):
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        if(x == y):
            return 
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)
    def Count(self, x):
        return -self.root[self.Find_Root(x)]

n = int(input())
arr = []
ans = 0
for i in range(n):
    arr.append([i] + list(map(int,input().split())))
x_sort = sorted(arr, key = lambda x:x[1])
y_sort = sorted(arr, key = lambda x:x[2])

import heapq as hq

q = []

for i in range(n-1):
    costx = x_sort[i+1][1] - x_sort[i][1]
    costy = y_sort[i+1][2] - y_sort[i][2]
    hq.heappush(q, [costx, x_sort[i][0], x_sort[i+1][0] ])
    hq.heappush(q, [costy, y_sort[i][0], y_sort[i+1][0] ])

uf = UnionFind(n)
for rep in range(3*10**5):
    cost, a, b = hq.heappop(q)
    if uf.isSameGroup(a, b):
        continue
    else:
        uf.Unite(a, b)
        ans += cost
    if uf.Count(0) == n:
        break
print(ans)

Measured memory_bytes: 55084
gets
ns = gets.split.map(&:to_i)

ret = 0

l,r = 0,1

mx = ns.length

t = ns[l]
while l < mx
  while r < mx && (t+ns[r]==t^ns[r])
    t += ns[r]
    r += 1
  end
  ret += r - l
  t -= ns[l]
  l += 1
end

p ret

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

using namespace std;
int main() {
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int dx = x2 - x1;
  int dy = y2 - y1;
  cout << x2 - dy << " " << y2 + dx << " ";
  cout << x1 - dy << " " << y1 + dx << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#include <bitset>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

long foo[510][510] = {0};

void solve() {
  long N, M, Q;
  cin >> N >> M >> Q;
  rep (i, M) {
    long L, R;
    cin >> L >> R;
    foo[L][R]++;
  }

  for (long i = 1; i <= N; i++) for (long j = 1; j <= N; j++) foo[i][j] += foo[i-1][j];
  for (long i = 1; i <= N; i++) for (long j = 1; j <= N; j++) foo[i][j] += foo[i][j-1];
  
  rep (i, Q) {
    long p, q;
    cin >> p >> q;
    cout << foo[q][q] - foo[q][p-1] - foo[p-1][q] + foo[p-1][p-1] << endl;
  }
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 2944
X = int(input())

r = X % 100

b = r // 5
r -= 5 * b

c = r // 4
r -= 4 * c

d = r // 3
r -= 3 * d

e = r // 2
r -= 2 * e

f = r // 1
r -= 1 * f

if 105 * b + 104 * c + 103 * d + 102 * e + 101 * f > X:
    print(0)
else:
    print(1)


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



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

	int N;
	cin >> N;
	vector<VI>dp(N+1, VI(5, 0));
	//i番目の数字が区間jの時の操作の最小値
	VI A(N);
	REP(i, N)cin >> A[i];
	eFOR(i, 1, N)REP(j, 5)dp[i][j] = INF;

	REP(i, N) {
		REP(j, 5) {
			int cnt = INF;
			eREP(k, j)chmin(cnt, dp[i][k]);
			//chmax(cnt, dp[i][j]);
			//cout << i << " " << j << " " << cnt << " ";
			if (j == 0 || j == 4)cnt += A[i];
			else if (j == 1 || j == 3) {
				cnt += A[i] % 2;
				if (A[i] == 0)cnt += 2;
			}
			else {
				if (A[i] % 2 == 0)cnt++;
			}

			dp[i + 1][j] = cnt;
			//cout << dp[i + 1][j] << endl;
		}
		//cout << endl;
	}


	int ans = INF;
	REP(i, 5)chmin(ans, dp[N][i]);
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 15872
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); i++){
        if(i % 2 == 0){
            if(s[i] == 'L'){
                cout << "No";
                return 0;
            }
        }
        else{
            if(s[i] == 'R'){
                cout << "No";
                return 0;
            }
        }
    }
    cout << "Yes";
}   

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

using namespace std;
const int MAXN=105;
const int MAXW=1e5+5;
int N,W;
int w[MAXN],v[MAXN];
long long dp[MAXW];
int main()
{
	cin>>N>>W;
	for(int i=1;i<=N;++i)
		cin>>w[i]>>v[i];
		
	for(int i=1;i<=N;++i)
		for(int j=W;j>=0;--j)
		{
			if(j-w[i]>=0)
			{
				dp[j]=max(dp[j],dp[j-w[i]]+v[i]);
			}

	}	
	long long ans=-1; 
	for(int i=1;i<=W;++i)
	{
		ans=max(ans,dp[i]);	
	} 
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstring>
#include <string>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <ctime>
#include <cmath>
#include <stack>
#include <set>
#include <map>

#define INF 0x3f3f3f3f
#define ll long long
#define rep(i, n) for(ll i=0;i<n;i++)
#define per(i, n) for(int i=n;i>=0;i--)
#define rep2(i, n) for(ll i=1;i<=n;i++)
#define pb(x) push_back(x)
#define clint(x, n) memset(x,n,sizeof(x))
#define mp make_pair
#define fi first
#define se second
#define IO std::ios::sync_with_stdio(false)
#define ull unsigned long long
#define ud long double
#define pii pair<int,int>
#define random(x) (rand()%x)
using namespace std;
const ll inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const int MAX = 123123;
const int N = 555;
const double eps = 1e-6;

inline int read() {
    int x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    return x * f;
}

inline ll read1() {
    ll x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    return x * f;
}

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

ll min(ll a, ll b) {
    if (a < b) return a;
    return b;
}

ll multi(ll a, ll b, ll p) {
    ll ans = 0;
    while (b) {
        if (b & 1ll) ans = (ans + a) % p;
        a = (a + a) % p;
        b >>= 1;
    }
    return ans;
}

ll pow_mod(ll a, ll b, ll p) {
    ll ans = 1;
    while (b) {
        if (b & 1ll) ans = multi(ans, a, p);
        a = multi(a, a, p);
        b >>= 1;
    }
    return ans;
}

int qpow(int a, int b) {
    int ans = 1, base = a;
    while (b != 0) {
        if ((b & 1) != 0)
            ans *= base;
        base *= base;
        b >>= 1;
    }
    return ans;
}

int lowbit(ll x) {
    return x & (-x);
}

int gcd(int a, int b) {
    return b > 0 ? gcd(b, a % b) : a;
}

bool cmp(int &a, int &b) {
    return a > b;
}

const int maxn = 1e5 + 10;

//**************************************

int main() {
    ll a;
    cin>>a;
    for(int i=sqrt(a);i>0;i--){
        if(a%i==0){

            cout<<(i+a/i-2)<<endl;
            break;
        }
    }
    return 0;
}


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

int main(){
    int n; cin>>n;
    string s; cin >> s;
    string t; cin >> t;

    int cnt=0;
    bool flg = false;
    for(int i=0; i<s.length(); i++){
        string s_sub = s.substr(i, s.length()-i);
        for(int j=0; j<t.length(); j++){
            string t_sub = t.substr(0, t.length()-j);
                if(s_sub==t_sub){
                    cnt = s_sub.length();  flg = true;
                    break;
                }
            }
        
        if(flg) break;
    }
    string res = s + t.substr(cnt, t.length()-cnt);
    int ans = res.length();
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 3604
S = input()
cnt = 0
for s in S[::2]:
    if s in {"R", "U", "D"}:
        cnt += 1
for s in S[1::2]:
    if s in {"L", "U", "D"}:
        cnt += 1
if cnt == len(S):
    print("Yes")
    exit()
print("No")



Measured memory_bytes: 61116
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
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; }
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
inline void err(bool b = true) {if(b) {cout << -1 << '\n'; exit(0);}}
template<class T> inline void fin(bool b = true, T e = 0) {if(b) {cout << e << '\n'; exit(0);}}
template<class T> T Roundup_div(T x, T y) {return (x+(y-1))/y;}
const ll INF = 1e18;
template <typename T>
T pow(T a, long long n, T e = 1) {
    T ret = e;
    while (n) {
        if (n & 1) ret *= a;
        a *= a;
        n >>= 1;
    }
    return ret;
}

bool memo[100000][11];//点、深さ
VV<> G(100000);
ll color[100000];

void dfs(ll p, ll dep, ll col){
    if(memo[p][dep]) return;
    memo[p][dep] = true;
    if(!dep){
		color[p] = col;
		return;
    }
    dfs(p, dep - 1, col);
    for(auto v:G[p]) dfs(v, dep - 1, col);
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    REP(i, 100000)REP(j, 11) memo[i][j] = 0;
    ll n, m; cin >> n >> m;
    REP(i, m){
        ll a, b; cin >> a >> b; a--; b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    ll q; cin >> q;
    V<> v(q), d(q), c(q);
    REP(i, q) cin >> v[i] >> d[i] >> c[i];
    RREP(i, q) dfs(v[i] - 1, d[i], c[i]);
    REP(i, n) cout << color[i] << endl;
}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define mp(a,b) make_pair((a),(b))
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int INF=1<<30;
const long long int INF_=1LL<<58;
const double EPS=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
	os << "[";
	for (const auto &v : vec) {
		os << v << ",";
	}
	os << "]";
	return os;
}

int n,q,s[1000000],t[1000000];
multiset<int> leader;

bool Check(ll r,int x){
	int cnt=0,tail=0;
	for(auto it=leader.begin(); it!=leader.end(); ++it){
		cnt+=max(0,int(lower_bound(t,t+n,*it-r)-t)-tail);
		tail=upper_bound(t,t+n,*it)-t;
	}

	return x>=cnt+n-tail;
}

void Solve(){
	cin >> n >> q;
	ll maxi=0;
	rep(i,0,n){
		cin >> s[i];
		maxi=max(maxi,(ll)s[i]);
		t[i]=s[i];
	}

	sort(t,t+n);

	rep(i,0,q){
		string query;
		int a;
		cin >> query >> a;
		
		if(query=="ADD"){
			--a;
			leader.insert(s[a]);
		}else if(query=="REMOVE"){
			--a;
			leader.erase(leader.find(s[a]));
		}else{
			ll lb=0,ub=maxi+1;
			while(ub-lb>1){
				ll m=(lb+ub)/2;
				if(Check(m,a)) ub=m;
				else lb=m;
			}
			if(Check(lb,a)) ub=lb;
			
			if(ub==maxi+1) cout << "NA" << endl;
			else cout << ub << endl;
		}
	}
}

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

Measured memory_bytes: 9044
#include <iostream>

using namespace std;

int a[1000000],n,h;

int main (){
    int sum=0;
    cin>>h>>n;
    for (int i=0;i<n;i++){
    cin>>a[i];
    sum+=a[i];
    }
    if(sum>=h) cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 640
# 15:20-

n, m = map(int, input().split())

dp = [[float("inf") for _ in range(2 ** n)] for i in range(m + 1)]
dp[0][0] = 0

pattern = {0}

for i in range(1, m+1):
  ai, bi = map(int, input().split()) 
  ci_bit = sum(2 ** (cij - 1) for cij in map(int, input().split()))
  new_pattern = set()
  for j in pattern:
    dp[i][j | ci_bit] = min(dp[i][j | ci_bit], dp[i-1][j] + ai)
    dp[i][j] = min(dp[i][j], dp[i-1][j])
    new_pattern.add(j | ci_bit)
  pattern |= new_pattern


print(-1 if dp[m][2**n - 1] == float("inf") else dp[m][2**n - 1])

Measured memory_bytes: 135560
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <queue>
using namespace std;

int main() {
    long long N;
    cin >> N;
    vector<long long> A(N+1), B(N);
    for (long long i=0; i<N+1; i++) {
        cin >> A[i];
    }
    for (long long i=0; i<N; i++) {
        cin >> B[i];
    }
    
    long long ans = 0;
    long long kurikoshi = 0;
    for (long long i=0; i<N; i++) {
        if (A[i]<B[i]) {
            ans += A[i];
            kurikoshi = B[i] - A[i];
            if (A[i+1] <= kurikoshi) {
                ans += A[i+1];
                A[i+1] = 0;
            }
            else{
                ans += kurikoshi;
                A[i+1] -= kurikoshi;
            }
        }
        else{
            ans += B[i];
        }
    }
    
    cout << ans << endl;
}


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

#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define mem(x,val) memset((x),(val),sizeof(x))
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define PI acos(-1.0) 
#define N 111

const int INF = 1 << 30 ;
typedef long long ll ;
typedef pair < int , int > pii ;

int a[N] ;

int main() {
  int n , m , p , x, sum = 0;
  scanf("%d" ,&n) ;
  for(int i = 1 ;i<=n ;i++){
    scanf("%d", &a[i]) ;
    sum+=a[i] ;
  }

  scanf("%d",&m) ;
  while(m--){
    scanf("%d %d", &p, &x) ;
    printf("%d\n" , sum-a[p] + x) ;
  }
  return 0 ;
}



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

int main (void){

   int c=0,l,i,flg=0;
   char s[101],t[101],tmp;

   scanf("%s",s);
   scanf("%s",t);

   l=strlen(s);
   while(1){
      if(strcmp(s,t)==0)
         goto A;
      tmp=t[0];
      for(i=1;i<l;i++)
         t[i-1]=t[i];
      t[l-1]=tmp;

      c++;

      if(c==l){flg=1; goto A;}
    }

   A:
   if (flg==0) printf("Yes\n");
   else        printf("No\n");

   return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>

using namespace std;

#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define rep(i,n) for(int i=0;i<(n);i++)
#define tr(it,container) for(typeof(container.begin()) it = container.begin(); \
                                                  it != container.end(); ++it)
#define mp(a,b) make_pair((a),(b))

typedef long long ll;
typedef complex<double> point;

// up right down left
const int dy[] = {-1,0,1,0};
const int dx[] = {0,1,0,-1};

const double EPS = 1e-9;
const int days[]     = {31,28,31,30,31,30,31,31,30,31,30,31};
const int daysleap[] = {31,29,31,30,31,30,31,31,30,31,30,31};

bool sorter(pair<string,double> a,pair<string,double> b){
    if(abs(a.second-b.second) < EPS){
        return a.first < b.first;
    }
    return a.second > b.second;
}

int main(){
    while(true){
        int N;
        cin >> N;
        if(N==0)break;
        vector<pair<string,double> > V;
        rep(ind,N){
            //L1 P1 A1 B1 C1 D1 E1 F1 S1 M1
            string L;
            int P,A,B,C,D,E,F,S,M;
            cin >> L >> P >> A >> B >> C >> D >> E >> F >> S >> M;
            int score = S*F*M - P;
            int time = (A+B+C) + (D+E)*M;
            double ratio = 1.0*score / time;
            V.push_back(mp(L,ratio));
        }
        sort(all(V),sorter);
        rep(i,N){
            cout << V[i].first << endl;
        }
        cout << "#" << endl;
    }
    return 0;
}

Measured memory_bytes: 1228
#include<cstdio>

int main() {
	int n;
	double debt=100000;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		debt = debt + debt*0.05;
		if ((int)debt % 1000 > 0) {
			debt = debt - (int)debt % 1000;
			debt += 1000;
		}
	}
	printf("%d\n", (int)debt);

	return 0;
}


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

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  long long N;
  cin >> N;

  string ans = "";

  while(true) {
    int num = N % 26;
    if(num == 0) {
      num = 26;
    }
    ans = (char)(num + (int)'a' - 1) + ans;
    N -= num;
    N /= 26;
    if(N == 0) {
      break;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3576
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int n, k, a, b;
    cin >> n >> k;
    unordered_set<int> snuke;
    while(k--) {
        cin >> a;
        while(a--) {
            cin >> b;
            snuke.insert(b);
        }
    }
    cout << n - snuke.size() << endl;
    return 0;
}


Measured memory_bytes: 3676
import java.util.*;

public class Main {

    static int mod = (int)Math.pow(10, 9)+ 7;

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int K = sc.nextInt();
        int n = N-K+1;

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

            if((n>0)&(N-K+1>=i)&(K>=i)) {
                long blue = nCr(N-K+1,i);
                long red = nCr(K-1,i-1);
                System.out.println(blue*red%mod);
            }else{
                System.out.println(0);
            }
            n--;
        }
        sc.close();
    }

    public static long factorical(int n){
        long tmp = 1;
        for (int i=n; i>0; i--){
            tmp = (tmp*i)%mod;
        }
        return tmp;
    }

    public static long power(long a, int n){
        long res=1;
        while(n>0){
            if ((n-n/2*2)==1){
                res = (res*a)%mod;
            }
            a = (a*a)%mod;
            n >>= 1;
        }
        return res;
    }

    public static long inv(long n){
        return power(n, mod-2);
    }

    public static long nCr(int n, int r){
        return factorical(n) * inv(factorical(n-r))%mod * inv(factorical(r))%mod;
    }
}




Measured memory_bytes: 22356
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>

using namespace std;


int main(){
	int A,B,C,D,E,sum=0;

	scanf("%d",&A);
	scanf("%d",&B);
	scanf("%d",&C);
	scanf("%d",&D);
	scanf("%d",&E);

	if(A <= 0){
		sum += (0-A)*C;
		sum += D;
		sum += B*E;
	}else{
		sum = (B-A)*E;
	}

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

	return 0;

}

Measured memory_bytes: 2736
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647
// MAX O(n) 10^18

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> D(K);
    rep(i, K) cin >> D.at(i);

    string ans;
    for (int i = N; i < 1000000; i++) { // 100000 * 5 * 10 -> OK
        string digits = to_string(i);
        bool isOk = true;
        for (char digit : digits) {
            rep(j,K) {
                if (digit - '0' == D.at(j)) isOk = false;
            }
        }
        if (isOk) {
            ans = digits;
            break;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3676
#include <stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card {
  char suit;
  int value;
};

struct Card L[MAX/2+2], R[MAX/2+2];

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

void mergeSort(struct 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);
  }
}

int partition(struct Card A[], int n, int p, int r) {
  int i, j;
  struct Card t, x;
  x = A[r];
  i = p-1;
  for(j=p; j<r; j++) {
    if(A[j].value <= x.value) {
      i++;
      t=A[i]; A[i]=A[j]; A[j]=t;
    }
  }
  t=A[i+1]; A[i+1]=A[r]; A[r]=t;
  return i+1;
}

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

int main() {
  int n, i, v;
  struct Card A[MAX], B[MAX];
  char S[10];
  int stable = 1;

  scanf("%d", &n);

  for(i=0;i<n;i++) {
    scanf("%s %d",S,&v);
    A[i].suit =  B[i].suit  = S[0];
    A[i].value = B[i].value = v;
  }

  mergeSort(A,n,0,n);
  quickSort(B,n,0,n-1);

  for(i=0;i<n;i++) {
    // マージソートとクイックソートの結果を比べる
    if(A[i].suit != B[i].suit) stable = 0;
  }

  if(stable==1) printf("Stable\n");
  else printf("Not stable\n");
  for(i=0;i<n;i++) {
    printf("%c %d\n",B[i].suit,B[i].value);
  }

  return 0;
}



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

const ll NEGINF=-(1LL<<63-1);
vector<vector<pair<ll,ll>>> g;
vector<bool> isInf;
vector<bool> visited;
vector<ll> scores;

void bf() {
	scores[1]=0;
	for (int i=0; i<g.size()-1; i++)
		for (int v=0; v<g.size(); v++)
			for (pair<ll,ll> p : g[v])
				scores[p.first] = max(scores[p.first], scores[v] + p.second);
}

void hasInfCycle() {
	for (int v=0; v<g.size(); v++)
		for (pair<ll,ll> p : g[v])
			if (scores[v] + p.second > scores[p.first])
				isInf[p.first] = true;
}

void dfs(int s) {
	visited[s]=true;
	isInf[s]=true;
	for (pair<ll,ll> p : g[s])
		if (!visited[p.first])
			dfs(p.first);
}

int main() {
	ll n,m; cin>>n>>m;
	g.resize(n+1);
	scores.resize(n+1,NEGINF);
	isInf.resize(n+1);
	visited.resize(n+1);
	for (ll i=0; i<m; i++) {
		ll a,b,c; cin>>a>>b>>c;
		g[a].push_back({b,c});
	}
	bf();
	hasInfCycle();
	for (int i=1; i<=n; i++)
		if (isInf[i]) dfs(i);

	if (isInf[1] or isInf[n]) cout << "inf" << endl;
	else cout << scores[n] << endl;
	return 0;
}


Measured memory_bytes: 384
import java.util.*;
public class Main {
    public static void main(String [] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int list [] = new int[n];
        Arrays.fill(list,0);
        if(m>0) {
            boolean check = true;
            for (int i = 0; i < m; i++) {
                int s = sc.nextInt();
                int c = sc.nextInt();
                if(s==1&&c==0&&n!=1){
                    check = false;
                    break;
                }
                if(list[s-1]!=0&&c!=list[s-1]){
                    check = false;
                    break;
                }
                list[s-1]=c;
            }

            if (!check) System.out.println(-1);
            else if (n != 1 && list[0] == 0 && check == true) {
                list[0] = 1;
                StringBuilder opt = new StringBuilder();
                for (int i : list) opt.append(i);
                System.out.println(opt);
            }
            else{
            StringBuilder opt = new StringBuilder();
            for (int i : list) opt.append(i);
            System.out.println(opt);
            }
        }
        else if(m==0) {
            if(n==1) System.out.println(0);
            else {
                list[0]=1;
                StringBuilder opt = new StringBuilder();
                for (int i : list) opt.append(i);
                System.out.println(opt);
            }
        }
    }
}

Measured memory_bytes: 23764