akhauriyash/Code-Regression huggingface dataset:
import math
while(1):
    [p,n]=[int(x) for x in raw_input().split()]
    if p==0:
        break
    else:
       sqrtp=math.sqrt(p)
       smaller=[math.floor(sqrtp),int(math.floor(sqrtp)),1]
       larger=[math.ceil(sqrtp),int(math.ceil(sqrtp)),1]
       for numerator in range(int(math.floor(sqrtp))+1,n+1):
           denom_smaller=math.ceil(numerator/sqrtp)
           denom_larger=math.floor(numerator/sqrtp)
           if numerator/denom_smaller>smaller[0]:
               if smaller[1]*denom_smaller/smaller[2]!=numerator:
                   smaller=[numerator/denom_smaller,numerator,int(denom_smaller)]
           if numerator/denom_larger<larger[0]:
               if larger[1]*denom_larger/larger[2]!=numerator:
                   larger=[numerator/denom_larger,numerator,int(denom_larger)]
       print str(larger[1])+"/"+str(larger[2])+" "+str(smaller[1])+"/"+str(smaller[2])

Measured memory_bytes: 4688
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	n, m := readI(), readI()
	a := readIs(n)

	sou := float64(sum(a))

	ninki := 0
	for _, v := range a {
		if float64(v) >= sou/float64((4*m)) {
			ninki++
		}
	}

	if ninki >= m {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}

func sum(a []int) int {
	b := 0
	for _, v := range a {
		b += v
	}
	return b
}

/*-----------Utils-----------*/

var sc = bufio.NewScanner(os.Stdin)

func init() {
	if len(os.Args) >= 2 {
		if os.Args[1] == "debug" {
			debug()
		}
	}
	const maxBuf = 200100
	var buf []byte = make([]byte, maxBuf)
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBuf)
}

func debug() {
	testFile, err := os.Open("./test/hand_04.in")
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error : There is no testfile.")
		os.Exit(1)
	}
	sc = bufio.NewScanner(testFile)
}

func readS() string {
	sc.Scan()
	return sc.Text()
}

func readSs(a int) []string {
	b := make([]string, a)
	for i := 0; i < a; i++ {
		b[i] = readS()
	}
	return b
}

func readI() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func readIs(a int) []int {
	b := make([]int, a)
	for i := 0; i < a; i++ {
		b[i] = readI()
	}
	return b
}

func readF() float64 {
	sc.Scan()
	r, _ := strconv.ParseFloat(sc.Text(), 64)
	return r
}

func readFs(a int) []float64 {
	b := make([]float64, a)
	for i := 0; i < a; i++ {
		b[i] = readF()
	}
	return b
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;++i)
#define per(i,a,n) for(int i=n-1;i>=a;--i)
#define cl(x,a) memset(x,a,sizeof(x))
#define all(x) x.bein(),x.end()
#define INF 0x3f3f3f3f
#define EPS 1e-8
#define S 3 //矩阵大小
#define MAXN (ll)1000000000000000000
using namespace std;
typedef unsigned long long ll;
typedef unsigned long long LL;
int main()
{
    int x, y;
    scanf("%d%d", &x, &y);
    LL lcm = 1ll * x * y / __gcd(x, y);
    LL k = lcm / x;
    if(k > 2)
        printf("%lld\n", 1ll * x * (k - 1));
    else if(k == 2)
        printf("%lld\n", 1ll * x * (k + 1));
    else
        printf("-1\n");
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<queue>
#include<set>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef string S;
typedef queue<int> qi;
typedef pair<int,int> P;
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define elif else if
#define unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define mp make_pair
#define fr(i,n)for(ll i=0;i<(n);i++)
#define ifr(i,n)for(ll i=(n)-1;i>=0;i--)

int main () {
    int a,b;cin>>a>>b;
    if(a<=5){
      cout<<0;
    }else if(a<=12){
      cout << b/2;
    }else cout<<b;

}

Measured memory_bytes: 256
N = int(input())
A = [[i]+input().split() for i in range(N)]
A = [[A[i][0],A[i][1],int(A[i][2])] for i in range(N)]
A = sorted(A,key=lambda x:x[2],reverse=True)
A = sorted(A,key=lambda x:x[1])
for i in range(N):
    j,_,_ = A[i]
    print(j+1)

Measured memory_bytes: 38256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cstdio>
#include<cstdlib>
#include<queue>
#include<list>
#include<deque>
#include<cmath>
#include<unordered_map>
#include<unordered_set>
#include<numeric>

using namespace std;

using ll = int64_t;

/// <summary>
/// 単純なcoutの時に使う
/// </summary>
#define co(a) cout<<a<<"\n"


/// <summary>
/// [beg, end)の範囲を，添え字indexでループするfor文に置換します
/// </summary>
#define rep(i,a) for(ll i=0; i<a; ++i)
#define reps(i, a, b) for(ll i = a; i < b; ++i)

/// <summary>
/// 迷路等で使う方向のベクトル
/// </summary>
const vector<ll> dx = { 0, 1, 0, -1 }, dy = { 1, 0, -1, 0 };

/// <summary>
/// デバッグ時に使う
/// </summary>
#define DEBUG(x)     std::cout << #x << " : " << x << "\n"

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

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

	ll N, M;
    cin >> N >> M;

    if (N == M) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}



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

int main() {
  int N,K;
  cin >> N >>K;
  int x=1;
  
  for (int i=0;i<N;i++){
    if (2*x < x+K){
      x = 2*x;
    }
    else{
      x = x+K;
    }
  }
  cout << x << endl;
}


Measured memory_bytes: 256
#include <iostream>

#define rep(i, first, to) for(ll i = first; i < to; ++i)
#define REP(i, first, to) for(ll i = first; i <= to; ++i)

using namespace std;
typedef long long ll;

int a[101];
int n;

