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

typedef long long ll;

const int N = 2e5+1;

long long a[N] = {0};
int main(){
	int n, f = 0;
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
		if(a[i] >= i || a[i] > a[i-1]+1)
			f++;
	}
	long long ans = a[n];

	for(int i = 1; i <= n-1; i++){
		if(a[i] >= a[i+1])
			ans += a[i];
	}
	if(f)
		cout << -1 << endl;	
	else cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1920
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int n,m,a[100000],b[100000],c[100000];
ll D[1000][1000];
int main(){
  cin >> n >> m;
  rep(i,n){
    rep(j,n){
      D[i][j]=INF;
    }
    D[i][i]=0;
  }
  rep(i,m){
    cin >> a[i] >> b[i] >> c[i];
    a[i]-=1;b[i]-=1;
    D[a[i]][b[i]]=c[i];
    D[b[i]][a[i]]=c[i];
  }
  
  rep(k,n){
    rep(i,n){
      rep(j,i){
        D[i][j]=min(D[i][j],D[i][k]+D[k][j]);
        D[j][i]=D[i][j];
      }
    }
  }
  int ans=0;
  rep(i,m){
    if(D[a[i]][b[i]]!=c[i]) ans+=1;
  }
  cout << ans << endl;
  
  return 0;
}
  
    
  
    

Measured memory_bytes: 2816
#include <cstdio>
#define MAX 10

int* sort(int* array);

int main(){
	int array[MAX];
	
	for(int i = 0; i < MAX; i++){
		array[i] = 0;
		scanf("%d", &array[i]);
	}
	
	sort(array);
	
	for(int i = MAX - 1; i > 6; i--){
		printf("%d\n", array[i]);
	}
	return 0;
}

int* sort(int* array){
    int temp = 0;
    for(int i = 0; i < MAX; i++){
        for(int j = 0; j < MAX - i - 1; j++){
            if(array[j] > array[j + 1]){
                temp = array[j];
                array[j] = array[j + 1];
                array[j + 1] = temp;
            }
        }
    }
    return array;
}

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


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

    map<int,int>mp;
    int n;
    cin>>n;
    long long ans = 0;
    for(int i=0; i<n; i++){
        int x;
        cin>>x;
        ans += mp[i-x];
        mp[x+i]++;
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 20660
import std.stdio, std.conv, std.string, std.algorithm, std.range;

void main() {
  auto N = readln.split[0].to!int;
  auto A = readln.split.to!(int[]);
  auto B = readln.split.to!(int[]);
  auto C = readln.split.to!(int[]);

  int result = 0;
  int before = -1;
  foreach(a; A) {
    result += B[a - 1];
    if (before != -1 && a - before == 1) {
      result += C[before - 1];
    }
    before = a;
  }
  result.writeln;
}

Measured memory_bytes: 256
class TwoPoints
  def initialize(array)
      @x1, @y1, @x2, @y2 = array
  end

  attr_accessor :x1, :y1, :x2, :y2

  def bisector
    return [
      @x2 - @x1,
      @y2 - @y1,
      (@x2 ** 2 + @y2 ** 2 - @x1 ** 2 - @y1 ** 2) / 2.0
    ]
  end

  def distance
    return Math.sqrt(((@x2 - @x1) ** 2 + (@y2 - @y1) ** 2).abs)
  end
end

class Simultaneous
  def initialize(array)
    @a,@b,@c,@d,@e,@f = array
  end

  attr_accessor :a,:b,:c,:d,:e,:f

  def calc
    x = (@c * @e - @b * @f) / (@a * @e - @b * @d).to_f
    y = (@c * @d - @a * @f) / (@b * @d - @a * @e).to_f
    x = 0 if x.abs == 0.0
    y = 0 if y.abs == 0.0
    return [x, y]
  end
end

gets.to_i.times do
  data = gets.split(" ").map(&:to_f)
  center = Simultaneous.new(TwoPoints.new(data.slice(0, 4)).bisector + TwoPoints.new(data.slice(2, 4)).bisector).calc
  radius = TwoPoints.new(data.slice(0, 2) + center).distance
  puts sprintf("%.3f %.3f %.3f", center[0], center[1], radius)
end

Measured memory_bytes: 6196
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	int a;
	cin>>a;
	if(a==1){
		cout<<0<<'\n';
	}
	else {
		cout<<1<<'\n';
	}
	return 0;
}

Measured memory_bytes: 3592
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		double a = sc.nextDouble();
		double b = sc.nextDouble();
		double x = sc.nextDouble();

		if(x <= a*a*b/2) {
		double tan = (a*b*b/2)/x;
		System.out.println(Math.toDegrees(Math.atan(tan)));
		}else {
		double tan = 2*(b*a*a-x)/(a*a*a);
		System.out.println(Math.toDegrees(Math.atan(tan)));
		}
		sc.close();
	}
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
#include <ext/rope>

#define min3(a,b,c)   min(a,min(b,c))
#define max3(a,b,c)   max(a,max(b,c))
#define min4(a,b,c,d) min(min(a,b),min(c,d))
#define max4(a,b,c,d) max(max(a,b),max(c,d))

#define count_one(a) __builtin_popcount(a)  // Returns the number of set bits(1) in a number(a). In long long use __builtin_popcountll(a)
#define parity(i)    __builtin_parity(i)  //even parity 0 and odd parity 1
#define blz(a)       __builtin_clz(a) //Returns the number of leading zeroes in a number(a)
#define btz(a)       __builtin_ctz(a) //Returns the number of trailing zeroes in a number(a)
#define gcd(a,b)     __gcd(a,b)
#define lcm(a,b)     (a*(b/gcd(a,b)))

#define pb   push_back
#define PI   M_PI
#define endl "\n"
#define sc   scanf
#define pf   printf

#define ll  long long
#define ull unsigned long long

