akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std ;

const int MAX = 3e5 + 10 ;

int arr[MAX] , freq[MAX] , suff[MAX] , mark[MAX] ;
vector<int>er[MAX] ;
int n ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n ;
	vector<int>v ;
	for(int i = 0 ; i < n ; ++i)
	{
		cin>>arr[i] ;
		freq[arr[i]]++ ;
	}
	for(int i = 0 ; i < n ; ++i)
	{
		if(freq[arr[i]])
			v.push_back(freq[arr[i]]) ;
		freq[arr[i]] = 0 ;
	}
	sort(v.rbegin() , v.rend()) ;
	int sz = v.size() ;
	for(int i = sz-1 ; i >= 0 ; --i)
		suff[i] = suff[i+1] + v[i] ;
	int idx = sz-1 ;
	for(int i = 1 ; i <= n ; ++i)
	{
		while(idx >= 0 && v[idx] < i)
			idx-- ;
		int k = idx+1 + suff[idx+1] / i ;
		er[k].push_back(i) ;
	}
	int k = n ;
	for(int i = 1 ; i <= n ; ++i)
	{
		while(mark[k])
			k-- ;
		cout<<k<<"\n" ;
		for(auto &j : er[i])
			mark[j] = 1 ;
	}
	return 0 ;
}		

Measured memory_bytes: 18200
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

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

    int dp[100010][3] = {};

    rep(i, n) {
        rep(j, 3) {
            int ni = i+1;
            if (j != 0) {
                dp[ni][0] = max(dp[ni][0], dp[i][j] + a[i]);
            }

            if (j != 1) {
                dp[ni][1] = max(dp[ni][1], dp[i][j] + b[i]);
            }

            if (j != 2) {
                dp[ni][2] = max(dp[ni][2], dp[i][j] + c[i]);
            }
        }
    }

    int res = 0;
    rep(i, 3) res = max(res, dp[n][i]);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 2560
import sys
input = sys.stdin.readline
N,X = map(int,input().split())

li = list(map(int,input().split()))	


res = 0
i = 0
ans = 1
for i in range(N):
    res += li[i]
    ans += 1
    if res > X:
        ans -= 1
        break
print(min(ans,N+1))
    

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(i,n)cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

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

    ll coins = 0;

    int day=0;
    do{
        day++;
        coins += a;
        if(day%7==0) coins += b;
    }while(coins<c);

    cout << day << endl;
    return 0;
}


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

using namespace std;

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

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

  int max = 0;
  int count = 0;

  for(int i = n-2; i >= 0; i--) {
    if(h[i] >= h[i+1]) {
      count++;
    }else {
      if(count > max) {
        max = count;
      }
      count = 0;
    }
  }

  if(count > max) {
    max = count;
  }

  cout << max << endl;
  return 0;
}

Measured memory_bytes: 640
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define MIN -10000000
#define MAX 10000000
#define debug printf("%d",__LINE__)
using namespace std;
long long a[114511141];
int main()
{
	int n;
	scanf("%d", &n);
	int cnt = 0;
	if(n < 3) return printf("0"), 0;
	for(int i=1; i<=n; i++) scanf("%lld", &a[i]);
	for(int i=1; i<=n; i++)
		for(int j=i+1; j<=n; j++)
			for(int k=j+1; k<=n; k++)
				if(a[i] != a[j] && a[j] != a[k] && a[i] != a[k])
					if(a[i] + a[j] > a[k])
						if(a[i] + a[k] > a[j])
							if(a[j] + a[k] > a[i])
								cnt ++;
	printf("%d", cnt);
	return 0;
}