void solve() {
	cin >> n;
	rep(i, 0, n) {
		cin >> a[i];
	}
	int count = 0;
	bool isOk = true;;
	rep(i, 0, n) {
		rep(j, 1, n) {
			if (a[j - 1] > a[j]) {
				swap(a[j], a[j - 1]);
				isOk = false;
				++count;
			}
		}
		if (isOk) break;
	}
	rep(i, 0, n - 1) {
		cout << a[i] << " ";
	}
	cout << a[n - 1] << endl;
	cout << count << endl;
}

int main() {
	solve();
	return 0;
}

Measured memory_bytes: 3088
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;


//組み合わせの数
//1 <= x の値を3つ使ってnを作成

//1,6,2
//1,5,3

int main(){
    //std::ifstream in("resource/input.txt");
    //std::cin.rdbuf(in.rdbuf());

    ll N,K;
    cin >> N >> K;

    vector <int> a(N);
    REP(i,N)
    {
        cin >> a.at(i);
    }
    //1回めを計測
    ll atode = 0;

    ll kai = 0;

    //a[i]の転倒数
    REP(i,N)
    {
        for(ll j = 0; j < N; ++j)
        {
            if(a[i] > a[j])
            {

                ++kai;
                if(i < j)
                {
                    ++atode;
                };
            }
        }
    }
    ll res;

    //1,2,3,4 (1 + N+1)/2

    //k個から2つ選ぶ

    res = atode * K % MOD;
    //等差数列の和
    res += ((K-1)*K/2)% MOD * kai % MOD;
    res %= MOD;
    //res += (K-1) / 2 * (2 + (K-2)*kai % MOD) % MOD;

    //for(ll i = 1; i <= K-1; ++i)
    //{
    //    res +=  (kai * i % MOD);
    //    res %= MOD;
    //}

    //cout << kai << endl;
    //cout << atode << endl;

    //printf("%lld¥n",res)
     cout << res << endl;

    return 0;    
}



Measured memory_bytes: 256
//*Author : Franklin*
#include<bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 5;
const int N = 2e5;
#define deb(x) cout << #x << "=" << x << "\n"
#define debug(a) for(auto &x:a) cout << x << " "
#define debugg(p) for(auto &x:p) cout << "(" << x.first << "," << x.second << ")" << "\n"

int h[100005];
int dp[100005];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
    for(int i=0; i<n; i++) cin>>h[i];
    for(int i=0; i<=n; i++) dp[i] = INF;
    dp[0] = 0;
    for(int i=0; i<n; i++) {
        if(i+1<n) dp[i+1] = min(dp[i+1],dp[i]+abs(h[i]-h[i+1]));
        if(i+2<n) dp[i+2] = min(dp[i+2],dp[i]+abs(h[i]-h[i+2]));
    }
    cout<<dp[n-1]<<"\n";

    return 0;
}


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

int main() {
    string s, t;
    cin >> s >> t;

    int s_l = s.length();
    string ret ="Yes";
    for(int i = 0; i < s_l; i++) {
        if(s[i] != t[i]) {
            ret = "No";
            break;
        }
    }

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3612
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		for (int i = 0; i < N; i++) {
			String arare = sc.next();
			if (arare.equals("Y")) {
				System.out.println("Four");
				return;
			}

		}
		System.out.println("Three");

	}

}


Measured memory_bytes: 21972
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

def cal(i)
  return 1 if i==1
  return i*cal(i-1)
end
n=gets.to_i
xy=array(n,1)
n.times do|i|
  xy[i]=get_i
end
ans=0
c=cal(n)
temp=cal(n-1)
(n-1).times do|i|
  (i+1).upto(n-1) do|j|
    ans+=((xy[i][0]-xy[j][0]).to_f**2+(xy[i][1]-xy[j][1]).to_f**2)**0.5*2*temp
  end
end
puts ans/c

Measured memory_bytes: 1916
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <functional>
#include <numeric>
#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(void) {
	int N;
	cin >> N;
	N %= 10;
	if ((N == 2) or (N == 4) or (N == 5) or (N == 7) or (N == 9)) cout << "hon" << endl;
	else if ((N == 0) or (N == 1) or (N == 6) or (N == 8)) cout << "pon" << endl;
	else cout << "bon" << endl;
	return 0;
}

Measured memory_bytes: 3632
import sys
def I(): return int(sys.stdin.readline().rstrip())

N = I()

# N = q*m+m = (q+1)*m になることに注目

