akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <memory>
#include <string>
#include <algorithm>

using namespace std;

int main(void){
    int n;
    string a,b,ans;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        ans="";
        cin>>a>>b;
        if(a.size()>80||b.size()>80){
            cout<<"overflow"<<endl;
            continue;
        }
        reverse(a.begin(),a.end());
        reverse(b.begin(),b.end());
        int size=(a.size()>b.size())?a.size():b.size();
        bool af=false,bf=false,uf=false;
        for(int j=0;j<size;j++){
            int pr=0;
            if(a.size()<j+1)af=true;
            if(b.size()<j+1)bf=true;
            if(!af){
                pr+=a[j];
                pr-=48;
            }
            if(!bf){
                pr+=b[j];
                pr-=48;
            }
            if(uf)pr++;
            if(pr>9){
                pr-=10;
                uf=true;
            }else uf=false;
            pr+=48;
            ans=(char)pr+ans;
        }
        if(uf)ans='1'+ans;
        if(ans.size()>80)cout<<"overflow"<<endl;
        else cout<<ans<<endl;
    }
}



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

namespace ConsoleApplication1
{
    class Node
    {
        internal int d, f;
        internal List<int> adj;

        public Node() { adj = new List<int>(); }
    }

    class Program
    {
        static int cnt;

        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            Node[] nodes = new Node[n + 1];

            for (int i = 0; i < n; i++)
            {
                int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

                nodes[input[0]] = new Node();

                for (int j = 0; j < input[1]; j++)
                {
                    nodes[input[0]].adj.Add(input[2 + j]);
                }
            }

            cnt = 0;

            for (int i = 1; i <= n; i++)
            {
                if (nodes[i].d == 0) DFS(nodes, nodes[i]);
            }

            StringBuilder sb = new StringBuilder();
            for (int i = 1; i <= n; i++)
            {
                sb.AppendLine(i + " " + nodes[i].d + " " + nodes[i].f);
            }
            Console.Write(sb);
        }

        static void DFS(Node[] nodes, Node node)
        {
            node.d = ++cnt;
            for (int i = 0; i < node.adj.Count; i++)
            {
                if (nodes[node.adj[i]].d == 0)
                {
                    DFS(nodes, nodes[node.adj[i]]);
                }
            }
            node.f = ++cnt;
        }
    }
}

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

//
int main(void) {
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> point(n, k), a(q);
    for (int i=0; i<q; i++) {
        cin >> a.at(i);
        point.at(a.at(i)-1)++;
    }
    for (int i=0; i<n; i++) {
        if (point.at(i)-q > 0) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 1408
import java.util.Scanner;

// https://atcoder.jp/contests/abc165/tasks/abc165_b
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		sc.close();



		int ans = 1;
		long a = 100L;
		for(int i=1;a<x;i++) {
			a = (long) (a*1.01);
			ans = i;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 26976
//! Framework <https://github.com/vain0x/procon>

#![allow(non_snake_case)]
#![allow(unused_imports)]

use std::collections::*;

pub struct Scan(Box<dyn Iterator<Item = &'static str>>); // '

impl Scan {
    fn new() -> Self {
        let mut buf = String::new();
        let read_line = move || {
            std::io::stdin().read_line(&mut buf).unwrap();
            Box::leak(buf.split_off(0).into_boxed_str()).split_whitespace()
        };
        Scan(Box::new(std::iter::repeat_with(read_line).flatten()))
    }

    pub fn word<T: std::str::FromStr>(&mut self) -> T {
        self.0.next().unwrap().parse().ok().unwrap()
    }

    pub fn list<T: std::str::FromStr>(&mut self, len: usize) -> Vec<T> {
        std::iter::repeat_with(|| self.word()).take(len).collect()
    }
}

fn main() {
    let mut scan = Scan::new();

    let N = scan.word::<usize>();
    let M = scan.word::<usize>();

    let mut g = vec![vec![]; N];
    for _ in 0..M {
        let A = scan.word::<usize>() - 1;
        let B = scan.word::<usize>() - 1;
        g[A].push(B);
        g[B].push(A);
    }

    let mut queue = VecDeque::new();
    let mut prev = vec![N; N];
    let mut count = 0;
    queue.push_back((0, 0));
    while let Some((u, p)) = queue.pop_front() {
        if prev[u] != N {
            continue;
        }

        prev[u] = p;
        count += 1;
        if count >= N {
            break;
        }

        for i in 0..g[u].len() {
            let v = g[u][i];
            if prev[v] != N {
                continue;
            }

            queue.push_back((v, u));
        }
    }

    println!("Yes");
    for u in 1..N {
        println!("{}", prev[u] + 1);
    }
}


Measured memory_bytes: 18632
#include <iostream>
#include <iomanip>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <array>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional>
#include <cmath>
#include <numeric>
#include <bitset>
#include <cstdint>
using namespace std;

#ifdef DEBUG
#include <cassert>
#else
#define assert(x)
#endif

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); i++)
using ll = long long;

//////////////// //////////////// //////////////// //////////////// ////////////////
//////////////// //////////////// //////////////// //////////////// ////////////////

int main()
{
    // 高速な入出力
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    // 浮動小数の表示の精度
    cout << setprecision(15);

    string s;
    cin >> s;
    int q;
    cin >> q;

    bool flip = false;
    vector<string> str(2);
    rep(i, q)
    {
        int t;
        cin >> t;
        if (t == 1)
        {
            flip = 1 ^ flip;
        }
        else
        {
            int f;
            char c;
            cin >> f >> c;
            bool b = (f == 2) ^ flip;
            str[b] += c;
        }
    }
    if (flip)
    {
        reverse(s.begin(), s.end());
        swap(str[0], str[1]);
    }
    reverse(str[0].begin(), str[0].end());
    cout << str[0] + s + str[1] << "\n";

    return 0;
}


Measured memory_bytes: 4240
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  ll N,M;
  cin >> N >> M;
  if (N == 1 || M == 1) {
    if (N == 1 && M == 1) {
      cout << 1 << endl;
    } else if (N == 1) {
      cout << M-2 << endl;
    } else {
      cout << N-2 << endl;
    }
  } else {
    cout << (N-2) * (M-2) << endl;
  }
  return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define Rep(i, s, n) for (int i = (int)s; i < (int)n; i++)
typedef long long ll;

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

    int n, a, b;
    cin >> n >> a >> b;
    cout << min(n * a, b) << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>
 
using namespace std;
 
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) r.begin(),r.end()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-3;
const double PI = acos(-1);

int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};

