akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    matrix c(3,Vi(3));
    rp(i,3){
        rp(j,3){
            cin >> c[i][j];
        }
    }
    bool ok=true;
    if(!(c[1][0]-c[0][0]==c[1][1]-c[0][1]&&c[1][2]-c[0][2]==c[1][0]-c[0][0])) ok=false;
    if(!(c[2][0]-c[1][0]==c[2][1]-c[1][1]&&c[2][2]-c[1][2]==c[2][0]-c[1][0])) ok=false;
    Yes(ok);
    return;
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

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

int main() {
    string s;
    cin >> s;
    int ans = 0;
    int cnt = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'A' || s[i] == 'G' || s[i] == 'C' || s[i] == 'T') {
            cnt++;
        } else {
            ans = max(ans, cnt);
            cnt = 0;
        }
    }
    ans = max(ans, cnt);
    cout << ans << endl;
}

Measured memory_bytes: 256
k,x=map(int,input().split())
if x-k<-1000000:
	a=-1000000
else:
	a=x-k+1
if x+k>1000000:
	b=1000000
else:
	b=x+k-1
aa=[]
for i in range(a,b+1):
	aa.append(i)
print(*aa)


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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

typedef long long ll;

using namespace std;
int main()
{
    int N;
    vector<int> a;
    cin >> N;
    REP(i, N)
    {
        int tmp;
        cin >> tmp;
        a.push_back(tmp);
    }

    sort(a.begin(), a.end());
    int ans = a[N -1] - a[0];
 
    cout << ans << endl;
}


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

int main(){
  int a,b,c,d,e,f=0;
  cin>>a>>b;
  /*if(10000*a<b)
    c*/
  for(int i=0;i<=a;i++){
    for(int j=0;j<=a-i;j++){
      if(10000*i+5000*j+1000*(a-i-j)==b){
        c=i;
        d=j;
        e=a-i-j;
        f=1;
        break;
      }
    }
    if(f==1)
      break;
  }
  if(f==0){
  c=-1;
  d=-1;
  e=-1;
}
  cout<<c<<' '<<d<<' '<<e<<endl;
}

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

int main() {
  ll n, ans = 0;
  cin >> n;
  rep(i,n) {
    ll x;
    cin >> x;
    while(x%2==0) {
      x /= 2;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3584
#[allow(unused_imports)]
use std::io::{stdin, Read, StdinLock};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::{HashSet, HashMap, BinaryHeap};
#[allow(unused_imports)]
use std::vec::Vec;

#[allow(dead_code)]
const INF: i32 = 1000_000_000;
#[allow(dead_code)]
const INFLL: i64 = 1000_000_000_000_000_000;
#[allow(dead_code)]
const EPS: f64 = 1.0e-10;

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

impl<'a> Scanner<'a> {
    #[allow(dead_code)]
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner {cin: cin}
    }

    #[allow(dead_code)]
    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
                    .skip_while(|c| c.is_whitespace())
                    .take_while(|c| !c.is_whitespace())
                    .collect::<String>();
        token.parse::<T>().ok()
    }

    #[allow(dead_code)]
    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);
    let x: i32 = sc.read();
    let y: i32 = sc.read();
    let z: i32 = sc.read();
    println!("{}", (x - z) / (y + z));
}

Measured memory_bytes: 4352
////////////
//||||| ||//
//   || ||//
//||||||||//
//|| ||   //
//|| |||||//
////////////
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define   ll  long long int
#define   dl double
#define   llu unsigned long long int
#define   scll(x) scanf("%lld",&x)
#define   scld(x) scanf("%lf",&x)
#define   scull(x) scanf("%llu",&x)
#define   scch(x) scanf(" %c",&x)
#define   eb(x)   emplace_back(x)
#define   pb(x) push_back(x)
#define   pf(x) push_front(x)
#define   ppb() pop_back()
#define   ppf() pop_front()
#define   Pi acos(-1.0)
#define   inf 1000000000000000000
#define   mod 1000000007
#define   ff first
#define   ss second
#define   mpr make_pair
#define   debug(x) cout<<x<<'\n';
#define   MAX 1000000
#define   eps 1e-8
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_multiset;
//Taking input by EOF
//while(scanf("%lld",&x)!=-1){ }
// Creates a min heap
//priority_queue <int, vector<int>, greater<int> > pq;
//sin((x*pi)/180.0)[x in degree]
//sin(x)[x in radian]
//asin(x)[radian]
//(asin(x)*180)/pi[degree]
//or(|)//and(&)//xor(^)//not(~)
//S.order_of_key(x)[Give me the position of x]
//S.find_by_order(x)[Give me the x th element in set]
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll lcm(ll a, ll b) {return (a * b) / __gcd(a, b);}
vector<ll>parent(100005,0);
void make_set(ll n)
{
    for(int i=1;i<=n;i++)
    {
        parent[i]=i;
    }
}
ll find_parent(ll u)
{
    if(parent[u]==u)
        return u;
    else
        return parent[u]=find_parent(parent[u]);
}
void make_union(ll u,ll v)
{
    ll paru=find_parent(u);
    ll parv=find_parent(v);
    if(paru==parv)
        return;
    else
        parent[parv]=paru;
}
int main()
{
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  ll a, b, c = 1, d, e, f = 0, g, h, i, j = 0, k, m, n, o, p, s, t, v, w, x = 0, y, z, l,res=0;
  ll cnt = 0, l1 = 0, l2, l3, c1 = 0, c2 = 0, c3 = 0, mx = 0, mn = 0;
  ll prevsum = 0, ans1 = 0, ans2 = 0, odd = 0, even = 0, hh, mm,u;
  string str, str1, str2, str3 = "", str4 = "";
  ll ide = 0, idx = 0, Q;
    scll(n);
    scll(m);
    make_set(n);
    for(i=0;i<m;i++){
        scll(u);
        scll(v);
        make_union(u,v);
      }
   for(i=1;i<=n;i++)
    {
        parent[i]=find_parent(parent[i]);
    }
    set<ll>st;
    for(i=1;i<=n;i++)
    {
        st.insert(parent[i]);
    }

    cout<<st.size()-1;




  return 0;
}

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

