akhauriyash/Code-Regression huggingface dataset:
import sys; input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
from collections import defaultdict
mod = 10 ** 9 + 7; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

def inverse(N, mod):
	return (pow(N, mod - 2, mod))

def main():
	N, X, M = getlist()
	if N <= 10 ** 6:
		cnt = 0
		A = X
		cnt += A
		for i in range(N - 1):
			A = (A ** 2) % M
			cnt += A

		print(cnt)
		return

	A = X
	D = defaultdict(int)
	L = [0] * (2 * 10 ** 5)
	L[1] = A
	D[A] = 1

	for i in range(2, N + 2):
		A = (A ** 2) % M
		if D[A] != 0:
			start = D[A]
			loop = i - D[A]
			break
		D[A] = i
		L[i] = A

	ans = 0
	for i in range(start, start + loop):
		ans += L[i]

	p = int((N - start + 1) // loop)
	ans *= p

	for i in range(1, start):
		ans += L[i]

	q = N - loop * p - start + 1
	for i in range(start, start + q):
		ans += L[i]

	print(ans)


if __name__ == '__main__':
	main()

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

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "]"; return os; }


int main(){
    LL n, m;
    cin >> n >> m;
    vector<LL> a(n);
    for(LL i = 0; i < n; ++i){
        cin >> a[i];
    }
    vector<pair<LL,LL>> cmd(m);
    for(LL i = 0; i < m; ++i){
        cin >> cmd[i].second >> cmd[i].first;
    }
    sort(cmd.begin(), cmd.end(), greater<pair<LL,LL>>());
    vector<LL> b;
    for(auto p: cmd){
        for(LL i = 0; i < p.second; ++i){
            if(b.size() >= n) break;
            b.push_back(p.first);
        }
    }
    sort(a.begin(), a.end());

    LL ans = 0;
    for(LL i = 0; i < n; ++i){
        if(i < b.size()){
            ans += max<LL>(a[i], b[i]);
        }else{
            ans += a[i];
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3704
#include <iostream>
#include <vector>
#include <algorithm>
#include <bitset>


using namespace std;

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

int main(){
    ll N,K;
    cin >> N >> K;
    vector<ll> A(N);
    vector<int> cnt(41,0);
    ll bi=1,ans=0,now=0;
    for(int i=0; i<N; i++){
        cin >> A[i];
        bitset<41> b(A[i]);
        for(int i=0; i<41; i++){
            cnt[i]+=b[i];
        }
    }
    for(int i=0; i<40; i++) bi*=2;

    reverse(cnt.begin(),cnt.end());
    for(int i=0; i<41; i++){
        if(cnt[i]*2>=N){ // 0にする
            ans+=bi*cnt[i];
        }else{
            if(bi+now>K){
                ans+=bi*cnt[i];
            }else{
                ans+=(N-cnt[i])*bi;
                now+=bi;
            }
        }
        bi/=2;
    }

    cout << ans << endl;



    return 0;
}

Measured memory_bytes: 4056
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし


N = I()
X = LI2()
X.reverse()

if N == 0:
    print(1)
    exit()

A = [0]*(2*10**5+1)  # Ai = f(i)
for i in range(1,2*10**5+1):
    k = 0
    for j in range(18):
        if (i >> j) & 1:
            k += 1
    A[i] = A[i % k] + 1


r = sum(X)  # Xの各桁の和

if r >= 2:
    B = [1] + [0]*(N-1)  # Bi = 2**i mod (r-1)
    C = [1] + [0]*(N-1)  # Ci = 2**i mod (r+1)
    b,c = X[0],X[0]  # b,c = X mod (r-1),X mod (r+1)
    for i in range(1,N):
        B[i] = (B[i-1]*2) % (r-1)
        C[i] = (C[i-1]*2) % (r+1)
        if X[i] == 1:
            b += B[i]
            b %= r-1
            c += C[i]
            c %= r+1

    for i in range(N-1,-1,-1):
        if X[i] == 0:
            print(1+A[(c+C[i]) % (r+1)])
        else:
            print(1+A[(b-B[i]) % (r-1)])

else:
    C = [1] + [0]*(N-1)  # Ci = 2**i mod (r+1)
    c = X[0]  # c = X mod (r+1)
    for i in range(1,N):
        C[i] = (C[i-1]*2) % (r+1)
        if X[i] == 1:
            c += C[i]
            c %= r+1

    for i in range(N-1,-1,-1):
        if X[i] == 0:
            print(1+A[(c+C[i]) % (r+1)])
        else:
            print(0)


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

int main() {
	int s_size, first, last;
	int rev;
	string s;
	first = -1;
	last = -1;

	cin >> s;
	s_size = s.size();
	rev = s_size;
	for (int i = 0; i < s_size; i++) {
		if (s[i] == 'A' && first == -1) {
			first = i;
		}
		if (s[rev] == 'Z' && last == -1) {
			last = rev;
		}
		rev--;
	}
	cout << last - first + 1 << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define REP(i,a,b) for(int i=int(a);i<(int)b;++i)
#define Graph vector<vecctor<ll>>
#define pairs vector<pair<ll,ll>>
#define pb push_back



using namespace std;
using ll = long long;
const ll INF = 1e18;
const double PI = acos(-1);

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;
}



int main(void)
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll>a(n);
    rep(i,n){
        cin >> a[i];
    }
    ll t = 1;
    vector<ll>ind;
    rep(i,a.size()){
        if(a[i] == t){
            ++t;
            ind.pb(i);
        }
    }
    if(t == 1){
        cout << -1 << endl;
        return 0;
    }
    cout << n-ind.size() << endl;
    return 0;

}


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

struct Data{
  int num,id;
  char ch;
};

int Partition(Data A[],int p,int r){
  Data x = A[r];
  int i=p-1;
  for(int j=p;j<r;j++){
    if(A[j].num<=x.num){
      i++;
      swap(A[i],A[j]);
    }
  }
  swap(A[i+1],A[r]);
  return i+1;
}

void Quicksort(Data A[],int p,int r){
  if(p<r){
    int q = Partition(A,p,r);
    Quicksort(A,p,q-1);
    Quicksort(A,q+1,r);
  }
}

void check(Data A[],int n){
  for(int i=1;i<n;i++){
    if(A[i-1].num<A[i].num)continue;
    if(A[i-1].id<A[i].id)continue;
    cout<<"Not stable"<<endl;
    return;
  }
  cout<<"Stable"<<endl;
}

int main(){
  int n;
  Data A[100000];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>A[i].ch>>A[i].num;
    A[i].id=i;
  }
  
  Quicksort(A,0,n-1);
  check(A,n); 
  for(int i=0;i<n;i++){
    cout<<A[i].ch<<' '<<A[i].num<<endl;
  }
  
  return 0;
}


Measured memory_bytes: 4160
#include<bits/stdc++.h>
#define MSET(x,y) memset(x,y,sizeof(x))
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ size()
#define M 100005
#define ll long long
#define ld long double
#define INF 1e18
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
ll MOD = 1000000007;
string yes = "YES\n";
string no = "NO\n";
#define PI 3.1415926535 

int32_t main() {
  ll n;
  cin>>n;

  vector<ld> a(n);
  for(ll i=0;i<n;i++) {
    cin>>a[i];
  }

  ld ans = 1;

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

  for(auto itr : a) {
    ans *= itr;
    if(ans > (ll)INF) {
      cout<<-1<<endl;
      return 0;
    }
  }

  cout<<(ll)ans<<endl;
}


Measured memory_bytes: 4820
#include <iostream>

using namespace std;

int main()
{
    int N,h[25],i,m,sum=1;
    cin>>N;
    for(i=0; i<N; i++)
        cin>>h[i];
    m=h[0];
    for(i=1; i<N; i++)
    {
        if(h[i]>=m)
        {
            m=h[i];
            sum++;
        }
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
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;
}
 
using namespace std;

//ここから
void solve(){
  ll x,y;
  cin>>x>>y;
  if(abs(x-y)>1)cout<<"Alice";
  else cout<<"Brown";
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
#include<math.h>
#include<bitset>
using namespace std;

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

/*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*/



int main()
{
	int a, b;
	cin >> a >> b;
	cout << a * b << " " << 2 * (a + b) << endl;

	return 0;
}



Measured memory_bytes: 3080
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>
#include <iterator>

using namespace std;

long long int cost[30000];
long long int min_size[30000];
long long int max_size[30000];


long long int const LL_MAX = 10000000000000000; // 10^16

int main(){
	
	int N, M, K;
	cin >> N >> M >> K;
	
	for(int i = 0; i < 30000; i++){
		max_size[i] = 0;
		min_size[i] = LL_MAX;
		cost[i] = LL_MAX;
	}
	
	min_size[0] = 0;
	cost[0] = 0;
	cost[1] = 0;
	
	for(int i = 1; i <= N + 1; i++){
		for(int j = max(1, i - M); j < i; j++){
			cost[i] = min(cost[i], cost[j] + K + (i - j) * (max_size[j] - min_size[j]));
		}
		if(i == N + 1){
			break;
		}
		long long int num;
		cin >> num;
		for(int j = max(0, i - M) + 1; j <= i; j++){
			max_size[j] = max(max_size[j], num);
			min_size[j] = min(min_size[j], num);
		}
	}
	
	cout << cost[N + 1] << endl;
	
	return 0;
}

Measured memory_bytes: 3780
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main()
{
  long long N;
  scanf("%lld", &N);
  std::vector<std::string> S(N);
  set<string> st;
  for (int i = 0; i < N; i++)
  {
    std::cin >> S[i];
    st.insert(S[i]);
  }
  cout << st.size() << endl;

  return 0;
}


Measured memory_bytes: 20080
#include <bits/stdc++.h>
#define X first
#define Y second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define ini(x, y) memset(x, y, sizeof(x))
#define endl '\n'
#define fastio cin.sync_with_stdio(false); cin.tie(nullptr)
using namespace std;

using ll = long long;
using pii = pair<int, int>;
const int dx[] = { -1, 0, 1, 0, -1, 1, 1, -1 };
const int dy[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

vector<int> adj[1000];
int wif[1000];

int main() {
	fastio; ini(wif, -1);
	int N, M;
	cin >> N >> M;

	for (int a, b, i = 0; i < M; ++i) {
		cin >> a >> b;
		adj[--a].push_back(--b);
	}

	vector<int> ans;
	for (int i = 0; i < N; ++i) {
		queue<int> Q;
		for (int nxt : adj[i]) {
			Q.push(nxt);
			wif[nxt] = i * 1000 + i;
		}

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

			if (now == i) {
				vector<int> tmp = { i };
				for (int j = wif[i] - i * 1000; j != i; j = wif[j] - i * 1000) tmp.push_back(j);

				if (ans.empty() || sz(ans) > sz(tmp)) ans = tmp;
				break;
			}

			for (int nxt : adj[now]) if (wif[nxt] < i * 1000) {
				wif[nxt] = i * 1000 + now;
				Q.push(nxt);
			}
		}
	}

	if (ans.empty()) return cout << -1, 0;

	cout << sz(ans) << endl;
	for (int i : ans) cout << i + 1 << endl;

	return 0;
}

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


int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    rep(i,n)cin >> s.at(i);
    map<string,int>kazu;
    int saidai=0;
    for(string a:s){
        kazu[a]++;
        saidai=max(saidai,kazu[a]);
    }
    
    for(auto a:kazu){
        if(a.second==saidai){
        cout<<a.first<<endl;
        }
    }
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

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

using namespace std;

const int N = 18;
int ans[1 << N];
int gray[1 << N];
int h[1 << N];

void swapBit(int u, int v, int L, int R) {
    int mask = (1 << u) ^ (1 << v);
    for(int i = L; i < R; i++){
        int s1 = (ans[i] >> u) & 1;
        int s2 = (ans[i] >> v) & 1;
        if (s1 != s2) ans[i] ^= mask;
    }
}
void build(int depth, int L, int R, int st, int en) {
    //cout << depth << " " << L << " " << R << " " << st << " " << en << '\n';
    assert(st < (1 << depth));
    assert(en < (1 << depth));
    int nen = en ^ st;

    vector<int> diff;
    for(int i = 0; i < depth; i++) if ((nen >> i) & 1) 
        diff.push_back(i);
    int ndiff = diff.size();

    if (ndiff == 1) {
        for(int i = L; i < R; i++) ans[i] = gray[i - L];
        swapBit(diff[0], depth - 1, L, R);
        for(int i = L; i < R; i++) ans[i] ^= st;
        return;
    }
    int half2 = nen ^ (1 << diff[ndiff - 1]);
    int half1 = half2 ^ (1 << diff[ndiff - 2]);

    int mid = (L + R) / 2;
    build(depth - 1, L, mid, 0, half1); 
    build(depth - 1, mid, R, half1, half2);
    for(int i = mid; i < R; i++)
        ans[i] ^= 1 << (depth - 1);
    swapBit(diff.back(), depth - 1, L, R);
    for(int i = L; i < R; i++) ans[i] ^= st;
}
int main() {
    gray[1] = 1;
    for(int i = 1; i < N; i++) 
        for(int j = 0; j < (1 << i); j++) 
            gray[(1 << i) + j] = gray[(1 << i) - j - 1] ^ (1 << i);
    int n, st, en;
    cin >> n >> st >> en;
    if (__builtin_popcount(st ^ en) % 2 == 0) {
        cout << "NO";
        exit(0);
    }
    cout << "YES\n";
    build(n, 0, (1 << n), st, en);
    for(int i = 0; i < (1 << n); i++) cout << ans[i] << " ";
    for(int i = 0; i < (1 << n); i++) h[ans[i]]++;
    assert(count(h, h + (1 << n), 1) == (1 << n));
    assert(ans[(1 << n) - 1] == en);
    assert(ans[0] == st);
    for(int i = 1; i < (1 << n); i++) assert(__builtin_popcount(ans[i] ^ ans[i - 1]) == 1);
}


Measured memory_bytes: 3072
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    //nextLineとnextを同時に使ったら死ぬ
    val sc = new Scanner(System.in)
    val s, w = sc.nextInt()

    if (s <= w) {
      println("unsafe")
    } else {
      println("safe")
    }
    Console.err.println("Is it WA?")
  }
}


Measured memory_bytes: 55268
module Main where

import Control.Applicative

getInt :: IO Int
getInt = head <$> getInts

getInts :: IO [Int]
getInts = map read . words <$> getLine 

main :: IO ()
main = do
  { [a, b, c] <- getInts
  ; if a < b && b < c then putStrLn "Yes"
    else putStrLn "No"
  }



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

int main() {
  int a; string s;
  cin >> a >> s;
  if (a >= 3200) cout << s << endl;
  else cout << "red" << endl;
}

Measured memory_bytes: 256
use std::cmp::max;
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let s: String = read();

    let mut count = 0;
    let mut ans = 0;

    for c in s.chars() {
        count = match c {
            'A' | 'C' | 'G' | 'T' => count + 1,
            _ => 0,
        };
        ans = max(ans, count);
    }

    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


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

int main()
{
    int rooms[5][4][11];

    for (int i = 1; i < 5; i++) {
        for (int j = 1; j < 4; j++) {
            for (int k = 1; k < 11; k++){
                rooms[i][j][k] = 0;
            }
        }
    }

    int n;
    cin >> n;
    for (int x = 0; x < n; x++) {
        int  b, f, r, v;
        cin >> b >> f >> r >> v;

        rooms[b][f][r] += v;
    }

    for (int a = 1; a < 4; a++) {
        for (int b = 1; b < 4; b++) {
            for (int c = 1; c < 11; c++) {
                cout << " " << rooms[a][b][c];
            }
            cout << '\n';
        }
        cout << "####################\n";
    }
    for (int b = 1; b < 4; b++) {
        for (int c = 1; c < 11; c++) {
            cout << " " << rooms[4][b][c];
        }
        cout << "\n";
    }
}


Measured memory_bytes: 3088
def actual(n):
    digit1 = int(n[-1])

    if digit1 in {2, 4, 5, 7, 9}:
        return 'hon'

    if digit1 in {0, 1, 6, 8}:
        return 'pon'

    return 'bon'

n = input()

print(actual(n))

Measured memory_bytes: 9112
S = input()

if len(S) != 26:
    chars = set()
    for s in S:
        chars.add(s)
    for c in range(ord('a'), ord('a') + 26):
        if chr(c) not in chars:
            print(S + chr(c))
            exit(0)

# len(S) == 26:
ans = S[0:25]
S = [ord(s) for s in S]
prev = [S[25]]
for i in range(24, -1, -1):
    res = 10000
    for p in prev:
        if S[i] < p:
            res = min(res, p)
    if res == 10000:
        prev.append(S[i])
    else:
        print(ans[0:i] + chr(res))
        exit(0)

print(-1)


Measured memory_bytes: 38256
from functools import lru_cache

import sys
sys.setrecursionlimit(10 ** 7)

N = int(input())
h = list(map(int, input().split()))

memo = [None] * N
memo[0] = 0
memo[1] = abs(h[1]-h[0])

def rec(n):
  if memo[n] == None:
    memo[n] = min(rec(n-1)+abs(h[n]-h[n-1]), rec(n-2)+abs(h[n]-h[n-2]))
  return memo[n]

rec(N-1)
print(memo[N-1])
"""
@lru_cache(maxsize=None)
def rec(n):
  # print(n)
  if n == 1:
    return 0
  elif n == 2:
    return abs(h[1]-h[0])
  else:
    return min(rec(n-1)+abs(h[n-1]-h[n-2]), rec(n-2)+abs(h[n-1]-h[n-3]))
"""

# print(rec(N))

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string num;
  cin >> num;
  cout << "ABC" << string(3, '0').substr(0, 3 - num.size()) << num << endl;
  return 0;
}


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

