akhauriyash/Code-Regression huggingface dataset:
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn vec<T, F: FnMut(usize) -> T>(n: usize, mut f: F) -> Vec<T> {
    (0..n).map(|i| f(i)).collect()
}

const EPS: f64 = 1e-6;

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let n: usize = scan(tokens);
    let k: usize = scan(tokens);
    let xyc: Vec<(f64, f64, f64)> = vec(n, |_| (scan(tokens), scan(tokens), scan(tokens)));
    let mut a: f64 = 0.0;
    let mut b: f64 = xyc
        .iter()
        .map(|&(x, y, c)| c * distance(x, y, 0.0, 0.0))
        .fold(0.0, f64::max);
    while b - a > EPS / 2.0 {
        let t = (a + b) / 2.0;
        if check(&xyc, t, k) {
            b = t;
        } else {
            a = t;
        }
    }
    println!("{}", (a + b) / 2.0);
}

fn distance(x0: f64, y0: f64, x1: f64, y1: f64) -> f64 {
    let dx = x1 - x0;
    let dy = y1 - y0;
    (dx * dx + dy * dy).sqrt()
}

fn check(xyc: &[(f64, f64, f64)], t: f64, k: usize) -> bool {
    let n = xyc.len();
    let mut candidates = Vec::with_capacity(n * n);
    for i in 0..n {
        let (xi, yi, ci) = xyc[i];
        let ri = t / ci;
        candidates.push((xi, yi));
        for j in i + 1..n {
            let (xj, yj, cj) = xyc[j];
            let rj = t / cj;
            let d = distance(xi, yi, xj, yj);
            let cos = (d * d + ri * ri - rj * rj) / (2.0 * d * ri);
            if cos * cos <= 1.0 {
                let sin = (1.0 - cos * cos).sqrt();
                let dx = xj - xi;
                let dy = yj - yi;
                let x = xi + ri / d * (cos * dx - sin * dy);
                let y = yi + ri / d * (cos * dy + sin * dx);
                candidates.push((x, y));
                let x = xi + ri / d * (cos * dx + sin * dy);
                let y = yi + ri / d * (cos * dy - sin * dx);
                candidates.push((x, y));
            }
        }
    }
    for (x0, y0) in candidates {
        let mut cnt = 0;
        for &(x, y, c) in xyc {
            if distance(x0, y0, x, y) * c <= t + EPS / 2.0 {
                cnt += 1;
            }
        }
        if cnt >= k {
            return true;
        }
    }
    return false;
}


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

int main() {
 char a,b,c;
 cin >> a >> b >> c ;
 string s = "AAA";
 s.at(0)=a;
 s.at(1)=b;
 s.at(2)=c;
  
 int x=stoi(s);
 if(x%4==0)
   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);
        StringBuilder bd = new StringBuilder();

        int n = sc.nextInt();

        int r0 = sc.nextInt();
        int r1 = sc.nextInt();

        int max = r1 - r0;
        int min = Math.min(r0, r1);

        for (int i=2; i<n; i++) {
            int r = sc.nextInt();
            max = Math.max(max, r-min);
            min = Math.min(min, r);
        }

        System.out.println(max);
    }
}


Measured memory_bytes: 99244
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c=1;
    cin>>a>>b;
    if(a>0||(a&1)^(b&1))cout<<"Positive"<<endl;else
    if(b>=0)cout<<"Zero"<<endl;else
    cout<<"Negative"<<endl;
    return 0;
} 

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp;
use std::io::Write;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    let s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn main() {
  let out = std::io::stdout();
  let mut out = std::io::BufWriter::new(out.lock());
  macro_rules! puts {
    ($($format:tt)*) => (write!(out,$($format)*).unwrap());
  }
  input! {
    n: usize,
    k: i64,
    a: [i64; n],
  }
  let s: i64 = a.iter().sum();
  let mut div = vec![];
  let mut i = 1;
  while i * i <= s {
    if s % i == 0 {
      div.push(i);
      div.push(s / i);
    }
    i += 1;
  }
  div.sort();
  use std::collections::VecDeque;
  for &d in div.iter().rev() {
    let mut v = vec![];
    for &x in &a {
      v.push(x % d);
    }
    v.sort();
    let mut q: VecDeque<_> = v.into_iter().collect();
    let mut c = 0;
    let mut mv = 0i64;
    while ! q.is_empty() {
      if c > 0 {
        let x = q.pop_back().unwrap();
        c += x - d;
        mv += d - x;
      } else {
        let x = q.pop_front().unwrap();
        c += x;
        mv += x;
      }
    }
    if mv / 2 <= k {
      puts!("{}\n", d);
      return;
    }
  }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define MOD 1000000007
#define ONLINE_JUDGE

using namespace std;
int dp[100005];
void ravi()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int frog2(vector<int> &vc,int pos,int k)
{
    // Base condition
    if (pos == vc.size()-1)
        return 0;
    if(dp[pos] != -1)
        return dp[pos];
    int mini = INT_MAX;
    for(int i = 1;i<=k;i++)
    {
        if(pos+i > vc.size()-1)
            break;
        mini = min(mini,abs(vc[pos]-vc[pos+i])+frog2(vc,pos+i,k));
    }
    return dp[pos] = mini;
}
int main()
{
    ravi();
    int n,k;
    cin>>n>>k;
    vector<int> vc;
    int temp;
    memset(dp,-1,sizeof(dp));
    for(int i = 0;i<n;i++)
    {
        cin>>temp;
        vc.push_back(temp);
    }
    cout<<frog2(vc,0,k);
    return 0;
}

Measured memory_bytes: 10488
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {
	public static void main(String[] args){
		InputStreamReader is = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(is);

		StringBuffer gyaku = null;

		try {
			gyaku = new StringBuffer(br.readLine());
			gyaku = gyaku.reverse();
			System.out.println(gyaku);
		} catch (IOException e) {
			System.out.println("error");
		}
	}
}

Measured memory_bytes: 9196
//sppsfver - 20.08.2020
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using pll = pair <ll, ll>;
const int MAX = 1e5+5;

ll n, k, x, y, ans;

ll calDis (ll a, ll b){
	return (a*a + b*b);
}

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

	cin >> n >> k;
	while (n--){
		cin >> x >> y;
		ans += calDis(x, y) <= k*k;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3624
words = lambda t : list(map(t, input().split()))
n = int(input())
a = words(int)
ab = []
for i in range(1,n+1):
    ab.append((a[i-1],i))

ab.sort()
b = []
for (a,i) in ab:
    b.append(i)

#print(ab)
print(" ".join(map(str,b)))


Measured memory_bytes: 24744
N = int(input())
As = list(map(int, input().split()))

S = set([])
lst = []

for a in As:
  if a not in S:
    S.add(a)
  else:
    lst.append(a)
    
if len(lst) % 2 == 0:
  print(len(S))
else:
  print(len(S)-1)

Measured memory_bytes: 87836
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
 
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
 
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
 
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
 
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
 
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: i64,
        b: i64,
        c: i64,
    }
    let mut i = 0;
    for j in a..(b+1) {
        if c % j == 0{
            i += 1;
        }
    }
    println!("{}", i);
}
//nを入力後ctrl+Z