divisor = []  # Nの約数
for i in range(1,int(N**.5)+1):
    if N % i == 0:
        divisor.append(i)
        if i != N//i:
            divisor.append(N//i)

ans = 0
for d in divisor:
    m = d-1
    if N//d < m:
        ans += m

print(ans)


Measured memory_bytes: 65900
N = int(input())
tests = []
for n in range(N):
  A = int(input())
  tests_i = {}
  for a in range(A):
    x,y = map(int, input().split())
    tests_i[x-1] = y
  tests.append(tests_i)
# N人の人
# 正直者か真偽不明の発言者
# 人iがAi個の証言
# xijは正直物 if yij else 真偽不明の発言者

maximum = 0
import itertools
for Z in itertools.product(range(2), repeat=N):
  Z = list(Z)
#  print(Z)
  for i in range(N): # 人iの証言を検証
    honest = Z[i] # 正直ものか？
    for j,y in tests[i].items():
      if honest: #正直ものなら正しいはず
        if Z[j] != y:
#          print('NO')
          break
    else:
      # 証言が全て正しい
      continue
    break # 明らかに誤った証言をしたものがいる
  else:
#    print("ok")
    maximum = max(maximum, sum(Z))
print(maximum)

Measured memory_bytes: 68676
n,x,y = map(int, input().split())

x-=1
y-=1

ans = [0]*n
for i in range(n-1):
    for j in range(i+1,n):
        l = min(j-i, abs(x-i)+1+abs(y-j))
        ans[l]+=1
print('\n'.join(map(str, ans[1:])))

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


int main(){
  int n,t;
  cin >> n >> t;
  int a[n];
  rep(i,n) cin >> a[i];
  ll ans=0;
  rep(i,n-1){
    if(a[i+1]-a[i]>t)  ans+=t;
    else ans+=a[i+1]-a[i];
  }
  ans+=t;
  cout << ans << endl;

  return 0;

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define array_input int n;cin>>n;int a[n+1],i;for(i=1;i<=n;i++){cin>>a[i];}
#define array_output for(i=1;i<=n;i++){cout<<a[i]<<" ";}cout<<endl;
#define INF 2147483647
#define long_INF 18446744073709551615
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef long double ld;
const double pi=acos(-1);
const double eps=1e-6;

void read(int &x)
{
    x=0;
	char c=getchar();
    while(c<'0' || c>'9')c=getchar();
    while(c>='0' && c<='9')
	{
        x=x*10+c-'0';
        c=getchar();
    }
}

void write(int x)
{
    if(x==0)
	{
		putchar(48);
		return;
	}
    int len=0,dg[20];
    while(x>0)
	{
		dg[++len]=x%10;
		x/=10;
	}
    for(int i=len;i>=1;i--)
	{
		putchar(dg[i]+48);
	}
}

int main()
{
	ios::sync_with_stdio(false);
	int n;
	read(n);
	int a[n+1],i,t[n+1];
	for (i=1;i<=n;i++)
	{
		read(a[i]);
		t[i]=a[i];
	}
	sort(a+1,a+n+1);
	int maxv,minv;
	maxv=a[n/2];
	minv=a[n/2+1];
	for (i=1;i<=n;i++)
	{
		if (t[i]<=maxv)
		{
			cout<<a[n/2+1]<<endl;
		}
		else
		{
			cout<<a[n/2]<<endl;
		}
	}
	return 0;
}

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

#define FOR(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greater<int>()

using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;

const int INF = 1001001001;
const int MOD = 1000000007;
const long long INFL = (1LL << 60);
const double EPS = 1e-9;

int main() {
  int N;
  string s;
  cin >> N >> s;

  rep(i, s.size()) {
    s[i] = s[i] + N;
    if (s[i] > 'Z') {
      s[i] = 'A' - 1 + s[i] % 'Z';
    }
  }

  cout << s << endl;
}

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

#define ALL(a) (a).begin(), (a).end()
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define rep(i, n) FOR(i, 0, n)
#define repi(i, n) FOR(i, 1, n + 1)
#define pp(v) cerr << #v "=" << (v) << endl;
#define ppa(v) cerr << "- " << #v << endl; rep(i,v.size()) cerr << #v << "[" << i << "] = " << v[i] << endl;
#define div_ceil(a,b) ((a) + ((b) - 1)) / (b)
#define UNIQUE(v) v.erase( unique(ALL(v)), v.end() );
#define INF 0x3f3f3f3f
#define LLINF 1000111000111000111LL
#define TIME system("date +%M:%S.%N")
using Graph = vector<vector<int>>;
using ll = long long;
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

const int A = 0;
const int B = 1;
const int C = 2;

int main() {
  vector<string> s(3);rep(i,3)cin>>s[i];
  vector<queue<int>> x(3);
  rep(i,3) rep(j,s[i].size()) {
    x[i].push(s[i][j]-'a');
  }
  int t = 0; // turn player
  while(1==1) {
    if (x[t].empty()) {
      cout << (char)('A' + t) << endl;
      exit(0);
    }
    int nt = x[t].front();
    x[t].pop();
    t = nt;
  }
  // cout << ans << endl;
}


Measured memory_bytes: 256
A,B,C,D=map(int,input().split())
i=0
ans=""
while True:
  if i%2==0:
    C-=B
    if C<=0:
      ans="Yes"
      break
  else:
    A-=D
    if A<=0:
      ans="No"
      break
  i+=1
print(ans)


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

int n;
char str[105];

int main(){
    scanf("%d",&n);
    scanf("%s",str);
    if(n&1){
        puts("No");
        return 0;
    }
    int i=0,j=n/2;
    while(j<n){
        if(str[i]!=str[j]){
            puts("No");
            return 0;
        }
        ++i;
        ++j;
    }
    puts("Yes");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int n;
    string s;

    cin >> n;
    cin >> s;

    int x = 0;
    int ans = x;

    for (int i = 0; i < n; i++) {
        if (s[i] == 'I') {
            x++;
            if (x > ans) {
                ans = x;
            }
        }
        else {
            x--;
        }

    }

    cout << ans << endl;
}


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

int main() {
    int N; cin >> N;
    long long int ans = 0;
    for(int i = 1; i <= N; i++){
        int plus = i;
        if(i % 3 == 0) plus = 0;
        if(i % 5 == 0) plus = 0;
        ans += plus;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string r;
    cin >> r;
    int e=r.size();
    if(e==2)
        printf("0\n");
    else{
        int ec=e/2-1,i;
        bool q=true;
        while(q){
        for(i=0;i<ec;i++)
            if(r[i]!=r[ec+i])
            {
                q=false;
                break;
            }
        if(!q)
        {
            ec--;
            q=true;
        }
        else{ printf("%d\n",2*ec); break;}
        }
    }
}


Measured memory_bytes: 256
N, Q = map(int, input().split())
S = input()

acl = [0]*(N+1)

for i in range(N):
    acl[i+1] = acl[i] + (1 if S[i:i+2] == "AC" else 0)

for _ in range(Q):
    l, r = map(int, input().split())
    print(acl[r-1] - acl[l-1])

Measured memory_bytes: 7748
#include <cstdio>

const int mod = 1e9+7;
int n, m;
long long dp[303][303][303];

int main() {
    scanf("%d %d", &n, &m);

    dp[0][1][1] = 1;
    for (int i = 0; i <= m; i++) {
        for (int j = 1; j <= n; j++) {
            for (int k = 1; k <= j; k++) {
                long long now = dp[i][j][k];
                dp[i+1][j+1][k] += now*(n-j)%mod;
                dp[i+1][j][k] += now*(j-k)%mod;
                dp[i+1][j][j] += now*k%mod;
            }
        }
    }

    printf("%lld\n", dp[m][n][n] % mod);

    return 0;
}

Measured memory_bytes: 216576
#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() {
  int a;
  cin >> a;
  if (a>=30){
    cout << "Yes" << endl;
    return 0;
  }else{
    cout << "No" << endl;
    return 0;
  }
}


Measured memory_bytes: 3592
m=*$<
o=?R
x=1
y=d=0
(u=v=9
(d+=1
v=y+[0,-1,0,1][e=d%4]
u=x+(e<1?-1:0))until u>=0&&v>=0&&v<9&&m[v][u]==?1
x+=[-1,0,1,0][e]
y+=[0,-2,0,2][e]
o+=:LURD[e]
d+=2)while x+y>0
puts o

Measured memory_bytes: 6096
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int w = sc.nextInt();
      int a = sc.nextInt();
      int b = sc.nextInt();
      if(b > w+a)System.out.println(b-w-a);
      else if(a <= b+w)System.out.println(0);
      else if(b+w < a)System.out.println(a-b-w);
    }
}

