akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
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 io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const ll MOD = 1000000007;
const double EPS = 1e-9;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;


ll dp[2][3010][3010];

ll rec(vi &v, int l, int r, bool turn) {
    
    ll res = -LLINF * ((!turn) ? 1 : -1);
    if(dp[turn][l][r] != 0){
        res = dp[turn][l][r];
    } else if(l == r) {
        res = v[l] * ((!turn) ? 1 : -1);
    }
    else {
        if(!turn) {
            if(l <= r - 1) {
                chmax(res, rec(v, l, r - 1, 1 - turn) + v[r] * ((!turn) ? 1 : -1));
            }
            if(l + 1 <= r) {
                chmax(res, rec(v, l + 1, r, 1 - turn) + v[l] * ((!turn) ? 1 : -1));
            }
        } else {
            if(l <= r - 1) {
                chmin(res, rec(v, l, r - 1, 1 - turn) - v[r]);
            }
            if(l + 1 <= r) {
                chmin(res, rec(v, l + 1, r, 1 - turn) - v[l]);
            }
        }
    }
    // cout<<turn<<" "<<l<<" "<<r<<" "<<res<<endl;

    return dp[turn][l][r] = res ;
}


int main(void) {

    int n;
    cin >> n;
    rep(i, 3010) rep(j, 3010) {
        dp[0][i][j] = 0;
        dp[1][i][j] = 0;
    }
    vi v(n);
    rep(i, n) cin >> v[i];

    ll ans = rec(v, 0, n - 1, 0);

    

    fin(ans);
}


Measured memory_bytes: 142080
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) noexcept {
  return std::vector<T>(n, std::forward<T>(val));
}

template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) noexcept {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}

template<class T, class Cond>
struct chain {
  Cond cond; chain(Cond cond) : cond(cond) {}
  bool operator()(T& a, const T& b) const {
    if(cond(a, b)) { a = b; return true; }
    return false;
  }
};
template<class T, class Cond>
chain<T, Cond> make_chain(Cond cond) { return chain<T, Cond>(cond); }

vector<int> A, B, C, D;

struct edge {
  int a, b, c, d;
};

vector<vector<edge>> vec;
int N, M, Q;

int ans = 0;

void dfs(int i, vector<int>& x, int MAX, int res) {
  if(i == N) {
    ans = std::max(ans, res);
    return;
  }
  rep(ne,MAX,M) {
    int sum = res;
    x[i] = ne;
    for(auto& e: vec[i]) {
      if(x[e.b] - x[e.a] == e.c) {
        sum += e.d;
      }
    }
    dfs(i + 1, x, ne, sum);
  }
}

int main() {
  cin >> N >> M >> Q;
  A.resize(Q);
  B.resize(Q);
  C.resize(Q);
  D.resize(Q);
  vec.resize(N);
  rep(i,0,Q) {
    cin >> A[i] >> B[i] >> C[i] >> D[i];
    A[i]--;
    B[i]--;
    vec[B[i]].push_back({ A[i], B[i], C[i], D[i] });
  }

  vector<int> x(N);
  dfs(0, x, 0, 0);
  cout << ans << endl;
}


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

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

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

    sw = selectionSort(A,N);

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

    return 0;
}


Measured memory_bytes: 2148
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
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; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, a, b;
    cin >> n >> a >> b;
    ll lb = a * (n-1) + b;
    ll ub = b * (n-1) + a;
    ll ans = ub - lb + 1;
    chmax(ans, 0LL);
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
string S;
cin>>S;
for(int i = 0; i<S.size(); i++){
    for(int j = i+1; j<S.size(); j++){
        if(S[i]==S[j]){
            cout<<"no"<<endl;
            return 0;
        }
    }
}
cout<<"yes"<<endl;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const int MOD = 1000000007;

//↓combination(ll a, ll b) でaCr計算。
//------------------------------------------------------------------------------------------
ll mpow(ll x, ll n){
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % MOD;
        x = x*x % MOD;
        n = n >> 1;
    }
    return ans;
}
ll kj(ll x){
    ll s = 1;
    for(ll i = 1; i <= x; i++){
        s = s * i % MOD;
    }
    return s;
}
ll combination(ll a, ll b){
    if(a == 0 && b == 0) return 1;
    if(a < b || a < 0) return 0;
    return (kj(a) * mpow(kj(b), MOD-2) % MOD) * mpow(kj(a-b), MOD-2) % MOD;
}
//---------------------------------------------------------------------------------------------
//↑combination(ll a, ll b) でaCr計算。

int main(){
    ll L,R;
    cin >> L >> R;
    int ans = 2500;
    if(R-L > 2030){
        ans = 0;
    }else{
        for(ll i=L; i < R; i++){
            for(ll j=i+1; j<R+1; j++){
                int mod = (i*j)%2019;
                ans = min( ans, mod );
            }
        }
    }
    cout << ans;
}