Measured memory_bytes: 5028
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if((a+b+c)>=22)
    {
        cout<<"bust"<<endl;
    }
    else
        cout<<"win"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <stdint.h>

int64_t as[100005];
int64_t bs[100005];

int main(){
  int64_t N;
  scanf("%ld",&N);
  int64_t total=0;
  for(int64_t i=0;i<N;i++){
    scanf("%ld",&as[i]);
    total+=as[i];
  }
  if(total%(N*(N+1)/2)!=0){
    printf("NO\n");
    return 0;
  }
  total/=(N*(N+1)/2);
  for(int64_t i=0;i<N;i++){
    int64_t tmp=total-(as[(i+1)%N]-as[i]);
    if(tmp<0||tmp%N!=0){
      printf("NO\n");
      return 0;
    }
    bs[i]=tmp/N;
  }
  for(int64_t i=0;i<N;i++){
    total-=bs[i];
  }
  if(total==0){
    printf("YES\n");
  }else{
    printf("NO\n");
  }
  
  return 0;
}


Measured memory_bytes: 1664
class UnionFind():
    # 作りたい要素数nで初期化
    # 使用するインスタンス変数の初期化
    def __init__(self, n):
        self.n = n
        # root[x]<0ならそのノードが根かつその値が木の要素数
        # rootノードでその木の要素数を記録する
        self.root = [-1]*(n+1)
        # 木をくっつける時にアンバランスにならないように調整する
        self.rnk = [0]*(n+1)
        self.potential=[0]*(n+1)
 
    # ノードxのrootノードを見つける
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            # ここで代入しておくことで、後の繰り返しを避ける
            r = self.Find_Root(self.root[x])
            self.potential[x] += self.potential[self.root[x]]
            self.root[x]=r
            return self.root[x]
 
    # 木の併合、入力は併合したい各ノード
    def Unite(self, x, y, d):
        d+=self.potential[x]-self.potential[y]
        # 入力ノードのrootノードを見つける
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        # すでに同じ木に属していた場合
        if(x == y):
            return 
        # 違う木に属していた場合rnkを見てくっつける方を決める
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x
            self.potential[y]=d
 
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            self.potential[x]=-d
            # rnkが同じ（深さに差がない場合）は1増やす
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
 
    # xとyが同じグループに属するか判断
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)
 
    # ノードxが属する木のサイズを返す
    def Count(self, x):
        return -self.root[self.Find_Root(x)]
    
    def dist(self,x,y):
        if self.isSameGroup(x,y):
            return self.potential[y]-self.potential[x]
        else: return -10**10

n,m=map(int,input().split())
if m==0:
  print('Yes')
else:
  t=UnionFind(n)
  arr=[list(map(int,input().split())) for _ in range(m)]
  for l,r,d in arr:
    if t.isSameGroup(l,r) and t.dist(l,r)!=d:
      print('No')
      break
    t.Unite(l,r,d)
  else:
    print('Yes')

Measured memory_bytes: 58024
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  int n; cin >> n;
  vi a(n);
  rep(i,n) cin >> a[i];
  vi left(n);
  vi right(n);
  left[0] = 0;
  right[n-1] = 0;
  for (int i=1; i<n; i++) {
    left[i] = max(left[i-1], a[i-1]);
  }
  for (int i=n-2; i>=0; i--) {
    right[i] = max(right[i+1], a[i+1]);
  }
  rep(i,n) {
    cout << max(right[i], left[i]) << endl;
  }
 return 0;
} 

Measured memory_bytes: 3968
N = int(input())
job = []
for i in range(N):
    A,B = map(int,input().split())
    job.append([B,A])
job = sorted(job)
time = 0
flag = 0
for i in job:
    time += i[1]
    if i[0] < time:
        print('No')
        flag = 1
        break
        
if flag == 0:
    print('Yes')

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

int main() {
    int N,M;
    cin >> N >> M;
    int l = 1,r = N;
    for ( int i = 0; i < M; ++i){
        int L,R;
        cin >> L >> R;
        l = max(l,L);
        r = min(r,R);
    }
    cout << max(r - l + 1,0) << endl;
    
    return 0;
}


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

#define N 3
#define LIM 32
#define HN 362897

struct dep{
    int depth,key;
};

int ans[N][N]={
    {1,2,3},
    {4,5,6},
    {7,8,0}};

int min = LIM;
struct dep h[HN];

int hash1(int k)
{
    return k % HN;
}
int hash2(int k)
{
    return 1 + k%(HN-1);
}
int hash(int k, int i)
{
    return (hash1(k) + i*hash2(k))%HN;
}