Measured memory_bytes: 23764
using System;
using System.IO;

class Program
{
    static void Main(string[] args)
    {
        string S = Console.ReadLine();

        if (S[0] != S[1] && S[1] != S[2] && S[2] != S[0])
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 11092
function main(input){
  var smallFactor = 1;
  var bigFactor = 1;
  for(var i = 1;i <= Math.sqrt(input);i++){
    if(input % i === 0){
      smallFactor = i;
      bigFactor = input / i;
    }
  }
  console.log(smallFactor + bigFactor -2);
}

main(Number(require("fs").readFileSync("/dev/stdin","utf8")));

Measured memory_bytes: 9548
k,n = map(int, input().split())
a = list(int(j) for j in input().split())

deff_list = []

for i in range(len(a)-1):
    deff_list.append(a[i+1]-a[i])

deff_list.append(min(a)+(k-max(a)))

deff_list[deff_list.index(max(deff_list))] = 0

print(sum(deff_list))

Measured memory_bytes: 26420
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int total=0;
  int d=0;
  vector<int>vec(n);
  for (int i=0;i<n;i++){
cin>>vec.at(i);
    total+=vec.at(i);
  }
  int y=(double)total/n+0.5;
  for (int i=0;i<n;i++){
    d+=(y-vec.at(i))*(y-vec.at(i));
  }
  cout<<d<<endl;
}


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

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


def solve(S: str):
    allA = [s=='A' for s in S]
    allB = [s=='B' for s in S]