void solve(long long x){
  long long ans = 0;
	if (x <= 6) { ans = 1; }
  else if (x <= 11) { ans = 2; }
  else {
    if (x % 11 == 0) {
      ans = x / 11 * 2;
    } else if (x % 11 <= 6) {
      ans = x / 11 * 2 + 1;
    } else if (x % 11 <= 10) {
      ans = x / 11 * 2 + 2;
    }
  }
  cout << ans << endl;
}

int main(){	
	long long x;
	scanf("%lld",&x);
	solve(x);
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define INF 1000000011
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
using namespace std;
typedef long long ll;
 
ll pow(ll a, ll y){
  ll p=1;
  while(a>=1){
    p*=y;
    p=p%998244353;
    a-=1;}
  return p;}


int main(){
 ll n;
  cin>>n;
  ll num[n+1];
  ll max=0;
  for(int i=1;i<=n;i++){
    num[i]=0;
    ll a;
    cin>>a;
    if(max<=a){
      max=a;}
    num[i]=a;}
  
  ll kyo[100002];
  rep(i, 100002){
    kyo[i]=0;}
  
  for(int i=1;i<=n;i++){
    kyo[num[i]]++;
  if(num[i]==0 && i>=2){
    cout<<0<<endl;
    return 0;}
  }
  
  if(num[1]!=0){
  cout<<0<<endl;
    return 0;}
  
    

  ll ans=1;
  ll bev=1;
  
  for(ll i=1;i<=100001;i++){
    
    if(i<=max&&kyo[i]==0){
      cout<<0<<endl;
      return 0;}
    
    if(i>=1 && kyo[i]>=1){
      ans*=pow(kyo[i], bev);
      ans%=998244353;
      bev=kyo[i];
     }
     
    
   
  }
    
  cout<<ans<<endl;
  return 0;
  
  
  
}

Measured memory_bytes: 1792
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {

            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {

            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }

       




        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var o = Console.ReadLine().ToArray();
            var e = Console.ReadLine().ToArray();
            for (int i = 0; i < e.Length; i++)
            {
                Console.Write(o[i]);
                Console.Write(e[i]);
            }
            if (o.Length > e.Length) Console.Write(o[o.Length - 1]);
            Console.WriteLine();

            Console.Out.Flush();
        }
    }
}




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

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vs = vector<string>;
using vvl = vector<vl>;
using pll = pair<ll,ll>;
using vb = vector<bool>;

const ll oo = 0x3f3f3f3f3f3f3f3fLL;
const double eps = 1e-9;

#define sz(c) ll((c).size())
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define xx first
#define yy second

#define has(c,i) ((c).find(i) != end(c))
#define FOR(i,a,b) for (int i=(a); i<(b); i++)
#define FORD(i,a,b) for (int i=int(b)-1; i>=(a); i--)

#define rv(type,name,count) vector<type> name(count); FOR(_i,0,count) cin >> name[_i];
#define grid(type,name,c1,c2) vector<vector<type>> name(c1, vector<type>(c2)); FOR(_i,0,c1)FOR(_j,0,c2)cin >> name[_i][_j];