#define W(t)            while(t--)
#define rep1(i,n)       for(int i = 0; i < n; i++)
#define rep2(a,b)       for(int i = a; i <= b; i++)
#define rep3(a,b,c)     for(int i = a; i <= b; i+=c)
#define irep(a,b,c)     for(int i = b; i >=a; i-=c)
#define repit(it,type)  for(it = type.begin(); it != type.end(); it++)
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
using namespace std;
using namespace __gnu_cxx;

int main()
{
     IOS
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n,i,k;
    int ans=0;

    cin>>n>>k;
    int a[n];
    rep1(i,n)
    {
         cin>>a[i];
    }
    sort(a,a+n);
    rep1(i,k)
    {
         ans+=a[i];
    }
    cout<<ans;

     return 0;
}



Measured memory_bytes: 3592
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;

using namespace std;

const long long MOD = 1000000007;

template<typename T>
constexpr T gcd(T m, T n) noexcept {
	while (1) {
		if (m < n) swap(m, n);
		if (!n) break;
		m %= n;
	}

	return m;
}

template<typename T>
constexpr T lcm(T m, T n) noexcept {
	return (m * n) / gcd(m, n);
}

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

	int n;
	ll m;
	cin >> n >> m;
	ll* a;
	a = new ll[n];
	rep(i, n) {
		cin >> a[i];
		a[i] = a[i] >> 1;
	}

	ll t = 1;
	rep(i, n) {
		t = lcm(t, a[i]);
		if (t > m) {
			cout << 0 << "\n";
			return 0;
		}
	}

	rep(i, n) {
		if (((t / a[i]) & 1) == 0) {
			cout << 0 << "\n";
			return 0;
		}
	}

	cout << ((m / t) + 1) / 2 << "\n";

	return 0;
}


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

readline = sys.stdin.buffer.readline
def readstr():return readline().rstrip().decode()
def readstrs():return list(readline().decode().split())
def readint():return int(readline())
def readints():return list(map(int,readline().split()))
def printrows(x):print('\n'.join(map(str,x)))
def printline(x):print(' '.join(map(str,x)))

from math import ceil

h,w = readints()

s = [readstr() for i in range(h)]

dp = [[0]*w for i in range(h)]

if s[0][0] == '.':
    dp[0][0] = 0
else:
    dp[0][0] = 1

for i in range(1,h):
    if s[i][0] != s[i-1][0]:
        dp[i][0] = dp[i-1][0] + 1
    else:
        dp[i][0] = dp[i-1][0] 

for i in range(1,w):
    if s[0][i] != s[0][i-1]:
        dp[0][i] = dp[0][i-1] + 1
    else:
        dp[0][i] = dp[0][i-1]

for i in range(1,h):
    for j in range(1,w):
        if s[i][j] != s[i-1][j]:
            dp[i][j] = dp[i-1][j] + 1
        else:
            dp[i][j] = dp[i-1][j]
        if s[i][j] != s[i][j-1]:
            dp[i][j] = min(dp[i][j-1] + 1,dp[i][j])
        else:
            dp[i][j] = min(dp[i][j-1],dp[i][j])

print(ceil(dp[-1][-1]/2))





Measured memory_bytes: 74104
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
constexpr long long int mod = 1000000007, MOD = 998244353;
constexpr double PI = 3.14159265358979323846;

int main() {
	long long i;
	long double j;
	cin >> i >> j;
	j *= 100;
j+=0.5;
	long long k = j;
	cout << i * k/100;
}


Measured memory_bytes: 3708
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let cin = stdin();
    let cin = cin.lock();
    let s: String = cin
        .bytes() // Bytes
        .map(|c| c.expect("failed reading char") as char)
        .skip_while(|c| c.is_whitespace()) // c が whitespace である限り skip
        .take_while(|c| !c.is_whitespace()) // c が whitespace でない限り要素を返す
        .collect();
    s.parse().ok().expect("failed parsing")
}

#[allow(non_snake_case)]
fn main() {
    input! {
        S:chars
    }
    for i in 0..3 {
        if S[i] == '7' {
            println!("Yes");
            return;
        }
    }
    println!("No");
}


Measured memory_bytes: 2112
#include <iostream>
#include <algorithm>
#include <functional>
#include <math.h>
using namespace std;
int main(){
  int a,b,c,ans=0;
  cin>>a>>b>>c;
  for(int i=a;i<=b;i++){
    if(c%i==0)ans++;
  }
  cout<<ans<<'\n';
  return 0;
}



Measured memory_bytes: 3112
#include <cstdio>
#include <string>
#include <iostream>
using namespace std;
const int N=1000+5;
string str;