Measured memory_bytes: 256
class RMQ
  def initialize(ini)
    @a = []
    i = 1
    while i < ini
      @a << Array.new(i, 0)
      i *= 2
    end
    @v = Array.new(i, 0)
    @a << @v
  end

  def larger(x, y)
    x > y ? x : y
  end

  def inspect
    @a.inject(""){|acc, x| acc + x.join(' ') + "\n"}
  end

  def []=(i, x)
    @v[i] = x
    layer = @a.size - 2
    while layer >= 0
      i /= 2
      y = larger(@a[layer + 1][i * 2], @a[layer + 1][i * 2 + 1])
      break if @a[layer][i] > y
      @a[layer][i] = y
      layer -= 1
    end
  end

  def rangeMax(a, b, layer = @a.size - 1)
    if a > b
      return 0
    else
      side = larger((a.odd? ? @a[layer][a] : 0), (b.even? ? @a[layer][b] : 0))
      larger(side, rangeMax((a + 1) / 2, (b - 1) / 2, layer - 1))
    end
  end
end
 
tree = RMQ.new(300_000)
 
N, K = gets.split.map(&:to_i)
N.times do
  a = gets.to_i
  left = a - K
  left = 0 if left < 0
  right = a + K
  right = 300_000 if right > 300_000
  tree[a] = 1 + tree.rangeMax(left, right)
end
puts tree.rangeMax(0, 300_000)

Measured memory_bytes: 22424
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int H, R;
    cin >> H >> R;
    if(H + R > 0) {
        cout << 1 << endl;
    }else if(H + R < 0) {
        cout << -1 << endl;
    }else {
        cout << 0 << endl;
    }
}



Measured memory_bytes: 3088
#include<iostream>
#include<algorithm>
#include<cassert>
#include<vector>
#include<fstream>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<queue>
#include<map>

using namespace std;
#define REP(i,m,n) for(long long i=m;i<n;++i)
#define INF 10000000000000000
#define MOD 1000000007
#define ll long long
#define mp make_pair
#define all(v) v.begin(),v.end()