void dfs(int p[N][N], int n)
{
    int i,j,i0,j0,a=0,b=1;
    int f=0;
    int tmp[N][N];
    //printf("A\n");
    for(i=0;i<N;i++)
    {
        for(j=0;j<N;j++)
        {
            if(ans[i][j]!=p[i][j])f++;
            if(p[i][j]==0)
            {
                i0=i;
                j0=j;
            }
            a+=p[i][j]*b;
            b*=10;
        }
    }
    
    if(f==0)
    {
        if(min>=n)
        {
            min=n;
        }
        return;
    }
    if(n>min) return;
    i=0;
    while(1)
    {
        b=hash(a, i);
        if(h[b].key == 0)
        {
            h[b].key=a;
            h[b].depth=n;
            break;
        }
        else if(h[b].key == a)
        {
            if(h[b].depth>n)
            {
                h[b].depth=n;
                break;
            }
            else return;
        }
        i++;
    }
    
    if(i0>0 && i0<N)
    {
        memcpy(tmp,p,sizeof(int)*N*N);
        f=tmp[i0][j0];
        tmp[i0][j0]=tmp[i0-1][j0];
        tmp[i0-1][j0]=f;
        dfs(tmp, n+1);
    }
    if(j0>0 && j0<N)
    {
        memcpy(tmp,p,sizeof(int)*N*N);
        f=tmp[i0][j0];
        tmp[i0][j0]=tmp[i0][j0-1];
        tmp[i0][j0-1]=f;
        dfs(tmp, n+1);
    }
    
    if(i0>=0 && i0<N-1)
    {
        memcpy(tmp,p,sizeof(int)*N*N);
        f=tmp[i0][j0];
        tmp[i0][j0]=tmp[i0+1][j0];
        tmp[i0+1][j0]=f;
        dfs(tmp, n+1);
    }
    if(j0>=0 && j0<N-1)
    {
        memcpy(tmp,p,sizeof(int)*N*N);
        f=tmp[i0][j0];
        tmp[i0][j0]=tmp[i0][j0+1];
        tmp[i0][j0+1]=f;
        dfs(tmp, n+1);
    }
    
}

int main()
{
    int i,j;
    int p[N][N];
    
    for(i=0;i<N;i++)
    {
        for(j=0;j<N;j++)
        {
            scanf("%d",&p[i][j]);
        }
    }
    dfs(p,0);
    
    printf("%d\n",min);
    
    return 0;
}

Measured memory_bytes: 3432
#include <bits/stdc++.h>
using namespace std ;
#define An setprecision(16) 
int main(){
    int  N;
    cin >> N;
    int B=-1;
    for(int i=0;i<=N;i++){
        int Ans = i*1.08;
        if(Ans==N){
            B=i;
            break;
        }
    }
    if(B==-1)cout << ":(" << endl;
    else cout << B << endl;
}

Measured memory_bytes: 3596
#include<iostream>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    if (n==1)
        n+=15;
    if (m==1)
        m+=15;
    if (n>m)
        cout<<"Alice"<<endl;
    else if (m>n)
        cout<<"Bob"<<endl;
    else
        cout<<"Draw"<<endl;
    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) = ABC165C.main()

object ABC165C {
    fun log(message: Any?) {
        println(message)// TODO: ←消す
    }

    fun main() {
        val (N, M, Q) = readInts()
        val tuples = (1..Q).map { readInts() }  // a,b,c,d

        val arrays = (1..M).combination(N)
            //.onEach { log(it) }
            .toList()

        val scores = arrays.map { it.calcScore(tuples) }
        val ans = scores.max()

        println(ans)
    }

    fun List<Int>.calcScore(tuples: List<List<Int>>): Long {
        return tuples.map { (a, b, c, d) ->
            if (this[b-1]-this[a-1] == c) d.toLong() else 0L
        }.sum()
    }

    /*####################################################################################*/

    fun readString() = readLine()!!
    fun readStrings() = readLine()!!.split(" ")
    fun readInt() = readLine()!!.toInt()
    fun readInts() = readLine()!!.split(" ").map { it.toInt() }


    class Combination<T> : BasicCombinator<T>() {
        override fun List<T>.chooseRemains(i: Int): List<T> = this.drop(i)
    }

    fun IntRange.combination(k: Int): Sequence<List<Int>> = this.toList().combination(k)
    fun <T> List<T>.combination(k: Int): Sequence<List<T>> = Combination<T>().generate(this, k)

    abstract class BasicCombinator<T> {
        abstract fun List<T>.chooseRemains(i: Int): List<T>

        fun generate(items: List<T>, k: Int): Sequence<List<T>> {
            when {
                (k < 0) ->
                    throw IllegalArgumentException()
                (k == 0) ->
                    return emptySequence()
                (k == 1) ->
                    return items.asSequence().map { listOf(it) }
                else ->
                    return items.asSequence().mapIndexed { index, first ->
                        val remains = items.chooseRemains(index)
                        generate(remains, k - 1).map { first + it }
                    }.flatten()
            }
        }

        private operator fun T.plus(other: List<T>): List<T> {
            val list = mutableListOf(this)
            list.addAll(other)
            return list
        }
    }
}

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

int main(void) {
    int n, m, d[200000];
    vector<int> g[200000];
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        g[a].push_back(b);
    }
    queue<int> q;
    for (int i = 0; i < n; i++)
        d[i] = 3;
    d[0] = 0;
    q.push(0);
    while (!q.empty()) {
        int p = q.front(); q.pop();
        for (int i = 0; i < g[p].size(); i++) {
            if (d[g[p][i]] == 3) {
                d[g[p][i]] = d[p] + 1;
                q.push(g[p][i]);
            }
        }
    }
    cout << (d[n - 1] == 2 ? "POSSIBLE" : "IMPOSSIBLE") << endl;
}