int main()
{
    int a,b,c,x,y,sum=0;
    scanf("%d%d%d%d%d",&a,&b,&c,&x,&y);
    if(a+b<=2*c)
    {
        sum+=(min(x,y)*(a+b));
        int cc=max(x,y)-min(x,y);
        if(x>y)
        {
            sum+=min(c*2*cc,cc*a);
        }
        else
        {
            sum+=min(c*2*cc,cc*b);
        }
    }
    else
    {
        int dd=min(x,y),cc=max(x,y)-min(x,y);
        sum+=dd*2*c;
        if(x>y)
        {
            sum+=min(c*2*cc,cc*a);
        }
        else
        {
            sum+=min(c*2*cc,cc*b);
        }
    }
    printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#define mod 1000000007
#define ten5 100005
#define PI 3.1415926
using namespace std;

long long int getGCD(long long int,long long int);

int main()
{
    //int m,n,o=0,i,j,k;
    long long int sum=0,sum2=0,n1=0,n2=0,n3;
    double ans=0.0,half;
    long long int m,n,o,i,j,k=0,now=0;
    long long int a,b,c,d,gcd,hcf;
    //float f,g,h;
    //char now,pre;
    cin>>a>>b>>c>>d;
    sum=b-a+1;
    gcd=getGCD(c,d);
    hcf=c/gcd*d;
    n1=(b)/c-(a-1)/c;
    n2=(b)/d-(a-1)/d;
    n3=(b)/hcf-(a-1)/hcf;
    sum=sum-n1-n2+n3;
    cout<<sum;
    return 0;
}

long long int getGCD(long long int m,long long int n)
{
    if(n==0) return m;
    else return getGCD(n,m%n);
}




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

int scana(int n,int m,int a[100][100]);
int mcalc(int a[100][100],int b[100],int c[100],int n,int m);

int main(void) {
    int i;
    int n,m;
    int a[100][100]= {0};
    int b[100]= {0};
    int c[100] = {0};
     
    scanf("%d %d",&n,&m);
    scana(n,m,a);
     
    for(i=0;i<m;i++){
        scanf("%d",&b[i]);
    }
    
    mcalc(a,b,c,n,m);
    
    for(i=0;i<n;i++){
    	printf("%d\n",c[i]);
    }
    return 0;
}

int scana(int n,int m,int a[100][100]){
	int i,k;
	
	for(i=0;i<n;i++){
        for(k=0;k<m;k++){
            scanf("%d",&a[i][k]);
        }
    }
    return a;
}

int mcalc(int a[100][100],int b[100],int c[100],int n,int m){
    int i,k;
    
    for(i=0;i<n;i++){
        for(k=0;k<m;k++){
            c[i] = c[i] + b[k]*a[i][k];
        }
    }
    return c;
}

Measured memory_bytes: 648
# coding: utf-8
# Your code here!
# coding: utf-8
from fractions import gcd 
from functools import reduce
import sys
sys.setrecursionlimit(200000000)
from inspect import currentframe


# my functions here!
#標準エラー出力
def printargs2err(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' : '+repr(arg) for arg in args),file=sys.stderr)






def printglobals():
    for (symbol, value) in globals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)
def printlocals():
    for (symbol, value) in locals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)
#入力（後でいじる）
def pin(type=int):
    return map(type,input().split())
     
#input

def resolve():
    N,M=pin()
    if N==1:
        ans=[0]
    else:
        ans=[1]+[0]*(N-1)
    h=[False]*3#ヒントもらったかどうか
    for i in range(M):
        p,m=pin()
        if h[p-1]==False:#ヒントもらってなければ
            if p==1 and m==0 and N!=1: #2桁以上の数字の時に先頭が0になれば
                print(-1)
                return
            else:#そうじゃなかったらそのまま代入してhintをTrueに
                h[p-1]=True
                ans[p-1]=m
        else:#ヒントもらってたら
            if ans[p-1]!=m:#ヒントで別の数字が来たら
                print(-1)
                return
            else:#そうじゃなかったらそのまま代入もいらない
                pass
    a=""
    for n in range(N):
        a+=str(ans[n])
    print(int(a))
    #print([["NA","YYMM"],["MMYY","AMBIGUOUS"]][cMMYY][cYYMM])
#if __name__=="__main__":resolve()

"""
#printデバッグ消した？
#前の問題の結果見てないのに次の問題に行くの？
"""
"""
お前カッコ閉じるの忘れてるだろ
"""

import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """3 3
1 0
3 2
2 7"""
        output = """-1"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """3 2
2 1
2 3"""
        output = """-1"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """3 1