int main() {
	int n;
	cin >> n;
	int a = n, hoge = 0;
	while (a != 0) {
		hoge += a % 10;
		a /= 10;
	}
	if (n%hoge == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
using vec_int = vector<int>;
using P = pair<int,int>;
using T = tuple<int,int,int>;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}

signed main(){
    int N; cin>>N;
    vec_int a(N);
    int maxa=0;
    rep(i,N){
        cin>>a.at(i);
        if(a.at(i)>maxa)maxa=a.at(i);
    }

    int bigN=0;
    int smallN=0;
    rep(i,N){
        if(a.at(i)==maxa){
            bigN++;
        }else if(a.at(i)==maxa-1){
            smallN++;
        }
    }
    if(bigN+smallN<N){
        cout<<"No"<<endl;
        return 0;
    }

    //基本的にはmaxa色の色が存在していると考えてよい。
    // 唯一の例外は全員が違う色の時なので、それはここで処理しておく
    if(bigN==N&&maxa==N-1){
        cout<<"Yes"<<endl;
        return 0;
    }

    // というわけでmaxa色あるんだけれど、
    // このうち一人しか色を持っていない色がsmallN色ある。
    // 逆に言うとmaxa-smallN色については必ずダブりがないといけない
    // 
    // このような振り分けが可能であるかを考えないといけない。
    if(maxa<=smallN){
        cout<<"No"<<endl;
        return 0;

    }
    if((N-maxa)>=(maxa-smallN)){
        cout<<"Yes"<<endl;
        return 0;
    }else{
        cout<<"No"<<endl;
        return 0;

    }




    return 0;
}

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

int main(void){
  int N, M;
  cin >> N >> M;
  vector<int> vec(M, 0);
  int K, A;
  for(int i = 0; i < N; i++){
    cin >> K;
    for(int j = 0; j < K; j++){
      cin >> A;
      vec[A - 1] += 1;
    }
  }
  int count = 0;
  for(int i = 0; i < M; i++){
    if(vec[i] == N) count++;
  }
  cout << count;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#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(int i=0; i<(n); i++)
#define RREP(i, n) for(int i=(n-1); i>=0; i--)
#define REP1(i, n) for(int i=1; i<=(n); i++)
#define RREP1(i, n) for(int i=(n); i>=1; i--)
#define ALL(a) (a).begin(),(a).end()
#define UNIQUE_SORT(l) sort(ALL(l)); l.erase(unique(ALL(l)), l.end());
#define CONTAIN(a, b) find(ALL(a), (b)) != (a).end()
#define out(...) printf(__VA_ARGS__)
#if DEBUG
#define debug(...) printf(__VA_ARGS__)
#else
#define debug(...) /* ... */
#endif
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

void solve();
signed main()
{
#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

/*================================*/
#if DEBUG
#define SIZE 100
#else
#define SIZE 223450
#endif

int N,Q,K;
int A[SIZE];

void solve() {
    cin>>N;
    int a, ans =0;
    REP1(i,N) {
        cin>>a;
        if (i%2 && a%2) ans++;
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 3580
#define _GLIBCXX_DEBUG
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdlib>
#include <iostream>
#include <iterator>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#include <math.h>

using namespace std;
typedef long long ll;
    

int main() {
    double a, b, x;
    cin >> a >> b >> x;
    double volume = a*a*b;
    double s = 0;
    double c = 0;
    double rest = 0;
    cout << fixed << setprecision(10); // C++

    if(volume/2 <= x){
        rest = x - volume/2;
        //cout << rest << endl;
        s = b - 2*(rest / (a * a));
        //cout << s << endl;
        double t = s/a;
        //cout << t << endl;
        double q = atan(t);
        //cout << q << endl;
        double ans = q * 180 / 3.14159265359;
        cout << ans <<endl;
    }
    else{
        c = (2*x)/(a*b);
        double t = b/c;
        //cout << t << endl;
        double q = atan(t);
        //cout << q << endl;
        double ans = q * 180 / 3.14159265359;
        cout << ans <<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
ll MOD = 1000000007;
ll INF = 200000000000000000;
double EPS = 1e-12;
double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

struct UnionFind{
    vector<int> par;
    vector<int> rank;
    vector<ll> connection;

    UnionFind(int N):par(N),rank(N),connection(N){
        rep(i,N){
          par[i] = i;
          rank[i] = 0;
          connection[i] = 1;
        }
    }

    int root(int x){
       while(x != par[x]){
        x =  par[x] = par[par[x]];
       }
       return x;
    }
    
    bool same(int x,int y){
      return root(x) == root(y);
    }

    void unite(int x,int y){
        int rx = root(x);
        int ry = root(y);
        if(!same(x,y)){
            connection[root(x)] += connection[root(y)];
            connection[root(y)] = connection[root(x)];
        }
        if(rx == ry)return;
        if(rank[x] > rank[y]){
          par[y] = rx;
        }
        if(rank[x] < rank[y]){
          par[rx] = ry;
        }else{
          par[ry] = rx;
          if(rank[x] == rank[y]){
            rank[rx]++;
          }
        }
    }

    ll SIZE(int x){
        return connection[root(x)];
    }
};


int main(){
  ll N;
  string S;
  cin >> N >> S;
  if(count(ALL(S),'R') >= (S.size())/2+1){
    cout <<"Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    ( $($t:ty),* ) => {{
        let mut s = String::new();
        std::io::stdin().read_line(&mut s);
        let mut splits = s.trim().split_whitespace();
        ($( { splits.next().unwrap().parse::<$t>().unwrap() },)*)
    }}
}

#[allow(dead_code)]
fn factor2(n: u64) -> (u64, u64) {
    let max = (n as f64).sqrt().ceil() as u64;

    for i in (1..(max + 1)).rev() {
        if n % i == 0 {
            return (i, n / i);
        }
    }
    return (0, 0);
}

#[allow(unused_must_use)]
#[allow(unused_variables)]
fn solve() {
    let (n, ) = input!(u64);

    let (a, b) = factor2(n);

    println!("{}", a + b - 2);
}

fn main() {
    solve();
}


Measured memory_bytes: 4352
n = int(input())
#dp[j] = j￥を引き出すために必要な操作の最小回数
dp = [float('inf')]*(10**5+1)
dp[0] = 0
import math

for i in range(1,10**5+1):
    for j in range(int(math.log(i,9)+0.00001)+1):
        dp[i] = min(dp[i], dp[i-9**j]+1)

    for k in range(int(math.log(i,6))+1):
        dp[i] = min(dp[i],dp[i-6**k]+1)
 
print(dp[n])
#print(dp[n-3:n+1])



Measured memory_bytes: 45132
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    x = int(input())
    if x < 1200:
        print("ABC")
    else:
        print("ARC")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3952
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>

#define MOD 1e9+7;
#define INF 1e17+9;
#define PI acos(-1);

using namespace std;

int main(){
	long long n,a,b;
	cin >> n >> a >> b;
	
	long long cost_win,cost_lose,cost_cent;
	
	if((b-a)%2==0){
		cost_cent=abs(b-a)/2;
		cout << cost_cent << endl;
		return 0;
	}
	
	cost_win=a+(b-a-1)/2;
	cost_lose=n-b+1+(b-a-1)/2;
	
	long long min_cost=min(cost_win,cost_lose);
	cout << min_cost << endl;
	return 0;
}


Measured memory_bytes: 256
import bisect

N=int(input())
S=list(str(input()))

def ci(x):
  return "abcdefghijklmnopqrstuvwxyz".find(x)

d=[[] for _ in range(26)]
for i,s in enumerate(S):
  d[ci(s)].append(i)

for i in range(int(input())):
  t,x,y=input().split()
  if t=="1":
    x=int(x)-1
    if S[x]!=y:
      l=bisect.bisect_left(d[ci(S[x])],x)
      d[ci(S[x])].pop(l)
      bisect.insort(d[ci(y)],x)
      S[x]=y
  else:
    x,y=int(x)-1,int(y)-1
    c=0
    for j in range(26):
      l=bisect.bisect_left(d[j],x)
      if l<len(d[j]) and d[j][l] <= y:
        c += 1
    print(c)


Measured memory_bytes: 29192
N = int(input())
B = list(map(int, input().split()))

A = [B[0]]

for i in range(len(B)):
  if A[i]  <= B[i]:
     A.append(B[i])
  else:
     A[i] = B[i]
     A.append(B[i])

print(sum(A))

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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> vp(n+1);
    for(int i=1; i<=n; i++) {
        int tmp = 1;
        while (tmp * i < k) {
            tmp *= 2;
        }
        vp[i] = tmp;
    }
    int mother = *max_element(vp.begin(), vp.end()), child = 0;
    for(int i=1; i<=n; i++) {
        child += mother / vp[i];
    }
    cout << fixed << setprecision(12) << (double) child / (double) (mother * n) << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<queue>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/****************************/
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define qi queue<int>
#define mii map<int,int>
#define msi map<string,int>
#define vs vector<string>
#define vc vector<char>
/****************************/
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define rep3(i,a,n) for(ll i=(a);i<(n);i++)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define pi 3.1415926535897932384626433832795
#define zero(n) memset(n,0,sizeof(n));
#define SZ(n) n.size()
#define ss st.st
#define sn st.nd 
/****************************/
using namespace std;     
int n,k;
int a[5050];
int main()
{
	ios::sync_with_stdio(0);
	cin>>n>>k;
	rep(i,n)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	reverse(a,a+n);
	ll cnt=0;
	int ans=0;
	rep(i,n)
	{
		cnt+=a[i];
		if(cnt>=k)
		{
			cnt-=a[i];
			ans=0;
		}
		else 
		{
			ans++;
		}
	} 
	cout<<ans<<endl;
	return 0;                                                                                                                                     
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {

	static void solve (Scanner in, PrintWriter out, Methods ms) {

		char[][] map = new char[8][8];
		for (int i = 0; i < 8; i++) {
			map[i] = in.next().toCharArray();
		}

		out.println(90);
		for (int i = 0; i < 8; i++) {
			for (int j = 0; j < 8; j++) {
				out.print(map[7-j][i]);
			}
			out.println();
		}

		out.println(180);
		for (int i = 0; i < 8; i++) {
			for (int j = 0; j < 8; j++) {
				out.print(map[7-i][7-j]);
			}
			out.println();
		}

		out.println(270);
		for (int i = 0; i < 8; i++) {
			for (int j = 0; j < 8; j++) {
				out.print(map[j][7-i]);
			}
			out.println();
		}

	}


	public static void printMap (char[][] a) {
		System.out.println();
		for (int i = 0; i < a.length; i++) {
			for (int j = 0; j < a[0].length; j++) {
				System.out.print(a[i][j]);
			}
			System.out.println();
		}
	}

	public static void main (String[] args) {

		Scanner in = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		Methods ms = new Methods();
		solve(in, out, ms);
		in.close();
		out.close();

	}

	static class Methods {

		public void print (Object... ar) {System.out.println(Arrays.deepToString(ar));}

		public int max (int... ar) {Arrays.sort(ar); return ar[ar.length-1];}

		public int min (int... ar) {Arrays.sort(ar); return ar[0];}

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

		public long lcm (long a, long b) {return a / gcd(a,b) * b;}

		public long factorial (int i) {
			if (i == 1) return 1;
			else return i * factorial(i-1);
		}

		public int manhat (int x1, int y1, int x2, int y2) {
			return Math.abs(x1 - x2) + Math.abs(y1 - y2);
		}

		public double euclid (double x1, double y1, double x2, double y2) {
			return Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
		}

		public boolean isPrime (int n) {
			if (n == 2) return true;
			if (n < 2 || n % 2 == 0) return false;
			for (int i = 3; i <= Math.sqrt(n); i += 2) if(n % i == 0) return false;
			return true;
		}

	}

}


Measured memory_bytes: 26244
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll MOD=(ll)1e9+7;
//}}}

int x[100];
int y[100];
int main(){
  int N, M, X, Y;
  cin >> N >> M >> X >> Y;
  rep(i, N) cin >> x[i];
  rep(i, M) cin >> y[i];
  sort(x, x + N);
  sort(y, y + M);

  bool ans = x[N - 1] < y[0] && X < y[0] && y[0] <= Y;
  puts(ans ? "No War" : "War");
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define EPS 1e-14
using namespace std;

int main(){
	int x,y,z,v[4],n,e[51],a[51];
	double dp[51][5000];
	while(1){
		cin >> x >> y >> z;
		if(!x) break;
		for(int i = 0;i <= 50;i++){
			e[i] = 0;
			a[i] = 0;
		}
		for(int i = 0;i < x;i++) cin >> v[i];
		for(int i = 0;i < z;i++) {
			cin >> n;
			cin >> e[n] >> a[n];
		}
		for(int i = 0;i <= 50;i++){
			for(int j = 0;j < 5000;j++) dp[i][j] = 0;
		}
		dp[0][0] = 1;
		for(int i = 0;i < y;i++){
			//if(e[i] == 1) continue;
			for(int j = 0;j < 5000;j++){
				for(int k = 0;k < x;k++){
					int pos = min(y,i + v[k]);
					if(e[pos] == 1){
						dp[min(y,pos + a[pos])][j] += dp[i][j] / (double)x;
					}
					else if(e[pos] == 2){
						if(j + a[pos] < 5000) dp[pos][j + a[pos]] += dp[i][j] / (double)x;
					}
					else if(e[pos] == 3){
						dp[pos][max(0,j - a[pos])] += dp[i][j] / (double)x;
					}
					else{
						dp[pos][j] += dp[i][j] / (double)x;
					}
				}
			}
		}
		double res = 0;
		for(int i = 0;i <= 4900;i++){
			res += (double)i * dp[y][i] + EPS;
			//res += dp[y][i];
		}
		cout << (int)res << endl;
	}
	return 0;
}

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

int main(void){
    string S;
    cin >> S;
    int result{0};
    for(int i{0}; i<S.size(); ++i){
        if(S[i]=='+')
            ++result;
        else
            --result;
    }
    cout << result << endl;
}

Measured memory_bytes: 256
import numpy as np
S = np.array(list(input()))
T = np.array(list(input()))
for i in range(len(S), -1, -1):
    subset = S[i:(i + len(T))]
    if len(subset) == len(T):
        # print('subset', subset)
        # print((subset == '?') | (subset == T))
        # print('all', np.all((subset == '?') | (subset == T)))
        if np.all((subset == '?') | (subset == T)):
            S[i:(i + len(T))] = T
            S[S == '?'] = 'a'
            # print('S', S)
            print(''.join(S))
            break
else:
    print('UNRESTORABLE')


Measured memory_bytes: 12612
#include <stdio.h>

int main(void) {
  long long n, nowmax = 0, max = 0, min = 0, i, nowmin = 0, now = 0;
  scanf("%lld", &n);
  int a, bef;
  for(i = 0; i < n; ++i) {
    scanf("%d", &a);
    if(i) {
      if(bef > a) {
        nowmin = min, nowmax--;
        if(nowmin > nowmax) nowmin = nowmax, min = nowmin;
      } else if(bef < a) {
        nowmin++, nowmax = max;
        if(nowmin > nowmax) nowmax = nowmin, max = nowmax;
      }
    }
    bef = a;
  }
  printf("%lld\n", max - min + 1);
  return 0;
}


Measured memory_bytes: 2748
#include<iostream>

using namespace std;

int main(){
	int n,count=0;
	cin >>n;
	int a[n];
	for(int i= 0;i<n;i++){
		cin >> a[i];
	}
	for(int i = 0;i<n;i++){
		int min = a[i];
		int min_num;
		bool flag = false;
		for(int j=i;j<n;j++){
			if(min >a[j]){
				min = a[j];
				min_num = j;
				flag = true;
			}
		}
		if(flag){
			int temp = a[i];
			a[i] = min;
			a[min_num] = temp;
			count++;
		}
	}
	for(int k= 0;k<n-1;k++){
		cout<< a[k] << ' ';
	}
	cout << a[n-1] << endl;
	cout << count << endl;
	return 0;
}
	

Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
using lint = long int;
#define MOD 1000000007

lint N, a, b, res = 0;


lint binary_pow(lint a, lint n, lint m){
    lint res = 1;
    /*以降,nの2進数表記で考える...aもそれに合わせる*/
    while(n > 0){
        if(n & 1) res = (res * a) % m;  //奇数分は別
        a = (a * a) % m;
        n >>= 1; 
    }
  	return res;
}

lint mod_inv(int x, int y){
    lint alpha = x, beta = y, u = 1, v = 0;
    lint d;
    while(beta){
        d = alpha / beta;
        alpha -= beta * d; swap(alpha, beta);
        u -= v * d; swap(u, v);
    }

    u %= y;
    if(u < 0) u += y;  //法を加えて正に
    return u;
}



lint mod_Comb(lint n, lint k, lint m){
    lint val = 1, inv = 1;
    for(int i = n-k+1; i <= n; i++){ val *= i; val %= m; }
    for(int i = 1; i <= k; i++){ inv *= i; inv %= m; }
    inv = mod_inv(inv, m);
    return (val * inv) % m;
}


int main(){
    cin >> N >> a >> b;
    res = (binary_pow(2,N,MOD)-mod_Comb(N,a,MOD)-mod_Comb(N,b,MOD)-1)%MOD;
    if(res < 0) res += MOD;
  	cout << res << endl;
    return 0;
}

    

Measured memory_bytes: 3628
#![allow(non_snake_case, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $var = read_value!($next, $t); input_inner!{$next $($r)*} }; }
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, [ $t:tt ]) => { { let len = read_value!($next, usize); (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() } }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        N: usize,
        K: usize,
        mut H: [u64; N],
    }
    H.sort();
    let mut ans = std::u64::MAX;
    for i in 0..N-K+1{
        ans = min(ans, H[i+K-1]-H[i]);
    }
    println!("{}",ans);
}

Measured memory_bytes: 4352
N, Q = map(int, input().split()) 
S = input()
tmp = [0] * (N+1)

for i in range(N):
    which = (1 if S[i : i + 2] == 'AC' else 0)
    tmp[i + 1] = tmp[i] + which
for _ in range(Q):
    l, r = map(int, input().split())
    print(tmp[r-1] - tmp[l-1])

Measured memory_bytes: 9412
#include<bits/stdc++.h>
using namespace std;
struct Unionfind{
  vector<int>par;
  vector<int>rank;
  Unionfind(int n):par(n),rank(n){
    for(int i=0;i<n;i++){
      par[i]=i;
      rank[i]=0;
    }
  }
  int root(int x){
    return par[x]==x?x:par[x]=root(par[x]);
  }
  bool same(int x,int y){
    return root(x)==root(y);
  }
  void unit(int x,int y){
    x=root(x);
    y=root(y);
    if(x==y)return;
    if(rank[x]<rank[y]){
      par[x]=y;
    }else{
      par[y]=x;
      if(rank[x]==rank[y]){
        rank[x]++;
      }
    }
  }
};
int main(){
  int N,M;
  cin>>N>>M;
  vector<pair<int,int>>edge(M);
  for(int i=0;i<M;i++){
    int a,b;
    cin>>a>>b;
    a--,b--;
    edge[i].first=a;
    edge[i].second=b;
  }
  int cnt=0;
  for(int i=0;i<M;i++){
    //i番目の辺について調べる
    Unionfind uf(N);
    for(int j=0;j<M;j++){
      if(i!=j){
        int a=edge[j].first;
        int b=edge[j].second;
        uf.unit(a,b);
      }
    }
    int sa=edge[i].first;
    int sb=edge[i].second;
    
    if(!uf.same(sa,sb)){
      //cout<<"sa:"<<sa<<"sb:"<<sb<<endl;
      cnt++;
    }
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define pb push_back
#define mp make_pair
#define INF9 1000000000 //10^9
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pii=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
using vb=vector<bool>;

vi stk(101);
int top = 0;

void print(vi A, int n){
    rep(i,n){
        if(i>0) cout << " ";
        cout << A[i];
    }
    cout << endl;
}

void initialize() {top = 0;}
void push(int x) {stk[++top] = x;}
int pop() {return stk[top--];}
bool isEmpty() {return top == 0;}
bool isFull() {return top==100;}

int main() {
    string s;
    while(cin >> s){
        // cout << s << endl;
        if(s=="+") push(pop()+pop()); 
        else if(s=="-") {
            int i1 = pop(), i2 = pop();
            push(i2-i1); 
        }
        else if(s=="*") push(pop()*pop());
        else push(stoi(s));
        // print(stk,10);
    }
    cout << (int)pop() << endl;
    return 0;
}


Measured memory_bytes: 3156
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ETozanAndGezan solver = new ETozanAndGezan();
        solver.solve(1, in, out);
        out.close();
    }

    static class ETozanAndGezan {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            long[] a = new long[n];
            long[] b = new long[n];

            for (int i = 0; i < n; i++) {
                a[i] = in.nextLong();
                b[i] = in.nextLong();
            }

            long answer = solve(a, b);

            out.println(answer);
        }

        long solve(long[] a, long[] b) {
            int n = a.length;
            long answer = 0;

            long minimumAGreaterThanB = Long.MAX_VALUE;
            long minimumBLessThanA = Long.MAX_VALUE;
            int index = -1;

            for (int i = 0; i < n; i++) {
                answer += a[i]; // either one just want total sum

                if (a[i] > b[i]) {
                    if (a[i] - b[i] < minimumAGreaterThanB) {
                        index = i;
                        minimumAGreaterThanB = a[i] - b[i];
                    }
                    minimumBLessThanA = Math.min(minimumBLessThanA, b[i]);
                }
            }

            if (index >= 0) {
                answer -= minimumBLessThanA;
            } else {
                answer = 0;
            }

            return answer;
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}



Measured memory_bytes: 32492
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 1000000000;
const int maxn = 200000+5;
ll T,n,m;
vector<pair<int,int> > a;
vector<int> b;
int main() {
//    scanf("%d",&T);
//    while(T--) {
//
//    }
	cin>>n;
	for(int i=0;i<n;i++){
		int t;
		cin>>t;
		a.push_back({t,i});
	}
	sort(a.begin(),a.end());
	int cnt = 0;
	for(int i=0;i<n;i++){
		if(a[i].second!=i)
			cnt++;
	}
	if(cnt>2){
		cout<<"NO\n";
	}
	else {
		cout<<"YES\n";
	}
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<algorithm>
using std::cout;
using std::cin;
using std::endl;
 
int main(void){
    int N;
    long long top[5]={};
    long long answer=0;
    std::string str;
 
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>str;
        if(str[0]=='M'){
            top[0]++;
        }
        else if(str[0]=='A'){
            top[1]++;
        }
        else if(str[0]=='R'){
            top[2]++;
        }
        else if(str[0]=='C'){
            top[3]++;
        }else if(str[0]=='H'){
            top[4]++;
        }
 
    }
 
    for(int i=0;i<=2;i++){
        for(int j=i+1;j<=3;j++){
            for(int k=j+1;k<=4;k++){
                answer+=top[i]*top[j]*top[k];
            }
        }
    }
    cout<<answer<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>

#define	pb			push_back
#define	rep(i,n)	for(int i=0;i<(n);i++)

using namespace std;

typedef	vector<int>	vi;

int a[10];

bool isOK(){
	int M=a[9];
	int s=(a[0]+a[4]+a[8])%M;
	if(s!=(a[2]+a[4]+a[6])%M)	return false;
	rep(i,3)if(s!=(a[3*i]+a[3*i+1]+a[3*i+2])%M)	return false;
	rep(i,3)if(s!=(a[i]+a[3+i]+a[6+i])%M)		return false;
	return true;
}

int main(){
	while(1){
		rep(i,10)	scanf("%d",a+i);
		if(a[0]==-1)	break;

		vi pos,num;
		bool used[11]={};
		rep(i,10){
			if(a[i]==0)	pos.pb(i);
			else	used[a[i]]=true;
		}
		rep(i,10)if(!used[i+1])	num.pb(i+1);
		sort(num.begin(),num.end());

		int cnt=0;
		do{
			rep(i,pos.size())	a[pos[i]]=num[i];
			if(isOK())	cnt++;
		}while(next_permutation(num.begin(),num.end()));
		printf("%d\n",cnt);
	}

	return 0;
}

Measured memory_bytes: 816
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9+7;
//const long long MOD = ;
const long long INF_LL = 1e18+3; const int INF_int = 1e9+3;
#define ll long long
#define rep(i,n) for(int i = 0;i<n;i++)
#define lrep(i,n) for(long long i = 0;i<n;i++)
#define All(a) a.begin(),a.end()
#define Debug_Output_ALL(a) for(auto itr = a.begin();itr!=a.end();itr++) cout << *itr << " ";cout << endl;
int main(){
    string s;
    set<char> st;
    cin >> s;
    rep(i,s.size()) st.insert(s[i]);
    if(st.size()==1) cout << "No" << endl;
    else cout << "Yes" << endl; 
}

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

int main() {
  std::string s;
  std::cin >> s;
  for (int i = 0; i < s.size(); i++) {
    if ((i+1) % 2 != 0) {
      std::cout << s.at(i);
    }
  }
  std::cout << '\n';
}

Measured memory_bytes: 512
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn get<T: FromStr>() -> T
        where <T as FromStr>::Err: Debug
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
        where <T as FromStr>::Err: Debug
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}

fn main() {
    let xab: Vec<i64> = util::gets();
    let x = xab[0];
    let a = xab[1];
    let b = xab[2];

    if b <= a {
        println!("delicious");
    } else if b - a <= x {
        println!("safe");
    } else {
        println!("dangerous");
    }
}


Measured memory_bytes: 4352
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int c = sc.nextInt();
		char[] s = sc.next().toCharArray();
		sc.close();

		int[] l = new int[k];
		int idx = 0;
		for (int i = 0; i < k; i++) {
			while (s[idx] == 'x') {
				idx++;
			}
			l[i] = idx;
			idx += c + 1;
		}

		int[] r = new int[k];
		idx = n - 1;
		for (int i = k - 1; i >= 0; i--) {
			while (s[idx] == 'x') {
				idx--;
			}
			r[i] = idx;
			idx -= c + 1;
		}

		PrintWriter pw = new PrintWriter(System.out);
		pw.flush();
		for (int i = 0; i < k; i++) {
			if (l[i] == r[i]) {
				pw.println(l[i] + 1);
			}
		}
		pw.flush();
	}
}


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

using namespace std;
int main(){
	int a[5];
	for(int i=0;i<5;i++){
		cin>>a[i];
	}
	int k;
	cin>>k;
	sort(a,a+5);
	if(a[4]-a[0]>k)cout<<":(";
	else cout<<"Yay!";
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <fstream>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
typedef long long ll;

#define INF 1000000000

int main(){
    int n,w;
    while(cin>>n>>w, n|w){
        vector<int> vec(n);
        int maxi = 0;
        rep(i,n){
            cin>>vec[i];
            vec[i]/=w;
            maxi = max(maxi, vec[i]);
        }

        vector<int> hist(maxi+1, 0);
        rep(i,n){
            hist[vec[i]]++;
        }

        int maxv = 0;
        rep(i, maxi+1) maxv = max(maxv, hist[i]);

        if(maxi==0) maxi=1; // for zero divide
        double res=0.01;
        rep(i, maxi+1) res += (1.-1.*i/maxi)*1.*hist[i]/maxv;

        printf("%lf\n", res);
    }
    return 0;
}

Measured memory_bytes: 1216
read = input 
n = int(read())
A = {}
for i in range(1, n+1):
    s, p = read().split()
    p = int(p)
    if s not in A:
        A[s] = {}
    A[s][p] = i
A = list(A.items())
A.sort()
for s,d in A:
    B = list(d.items())
    B.sort(reverse=True)
    for p,i in B:
        print(i)

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

void prians(bool answer) {
  if(answer)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
string a, b, c;

int main() {
  cin >> a >> b >> c;
  prians(a[a.size() - 1] == b[0] &&
         b[b.size() - 1] == c[0]);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_poizcy.hpp>
typedef long long  ll;
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define mem(a,h)          memset(a, (h), sizeof(a))
#define fi first
#define se second
#define por(a,b) (((a%MOD) * (b%MOD))%MOD)
#define forg(i, b, e, c)    for (ll i = (ll)b; i < (ll)e; i+=c)
#define forr(i, b, e)    for (ll i = b; i < e; i++)
 
 
using namespace std;
//using namespace __gnu_pbds;
typedef double lldb;
typedef pair<ll, ll>  ii;
typedef pair<double, double>  iidb;
typedef pair<ll, ii>  iii;
typedef vector<ll>     vi;
typedef vector<vi>     vvi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
//typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const ll INF = 1e9+7;
const double PI = acos(-1);
const ll MOD= 1e9+7;
#define initseg ll new_nodo=(nodo*2),mid=(iz+der)/2;
 
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define tam 110000
#define offset 200
#define ptr nodo*
const ll inf=2e18;

int main()
{
	int x;
	cin>>x;
	x-=400;
	cout<<(8-x/200)<<endl;
	
}				

Measured memory_bytes: 3608
using Yorukatsu032.Questions;
using Yorukatsu032.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Yorukatsu032.Questions
{
    public class QuestionB : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var s = inputStream.ReadLine();

            var max = 0;
            for (int i = 1; i < s.Length / 2; i++)
            {
                var left = s.Substring(0, i);
                var right = s.Substring(i, i);

                if (left == right)
                {
                    max = i * 2;
                }
            }

            yield return max;
        }
    }
}


namespace Yorukatsu032
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionB();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace Yorukatsu032.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace Yorukatsu032.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 11220
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication51
{
    class Program
    {
        static void Main()
        {
            int a = 0;
            for(int b = 0; b < 4; b++)
            {
                a += int.Parse(Console.ReadLine());
            }
            Console.WriteLine(a/60);
            Console.WriteLine(a%60);
        }
    }
}

Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000000007;
struct edge {int to,costa,costb;};

signed main() {
int a,b,c,d;
cin>>a>>b>>c>>d;
if(b>d)cout<<1;
else cout<<0;



return 0;


}


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

int main(){
    int a, b;
    cin >> a >> b;
    int x = a + b;
    int y = a - b;
    int z = a*b;
    int max = x;
    if(y > max) max = y;
    if(z > max) max = z;
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 3616
/*
for i = 1 to A.length-1
    key = A[i]
    j = i - 1
    while j >= 0 and A[j] > key
        A[j+1] = A[j]
        j--
    A[j+1] = key
*/
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,i,j;
    cin>>n;
    vector<int> v(n);
    for(i=0;i<n;i++)
        cin>>v[i];
    for(j=0;j<v.size();j++){
        cout<<v[j]<<((j!=v.size()-1)?' ':'\n');
    }
    for(i=1;i<n;i++){
        int k=v[i];
        j=i-1;
        while(j>=0&&v[j]>k){
            v[j+1]=v[j];
            j--;
        }
        v[j+1]=k;
        for(j=0;j<v.size();j++){
            cout<<v[j]<<((j!=v.size()-1)?' ':'\n');
        }
    }
}


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

int main(){
  int n,a=32,b,cnt;
  cin >> n;
  while(n--){
  	cin>>b;
  	cnt=0;
  	while(b%2==0){
  		b/=2;
  		cnt++;
  	}
  	a=min(a,cnt);
  }
  cout <<a << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int main(){
    ll N, x; cin >> N >> x;
    vector<ll> a(N);
    for(int i=0; i<N; ++i) cin >> a[i];

    ll ans = 1LL<<59;

    vector<vector<ll>> b(2020, vector<ll>(2020, 0));
    for(int i=0; i<N; ++i) b[i][0] = a[i];

    for(int i=0; i<N; ++i){
        for(int j=1; j<N; ++j){
            b[i][j] = min(b[i][j-1], a[(i-j+N)%N]);
        }
    }

    for(int k=0; k<N; ++k){
        ll tmp = k*x;
        for(int i=0; i<N; ++i) tmp += b[i][k];
        chmin(ans, tmp);
    }

    cout << ans << endl;
}

Measured memory_bytes: 32256