Measured memory_bytes: 9592
def main():
    MOD = 10 ** 9 + 7
    N, M = list(map(int, input().split(' ')))
    S = list(map(int, input().split(' ')))
    T = list(map(int, input().split(' ')))
    dp = [[0 for _ in range(M + 1)] for _ in range(N + 1)]
    sdp = [[0 for _ in range(M + 1)] for _ in range(N + 1)]
    for n, s in enumerate(S):
        for m, t in enumerate(T):
            sdp_val = sdp[n][m]
            new_dp_val = (sdp_val + 1) if s == t else 0
            dp[n + 1][m + 1] = new_dp_val % MOD
            sdp[n + 1][m + 1] = (sdp[n][m + 1] + sdp[n + 1][m] - sdp_val + new_dp_val) % MOD
    print((sdp[N][M] + 1) % MOD)  # 1: an empty sequence


if __name__ == '__main__':
    main()

Measured memory_bytes: 139580
/*  Bismillahir Rahmanir Rahim  */

#include <bits/stdc++.h>

using namespace std;

const int N = 100005;

int n;
vector <int> g[N];

int hack(int at, int par){
	int child = 0;
	vector <int> son;
	for(auto u : g[at]){
		if(u == par) continue;
		++child;
		son.push_back(hack(u, at));
	}
	int ret;
	if(son.size() == 0) ret = 1;
	if(son.size() == 1) ret = son[0] + 1;
	else{
		int X = 0;
		for(auto u : son) X ^= u;
		ret = X + 1;
	}
	return ret;
}

int main(){
	int x, y;
	scanf("%d", &n);
	for(int i = 2; i <= n; ++i){
		scanf("%d %d", &x, &y);
		g[x].push_back(y);
		g[y].push_back(x);
	}
	int X = hack(1, 0) - 1;
	if(X) cout << "Alice\n";
	else cout << "Bob\n";
	return 0;
}

Measured memory_bytes: 15104
//g++ -std=gnu++14 a.cpp
//#include <bits/stdc++.h>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>



using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int main(){

  int N,W;
  cin >> N >> W;
  vector<ll> w(N);
  vector<ll> v(N);
  rep(i,N){
    cin >> w[i] >> v[i];
  }
  ll max_v = 0;
  rep(i,N){
    max_v = max(max_v ,v[i]);
  }
  vector<vector<ll>> dp(110,vector<ll>(100010, INFL));
  dp[0][0] = 0;

  for(int i = 0 ;i < N;i++){
    for(int sumv = 0;sumv <= 100010;sumv++){
      if(v[i] <= sumv){
        dp[i+1][sumv] = min(dp[i][sumv],dp[i][sumv-v[i]]+w[i]);
      }
      dp[i+1][sumv] = min(dp[i+1][sumv],dp[i][sumv]);
    }
  }

    //cout << dp[4][] << endl;

  ll ans = 0;


    rep(sumv,100010){
      if(dp[N][sumv] <= W){
        ans = max(ans,sumv);
      }
    }


  cout << ans << endl;
/*
  rep(i,4){
    rep(j,180){
      cout << dp[i][j] << " ";
    }
    cout << endl;
  }
  */



}


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

#define ARC(i, a, b) for(int i = (a); i < (b); ++i)
#define RC(i, n) ARC(i, 0, n)
#define ARCH(i, a, b) for(int i = (a) - 1; i >= (b); --i)
#define RCH(i, n) ARCH(i, n, 0)

int main(){
	int n, m;
	std::cin >> n >> m;
	if(n >= m){
		std::cout << "0" << std::endl;
		return 0;
	}
	std::vector<int> x(m), dx(m - 1);
	RC(i, m) std::cin >> x[i];
	std::sort(x.begin(), x.end());
	int range = x.back() - x.front();

	RC(i, m - 1) dx[i] = x[i + 1] - x[i];

	std::sort(dx.begin(), dx.end(), std::greater<int>());

	RC(i, n - 1) range -= dx[i];

	std::cout << range << std::endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstring>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;
int main()
{
	ll n,k;
	cin>>n>>k;
	//if(k==1) cout<<0<<endl;
	//else
	//{
	
	ll tmp=n/k;
	n=n-tmp*k;
	ll t=abs(n-k);
	while(n>t&&n>=0&&t>=0)
	{
		n=t;
		t=abs(n-k);
		//cout<<"??";
	}
	cout<<n<<endl;
	//}
	
}

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

int main(){
  int n,u,k;
  int ad;
  int arr[200][200] = {0};
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    cin >> u >> k;
    for(int i=0;i<k;i++){
      cin >> ad;
      arr[u][ad] = 1;
    }
  }

  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      cout << arr[i][j];
      if(j != n)cout << " ";
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 3296
import java.io.*;

public class Main{
public static void main(String[] args){
	try{
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String[] str = br.readLine().split(" ");
	int num0 = Integer.parseInt(str[0]);
	int num1 = Integer.parseInt(str[1]);
	int num2 = Integer.parseInt(str[2]);

		if ( num0 < num1 && num1 < num2){
		System.out.println("Yes");
		}else{
		System.out.println("No");
		}
	}catch(IOException e){
	System.out.println(e);
	}
}
}	

Measured memory_bytes: 16892
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
#define rep(i, n) for (i32 i = 0; i < (i32)(n); i++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using P = pair<i64,i64>;

int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
i64 n,w;
cin >> n >> w;
vector<i64> weight(n),value(n);
rep(i,n){
    cin >> weight[i] >> value[i];
}
vector<i64> dp(w + 1,0);
dp[0] = 0;
rep(i,n) {
    for (i64 j = w; 0 < j; j--) {
        if(j - weight[i] >= 0){
            dp[j] = max(dp[j - weight[i]] + value[i],dp[j]);
        }else{
            dp[j] = max(dp[j],dp[j - 1]);
        }
    }
}

cout << dp[w] << endl;
}

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