Measured memory_bytes: 3824
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	m := make(map[int]int)
	for i := 0; i < n; i++ {
		var x int
		fmt.Scan(&x)
		m[x]++
	}

	if m[0] == n {
		fmt.Println("Yes")
		return
	}

	if n%3 != 0 {
		fmt.Println("No")
		return
	}

	switch len(m) {
	case 2:
		if m[0] == n/3 {
			fmt.Println("Yes")
			return
		}
	case 3:
		x := make([]int, 0, 3)
		for k, v := range m {
			if v != n/3 {
				fmt.Println("No")
				return
			}
			x = append(x, k)
		}
		if x[0]^x[1]^x[2] == 0 {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")
}


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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

#define INF 1000000000000000000

int main(){
  LL n,s;
  cin >> n >> s;
  if(n<s){
    cout << -1 << endl;
    return 0;
  }
  LL ans=INF;
  if(n==s) ans=n+1;
  for(LL i=1;i<=100*sqrt(n);i++){
    if((n-s)%i==0&&0<=n-(n+i-s)/i*i&&n-(n+i-s)/i*i<(n+i-s)/i&&(n+i-s)/i!=1) if((n+i-s)/i*((n+i-s)/i)!=n||s==1)ans=min(ans,(n+i-s)/i);
  }
  LL tmp;
  for(LL i=2;(double)i<=sqrt(n)+10;i++){
    tmp=0;
    for(LL x=n;x>0;tmp+=x%i,x/=i);
    if(tmp==s&&ans!=1) ans=min(ans,i);
  }
  if(ans==INF){
    cout << -1 << endl;
  }else{
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> P3;
typedef pair<P ,P> PP;
constexpr ll MOD = ll(1e9) + 7;
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(2e5) + 5;
constexpr double EPS = 1e-8;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

ll mod_power(ll x, ll n) {  //繰り返し二乗法
    ll res = 1;
    while (n > 0) {
        if (n & 1) {
            res = res * x % MOD;
        }
        x = x * x % MOD;
        n >>= 1;
    }
    return res;
}

ll factrial[MAX_N], inverse[MAX_N];

void init(ll n) {
    factrial[0] = 1;
    inverse[0] = 1;
    for (ll i = 1; i <= n; i++) {
        factrial[i] = (factrial[i - 1] * i) % MOD;  //階乗を求める
        inverse[i] = mod_power(factrial[i], MOD - 2) % MOD;  //オイラーの定理で逆元を求める
    }
}

ll nCk(ll n, ll k) {
    if(n < 0 || k < 0 || n < k) return 0;
    return factrial[n] * inverse[k] % MOD * inverse[n - k] % MOD;
}

int main() {
    ll n, a, b, c, p = 1, q = 1, ansp=0, ansq=1;
    cin >> n >> a >> b >> c;
    init(2*n);
    REP(i,n){
        p = 1;
        q = 1;
        p *= 100*(n+i);
        p %= MOD;
        q *= 100-c;
        q %= MOD;

        p *= mod_power(a,n);
        p %= MOD;
        p *= mod_power(b,i);
        p %= MOD;
        p *= nCk(n-1+i,i);
        p %= MOD;
        //cout << nCk(n-1+i,i) << endl;

        q *= mod_power(a+b,n+i);
        q %= MOD;
        //cout << p << " " << q << endl;

        ansp *= q;
        ansp %= MOD;
        p *= ansq;
        p %= MOD;
        ansq *= q;
        ansq %= MOD;
        ansp += p;
        ansp %= MOD;
    }
    //cout << p << " " << q << endl;
    REP(i,n){
        p = 1;
        q = 1;
        p *= 100*(n+i);
        p %= MOD;
        q *= 100-c;
        q %= MOD;

        p *= mod_power(b,n);
        p %= MOD;
        p *= mod_power(a,i);
        p %= MOD;
        p *= nCk(n-1+i,i);
        p %= MOD;

        q *= mod_power(a+b,n+i);
        q %= MOD;

        ansp *= q;
        ansp %= MOD;
        p *= ansq;
        p %= MOD;
        ansq *= q;
        ansq %= MOD;
        ansp += p;
        ansp %= MOD;
    }

    ll r = ansp * mod_power(ansq, MOD-2) % MOD;
    cout << r << endl;
    return 0;
}


Measured memory_bytes: 3328
M = int(input())
keta = 0
kei = 0
for i in range(M):
    [dtmp,ctmp] = list(map(int,input().split()))
    keta += ctmp
    kei += dtmp*ctmp

kei10 = kei//9

if kei%9==0:
    kei10-=1

output = keta-1 + kei10
print(output)

Measured memory_bytes: 44760
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{

    ll t;
    ll n,k,x;
    t=1;
    vector <ll> v,v1;
    string s;

    while(t--){
        cin>>n>>x>>k;
        ll a=n/x;
        if(x*a!=n) a++;
        cout<<a*k<<endl;;

    }
    return 0;
}



Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
int main()
{
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    rep(i, N) cin >> A.at(i);
    rep(i, min(100LL, K)){
        vector<ll> imos(N+1, 0);
        rep(i, N){
            imos.at(max(i - A.at(i), 0LL))++;
            imos.at(min(i + A.at(i) + 1, N))--;
        }
//        rep(i, N+1){
//            cout << imos.at(i) << " ";
//        }
//        cout << endl;
        A.at(0) = imos.at(0);
        rep(i, N-1){
            A.at(i+1) = A.at(i) + imos.at(i+1);
        }
    }
    rep(i, N-1){
        cout << A.at(i) << " ";
    }
    cout << A.at(N-1) << endl;
}

Measured memory_bytes: 6400
def main
  while nums = gets
    nums = nums.split(/\s/).collect { |x| x.to_i}
    break if nums[0] == 0
    arrs = solve nums
    n = gets.chomp.to_i
    (1..n).each do |ca|
      radius = gets.chomp.to_i
      puts "NA" if arrs.min >= radius
      puts "OK" if arrs.min < radius
    end
  end
end

def solve nums
  ret = []
  nums = nums.collect { |x| x /= 2.0}
  ret << Math.sqrt(nums[0] ** 2 + nums[1] ** 2)
  ret << Math.sqrt(nums[1] ** 2 + nums[2] ** 2)
  ret << Math.sqrt(nums[0] ** 2 + nums[2] ** 2)
  ret
end

main

Measured memory_bytes: 6160
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
                 (shadow :run)
                 (use-package :fiveam)))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS
(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(defmacro println (obj &optional (stream '*standard-output*))
  `(let ((*read-default-float-format* 'double-float))
     (prog1 (princ ,obj ,stream) (terpri ,stream))))

(defconstant +mod+ 1000000007)

;; Hauptteil

(defun main ()
  (let* ((n (read))
         res)
    (if (evenp n)
        (dotimes (i n)
          (loop for j from (1+ i) below n
                do (unless (= (+ i j) (- n 1))
                     (push (cons (1+ i) (1+ j)) res))))
        (progn
          (dotimes (i n)
            (loop for j from (1+ i) below (- n 1)
                  do (unless (= (+ i j) (- n 2))
                       (push (cons (1+ i) (1+ j)) res))))
          (dotimes (i (- n 1))
            (push (cons (1+ i) n) res))))
    (println (length res))
    (dolist (pair res)
      (format t "~D ~D~%" (car pair) (cdr pair)))))

#-swank(main)


Measured memory_bytes: 18664
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
#define ll long long
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl;
#define WHITE 0
#define BLACK 2
#define GRAY 1
#define RE return 0;

int main(){
  int suma=0,sumb=0;
  for(int i=0; i<4; i++){
    int a;
    cin>>a;
    suma+=a;
  }
  for(int i=0; i<4; i++){
    int b;
    cin>>b;
    sumb+=b;
  }
  
  cout<<(suma>=sumb ? suma:sumb)<<en
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define lpin(a,i,n) for(int i=0;i<n;i++){cin>>a[i];}

int main(){
  while(1){
    int n,a,b,c,x;
    cin>>n>>a>>b>>c>>x;
    if(n==0&&a==0&&b==0&&c==0&&x==0) break;
    int ans=0;
    int j,i;
    for(i=0;i<n;i++){
      int rand;
      cin>>rand;
      for(j=0;j<10001;j++){
	if(x==rand){
	  rand=-1;
	  break;
	}
	x=(a*x+b)%c;
	ans++;
	if(ans>10000){
	  ans=-1;
	  break;
	}
      }
      if(ans==-1){
	ans=-1; break;
      }
      if(rand!=-1){
	ans=-1; break;
      }
      x=(a*x+b)%c;
      ans++;
    }
    if(i==n-1) 1;
    else lp(k,n-1-i){
	int rand;
	cin>>rand;
      }
    if(ans==-1) cout<<"-1"<<endl;
    else cout<<ans-1<<endl;
  }
  return 0;
}



Measured memory_bytes: 3056
N = int(input())
H = list(map(int,input().split()))

DP = []

for i in range(N):
    DP.append(10 ** 9)

DP[0] = 0
DP[1] = abs(H[1]-H[0])

for j in range(2, N):
    DP[j] = min(DP[j], DP[j - 1] + abs(H[j] - H[j - 1]))
    DP[j] = min(DP[j], DP[j - 2] + abs(H[j] - H[j - 2]))

print(DP[N - 1])

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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		List<Pair>[] P = new List<Pair>[C];
		for(int i=0;i<C;i++){
			P[i] = new List<Pair>();
		}
		
		for(int i=0;i<N;i++){
			P[Cs[i]].Add(new Pair(S[i],T[i]));
		}
		
		for(int i=0;i<C;i++){
			P[i].Sort((p,q) => p.S.CompareTo(q.S));
		}
		
		for(int i=0;i<C;i++){
			if(P[i].Count == 0) continue;
			var l = new List<Pair>();
			l.Add(P[i][0]);
			for(int j=1;j<P[i].Count;j++){
				if(P[i][j].S == l[l.Count-1].T){
					l[l.Count-1].T = P[i][j].T;
				} else {
					l.Add(P[i][j]);
				}
			}
			P[i] = new List<Pair>(l);
		}
		int MM = T.Max() + 20;
		int[] imos = new int[MM+1];
		foreach(var ll in P){
			foreach(var p in ll){
				imos[p.S - 1] += 1;
				imos[p.T] += -1;
			}
		}
		
		int[] tot = new int[MM+1];
		for(int i=0;i<MM;i++){
			tot[i+1] = tot[i] + imos[i];
		}
		Console.WriteLine(tot.Max());
		
	}
	
	class Pair{
		public int S,T;
		public Pair(int s, int t){
			S = s; T = t;
		} 
	}
	
	int N,C;
	int[] S,T,Cs;
	public Sol(){
		var d = ria();
		N = d[0]; C = d[1];
		S = new int[N];
		T = new int[N];
		Cs = new int[N];
		for(int i=0;i<N;i++){
			d = ria();
			S[i] = d[0] * 2;
			T[i] = d[1] * 2;
			Cs[i] = d[2] - 1;
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

using namespace std;

int main(){
int N; cin >> N;
  vector<pair<int,int>> AB(N); vector<pair<int,int>> CD(N);
  
  vector<bool> flag = {false};
  
  for(int i = 0; i < N; i++){cin >> AB[i].first >> AB[i].second;}
  
  for(int j = 0; j  <N; j++){cin >> CD[j].first >> CD[j].second;}
  
  sort(CD.begin(),CD.end());
  
  int cnt = 0;
  
  for(int i = 0; i < N; i++){
    int x = CD[i].first;
    int y = CD[i].second;
    int number = -1;
    int max_alt = -1;
    for(int j = 0; j < N; j++){
      if( AB[j].first < x && AB[j].second < y && flag[j] == false){
        if( AB[j].second > max_alt){
          max_alt = AB[j].second; number = j;}}}
    if(max_alt != -1){ flag[number] = true; //j番目のAB点が繋がる(もう使えない)
                      cnt++;}}
  
  cout<< cnt << endl; return 0;}
      
  

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <math.h>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}*/


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

	int a, b;
	cin >> a >> b;

	int ans = 0;

	for (int i = 0; i < 2; i++) {
		if (a >= b) {
			ans += a;
			a--;
		}
		else {
			ans += b;
			b--;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <stack>
#include <vector>
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstring>
#include <queue>
#include <string>

using namespace std;

const double PI = 3.14159265358979;

//int G[101][101];
int visited[10001];
int n;

int d[10001];


struct Vertex {
	int u;
	int weight;

	friend bool operator < (Vertex a, Vertex b) {
		return a.weight > b.weight;
	}
};

vector<Vertex> G[10001];

void dijkstra(int start) {

	priority_queue<Vertex> PQ;

	for (int i = 0; i < n; i++)	{
		d[i] = INT_MAX;
	}

	d[start] = 0;
	PQ.push(Vertex{ 0,0 });

	while (!PQ.empty()) {
		Vertex f = PQ.top();
		PQ.pop();
		int u = f.u;
		if (visited[u]) {
			continue;
		}
		else {
			visited[u] = 1;
		}

		//if (f.weight > d[u]) continue;

		
		for (int j = 0; j < G[u].size(); j++)
		{
			int v = G[u][j].u;
			if (!visited[v]) {
				if (d[u] + G[u][j].weight < d[v]) {
					PQ.push(Vertex{ v, d[u] + G[u][j].weight });
					d[v] = d[u] + G[u][j].weight;
				}
			}
		}
	}


}

int main() {
	
	
	cin >> n;

	for (int i = 0; i < n; i++)	{
		int u, k; cin >> u >> k;
		for (int j = 0; j < k; j++)	{
			int v, w; cin >> v >> w;
			G[u].push_back(Vertex{ v, w });
		}
	}

	dijkstra(0);

	for (int i = 0; i < n; i++)	{
		cout << i << " " << d[i] << endl;
	}

	return 0;
}



Measured memory_bytes: 8096
# Q2
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
from functools import lru_cache

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N, D = LI()
total = 0
for i in range(N):
    X, Y = LI()
    if math.sqrt(X**2 + Y**2) <= D:
        total += 1
print(total)

Measured memory_bytes: 27196
def read():
    return raw_input()


def write(message):
    import sys
    print message
    sys.stdout.flush()


if __name__ == '__main__':
    n = int(read())

    allowed = [1, ]
    spow = 6
    while spow <= n:
        allowed.append(spow)
        spow *= 6
    npow = 9
    while npow <= n:
        allowed.append(npow)
        npow *= 9

    allowed = allowed[::-1]
    res = {a: 1 for a in allowed}

    def min_ops(N):
        global res
        global allowed
        if N in res:
            return res[N]

        for a in allowed:
            if N - a > 0:
                if N not in res or min_ops(N-a) + 1 < res[N]:
                    res[N] = min_ops(N-a) + 1
        return res[N]

    write(min_ops(n))







Measured memory_bytes: 13884
a, b, c = map(int, input().split())
if a == b == c and a % 2 == 0:
  print(-1)
else:
  cnt = 0
  while a%2 == b%2 == c%2 ==0:
    a, b, c = (b+c)//2, (a+c)//2, (a+b)//2
    cnt += 1
  print(cnt)


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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  for(int i=0; i<N-1; i++){
    if(A[i]==A[i+1]){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 1024
n=int(input())
al=list(map(int,input().split()))
ans=0
z=True
x=0
m=10**10
for a in al:
    ans+=abs(a)
    z=True if a==0 else False
    x+=1 if a<0 else 0
    m=min(m,abs(a))
if z or x%2==0:
    print(ans)
else:
    print(ans-m*2)

Measured memory_bytes: 14284
import itertools

n = int(input())
s = [0]*n
for i in range(n):
    s[i] = list(int(x) for x in input().split())

key = [[False]*n for i in range(n)]

for i in range(n):
    for j in range(i+1, n):
        key[i][j] = ((s[i][0]-s[j][0])**2+(s[i][1]-s[j][1])**2)**0.5
ans = 0
key_permnutation = list(int(x) for x in range(n))
for key_list in itertools.permutations(key_permnutation):
    for i in range(n-1):
        p, q = key_list[i], key_list[i+1]
        p, q = min([p, q]), max([p, q])
        ans += key[p][q]

for i in range(1, n+1):
    ans /= i
print(ans)

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

typedef long long ll;

int main() {
  int S;
  cin>>S;
  vector<int> Flag(1000010,0);
  int counter = 0;
  while(1) {
    counter++;
    if(Flag[S]) break;
    Flag[S] = 1;
    if(S % 2 == 0) {
      S /= 2;
    } else S = 3 * S + 1;
  }
  cout<<counter<<endl;
  return 0;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
int main(){
    vector<long> ans={0,0,0,0,0,0,0,0,0,1,1,1,1,2,2,3,3,3,3,8,8,11,11,11,11,14,14,32,32,35,35,35,35,42,42,42,42,49,49,49,49,49,49,75,75,86,86,86,86,86,86,123,123,131,131,131,131,148,148,153,153,170,170,170,170,170,170,227,227,227,227,227,227,250,250,323,323,324,324,324,324,354,354,354,354,384,384,384,384,384,391,491,491,529,529,529,529,529,529,543};
    long N;
    cin>>N;
    cout<<ans.at(N-1)<<endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

import math

for i in range(int(input())):
    a, b, c, d = map(int, input().split())

    if a < b:
        print('No')
        continue

    if b > d:
        print('No')
        continue

    if c >= b:
        print('Yes')
        continue

    g = gcd(b, d)
    r = a % g
    #_max = (math.ceil((b - r) / g) - 1) * g + r
    _max = ((b - r + g - 1)//g) * g + r - g
    if c < _max:
        print('No')
    else:
        print('Yes')


Measured memory_bytes: 67960
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<queue>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

typedef long long ll;
const ll INF = 1e17;
const int BIG = 1000000007;





int main() {

	int N;
	cin >> N;

	cout << (N - 1) / 2;
	
	system("PAUSE");

}


Measured memory_bytes: 504
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <map>
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
using namespace std;
int main() {
	vector<pair<int64_t,int64_t>> v;
	int64_t n,mini=0,ans;
	pair<int64_t, int64_t> sum;
	cin >> n;
	FOR(i, 0, n) {
		cin >> sum.first >> sum.second;
		v.emplace_back(sum);
		if (mini != max(sum.first, mini)) {
			mini = sum.first;
			ans = sum.second;
		}
	}
	cout << mini + ans;
	return 0;
}

Measured memory_bytes: 2420
x,k,d = map(int,input().split())

n = abs(x)//d 

if n < k:
  if (k-n) % 2 == 1:
    print(abs(abs(x) - n*d - d))
  else:
    print(abs(abs(x) - n*d))
else:
  print(abs(abs(x) - k*d))

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

bool check(ll n, ll a) {
  ll c = n;
  while(c >= a) {
    if(c % a == 0) c /= a;
    else c %= a; 
  }
  return (c == 1);
}

int main(){
  ll n;
  cin >> n;
  vector<ll> v;
  v.push_back(n);
  if(n != 2) v.push_back(n-1);
  for(ll i = 2; i*i <= n; i++) {
    if(n % i == 0) {
      v.push_back(i);
      v.push_back(n/i);
    }
  }
  for(ll i = 2; i*i <= n-1; i++) {
    if((n-1) % i == 0) {
      v.push_back(i);
      v.push_back((n-1)/i);
    }
  }
  set<int> s;
  for(auto x : v) {
    if(check(n,x)) s.insert(x);
  }
  cout << s.size() << endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define r(i, n) for (int i=0;i<n;i++)
using namespace std;
int main() {
  int n,a=0,b=0;
  cin >> n;
  int h[n];
  r(i, n) cin >> h[i];
  r(i, n-1) {
    if (h[i]>=h[i+1]) {
      b++;
      a=max(a,b);
    }
    else {
      b=0;
    }
  }
  cout << a << endl;
  return 0;
}


Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>		//UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>		//do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;

const int MR = 1e5 + 10;

int a[MR];

pair < int ,int > t[MR];

LL res[MR];

int main()
{
	int N;
	scanf("%d", &N);
	REP(i,N)
	{
		scanf("%d", &a[i]);
		t[i] = MP(a[i],i);
	}
	sort(t,t+N);
	int prev = 0, ind = 0;
	REP(i,N)
		// znajdz kolejny wiekszy od lewej
		if(a[i] > prev)
		{
			// wez wszystkie <= od niego po prawej
			// one automatycznie sa na prawo od niego - tak dziala algos
			while(ind < N && t[ind].first <= a[i])
			{
				res[i] += t[ind].first - prev;
				ind++;
			}
			// uzupelnij to, czego brakuje
			res[i] += (N-ind)*(LL)(a[i]-prev);
			// do kolejnego wiekszego
			prev = a[i];
		}

	REP(i,N)
		printf("%lld\n", res[i]);

	return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



int main() {
  int N; cin >> N;
  cout << 0 << endl;
  string front;
  cin >> front;
  if (front == "Vacant") return 0;

  string ans;
  int left = -1, right = N, mid;
  while (true) {
    mid = (left + right) / 2;
    cout << mid << endl;
    cin >> ans;
    if (ans == "Vacant") return 0;

    if (ans == front && mid % 2 == 0 || ans != front && mid % 2 == 1) {
      left = mid;
    }
    else right = mid;
  }


  return 0;
}

Measured memory_bytes: 852
import itertools

N, M, Q = map(int, input().split())
queue = []
for _ in range(Q):
    queue.append(list(map(int, input().split())))

ans = 0
for A in itertools.combinations_with_replacement(range(1, M+1), N):
    tmp = 0
    for q in queue:
        if A[q[1]-1] - A[q[0]-1] == q[2]:
            tmp += q[3]
    ans = max(ans, tmp)
print(ans)

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

using namespace std;

typedef long long ll;
ll pts[200005][6]={0};

ll mnht(ll pt[200005][6], int kth, int idx, int d)
{
    ll dist=0;

    for(int i=0;i<d;i++)
    {
        dist+=abs(pt[kth][i]-pt[idx][i]);
    }

    return dist;
}
   /*
   10
   -70 -64 -6 -56 64 61 -57 16 48 -98
   */
ll max_cmb(ll cmbn[6], ll pt[200005][6], int n, int d)
{
    ll pk=0;ll idx=0;

   for(int i=0;i<n;i++)
   {
       ll val=0;

       for(int j=0;j<d;j++)
       {
           val+=(1-2*cmbn[j])*pt[i][j];
       }

       if(val>pk)
       {
           pk=val;
           idx=i;
       }
   }

   return idx;
}

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

   ll pk[2<<d];

   for(int j=0;j< 1<<(d);j++)
   {
       ll cmbn[6]={0};
       for(int dig=0;dig< d; dig++)
       {
           if(j & 1<<dig)
             cmbn[dig]=1;
          // cout<<cmbn[dig]<<" ";
       }
//cout<<endl;
       pk[j]=max_cmb(cmbn, pts, n, d);
   }

   ll maxd=0;
   for(int i=0;i<n;i++)
   {
       for(int j=0;j< 1<<(d);j++)
       maxd=max(maxd, mnht(pts, i, pk[j], d));
   }

   cout<<maxd<<endl;
   return 0;
}


Measured memory_bytes: 13008
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int cmp(const void *p,const void *q){
    return *(int*)p-*(int*)q;
}
int main(){
    int N,M,X,Y;
    int city_x[100],city_y[100];
    int x_max,x_min,y_max,y_min;
    scanf("%d %d %d %d",&N,&M,&X,&Y);
    for(int i=0;i<N;i++){
        scanf("%d",&city_x[i]);
    }
    for(int i=0;i<M;i++){
        scanf("%d",&city_y[i]);
    }
    
   /* for(int i=0;i<N;i++){
        printf("[%d] %d\n",i,city_x[i]);
    }
    for(int i=0;i<M;i++){
        printf("[%d] %d\n",i,city_y[i]);
    }*/
    qsort(city_x,N,sizeof(int),cmp);
    qsort(city_y,M,sizeof(int),cmp);
    //puts("_______________");
    
    x_max=city_x[N-1];
    x_min=city_x[0];
    y_min=city_y[0];
    y_max=city_y[M-1];
   

    if(x_max<y_min && x_max<Y && y_min>X){
        puts("No War");
        return 0;
    }
    else{
        puts("War");
        return 0;
    }
        
    
    return 0;
}


Measured memory_bytes: 128
import sys
sys.setrecursionlimit(10 ** 7)

H, W = map(int, input().split())
A = []
for _ in range(H):
    A.append(input())


from collections import deque
todo = deque()
seen = [[False] * W for _ in range(H)]
route= [[0] * W for _ in range(H)]
for y in range(H):
    for x in range(W):
        if A[y][x] == '#':
            todo.append((x, y))
            seen[y][x] = True



dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]
cnt = -1
while todo:
    cnt += 1
    for _ in range(len(todo)):
        x, y = todo.popleft()
        #print(x, y)
        for i in range(4):
            if 0 <= x + dx[i] < W and 0 <= y + dy[i] < H:
                if seen[y + dy[i]][x + dx[i]] == False:
                    route[y + dy[i]][x + dx[i]] = route[y][x] + 1
                    seen[y + dy[i]][x + dx[i]] = True
                    todo.append((x + dx[i], y + dy[i]))

#print(seen)
# print(route)
# M = 0
# for y in range(H):
#     for x in range(W):
#         M = max(M, route[y][x])
# print(M)
print(cnt)

Measured memory_bytes: 94940
s = list(input())
n = len(s)
ans = [0]*n
for ri in range(2):
    count = 0
    for i in range(n):
        if s[i] == "R":
            count += 1
        else:
            ans[i] += count//2 #L
            ans[i-1] += -(-count//2)#R
            count = 0
    ans = ans[::-1]
    s = s[::-1]
    for i in range(n):
        if s[i] == "L":
            s[i] = "R"
        else:
            s[i] = "L"

print(" ".join(map(str, ans)))

Measured memory_bytes: 11656
#include <iostream>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

ll N, A[100000];

int main(void) {
  cin >> N;
  REP(i, 0, N) cin >> A[i];

  bool f = 0;
  ll odd = 0, n4 = 0;
  REP(i, 0, N) {
    if(A[i] % 4 == 0) n4++;
    else if(A[i] % 2 == 0) f = 1;
    else odd++;
  }
  cout << (odd + f <= n4 + 1 ? "Yes" : "No") << endl;
}


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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  ll a,b,c ;
  cin>>a>>b>>c;
  
  ll ans=0;
  if(a+b+1>=c) cout<<b+c<<endl;
  else cout<<a+2*b+1<<endl;
  
}
  



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

using i64 = int64_t;

int main(){
    i64 t1, t2, a1, a2, b1, b2;
    cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
    i64 p = (a1 - b1)*t1, q = (a2 - b2)*t2;
    if(p > 0){
        p *= -1;
        q *= -1;
    }
    if(p+q < 0)cout << 0 << endl;
    else if(p+q == 0)cout << "infinity" << endl;
    else{
        if((-p)%(p+q) == 0)cout << 2*(-p/(p+q)) << endl;
        else cout << 2*(-p/(p+q))+1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
s = input()
K = int(input())

idx = -1
for i, ss in enumerate(s):
    if ss != '1':
        idx = i
        break

ans = ''
if idx == -1:
    # 全て１のとき
    ans = '1'
else:
    if (idx + 1) <= K:
        ans = s[idx]
    else:
        ans = '1'
print(ans)


Measured memory_bytes: 3060
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int, L: "List[int]"):
    if 2*max(L) < sum(L):
        print(YES)
    else:
        print(NO)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    L = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, L)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <stdio.h>

int main(void)
{
	int h,w,a,b;
	while(1){
	scanf("%d %d",&h,&w);
	if(h==0)
	if(w==0)
	break;
		
	for(a=1;a<=h;a++){
		for(b=1;b<=w;b++){
		printf("#");}
	printf("\n");
	}
	printf("\n");
}
	return 0;
}

Measured memory_bytes: 572
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
using namespace std;
typedef unsigned long long int ulint;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=1e9+7;
const llint big=1e18+100;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else{return gcd(b,a%b);}}
llint lcm(llint a,llint b){return a/gcd(a,b) *b;}
template<class T,class U> auto LB(T& ve,U in){return lower_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto UB(T& ve,U in){return upper_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto LBI(T& ve,U in){return LB(ve,in)-ve.begin();}
template<class T,class U> auto UBI(T& ve,U in){return UB(ve,in)-ve.begin();}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
int main(void){
	int n,a,b;cin>>n>>a>>b;
	cout<<((b-a)%2==0?"Alice":"Borys")<<endl;RE;
}

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

fun ripPro0408d() {
    val (n, m) = readLine()!!.split(' ').map { it.toInt() }
    val broken = (1..m).map { readLine()!!.toInt() }.toSet()

    for (i in 0 until n - 1) if (i in broken && i + 1 in broken) return println(0)

    val fib = LongArray(n + 1)
    fib[0] = 1
    fib[1] = 1
    for (i in 0 until n - 1) fib[i + 2] = (fib[i + 1] + fib[i]) % MOD

    var answer = 1L

    var left = 0
    var right: Int

    while (left < n) {
        while (left < n && left in broken) left++
        right = left
        while (right < n && right + 1 !in broken) right++
        answer *= fib[right - left]
        answer %= MOD
        while (left < n && left !in broken) left++
    }

    println(answer)
}

private const val MOD = (1e9 + 7).toLong()


Measured memory_bytes: 48212
#include <iostream>
#include <vector>
 
using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;

struct PARAM {
    Int x;
    Int y;
    Int h;
};
Int Max(const Int a, const Int b) {
    if (a >= b) {
        return a;
    } else {
        return b;
    }
}

int main(void) {
    Int n;
    cin >> n;
    vector<PARAM> v(n);
    PARAM base;
    for (Int i = 0; i < n; ++i) {
        Int x, y, h;
        cin >> x >> y >> h;
        v[i] = {x, y, h};
        if (h != 0) {
            base = {x, y, h};
        }
    }
    for (Int i = 0; i <= 100; ++i) {
        for (Int j = 0; j <= 100; ++j) {
            // (i, j) が中心
            PARAM center = {i, j, base.h + abs(base.x - i) + abs(base.y - j)};
            bool isCenter = true;
            for (Int k = 0; k < n; ++k) {
                Int target_h = center.h - abs(center.x - v[k].x) - abs(center.y - v[k].y);
                target_h = Max(target_h, 0);
                if (v[k].h == target_h) {
                } else {
                    isCenter = false;
                }
            }
            if (isCenter == true) {
                cout << center.x << " " << center.y << " " << center.h << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3592
#include <stdio.h>
#include <math.h>

#define N 10000
int isprime(int);


  int main()
{
  int num[N];
  //int prime[N];
  int prime = 0;
  int i,j;


  scanf("%d",&i);
  //printf("i = %d",i);

  for(j = 0 ; j < i ; j++)
    {
      scanf("%d",&num[j]);
    }


  for(j = 0 ; j < i ; j++)
    {
      prime  += isprime(num[j]);
    }
  printf("%d\n",prime);
  return 0;
}

int isprime(int x)
{
  int i;
  double jud;
  
  if(x == 2)return 1;
  if(x < 2 || x % 2 == 0 )return 0;

  i = 3;
  while(i <= sqrt(x)){
    if(x % i == 0)return 0;

    i =  i + 2;
  }

  return 1;
}

Measured memory_bytes: 628
# -*- coding: utf-8 -*-

N = int(input())

flg = False
for i in range(9):
    ans = list(map(int, str(N/(i+1)).split(".")))
    if ans[1] == 0 and 0 < ans[0] < 10:
        flg = True
        break
if flg:
    print("Yes")
else:
    print("No")


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int n,m,q;
vector<int> g[111111];
int a[111111],b[111111],c[111111];
int bfs[111111][11];

int main(){
	cin.sync_with_stdio(false);
  cin>>n>>m;
  rep(i,m){
    int aa,bb;
    cin>>aa>>bb;
    aa--; bb--;
    g[aa].pb(bb);
    g[bb].pb(aa);
  }
  cin>>q;
  rep(i,q){
    cin>>a[i]>>b[i]>>c[i];
    a[i]--;
  }
  memset(bfs,-1,sizeof(bfs));
  for(int i=q-1;i>=0;i--){
    queue<PPI> que;
    que.push(PPI(P(a[i],i),b[i]));
    while(que.size()){
      int v=que.front().fi.fi,nq=que.front().fi.se,d=que.front().se;
      que.pop();
      if(bfs[v][d]!=-1)continue;
      bfs[v][d]=i;
      if(d==0)continue;
      rep(j,g[v].size()){
        que.push(PPI(P(g[v][j],i),d-1));
      }
    }
  }
  rep(i,n){
    int maxq=-1;
    rep(j,11){
      maxch(maxq,bfs[i][j]);
    }
    if(maxq==-1)cout<<0<<endl;
    else cout<<c[maxq]<<endl;
  }
	return 0;
}


Measured memory_bytes: 14936
S = input()


def check_even(stri):
    if len(stri) % 2 !=0:
        return False
    else:
        half = int(len(stri)/2)
        if stri[:half] == stri[half:]:
            return True
        else:
            return False


for i in range(len(S)):
    if check_even(S[:-(i+1)]):
        print(len(S)-(i+1))
        exit()


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr double inf = 10000000000 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-3 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

struct Data{
  ll f,a,x,y;
  bool u ;
  double ti,di;
  double dis(ll s,ll t){
    return sqrt((x - s) * (x - s) + (y - t) * (y - t));
  }
};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,f,a,t,x,y;
  cin >> n;
  Data A[2];
  A[0].u = false;
  A[1].u = false;
  A[0].di = 0;
  A[1].di = 0;
  ll bfr = -1LL;
  rep(i,n){
    cin >> f >> a >> t >> x >> y;
    if(A[t].u == false){
      A[t] = {f,a,x,y,true,inf,0};
      bfr = t;
    }
    else{
      if(A[t].a != a && bfr == t){
        if(A[t].di < A[t].dis(x,y) + eps){
          A[t].di = A[t].dis(x,y);
          A[t].ti = f - A[t].f;
        }
        else if(abs(A[t].di- A[t].dis(x,y)) <= eps){
          if(A[t].ti > f - A[t].f){
            A[t].ti = f - A[t].f;
          }
        }
      }
      bfr = t;
      A[t] = {f,a,x,y,true,A[t].ti,A[t].di};
    }
  }
  rep(i,2){
    if(A[i].di == 0){
      cout << -1 << ' ' << -1 << endl;
    }
    else
      fcout(10) << A[i].di << ' ' << A[i].ti/60.0 << endl;
  }
  return 0;
}

Measured memory_bytes: 3316
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map> 
#include<set>
#include<queue>

typedef long long ll;


#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h, w, n,m,k; string s,t;
char maze[60][60];
int dis[101][101]; int graph[52][52]; bool vis[52];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);

}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

int GetDigit(int num) {
	return log10(num) + 1;
}

int main() {
	cin >> n;
	ll cnt = 0;
	for (ll i = 1; i <= n; i++) {
		if (GetDigit(i) % 2 == 1) {
			cnt++;
		}
	}
	cout << cnt << endl;
}



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

// Define
using ll = int64_t;
using ul = uint64_t;
using ld = long double;
using pii = pair<int, int>;
const ll MOD = 1e9 + 7;
const ll INF = LONG_MAX;
const ul MAX = ULONG_MAX;
const char nl = '\n';

#define elif else if
#define def inline auto
#define run __attribute__((constructor)) def _

// Debug
#define debug(x) cerr << (x) << " (L:" << __LINE__ << ")" << '\n'

// Loop
#define inc(i, a, n) for (ll i = (a), _##i = (n); i < _##i; ++i)
#define dec(i, a, n) for (ll i = (a), _##i = (n); i > _##i; --i)
#define rep(i, n) inc(i, 0, n)
#define be(c) begin(c), end(c)

// Stream
#define fout(n) cout << fixed << setprecision(n)
#define fasten cin.tie(0), ios::sync_with_stdio(0)

// Speed
run() { fasten, fout(10); }
#pragma GCC optimize("-O3")
#pragma GCC target("avx")

// Math
inline ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

struct edge{
    int from, to;
    ll cost;
};
bool bellman_ford_n(const vector<edge>& g, vector<ll>& d, int s){
    const int n = d.size();
    d[s] = 0;
    rep(i, n) {
        bool update = false;
        for(auto& e : g){
            if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost){
                d[e.to] = d[e.from] + e.cost;
                update = true;
                if(i==n-1 && e.to == n-1) return false;
            }
        }
        if(!update) break;
    }
    return true;
}

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

    vector<edge> g;
    rep(i, m){
        int u, v;
        ll c;
        cin >> u >> v >> c;
        --u,--v;
        g.push_back({u,v,-c});
    }
    vector<ll> d(n, INF);
    if (!bellman_ford_n(g, d, 0)){
        cout << "inf" << nl;
        return 0;
    }
    cout<< -d[n-1] << nl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T = int> void print(vector<T> v){for(auto a:v)cout<<a<<" ";cout<<endl;}

/*
1回でH+W回、
H+Wlog(H+W)

縦の割り方を固定 → 横の割り方を貪欲で定める
*/

ll h,w,k,dp[11][1001];
string s[11];
ll ans=1e9;

ll count(int l, int r, int u, int d){
	return dp[d][r] - dp[u-1][r] - dp[d][l-1] + dp[u-1][l-1];
}

bool kireru(V<pair<int,int>> &v, int l, int r){
	bool ok=true;
	for(auto p:v){
		if(count(l,r,p.first,p.second)>k)ok=false;
	}
	return ok;
}

int main(void){
	cin>>h>>w>>k;
	rep(i,h)cin>>s[i];
	rep(i,h+1)rep(j,w+1)dp[i][j]=0;
	reg(i,1,h){
		reg(j,1,w){
			int d=0;
			if(s[i-1][j-1]=='1')d=1;
			dp[i][j] = dp[i][j-1] + dp[i-1][j] - dp[i-1][j-1] + d;
		}
	}
	rep(i,1<<(h-1)){
		ll sum=0;
		V<pair<int,int>> v;
		ll u=1;
		rep(j,h-1)if(1 & (i>>j)){
			sum++;
			v.push_back({u,j+1});
			u = j+2;
		}
		v.push_back({u,h});
		// rep(j,v.size()){
		// 	cerr<<"("<<v[j].first<<","<<v[j].second<<") ";
		// }
		// cerr<<endl;
		ll l=0;
		reg(j,1,w){
			if(!kireru(v,l+1,j)){
				if(j-l>1){
					sum++;
					l=j-1;
				}else{
					sum=1e9;
					break;
				}
			}
		}
		bool ok2=true;
		for(auto p:v){
			if(count(l+1,w,p.first,p.second)>k)ok2=false;
		}
		if(!ok2)sum=1e9;
		ans=min(ans,sum);
	}
	cout<<ans<<endl;
	return 0;
}

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

vector<int> par[1000];
string s[1000];

void dfs(int depth, int j){
    for(int i = 0; i < depth; i++)  cout << ".";
    cout << s[j] << endl;

    for(int i = 0; i < par[j].size(); i++){
        dfs(depth+1, par[j][i]);
    }
}

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

    int k;
    
    cin >> k >> s[0];

    if(n == 1){
        cout << s[0] << endl;
        return 0;
    }

    for(int i = 1; i < n; i++){
        cin >> k >> s[i];
        par[--k].push_back(i);
    }

    dfs(0, 0);

    return 0;
}


Measured memory_bytes: 3348