int ans[110], d[18];

int calc(int t, int m){
	vi v(18, 0);
	for(int i = 16; i >= 0; i--){
		if(d[i] <= t) v[i] = v[i+1]+1;
	}
	for(int i = 0; i < 17; i++){
		if(v[i] >= m) return i;
	}
	return -1;
}

int main(){
	int n, t=0, idx;
	for(int i = 0; i < 100; i++){
		n = i%5==1?5:2;
		t = max(t,i*5);
		while(1){
			idx = calc(t, n);
			if(idx < 0) {
				t++;
				continue;
			}
			ans[i] = t - i*5;
			for(int j = 0; j < n; j++) d[idx+j] = t + 17*(i%2)+3*(i%3)+19;
			break;
		}
	}
	
	while(cin>>n){
		printf("%d\n", ans[n]);
	}
}

Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define debug(x_) cerr << #x_ << ":" << x_ << endl;
#define debug2(x__) for(auto a__ : x__) cerr << a__ << " "; cerr << endl;
#define debug3(x___ , sx___) rep(i, sx___) cerr << x___[i] << " "; cerr << endl;

vector<pii> around = {MP(1, 0), MP(-1, 0), MP(0, 1), MP(0, -1)};

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

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

//------------------------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, T;
    cin >> n >> T;
    int ans = INF;

    rep(i, n) {
        int c, t;
        cin >> c >> t;
        if (t > T) continue;
        ans = min(ans, c);
    }
    if (ans == INF) cout << "TLE" << endl;
    else cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
using namespace std;
main()
{
    string s,s1;
    cin>>s;
    int ans=0,n=0,n1=0;
    s1=s.substr(0,3);
    stringstream g(s1);
    int p=0;
    g>>p;
    if(p>753)
        ans=p-753;
    else if(p<753)
        ans=753-p;
    else
        ans=0;
    for(int i=0;i<=s.size()-2;i++){
        string s1=s.substr(i,3);
        stringstream g(s1);
        int d=0;
        g>>d;
        if(d>753)
            n=d-753;
        else if(d<753)
            n=753-d;
        else
            n=0;
        if(n<ans)
            ans=n;
    }
    cout<<ans;
}


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