int main()
{
ll n ;
cin >> n ;
char s[n][n];
rep(i,n)rep(j,n){
  cin >> s[i][j];
}
ll t[n][n]={};
rep(i,n)rep(j,n){
  rep(k,n-1){
    if(s[(i+k+1)%n][j]!=s[i][(j+k+1)%n]){
      t[i][j]=k;
      break;
    }
    if(k==n-2)t[i][j]=n-1;
  }
}
rep(i,n)rep(j,n){
  bool ok=1;
  rep(k,n-1){
    if(t[(i+k)%n][(j+k)%n]<n-1-k){ok=0;break;}
  }
  if(ok)ans++;
}

cout << ans << endl;
return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val n = sc.nextInt()
    val h = Vector.fill(n)(sc.nextInt)

    @scala.annotation.tailrec
    def count(vector: Vector[Int], acc: Int): Int = {
      if (vector.isEmpty) acc
      else if (vector.forall(_ > 0)) count(vector.map(_ - 1), acc + 1)
      else if (vector.forall(_ == 0)) acc
      else {
        val idx = vector.indexOf(0)
        if (idx == 0) count(vector.tail, acc)
        else if (idx == vector.size - 1) count(vector.init, acc)
        else count((vector.take(idx).map(_ - 1) :+ 0) ++ vector.drop(idx + 1), acc + 1)
      }
    }

    println(count(h, 0))
  }
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

int ketamax(int a, int b){
    if ( to_string(a).length() > to_string(b).length())
        return to_string(a).length();
    else
        return to_string(b).length();

}

void solve(){
    ll N;
    cin >> N;

    int ans=INT_MAX;
    for (int i = 1; i <= sqrt(N); i++) {
        if (i * (N / i) == N) {
            ans = min(ans, ketamax(i, N/i));
        }
    }

    cout << ans << endl;


    return;
}

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


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

n, a, b = map(int, readline().split())
P = 10**9 + 7

def mod_prod(a,b):
    return a * b % P

def mod_fact(a):
    ret = 1
    for i in range(a):
        ret = ret * (i + 1) % P
    return ret

def mod_pow(a, n):
    ret = 1
    while n > 0:
        if n % 2 == 1:
            ret = ret * a % P
        a = a * a % P
        n = n // 2
    return ret

def mod_div(a, b):
    b_inv = mod_pow(b, P - 2)
    return a * b_inv % P

def mod_comb(a,b):
    ret = 1
    b = min(b, a - b)
    for i in range(b):
        ret *= a - i
        ret %= P
    ret = mod_div(ret, mod_fact(b))
    return ret


ans = mod_pow(2, n) - 1 - mod_comb(n, a) - mod_comb(n, b)
ans %= P
print(ans)