int main() {
	ll n;
	cin >> n;
	vl v(n);
	FOR(i,0,n) cin >> v[i];
	vl best(n);
	best[0] = 0;
	best[1] = abs(v[1] - v[0]);
	FOR(i,2,n) {
		best[i] = min(best[i-1] + abs(v[i]-v[i-1]), best[i-2] + abs(v[i]-v[i-2]));
	}
	cout << best[n-1] << endl;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int n, q;
int a[100000];
int x;
int cfrom, cto;
LL pref[100001], suf[100001];

bool check(int turns) {
    int taka = (turns + 1) / 2;
    int aoki = turns / 2;
    int lo = 0, hi = n - aoki, mid;
    while (lo < hi) {
        mid = (lo + hi) / 2;
        int from = mid;
        int to = mid + aoki - 1;
        bool ok;
        if (a[to] - x >= x - a[from]) {
            ok = (from == 0 || a[to] - x < x - a[from - 1]);
            if (!ok) {
                hi = mid - 1;
            }
        } else {
            ok = (to == n - 1 || a[to + 1] - x >= x - a[from]);
            if (!ok) {
                lo = mid + 1;
            }
        }
        if (ok) {
            lo = hi = mid;
            break;
        }
    }
    cfrom = lo;
    cto = lo + aoki - 1;
    return cto < n - taka;
}

LL solve(int _x) {
    x = _x;
    int lo = 1, hi = n, mid;
    while (lo < hi) {
        mid = (lo + hi + 1) / 2;
        if (check(mid)) {
            lo = mid;
        } else {
            hi = mid - 1;
        }
    }
    LL res = suf[n - (lo + 1) / 2];
    res += pref[n - lo];
    return res;
}

int main() {
//    freopen("input.txt", "r", stdin);
    scanf("%d%d", &n, &q);
    forn(i, n) scanf("%d", a + i);
    pref[0] = 0;
    forn(i, n) {
        if (i % 2 != n % 2) {
            pref[i + 1] = pref[i] + a[i];
        } else {
            pref[i + 1] = pref[i];
        }
    }
    suf[n] = 0;
    for (int i = n - 1; i >= 0; --i) {
        suf[i] = suf[i + 1] + a[i];
    }
    forn(_, q) {
        int x;
        scanf("%d", &x);
        LL res = solve(x);
        printf("%lld\n", res);
    }
    return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <cstdio>

using namespace std;

long long N;

long long dfs(long long x, bool b3, bool b5, bool b7)
{
    if(x > N)
    {
        return 0LL;
    }

    return (long long)(b3 && b5 && b7) + dfs(x * 10 + 3,true, b5, b7) + dfs(x * 10 + 5, b3, true, b7) + dfs(x * 10 + 7, b3, b5,true);
}

int main()
{
    cin >> N;

    cout << dfs(0LL, false, false, false) << endl;

    return 0;
}

Measured memory_bytes: 888
# -*- coding: utf-8 -*-
# 整数の入力
p=str(input())
c = 0
for i in range(0,len(p)-1):
    if (int(p[i+1]) - int(p[i])) == 0:
        c+=1
    else:
        pass
if c !=0:
    print("Bad")
else:
    print("Good")
  

Measured memory_bytes: 2940
using System;
//using System.Collections.Generic;
//using System.Collections;
using System.Linq;

namespace solution
{
  class Class1
  {
    static void Main()
    {
      int n = int.Parse(Console.ReadLine());
      int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
      int[] y = Console.ReadLine().Split().Select(int.Parse).ToArray();

      double sum = 0;
      for (int i = 0; i < n; i++)
      {
        sum += Math.Abs(x[i] - y[i]);
      }
      Console.WriteLine(sum);

      sum = 0;
      for (int i = 0; i < n; i++)
      {
        sum += (Math.Pow((x[i] - y[i]), 2));
      }
      Console.WriteLine(Math.Sqrt(sum));

      sum = 0;
      for (int i = 0; i < n; i++)
      {
        sum += (Math.Pow(Math.Abs(x[i] - y[i]), 3));
      }
      Console.WriteLine(Math.Pow(sum, 1.0 / 3.0));

      double[] inf = new double[n];
      for (int i = 0; i < n; i++)
      {
        inf[i] = Math.Abs(x[i] - y[i]);
      }
      Console.WriteLine(inf.Max());
    }
  }
}




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

using namespace std;

int a,b,ans;
string s;

int main()
{
    cin >> a >> b >> s;
    for (int i = 0; i <= a+b; i++)
    {
        if (i!=a&&s[i]!='-') ans++;
        if (i==a&&s[i]=='-') ans++;
    }
    if (ans==a+b+1) cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			int m = sc.nextInt();
			int p = sc.nextInt();
			if (n == 0 && m == 0 && p == 0)
				break;
			int[] x = new int[n];
			int sum = 0;
			for (int i = 0; i < n; i++) {
				x[i] = sc.nextInt();
				sum += x[i];
			}
			int s = sum * 100;
			s *= (100 - p);
			s /= 100;
			if (x[m - 1] != 0)
				s /= x[m - 1];
			if (x[m - 1] == 0)
				s = 0;
			System.out.println(s);
		}
		sc.close();
	}
}

Measured memory_bytes: 27692
from sys import setrecursionlimit


def genid(a, b):
    if b < a:
        a, b = b, a
    return a * 100000 + b


def paint(currentNode, usedColor, parentNode, edges, colors):
    color = 1
    for childNode in edges[currentNode]:
        if childNode == parentNode:
            continue
        if color == usedColor:
            color += 1
        colors[genid(currentNode, childNode)] = color
        paint(childNode, color, currentNode, edges, colors)
        color += 1


setrecursionlimit(100000)

N = int(input())
ab = [list(map(int, input().split())) for _ in range(N - 1)]

edges = [[] for _ in range(N)]
for a, b in ab:
    edges[a - 1].append(b - 1)
    edges[b - 1].append(a - 1)

colors = {}
paint(0, -1, -1, edges, colors)

print(max(len(e) for e in edges))
for a, b in ab:
    print(colors[genid(a - 1, b - 1)])

Measured memory_bytes: 82836
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
inline long long mod(long long n,long long m){return(n%m+m)%m;}
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    int a,b; cin>>a>>b;
    if(b%a==0) cout<<a+b<<endl;
    else cout<<b-a<<endl;
    return 0;
}


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

int l[101][101] = {}, u[101][101] = {};

int main(){
    int n, m, d;
    char x;
    cin >> n >> m >> d;

    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            cin >> x;
            if(x == '.'){
                u[i][j] = u[i-1][j]+1;
                l[i][j] = l[i][j-1]+1;
            }    
        }
    }

    int ans = 0;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            ans += (l[i][j] >= d) + (u[i][j] >= d);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3172
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define ll long long

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    int n, x;
    cin>>n>>x;
    int a[n];
    f(i, n) cin>>a[i];
    vector<ll> go;
    f(i, n) go.pb(abs(a[i] - x));
    ll ans = 0;
    f(i, n) ans = __gcd(ans, go[i]);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1784
import math
x = int(input())

if x<=6:
    print(1)
elif 7<=x<=11:
    print(2)