int main() {
    int x, y;
    for(int i = 0; i < 3000; i++) {
        cin >> x >> y;
        if(x == 0 && y == 0) break;
        int m = min(x, y);
        int M = max(x, y);
        cout << m << ' ' << M << endl;
    }
}


Measured memory_bytes: 2992
#include <iostream>
using namespace std;
int main(void){
    long long n,y,i,j,k;
    cin >> n >> y;
    for(i=0;i<=n;i++){
        for(j=0;j<=n-i;j++){
            k = n-i-j;
            if(i*10000+j*5000+k*1000==y){
                cout << i << " " << j << " " << k;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1";
    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}
ll gcd(ll(a), ll(b)) {
	ll c = a;
	while (a % b != 0) {
		c = a % b;
		a = b;
		b = c;
	}
	return b;
}



int main() {
	ll H, W;
	cin >> H >> W;
	vector<string> S(H);
	rep(i, H) {
		cin >> S.at(i);
	}
	rep(i, W + 2) {
		cout << '#';
	}
	cout << endl;
	rep(j, H) {
		cout << '#';
		
		cout << S.at(j);
		cout << '#';
		cout << endl;
	}
	rep(i, W + 2) {
		cout << '#';
	}
	cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>

template <class T>
inline void read(T &x) {
    x = 0;
    int f = 0;
    char ch = getchar();
    while (!isdigit(ch))    { f |= ch == '-'; ch = getchar(); }
    while (isdigit(ch))     { x = (x << 1) + (x << 3) + (ch ^ 48); ch = getchar(); }
    x = f ? -x : x;
    return;
}

long long a[1000010];
long long n, k;

int main() {
    read(k), read(n);
    for (int i = 1; i <= n; ++i)    read(a[i]);
    a[n + 1] = k;
    k = std::min(k, a[n] - a[1]);
    for (int i = 2; i <= n; ++i) {
        k = std::min(k, a[i] - a[0] + a[n + 1] - a[i + 1]);
    }
    printf("%lld\n", k);
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
vector<int>par;
vector<int>siz;
int root(int v) {
  if (v == par[v]) return v;
  return par[v] = root(par[v]);
}
void merge(int a, int b) {
  a = root(a);
  b = root(b);
  if (a == b) return;
  par[b] = a;
  siz[a] += siz[b];
}
int main () {
  int N, M;
  cin >> N >> M;
  par.resize(N + 1);
  for (int i = 0; i <= N; i ++) par[i] = i;
  siz.assign(N + 1, 1);
  for (int i = 0; i < M; i ++) {
    int a, b;
    cin >> a >> b;
    merge(a, b);
    //cout << root(b) << endl;
  }
  int ans = 0;
  for (int i = 1; i <= N; i ++) {
    ans = max(ans, siz[root(i)]);
  }
  cout << ans << endl;
}


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

int N, M;

signed main(){
  
  while(1){
  
    cin>>N>>M;
    if( !N && !M ) break;
    
    int maxv[105] = {};
    
    for(int i=0;i<N;i++){
      int d, v;
      cin>>d>>v;
      maxv[d] = max( maxv[d], v );
    }
    
    int ans = 0;
    
    for(int i=1;i<=M;i++) ans += maxv[i];
    
    cout<<ans<<endl;
    
  }
  
  return 0;
}



Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

struct edge{
	int to,cap,rev;
	edge(){}
	edge(int tt,int cc,int rr){
		to=tt;
		cap=cc;
		rev=rr;
	}
};

vector<edge> G[501];
int level[501];
int iter[501];

void add_edge(int from,int to,int cap){
	G[from].push_back(edge(to,cap,G[to].size()));
	G[to].push_back(edge(from,0,G[from].size()-1));
}

void bfs(int s){
	memset(level,-1,sizeof(level));
	queue<int> que;
	level[s]=0;
	que.push(s);
	while(que.size()){
		int v=que.front();
		que.pop();
		for(int i=0;i<G[v].size();i++){
			edge &e=G[v][i];
			if(e.cap>0 && level[e.to]<0){
				level[e.to]=level[v]+1;
				que.push(e.to);
			}
		}
	}
}

int dfs(int v,int t,int f){
	if(v==t)return f;
	for(int &i=iter[v];i<G[v].size();i++){
		edge &e=G[v][i];
		if(e.cap>0 && level[v]<level[e.to]){
			int d=dfs(e.to,t,min(f,e.cap));
			if(d>0){
				e.cap-=d;			
				G[e.to][e.rev].cap+=d;
				return d;
			}
		}
	}
	return 0;
}

int max_flow(int s,int t){
	int flow=0;
	while(1){
		bfs(s);
		if(level[t]<0)return flow;
		memset(iter,0,sizeof(iter));
		int f;
		while((f=dfs(s,t,1000))>0){
			flow+=f;
		}
	}
}

int n;
int x[101];
int a[10000001];
int b[10000001];

int prime(int x){
	if(x<=2)return 3;
	bool flag=true;
	for(int i=2;i*i<=x;i++){
		if(x%i==0)return 3;
	}
	return 1;
}

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&x[i]);
		a[x[i]]=1;
	}
	vector<int> colt[2];
	for(int i=1;i<=x[n-1]+1;i++){
		b[i]=a[i-1]^a[i];
		if(b[i]==1){
			colt[i%2].push_back(i);
		}
	}
	int s=colt[0].size()+colt[1].size();
	int t=s+1;
	for(int i=0;i<colt[0].size();i++){
		for(int j=0;j<colt[1].size();j++){
			int val=prime(abs(colt[0][i]-colt[1][j]));
			if(val==1)add_edge(i,colt[0].size()+j,val);
		}
	}
	for(int i=0;i<colt[0].size();i++){
		add_edge(s,i,1);
	}
	for(int i=0;i<colt[1].size();i++){
		add_edge(colt[0].size()+i,t,1);
	}
	int cnt=max_flow(s,t);
	int res=0;
	res+=((int)colt[0].size()-cnt)/2*2;
	res+=((int)colt[1].size()-cnt)/2*2;
	res+=(((int)colt[0].size()-cnt)%2)*3;
	res+=cnt;
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 78208
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
#define deb(x) cout << #x": " << (x) << endl;

const int N = 1e3;
const lli INF = 1e18;
const lli MOD = 1e9+7;

vi m;
vi primes(1,2);
vector<vector<ld>>nk;
void sieve(){
	m = vi(N+1,0);
	for(int i = 4; i<N; i+=2)m[i]=1;
	for(int i = 3; i*i<=N; i+=2)if(!m[i])for(int j = i*i; j<N; j+=i)m[j]=1;
	for(int i = 3; i<N; i+=2)if(!m[i])primes.pb(i);
}

void pascal(){
	nk =vector<vector<ld>>(N,vector<ld>(N,0.0));
	fore(i,0,N)nk[i][0]=nk[i][i]=1.0;
	fore(i,1,N)fore(j,1,i)nk[i][j]=nk[i-1][j-1]+nk[i-1][j];
}

lli gcd(lli a, lli b){return (b?gcd(b,a%b):a);}

lli lcm(lli a, lli b){
	if(a<b)swap(a,b);
	lli c = gcd(a,b);
	a/=c;
	return a*b;
}

int popcount(lli x) { return __builtin_popcountll(x); }

lli poww(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = res * a;
		a = a*a;
		b/=2;
	}
	return res;
}

lli powm(lli a, lli b, lli mod = MOD){
	lli res =1;
	while(b){
		if(b&1) res = (res * a)%mod;
		a = (a*a)%mod;
		b/=2;
	}
	return res;
}

bool isPrime(lli x){
	if(x==1)return 0;
	for(auto i:primes){
		if(i*i>x)return 1;
		if(x%i==0)return 0;
	}
	return 1;
}

// ---- コーディングはここから！ ('-')7


int main(){_
	int n,r=0,o=0; cin>>n;
	string s;cin>>s;
	fore(i,0,n)if(s[i]=='R')r++;
	fore(i,0,r)if(s[i]=='W')o++;
	cout<<o<<ENDL;

}


Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1000000007;

//j-i=a[j]+a[i]
//j-a[j]=i+a[i]
int main(){
  ll n;
  cin >> n;
  vector<ll>wa(200000),sa(200000);
  for(int i=0; i<n; i++){
    ll a;
    cin >> a;
    if(a+i+1<200000) wa[a+i+1]++;
    if(i+1-a>=0) sa[i+1-a]++;
  }
  ll ans=0;
  for(ll i=1; i<200000; i++){
    ans+=wa[i]*sa[i];
  }
  
  cout << ans << endl;
  
}
  


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

using namespace std;

const int N = (int)1e5 + 5;

int n, h[N];

void init() {
  cin >> n;
  for(int i = 1 ; i <= n ; ++i) cin >> h[i];
}
void solve() {
  int now = 1, ans = 1;
  for(int i = 2 ; i <= n ; ++i) {
    if(h[i - 1] >= h[i]) now++;
    else {
      ans = max(ans, now);
      now = 1;
    }
  }
  ans = max(ans, now);
  cout << ans - 1 << '\n';
}

int main() {
  init();
  solve();
}


Measured memory_bytes: 640
#include<stdio.h>

  int parent(int i){return i/2;}
  int left(int i){return 2*i;}
  int right(int i){return 2*i+1;}

int main(){
  int H,i,A[1000000];
  scanf("%d",&H);
  for(i=1;i<=H;i++)scanf("%d",&A[i]);
  for(i=1;i<=H;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(parent(i) >=1)printf("parent key = %d, ",A[parent(i)]);
    if(left(i) <=H)printf("left key = %d, ",A[left(i)]);
    if(right(i) <=H)printf("right key = %d, ",A[right(i)]);
    printf("\n");
  }
}



Measured memory_bytes: 2708
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;

public class Main {
    public static void main(String args[]){
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try{
            String line;
            while((line=br.readLine())!=null){  if(line.equals(""))break;
                String[] splited = line.split(",");
                
                int[] ints = new int[10];
                for(int i=0; i<10;i++)ints[i]=Integer.parseInt(splited[i]);
                
               int v1 = Integer.parseInt(splited[10]), v2 = Integer.parseInt(splited[11]);
               int sumL = 0; for(int i=0;i<10;i++)sumL+=ints[i];
               double t = (sumL+0.0)/(v1+v2); double x = t*v1;
               int ans=0, sumTmp=0;//System.out.println("sL"+sumL+"t"+t+""+x+"x");
               for(int i=0; i<10;i++){
                   sumTmp+=ints[i];if(sumTmp>=x){ans=i+1;break;}
               }
                System.out.println(ans);
            }         
        }catch(Exception e){e.printStackTrace();}
        
    }
    
}

Measured memory_bytes: 17068
#include <iostream>
#include <cmath>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <cstring>

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define pii pair < int, int >
#define pll pair < long long, long long>
#define ull unsigned long long
#define vi vector < int >
#define vll vector < long long >
#define sz(a) (int)a.size()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x))
#define fname "searching"

const int inf = (int)1e9;
const ll INF = (ll)1e18;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int mod = (int)1e9 + 7;

int n, a[100100];
ll ans[2];

ll solve(){
    cin >> n;
    for(int i = 0; i < n; ++i){
        cin >> a[i];
    }
    for(int k = 0; k < 2; ++k){
        ll sum = 0;
        for(int i = 0, j = -1 + 2 * k; i < n; ++i, j *= -1){
            sum += a[i];
            if(sum * j > 0) continue;
            if(j == -1){
                if(sum >= 0){
                    ans[k] += sum + 1;
                    sum = -1;
                }
            }else{
                if(sum <= 0){
                    ans[k] += 1 - sum;
                    sum = 1;
                }
            }
        }
    }
    return min(ans[0], ans[1]);
}

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

    cout << solve() << "\n";
    
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <math.h>
#include <algorithm>
#include <set>
#include <map>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
#define rep_r(i,s,n)for(ll i=n-1;i>=s;i--)
#define repe_r(i,s,n)for(ll i=s;i<=n;i++)
static const ll MOD = 1e9 + 7;
static const ll MAX_L = (ll)1 << 62;

ll h[100001] = {};
ll k[100001] = {};

ll n, a, b;
bool holocost(ll t) {
	rep(i, 0, n) {
		k[i] = h[i];
	}
	rep(i, 0, n) k[i] -= b * t;
	ll cnt = 0;
	rep(i, 0, n) {
		if (h[i] > 0) {
			ll d = a - b;
			cnt += k[i] / d;
			if (k[i] % d != 0)cnt++;
		}
	}
	return cnt <= t;
}
//cnt += k[i] / (a - b);
//if (k[i] % (a - b) != 0)cnt++;
bool condition(ll x) {
	rep(i, 0, n) {
		k[i] = h[i];
	}
	rep(i, 0, n) k[i] -= x * b;
	ll cnt = 0;
	rep(i, 0, n) {
		if (k[i] > 0) {
			ll d = a - b;
			cnt += k[i] / d;
			if (k[i] % d != 0)cnt++;
		}
	}
	return cnt <= x;
}

int main() {
	cin >> n >> a >> b;
	rep(i, 0, n) cin >> h[i];

	ll l = -1;
	ll r = (ll)1 << 30;
	ll m;
	while (r - l > 1) {
		m = (l + r) / 2;
		if (condition(m)) {
			//if (holocost(m)) {
			r = m;
		}
		else {
			l = m;
		}
	}
	cout << r << endl;

	return 0;
}

Measured memory_bytes: 1792
import io, sys, atexit, os

import math as ma
from sys import exit
from decimal import Decimal as dec
from itertools import permutations


def li ():
	return list (map (int, input ().split ()))


def num ():
	return map (int, input ().split ())


def nu ():
	return int (input ())


def find_gcd ( x, y ):
	while (y):
		x, y = y, x % y
	return x


mm = 1000000007



def solve ():
	t = 1
	for it in range (t):
		b=input()
		if(b=="A"):
			print("T")
		if(b=="T"):
			print("A")
		if(b=="C"):
			print("G")
		if(b=="G"):
			print("C")





if __name__ == "__main__":
	solve ()

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

int main(){
    string a,b; cin >> a >> b;
    string c=a+b;
    int num=atoi(c.c_str());
    
    int i=1;
    while(1){
        if(i*i==num){
            cout << "Yes";
            return 0;
        }else{
            if(i*i>num){
                cout << "No";
                return 0;
            }
        }
        i++;
    }
}

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

using namespace std;

int dp[20][20];
bool cross[20][20];
int a, b;

int solve(int x, int y)
{
  if(x < 0 || a <= x || y < 0 || b <= y) return 0;
  if(cross[x][y]) return 0;
  if(x == a-1 && y == b-1) return 1;
  if(~dp[x][y]) return dp[x][y];
  return dp[x][y] = solve(x + 1, y) + solve(x, y + 1);
}

int main()
{
  while(cin >> a >> b, a || b){
    memset(dp, -1, sizeof(dp));
    memset(cross, false, sizeof(cross));
    int n; cin >> n;
    for(int i = 0; i < n; i++){
      int x, y; cin >> x >> y;
      cross[--x][--y] = true;
    }
    cout << solve(0, 0) << endl;
  }
  return 0;
}

Measured memory_bytes: 1156
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#define cs ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define rep(i,b)  for(int i=0;i<(int)(b);i++)
#define Rep(i,n) for(int i=1;i<(int)(n);i++)
#define repp(i,a,b)  for(int i=a;i<=(int)(b);i++)
#define Repp(i,a,b)  for(int i=a;i>=(int)(b);i--)
typedef long long ll;
typedef long double ld;

using namespace std;

int main(){
    cs
    string s;cin>>s;
    rep(i,3) if(s[i]==s[i+1]) {cout<<"Bad";return 0;}
    cout<<"Good";
}

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

int main() {
  int N;
  cin>>N;
  vector<int>B(N-1);
  for(int i=0;i<N-1;i++){
    cin>>B.at(i);
  }
  int ans;
  ans=0;
  ans+=B.at(0);
    for(int i=0;i<N-2;i++){
      ans+=min(B.at(i),B.at(i+1));
    }
  ans+=B.at(N-2);
  cout<<ans<<endl;
  
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    A=LI()
    A.sort(reverse=True)
    cnt=[2]*N
    cnt[0]-=1
    now=0
    ans=0
    for i in range(N-1):
        if cnt[now]!=0:
            ans+=A[now]
            cnt[now]-=1
        else:
            now+=1
            ans+=A[now]
            cnt[now]-=1
    print(ans)
            

main()


Measured memory_bytes: 91972
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int K,X;
    cin >> K >> X;
    if (500 * K >= X) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env php
<?php

function genInputs() {
    while(($input = rtrim(fgets(STDIN))) !== false) {
        foreach (explode(' ', $input) as $v) {
            yield $v;
        }
    }
}
function getNext($gen) {
    $value = $gen->current();
    $gen->next();
    return $value;
}
$gen = genInputs();

$N = (int)getNext($gen);
$K = (int)getNext($gen);

$q = 0;
while (pow(2, $q) < $K) { $q++; }
$per = pow(2, $q);
$sum = 1;

$p = 0;
for ($i = $N; $i > 1; $i--) {
    while ($i * pow(2, $p) < $K) { $p++; }
    $sum += pow(2, $q - $p);
}

echo ($sum / $per / $N).PHP_EOL;

Measured memory_bytes: 4604
#include<bits/stdc++.h>
using namespace std;
#define N 100010
#define pb push_back
#define int long long
#define pi pair<int , int>
#define mp make_pair
vector<int> edges[N];
bool visited[N];
bool arr[N];
int dp[N];
int parent[N];
int find(int x){
 if(parent[x] == -1){
 return x;
 }
 return find(parent[x]);
}
int n ,m;
void dfs(int st , int par){
	visited[st] = true;
  for(auto it:edges[st]){
      if(!visited[it]){
	    dfs(it , st);
	}
	     dp[st] = max(dp[st] , 1 + dp[it]);
  }
}
int32_t main(){
	cin>>n>>m;
	for(int i = 0 ; i < m;i++){
	   int x , y;
	   cin>>x>>y;
	   edges[--x].pb(--y);
	}
	memset(dp , 0 , sizeof(dp));
	memset(visited , false , sizeof(visited));
	for(int i = 0 ;i < n ;i++){
	   if(!visited[i]){
	     dfs(i , i);
	   }
	}
	int maxi = -1;
	for(int i =0; i < n; i++){
	    maxi = max(maxi , dp[i]);
	}
	cout<<maxi<<endl;
	
}


Measured memory_bytes: 8704
import sys
import math
from collections import Counter
#from functools import reduce

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")



N=II()
A=LI()
c=Counter(A)

for i in range(1,N+1):
  print(c[i])

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


int main() {
  int n,m;
  cin >> n>>m;
  
    cout<<n*m<<endl;
  
  
  
}







Measured memory_bytes: 3624
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String N = in.readLine();

		int x = Integer.parseInt(N);
		double sum = 0;
		N = in.readLine();
		String[] X = N.split(" ");
		int[] V = new int[x];
		for(int i=0;i<x;i++){
			V[i] = Integer.parseInt(X[i]);
		}

		Arrays.sort(V);
		double ans = (V[0]+V[1])/2.0;
		for(int i=2;i<V.length;i++){
			ans = (ans+V[i])/2.0;
		}
		System.out.println(ans);

	}




}


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

int main() {
  int a,b;
  cin>>a>>b;
  int ans=0;
  for(int i=a;i<=b;i++){
    string s=to_string(i);
    string t=s;
    reverse(t.begin(),t.end());
    if(s==t) ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
S = input()

flag = False
if S[0] == "A":
    flag = True
    S = S.replace("A", "a", 1)

count = 0
for i in range(2, len(S) - 1):
    if S[i] == "C":
        count += 1
        S = S.replace("C", "c", 1)
if count != 1:
    flag = False

if not S.islower():
    flag = False

print("AC" if flag else "WA")


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

int main() {
  
  int N;
  cin >> N;
  int P = 0;
  int G = 0;
  int W = 0;
  int Y = 0;
  
  for (int i = 0; i < N; i++){
    
    string S;
    cin >> S;
    
    if (S == "P"){
      P = P  + 1;
    }
    else if (S == "G"){
      G = G + 1;
    }
    else if (S == "W"){
      W = W + 1;
    }
    else if (S == "Y"){
      Y = Y + 1;
    }
    
  }
  
  if (P > 0 && W >0){
    if (Y > 0 && G > 0){
		cout << "Four" << endl;
    }
    else{
	cout << "Three" << endl;
    }
  }
  else{
	cout << "Three" << endl;
  }
  
  

 }

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll h, w;
    cin >> h >> w;
    vector<string> a(h);
    rep(i, h) cin >> a[i];
    map<char, ll> cnt;
    rep(i, h) rep(j, w) cnt[a[i][j]]++;
    string s = "";
    rep(i, w) s += "*";
    vector<string> cur(h);
    rep(i, h) cur[i] = s;
    priority_queue<ll> pq;
    rep(i, h) {
        rep(j, w) {
            ll cnt = 0;
            if (cur[i][j] != '*') continue;
            cur[i][j] = 'S';
            cnt++;
            if (cur[h - 1 - i][j] == '*') {
                cur[h - 1 - i][j] = 'S';
                cnt++;
            }
            if (cur[h - 1 - i][w - 1 - j] == '*') {
                cur[h - 1 - i][w - 1 - j] = 'S';
                cnt++;
            }
            if (cur[i][w - 1 - j] == '*') {
                cur[i][w - 1 - j] = 'S';
                cnt++;
            }
            pq.push(cnt);
        }
    }
    priority_queue<ll> cntpq;
    for(auto x : cnt) cntpq.push(x.second);
    while(!pq.empty()) {
        ll v = cntpq.top(); cntpq.pop();
        ll x = pq.top(); pq.pop();
        if (v < x) {
            cout << "No" << endl;
            return 0;
        }
        v -= x;
        if (v > 0) cntpq.push(v);
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 384
if __name__ == '__main__':
    n = int(input())
    p = [int(s) for s in input().split()]
    p_sorted = sorted(p)
    rem = [(x, y) for x, y in zip(p, p_sorted) if x != y]
    if len(rem) <= 2:
        print('YES')
    else:
        print('NO')



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

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;} 
ll lcm(ll x,ll y) {return x/gcd(x,y)*y;}

int main(){
    ll r,d,x;
    cin >> r >> d >> x;
    for(int i=0;i<10;i++){
        x=r*x-d;
        cout << x << endl;
    }
    
    return 0;
}











Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#define MAX 1000
using namespace std;

int check(int a[], int b[], int k, int l, int n, int m){
  int c, d;

  c = a[k];
  d = b[l];

  a[k] = d;
  b[l] = c;

  if(accumulate(a, a + n, 0) == accumulate(b, b + m, 0)){
    a[k] = c;
    b[l] = d;
    return 1;
  } else {
    a[k] = c;
    b[l] = d;
    return 0;
  }
}

int main(){
  int n, m, sum_taro, sum_hanako, taro[MAX], hanako[MAX], difference;

  while(true){
    cin >> n >> m;
    
    if(n == 0 && m == 0) break;
    
    for(int i = 0; i < n; i++){
      cin >> taro[i];
    }
    for(int j = 0; j < m; j++){
      cin >> hanako[j];
    }
    
    sum_taro = accumulate(taro, taro + n, 0);
    sum_hanako = accumulate(hanako, hanako + m, 0);
    
    difference = abs(sum_taro - sum_hanako) / 2; //合計値の差の1/2
    
    sort(taro, taro + n);
    sort(hanako, hanako + m);
    
    for(int k = 0; k < n; k++){
      for(int l = 0; l < m; l++){
	if(taro[k] == hanako[l] + difference && check(taro, hanako, k, l, n, m) == 1){
	  cout << taro[k] << " " << hanako[l] << endl;
	  goto FINE;
	} else if(hanako[l] == taro[k] + difference && check(taro, hanako, k, l, n, m) == 1){
	  cout << taro[k] << " " << hanako[l] << endl;
	  goto FINE;
	}
      }
    }
    
    cout << "-1" << endl;
  FINE:
    ;
  }

  return 0;
}

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

using namespace std;

string s[100005];

int main() {

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	int n;
	cin >> n;
	unordered_map <string, long long> anagrams;
	for (int i = 0; i < n; ++i) {
		cin >> s[i];
		sort(s[i].begin(), s[i].end());
		if (anagrams.count(s[i])) {
			anagrams[s[i]]++;
		}
		else anagrams[s[i]] = 1;
	}
	long long cnt = 0;
	for (auto x: anagrams) {
		cnt += (x.second * (x.second - 1)) / 2;
	}
	cout << cnt << '\n';
	return 0;
}

Measured memory_bytes: 17572
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def main():
    A, B = map(int, readline().split())
    print(A*B)
    
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 61656
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric>
#include <set>
#include <cstdlib>
#include <queue>

using namespace std;

typedef long long llint;
typedef long double ld;
#define inf 1e18

priority_queue<int,vector<int>,greater<int>> que;

llint x,y;
string s;
void solve(){
	cin >> s;
	if(s[2]==s[3] && s[4]==s[5])cout << "Yes";
	else cout << "No";
	cout << endl;
}

int main(int argc, char *argv[]) {
  solve();
  return 0;
}


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


int main(int argc, char const *argv[])
{
    int m1, m2, d1, d2;
    std::cin >> m1 >> d1;
    std::cin >> m2 >> d2;

    if (m1 != m2) {
        if (m1 == 12 && m2 == 1) {
            std::cout << 1 << std::endl;
            return 0;
        }
        if (m2 == m1 + 1) {
            std::cout << 1 << std::endl;
            return 0;
        }
    }
    std::cout << 0 << std::endl;
    return 0;
}


Measured memory_bytes: 256
n=gets.to_i
ss=[]
ts=[]
n.times{
  s,t=gets.split
  ss.push(s)
  ts.push(t.to_i)
}
x=gets.chomp
li=ss.index(x)
puts (li+1...n).reduce(0){|s,i| s+ts[i] }


Measured memory_bytes: 1788
#include<cstdio>
#include<cstring>
#include<vector>


using namespace std;

using vi=vector<int>;


int solve(vi&s, int l)
{
	int ans=l;

	if(s.size()<=1) return l;

	while(s.size()>2)
	{
		int n=s.size();
		int w1=max(s[0], l-s[0]);
		int w2=max(s[n-1], l-s[n-1]);
		if(w1>w2)
		{
			s[1]+=s[0];
			ans=min(ans, w1);
			s.erase(s.begin());
		}
		else
		{
			s[n-2]+=s[n-1];
			ans=min(ans, w2);
			s.pop_back();
		}
	}
	ans=min(ans, max(s[0], s[1]));
	return ans;
}


int main(void)
{
	char s[100000+2];

	while(scanf("%[01]\n", s)==1)
	{
		int l=strlen(s);
		vi series;
		int c=1;

		for(int i=1;i<l;i++)
		{
			if(s[i]==s[i-1])
			{
				c++;
			}
			else
			{
				series.push_back(c);
				c=1;
			}
		}
		if(c>0) series.push_back(c);
/*
		for(auto x:series)
		{
			printf(" %d", x);
		}
		printf("\n");
*/
		printf("%d\n", solve(series, l));
	}

	return 0;
}


Measured memory_bytes: 768