int main() {
	
	long long x;
	cin >> x;
    
	long long MOD = 1000 * 1000 * 1000 + 7;
	long long c = 1;
	for (long long i=1; i<=x; i++) {
		c = c * i;
		c = c % MOD;
	}
	cout << c << endl;
	
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
template<class T> void chmin(T& x, T y){if(x < y) x = y;}
template<class T> void chmax(T& x, T y){if(x > y) x = y;}

int main(){
    int x, a;
    cin >> x >> a;
    cout << (x  < a ? 0 : 10) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define no {cout << "No\n"; return;}

const double PI = 3.1415926535;

void solve() {
    double x; cin >> x;
    cout << fixed << setprecision(10) << 2 * PI * x;
}

signed main(){
   ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   //int t; cin >> t; loop(i, t)
   solve();
   return 0;
}


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

void Cont(){
    int N, M;
    cin >> N >> M;
    vector<long> tenboo(N);
    vector<bool> goodgoods(N);
    for(auto& v : tenboo)
        cin >> v;

    for(int i=0;i<M;i++){
        int Ai,Bi;
        cin >> Ai >> Bi;
        if(tenboo.at(Ai-1) > tenboo.at(Bi-1)){
            goodgoods.at(Bi-1)=1;
        }
        else if(tenboo.at(Ai-1) < tenboo.at(Bi-1)){
            goodgoods.at(Ai-1)=1;
        }
        else{
            goodgoods.at(Ai-1)=1;
            goodgoods.at(Bi-1)=1;
        }
    }
    int sum=0;
    for(const auto& v:goodgoods){
        // cout << v << " ";
        if(v==0)
            sum++;
    }
    cout << sum << "\n";
}

int main()
{
	std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Cont();
}


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

using namespace std;

/*
 * エラトステネスの篩
 *   n 以下の素数を bitset で返す
 */
static bitset<100000 + 1> sieve_of_eratosthenes (long long n) {
    bitset<100000 + 1> prime(0);

    for ( long long i = 2; i <= n; i++ )
        prime.set(i);
    for ( long long i = 2; i <= n; i++ ) {
        if ( prime[i] ) {
            for ( long long j = i * 2; j <= n; j += i ) {
                prime.reset(j);
            }
        }
    }

    return prime;
}

int main (void) {
    bitset<100000 + 1> primes = sieve_of_eratosthenes(100000);
    vector<int> cumsum(100000 + 1, 0);
    for ( int i = 1; i <= 100000; i += 2 ) {
        if ( primes[i] && primes[(i+1)/2] ) {
            cumsum.at(i) = 1;
        }
    }
    for ( int i = 1; i <= 100000; i++ ) {
        cumsum.at(i) += cumsum.at(i-1);
    }

    int Q;
    cin >> Q;
    int l, r;
    for ( int i = 0; i < Q; i++ ) {
        cin >> l >> r;
        cout << cumsum.at(r) - cumsum.at(l-1) << endl;
    }

    return 0;
}


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

int main () {
        long N, M;

        cin >> N >> M;

        if (N >= M / 2) {
                cout << M / 2 << endl;

        } else {
                M -= N * 2;
                cout << N + M / 4 << endl;
        }

        return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  int cnt=0;
  string s;
  cin >> s;
  for(int i=0; i<s.size(); i++) {
    if(s[i]=='o') {
      cnt++;
    }
  }
  if(cnt>=8) {
    cout << "YES" << endl;
    return 0;
  }
  else if(15-s.size()>=8-cnt) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
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; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    int x = (a + d - 1) / d;
    int y = (c + b - 1) / b;

    if (y <= x) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

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

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

int main(){
  int N;
  cin >> N;
  vector<vector<int>> w(N, vector<int> (3));
  REP(i, N)REP(j, 3) cin >> w[i][j];

  vector<vector<int>> dp(N, vector<int> (3, 0));
  REP(j, 3) dp[0][j] = w[0][j];

  for(int i = 1; i < N; ++i) {
    REP(j, 3) {
      REP(k, 3) {
        if(k == j) continue;
        dp[i][j] = max(dp[i][j], dp[i - 1][k] + w[i][j]);
      }
    }
  }

  int ret = 0;
  REP(j, 3) ret = max(ret, dp[N - 1][j]);
  cout << ret << endl;
  return 0;
}



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

typedef long long ll;

bool is_sqr(ll x){
	ll g = static_cast<ll>(sqrt(x));
	for(ll r = max(0ll, g - 5); r <= g + 5; r++)
		if(r * r == x)
			return true;
	return false;
}

ll sqr(ll x){
	ll g = static_cast<ll>(sqrt(x));
	for(ll r = max(0ll, g - 5); r <= g + 5; r++)
		if(r * r == x)
			return r;
	return g;
}

ll pw(ll x, int c){
	switch(c){
		case 0:
			return 1;
		case 1:
			return x;
		case 2:
			return x * x;
		case 3:
			return 1;
	}
	return 0;
}

const int maxn = 100005;
const int maxp = 2200;

map<ll, int>  M;
int n; ll a[maxn], b[maxn];
int pr[maxp], ispr[maxp], pc;

void pre(){
	for(int i = 2; i < maxp; i++){
		if(!ispr[i]){
			pr[++pc] = i;
			for(int j = i; j < maxp; j += i)
				ispr[j] = true;
		}
	}
}

void get(ll x, int p){
	a[p] = b[p] = 1;
	for(int i = 1; i <= pc; i++){
		int cnt_cur = 0;
		while(x % pr[i] == 0)
			++cnt_cur, x /= pr[i];
		cnt_cur %= 3;
		a[p] *= pw(pr[i], cnt_cur), b[p] *= pw(pr[i], 3 - cnt_cur);
	}
	a[p] *= x;
	if(is_sqr(x))
		b[p] *= sqr(x);
	else b[p] *= pw(x, 2);
	++M[ a[p] ];
}

int main(){
	ll cur_x; 
	
	pre();
	scanf("%d", &n);
	for(int i = 1; i <= n; i++){
		scanf("%lld", &cur_x);
		get(cur_x, i);
	}
	
	int ans = 0;
	if(M[1] != 0)
		++ans, M[1] = 0;
	for(int i = 1; i <= n; i++)
		ans += max(M[ a[i] ], M[ b[i] ]), M[ a[i] ] = M[ b[i] ] = 0;
	printf("%d", ans);
	
	return 0;
}

Measured memory_bytes: 14336
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <complex>
#include <bitset>
#include <functional>

using namespace std;
using ll=long long int;

int mergecount(vector<int> &a) {
  int count = 0;
  int n = a.size();
  if (n > 1) {
    vector<int> b(a.begin(), a.begin() + n/2);
    vector<int> c(a.begin() + n/2, a.end());
    count += mergecount(b);
    count += mergecount(c);
    for (int i = 0, j = 0, k = 0; i < n; ++i)
      if (k == c.size())       a[i] = b[j++];
      else if (j == b.size())  a[i] = c[k++];
      else if (b[j] <= c[k])   a[i] = b[j++];
      else                   { a[i] = c[k++]; count += n/2 - j; }
  }
  return count;
}


int main() {
    int n;
    cin >> n;
    vector<vector<int>> cards(n, vector<int>(2));
    for (int i = 0; i < 2; ++i) for (int j = 0; j < n; ++j) {
        cin >> cards[j][i];
    }

    int ans = 1e9;
    vector<pair<int, int>> ar[2];
    vector<int> val(n);
    vector<int> idx(n);
    for (int i = 0; i < (1 << n); ++i) {
        for (auto &v: ar) v.resize(0);

        for (int j = 0; j < n; ++j) {
            int t = (i >> j) & 1;
            int odd = t ^ (j % 2);
            ar[odd].emplace_back(cards[j][t], j);
        }
        if (ar[1].size() != n/2) continue;
        for (auto &v: ar) sort(v.begin(), v.end());

        for (int j = 0; j < n; ++j) {
            tie(val[j], idx[j]) = ar[j%2][j/2];
        }

        bool f = true;
        for (int j = 1; j < n; ++j) {
            if (val[j] < val[j-1]) f = false;
        }
        if (f) {
            // for (auto &e: val) cout << e << " ";
            // cout << endl;
            // for (auto &e: idx) cout << e << " ";
            // cout << endl;
            ans = min(ans, mergecount(idx));
        }
    }

    if (ans == 1e9) ans = -1;
    cout << ans << endl;
    

    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++)
using ll = long long;
using P = pair<int, int>;

int main(){
    int a,b;
    cin >> a >> b;
    if (a != 1 && b!=1) cout << 1 << endl;
    else if (a != 2 && b != 2) cout << 2 <<endl;
    else cout << 3 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
char a[10010],b[10050],c[10005],d[10005];
int x[100005],y[200000];
int main()
{
    int i,n,m,j,k=1,l=0,z=1;;
    k=1;
    scanf("%d",&n);
    for(i=1; i<=n; i++)
    {
        scanf("%d",&y[i]);
        //x[y[i]]=y[i];
        if(y[i]==2&&i!=2)
        {
            l=1;
        }
    }
    i=1;
    if(l==1)
    {
        while(1)
        {
            if(y[i]==2||y[i]==0)
            {
                if(y[i]==0)
                {
                    z=-1;
                }
                break;
            }
            else
            {
                m=i;
                i=y[i];
                y[m]=0;
                k++;
            }

        }
    }else
    {
        k=-1;
    }
    if(z==-1)
    {
        k=-1;
    }
    printf("%d",k);
    return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

string s;

int main() {
	cin >> s;
	cout << s.substr(0, s.size() - 8) << endl;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc145/tasks/abc145_c
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<pair<int, int>> A(N);
    REP(i, N) { cin >> A[i].first >> A[i].second; }
    double sum = 0;
    REP(i, N) {
        FOR(j, i + 1, N) {
            sum += hypot(A[i].first - A[j].first, A[i].second - A[j].second);
        }
    }
    cout << setprecision(10) << 2.0 * sum / N << endl;

    return 0;
}


Measured memory_bytes: 3812
while True:

    a,op,b=input().split()

    a=int(a)
    b=int(b)

    if op=='?':
        break

    if op=='+':
        print(a+b)
    elif op=='-':
        print(a-b)
    elif op=='*':
        print(a*b)
    else:
        print(int(a/b))


Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
 
int main(){
    long int x; cin >> x;
    if(x%11 == 0) cout << (x/11)*2;
    else if(x%11 <= 6) cout << (x/11)*2 + 1;
  	else cout << (x/11)*2 + 2;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
using namespace std;
typedef long long ll;


void solve(){
	int n;
	cin >> n;
	ll x, ma, ans = 0;
	cin >> x;
	ma = x;
	for (int i = 1; i < n; i++){
		cin >> x;
		if (ma > x) ans += ma - x;
		else ma = x;
	}
	cout << ans << endl;
}

int main(){
	int TC = 1;
	//cin >> TC;
	for (int tcc = 1; tcc <= TC; tcc++){
		//cout << "Case #"<< tcc << ": ";
		solve();
	}
	return 0;
		
}

Measured memory_bytes: 3560
using System;
using System.Collections.Generic;
using System.Windows;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    public class Program
    {
        static void Main(string[] args)
        {
            var N = Console.ReadLine().ToInt();
            var S = Console.ReadLine();
            if (N % 2 != 0)
            {
                Console.WriteLine("No");
                return;
            }
            var n2 = N / 2;
            if (S.Substring(0, n2) == S.Substring(n2, n2))
            {
                Console.WriteLine("Yes");
                return;
            }
            Console.WriteLine("No");
            return;
        }
    }
}

public static class Extentions
{
    public static int ToInt(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static decimal ToDecimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double ToDouble(this object obj)
    {
        return double.Parse(obj.ToString());
    }
}



Measured memory_bytes: 11092
import Control.Applicative

main = do
  [x, y, z] <- words <$> getLine
  let a = read x :: Int
  let b = read y :: Int
  let c = read z :: Int

  if (a < b) && (b < c) then
    putStr "Yes"
  else
    putStr "No"
  putChar '\n'

Measured memory_bytes: 3504
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
int n, m, d[209] = {0,300000,200000,100000};

int main(){
	scanf("%d%d", &n, &m);
	printf("%d\n", d[n] + d[m] + (n+m == 2 ? 400000 : 0));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>
// using namespace __gnu_pbds;
using namespace std;
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
//     tree_order_statistics_node_update>;
 
typedef long long int ll;
const ll N = 5001;
// const ll m = 1e9 + 7;
const ll inf= 1ll<<62;
#define x first
#define y second
#define pb push_back
#define mp make_pair
using pii = pair<ll, ll>;
const ll mod = 1e9+7;
ll powm(ll a, ll b) { a = a%mod;ll res = 1; while (b) { if (b & 1) res = (res * a) % mod; a = (a * a) % mod; b >>= 1; } return res; }


int main()
{    
     #ifndef ONLINE_JUDGE
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
     #endif     
     ll t = 1;
     // cin>>t;
     while(t--){
          ll k,a,b;cin>>k>>a>>b;
          bool f = 1;
          for(int i = k;i<=b;i+=k){
               if(i>=a && i<=b){
                    f = 0;
                    break;

               }
          }
          if(f){
               cout<<"NG"<<'\n';
          }
          else{
               cout<<"OK"<<'\n';
          }
     }
     return 0;
}

Measured memory_bytes: 3636
#include <iostream>
using namespace std;
int main () {

	int n,m;
	cin>>n>>m;
	long long int br=1;
	if (m>n) {swap(n,m);}
	if (n-1>m) {cout<<0; return 0;}
	if (n==m) {
		int b=n-1;
		while (b>0) {
			br=br*b;
			br=br%1000000007;
			br=br*b;
			br=br%1000000007;
			b--;
		}
		cout<<(((br*(n+m))%1000000007)*m)%1000000007; return 0;
	}
	else {
		while (n>0) {
			br=br*n;
			n--;
			br=br%1000000007;
		}
		while (m>0) {
			br=br*m;
			m--;
			br=br%1000000007;
		}
		cout<<br;
	}
		
return 0;
}

Measured memory_bytes: 256
import java.util.*;


public  class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int payment = sc.nextInt();
        int one_yen_count = sc.nextInt();
        System.out.println(payment % 500 > one_yen_count ? "No" : "Yes");
    }
}

Measured memory_bytes: 20820
#include <stdio.h>
int main (){
	int alas,tinggi,sisi_miring,luas;	
	scanf("%d %d %d",&alas,&tinggi,&sisi_miring);
	luas = alas * tinggi/2;
	printf("%d",luas);
		
	
	
	
	
	return 0;
}

Measured memory_bytes: 1704
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
typedef long long ll ;
int main() {
  int n ;
  cin >> n ;
  string N , M ;
  cin >> N >> M ;
  string T ;
  rep(i,n){
    T[2*i] = N[i] ;
    T[2*i+1] = M[i] ;
  }
 rep(i,2*n) cout << T[i] ;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 10e+6
#define DEKA 1000000007

using namespace std;

int main(){
    double w,h,x,y;
    cin >> w >> h >> x >>y;
    double ans=w*h/2;
    
    if(x*2==w && y*2==h) {//1
        printf("%.12f",ans);
        cout << " " << 1 << endl;
    }
    else {//0
       printf("%.12f",ans);
        cout << " " << 0 << endl;
    }
}



Measured memory_bytes: 256
a,s=map(int,input().split())
if abs(a-s)>1:print(0)
else:
  ans=1
  mod=10**9+7
  if a==s:
    for i in range(1,a+1)[::-1]:
      ans=ans*i%mod
    ans=2*(ans**2)%mod
  else:
    M=max(a,s)
    for i in range(1,M):
      ans=ans*i%mod
    ans=(M%mod)*(ans**2)%mod
  print(ans)

Measured memory_bytes: 3064
N = input()
N = int(N)
str = input().split()
H = []
i = 0
j = 0
for i in range(N):
  H.append( int(str[i]) )
flag = 0
ans = 0
for i in range(N):
  for j in range(i):
    if H [i] < H[j]:
      flag =  1
      break
    else:
      flag = 0
  if flag == 0:
    ans = ans+1
  flag = 0

print(ans)

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

int main() {
int n;
cin >> n;

vector<int> a(n + 1);
vector<int> past(n + 1);

for (int i = 1; i <= n; i++) cin >> a.at(i);

int count = 0;
int current = 1;
past.at(1) = 1;
int answer = -1;

for (int i = 1; i <= n; i++) {
    current = a.at(current);
    count++;
    if (past.at(current) == 1) {
        break;        
    } else {
        past.at(current) = 1;
        if (current == 2) {
            answer = count;
            break;
        }
    }
}

cout << answer << endl;

return 0;
}

Measured memory_bytes: 4040
n,k = map(int,input().split())
ass = 0
for i in range(1,n+1):
    if 2*i%k == 0:
        x = 2*i//k
        y = (n+i)//k
        w = y-x+1
        if w == 1:
            ass += 1
        elif w == 2:
            ass += 7
        else:
            ass += 1 + 6*w-6 + 6*(w-1)*(w-2)//2
        #print(i,ass)
print(ass)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;
#define N 100007
#define mod 1000000000000000000
#define pb push_back
vector<ll> v[N];
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
int main()
{
    ll a,b;
    cin>>a>>b;
    cout<<a*b;
    
}

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

using namespace std;

const long long MOD = 1000000007;

void Main() {
    long long N;
    cin >> N;

    long long ans = 1LL;
    long long without09 = 1LL;
    long long without0 = 1LL;
    long long without9 = 1LL;
    for (long long i = 0; i < N; ++i) {
        ans *= 10;
        without09 *= 8;
        without0 *= 9;
        without9 *= 9;
        ans %= MOD;
        without09 %= MOD;
        without0 %= MOD;
        without9 %= MOD;
    }
    ans -= without0;
    ans %= MOD;
    ans -= without9;
    ans %= MOD;
    ans += without09;
    ans %= MOD;
    if (ans < 0) {
        ans += MOD;
    }
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int main()
{
	int A;
	int B;
	cin >> A >> B;
	int Min_tax;
	int X;
	int Y;
	
	for(int i = 1;i<2000;i++){
		Min_tax = i;
		X = Min_tax*8/100;
		Y = Min_tax*10/100;
		if(A==X && B==Y){
			cout << Min_tax << endl;
			return 0;
		}
	}
	cout << "-1" << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n)
using namespace std;

static const int N = 100;

int main(){
  int M[N][N];
  int n, u, k, v;

  cin >> n;

  REP(i, n) {
    REP(j, n) {
      M[i][j] = 0;
    }
  }

  REP(i, n) {
    cin >> u >> k;
    u--;
    REP(j, k) {
      cin >> v;
      v--;
      M[u][v] = 1;
    }
  }

  REP(i, n) {
    REP(j, n) {
      if ( j ) cout << " ";
      cout << M[i][j];
    }
    cout << endl;
  }

  return 0;
} 

Measured memory_bytes: 3096
n = int(input())
t,a = map(int,input().split())
h = list(map(int,input().split()))
minabs = 10**10

for i in range(n):
  if abs(a-(t-h[i]*0.006)) < minabs:
    minabs = abs(a-(t-h[i]*0.006))
    j = i

print(j+1)

Measured memory_bytes: 3060
#include <iostream>
#include <fstream>
using namespace std;
#define N 14

void find_print(int A[]) {
    int i;
    char s = A[0];
    for (i = 1; i < N; i++) {
        if (!A[i])
            cout << s <<" "<< i << endl;
    }
}

int main()
{
    #ifdef debug
    ifstream cin("in.txt");
    #endif

    int n, k, i = 0;
    char s;
    int S[N] = {0}, H[N] = {0}, C[N] = {0}, D[N] = {0};
    S[0] = 'S';
    H[0] = 'H';
    C[0] = 'C';
    D[0] = 'D';
    cin >> n;
    while((cin >> s >> k) && ((i++) < n)) {
        switch(s) {
          case 'S': S[k] = 1;break;
          case 'H': H[k] = 1;break;
          case 'C': C[k] = 1;break;
          case 'D': D[k] = 1;break;
          }
    }
    find_print(S);
    find_print(H);
    find_print(C);
    find_print(D);

    #ifdef debug
    fclose(stdin);
    #endif // a
    return 0;
}



Measured memory_bytes: 3100
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>

using namespace std;

#define ll long long int

template<typename T>
class SegmentTree{
    int n;
    int realsize;
    T initialvalue;
    vector<T> tree;

    public:
    
    SegmentTree(int size,T initial):realsize(size),initialvalue(initial){
        n = 1;
        while(n < size)n *= 2;

        tree = vector<T>(2*n + 1,initial);
    }

    //1-indexed
    void insert(int i,T data){
        int ind = n+i-1;
        tree[ind] = data;
        ind >>= 1;
        while(ind > 0){
            tree[ind] = tree[ind*2] + tree[ind*2+1];
            ind >>= 1;
        }
    }

    void add(int i,T data){
        int ind = n+i-1;
        tree[ind] += data;
        ind >>= 1;
        while(ind > 0){
            tree[ind] = tree[ind*2] + tree[ind*2+1];
            ind >>= 1;
        }
    }

    T get(int l,int r){
        if(l > realsize || r > realsize || l <= 0 || r <= 0)return initialvalue;
        l = n+l-1;
        r = n+r-1;
        if(l == r)return tree[l];
        int prel = l;
        int prer = r;
        T lnum = tree[l];
        T rnum = tree[r];
        l >>= 1;
        r >>= 1;
        while(l != r){
            if(l*2 == prel){
                lnum += tree[l*2+1];
            }
            if(r*2+1 == prer){
                rnum += tree[r*2];
            }
            prel = l;
            prer = r;
            l >>= 1;
            r >>= 1;
        }
        return lnum+rnum;
    }
};

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n;
    cin >> n;
    vector<pair<ll,ll>> a;
    for(int i = 0; i < n; i++){
        ll t;
        cin >> t;
        a.push_back(make_pair(t,i));
    }

    vector<pair<ll,ll>> asc = a;
    sort(asc.begin(),asc.end());

    SegmentTree<ll> st = SegmentTree<ll>(n,0);

    int idx = 0;

    ll ans = 0;

    while(idx < n){
        deque<ll> dq;
        ll t = asc[idx].first;
        dq.push_back(asc[idx].second);
        idx++;
        while(idx < n && asc[idx].first == t){
            dq.push_back(asc[idx].second);
            idx++;
        }
        while(!dq.empty()){
            ll fr = dq.front();
            ll bc = dq.back();
            ll frleft = fr - st.get(1,fr);
            ll frright = n-fr-1 - st.get(fr+2,n);
            ll bcleft = bc - st.get(1,bc);
            ll bcright = n-bc-1 - st.get(bc+2,n);
            ll frm =min(frleft,frright);
            ll bcm = min(bcleft,bcright);
            if(frm > bcm){
                ans += bcm;
                st.add(bc+1,1);
                dq.pop_back();
            }else{
                ans += frm;
                st.add(fr+1,1);
                dq.pop_front();
            }
        }
    }

    cout << ans << endl;

    
    return 0;
}


Measured memory_bytes: 8648
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
	while (true) {
		int N;
		cin >> N;
		if(N == 0) break;
		string c;
		cin >> c;
		int maisu[10];
		for(int i = 0; i < N; i++) {
			maisu[i] = 0;
		}
		int ba = 0;
		int turn = 0;
		for(int i = 0; i < c.size(); i++) {
			if(c[i] == 'M') {
				maisu[turn]++;
			}
			else if(c[i] == 'S') {
				maisu[turn]++;
				ba += maisu[turn];
				maisu[turn] = 0;
			}
			else {
				maisu[turn]++;
				maisu[turn] += ba;
				ba = 0;
			}
			turn++;
			turn %= N;
		}
		sort(maisu, maisu+N);
		for(int i = 0; i < N; i++) {
			cout << maisu[i] << " ";
		}
		cout << ba << endl;
	}

	return 0;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b) - 1; (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll fac(ll n){
    if (n > 0) {
        return  n * fac(n - 1);
    }else{
        return 1;
    }
}

int main()
{
    ll n,k,ans = 10e9;
    cin >> n >> k;
    vector<ll> h(n);
    rep(i, n)cin >> h[i];
    sort(h.begin(), h.end());
    rep(i, n - k + 1){
        ans = min(h[i + k - 1] - h[i], ans);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define boost ios_base::sync_with_stdio(false)
#define pb push_back
#define e1 first
#define e2 second
#define x first
#define y second
#define tysiac 1010
#define milion 1000100
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define OUT(x) { cout << x; return 0; }
#define PRINT(x, y) {printf("%d %d\n", x, y); return;} 
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define scanf(...) scanf(__VA_ARGS__)?:0
typedef long long int ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef double ld;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;
typedef pair <ld, ld> PDD;
typedef pair <PII, PII> PP;
typedef pair <ll, int> PLI;
typedef pair <double, int> PDI;
typedef vector <int> vi;
#define N 100100
vector<int> g[N];
int deg[N],val[N],tv[N];
int id[N],cnt;
bool del[N];
int main(){
	long long ans=0;
	int n,m,x,y;
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++){
		scanf("%d%d",&x,&y);
		g[x].push_back(y);
		g[y].push_back(x);
		deg[x]++;
		deg[y]++;
	}
	queue<int> q;
	for(int i=1;i<=n;i++){
		if(deg[i]==1) q.push(i);
		val[i]=1;
	}
	while(!q.empty()){
		int u=q.front();
		q.pop();
		if(deg[u]!=1){
			continue;
		}
		del[u]=true;
		ans+=abs(val[u]);
		for(int i=0;i<g[u].size();i++){
			int v=g[u][i];
			if(del[v]) continue;
			val[v]-=val[u];
			if(--deg[v]==1) q.push(v);
		}
	}
	for(int i=1;i<=n;i++){
		if(!del[i]){
			while(1){
				del[i]=true;
				id[cnt++]=i;
				int nxt=-1;
				for(int j=0;j<g[i].size();j++){
					if(del[g[i][j]]) continue;
					nxt=g[i][j];
					break;
				}
				if(nxt<0) break;
				i=nxt;
			}
			break;
		}
	}
	if(cnt==1){
		if(val[id[0]]) puts("-1");
		else printf("%lld\n",ans);
	}
	else if(cnt&1){
		long long tmp=0;
		for(int i=0;i<cnt;i++){
			tmp+=val[id[i]];
		}
		if(tmp&1) puts("-1");
		else{
			tmp>>=1;
			for(int i=1;i<cnt;i+=2){
				tmp-=val[id[i]];
			}
			for(int i=0;i<cnt;i++){
				ans+=abs(tmp);
				tmp=val[id[i]]-tmp;
			}
			printf("%lld\n",ans);
		}
	}
	else{
		long long tmp=0;
		for(int i=0;i<cnt;i++){
			if(i&1) tv[i]=-tmp;
			else tv[i]=tmp;
			tmp=val[id[i]]-tmp;
		}
		if(tmp) puts("-1");
		else{
			sort(tv,tv+cnt);
			for(int i=0;i<cnt-1-i;i++){
				ans+=tv[cnt-1-i]-tv[i];
			}
			printf("%lld\n",ans);
		}
	}
	return 0;
}


Measured memory_bytes: 7424
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] t = new long[N];

        for (int i = 0; i < N; i++) {
            t[i] = sc.nextLong();
        }

        if (N == 1) {
            System.out.println(t[0]);
            return;
        }

        long ans = lcm(t[0], t[1]);
        for (int i = 2; i < N; i++) {
            ans = lcm(ans, t[i]);
        }
        System.out.println(ans);
    }

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

    static long gcd(long a, long b) {
        if (a < b) {
            long tmp = a;
            a = b;
            b = tmp;
        }

        long r = -1;
        while (r != 0) {
            r = a % b;
            a = b;
            b = r;
        }
        return a;
    }
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
int n, a[100005], f[100005];
int main() {
    int ans = 0;
    cin >> n;
    for (int i = 1; i <= n; i ++) cin >> a[i];
    for (int i = 1; i < n; i ++) {
        if (a[i] == i) swap(a[i], a[i + 1]), ans ++;
    }
    if (a[n] == n) swap(a[n - 1], a[n]), ans ++;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		for(;;){
			int n = sc.nextInt();
			if(n==0)break;
			
			double st = 0;
			double m = 0;
			double to = 0;
			double a = 0;
			double[] s = new double[n];
			for(int i=0; i<n; i++){
				s[i] = sc.nextDouble();
				st += s[i];
			}
			m = st/n;
			for(int i=0; i<n; i++){
				to += Math.pow(s[i]-m, 2);
			}
			a = Math.sqrt(to/n);
			System.out.println(a);
		}
	}
}

Measured memory_bytes: 39076
#include<cstdio>
#include<iostream>
#include<algorithm>

using namespace std;
bool cmp(int a,int b)
{
	return a>b;
}
long long n,k,h;
int a[60];
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	sort(a+1,a+1+n,cmp);
	for(int i=1;i<=k;i++)
	{
		h+=a[i];
	}
	cout<<h;
return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> c(n), w(n);
    for(int i=0; i<n; ++i)
        cin >> c[i] >> w[i];

    vector<int> wSum(n+1, 0);
    for(int i=0; i<n; ++i)
        wSum[i+1] = wSum[i] + w[i];

    vector<vector<bool> > check(n, vector<bool>(n, false));
    for(int i=0; i<n; ++i)
        check[i][i] = true;
    for(int i=1; i<n; ++i){
        for(int j=0; j+i<n; ++j){
            int k = i + j;
            if((check[j+1][k] && wSum[k+1] - wSum[j+1] <= c[j]) || (check[j][k-1] && wSum[k] - wSum[j] <= c[k]))
                check[j][k] = true;
        }
    }

    vector<int> dp(n+1, INT_MAX / 2);
    dp[0] = 0;
    for(int i=0; i<n; ++i){
        for(int j=i; j<n; ++j){
            if(check[i][j])
                dp[j+1] = min(dp[j+1], dp[i] + 1);
        }
    }
    cout << dp[n] << endl;

    return 0;
}

Measured memory_bytes: 1384
#include <bits/stdc++.h>
    #include <string>
          #define ll long long int
          #define N 4000
          #define f(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
          #define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
          #define po pop_back
          #define pb push_back
          #define pp pair<ll,ll>
          #define lb lower_bound
          #define fi first
          #define se second
          #define debug(x) cout << #x << " = " << x << endl
          #define ub upper_bound
          #define ibs ios_base::sync_with_stdio(false)
          #define cti cin.tie(0)
          #define all(x) x.begin(),x.end()
          #define PI 3.14159265
          #define cot cout.tie(0)
          using namespace std;
         /**
          * @author :: Sawlani
          *
          */
          ll n,t;
           ll a[N+1];
           ll b[N+1];

           ll dp[N+1][N+1];

           ll rec(ll idx,ll tim)
           {
               if(tim<=0)
                return 0;
               if(idx>n)
                return 0;

               if(dp[idx][tim]!=-1)
                return dp[idx][tim];


               ll ans=LONG_MIN;
               ans=max({ans,b[idx]+rec(idx+1,tim-a[idx]),rec(idx+1,tim)});

                return dp[idx][tim]=ans;

           }

          int main()
          {
              cin >>  n >>  t;
              memset(dp,-1,sizeof(dp));
               vector <pair <ll,ll> >  vp;
              f(i,1,n)
              {
                  cin >> a[i] >>  b[i];

                  vp.pb({a[i],b[i]});
              }
              sort(all(vp));

              ll k=1;
              for(auto i:vp)
              {
                a[k]=i.fi;
                b[k++]=i.se;

              }

              cout <<  rec(1,t) << endl;


          }


Measured memory_bytes: 125568
from sys import stdin
from collections import deque

def read_graph(n):
    A = [ [0]*(n+1) for _ in range(n+1) ]
    for _ in range(n):
        line = deque(stdin.readline().strip().split())
        i = line.popleft()
        line.popleft()
        for k in line:
            A[int(i)][int(k)] = 1
    return A

def bfs_ctrl(n, A):
    color = ["WHITE"] * (n+1)
    d = [-1] * (n+1)
    Q = deque([])

    def bfs(s):
        nonlocal color
        nonlocal d
        nonlocal Q
        color[s] = "GRAY"
        d[s] = 0
        Q.append(s)

        while Q:
            u = Q.popleft()
            for v in range(1, n+1):
                if A[u][v] and color[v] == "WHITE":
                    color[v] = "GRAY"
                    d[v] = d[u] + 1
                    Q.append(v)

            color[u] = "BLACK"

    bfs(1)
    for i in range(1, n+1):
            print(i, d[i])

n = int(input())
A = read_graph(n)
bfs_ctrl(n, A)


Measured memory_bytes: 6108