else:
    if x%11 ==1 or x%11 ==2 or x%11 ==3 or x%11 ==4 or x%11 ==5 or x%11 ==6:
        print((x//11)*2+1)
    elif x%11 ==7 or x%11 ==8 or x%11 ==9 or x%11 ==10:
        print((x // 11) * 2 + 2)
    else:
        print((x//11)*2)

Measured memory_bytes: 3064
N=int(input())
S=input()

r=S.count('R')
g=S.count('G')
b=S.count('B')
al_num=r*g*b

#全体からj-i=k-jの場合を引く
sub=0
for i in range(0,N):
  for j in range(i+1,N):
    if S[i]==S[j]:
      continue

    k = 2*j -i
    #i,j,kは等差数列なのでkは決まる, k>=Nは不適なのでスキップ
    if k>=N or S[k]==S[i] or S[k]==S[j]:
      continue
    
    sub += 1
print(al_num - sub)
# O(N^2)

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

void solve(long long N, std::vector<long long> h) {
    long long use = 0;
    long long ans = 0;
    for(int i = 0 ; i < h.size() ; i++){
      if( h[i] > use ){
        ans += h[i] - use;
        use = h[i];
      }else{
        use = min(h[i], use);
      }
    }
    cout << ans << endl;
}


int main() {
  long long N;
  scanf("%lld", &N);
  std::vector<long long> h(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &h[i]);
  }
  solve(N, std::move(h));
  return 0;
}


Measured memory_bytes: 256
#https://atcoder.jp/contests/abc150/tasks/abc150_b
N= int(input())
s= input()

A= []
A= list(s)

#print(A)

add = 0
for i in range(0, N-2):
    if A[i]== 'A' and A[i+1]=='B' and A[i+2]=='C':
        add = add + 1

print(add)

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

int main()
{
    int n;
    cin >> n;
    
    string a, b;
    cin >> a >> b;
    
    for(int i = 0; i < n; i++){
        cout <<a[i]<<b[i];
    }
    
    cout <<"\n";

}


Measured memory_bytes: 256
N, K = map(int, input().split())
H = list(map(int, input().split()))
H.sort(reverse=True)
count1 = 0
count2 = K
for i in range(N):
    if count2 != 0:
        count2 -= 1
    else:
        count1 += H[i]
print(count1)


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

int main() {

	int X, N, tmp, chk_minus = 0, chk_plus = 0, c1, c2;
	cin >> X >> N;
	vector<int> p(N);
	bool flag = true;

	for (int i = 0; i < N; i++) {
		cin >> p[i];
	}

	if (N == 0) {
		cout << X << endl;
		return 0;
	}

	if (N == 1&&p[0]==X) {
		cout << X-1 << endl;
		return 0;
	}

	//for (int i = 0; i < N; i++) {
	//	for (int j = 0; j < N; j++) {
	//		if (p[i] < p[j]) {
	//			tmp = p[i];
	//			p[i] = p[j];
	//			p[j] = tmp;
	//		}
	//	}
	//}

	for (int i = 0; i <= N; i++) {
		chk_minus = X - i;
		flag = true;
		for (int j = 0; j < N; j++) {
			if (chk_minus == p[j]) {
				flag = false;
			}
		}
		if (flag == true) {
			goto OUT1;
		}
	}
OUT1:

	for (int i = 0; i <= N; i++) {
		chk_plus = X + i;
		flag = true;
		for (int j = 0; j < N; j++) {
			if (chk_plus == p[j]) {
				flag = false;
			}
		}
		if (flag == true) {
			goto OUT2;
		}
	}
OUT2:

	c1 = abs(X - chk_minus);
	c2 = abs(X - chk_plus);



	if (c1 == c2) {
		cout << chk_minus << endl;
		//cout << "1" << endl;
		return 0;

	}
	if (c1 > c2) {
		cout << chk_plus << endl;
		//cout << "2" << endl;
		return 0;

	}
	else {
		cout << chk_minus << endl;
		//cout << "3" << endl;
		return 0;
	}


}


Measured memory_bytes: 3628
#include <iostream>
#include <string>

using namespace std;

int comp(string s,string t){
  int num=0;
  for(int i=0;i<t.length();i++){
    if(s[i]!=t[i])
      num++;
  }
  return num;
}

int main(void){
  string s,t;
  cin >> s;
  cin >> t;
  int ans = t.length();
  if(t.length()-s.length()==0){
    cout << comp(s,t) << endl;
    return 0;
  }
  for(int i=0;i<s.length()-t.length();i++){
    string sub = s.substr(i,t.length());
    int num = comp(sub,t);
    if(ans > num){
      ans = num;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        
        if ( A >= 13 ){
            System.out.println(B);
        } else if ( A <= 5 ){
            System.out.println(0);
        } else {
            System.out.println(B/2);
        }
    }
}


Measured memory_bytes: 22996
#include<stdio.h>

int main(){
	
int i,a,b,c,count=0;

scanf("%d%d%d",&a,&b,&c);

for(i=a; i<=b; i++){
	
if(c%i==0){
	count++;
}
}
printf("%d\n",count);

return 0;

}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;

typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}


int main(){
    int a,b,H,M;
    cin >> a >> b >> H >> M;
    double hd = 0,md = 0;
    bool flag = false;
    for(int i=0;i<12;i++) {
        for(int j=0;j<60;j++) {
            if(i==H && M==j){
                flag = true;
                break;
            }
            hd += 0.5;
            md += 6.0;
        }
        if(flag)break;
        md = 0;
    }
    double ans = sqrt(a*a + b*b  - 2*a*b*cos((hd-md)* M_PI / 180));
    printf("%.15f\n",ans);

    return 0;
}

Measured memory_bytes: 4196
using System;
using System.Collections.Generic;
using System.Linq;

class Program {
    static string ReadLine() { return Console.ReadLine(); }
    static int ReadInt() { return int.Parse(ReadLine()); }
    static int[] ReadInts() { return ReadLine().Split().Select(int.Parse).ToArray(); }
    static string[] ReadStrings() { return ReadLine().Split(); }

    static void Main() {
        int n = ReadInt();
        for (int i = 0; i < n; i++) {
            var xs = ReadInts();
            Array.Sort(xs);
            int a = xs[0];
            int b = xs[1];
            int c = xs[2];
            if (a * a + b * b == c * c) {
                Console.WriteLine("YES");
            }
            else {
                Console.WriteLine("NO");
            }
        }
    }
}

Measured memory_bytes: 9524
//  RAKSHIT KADAM
//ALWAYS USE &IT FOR ITERATING USING AUTO ...
//USE COUNT(STARTING ADDRESS, ENDING ADRESS ,VALUE) FOR FINDING THE COUNT IN THE RESPECTIVE DATA STRUCTURE
//NOTE THAT MEMSET CANT FILL THE DOUBLE VALUES;
//ACCUMULATE DOES NOT WORK PROPERLY IF VALUES START SUMMING BEYOND 1E9...
 #include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree< int ,  null_type ,  less<int> ,  rb_tree_tag ,  tree_order_statistics_node_update>
#warning !!!check the size of arrayss!!!
 
// NUMERIC DEFINITIONS :
    #define INF 1000000000000000005
    #define inf 1000000037
    #define MOD  1000000007
    #define newMOD  998244353
    #define MAX 300006
    #define pi 3.1415926535897932384626433832795
#define ld long double
                         #define ll long long
                         #define int long long
//  #define ll int
 #define P(gg) for(auto rax:gg){cout<<rax<<" ";}cout<<endl;
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll t; cin>> t; while(t--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define endl "\n"
 #define x first
 #define y second
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define forci(i,n) for(ll i=0;i<n;i++)
 #define vi vector<ll>
 #define Endl endl
 #define lb lower_bound
 #define ub upper_bound
#define pii pair<ll,ll>
 
 #define input freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout)
// #define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;
 
ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
int power(int x, unsigned int y, unsigned int m){ if (y == 0) return 1;int p = power(x, y/2, m) % m;  p = (p * p) % m;return (y%2 == 0)? p : (x * p) % m;}
ll modInverse(int a, int m){{ return power(a, m-2, m);}}
const int maxn =500003;


void solve()
{
    ll n;cin>>n;string ans;
    while(n)
    {
        ll x =n%26;
        if(x)
        {ans+=char('a'+x-1);}
        else { ans+='z';}
        n =(n-1)/26;
       
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
}
 
signed main()
{
   Need_for_speed(activated);
    
   
//satisfy
//    {
//  solve();
//   }
    solve();
    
    return 0;
}
 


Measured memory_bytes: 3652
#include <stdio.h>
int main() {
  int N, i, count, num;
  count = num = 0;
  scanf("%d", &N);
  char S[N];
  scanf("%s", S);
  for (i = 0; i < N; ++i) {
    if (S[i] == 'A') {
      num = 1;
    } else if (num == 1 && S[i] == 'B') {
      num = 2;
    } else if (num == 2 && S[i] == 'C') {
      ++count;
      num = 0;
    } else {
      num = 0;
    }
  }
  
  printf("%d\n", count);
  return 0;
}

Measured memory_bytes: 128
#!/usr/bin/env ruby

def mapping(lat, lon)
  # ??¢?´¢???????????????
  @map[lat][lon] = -1

  # ?????????????????¢?´¢
  mapping(lat, lon - 1) if lon > 0 && @map[lat][lon - 1] == 1
  mapping(lat, lon + 1) if lon < 11 && @map[lat][lon + 1] == 1
  mapping(lat - 1, lon) if lat > 0 && @map[lat - 1][lon] == 1
  mapping(lat + 1, lon) if lat < 11 && @map[lat + 1][lon] == 1

  1
end

loop do
  @map = []
  cnt = 0

  12.times do |i|
    @map[i] = gets.chomp!.split('').map(&:to_i)
  end

  12.times do |lon|
    12.times do |lat|
      cnt += mapping(lat, lon) if @map[lat][lon] == 1
    end
  end

  puts cnt

  # ????????????
  break unless gets
end

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

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}

void code() {
    int x,y;
    cin>>x>>y;
    int ans=0;
    if(y%2==1) {
        cout << "No\n";
        return;
    }
    if(y<2*x || y>4*x) {
        cout << "No\n";
        return;
    }
    cout << "Yes\n";
}

signed main() {
    std::ios_base::sync_with_stdio(false);
    int t=1;
    // cin>>t;
    for(int i=0; i<t; i++) {
        code();
    }
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int main () {
	int A,B,C;
	cin >> A >> B;
	if((A % 3 == 0) || (B % 3 == 0) || ((A + B) % 3 == 0)){
		cout << "Possible" << endl;
	}else{
		cout << "Impossible" << endl;
	}
}

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

using namespace std;

int main()
{
	int wei[11];
	int sinn[11];
	int omosa=1;
	int n;
	int flag=0;
	for(int i=0;i<=10;i++){
		wei[i]=omosa;
		omosa*=2;
	}
	while(cin>>n){
		flag=0;
		for(int i=0;i<=10;i++){
			sinn[i]=n%2;
			n/=2;
		}
		for(int i=0;i<10;i++){
			if(sinn[i]==1){
				if(flag==0){
					flag=1;
					cout<<wei[i];
				}
				else cout<<' '<<wei[i];
			}
		}
		cout<<'\n';
	}
	return 0;
}

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

#define ll long long

template<typename T> void drop(const T &x){cout<<x<<'\n';exit(0);}

void solve() {
  int a, b, c; cin >> a >> b >> c;

  for(int i=1; i<=b; ++i) {
    if((a+a*i)%b == c) drop("YES");
  }
  cout << "NO" << '\n';
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int T=1;
  //cin >> T;
  while(T--) solve();

  return 0;
}


Measured memory_bytes: 3620
#include <stdio.h>
int main() {

int w,h,x,y,r;
scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);

if(x+r>w || x-r<0){
printf("No\n");
}else if(y+r>h || y-r<0){
printf("No\n");
}else if(w*h<=r*r*3.15){
printf("No\n");
}else{
printf("Yes\n");
}
return 0;
}


Measured memory_bytes: 2096
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  bool f=1;
  for(int i=1;i<=1000;i++){
    if((i*2)/25==a&&i/10==b){
      cout<<i<<endl;
      f=0;
      break;
    }
  }
  if(f)  cout<<-1<<endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
colors = [0] * 8
other = 0
for a in A:
  index = a // 400
  if index > 7:
    other += 1
  else:
    colors[index] += 1
min_color = 0
max_color = 0
# 全員3200以上の場合
if other == N:
  min_color = 1
  max_color = other
else:
  for c in colors:
    if c != 0:
      min_color += 1
  max_color = min_color + other 

print(min_color,max_color)
 

Measured memory_bytes: 9008
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <fstream>

using namespace std;

#define ll long long
#define INF 2000000000
#define LINF 2000000000000000000
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define dum(x) cout<<#x<<'='<<x<<endl
#define dum2(x,y) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<'\n'<<endl
#define dum3(x,y,z) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<' '<<#z<<'='<<z<<'\n'<<endl
#define darr(arr,n) rep(i,(n-arr)){cout<<*(arr+i)<<' ';}cout<<endl

//ifstream in("Text.txt");cin.rdbuf(in.rdbuf());

map<int, bool>mp[200020];

int main() {
    int N, M, a, b;
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        cin >> a >> b;
        mp[a][b] = true;
        mp[b][a] = true;
    }
    for (int i = 2; i <= N; i++) {
        if (mp[1][i] == true && mp[i][N] == true) {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 37760
///Author:- lazy_coder99

#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll n,m;
    cin>>n>>m;
    //vector<ll> l,m;
    ll l = INT_MIN,r = INT_MAX;
    for(int i=0;i<m;i++)
    {
        ll val1,val2;
        cin>>val1>>val2;
        l = max(l,val1);
        r = min(r,val2);
    }
    if(l<=r)
    cout<<abs(l-r)+1<<'\n';
    else
    {
        cout<<"0"<<'\n';
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int m,k;
    cin>>m>>k;
    if(m==0||m==1){
        if(k){
            cout << -1<<endl;
        }else{
            if(m){
                cout << "0 0 1 1"<<endl;
            }else{
                cout <<"0 0"<<endl;
            }
        }
    }else{
        vector<int> v;
        int num=0;
        if(k>=(1<<m)){
            cout <<-1<<endl;
        }else{
            for(int i=0;i<(1<<m);i++){
                if(i!=k){
                    v.pb(i);
                    num^=i;
                }
            }
            if(num!=k){
                cout << -1<<endl;
            }else{
                int maki=v.size();
                for(int i=0;i<maki;i++){
                    cout << v[i] <<" ";
                }
                cout <<k<<" ";
                for(int i=maki-1;i>=0;i--){
                    cout << v[i]<<" ";
                }
                cout << k<<endl;
            }
        }
    }
    return 0;
}


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

#define INT_MAX 2147483647
#define INT_MIN -2147483648

int max(int a, int b);
int min(int a, int b);
int abs(int a);

int main() {
	int a, b;
	scanf("%d %d", &a, &b);
	printf("%d\n", (3 * a + b) / 2);
	return 0;
}

void swap(int *a, int *b) {
	int temp = *a;
	*a = *b;
	*b = temp;	
}

int max(int a, int b) {
	return (a > b) ? a : b;
}

int min(int a, int b) {
	return (a < b) ? a : b;
}

int abs(int a) {
	return (a < 0) ? -a : a;
}


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

int main() {
  int N;
  string A, B, C;
  cin >> N >> A >> B >> C;
  
  int ans = 0;

  while (A != B || A != C || B != C) {
    for (int i = 0; i < N; i++) {
      if (A[i] == B[i] && A[i] != C[i]) {
        C[i] = A[i];
        ans++;
      }
      else if (A[i] == C[i] && A[i] != B[i]) {
        B[i] = A[i];
        ans++;
      }
      else if (B[i] == C[i] && B[i] != A[i]) {
        A[i] = B[i];
        ans++;
      }
      else if (A[i] != B[i] && A[i] != C[i] && B[i] != C[i]) {
        B[i] = A[i];
        C[i] = A[i];
        ans += 2;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.TreeMap;




public class Main {




	static Scanner scan = new Scanner(System.in);
	static PrintWriter out = new PrintWriter(System.out);




	public static void main(String[] args) {
		TreeMap<String, ArrayList<Integer>> map = new TreeMap<String, ArrayList<Integer>>();
		while(scan.hasNext()){
			String mozi = scan.next();
			int page = si();
			if(!map.containsKey(mozi)){
				ArrayList<Integer> list = new ArrayList<Integer>();
				list.add(page);
				map.put(mozi,list);
			}else{
				ArrayList<Integer> list = map.get(mozi);
				list.add(page);
				map.put(mozi,list);
			}
		}
		for(Entry<String, ArrayList<Integer>> e : map.entrySet()){
			out.println(e.getKey());
			ArrayList<Integer> list = e.getValue();
			Collections.sort(list);
			for (int i = 0; i < list.size() ; i++) {
				if(i==list.size()-1) out.println(list.get(i));
				else out.print(list.get(i)+" ");
			}
		}
		out.flush();
	}




	static int si() {
		return Integer.parseInt(scan.next());
	}
}

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

using namespace std;

int main() {
   long long a,b,c,x1,x2,y1,y2;
   cin>>a>>b>>c;
   x1=0;y2=b,x2=a,y1=0;
   
   for(long long i=0;i<c;i++)
   {
       long long d,e,f;
       cin>>d>>e>>f;
       if(f==1)
       {
           x1=max(x1,d);
       }
        if(f==2)
       {
           x2=min(x2,d);
       }
        if(f==3)
       {
           y1=max(y1,e);
       }
        if(f==4)
       {
           y2=min(y2,e);
       }
       
   }
   
   int whiteH = max(x2 - x1, (long long)0);
  int whiteW = max(y2 - y1, (long long)0);
 
  cout << whiteH * whiteW << endl;
}

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

int main() {
  vector<int> vec(3);
  for(int i = 0; i < 3; i++){
    cin >> vec[i];
  }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  int count = 0;
  count = vec[0] - vec[1];
  vec[1] = vec[0];
  vec[2] += count;
  if((vec[1] - vec[2]) % 2 == 0){
    count += (vec[1] - vec[2])/2;
    cout << count <<endl;
  }
  else{
    count += (vec[1] - vec[2])/2 +2;
    cout << count <<endl;
  }
}


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

const int Maxn = 100005;
int n, cnt, root, fa[Maxn], siz[Maxn], pos[Maxn], head[Maxn];
long long d[Maxn], dis[Maxn];
map <long long, int> Ma;
struct edg
{
	int nxt, to;
}edge[Maxn];
void add(int x, int y)
{
	edge[++cnt] = (edg){head[x], y};
	head[x] = cnt;
}
void dfs1(int u)
{
	for (int i = head[u]; i; i = edge[i].nxt)
	{
		int to = edge[i].to;
		dfs1(to), dis[u] += dis[to] + siz[to];
	}
}
void dfs2(int u)
{
	for (int i = head[u]; i; i = edge[i].nxt)
	{
		int to = edge[i].to;
		dis[to] = dis[u] + n - 2 * siz[to];
		dfs2(to);
	}
}
int main()
{
	scanf("%d", &n);
	root = 1;
	for (int i = 1; i <= n; i++)
		scanf("%lld", &d[i]), pos[i] = i, Ma[d[i]] = i, siz[i] = 1;
	sort(pos + 1, pos + 1 + n, [](int x, int y){return d[x] < d[y];});
	for (int i = n; i >= 1; i--)
	{
		Ma[d[pos[i]]] = 0;
		fa[pos[i]] = Ma[d[pos[i]] - n + 2 * siz[pos[i]]];
		siz[fa[pos[i]]] += siz[pos[i]];
	}
	for (int i = 1; i <= n; i++)
	{
		if (!fa[i] && i != pos[1])
		{
			puts("-1");
			return 0;
		}
		add(fa[i], i);
	}
	dfs1(pos[1]);
	for (int i = 2; i <= n; i++)
		dis[pos[i]] = 0;
	dfs2(pos[1]);
	for (int i = 1; i <= n; i++)
		if (d[i] != dis[i])
		{
			puts("-1");
			return 0;
		}
	for (int i = 2; i <= n; i++)
		printf("%d %d\n", fa[pos[i]], pos[i]);
	return 0;
}

Measured memory_bytes: 13056
EPS = 1e-4

#点と線分の距離
def PointSegmentDistance(point, begin, end):
	point, begin, end = point-begin, 0, end-begin
	point = (point / end) * abs(end)
	end = abs(end)
	if -EPS <= point.real <= abs(end):
		return abs(point.imag)
	else:
		return min(abs(point), abs(point - end))

#外積
def OuterProduct(one, two):
	tmp = one.conjugate() * two
	return tmp.imag

#内積
def InnerProduct(one, two):
	tmp = one.conjugate() * two
	return tmp.real

#点が線分上にあるか
def IsOnSegment(point, begin, end):
	if abs(OuterProduct(begin-point, end-point)) <= EPS and InnerProduct(begin-point, end-point) <= EPS:
		return True
	else:
		return False

#3点が反時計回りか
#一直線上のときの例外処理できていない→とりあえずF
def CCW(p, q, r):
	one, two = q-p, r-q
	if OuterProduct(one, two) > -EPS:
		return True
	else:
		return False

#線分どうし交叉
def Intersect_SS(b1, e1, b2, e2):
	if IsOnSegment(b1, b2, e2) or IsOnSegment(e1, b2, e2) or IsOnSegment(b2, b1, e1) or IsOnSegment(e2, b1, e1):
		return True
	elif (CCW(b1, e1, b2) != CCW(b1, e1, e2)) and (CCW(b2, e2, b1) != CCW(b2, e2, e1)):
		return True
	else:
		return False

#点と線分の距離
def SegmentSegmentDistance(a, b, c, d):
	if Intersect_SS(a, b, c, d):
		return 0
	else:
		return min(PointSegmentDistance(a, c, d), PointSegmentDistance(b, c, d), PointSegmentDistance(c, a, b), PointSegmentDistance(d, a, b))

n = int(input())
for _ in range(n):
	pp = list(map(int, input().split()))
	p = [complex(pp[i], pp[i+1]) for i in range(0, 8, 2)]
	print(SegmentSegmentDistance(p[0], p[1], p[2], p[3]))


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

struct StNode
{
  StNode* m_poParnt;
  StNode* m_poLeft;
  StNode* m_poRigt;
  int m_nKey;

  StNode(int nNo) :
    m_poParnt(nullptr), m_poLeft(nullptr), m_poRigt(nullptr), m_nKey(nNo)
  { }
};

void fnPreOrder(StNode* poNode)
{
  if (poNode == nullptr)  return;

  cout << " " << poNode->m_nKey;
  fnPreOrder(poNode->m_poLeft);
  fnPreOrder(poNode->m_poRigt);
}

void fnInOrder(StNode* poNode)
{
  if (poNode == nullptr)  return;

  fnInOrder(poNode->m_poLeft);
  cout << " " << poNode->m_nKey;
  fnInOrder(poNode->m_poRigt);
}

void fnInsert(StNode*& rpoRoot, StNode* poNewNod)
{
  StNode* poParnt = nullptr;
  StNode* poNode = rpoRoot;

  while (poNode != nullptr)
  {
    poParnt = poNode;
    if (poNewNod->m_nKey < poNode->m_nKey)
      poNode = poNode->m_poLeft;
    else
      poNode = poNode->m_poRigt;
  }

  poNewNod->m_poParnt = poParnt;
  if (poParnt == nullptr)
    rpoRoot = poNewNod;
  else if (poNewNod->m_nKey < poParnt->m_nKey)
    poParnt->m_poLeft = poNewNod;
  else
    poParnt->m_poRigt = poNewNod;
}

void fnBinSchTree(StNode*& poRoot)
{
  int nMaxSiz;
  cin >> nMaxSiz;

  for (int i = 0; i < nMaxSiz; ++i)
  {
    string sCmd;
    cin >> sCmd;
    if (sCmd[0] == 'i')
    {
      int nNo;
      cin >> nNo;
      StNode* poNewNod = new StNode(nNo);
      fnInsert(poRoot, poNewNod);
    }
    if (sCmd[0] == 'p')
    {
      fnInOrder(poRoot);
      cout << endl;
      fnPreOrder(poRoot);
      cout << endl;
    }
  }
}

void fnPstOrder(StNode* poNode)
{
  if (poNode == nullptr)  return;

  fnPstOrder(poNode->m_poLeft);
  fnPstOrder(poNode->m_poRigt);
  delete poNode;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  StNode* poRoot = nullptr;

  fnBinSchTree(poRoot);
  fnPstOrder(poRoot);
}

Measured memory_bytes: 26556
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>
#include <cassert>
using namespace std;

//common
typedef int  i32;
typedef long long i64,ll;
#define BR "\n"

#define ALL(c) (c).begin(),(c).end()
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define EACH(it,o) for(auto it = (o).begin(); it != (o).end(); ++it)
#define IN(l,v,r) ((l)<=(v) && (v)<(r))

typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii;
typedef long long ll; typedef vector<long long> vl; typedef pair<long long,long long> pll; typedef vector<pair<long long,long long> > vpll;
typedef vector<string> vs; typedef long double ld;

//config
#define MODE_DEBUG
//#define INF 1<<30
//#define EPS 1e-8
//const ll MOD =100000007;

//debug
#ifdef NDEBUG
#define DUMP(x)
#define DUMPLN(x)
#define DEBUG(x)
#define DEBUGLN(x)
#define LINE()
#define LINELN()
#define CHECK(exp,act)
#define STOP(e)
#else
#define DUMP(x)  cerr << #x << " = " << (x)
#define DUMPLN(x)  DUMP(x) <<endl
#define DEBUG(x) DUMP(x) << LINE() << " " << __FILE__
#define DEBUGLN(x) DEBUG(x)<<endl
#define LINE()    cerr<< " (L" << __LINE__ << ")"
#define LINELN()    LINE()<<endl
#define CHECK(exp,act)  if(exp!=act){DUMPLN(exp);DEBUGLN(act);}
#define STOP(e)  CHECK(e,true);if(!(e)) exit(1);
#endif

template<class T> inline string toString(const vector<T>& x) {
	stringstream ss;
	REP(i,x.size()){
		if(i!=0)ss<<" ";
		ss<< x[i];
	}
	return ss.str();
}
template<class T> inline string toString(const vector<vector<T> >& map) {
	stringstream ss;
	REP(i,map.size()){
		if(i!=0)ss<<BR;
		ss<< toString(map[i]);
	}
	return ss.str();
}
template<class K,class V>  string toString(map<K,V>& x) {
	string res;stringstream ss;
	for(auto& p:x)ss<< p.first<<":" << p.second<<" ";
	return ss.str();
}

template<typename T,typename V> inline T mod(T v,V MOD){
	return (v%MOD+MOD)%MOD;
}

#define nextInt(n) scanf("%d",&n)
#define nextLong(n) scanf("%lld",&n)
#define nextDouble(n) scanf("%lf",&n)

ll INF=1LL<<58;
class Main{
public:	
	void run(){
		ll n,m,k;cin >> n >> m >> k;
		n%=10;

		if(n==0 || n==1 || n==5 || n==6){
			cout << n*k <<endl;return;
		}
		if(n==4 || n==9){
			if(m%2==0){
				cout << n*k <<endl; return; 
			}else{
				if(k%2==0){
					cout << 10*(k/2)<<endl;return;
				}else{
					cout << 10*(k/2)+n<<endl;return;		
				}
			}
		}
		if(m%4==0){
			cout << n*k <<endl;return;
		}else if(m%2==0){
			if(k%2==0){
				cout << 10*(k/2)<<endl;return;
			}else{
				cout << 10*(k/2)+n<<endl;return;		
			}				
		}else{

			int md=0,v=n;
			REP(i,k%4){
				md+=v;
				v=(v*(ll)pow(n,m%4))%10;//pow
			}
			cout << 20*(k/4)+md<<endl;return;
		}
	}
};
 int main(){
 	cout <<fixed<<setprecision(15);
	ios::sync_with_stdio(false);
 	Main().run();
 	return 0;
 }


Measured memory_bytes: 1228
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

constexpr int64_t DIV1097 = 1000000007LL;

using namespace std;

int main()
{
    std::string S, T;
    std::cin >> S >> T;

    // std::cout.precision(20);

    std::map<char, int64_t> SS, TT;

    for (size_t i = 0; i < S.size(); ++i) {
        SS[S[i]]++;
        TT[T[i]]++;
    }

    std::vector<int64_t> SV, TV;

    for (auto e: SS) {
        SV.push_back(e.second);
    }
    for (auto e: TT) {
        TV.push_back(e.second);
    }

    std::sort(std::begin(SV), std::end(SV));
    std::sort(std::begin(TV), std::end(TV));

    if (SV.size() != TV.size()) {
        std::cout << "No" << std::endl;
        return 0;
    }

    for (size_t i = 0; i < SV.size(); ++i) {
        if (SV[i] != TV[i]) {
            std::cout << "No" << std::endl;
            return 0;
        }
    }

    std::cout << "Yes" << std::endl;
    return 0;

}


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

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

    ll n, k;
    cin >> n >> k;

    vector<int> a(n);
    rep(i, n) cin >> a[i];

    vector<int> s;
    vector<int> ord(n+1, -1);
    int c = 1;
    int l = 0;
    {
        int v = 1;
        while(ord[v] == -1){
            ord[v] = s.size();
            s.push_back(v);
            v = a[v-1];
        }
        c = s.size() - ord[v];
        l = ord[v];
    }

    if(k < l) cout << s[k] << endl;
    else{
        k -= l;
        k %= c;
        cout << s[l+k] << endl;
    }


    return 0;
}

Measured memory_bytes: 5864