1 0"""
        output = """-1"""
        self.assertIO(input, output)


if __name__=="__main__":resolve()

Measured memory_bytes: 7308
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define MAX_V 2050
#define INF (1LL<<60LL)
typedef pair<int,int> P;
int V;
struct edge2{
  int from,to,cost;
  edge2(){}
  edge2(int from,int to,int cost):from(from),to(to),cost(cost){}
};
edge2 es[2050];
int d[2050];
int ok[1111];
int used[1111];
int shortest_path(int s,int e){
  for(int i=0;i<V;i++) d[i]=INF;
  d[s]=0;
  for(int j=0;j<V;j++){
    bool update=0;
    for(int i=0;i<e;i++){
      edge2 e=es[i];
      if(!ok[e.from]||!ok[e.to]) continue;
      if(d[e.from]!=INF&&d[e.to]>d[e.from]+e.cost){
	d[e.to]=d[e.from]+e.cost;
	update=1;
      }
    }
    if(!update) break;
    if(j==V-1){
      cout<<"inf"<<endl;
      exit(0);
    } 
  }
  return d[V-1];
}

vector<int> G[1111];
void dfs2(int v){
  if(used[v]) return;
  used[v]=1;
  for(int u:G[v]){
    dfs2(u);
  }
}

signed main(){
  int v,e;
  cin>>v>>e;
  for(int i=0;i<e;i++){
    int u,v,d;
    cin>>u>>v>>d;u--;v--;
    G[u].push_back(v);
    es[i]=edge2(u,v,-d);
  }
  for(int i=0;i<v;i++){
    memset(used,0,sizeof(used));
    dfs2(i);
    ok[i]=used[v-1];
  }
  V=v;
  cout<<-shortest_path(0,e)<<endl;
  return 0;
}


Measured memory_bytes: 384
// Copyright 2019 yaito3014
#include "bits/stdc++.h"
using namespace std;

int main() {
  cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false);
  int H, N;
  cin >> H >> N;
  int sum = 0;
  for (int i = 0; i < N; ++i) {
    int A;
    cin >> A;
    sum += A;
  }
  cout << (H <= sum ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();
		int B = sc.nextInt();
		int cost =0;
		if(A>=13) cost = B;
		else if(A<=12 && A>=6) cost = B/2;
		else if(A<=5) cost =0;

		System.out.print(cost);


	}

}


Measured memory_bytes: 23124
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

vector<int> parent;

int root(int x) {
	if (parent[x]==x) {
		return x;
	}
	else {
		return parent[x] = root(parent[x]);
	}
}

bool same(ll x, ll y) {
	return root(x) == root(y);
}

void unite(ll x, ll y) {
	x = root(x);
	y = root(y);
	if (x == y) return;

	parent[x] = y;
}

int main() {
	int n, m;
	cin >> n >> m;
	vector<ll> a(m);
	vector<ll> b(m);
	vector<ll> c(n+1,0);

	for (int i = 0; i < m; i++) {
		cin >> a[i] >> b[i];
	}

	parent.resize(n+1);

	for (int i = 1; i <= n;i++) {
		parent[i] = i;
	}

	for (int i = 0; i < m;i++) {
		unite(a[i], b[i]);
		for (int j = 1; j <= n; j++) {
		}
	}

	for (int i = 1; i <= n; i++) {
		c[root(i)]++;
	}

	ll result = 0;

	for (int i = 1; i <= n; i++) {
		result = max(result,c[i]);
	}

	cout << result << endl;

	return 0;
}


Measured memory_bytes: 11824
#include <stdio.h>
#include <stdlib.h>

int main (void) {
    long int N, D, x, y, count = 0;
    scanf("%ld %ld", &N, &D);
    for (int i = 0; i < N; i++) {
        scanf("%ld %ld", &x, &y);
        if (D * D >= x * x + y * y) {
            count++;
        }
    }
    printf("%ld\n", count);
    return 0;
}

Measured memory_bytes: 1732
//Daniel Grzegorzewski
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second

using namespace std;

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios() {
     ios_base::sync_with_stdio(0);
     cin.tie(0);
}

string s;
int a, b;

int main() {
  init_ios();
  cin >> s;
  for (char c: s) {
    if (c == '0')
      ++a;
    else
      ++b;
  }
  cout<<2*min(a, b)<<"\n";
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
  public static void main (String[] args) {
    Scanner in = new Scanner(System.in);

    while (in.hasNext()) {
      String S = in.next();
      int oneCBetween = 0;
      boolean otherLowerCase = true;
      
      for (int i = 2; i <= S.length() - 2; ++i) {
        if (S.charAt(i) == 'C') {
          ++oneCBetween;
        } else if (S.charAt(i) != 'A') {
          if (Character.isUpperCase(S.charAt(i))) {
            otherLowerCase = false;
          }
        }
      }

     if (Character.isUpperCase(S.charAt(1)) || Character.isUpperCase(S.charAt(S.length() - 1))) {
       otherLowerCase = false;
     }

      if (S.charAt(0) == 'A' && oneCBetween == 1 && otherLowerCase) {
        System.out.println("AC");
      } else {
        System.out.println("WA");
      }
    }
  }
}

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

int main(void){
    int N;
    cin >> N;
    
    vector<vector<int>> G(N);
    vector<pair<int, int>> vp;
    
    for (int i=1; i<N; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
        vp.emplace_back(a, b);
    }
    
    int K = 0;
    map<pair<int, int>, int> I;
    vector<int> cs(N, 0); //親との間の枝の色
    vector<int> used(N, 0);
    queue<int> que;
    used[0] = 1;
    que.emplace(0);
    while(!que.empty()) {
        int v = que.front(); que.pop();
        //cout << "v = " << v << endl;
        if(K < (int)G[v].size()) K = G[v].size();
        int cur=1;
        for(int u:G[v]){
            //cout << "u = " << u << endl;
            if(used[u]) continue;
            //cout << "used[u] = " << used[u] << endl;
            if(cur==cs[v]) cur++;
            cs[u] = I[make_pair(u, v)] = I[make_pair(v, u)] = cur++;
            used[u] = 1;
            que.emplace(u);
        }
    }
    
    cout << K << endl;
    for(auto p:vp) cout << I[p] << endl;
    return 0;
}

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

int main() {
  string S,T,U;
  int A,B;
  cin>>S>>T;
  cin>>A>>B;
  cin>>U;
  
  if(S==U) A--;
  else B--;
  cout<<A<<" "<<B<<endl;
}

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

int main() {
  int A,B; cin >>A >>B;
  cout <<A*B <<endl;
}


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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long N, long long i){
    cout << N - i + 1 << endl;
}

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


Measured memory_bytes: 256
N = int(input())
dic = {}

for i in range(N):
    spell = ''.join(sorted(input()))
    if spell in dic.keys():
        dic[spell] += 1
    else:
        dic[spell] = 1

count = 0
for num in dic.values():
    count += sum([i for i in range(num)])

print(count)



Measured memory_bytes: 17852
#include<bits/stdc++.h>
using namespace std;
typedef long long int llint;
typedef long int lint;
typedef vector<char> vchar;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
#define vsort(v) sort((v).begin(), (v).end())
#define vreverse(v) reverse((v).begin(), (v).end())
#define pb(a) push_back(a)
#define INF 1000000007
#define MOD 1e9+7
int main(){
  //input
  int a,b;cin>>a>>b;
  if(a<6){cout<<0<<endl;}
  else if(a<13){cout<<(b/2)<<endl;}
  else{cout<<b<<endl;}
  //caricurate
  //output
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

int main() {
  uint32_t K = 0;
  std::string S;
  std::cin >> K >> S;

  if (S.size() <= K) {
    std::cout << S << std::endl;
  } else {
    std::cout << S.substr(0, K) << "..." << std::endl;
  }

  return 0;
}

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

using ll=long long;
#define int ll

#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#ifdef LOCAL
#define dmp(x) cerr<<__LINE__<<" "<<#x<<" "<<x<<endl
#else
#define dmp(x) void(0)
#endif

template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class t,class u>
ostream& operator<<(ostream& os,const pair<t,u>& p){
	return os<<"{"<<p.a<<","<<p.b<<"}";
}

template<class t> ostream& operator<<(ostream& os,const vc<t>& v){
	os<<"{";
	for(auto e:v)os<<e<<",";
	return os<<"}";
}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout<<fixed<<setprecision(20);
	
	int n,k;cin>>n>>k;
	vi p(n);
	rep(i,n)cin>>p[i];
	
	vi t(n-k+1);
	{
		int cnt=0,j=1;
		rep(i,n-k+1){
			while(j<i+k){
				if(p[j-1]>p[j])
					cnt++;
				j++;
			}
			t[i]=cnt;
			if(p[i]>p[i+1])
				cnt--;
		}
	}
	vi sm(n-k+1);
	{
		set<int> s;
		int j=0;
		rep(i,n-k){
			while(j<i+k+1)
				s.insert(p[j++]);
			if(*s.bg==p[i]&&*prev(s.ed)==p[j-1])
				sm[i+1]=1;
			s.erase(p[i]);
		}
	}
	int ans=0,z=0;
	rep(i,n-k+1)if(!sm[i]){
		if(t[i])ans++;
		else z++;
	}
	ans+=bool(z);
	cout<<ans<<endl;
}


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

int n,m,cnt,a[N],b[109],p[20][N],q[20][N],f[N],g[N];
struct node{ int x,y; }c[N];
bool cmp(node u,node v){ return u.y<v.y; }
int main(){
	scanf("%d%d",&n,&m);
	int i,j,k;
	for (i=1; i<=n; i++) scanf("%d",&a[i]);
	for (; m; m>>=1) b[++cnt]=m; cnt++;
	for (i=1; i<=(cnt>>1); i++) swap(b[i],b[cnt-i+1]);
	for (i=1; i<=cnt; i++){
		p[i][n]=n; q[i][1]=1;
		for (j=n-1; j; j--) p[i][j]=(a[j+1]-a[j]<=b[i]?p[i][j+1]:j);
		for (j=2; j<=n; j++) q[i][j]=(a[j]-a[j-1]<=b[i]?q[i][j-1]:j);
	}
	m=1<<cnt-1;
	for (i=0; i<m; i++) g[i]=n+1;
	for (i=1; i<m; i++)
		for (j=1; j<cnt; j++) if (i>>j-1&1){
			k=i^1<<j-1;
			f[i]=max(f[i],f[k]<n?p[j][f[k]+1]:n);
			g[i]=min(g[i],g[k]>1?q[j][g[k]-1]:1);
		}
	for (i=0; i<m; i++)
		if (f[i]+1<g[m-1^i]) c[i+1]=(node){f[i]+1,g[m-1^i]-1};
		else{
			for (i=1; i<=n; i++) puts("Possible"); return 0;
		}
	sort(c+1,c+m+1,cmp);
	for (i=j=1,k=0; i<=n; i++){
		for (; j<=m && c[j].y<=p[cnt][i]; j++)
			k=max(k,c[j].x);
		puts(k<q[cnt][i]?"Impossible":"Possible");
	}
	return 0;
}


Measured memory_bytes: 102784
# from math import log
n = int(input())


# def make_list(n, x):
#     return [x ** i for i in range(1, int(log(n, x))+1)]
nums = [1]
# N = int(input())
for i in range(20):
    if 100000 >= 6**i:
        nums.append(6**i)
    if 100000 >= 9**i:
        nums.append(9**i)

# sixes = make_list(n, 6)
# nines = make_list(n, 9)
# nums = [1] + sixes + nines

dp = [float('inf')] * (n+1)
for num in nums:
    for i in range(1, n+1):  # 1~nまでのn円について調べる
        if i == num:
            dp[i] = 1
        elif i > num:
            dp[i] = min(dp[i], dp[i-num]+1)
print(dp[n])


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

# define ll long long 
# define VI vector<int>
# define VLL vector<ll>
# define PII pair<int,int> 
#define mp make_pair
#define pb push_back
# define PI acos(-1)
# define double long double
const int MxN = 10005 ; 
# define FOR(i,a,b) for(int i = a ; i < b ; ++i)
# define RFOR(i,a,b) for(int i = a ; i >= b ; --i)

/* VARIABLES */
ll n ; 
/* END OF VARIABLES */

int dig(ll n) {
	int ans = 0 ;
	while(n) {
		n = n / 10 ; 
		ans++;
	}
	return ans ; 
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL) ; 
	int ans = 1e9 ; 
	cin >> n ; 
	FOR(i,1,sqrt(n)+1) {
		if(n%i == 0) 
			ans = min(ans,max(dig(i),dig(n/i))) ; 
	} 
	cout << ans ; 
	return 0 ; 
}



Measured memory_bytes: 3632
n = gets.to_i
a = n.times.map{gets.to_i}.sort
c = Array.new(n){|i|
  if i < n/2
    -2
  else
    2
  end
}
ans = 0

if n%2 == 0
  c[n/2-1] = -1
  c[n/2] = 1
  for i in 0..n-1
    ans += a[i]*c[i]
  end
  puts ans
else
  temp = 0
  c[n/2] = c[n/2+1] = 1
  for i in 0..n-1
    temp += a[i]*c[i]
  end
  c[n/2-1] = c[n/2] = -1
  c[n/2+1] = 2
  for i in 0..n-1
    ans += a[i]*c[i]
  end
  puts [ans,temp].max
end

Measured memory_bytes: 4656
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
const int Amax = 1e5;
int A, B, Q;
ll S[Amax], T[Amax], X[Amax];

int main(){
	cin >> A >> B >> Q;
	for(int i=0; i<A; i++) cin >> S[i];
	for(int i=0; i<B; i++) cin >> T[i];
	for(int i=0; i<Q; i++){
		cin >> X[i];

		int si = lower_bound(S, S+A, X[i])-S;
		int ti = lower_bound(T, T+B, X[i])-T;

		ll ans = 1e18;
		if(si < A && ti < B) ans = min(ans, max(S[si]-X[i], T[ti]-X[i]));
		if(si > 0 && ti > 0) ans = min(ans, max(X[i]-S[si-1], X[i]-T[ti-1]));
		if(si > 0 && ti < B){
			ans = min(ans, 2*(X[i]-S[si-1])+T[ti]-X[i]);
			ans = min(ans, X[i]-S[si-1]+2*(T[ti]-X[i]));
		}
		if(si < A && ti > 0){
			ans = min(ans, 2*(S[si]-X[i])+X[i]-T[ti-1]);
			ans = min(ans, S[si]-X[i]+2*(X[i]-T[ti-1]));
		}
		cout << ans << endl;
	}

	return 0;
}


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


#define rep(i, n) for(int i = 0; i < (n); i++)
using ULL = unsigned long long;


void solve() {
	int n; cin >> n;
	ULL bil7 = 1000000007;
	ULL ans = 1;
	string s; cin >> s;
	if (s[0] == 'W') { cout << 0 << endl; return; }
	if (s.back() == 'W') { cout << 0 << endl; return; }

	int pos = 1; bool prepos = true;
	for (size_t i = 1; i < s.size(); i++) {
		if (s[i] == s[i - 1]) {
			if (prepos) {
				ans = ans * pos % bil7;
				pos--;
			}
			else {
				pos++;
			}
			prepos = !prepos;
		}
		else {
			if (prepos) {
				pos++;
			}
			else {
				ans = ans * pos % bil7;
				pos--;
			}
		}
	}

	if (pos != 0) { cout << 0 << endl; return; }

	rep(i, n) { ans = ans * (i + 1) % bil7; }

	cout << ans << endl;
}

int main() {

	solve();

	return 0;
}

Measured memory_bytes: 640
import itertools as it
n = int(input())
zahyou = []
for i in range(n):
    x,y = map(int, input().split())
    zahyou.append((x,y))
perm = list(it.permutations(range(n),n))
ans = 0
for zyu in perm:
    for i in range(n-1):
        ans += ((zahyou[zyu[i]][0] - zahyou[zyu[i+1]][0])**2 +(zahyou[zyu[i]][1] - zahyou[zyu[i+1]][1])**2 )**.5
ans /=len(perm)
print(ans)


Measured memory_bytes: 8052
#include<bits/stdc++.h>
#define llenar(a,val)   memset(a,val,sizeof(a))
#define pb          push_back 
#define endl        "\n"
#define mostrar(x,y) cout<<x<<" "<<y<<endl;
#define f           first
#define s           second
#define mod         1000000007
#define EPS         1e-9
using namespace std;
typedef pair<int,int> ii;
typedef pair<pair<int,int>,int> iii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef long long ll;
typedef vector< pair<pair<int,int>,int> > viii;




int main(){
    ofstream out("output.txt");
    
    int n;
    cin>>n;

    ll res = 1;
    for(int i =1;i<=3;i++){
        res *=n;
    }
    cout<<res<<endl;
    return 0;
}

 
 







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

#define int long long

#define rep(i, n) for (int i = 0; i < n; i++)
#define all(c) begin(c), end(c)

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
signed main() {
	int W, H, N; cin >> W >> H >> N;
	V ws(N), hs(N);
	vector<P> v(N);
	rep(i, N) {
		int x, y; cin >> x >> y;
		ws[i] = x; hs[i] = y;
		v[i] = P(x, y);
	}
	sort(all(ws));
	sort(all(hs));

	vector<VV> dists(3, VV(3, V(N)));
	rep(i, N) rep(j, 3) rep(k, 3) {
		dists[j][k][i] = abs(v[i].first - ws[N / 2 + j - 1]) + abs(v[i].second - hs[N / 2 + k - 1]);
	}
	rep(i, 3) rep(j, 3) sort(all(dists[i][j]));

	int ans = 1ll << 62;
	int xpos = 0, ypos = 0;
	rep(i, 3) rep(j, 3) {
		int sum = accumulate(all(dists[i][j]), 0ll) * 2 - dists[i][j].back();
		if (sum < ans) {
			xpos = ws[N / 2 + i - 1];
			ypos = hs[N / 2 + j - 1];
			ans = sum;
		}
	}
	cout << ans << endl;
	cout << xpos << " " << ypos << endl;
}

Measured memory_bytes: 16064
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn solve() {
    input! {
        s: Chars
    };

    let res = s.into_iter().filter(|&ch| ch == '1').count();
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 2224
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define ull unsigned ll
#define all(x) x.begin(), x.end()
#define CHECK_BIT(var, pos) ((var) & (1<<(pos)))
#define eb emplace_back
const int M = 1e9 + 7;

typedef long double ldb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef tree<
        pair<int, int>,
        null_type,
        less<pair<int, int>>,
        rb_tree_tag,
        tree_order_statistics_node_update> ordered_set;

int main() {
    string s;
    cin >> s;
    int ch[26] = {};
    sort(all(s));
    for (int i = 0; i < 4; ++i) {
        ch[s[i] - 'A']++;
    }
    sort(ch, ch + 26);

    if (ch[25] == 2 && ch[24] == 2)
        cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll m;
    cin >> m;
    ll ans = 0, sum = 0;
    rep(i, m) {
        ll d, c;
        cin >> d >> c;
        ans += c;
        sum += d * c;
    }
    cout << (ans + ((sum - 1) / 9) - 1) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef _WIN32
#include "debug.hpp"
#endif
using namespace std;

#define rep(i, N)  for(int i = 0; i < (N); i++)
#define reps(i, N) for(int i = 1; i <= (N); i++)
#define repr(i, N) for(int i = (N) - 1; i >= 0; i--)
#define pub push_back

template<typename T> 
void chmax(T &a, T b){ a = max(a, b); };
template<typename T> 
void chmin(T &a, T b){ a = min(a, b); };

typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;
const ll LINF = 10000000000000000;
const int MOD = 1000000007;
const int dx[9] = { 0, 1,  0, -1, 1,  1, -1, -1, 0};
const int dy[9] = { 1, 0, -1,  0, 1, -1, -1,  1, 0};
//--------------------------------------//
int N, M;
int A[1001], B[1001];

void solve(){
	A[N] = INF;
	B[M] = INF;
	sort(A, A + N + 1, greater<int>());
	sort(B, B + M + 1, greater<int>());
	int nc = 1;
	bool ncc = true;
	int mc = 1;
	bool mcc = true;
	int size = N * M;
	if(A[1] != size or B[1] != size){
		cout<<0<<endl;
		return;
	}
	ll ans = 1;
	for(int i = size - 1; i >= 1; i--){
		if(ncc and mcc and A[nc + 1] == i and B[mc + 1] == i){
			nc++;
			if(nc == N)
				ncc = false;
			mc++;
			if(mc == M)
				mcc = false;
		}
		else if(ncc and A[nc + 1] == i){
			ans = (ans*mc)%MOD;
			nc++;
			if(nc == N)
				ncc = false;
		}
		else if(mcc and B[mc + 1] == i){
			ans = (ans*nc)%MOD;
			mc++;
			if(mc == M)
				mcc = false;
		}
		else{
			ll k = mc * nc;
			k = k - (size - i);
			ans = (ans*k)%MOD;
		}
	}
	ans %= MOD;
	cout<<ans<<endl;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin>>N>>M;
	rep(i, N) {
		cin>>A[i];
	}
	rep(i, M) {
		cin>>B[i];
	}
		solve();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int,int> pii;
#define fi first
#define se second
#define mp make_pair

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 = 1LL << 60;
const int INF = 1001001001;
const int MAX = 110;

//struct edge{
//  int to, cost;
//  edge(){}
//  edge(int to, int cost): to(to), cost(cost){}
//};

int G[MAX][MAX];
bool seen[MAX];
priority_queue<pii, vector<pii>, greater<pii> > pq;
int n;

int prim(){
  seen[0] = true;
  rep(i, n){
    if(G[0][i] == -1) continue;
    pq.push(mp(G[0][i], i));
  }
  
  int sum = 0;
  while(!pq.empty()){
    pii p = pq.top();
    pq.pop();
    if(seen[p.se]) continue;
    seen[p.se] = true;
    sum += p.fi;
    rep(i, n){
      if(G[p.se][i] == -1) continue;
      pq.push(mp(G[p.se][i], i));
    }
  }

  return sum;
}

int main(){
  cin >> n;
  rep(i, n) rep(j, n) cin >> G[i][j];

  cout << prim() << endl;
 
  return 0;
}





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

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

	int n, m;
	cin >> n >> m;
	vector<vector<int>> g(n);
	for(int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	vector<int> perm(n);
	iota(perm.begin(), perm.end(), 0);
	int ans = 0;
	do {
		bool ok = true;
		for(int i = 0; i < n - 1; i++) {
			bool found = false;
			for(int j = 0; j < g[perm[i]].size(); j++) {
				if(g[perm[i]][j] == perm[i + 1]) found = true;
			}
			if(!found) {
				ok = false;
				break;
			}
		}
		ans += ok;
	} while(next_permutation(perm.begin() + 1, perm.end()));
	cout << ans << endl;
	return 0;	
}

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

const int N = 2e5 + 5;

vector< int> conn[N];
bitset< N> seen;
int cmp, cnt;
int x[N], y[N];

void dfs(int u, int cc) {
    seen[u] = true;
    x[u] = cc;

    for (int &v : conn[u]) if (!seen[v]) {
            dfs(v, cc);
        }
}

void dfs2(int u, int cc) {
    seen[u] = true;
    y[u] = cc;

    for (int &v : conn[u]) if (!seen[v]) {
            dfs2(v, cc);
        }
}


int main() {
    int n, m, k;
    scanf("%d %d %d", &n, &m, &k);
    for (int i = 0; i < m; ++i) {
        int a, b;
        scanf("%d %d", &a, &b);
        conn[a].emplace_back(b);
        conn[b].emplace_back(a);
    }

    for (int i = 1; i <= n; ++i) if (!seen[i]) {
            ++cmp;
            dfs(i, cmp);
        }

    for (int i = 1; i <= n; ++i) conn[i].clear();

    for (int i = 0; i < k; ++i) {
        int a, b;
        scanf("%d %d", &a, &b);
        conn[a].emplace_back(b);
        conn[b].emplace_back(a);
    }

    cmp = 0;
    seen.reset();
    for (int i = 1; i <= n; ++i) if (!seen[i]) {
            ++cmp;
            dfs2(i, cmp);
        }

    map< pair< int, int>, int > mp;
    for(int i = 1; i <= n; ++i) mp[{x[i], y[i]}] ++;


    for (int i = 1; i <= n; ++i) printf("%d ", mp[{x[i], y[i]}]);
}

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

	#define E "\n"
	#define int long long 
	#define f(i,l,n) for(int i=l;i<n;i++)

	

	int32_t main()
	{

	
	 int a,b,n;
	 cin >> a >> b >> n;
	 int ans=INT_MIN;
	 if(b==1) return cout<<0,0;

	 for(int i=1;i<=n/b;i++)
	 {
	 	int x=i*b-1;
	 	ans=max(ans,(a*x)/b-a*(x/b));
	 }
	 if(n<b) ans=(a*n)/b-a*(n/b);
	 cout<<ans;

	}

Measured memory_bytes: 3604
//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()

using namespace std;

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

const int N = 25e6 + 10;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

ll dp1[N], dp2[N];

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n, ga, sa, ba, gb, sb, bb;
	cin >> n >> ga >> sa >> ba >> gb >> sb >> bb;
	for (int i = 1; i < N; i++){
		dp1[i] = dp1[i - 1] + 1;
		if (i >= ga) dp1[i] = max(dp1[i], dp1[i  - ga] + gb);
		if (i >= sa) dp1[i] = max(dp1[i], dp1[i - sa] + sb);
		if (i >= ba) dp1[i] = max(dp1[i], dp1[i - ba] + bb);
	}
	for (int i = 1; i < N; i++){
		dp2[i] = dp2[i - 1] + 1;
		if (i >= gb) dp2[i] = max(dp2[i], dp2[i - gb] + ga);
		if (i >= sb) dp2[i] = max(dp2[i], dp2[i - sb] + sa);
		if (i >= bb) dp2[i] = max(dp2[i], dp2[i - bb] + ba);
		
	}
	cout << dp2[dp1[n]];











	return 0;
}


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

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

Measured memory_bytes: 3652
x, y = map(int, input().split())
a = [1,3,5,7,8,10,12]
b = [4,6,9,11]
c = [2]
if x in a and y in a:
  print("Yes")
elif x in b and y in b:
  print("Yes")
elif x in c and y in c:
  print("Yes")
else:
  print("No")



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

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

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


int main()
{
    int n,count=0;
    cin>>n;

    string s;
    cin>>s;

    if((n%2)==1)
        cout<<"No"<<endl;


    else
    {
    char b[n+1],a[n+1];
    int j=0;

    for(int i=0;i<n/2;i++)
        a[i]=s[i];

    for(int i=n/2;i<n;i++)
        {
            b[j]=s[i];
            j++;
        }



    for(int i=0;i<n/2;i++)
    {
        if(a[i]==b[i])
            count++;
        else
            break;
    }


    if(count==n/2)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

    }



    return 0;
}


Measured memory_bytes: 256
/* it was worth becoming a chemist */
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;
typedef long double ld;
typedef unsigned int uni;
typedef unsigned long long unll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<long long, int> pli;
typedef pair<int, long long> pil;
typedef vector<int> vi;
typedef vector<long long> vll;

#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
#define NAME "puts"
#define F first
#define S second

const ll INF = 1e18;
const int inf = 1e9;
const int mod = 1e9 + 7;
const db EPS = (db) 1e-9;
const db pi = acos(-1.0);
const int MAXN = 1e5 + 5;

int n;
ll a[MAXN], k, g, m;

int main() {	
    
	cin >> n >> k;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		m = max(m, a[i]);
	}
	g = a[1];
	for (int i = 2; i <= n; i++) {
		g = __gcd(g, a[i]);
	}
	if (k % g == 0 && k <= m) cout << "POSSIBLE";
	else cout << "IMPOSSIBLE";
		
	return 0;
}


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

int n, c;
int rec[30];

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin >> n >> c;
    vector<pair<int, pair<int, int>>> a;
    for (int i = 0; i < n; ++i) {
        int s, t, ch;
        cin >> s >> t >> ch;
        --ch;
        a.push_back({s, {0, ch}});
        a.push_back({t, {1, ch}});
    }
    sort(a.begin(), a.end());
    
    int ans = 0, avail = 0;
    for (auto i : a) {
        int mode = i.second.first, channel = i.second.second;
        if (!mode) {
            if (rec[channel]) {
                ++rec[channel];
            } else if (avail) {
                ++rec[channel];
                --avail;
            } else {
                ++ans;
                ++rec[channel];
            }
        } else {
            --rec[channel];
            if (!rec[channel]) 
                ++avail;
        }
    }
    cout << ans;
}


Measured memory_bytes: 6328
a, b, c = map(int, input().split())
k = int(input())


def ok(ax, bx, cx):
    if ax + bx + cx > k:
        return False
    aa = a
    bb = b
    cc = c
    for _ in range(ax):
        aa *= 2
    for _ in range(bx):
        bb *= 2
    for _ in range(cx):
        cc *= 2
    if aa < bb < cc:
        print('Yes')
        exit()
    else:
        return False


for x in range(8):
    ok(x, 0, 0)
    for y in range(8 - x):
        ok(x, y, 0)
        for z in range(8 - x - y):
            ok(x, y, z)
print('No')


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

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

class FenwickTree {
private:
    int bit_size;
    vector<LL> bit;

public:
    FenwickTree(int siz): bit_size(siz), bit(siz + 1) {}

    void add(int num, LL val) {
        for(int i = num + 1; i <= bit_size; i += i & -i) {
            bit[i] += val;
        }
    }

    LL sum(int end){
        LL res = 0;
        for(int i = end + 1; i > 0; i -= i & -i) {
            res += bit[i];
        }
        return res;
    }

    void init(LL val) {
        for(int i = 1; i <= bit_size; i++) {
            add(i, val);
        }
    }

    int lower_bound(LL val) {
        if(val <= 0) return 0;
        int i = 0, n = 1;
        while(n * 2 <= bit_size) n *= 2;
        for(int k = n; k > 0; k /= 2) {
            if(i + k <= bit_size && bit[i + k] < val) {
                val -= bit[i + k];
                i += k;
            }
        }
        return i + 1;
    }
};

int main(){
	LL N, K;
	cin >> N >> K;
	vector<LL> a(N);
	rep(i,N) cin >> a[i];
	vector<LL> s(N+1), b(N+1);
	rep(i,N) s[i+1]=s[i]+a[i];
	rep(i,N) b[i+1]=s[i+1]-K*(i+1);
	vector<LL> vals(N+1);
	vector<int> c(N+1);
	rep(i,N+1) vals[i]=b[i];
	sort(vals.begin(),vals.end());
	vals.erase(unique(vals.begin(),vals.end()),vals.end());
	rep(i,N+1){
		int id=lower_bound(vals.begin(),vals.end(),b[i])-vals.begin();
		c[i]=id;
	}
	LL ans=0;
	FenwickTree FT(N+1);
	rep(i,N){
		FT.add(c[i],1);
		ans+=FT.sum(c[i+1]);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 8832
#include <stdio.h>

int main(void) {
    int a, b, c, tmp ;
    scanf("%d %d %d", &a, &b, &c);
    if (a>b||a>c) {
        if (b < c) {
            tmp = a;
            a = b;
            b = tmp;
        }
        else {
            tmp = a;
            a = c;
            c = tmp;
        }
    }
    
    if(b>c){
        tmp = b;
        b = c;
        c = tmp;
    }
    printf("%d %d %d\n", a, b, c);
    return 0;
}


Measured memory_bytes: 2100
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
ll fun(ll h)
{
  if(h==0) return 0;
  if(h==1)
    return 1;
   return 1+2*fun(h/2);
}
int main()
{
  ll h;
  cin>>h;
  
  cout<<fun(h);
  return 0;
}

Measured memory_bytes: 256