    if all(allA) or all(allB):
        print(NO)
    else:
        print(YES)
    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()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;

/*
コインのある領域は必ず連続している。直径をdとすると、直径がd-1 or d-2になる

*/

ll n,d[200010],diam,dp[200010];
vector<ll> v[200010];

void init(){
	cin>>n;
	rep(i,n-1){
		ll a,b;
		cin>>a>>b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	queue<ll> Q;
	reg(i,1,n)d[i]=1e18;
	d[1]=1;
	Q.push(1);
	while(!Q.empty()){
		ll p = Q.front();Q.pop();
		for(ll q:v[p]){
			if(d[q]>d[p]+1){
				d[q]=d[p]+1;
				Q.push(q);
			}
		}
	}
	ll t=1;
	reg(i,1,n)if(d[t]<d[i])t=i;
	reg(i,1,n)d[i]=1e18;
	d[t]=1;
	Q.push(t);
	while(!Q.empty()){
		ll p = Q.front();Q.pop();
		for(ll q:v[p]){
			if(d[q]>d[p]+1){
				d[q]=d[p]+1;
				Q.push(q);
			}
		}
	}
	t=1;
	reg(i,1,n)if(d[t]<d[i])t=i;
	diam = d[t];
}

int main(void){
	init();
	dp[0]=0;
	dp[1]=1;
	dp[2]=0;
	reg(i,3,diam){
		if(dp[i-1]==0||dp[i-2]==0){
			dp[i]=1;
		}else{
			dp[i]=0;
		}
	}
	cout<<(dp[diam]==0?"Second":"First")<<endl;
	return 0;
}

Measured memory_bytes: 17392
h, w = map(int, input().split())

n = 0
ans = []
next = 0
for y in range(h):
    line = list(map(int, input().split()))
    if next:
        line[-1] += 1
    for x in range(w - 1):
        if line[x] % 2 == 1:
            line[x + 1] += 1
            n += 1
            ans.append([y + 1, x + 1, y + 1, x + 2])
    if y == h - 1:
        break
    if line[-1] % 2 == 1:
        next = 1
        n += 1
        ans.append([y + 1, w, y + 2, w])
    else:
        next = 0

print(n)
for line in ans:
    print(*line)

Measured memory_bytes: 28080
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
using namespace std;

int main() {
    int n, m; cin >> n >> m;
    vector<int> a(n);
    for (int &ai: a) cin >> ai;
    map<long long, int> cnt;
    cnt[0]++;
    long long acc = 0, res = 0;
    for (int i = 0; i < n; i++) {
        acc += a[i];
        res += cnt[acc % m]++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 4608
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;

int main(void){
    int N, tmp;
    scanf("%d", &N);

    set<int> A;

    for (int i = 0; i < N;i ++){
        scanf("%d", &tmp);
        A.insert(tmp);
    }

    if(N == A.size()){
        printf("YES");
    }
    else{
        printf("NO");
    }
    return 0;
}


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

int main() {
  string s;
  cin >> s;
  ll ans=0;
  for(ll i=0;i<s.size();i++) {
    if(s[i]=='p') {
      ans++;
    }
  }
  ans=s.size()/2-ans;
  cout << ans << endl;
}

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

int N;
vector<bitset<8>> b(8, 0);

void loop(int bit, int *count, int point)
{
  bitset<8> flag(bit);
  flag.set(point);
  if (flag.count() == N)
  {
    (*count)++;
    return ;
  }
  for (int i = 0; i < N; i++)
  {
    if (!flag.test(i))
    {
      if (b[point].test(i))
        loop(flag.to_ullong(), count, i);
    }
  }
}

int main()
{
  int M, ai, aj, count = 0;

  cin >> N >> M;
  for (int i = 0; i < M; i++)
  {
    cin >> ai >> aj;
    b[ai - 1].set(aj - 1);
    b[aj - 1].set(ai - 1);
  }
  loop(0, &count, 0);
  cout << count << endl;
}


Measured memory_bytes: 256
n = int(input())
bits = set()
c1 = 0
count = 0
ans = []
for i in range(n):
    x = int(input())
    if x in bits:
        y = x
        while c1 < y and y in bits:
            y -= 1
        if y <= c1:
            y = 0
        if y == 0 and count != x:
            c1 = max(x, c1)
            ans.append("No")
        else:
            bits.add(y)
            ans.append("Yes")
            count += 1
            if y == 0:
                if i <= n-2:
                    ans.append("No\n"*(n-2-i) + "No")
                break
            for i in range(y+1, x+1):
                bits.remove(i)
                count -= 1
    else:
        bits.add(x)
        count += 1
        ans.append("Yes")
print("\n".join(ans))

Measured memory_bytes: 31008
import math
import numpy as np

A, B, H, M = map(int,input().split())
long = np.array([A*math.sin(H/12*2*math.pi+M/60*math.pi/6), A*math.cos(H/12*2*math.pi+M/60*math.pi/6)])
short = np.array([B*math.sin(M/60*2*math.pi), B*math.cos(M/60*2*math.pi)])

print(np.linalg.norm(long-short))


Measured memory_bytes: 27192
N = int(input())
S = list(input())

upper = [chr(i) for i in range(65, 65+26)]
new_upper = []

for i in S:
    Index = upper.index(i) + N
    if Index >= 26:
        Index -= 26
        new_upper.append(upper[Index])
    else:
        new_upper.append(upper[Index])
        
print(''.join(new_upper))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <numeric>
#define ll long long
using namespace std;
ll MOD = 1e9 + 7;
ll H, N, M, L, K, W, X, Y, Z;
ll ans = 0;
int gcd(int m, int n){
	return n == 0 ? m : gcd(n, m % n);
}
int lcm(int m, int n) {
	return (m / gcd(m, n))*n;
}
int main() {
	cin >> N >> X;
	vector<int>x(N);
	cin >> ans;
	ans = abs(ans - X);
	for (int i = 1; i < N; i++) {
		int tmp;
		cin >> tmp;
		x[i] = abs(tmp - X);
		ans = gcd(ans, x[i]);
	}
	cout << ans << endl;
}


Measured memory_bytes: 640
N = int(input())
L = [int(l) for l in input().split()]

L.sort()

S = [0]*(L[-1]+L[-2]+2)

for i in range(N):
    if i < N-1:
        for j in range(L[i], L[i+1]):
            S[j] = i+1
    else:
        for j in range(L[-1], len(S)):
            S[j] = i+1
        
ans = 0
for i in range(N-1):
    for j in range(i+1, N):
        m = abs(L[j]-L[i])
        M = L[j]+L[i]
        ans += S[M-1]-S[m]
        if m < L[i] < M:
            ans -= 1
        if m < L[j] < M:
            ans -= 1
            
print(ans//3)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=200010;
int n,L[N],siz[N];
char s[N];
vector<int> v[N];
class dat
{
	public:
		int mx1,mx2;
		void update(int v)
		{
			if(v>mx1)
			{
				mx2=mx1;
				mx1=v;
			}
			else if(v>mx2)mx2=v;
		}
}d[N],dg[N];
void dfs1(int np,int fath)
{
	L[np]=0x3f3f3f3f;
	siz[np]=(s[np]=='1');
	for(int &x:v[np])
	{
		if(x==fath)continue;
		dfs1(x,np);
		siz[np]+=siz[x];
		if(siz[x])L[np]=min(L[np],d[x].mx1+1);
		d[np].update(d[x].mx1+1);
	}
}
void dfs2(int np,int fath,int dfa)
{
	if(siz[1]-siz[np])L[np]=min(L[np],dfa+1);
	d[np].update(dfa+1);
	vector<int> ch;
	ch.push_back(0);
	for(int &x:v[np])
	{
		if(x==fath)continue;
		ch.push_back(x);
	}
	ch.push_back(0);
	vector<int> pre(ch.size()),suf(ch.size());
	for(int i=1;i+1<pre.size();i++)pre[i]=max(pre[i-1],d[ch[i]].mx1+1);
	for(int i=suf.size()-2;i>=1;i--)suf[i]=max(suf[i+1],d[ch[i]].mx1+1);
	for(int i=1;i+1<ch.size();i++)
		dfs2(ch[i],np,max(dfa+1,max(pre[i-1],suf[i+1])));
}
int main()
{
	scanf("%d",&n);
	for(int i=1,ti,tj;i<n;i++)
	{
		scanf("%d%d",&ti,&tj);
		v[ti].push_back(tj);
		v[tj].push_back(ti);
	}
	scanf("%s",s+1);
	dfs1(1,0);
	dfs2(1,0,-1e9);
	ll ans=1;
	for(int i=1;i<=n;i++)
	{
		int l=(s[i]=='1'?0:L[i]),r=min(d[i].mx1,d[i].mx2+2);
		if(l<r)ans+=r-l;
	}
	printf("%lld\n",ans);
	return 0;
}

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

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  int n,m,d;
  scanf("%d%d%d",&n,&m,&d);
  if(d==0){
    double p=(double)1/n;
    printf("%.9lf\n",(double)p*(m-1));
    return;
  }
  double p=(double)(n-d)*2/n/n;
  printf("%.9lf\n",ABS(p*(m-1)));
}

int main(void){
  run();
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include <algorithm>
#include<deque>

//マクロ
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)

#define All(a) (a).begin(),(a).end()

//定数
#define INF 1e9
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数

//使用する関数
template<class T>bool chmax(T &a, const T &b) {
	if (a < b) { a = b; return 1; }
	return 0;
}
template<class T>bool chmin(T &a, const T &b) {
	if (a > b) { a = b; return 1; }
	return 0;
}


int main()
{
	int n, k, q;
	cin >> n >> k >> q;

	vector<int> a(100000, 0);
	REP(i, q) {
		int ai;
		cin >> ai;
		a[ai-1]++;
	}

	REP(i, n) {
		if (k - (q - a[i]) > 0) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1024
// Original: https://github.com/tanakh/competitive-rs
#[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)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

mod util {
    #[allow(dead_code)]
    pub fn chmin<T>(x: &mut T, y: T) -> bool
    where
        T: PartialOrd + Copy,
    {
        *x > y && {
            *x = y;
            true
        }
    }

    #[allow(dead_code)]
    pub fn chmax<T>(x: &mut T, y: T) -> bool
    where
        T: PartialOrd + Copy,
    {
        *x < y && {
            *x = y;
            true
        }
    }

    /// 整数除算切り上げ
    #[allow(dead_code)]
    pub fn roundup(a: i64, b: i64) -> i64 {
        (a + b - 1) / b
    }

    #[allow(dead_code)]
    pub fn ctoi(c: char) -> i64 {
        c as i64 - 48
    }
}

#[allow(unused_imports)]
use util::*;

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, VecDeque};

fn main() {
    input! {
        a:i64,b:i64
    }

    // 和と差の積は2乗の差などを使って式変形すれば、2k = a + b が得られる
    let k = a + b;
    let k = k / 2;
    // 得られたkが条件を満たすか判断
    let ok = (k - a).abs() == (k - b).abs();
    if ok {
        println!("{}", k);
    } else {
        println!("IMPOSSIBLE");
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <tuple>
#include <cmath>
using namespace std;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;

int main(){
    int N;
    int64_t L,T;
    cin>>N>>L>>T;
    vector<int64_t> X(N),W(N);
    for(int i=0;i<N;i++){
        cin>>X[i]>>W[i];
    }
    int64_t cnt = 0;
    for(int i=1;i<N;i++){
        if(W[0]==W[i]) continue;
        if(W[0]==1&&W[i]==2){
            if(X[i]-X[0]<=2*T){
                cnt+=1+(2*T-(X[i]-X[0]))/L;
            }
        }
        if(W[0]==2&&W[i]==1){
            if(X[0]+(L-X[i])<=2*T){
                cnt+=1+(2*T-(X[0]+(L-X[i])))/L;
            }
        }
    }
    for(int i=0;i<N;i++){
        if(W[i]==1){
            X[i]=(X[i]+T)%L;
        }else{
            X[i]=(X[i]+L-(T%L))%L;
        }
    }
    int x=X[0],idx;
    sort(X.begin(), X.end());
    if(W[0]==1){
        idx=cnt%N;
    }else{
        idx=(N-(cnt%N))%N;
    }
    for(int i=0;i<N;i++){
        if(x==X[i]){
            if(i+1<N&&X[i+1]==X[i]&&W[0]==1){
                i++;
            }
            for(int j=(N+i-idx)%N;j<N;j++){
                cout<<X[j]<<endl;
            }
            for(int j=0;j<(N+i-idx)%N;j++){
                cout<<X[j]<<endl;
            }
            break;
        }
    }
    return 0;
}

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

using namespace std;

int main() {
  int X, N;
  cin >> X >> N;

  if (N == 0) {
    cout << X << endl;
  } else {
    vector<int> p(N);

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

    // 出力しうる数字のリスト
    vector<int> nature(201);
    // 初期化
    for (int i = 0; i < 201; i++) {
      nature.at(i) = i;
    }

    // pを降順ソートしておく
    sort(p.begin(), p.end(), greater<int>());

    // 禁止リストの要素を排除
    for (auto pi : p) {
      nature.erase(nature.begin() + pi);
    }

    // 出力可能性リストを降順ソート
    sort(nature.begin(), nature.end(), greater<int>());

    int minimum_diff = 1000;
    int answer = 0;

    for (auto n : nature) {
      if (abs(X - n) <= minimum_diff) {
        minimum_diff = abs(X - n);
        answer = n;
      }
    }

    cout << answer << endl;
  }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define sz(v) (int)(v).size()
using namespace std;
using P = pair<int, int>;
typedef long long ll;
int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	string s;
	cin >> s;
	int ans = 0, l = sz(s);
	rep(i, l / 2)
	{
		if(s[i] != s[l-i-1])
		{
			// cout << "i: " << s[i] << " l-i: " << s[l-i-1] << endl;
			s[i] = s[l-i-1];
			ans++;
		}
	}
	cout << ans << '\n';
	return 0;
}


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

int main() {
	int n;
	cin >> n;
	int ans = 0;
	for (int i = 0, prev = 0, h; i < n; i++) {
		cin >> h;
		if (h > prev) {
			ans += h - prev;
		}
		prev = h;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ll N; cin >> N;
  ll res = 0;
  for (ll i = 0; i < N; i++) {
    ll x; cin >> x;
    while (x%2 == 0) {x/=2; res++;}
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e3+5,M=2e4+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a,b) memset(a,b,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first
#define se second
#define pb push_back
#define il inline
int main(){
	int a,b;
	char c;
	cin>>a>>c>>b;
	if(c=='+') cout<<a+b;
	else cout<<a-b;
	return 0;
}

Measured memory_bytes: 3648
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,tune=native")
//#pragma comment(linker, "/stack:200000000"]

#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <bitset>
#include <stack>
#include <random>

#define fr first
#define se second
#define pb push_back
#define ll long long
#define ld long double
#define hm unordered_map
#define pii pair<int, int>
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define cinv(v) for (auto& x: v) cin >> x
//#define fr(i, n) for (int i = 0; i < n; ++i)
#define fl(i, l, n) for (int i = l; i < n; ++i)

using namespace std;

#ifdef __LOCAL
    #define dbg(x) cerr << #x << " : " << x << '\n'
    const int maxn = 110 + 10;
#else
    #define dbg(x)
    const int maxn = 110;
#endif

//tg: @galebickosikasa

const ll inf = (ll) 1e9 + 10;
const ld pi = 3.14159265358979323846264;
const ld eps = 1e-8;
const ll mod = (ll) 1e9 + 7;
const ll ns = 97;
const int MAXLOG = 20;
const int N = 45;

#define int ll

random_device rd;
mt19937 SuperRandom(rd());

struct DSU {
    vector<int> dsu, sz;

    DSU(int s) {
        dsu = vector<int>(s);
        sz = vector<int> (s, 1);
        for (int i = 0; i < s; ++i) dsu[i] = i;
    }

    int get(int x) {
        if (dsu[x] == x) return x;
        return dsu[x] = get(dsu[x]);
    }

    void join(int a, int b) {
        int x = get(a), y = get(b);
        if (x != y) {
            dsu[x] = y;
            sz[y] += sz[x];
        }
    }
};


signed main(){
    ios_base::sync_with_stdio(false);
    cout.tie(nullptr);
    cin.tie(nullptr);
    int n;
    cin >> n;
    int m, k;
    cin >> m >> k;
    vector<vector<int>> g (n), _g (n);
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        g[a].pb(b), g[b].pb(a);
    }
    for (int i = 0; i < k; ++i) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        _g[a].pb(b), _g[b].pb(a);
    }
    DSU goo (n);
    for (int i = 0; i < n; ++i) {
        for (auto &x: g[i]) {
            goo.join(x, i);
        }
    }
    vector<int> ans (n);
    for (int i = 0; i < n; ++i) {
        ans[i] = goo.sz[goo.get(i)];
        ans[i] -= sz (g[i]);
        for (auto &x: _g[i]) {
            int a = goo.get(i), b = goo.get(x);
            if (a == b) --ans[i];
        }
        cout << ans[i] - 1 << ' ';
    }




}

Measured memory_bytes: 15348
#include <stdio.h>
int main (void){
int Y[300],X[300],a=1,b=1,c=1;
while (3){
    scanf ("%d %d",&Y[300],&X[300]);
    if (Y[300]==0&&X[300]==0){break;}
    for (a=1; a<Y[300]+1; a++){
        if(a%2==1){
            for (b=1; b<X[300]+1; b++){
                if(b%2==1){
                    printf ("#");
                }
                else if(b%2==0){
                    printf (".");
                }
            }
        }
        if (a%2==0){
            for (c=1; c<X[300]+1; c++){
                if(c%2==1){
                    printf (".");
                }
                else if(c%2==0){
                    printf ("#");
                }
            }

        }
printf ("\n");
    }
printf ("\n");

}
return 0;
}

Measured memory_bytes: 572
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#include <cmath>
#include <map>
#include <set>

#define rep(i, m, n) for (int i = m; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define srep(i) for (int i = 0; i < s.size(); i++)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout << #x << ": " << x << endl
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define PI 3.14159265358979

using namespace std;

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int n,a,b, gx, gy;
char field[105][105];
int cnt[105][105];
string s;

int main(){
    cin>>s;
    for(int i=0; i<s.size(); i++){
        if(s[i]=='1') cout<<'9';
        else cout<<'1';
    }
    cout<<endl;
}

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

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

    vector<string> s(N);
    rep(i, N) {
        cin >> s.at(i);
    }

    int M;
    cin >> M;
    vector<string> t(M);
    rep(i, M) {
        cin >> t.at(i);
    }

    int max = 0;
    rep(i, N) {
        int count = 1;
        for (int j = i + 1; j < N; j++) {
            if (s.at(j) == s.at(i)) {
                count++;
            }
        }
        rep(k, M) {
            if (t.at(k) == s.at(i)) {
                count--;
            }
        }
        if (max < count) {
            max = count;
        }
    }

    cout << max << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		while(true){
			String[] line = br.readLine().split(" ");
			int a = Integer.parseInt(line[0]);
			int b = Integer.parseInt(line[2]);
			if( line[1].equals("?") ){
				break;
			}else if( line[1].equals("+") ){
				sb.append((a + b)+"\n");
			}else if( line[1].equals("-") ){
				sb.append((a - b)+"\n");
			}else if( line[1].equals("*") ){
				sb.append((a * b)+"\n");
			}else if( line[1].equals("/") ){
				sb.append((a / b)+"\n");
			}else if( line[1].equals("%") ){
				sb.append((a % b)+"\n");
			}
		}
		System.out.print(sb);
	}
}

Measured memory_bytes: 24396
#include<iostream>
#include<cstring>
#include<cstdio>
 
using namespace std;
const int N = 100000 + 5;
 
int a[N];
 
int main(){
    int n, x;
    memset(a, 0, sizeof(a));
    scanf("%d", &n);
    int maxn = 0;
    for(int i = 0; i < n; i++){
        scanf("%d", &x);
        a[x]++;
        if(x > maxn) maxn = x;
    }
    int ans = 0;
    for(int i = 0; i <= maxn; i++){
        if(a[i] > ans) ans = a[i];
    }
    for(int i = 0; i <= maxn; i++){
        if(a[i] + a[i+1] > ans) ans = a[i] + a[i+1];
    }
    for(int i = 0; i <= maxn; i++){
        if(a[i]+ a[i + 2] + a[i + 1] > ans) ans = a[i] + a[i+1] + a[i+2];
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<28;
const ll INF=1ll<<50;
const double pi=acos(-1);
const double eps=1e-8;
const int mod=1e9+7;
const vi emp;
const int dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
const int DX[8]={-1,-1,-1,0,0,1,1,1},DY[8]={1,0,-1,1,-1,1,0,-1};

class Segment_Tree{
	public:
	vi date;
	int n;
	Segment_Tree(int n_){
		n=1;
		for(int i=0;i<n_;i++) n*=2;
		date=vi(2*n-1,-1);
		for(int i=0;i<n;i++){
			int a;
			cin>>a;
			Update(i,a);
		}
	}
	void Update(int k,int x){
		k+=n-1;
		date[k]=x;
		while(k>0){
			k=(k-1)/2;
			int a=k*2+1,b=k*2+2;
			if(date[a]!=-1&&date[b]!=-1){
				if(date[a]==date[b]) date[k]=date[a];
				else{
					if(date[a]<date[b]) swap(date[a],date[b]);
					date[k]=date[a]-date[b];
				}
			}
		}
	}
};

int n;

int main(){
	cin>>n;
	Segment_Tree t(n);
	cout<<t.date[0]<<endl;
}

Measured memory_bytes: 2304
/**
 * @author      : omgursocute
 * @created     : 27/01/2020
 * @task        : D
 */

// ===== TEMPLATE STARTS HERE ===== //

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

#define FORa(i, a, b) for(ll i = (a); i <= (b); ++i)
#define FORb(i, a, b, c) for(ll i = (a); i <= (b); i += (c))
#define FORn(i, n) for(ll i = 0; i < (n); ++i)
#define FORra(i, a, b) for(ll i = (a); i >= (b); --i)
#define FORrb(i, a, b, c) for(ll i = (a); i >= (b); i -= (c))
#define FORrn(i, n) for(ll i = ((n)-1); i >= 0; --i)
#define NUMARGC(_1, _2, _3, _4, NAME, ...) NAME
#define FOR(...) NUMARGC(__VA_ARGS__, FORb, FORa, FORn)(__VA_ARGS__)
#define RFOR(...) NUMARGC(__VA_ARGS__, FORrb, FORra, FORrn)(__VA_ARGS__)

#define XFOR(i, x) for(__typeof((x).begin()) i = (x).begin(); i != (x).end(); ++i)
#define RXFOR(i, x) for(__typeof((x).rbegin()) i = (x).rbegin(); i != (x).rend(); ++i)

#define pll pair<ll, ll>
#define pii pair<int, int>
#define vi vector<int>
#define vll vector<ll>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define range(x, a, b) ((x).begin()+a), ((x).begin()+b)
#define pb push_back

#define sqr(x) 1ll*(x)*(x)
#ifndef ONLINE_JUDGE
#define debug(x) cerr << '[' << #x << ']' << " = " << x << '\n'
#else
#define debug(x) "cute"
#endif

namespace io {
	void Speed() {
		ios::sync_with_stdio(false);
		cin.tie(NULL); cout.tie(NULL);
	}
#ifndef ONLINE_JUGDE
	void In(string s) {freopen(s.c_str(), "r", stdin);}
	void Out(string s) {freopen(s.c_str(), "w", stdout);}
	void setIO(string s) {In(s + ".inp"); Out(s + "out");}
#endif
}

// ======= TEMPLATE ENDS HERE ======= //

int main() {
	io::Speed();
	
	ll n;
	cin >> n;
	
	ll ct = 0;
	ll x = 1;

	while(n != 0) {
		n /= 2;
		ct += x;
		x *= 2 ;
	}

	cout << ct;

	return 0;
}



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

//#define DEBUG

#ifdef DEBUG
#define dump(i) cout << "[*] " #i ": " << i << endl;
#else
#define dump(i)
#endif

long long int a[51];
long long int ha[51];

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

    a[0] = 1;
    ha[0] = 1;
    for (int i = 1; i <= n; ++i) {
        a[i] = a[i-1] * 2 + 3;
        ha[i] = (a[i] + 1) / 2;
        dump(a[i]);
        dump(ha[i]);
    }
    long long int pnum = 0;
    while (n+1) {
        dump(n);
        dump(x);
        if (x == ha[n]) {
            pnum += ha[n-1] + 1;
            break;
        } else if (x == ha[n] - 1) {
            pnum += ha[n-1];
            break;
        } else if (x < ha[n] - 1) {
            x--;
            n--;
        } else if (x > ha[n]) {
            pnum += ha[n-1]+1;
            x -= ha[n];
            n--;
        }
    }

    cout << pnum << endl;
    return 0;
}


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

int main() {
    int n;
  cin>>n;
    ll t,l=1;
    for (int i=0;i<n;i++) {
        cin>>t;
        l=l/__gcd(l,t)*t;
    }
    cout<<l<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
     
    using namespace std;
     
    int main(){
    	int h , n;
      	cin >> h >> n;
      	while(n--){
        	int x;
          	cin >> x;
          	if((h-=x) <=0){
              	cout <<"Yes\n";
            	return 0;
            }
        }
      	cout <<"No\n";
    	return 0;
    }

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

int main()
{
    int A,B,j;
    cin >> A >> B;
    bool success = false;
    for(int i=1;i<=1250;i++)
    {
        if((i*8)/100==A && (i/10)==B)
        {
            success = true;
            j = i;
            break;
        }
    }
    if(success)
    {
        cout << j << endl;
    }
    else
    {
        cout << -1 << endl;

    }

}

Measured memory_bytes: 256