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

lint n, x, m;

lint f(lint z) {
    return z * z % m;
}

lint solve_short() {
    lint now = x;
    lint res = 0;
    for (int i = 0; i < n; i++) {
        res += now;
        now = f(now);
    }
    return res;
}

bool be_zero() {
    lint now = x;
    for (int i = 0; i <= m; i++) {
        now = f(now);
    }
    return now == 0;
}

vector<lint> loop() {
    set<lint> st;
    lint now = x;
    vector<lint> res;
    while (true) {
        res.push_back(now);
        if (st.count(now)) {
            return res;
        } else {
            st.insert(now);
            now = f(now);
        }
    }
}

int main() {
    cin >> n >> x >> m;
    if (n < 1000000) {
        cout << solve_short() << endl;
        return 0;
    }
    if (be_zero()) {
        lint now = x;
        lint res = 0;
        while (now != 0) {
            res += now;
            now = f(now);
        }
        cout << res << endl;
        return 0;
    } else {
        auto l = loop();
        // for (auto e : l) {
        //    cout << e << endl;
        //}
        lint loop_last = l.back();
        l.pop_back();
        lint k = l.size();
        lint left = 0;
        lint right = k;
        for (int i = 0; i < k; i++) {
            if (l[i] == loop_last) {
                left = i;
                break;
            }
        }
        lint ans = 0;
        for (int i = 0; i < left; i++) {
            ans += l[i];
        }
        n -= left;
        lint unit = 0;
        for (int i = left; i < right; i++) {
            unit += l[i];
        }
        lint loop_len = right - left;
        ans += unit * (n / loop_len);
        n %= loop_len;
        for (int i = 0; i < n; i++) {
            ans += l[left + i];
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 5880
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
ll m=1000000007;
ll sieve[1000001]={0},i,j;
ll power(ll p, ll k)
{
ll a=1;
while(k)
{
if(k&1)
a=(a*p)%m;
p=(p*p)%m;
k>>=1;
}
return a;
}
using namespace std;
int main()
{
ll n;
cin>>n;
ll i,j,ans=0;
ll a[n];
for(i=0;i<n;i++)
cin>>a[i];
for(i=0;i<n;i++)
{
for(j=0;j<i;j++)
ans+=a[i]*a[j];
}
cout<<ans;
}

Measured memory_bytes: 256
import math

x = int(input())

# エラトステネスの篩
def Eratosthenes(n):
    if n < 2:
        return None
    prime = [2]
    limit = math.ceil(n**0.5)
    data = list(range(3, n+1, 2))
    p = -1
    while p < limit:
        p = data[0]
        prime.append(p)
        data = [d for d in data if d%p != 0]
    return prime + data


prime = Eratosthenes(10**5+3)
if x in prime:
    print(x)
else:
    import bisect
    min_prime_index = bisect.bisect_right(prime, x)
    print(prime[min_prime_index])

Measured memory_bytes: 5400
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;

int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= 9; i++)
		for (int j = 1; j <= 9; j++) {
			if (i * j == n) {
				cout << "Yes\n";
				return 0;
			}
		}
	cout << "No\n";
	return 0;
}


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

using namespace std;
using ll = long long;
using ld = long double;

int main(){
    vector<ll> vec;
    int n;
    ll mod = 1e9+7LL;
    cin>>n;
    for(int i=0; i<n; i++){
        ll x;
        cin>>x;
        vec.push_back(x);
    }
    ll ans = 0;
    ll powmod[62];
    powmod[0] = 1;
    for(int i=1; i<=60; i++){
        powmod[i] = (powmod[i-1] * 2) % mod;
    }
    for(int i=0; i<60; i++){
        ll z = 0, o = 0;
        for(int j=0; j<n; j++){
            if(((vec[j]>>i)&1) == 1){
                o++;
            }
            else z++;
        }
        ans = (ans + ((o * ((z * powmod[i])% mod)) % mod))%mod;
    }
    cout<<ans<<endl;
}


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

int main() {
    int n,x;
    cin >> n >> x;
    vector<int> a(n);
    for (int i=0;i<n;i++) cin >> a[i];
    ll ans=max(0,a[0]-x);
    a[0]=min(x,a[0]);
    for (int i=1;i<n;i++) {
        if (a[i]+a[i-1]>x) {
            ans+=a[i]-(x-a[i-1]);
            a[i]=x-a[i-1];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
using namespace std;
using ll = long long;
using ull = unsigned long long;

int main(){
  int n, q; cin >> n >> q;
  string s;
  cin >> s;
  vector<int> res(n, 0);
  res[0] = 0;
  for(int i = 0; i < n-1; i++){
    if(s[i] == 'A' && s[i+1] == 'C'){
      res[i+1] = res[i] + 1;
    }
    else{res[i+1] = res[i];}
  }

  
  for(int i = 0; i < q; i++){
    int a, b; cin >> a >> b;
    cout << res[b-1] - res[a-1] << endl;
  }

  
}

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

using ll = long long;

class Stream{
public:
    Stream(){

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

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

int main(){
    Stream io;
    
    int A, B, T;
    io.read(A, B, T);
    int ans = 0;
    for(int x = A; x <= T; x += A){
        ans += B;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  int A, B, K;
  cin >> A >> B >> K;
  rep(i, K)
  {

    if (i % 2 == 0)
    {
      int tempA = A - A % 2;
      A = tempA / 2;
      B += tempA / 2;
    }
    else
    {
      int tempB = B - B % 2;
      A += tempB / 2;
      B = tempB / 2;
    }
  }
  cout << A << " " << B << endl;
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;

  stack<char> st;
  st.push(S[0]);

  for (ll i = 1; i < N; i++) {
    if (st.top() != S[i]) st.push(S[i]);
  }

  ll res = st.size();
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 512
#include <cstdio>
#include <algorithm>

using namespace std;

const int MAXN=1007;
char s1[MAXN];
char s2[MAXN];
int dp[MAXN][MAXN];


int main(){
    scanf("%s",s1+1);
    scanf("%s",s2+1);
    for(int i=1;s1[i];i++) dp[0][i]=i;
    for(int i=1;s2[i];i++) dp[i][0]=i;

    // puts(s1+1);
    // puts(s2+1);

    int i=1,j=1;
    for(;s2[i];i++){
        for(j=1;s1[j];j++){
            int temp=(s1[j]==s2[i]?dp[i-1][j-1]:dp[i-1][j-1]+1);
            dp[i][j]=min(min(temp,dp[i][j-1]+1),dp[i-1][j]+1);
        }
    }

    printf("%d\n",dp[i-1][j-1]);

    return 0;
}


Measured memory_bytes: 6648
import itertools as it
import collections as col
import heapq
import sys
sys.setrecursionlimit(10**9)

N=int(input())
print(180*(N-2))
"""
S=list(input())
T=[c for c in S if c == 'o']
print("YES" if len(T) + (15 - len(S)) >= 8 else "NO")
"""

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

int main(void) {
    double r;
    const double pi = 3.14159265358979323846264338;
    
    cin >> r;

    
    cout << fixed << setprecision(8) << pi * r * r << " " << 2 * pi * r << endl;
    
    return 0;
}

Measured memory_bytes: 3256
sa=input()
sb=input()
sc=input()
from collections import deque
a = deque(sa)
b = deque(sb)
c = deque(sc)

x = a.popleft()
while True:
    if x == 'a':
        if not a:
            print('A')
            break
        x = a.popleft()
    elif x == 'b':
        if not b:
            print('B')
            break
        x = b.popleft()
    elif x == 'c':
        if not c:
            print('C')
            break
        x = c.popleft()

Measured memory_bytes: 3316
trait Monoid {
    type T: Clone;
    fn id() -> Self::T;
    fn op(a: &Self::T, b: &Self::T) -> Self::T;
}

#[derive(Debug)]
struct SegmentTree<M: Monoid> {
    n: usize,
    vec: Vec<M::T>,
}

impl<M: Monoid> SegmentTree<M> {
    fn new(n: usize) -> Self {
        let n = n.next_power_of_two();
        SegmentTree {
            n: n,
            vec: vec![M::id().clone(); 2 * n - 1],
        }
    }

    // vec[k] = a
    fn update(&mut self, k: usize, a: M::T) {
        let mut k = k + self.n - 1;
        self.vec[k] = a;
        while k > 0 {
            k = (k - 1) / 2;
            self.vec[k] = M::op(&self.vec[2 * k + 1], &self.vec[2 * k + 2]);
        }
    }

    fn querySub(&self, a: usize, b: usize, k: usize, l: usize, r: usize) -> M::T {
        if r <= a || b <= l {
            M::id()
        } else if a <= l && r <= b {
            self.vec[k].clone()
        } else {
            M::op(
                &self.querySub(a, b, k * 2 + 1, l, (l + r) / 2),
                &self.querySub(a, b, k * 2 + 2, (l + r) / 2, r),
            )
        }
    }

    // op [a, b)
    fn query(&self, a: usize, b: usize) -> M::T {
        self.querySub(a, b, 0, 0, self.n)
    }
}

struct MIN;
impl Monoid for MIN {
    type T = i64;
    fn id() -> Self::T {
        2_i64.pow(31) - 1
    }
    fn op(a: &Self::T, b: &Self::T) -> Self::T {
        std::cmp::min(*a, *b)
    }
}

use std::io::*;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let q: usize = read();
    let mut seg: SegmentTree<MIN> = SegmentTree::new(n);
    for _ in 0..q {
        let com: usize = read();
        let x: usize = read();
        let y: usize = read();
        if com == 0 {
            seg.update(x, y as i64);
        } else {
            println!("{}", seg.query(x, y + 1));
        }
    }
}

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



Measured memory_bytes: 7080
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = Integer.parseInt(sc.next());
		int B = Integer.parseInt(sc.next());
		int result = 0;
		for (; A <= B; A++) {
			int digit1 = A / 10000;
			int digit2 = A / 1000 % 10;
			int digit4 = A / 10 % 10;
			int digit5 = A % 10;
			if (digit1 == digit5 && digit2 == digit4) {
				result++;
			}
		}
		System.out.println(result);
	}
}



Measured memory_bytes: 26980
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main() {
    int n, y;
    cin >> n;
    cin >> y;
    
    int maxp = n * 10000;
    int num = maxp - y;
    if (maxp >= y && (y % 1000) == 0)
    {
        for (int i = 0; i <= n; ++i)
        {
            for (int j = 0; j <= (n - i); ++j)
            {
                int val = i * 9000 + j * 5000;
                if (val == num)
                {
                    cout << n - i - j << " " << j << " " << i << endl;
                    return 0;
                }
            }
        }
        cout << "-1 -1 -1" << endl;
    }
    else
    {
        cout << "-1 -1 -1" << endl;
    }

    
    return 0;
}

Measured memory_bytes: 256
/* template.cpp(shinobu_menkoi) {{{ */
#include <bits/stdc++.h>
using namespace std;

// clang-format off
#define GET_MACRO(_1, _2, _3, _4, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rep1(n) rep2(_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, n) rep4(i, a, n, 1)
#define rep4(i, a, n, s) for (lint i = (a); i < (lint)(n); i += (s))
#define rrep(...) GET_MACRO(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rrep1(a) rrep2(_, a)
#define rrep2(i, a) rrep3(i, a, 0)
#define rrep3(i, a, n) rrep4(i, a, n, 1)
#define rrep4(i, a, n, s) for (lint i = (a); i >= (lint)(n); i -= (s))
#define each(i, ctn) for (auto &&i : (ctn))

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define all(v) begin(v), end(v)
#define debug(x) cerr << (x) << " (L:" << __LINE__ << ")" << '\n'
#define TEMP_T template <class T>
#define TEMP_TU template <class T, class U>

TEMP_T using vec = vector<T>;
TEMP_T using heap = priority_queue<T>;
TEMP_T using minheap = priority_queue<T, vec<T>, greater<T>>;
using lint = long long;
using ulint = unsigned long long;
using ld = long double;
using vi = vec<int>;
using vvi = vec<vi>;
using vvvi = vec<vvi>;
using pii = pair<int, int>;
using vs = vec<string>;

TEMP_TU ostream &operator<<(ostream &os, const pair<T, U> &p) { return os << p.fi << " " << p.se; }
TEMP_TU istream &operator>>(istream &is, pair<T, U> &p) { return is >> p.fi >> p.se; }

const int INF{1001001001};
const lint LINF{1001001001001001001ll};
const int MOD{(int)1e9 + 7};
const double EPS{1e-9};
const double PI{acos(-1)};
const int dx[]{0, 1, 0, -1, 1, -1, 1, -1}, dy[]{1, 0, -1, 0, 1, -1, -1, 1};

inline bool inside(int y, int x, int h, int w) { return y >= 0 && x >= 0 && y < h && x < w; }
TEMP_T inline bool chmin(T &a, const T &b) { if (a > b) a = b; return a > b; }
TEMP_T inline bool chmax(T &a, const T &b) { if (a < b) a = b; return a < b; }
TEMP_T inline void print(const T &x) { cout << x << '\n'; }
TEMP_T inline void print(const vec<T> &v, string d = "\n") { rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? "\n" : d); }
template <class T = int> inline T in() { T x; cin >> x; return x; }
template <class T = string> vec<T> split(const string &s, char d = ',') {
  vec<T> v; stringstream ss(s); for (string b; getline(ss, b, d); ) {
    stringstream conv(b); T t; conv >> t; v.eb(t); } return v;
}
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } pre__;
// clang-format on
/* }}} */

signed main() {
  lint n, m;
  lint res = 0;
  cin >> n >> m;

  lint t = m - n * 2;
  if (m < n * 2) {
    print(m / 2);
    return 0;
  } else {
    res += t / 4;
  }
  print(res + n);
}


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

int main() {
    int N;
    cin >> N;
    vector<double> v(N);
    rep(i, N) cin >> v[i];
    sort(v.begin(), v.end());
    double ans = v[0];
    rep(i, N - 1) ans = (ans + v[i + 1]) / 2;
    cout << setprecision(10) << ans << endl;
}

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

int main () {;
	int a, b, c;
	int tmp;
	cin >> a >> b >> c;
	
	if(a > b) {
		tmp = a;
		a = b;
		b = tmp;
	}
	
	if(b > c) {
		tmp = b;
		b = c;
		c = tmp;
	}
	
	if(a > b) {
	tmp = a;
	a = b;
	b = tmp;
	}
	cout << a << " " << b << " " << c << endl;
	return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define eps 1e-9
#define mod 1000000007
#define pi 3.14159265359
#define inf 1e18

using namespace std;

typedef long long ll;
typedef long double ld;

string s;

int main()
{
    // freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    string pat = "CF";
    cin>>s;
    int j = 0;
    for (int i=0; i<s.size() && j<pat.size(); i++)
    {
        if (s[i] == pat[j])
        {
            j++;
        }
    }

    if (j == 2)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }


    return 0;
}

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

int main() {
	int N;
	cin >> N;
  
	for(int i=1;i<=9;i++){
		int amari = N % i;
		int syou = N /i;
		if(amari == 0 && (syou>0 && syou<=9)){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using namespace boost::multiprecision;

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

int main () {
  cpp_int h,w;
  cin >> h >> w;

  if(h == 1 || w == 1) {
    cout << 1 << endl;
    return 0;
  }
  cout << ((h / 2) * w) + ((h % 2) * ((w / 2) + (w % 2))) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,b) for(int i=1;i<=b;i++)
#define drep(i,b) for(int i=b;i>=1;i--)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define int long long
#define endl '\n'
using namespace std;
const int N=2e5+5;
const int mod=1e9+7;
int n,m,k,t,x,y,z;
//pr
//
#define mid (l+r)/2
#define ls i<<1
#define rs i<<1|1
//vec
//alg

int a[6000],az;

void solve(int ans=0) {
    cin>>n>>m;
    vector<int> a(n+1),ve[n+1];
    rep(i,n) cin>>a[i];
    rep(i,m) {
        cin>>x>>y;
        ve[x].push_back(y);
        ve[y].push_back(x);
    }
    rep(i,n) {
        int fg=1;
        for(int v:ve[i]) {
            if(a[v]>=a[i]) fg=0;
        }
        if(fg) ans++;
    }
    cout<<ans<<endl;
}

#undef int
int main() {
    ios::sync_with_stdio(false);
    //int T;cin>>T;
    //while(T--)
        solve();
}


Measured memory_bytes: 9860
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;
const int X[4] = { 0,1,0,-1 }, Y[4] = { 1,0,-1,0 };

int H, W, dis[1000][1000], res;
char c;
queue<pair<int, int>>q;

int main() {
	cin >> H >> W;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			cin >> c;
			if (c == '#') {
				q.push(mkp(i, j));
			}
			else {
				dis[i][j] = -1;
			}
		}
	}
	while (!q.empty()) {
		for (int i = 0; i < 4; ++i) {
			int x = q.front().first + X[i];
			int y = q.front().second + Y[i];
			if (x < 0 || y < 0 || H <= x || W <= y || dis[x][y] != -1)continue;
			dis[x][y] = dis[q.front().first][q.front().second] + 1;
			q.push(mkp(x, y));
		}
		q.pop();
	}
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			res = max(res, dis[i][j]);
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 9088
<?php
fscanf(STDIN, "%d %d", $n, $m);
for ($i = 0; $i < $m; $i++) {
	fscanf(STDIN, "%d %d", $p, $y);
	$c[$y][$p] = $i;
}
ksort($c);
$x = array_fill(1, $n, 0);
foreach ($c as $y => $z) {
	foreach ($z as $p => $i) {
		$t[$i] = sprintf("%06d%06d", $p, ++$x[$p]);
	}
}
ksort($t);
echo implode("\n", $t);

Measured memory_bytes: 88952
function Main(input) {
  var n = input.split("\n")[0];
  var a = input.split("\n")[1].split(" ");
  var sum = 0;
  var min = Infinity;
  var minusCount = 0;
  for(var i of a){
  	sum += Math.abs(i);
    if(i<0)minusCount++;
    if(Math.abs(i)<min)min = Math.abs(i);
  }
  if(minusCount%2==1)sum -= min*2;
  console.log(sum);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29008
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#define SF scanf
#define PF printf
#define MAXN 1010
using namespace std;
typedef long long ll;
double stx,sty,edx,edy;
int n;
struct node{
	double x,y,r;	
}p[MAXN];
double lenp(double x,double y,double xx,double yy){
	return sqrt((x-xx)*(x-xx)+(y-yy)*(y-yy));
}
double len(int x,int y){
	double distx=lenp(p[x].x,p[x].y,p[y].x,p[y].y);
	return max(0.0,distx-p[x].r-p[y].r);
}
double len1[MAXN][MAXN];
double dist[MAXN];
int inq[MAXN];
queue<int> q;
void spfa(){
	while(!q.empty()){
		int x=q.front();
		inq[x]=0;
		q.pop();
		for(int i=1;i<=n;i++){
			if(i==x)
				continue;
			if(dist[i]<0||dist[i]>dist[x]+len1[x][i]){
				dist[i]=dist[x]+len(x,i);
				if(inq[i]==0){
					inq[i]=1;
					q.push(i);	
				}
			}
		}
	}
}	
int main(){
	SF("%lf%lf%lf%lf",&stx,&sty,&edx,&edy);
	SF("%d",&n);
	for(int i=1;i<=n;i++)
		SF("%lf%lf%lf",&p[i].x,&p[i].y,&p[i].r);
	p[++n].x=stx;
	p[n].y=sty;
	p[n].r=0;
	p[++n].x=edx;
	p[n].y=edy;
	p[n].r=0;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			len1[i][j]=len(i,j);
	for(int i=1;i<=n;i++)
		dist[i]=-1;
		
	dist[n]=0;
	q.push(n);
	spfa();
	PF("%.10lf\n",dist[n-1]);
}
	

Measured memory_bytes: 8320
from collections import deque
N, D, A = map(int, input().split())
ls = []
for i in range(N):
  x,h = map(int, input().split())
  h = h//A if h%A==0 else h//A+1
  ls += [(x,h)]
ls.sort(key=lambda x:x[0])
deq = deque([])
ans = 0
acc = 0
for i in range(N):
  x, h = ls[i]
  while deq and deq[0][0]<x:
    y, d = deq.popleft()
    acc -= d
  n = max(0,h-acc)
  ans += n
  acc += n
  if n:
    deq += [(x+2*D,n)]
print(ans)

Measured memory_bytes: 44644
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
static const int N = 1000;

int lcs(string X, string Y){
    int c[N + 1][N + 1];
    int m = X.size();
    int n = Y.size();
    int maxl = 0;
    X = ' ' + X;
    Y = ' ' + Y;
    for (int i = 1; i <= m; i++) c[i][0] = 0;
    for (int j = 0; j <= n; j++) c[0][j] = 0;
    
    for (int i = 1; i <= m; i++){
        for(int j = 1; j <= n; j++){
            if (X[i] == Y[j]){
                c[i][j] = c[i - 1][j - 1] + 1;
            } else {
                c[i][j] = max(c[i - 1][j], c[i][j - 1]);
            }
            maxl = max(maxl, c[i][j]);
        }
    }
    return maxl;
}

int main(){
    string s1, s2;
    int n; cin >> n;
    for (int i = 0; i < n; i++){
        cin >> s1 >> s2;
        cout << lcs(s1, s2) << endl;
    }
    return 0;
}



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

int enc(int i){
    if(i < 15)  return 0;
    if(i < 21)  return 1;
    return 2;
}

string s[3] = {"lunch", "dinner", "midnight"};

int main(){
    int n;
    while(scanf("%d\n", &n), n){
        int h, m, mm, ans[3][2] = {};
        while(n-- > 0){
            scanf("%d:%d %d\n", &h, &m, &mm);
            if(h < 2)   h += 24;
            if(15 <= h && h < 18)   continue;
            if(m > mm)  mm += 60;
            int ok = (mm-m <= 8);
            ans[enc(h)][ok]++;
        }
        for(int i = 0; i < 3; i++){
            cout << s[i] << " ";
            if(ans[i][0]+ans[i][1] == 0){
                cout << "no guest" << endl;
            }else{
                cout << 100*ans[i][1]/(ans[i][0]+ans[i][1]) << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3112
#include<stdio.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;

void run (void) {
  i32 n, x;
  scanf ("%" SCNi32 "%" SCNi32, &n, &x);
  i32 d = 0;
  i32 cnt = 1;
  while (n--) {
    i32 l;
    scanf ("%" SCNi32, &l);
    d += l;
    cnt += (d <= x ? 1 : 0);
  }
  printf ("%" PRIi32 "\n", cnt);
}

int main (void) {
  run();
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>

int N, K, temp;
std::vector<int> k;

int main() {
    std::cin >> N >> K;
    for (int i=0; i<N; ++i) {
        std::cin >> temp;
        k.push_back(temp);
    }
    
    std::sort(k.begin(), k.end());
    
    int ans = 1000000001;
    for (int i=0; i<N-K+1; ++i) {
        temp = k[i+K-1] - k[i];
        if (temp < ans) ans = temp;
    }
    std::cout << ans << std::endl;
}


Measured memory_bytes: 892
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
    int n,t=0;cin>>n;
    vector<int> v(n);
    vector<int> c(n);
    for(auto &i:v) cin>>i;
    for(auto &i:c) cin>>i;
    for(int i=0;i<n;i++){
        if(v[i]>c[i]) t+=v[i]-c[i];
    }
    cout<<t;
}

Measured memory_bytes: 256
A,B,C = map(int,input().split())
K = int(input())
frag = False
for i in range(K):
    if A >= B:
        B = 2 * B
    elif B >= C:
        C = C * 2
    
if  A < B and B < C:
    print("Yes")
else:
    print("No")

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

using namespace std;
using ll = long long;

const int N = 5e2;

ll p[N], dp[N][N];

ll calc(int l, int r) {
    if (l >= r)
        return 0;
    if (l + 1 == r)
        return p[r] - p[l - 1];
    if (~dp[l][r])
        return dp[l][r];
    dp[l][r] = 1e14;
    for (int i = l; i < r; ++i) {
        ll x = calc(l, i);
        ll y = calc(i + 1, r);
        dp[l][r] = min(dp[l][r], x + y + p[r] - p[l - 1]);
    }
    return dp[l][r];
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i)
        cin >> p[i], p[i] += p[i - 1];
    for (int i = 0; i < N; ++i)
        fill(dp[i], dp[i] + N, -1);
    cout << calc(1, n);
    return 0;
}

Measured memory_bytes: 2304
#include <iostream> //üoÍ
#include <vector>   //®Izñ

using namespace std;

int main(){
	vector<int> vec;
	int n;

	while(cin >> n){
		vec.push_back(n);
	}

	for(int i=0;i<vec.size();i++){
		for(int j=0;j<vec.size()-1;j++){
			if(vec[j] < vec[j+1]){
				int num = vec[j];
				vec[j] = vec[j+1];
				vec[j+1] = num;
			}
		}
	}

	for(int i=0;i<3;i++){
		cout << vec[i] << endl;
	}

	return 0;
	
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int i,j;
  int n,m;
  cin>>n>>m;
  int h[n];
  for(i=0;i<n;i++){
    cin>>h[i];
  }
  VI v(n,1);
  for(i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    a--; b--;
    if(h[a]<=h[b]) v[a]=0;
    if(h[a]>=h[b]) v[b]=0;
  }
  int ans=0;
  for(i=0;i<n;i++) ans+=v[i];
  cout<<ans<<endl;


}

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

int main(){
  int a, b;
  cin >> a >> b;
  if((a + b) == 15){
    cout << "+" << endl;
  } else if ((a * b) == 15){
    cout << "*" << endl;
  } else {
    cout << "x" << endl;
  }
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
 
using namespace std;
 
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)
int main() {
    string a,b;
    cin>>a>>b;
    cout<<b+a<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>          // printf(), scanf()
#include <string.h>         // strlen()

const int MAX_L = 100;

int
main(int argc, char **argv)
{
	char str[MAX_L + 1];
	int i;

	int count = 0;
	while (scanf("%s", str) != EOF)
	{
		int j = strlen(str);
		int k = j / 2;
		for (i = 0; i < k; ++i)
		{
			if (str[i] != str[j - 1 - i])
				break;
		}

		if (i >= k)
			count++;
	}

	printf("%d\n", count);
	return 0;
}

Measured memory_bytes: 540
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())
 
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18


int main() {
    LL a, b;
    cin >> a>>b;
    LL A = a;
    LL B=b;
    if(a<b){
        a=b;
        b=A;
    }
    LL r = a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    cout<<A*B/b<<endl;
}

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

int main(){
    int N;
    int odd;
    cin>>N;

    if(N%2==1){
        odd=N/2+1;
        cout<<(double)odd/(double)N<<endl;
    }else{
        cout<<(double)1/2<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 10000000000000000
#define endl '\n'
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; }
using namespace std;

int N;
int A[2010];
int dp[2][2010][2010];
int maxY[2010],minX[2010];

signed main(void){
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>N;
    rep(i,N+2)cin>>A[i];
    
    //dp[0][i][j] は　dp[1][j+1][j], dp[1][j+2][j], ... dp[1][N+1][j] の最大値
    //dp[1][i][j] は　dp[0][i][i+1], dp[0][i][i+2], ... dp[0][i][N+1] の最小値
    //2-indexedで、0,1は初期状態を表す
    //dp[0][0][1]を求めたい
    
    fill(maxY,maxY+N+2,0);
    fill(minX,minX+N+2,INF);
    for(int i=2; i<=N; i++){
        dp[0][i][N+1]=abs(A[i]-A[N+1]);
        chmin(minX[i], dp[0][i][N+1]);
    }
    for(int i=1; i<=N; i++){
        dp[1][N+1][i]=abs(A[i]-A[N+1]);
        chmax(maxY[i], dp[1][N+1][i]);
    }
    
    for(int i=N; i>=3; i--){
        for(int j=i-1; j>=2; j--){
            dp[0][j][i]=maxY[i];
            chmin(minX[j], dp[0][j][i]);
            dp[1][i][j]=minX[i];
            chmax(maxY[j], dp[1][i][j]);
        }
    }
    for(int i=N; i>=2; i--){
        dp[1][i][1]=minX[i];
        chmax(maxY[1], dp[1][i][1]);
    }
    
    cout<<maxY[1]<<endl;
    return 0;
    
}

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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

#define REP(i, x, n) for(ll i=x; i<(ll)n; ++i)
#define rep(i, x) REP(i, 0, n)
#define all(v) v.gein(), v.end()

int main(){
    int N, K;
    cin >> N >> K;
    cout << (K==1? 0 : (N-K)) << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
const int N=20000+10;
int n,p[N],a[N],b[N];
int main() {
    scanf("%d",&n);
    a[1]=5e8,b[1]=5e8;
    for(int i=2;i<=n;i++) {
        a[i]=a[i-1] + (n+1);
        b[i]=b[i-1] - (n+1);
    }
    for(int i=1;i<=n;i++) {
        scanf("%d",&p[i]);
        b[p[i]]+=i;
    }
    for(int i=1;i<=n;i++) printf("%d%c", a[i],i==n?'\n':' ');
    for(int i=1;i<=n;i++) printf("%d%c", b[i],i==n?'\n':' ');
}

Measured memory_bytes: 896
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long sum = 0;
		long[] dif = new long[n + 1];
		
		int[] a = new int[n];
		int[] nums = new int[n + 1];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			nums[a[i]]++;
		}
		
		for (int i = 1; i < n + 1; i++) {
			// System.out.println("i:" + i);
			
			long num = nums[i];
			// System.out.println("  num:" + num);
			
			long tmp = num * (num - 1) / 2;
			// System.out.println("  tmp:" + tmp);
			
			sum += tmp;
			dif[i] = tmp - ((num - 1) * (num - 2) / 2);
			if (tmp == 0)
				dif[i] = 0;
			// System.out.println("  dif[" + i + "]:" + dif[i]);
		}
		// System.out.println("sum:" + sum);
		
		for (int k = 0; k < n; k++) {
			// System.out.println("k:" + k);
			// System.out.println("  a[" + k + "]:" + a[k]);
			// System.out.println("  dif[a[" + k + "]]:" + dif[a[k]]);
			System.out.println(sum - dif[a[k]]);
		}
		
		sc.close();
	}
}


Measured memory_bytes: 95476
N = int(input())
A = list(map(int, input().split()))

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

index = list(range(N))
L = index.copy()

L[0] = 0
for i in index[:-1]:
    #print(i)
    L[i+1] = gcd(L[i], A[i])

R = index.copy()
R.append(0)
for i in reversed(index):
    #print(i)
    R[i] = gcd(R[i+1], A[i])

# confirm
#print(L)
#print(R)

M = []
for j in range(len(L)):
    m = gcd(L[j], R[j+1])
    #print(m)
    M.append(m)

# Confirm
#print(M)

# Answer
print(max(M))

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

#define FOR(i,a,n) for (int i = a; i < (int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define whole(f,x,...) ([&](decltype((x)) whole) { \
    return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
template<typename T> bool chmin(T &a, const T &b) {if (a > b) { a = b; return true; }return false;}
template<typename T> bool chmax(T &a, const T &b) {if (a < b) { a = b; return true; }return false;}

using ll = int_fast64_t;

constexpr ll INF = (1e9);
constexpr ll MOD = (1e9+7);


int main() {
  ll h, w; cin >> h >> w;
  ll ans = INF;
  REP(i,h) {
    ll a = i*w;
    ll b = (h-i)/2*w;
    ll c = h*w - (a+b);
    chmin(ans, max({a, b, c}) - min({a, b, c}));
    b = (h-i)*(w/2);
    c = h*w - (a+b);
    chmin(ans, max({a, b, c}) - min({a, b, c}));
  }
  REP(i,w) {
    ll a = i*h;
    ll b = (w-i)/2*h;
    ll c = h*w - (a+b);
    chmin(ans, max({a, b, c}) - min({a, b, c}));
    b = (w-i)*(h/2);
    c = h*w - (a+b);
    chmin(ans, max({a, b, c}) - min({a, b, c}));
  }
  cout << ans <<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n,m;
  cin>>n>>m;
  vector<Int> a(n),b(n);
  for(Int i=0;i<n;i++) cin>>a[i]>>b[i];
  vector<Int> c(m),d(m);
  for(Int i=0;i<m;i++) cin>>c[i]>>d[i];

  {
    vector<Int> x,y;
    x.emplace_back(c[0]);
    y.emplace_back(d[0]);
    for(Int i=1;i<m;i++){
      if(y.back()<=d[i]) continue;
      if(x.back()==c[i]){
        y.back()=d[i];
      }else{
        x.emplace_back(c[i]);
        y.emplace_back(d[i]);
      }      
    }
    m=x.size();
    c=x;d=y;
  }  

  priority_queue<Int, vector<Int>, greater<Int> > pq;    
  Int j=n-1;
  for(Int i=m-1;i>=0;i--){
    while(j>=0&&a[j]>=c[i]) pq.emplace(b[j--]);
    while((Int)pq.size()>=d[i]) pq.pop();
  }
  while(j>=0) pq.emplace(b[j--]);

  Int ans=0;
  while(!pq.empty()){
    ans+=pq.top();
    pq.pop();
  }
  
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 7048
start = []
end = []

def query1(b):
    return not b

def query2(F, C, string, b):
    if (F == '1' and b) or (F == '2' and not b):
        start.append(C)
        return C + string
    else:
        end.append(C)

S = input()
Q = int(input())
direction = True

for i in range(Q):
    Query = input().split()
    if len(Query) == 1:
        direction = query1(direction)
    else:
        query2(Query[1], Query[2], S, direction)

if direction:
    print(''.join(start[::-1]) + S + ''.join(end))
else:
    print(''.join(end[::-1]) + S[::-1] + ''.join(start))

Measured memory_bytes: 6316
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	int n;cin>>n;
	int a[n];
	for(int i=0;i<n;i++)	cin>>a[i];
	ll ans=0;
	for(int i=0;i<n;i++) {
		for(int j=i+1;j<n;j++){
			ans+=a[i]*a[j];
		}
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 3624
import numpy as np
N, T = map(int, input().split())
AB = [tuple(map(int, input().split())) for n in range(N)]
AB.sort()

dp = np.zeros(T, dtype=int)
ans = 0
for a, b in AB:
    ans = max(ans, dp[-1]+b)
    np.maximum(dp[a:], dp[:-a]+b, out=dp[a:])
print(ans)


Measured memory_bytes: 12512
input1 = input().split()
B = input().split()


N = input1[0]
M = input1[1]
C = input1[2]

result = 0

for i in range(int(N)):
	A = input().split()
	
	ans = 0
	
	for j in range(int(M)):
		ans += int(A[int(j)])*int(B[int(j)])
		
	ans += int(C)
	
	if ans > 0:
		result += 1

print(result)

Measured memory_bytes: 3064
#include <cstdio>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

struct K {
  int a, b, c;
};

K vs[50];

int dp[430][430];

const int INF = 1000000;

int main(void) {
  int n, ma, mb;
  scanf("%d%d%d", &n, &ma, &mb);
  REP(i, n) {
    scanf("%d%d%d", &vs[i].a, &vs[i].b, &vs[i].c);
  }

  REP(i, 410) REP(j, 410)
    dp[i][j] = INF;

  dp[0][0] = 0;
  REP(i, n) {
    const K& cur = vs[i];
    for(int a = 400; a - cur.a >= 0; --a) {
      for(int b = 400; b - cur.b >= 0; --b) {
        dp[a][b] = min(dp[a][b], dp[a-cur.a][b-cur.b] + cur.c);
      }
    }
  }

  int res = INF;
  for(int a = ma, b = mb; a <= 400 && b <= 400; a += ma, b += mb){
    res = min(res, dp[a][b]);
  }
  printf("%d\n", res >= INF ? -1 : res);
  
  return 0;
}


Measured memory_bytes: 896
#include <cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<set>
#include<bitset>
#include<iomanip>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
int main(void) {
	int d, t, s;
	cin >> d >> t >> s;
	double ans = (double)d / s;
	
	if (ans <= t) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3628
AB=[list(map(int,input().split())) for i in range(int(input()))]
for a,b in AB:
    if a<b:a,b=b,a
    if a==b:
        print(2*a-2)
        continue
    c=int((a*b)**0.5)
    if a*b>c**2:
        if c*(c+1)<a*b:print(c*2-1)
        else:print(c*2-2)
    elif a*b==c**2:print((c-1)*2-1)

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

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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 (a > b) {
    a = b;
    return true;
  }
  return false;
}

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>
//  ba;
signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) {
    int temp;
    cin >> temp;
    temp--;
    a[temp] = i;
  }
  rep(i, n) {
    cout << a[i] +1;
    if (i == n - 1)
      cout << endl;
    else
      cout << " ";
  }
  return 0;
}


Measured memory_bytes: 1280
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.nextLine().toCharArray();
		int k = sc.nextInt();

		for (int i = 0; i < s.length - 1; i++) {
			int id = s[i] - 'a';
			if (id == 0 || 26 - id > k) continue;
			k -= (26 - id);
			s[i] = 'a';
			if (k == 0) break;
		}
		if (k > 0) {
			s[s.length - 1] = (char) ((s[s.length - 1] - 'a' + k) % 26 + 'a');
		}

		System.out.println(s);
	}
}


Measured memory_bytes: 28228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef std::pair<int,int> pair2;
typedef std::pair<int,pair2> pair3;
const ll INF = 1LL<<60;

int main(){
  ll N;
  cin>>N;
  ll F[N+1][10+1];
  for(ll k=1;k<N+1;k++){
	  for(ll i=1;i<10+1;i++){
  	cin>>F[k][i];
  	}
  }
  ll P[N+1][10+1];
  for(ll j=1;j<N+1;j++){
  for(ll i=0;i<10+1;i++){
  	cin>>P[j][i];
  }
  }
  
ll ans=-INF;
  for(ll i=1;i<1024;i++){
    ll counter[N+1]={0};
    ll house[10+1]={0};
    ll inum=i;
    for(ll j=1;j<10+1;j++){
      house[j]=inum%2;
      inum=inum/2;
      if(house[j]==1){
        for(ll k=1;k<N+1;k++){counter[k]=counter[k]+F[k][j];}
      }
    }
    ll lans=0;
    for(ll m=1;m<N+1;m++){
      lans=lans+P[m][counter[m]];
    }
    if(lans>ans){
    ans=lans;
    }
    
  }
  
  cout<<ans<<endl;
}


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

int main(){

  int h,m,s;

  cin  >> s;

  h=s/3600;

  s=s%3600;

  m=s/60;

  s=s%60;

  cout << h << ":"<< m<<":"<<s<< endl;

  return 0;

}

Measured memory_bytes: 1164
#include <iostream>
using namespace std;
typedef long long ll;
ll n,dp[300][300],m,L,Q,a,b,c,INF=1e15,dp2[300][300];
int main(void){
    for(int i=0;i<300;i++){
        for(int j=0;j<300;j++){
            dp[i][j]=INF;
            dp2[i][j]=INF;
        }
    }
    cin>>n>>m>>L;
    for(int i=0;i<m;i++){
        cin>>a>>b>>c;
        a--,b--;
        if(L>=c){
            dp[a][b]=c;
            dp[b][a]=c;
        }
    }
    for(int k=0;k<300;k++){
        for(int i=0;i<300;i++){
            for(int j=0;j<300;j++){
                dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);
            }
        }
    }
    for(int i=0;i<300;i++){
        for(int j=0;j<300;j++){
            if(dp[i][j]<=L)dp2[i][j]=1;
        }
    }
    for(int k=0;k<300;k++){
        for(int i=0;i<300;i++){
            for(int j=0;j<300;j++){
                dp2[i][j]=min(dp2[i][j],dp2[i][k]+dp2[k][j]);
            }
        }
    }
    cin>>Q;
    for(int i=0;i<Q;i++){
        cin>>a>>b;
        a--,b--;
        if(dp2[a][b]==INF)cout<<-1<<endl;
        else{
            cout<<dp2[a][b]-1<<endl;
        }
    }
}


Measured memory_bytes: 1920
fn main() {
    use std::io::Read;
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();

    let n: u64 = iter.next().unwrap().parse().unwrap();    
    if n == 1 {
        println!("Hello World");
    } else {
        let a: u64 = iter.next().unwrap().parse().unwrap();
        let b: u64 = iter.next().unwrap().parse().unwrap();
        
        println!("{}", a + b);
    }
}

Measured memory_bytes: 4352
def dfs(i: int, sum: int, count: int, nokori: int) -> int:
    global ans
    if i == d:
        if sum < g:
            use = max(nokori)
            n = min(p[use], -(-(g-sum) // (use*100)))
            count += n
            sum += n * use * 100

        if sum >= g:
            ans = min(ans, count)
    
    else:
        dfs(i+1, sum, count, nokori)
        dfs(i+1, sum + p[i+1]*(i+1)*100+c[i+1], count + p[i+1], nokori - {i+1})

d,g = map(int, input().split())
p = [0] * (d+1)
c = [0] * (d+1)

for i in range(1, d+1):
    p[i], c[i] = map(int, input().split())

ans = float("inf")

dfs(0, 0, 0, set(range(1, d+1)))
print(ans)

Measured memory_bytes: 71252
#include<bits/stdc++.h>
using namespace std;
signed main(void){
	string s;
	getline(cin,s);
	for(int i=0;i<s.length();i++)
		if(s[i]>='a'&&s[i]<='z')
			s[i]+=('A'-'a');
	cout<<s<<endl;
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using namespace std;
int main(){
    int x;
    cin>>x;
    if(x>=30){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }


    }

Measured memory_bytes: 3632
#include <stdio.h>
int main(){
	int min=1000000,max=-1000000,n,i,f=0;
	long long sum=0;
	//n?????\???
	do{
		scanf("%d",&n);
		printf("");
	}while(!(n>=0 && n<=10000));
	
	int a[10000];
	do{
		for(i=0;i<n;i++){
			scanf("%d ",&a[i]);
			if(!(a[i]>=-1000000 && a[i]<=1000000))f=1;
		}
	}while(f!=0);

	//??????
	for(i=0;i<n;i++){
		if(min>a[i])min=a[i];
		if(max<a[i])max=a[i];
		sum=sum+a[i];
	}
	printf("%d %d %lld\n",min,max,sum);


	return 0;
}

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

int n;
string s[MAX];
map<string, int> mp;
vector<string> v;

int main()
{
    cin >> n;
    int mx = 0;
    for(int i = 1; i <= n; i++){
        cin >> s[i];
        mp[s[i]]++;
        mx = max(mx, mp[s[i]]);
    }
    for(int i = 1; i <= n; i++){
        if(mp[s[i]] == mx){
            v.push_back(s[i]);
            mp[s[i]] = -1;
        }
    }
    sort(v.begin(), v.end());
    for(int i = 0; i < v.size(); i++){
        cout << v[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 30836
import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int[] A = new int[N+1];
        int[] B = new int[N];
        for(int i = 0; i < N+1; i++)
            A[i] = sc.nextInt();
        for(int i = 0; i < N; i++)
            B[i] = sc.nextInt();
        long count = 0;

        for(int i = 0; i < N; i++) {
            if (B[i] >= (A[i] + A[i+1])) {
                count += (A[i]+A[i+1]);
                A[i+1] = 0;
            }
            if((B[i] > A[i]) && (B[i] < (A[i] + A[i+1]))) {
                count += B[i];
                A[i+1] -= (B[i] - A[i]);
            }
            if(B[i] <= A[i]){
                count += B[i];
            }
        }
        sc.close();
        System.out.println(count);        
    }
}

Measured memory_bytes: 79300
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,k; cin >> a >> b >> c >>k;
  if(k <= a)
    cout << k;
  else if(k <= a + b)
    cout << a;
  else{
    int amari = k - a - b;
    if(amari < c)
      cout << a - amari;
    else
      cout << a - c;
  }
    
}

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

using namespace std;

typedef long long ll;

signed main()
{
    ll n, m;
    cin >> n >> m;
    vector<ll> a(n);
    vector<ll> b(n);
    for(ll i = 0; i < n; ++i)
        cin >> a[i] >> b[i];
    vector<vector<ll>> dp(n + 1, vector<ll>(1000 * n + 1, 1e12));
    dp[0][0] = 0;
    for(ll i = 0; i < n; ++i){
        for(ll j = 0; j <= 1000 * n; ++j){
            if(dp[i][j] == 1e12)
                continue;
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
            dp[i + 1][j + b[i]] = min(dp[i + 1][j + b[i]], dp[i][j] + a[i]);
        }
    }
    for(ll i = 1000 * n; i >= 0; --i){
        if(dp[n][i] <= m){
            cout << i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 80256