Measured memory_bytes: 38768
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<cctype>
#define int long long
#define rg register
using namespace std;
inline int read(){
	rg int s=0,f=0;
	rg char ch=getchar();
	while(!isdigit(ch)) f|=(ch=='-'),ch=getchar();
	while(isdigit(ch)) s=(s<<1)+(s<<3)+(ch^48),ch=getchar();
	return f?-s:s;
}
int ans;
char s1[15],s2[15];
signed main(){
	cin>>s1+1;
	cin>>s2+1;
	int len=strlen(s1+1);
//	cout<<len<<endl;
	for(rg int i=1;i<=len;i=-~i){
//		cout<<s1[i]<<" "<<s2[i]<<endl;
		if(s1[i]==s2[i]) ++ans;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<map>
 
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define pb push_back
#define pf push_front
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
 
ll gcd(ll x, ll y) {
	ll r;
	while ((r = x % y) != 0) {
		x = y;
		y = r;
	}
	return y;
	}
ll lcm(ll x, ll y) {
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x*y);
}

int main()
{
	int n,m,x,ans=0,k;
	cin >> n >> m;
	map<int,int>ma;
	rep(i,n){
		cin >> k;
		rep(j,k){
			cin >> x;
			ma[x]++;
			if(ma[x]==n) ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

int main(void){

	int N,M;
	int inp;
	int sol,maxq=0;

	cin>>N>>M;

	for(int i=0;i<N;i++){
		sol=0;
		for(int j=0;j<M;j++){
			cin>>inp;
			sol+=inp;
		}
		maxq=max(sol,maxq);
	}

	cout<<maxq<<endl;

    return 0;
}

Measured memory_bytes: 1160
#pragma GCC optimize("O3")
/*{{{*/
#include <bits/stdc++.h>
#ifdef LOCAL
int c_ = 0;
#define cout (c_?cerr:cout)
#define debug(...) \
{if(!c_++)cerr<<"\033[96;1m"; \
__VA_ARGS__; \
if(!--c_)cerr<<"\033[0m";}
#else
#define debug(...) {}
#endif
#define assrt(...) debug(\
if (not (__VA_ARGS__)) \
    exit((cerr << __LINE__ << ": " << #__VA_ARGS__ << '\n', 0));\
)
#define st first
#define nd second
#define all(...) (__VA_ARGS__).begin(), (__VA_ARGS__).end()
using namespace std; using ll = long long;
template < typename t > using V = vector< t >;
template < typename t, size_t s > using A = array< t, s >;
void print() {cout << '\n';}
template< typename t, typename... v >
void print(const t& a, const v&... b)
{cout << a << (sizeof...(b)?" ":""); print(b...);}
template< typename t > void print_range(t a, const t& b)
{ while (a != b) cout << (*a++) << ' '; cout << '\n';}
#define dump(...) debug(print(#__VA_ARGS__,'=',__VA_ARGS__))
#define dump_range(...) debug(cerr<<#__VA_ARGS__ << ": "; print_range(__VA_ARGS__))
/*}}}*/

constexpr int nax = 2e5;

int n, res;
multiset< int > S;

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

    cin >> n;

    for (int i = 0; i < n; ++i)
    {
        int v; cin >> v;
        S.insert(v);
    }

    while (not S.empty())
    {
        int v = *S.rbegin(); S.erase(prev(S.end()));
        int a = 1;
        while (a <= v) a <<= 1;
        if (S.find(a - v) != S.end())
        {
            auto it = S.find(a - v);
            S.erase(it);
            ++res;
        }
    }

    print(res);
}

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

#define lli long long int
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define INF 1000000007
#define endl "\n"

lli a,n,x,y,cvp[10000];

int main(){
	cin>>n>>x>>y;
	for (int i = 1; i <= n; i++){
		for (int j = i+1; j <= n; j++){
			int tmpcvp=min(j-i, min((int)abs(x-i)+(int)abs(y-j)+1, (int)abs(x-j)+(int)abs(y-i)+1));
			cvp[tmpcvp]++;
		}
	}
	for(int i=1;i<n;i++){
		cout<<cvp[i]<<endl;
	}
	//system("pause");
}

Measured memory_bytes: 256
N, M = map(int, input().split())
Parent = [-1 for x in range(N + 5)]
lis = [list(map(int, input().split())) for _ in range(M)]
ini = int(N*(N - 1)/2)
ans = [x for x in range(M)]
ans[M - 1] = ini
def root(a):
    if Parent[a] < 0:
        return a
    else:
        k = root(Parent[a])
        Parent[a] = k
        return k
def size(a):
    return -Parent[root(a)]
def connect(a, b):
    A = root(a)
    B = root(b)
    if A == B:
        return None
    else:
        if size(A) < size(B):
            A, B = B, A
        Parent[A] += Parent[B]
        Parent[B] = A
for i in reversed(range(1, M)):
    ans[i - 1] = ans[i]
    if root(lis[i][0]) != root(lis[i][1]):
        ans[i - 1] -= size(lis[i][0])*size(lis[i][1])
        connect(lis[i][0], lis[i][1])    
for i in range(M):
  print(ans[i])

Measured memory_bytes: 33604
#include <stdio.h>
using namespace std;
int main()
{
    char str1[10],str2[10];
    scanf("%s %s",str1,str2);
    if(str1[0]=='H')
    {
        if(str2[0]=='D')
        {
            puts("D");
        }
        else
        {
            puts("H");
        }
    }
    if(str1[0]=='D')
    {
        if(str2[0]=='H')
        {
            puts("D");
        }
        else
        {
            puts("H");
        }
    }
    return 0;
}


Measured memory_bytes: 128
import scala.io.StdIn._
import scala.annotation.tailrec
import scala.collection._

object Main {

  def sieve(top: Int): Iterator[Int] = {
    val topNdx = (top - 3) / 2 + 1
    val (cmpsts, sqrtLmtNdx) = (new Array[Int]((topNdx >>> 5) + 1), (Math.sqrt(top).toInt - 3) / 2)

    @inline def isCmpst(ci: Int): Boolean =
      (cmpsts(ci >>> 5) & (1 << (ci & 31))) != 0

    @inline def setCmpst(ci: Int): Unit =
      cmpsts(ci >>> 5) |= 1 << (ci & 31)

    @tailrec def forCndNdxsFrom(cndNdx: Int): Unit =
      if(cndNdx <= sqrtLmtNdx){
        if(!isCmpst(cndNdx)){
          val p = 2 * cndNdx + 3

          @tailrec def cullPrmCmpstsFrom(cmpstNdx: Int): Unit =
          if(cmpstNdx <= topNdx){
            setCmpst(cmpstNdx)
            cullPrmCmpstsFrom(cmpstNdx + p)
          }
          cullPrmCmpstsFrom((p * p - 3) >>> 1)
        }
        forCndNdxsFrom(cndNdx + 1)
      }

    forCndNdxsFrom(0)

    @tailrec def getNxtPrmFrom(cndNdx: Int): Int =
      if ((cndNdx > topNdx) || !isCmpst(cndNdx)) 2 * cndNdx + 3
      else getNxtPrmFrom(cndNdx + 1)

    Iterator.single(2) ++ Iterator.iterate(3)(p => getNxtPrmFrom((p - 1) >>> 1)).takeWhile(_ <= top)
  }

  @tailrec
  def loop(s: String){
    if(s != null){
       val Array(n,_*) = s.split(" ").map(_.toInt)
       if(n<2) println(0)
       else println(sieve(n).size)
       loop(readLine)
    }
  }

  def main(args: Array[String]): Unit ={
    loop(readLine)
  }
}

Measured memory_bytes: 65580
#include <iostream>
#include <string>
#include <map>
using namespace std;
int main(){
	string str,s,mls,mcs,input[100];
	map <string,int> dic;
	int n,c,a,ml,mc;
	getline(cin,str);
	c = a = mc = ml = 0;
	str += ' ';
	while(str.length()){
		n = str.find(' ');
		s = str[c];
		++c;
		for(;c < n;++c){
			s += str[c];
		}
		str.erase(0,n+1);
		c = 0;
		input[a] = s;
		++a;
		++dic[s];
		if(s.length() > ml) {
			ml = s.length();
			mls = s;
		}
	}
	for(int i = 0;i < a;++i){
		if(mc < dic[input[i]]){
			mc = dic[input[i]];
			mcs = input[i];
		}
	}
	cout << mcs << " " << mls << endl;
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
using namespace std;
int main(){
	int n,b=1,count=0,d;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	while(a[b-1]!=0 && a[b-1]!=2){
		d=b;
		b=a[b-1];
		a[d-1]=0;
		count=count+1;
	}
	if(a[b-1]==2){
		cout<<count+1<<endl;
	}
	else{
		cout<<"-1"<<endl;
	}
	return 0;
}


Measured memory_bytes: 640
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include <cassert>
    #include <cmath>

    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))

    using namespace std;
    using ll = long long;
    using Graph = vector<vector<int>>;
    using P = pair<int,int>;


    
    
    int main(){
        int n;cin>>n;
        VEC(int,p,n);
        int cnt = 0;
        int mn = INF;
        rep(i,n){
            if(p[i]<=mn)cnt++;
            mn = min(mn,p[i]);
        }
        cout<<cnt;
    }
    


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>

void printArray(int* A, int N){
  for (int i = 0; i < N; i++) {
    std::cout << A[i];
    if (i!=N-1) {
      std::cout << " ";
    }
  }
  std::cout <<'\n';
}

void bubbleSort(int* A, int n){
  int flag=1;
  int cnt=0;
  int sorted_i=0;
  while (flag) {
    flag=0;
    for (int i = n-1; i > sorted_i; i--) {
      if(A[i-1] > A[i]){
        std::swap(A[i-1], A[i]);
        cnt++;
        flag=1;
      }
    }
    sorted_i++;
  }
  printArray(A,n);
  std::cout << cnt << '\n';
}

int main() {
  int n;
  std::cin >> n;
  int* A = new int[n];
  for (int i = 0; i < n; i++) {
    std::cin >> A[i];
  }
  bubbleSort(A,n);
  return 0;
}



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

int main() {
	int n,m;
	cin >> n >> m;
	if (n == m) cout << "Yes";
	else cout << "No";
	return 0;
}


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

using namespace std;

/* 最長増加部分列 */
template <typename T>
size_t LIS(const vector<T> &A) {
  size_t n = A.size();
  vector<T> L;
  L.push_back(A[0]);
  size_t length = 1;
  for (int i = 1; i < n; i++) {
    if (L[length - 1] < A[i]) {
      L.push_back(A[i]);
      length++;
    } else {
      *lower_bound(L.begin(), L.end(), A[i]) = A[i];
    }
  }

  return length;
}

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

  cout << LIS(c) << endl;

  return 0;
}


Measured memory_bytes: 3728
#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 fbo find_by_order
#define ook order_of_key
#define fi first
#define se second
#define long long long
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

map<int,int> mp;

int main()
{
	// freopen("input.in", "r", stdin);

	int n; cin >> n;
	bool bol = 1;
	for(int i = 0; i < n; i++)
	{
		int x; cin >> x;
		if(mp[x]) bol = 0;
		mp[x] = 1;
	}
	if(bol) cout << "YES\n";
	else cout << "NO\n";
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
int main(){
	int f1=0,f2=0;
	string a;
	cin>>a;
	for(int i=0;i<a.size();i++){
		if(a[i]=='C')f1=1;
		if(f1&&a[i]=='F')f2=1;
	}
	if(f2)printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
typedef struct{
    int head;
    int tail;
    int right;
    int left;
    int up;
    int down;
} dice;
dice s(dice a) {
    int buf;
    buf = a.tail;
    a.tail = a.down;
    a.down = a.head;
    a.head = a.up;
    a.up = buf;
	return a;
}
dice n(dice a) {
	return s(s(s(a)));
}
dice e(dice a) {
    int buf;
    buf = a.tail;
    a.tail = a.right;
    a.right = a.head;
    a.head = a.left;
    a.left = buf;
	return a;
}
dice w(dice a) {
	return e(e(e(a)));
}
dice rev(dice a) {
	return e(e(a));
}
dice round(dice a) {
	int buf;
	buf = a.right;
	a.right = a.up;
	a.up = a.left;
	a.left = a.down;
	a.down = buf;
	return a;
}
bool same(dice a, dice b) {
	dice c = a;
	rep(i,4) {
		if(c.head == b.head && c.tail == b.tail && c.up == b.up && c.down == b.down && c.right == b.right && c.left == b.left) return true;
		c = round(c);
	}
	return false;
}

int main() {
    int k, a[105][6];
	cin >> k;
	rep(i,k) {
		rep(j,6) {
	        cin >> a[i][j];
		}
	}
	rep(i,k) {
		rep2(j,i+1,k) {
			dice da, db;
			da.head = a[i][0];
			da.down = a[i][1];
			da.right = a[i][2];
			da.left = a[i][3];
			da.up = a[i][4];
			da.tail = a[i][5];
			db.head = a[j][0];
			db.down = a[j][1];
			db.right = a[j][2];
			db.left = a[j][3];
			db.up = a[j][4];
			db.tail = a[j][5];	
			if(same(da,db) || same(s(da), db) || same(n(da), db) || same(e(da), db) || same(w(da), db) || same(rev(da), db)) {
				cout << "No" <<endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;	
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <list>
#include <cstdlib>

using std::cin;
using std::cout;
using std::endl;

int main(void) {
	int n,r;

	cin >> n;
	cin >> r;

	while (n != 0 || r != 0) {
		std::list<int> lst;
		int now = 1;

		for (int i = 0; i < n; i++) {
			lst.push_back(i+1);
		}

		for (int i = 0; i < r; i++) {
			int index = 1;
			int p,c;
			cin >> p;
			cin >> c;

			for (std::list<int>::iterator itr = lst.begin(); itr != lst.end();) {
				if (index >  n-(p-1)-c && index < n-(p-2)){
					lst.push_back(*itr);
					itr = lst.erase(itr);
				}else{
					itr++;
				}	
				index++;
			}
		}
		for (std::list<int>::iterator itr = lst.begin(); itr != lst.end(); ++itr) {
			if (now == n) {
				cout << *itr << endl;
			}
			now++;
		}
		cin >> n;
		cin >> r;
	}	
	return 0;
}

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

int n, m;

int main()
{
	scanf("%d%d", &n, &m);
	vector<pair<int, int> > vec(n);
	for (int i = 0; i < n; i++) {
		scanf("%d%d", &vec[i].first, &vec[i].second);
	}
	sort(vec.begin(), vec.end());
	multiset<int> s;
	int ans = 0, j = 0;
	for (int i = 1; i <= m; i++) {
		for (; j < n && vec[j].first <= i; j++) {
			s.insert(vec[j].second);
		}
		if (s.size() > 0) {
			auto it = s.end();
			it--;
			ans += *it;
			s.erase(it);
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 5632
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAXN 200010
#define MAXM 8010
#define MO 1000000007
int fac[MAXM+5],inv[MAXM+5],f[MAXM/2][MAXM/2];
int PowMod(int a,int b)
{
	int ret=1;
	while(b)
	{
		if(b&1) ret=1LL*ret*a%MO;
		a=1LL*a*a%MO;
		b>>=1;
	}
	return ret;
}
int a[MAXN],b[MAXN],n,ans;
int C(int n,int m)
{
	return 1LL*fac[n]*inv[m]%MO*inv[n-m]%MO;
}
int main()
{
//	freopen("bbq.in","r",stdin);
//	freopen("bbq.out","w",stdout);
	fac[0]=1;
	for(int i=1;i<=MAXM;i++) fac[i]=1LL*fac[i-1]*i%MO;
	inv[MAXM]=PowMod(fac[MAXM],MO-2);
	for(int i=MAXM-1;i>=0;i--)
		inv[i]=1LL*inv[i+1]*(i+1)%MO;
	scanf("%d",&n);	
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&a[i],&b[i]);
		f[2000-a[i]][2000-b[i]]++;
	}
	for(int i=0;i<=4000;i++)
		for(int j=0;j<=4000;j++)
		{
			if(i!=0) (f[i][j]+=f[i-1][j])%=MO;
			if(j!=0) (f[i][j]+=f[i][j-1])%=MO;
		}
	for(int i=1;i<=n;i++)
		(ans+=f[a[i]+2000][b[i]+2000])%=MO;
	for(int i=1;i<=n;i++)
		(ans-=C((a[i]+b[i])*2,a[i]*2)-MO)%=MO;
	ans=1LL*ans*500000004%MO;
	printf("%d\n",ans);
}

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

#define ll long long 
#define pb push_back
#define pu push
#define ins insert
#define f(s,e) for(i=s;i<e;i++)
#define loop(i) while(i--)
#define bg(v) v.begin()
#define ed(v) v.end()
#define sz(v) v.size()
#define len(v) v.length()
#define con continue;
#define brk break;
#define sn cout<<"\n";
#define in(n) cin>>n;
#define out(n) cout<<n;





int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    ll t,op,i,j,k,m,h,n;
    cin>>n>>m;
    ll mod=1000000007;
    char c[n+1][m+1];
    for(i=1;i<=n;i++)
    for(j=1;j<=m;j++)
    cin>>c[i][j];
    ll dp[n+1][m+1];
    for(i=0;i<=n;i++)
    for(j=0;j<=m;j++)
    dp[i][j]=0;
    dp[1][1]=1;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            if(c[i][j]=='.')
            {
                if(j+1<=m&&c[i][j+1]=='.')
                dp[i][j+1]=(dp[i][j+1]+dp[i][j])%mod;
                if(i+1<=n&&c[i+1][j]=='.')
                dp[i+1][j]=(dp[i+1][j]+dp[i][j])%mod;
            }
        }
    }
    cout<<dp[n][m];
	return 0; 
} 

Measured memory_bytes: 9088
N, K, C = map(int, input().split())
S = input()

# 前から貪欲に働く日を決めていく。一番早く働く場合
L = []
L_l = 0
off = 0
for i in range(N):
    if S[i] == 'o' and off <= 0:
        L.append(i)
        L_l += 1
        if L_l == K:
            break
        off = C
    else:
        off -= 1

# 後ろから貪欲に働く日を決めていく。一番遅く働く場合
R = []
R_l = 0
off = 0
for i in range(N-1, -1, -1):
    if S[i] == 'o' and off <= 0:
        R.append(i)
        R_l += 1
        if R_l == K:
            break
        off = C
    else:
        off -= 1
R.sort()

# 一番早く働いても遅く働いてもi番目に働く日が同じになる場合、その日は必ず働く必要がある
ans = []
for i in range(K):
    if L[i] == R[i]:
        ans.append(L[i]+1)
print(*ans, sep='\n')


Measured memory_bytes: 65060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    ll n;
    cin >> n;
    ll a[n];
    rep(i, 0, n) cin >> a[i];
    ll ans = 0;
    rep(i, 0, 61) {
        ll sum1 = 0;
        rep(j, 0, n) {
            if (a[j] & (1LL << i)) sum1++;
        }
        ans += (((1LL << i) % MOD) * ((sum1 * (n - sum1)) % MOD)) % MOD;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
    long long a,b,x;
    cin>>a>>b>>x;
    if (a==0){
        cout<<b/x+1;
    }
    else{
        cout<<(b/x)-((a-1)/x);
    }
    return 0;
}

Measured memory_bytes: 256
N=int(input())
S=input()
S_list=list(S)
S_max=0
for n in range(N):
    S_list_former=set(S_list[:n])
    S_list_latter=set(S_list[n:N])
    S_list_com=len(S_list_former & S_list_latter)
    if S_list_com>=S_max:
        S_max=S_list_com
print(S_max)

Measured memory_bytes: 3060
#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;

int main()
{
    char A[50], B[50],c[100];
    int i,j,lnth;

    cin>>A;
    cin>>B;

    lnth = strlen(A) + strlen(B);

    for(i=0,j=0;j<lnth; i++,j++)
    {
        c[i] = A[j];
        c[i+1] = B[j];
        i++;
    }
    cout<<c;
}



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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int N, K;
  scanf("%d %d", &N, &K);
  vector<int> X(N);
  for (int i = 0; i < N; ++i) { scanf("%d", &X[i]); }
  int ans = 0;
  for (int i = 0; i < N; ++i) {
    ans += min(X[i] * 2, abs(K - X[i]) * 2);
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
/*input

*/


//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define pb          push_back
#define pii         pair<ll int,ll int>
#define vpii        vector< pii >
#define vi          vector<ll int>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll int i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int solve()
{
	ll n;cin>>n;
	vvi a(3,vi (n,0));
	rep(i,0,n) rep(j,0,3) cin>>a[j][i];
	vvi dp(n, vi(3,0));
	rep(i,0,n) rep(j,0,3) dp[i][j] = (i-1>=0?max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3]):0) + a[j][i];
	cout<<max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]);
	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	// cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}

Measured memory_bytes: 8056
x = int(input())


def ab(x):
    for a in range(70):
        for b in range(70):
            if a ** 5 + b ** 5 == x:
                return (a, -b)

    for a in range(200):
        for b in range(a):
            if a ** 5 - b ** 5 == x:
                return (a, b)

a, b = ab(x)
print(a, b)


Measured memory_bytes: 9184