akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define debug(x)        cout<<#x<<" :"<<x<<endl;
#define ff              first
#define ss              second
#define ar              array
#define int             long long
#define ld              long double
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define f(i,n)          for(int i=0;i<n;i++)
#define MOD             1000000007
#define pi              3.14159265
#define umii            unordered_map<int,int>
#define umci            unordered_map<char,int>
#define umsi            unordered_map<string,int>

void k_007()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#ifndef ONLINE_JUDGE
	freopen("ip1.txt", "r", stdin);
	freopen("op1.txt", "w", stdout);
#endif
}

bool sortbysec(const pair<int, int> &a, const pair<int, int> &b)
{
	return (a.second < b.second);
}
int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int prime(int n) {
	int flag = 1;
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0) {flag = 0; break;}
	}
	return flag;
}
int power(int x, int y)
{
	if (y == 0)
		return 1;
	else if (y % 2 == 0)
		return ((power(x, y / 2) % MOD) * ( power(x, y / 2) % MOD)) % MOD;
	else
		return ((x % MOD) * (power(x, y / 2) % MOD) * (power(x, y / 2) % MOD)) % MOD;
}
int lcm(int a, int b)
{
	return (a * b) / gcd(a, b);
}
// int JUDGE_ONLINE = 1;
// if (fopen("ip1.txt", "r")) {
// 	JUDGE_ONLINE = 0;
// 	assert(freopen("ip1.txt", "r", stdin));
// 	assert(freopen("op1.txt", "w", stdout));
// }

// if (!JUDGE_ONLINE) {
// 	cout << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
// }

int32_t main()
{
	k_007();
	int a[3][3];
	f(i, 3)
	{
		f(j, 3)
		{cin >> a[i][j];}
	}
	int n;
	cin >> n;
	map<int, int> mp;
	while (n--)
	{
		int x;
		cin >> x;
		mp[x] = 1;
	}
	bool bingo = false;
	f(i, 3)
	{
		bool ok = true;
		f(j, 3)
		{
			if (mp[a[i][j]] != 1)
			{
				ok = false;
			}
		}
		if (ok)
		{
			bingo = true;
			break;
		}
	}
	if (bingo)
	{
		cout << "Yes";
		return 0;
	}

	f(i, 3)
	{
		bool ok = true;

		f(j, 3)
		{
			if (mp[a[j][i]] != 1)
			{
				ok = false;
			}
		}
		if (ok)
		{
			bingo = true;
			break;
		}

	}
	if (bingo)
	{
		cout << "Yes";
		return 0;
	}

	if (mp[a[1][1]] && mp[a[0][0]] && mp[a[2][2]])
	{
		cout << "Yes";
		return 0;
	}
	if (mp[a[0][2]] && mp[a[1][1]] && mp[a[2][0]])
	{
		cout << "Yes";
		return 0;
	}

	cout << "No" << endl;

}


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

int cnt = 0;
const int INF = 1<<30;

const int MAX = 500010;
int ls[MAX], rs[MAX];

void merge(vector<int> &arr, int left, int mid, int right)
{
  int n1, n2;
  n1 = mid - left;
  n2 = right - mid;
  for (int i = 0; i < n1; i++)
    ls[i] = arr[left + i];
  for (int i = 0; i < n2; i++)
    rs[i] = arr[mid + i];
  ls[n1] = INF;
  rs[n2] = INF;

  int i = 0, j = 0;
  for (int k = left; k < right; k++) {
    cnt++;
    if (ls[i] <= rs[j]) {
      arr[k] = ls[i];
      i++;
    } else {
      arr[k] = rs[j];
      j++;
    }
  }
}

void merge_sort(vector<int> &arr, int left, int right)
{
  if (left+1 < right) {
    int mid = (left + right)/2;
    merge_sort(arr, left, mid);
    merge_sort(arr, mid, right);
    merge(arr, left, mid, right);
  }
}

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

  merge_sort(arr, 0, arr.size());

  for (int i = 0; i < n; i++)
    cout << arr[i] << (i==n-1?'\n':' ');
  cout << cnt << endl;

  return EXIT_SUCCESS;
}




Measured memory_bytes: 6752
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));
	int s = Integer.parseInt(br.readLine());
	int sec = s % 60;
	int t = s / 60;
	int min = t % 60;
	int hour = t / 60;

	System.out.println(hour + ":" + min + ":" + sec);
    }

}

Measured memory_bytes: 24292
#include<vector>
#include<iostream>
#include<algorithm>
#include<tuple>
#include<string>
#include<bits/stdc++.h>
using namespace std;
int func(int x){
    if((x%2)!=0)return 0;
    return func(x/2)+1;
}
void solve(){
    int N,a,ans;
    cin>>N;
    ans=0;
    for(int i=0;i<N;i++){
        cin>>a;
        ans+=func(a);
    }
    cout<<ans<<endl;
    


}

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

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		long h = sc.nextLong();
		System.out.println(calc(h));
	}
	static long calc(long n) {
		if(n == 1) return 1;
		else return 1+2*calc(n/2);
	}
	
	static class FastScanner {
		public BufferedReader reader;
		public StringTokenizer tokenizer;
		public FastScanner() {
			reader = new BufferedReader(new InputStreamReader(System.in), 32768);
			tokenizer = null;
		}
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch(IOException e) {
				throw new RuntimeException(e);
			}
		}
	}

}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

ll n, m;

int main() {
    cin >> n >> m;
    if (n < m)
        swap(n, m);
    if (m == 1) {
        if (n == 1)
            cout << 1 << endl;
        else
            cout << n - 2 << endl;
    } else {
        cout << (n - 2) * (m - 2) << endl;
    }

    return 0;
}


Measured memory_bytes: 3588
#include "bits/stdc++.h"

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

using namespace std;

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

	int N, L, sum = 0; cin >> N >> L;
	vector<int> ver(N + 1, 0);
	for (int i = 1; i < N + 1; i++) {
		ver[i] = L + i - 1;
		sum += ver[i];
	}
	for (int i = 1; i < N + 1; i++) {
		if (ver[i]==0) {
			cout << sum << endl;
			return 0;
		}
	}
	int A = -99999,B=99999;
	if (sum >= 0) {
		for (int i = 1; i < N + 1; i++) {
			A = max(A, sum - ver[i]);
		}
		cout << A << endl;
		return 0;
	}
	else {
		for (int i = 1; i < N + 1; i++) {
			B = min(B, sum - ver[i]);
		}
		cout << B << endl;
		return 0;
	}
}

Measured memory_bytes: 256
package main

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

func main() {
	N := nextInt()
	M := nextInt()
	p := make([]int, N)
	cw := make([]int, N)
	for i := 0; i < N; i++ {
		p[i] = -1
	}
	for i := 0; i < M; i++ {
		n := nextInt()
		r := nextString()
		if r == "WA" && p[n-1] == -1 {
			cw[n-1]++
		}
		if r == "AC" {
			if p[n-1] == -1 {
				p[n-1] = cw[n-1]
			}
		}
	}

	ans := 0
	tp := 0
	for _, v := range p {
		if v != -1 {
			ans++
			tp += v
		}
	}
	fmt.Printf("%d %d", ans, tp)
}

func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}

func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}

func nextString() string {
	return nextReader()
}

func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

func nextInt64s(n int) []int64 {
	r := make([]int64, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt64()
	}
	return r
}

var nextReader func() string

func init() {
	nextReader = NewScanner()
}

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}

func Min(a int, b int) int {
	if a > b {
		return b
	}
	return a
}

func Max(a int, b int) int {
	if a > b {
		return a
	}
	return b
}

func MinA(arg ...int) int {
	var s = arg[0]
	for _, v := range arg {
		s = Min(s, v)
	}
	return s
}

func MaxA(arg ...int) int {
	var s = arg[0]
	for _, v := range arg {
		s = Max(s, v)
	}
	return s
}

func Abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}


Measured memory_bytes: 3072
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars};
#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
	input! {
		n: usize,
	}

	let mut m = n;
	let mut sum = 0;
	while m > 0 {
		sum += m % 10;
		m /= 10;
	}
	if n % sum == 0 {
		println!("Yes");
	}
	else {
		println!("No");
	}
}



Measured memory_bytes: 2076
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <algorithm>

#define REP(i,n) for(int i=0; i<n; i++)
#define FOR(i,a,b) for(int i=a; i<=b; i++)
#define ll long long int

using namespace std;

int main(void) {
    int a[30]={};
    REP(i,28){
        int t;
        cin >> t;
        a[t-1]++;
    }
    REP(i,30){
        if(a[i]==0)
            cout << i+1 <<endl;
    }
    
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const int mod=1000000007;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

int gcd(int a, int b){
  if (a%b==0){
    return(b);
  }
  else{
    return(gcd(b,a%b));
  }
}


// ll memo[2020][2020];
// int pascal_triangle(){
//   for(int i = 0; i < 2020; i++){
//     for(int j = 0; j < i+1; j++){
//       if(j == 0 || j == i) memo[i][j] = 1;
//       else{
// 	memo[i][j] = (memo[i-1][j-1]+memo[i-1][j]);
//       }
//     }
//   }
//   return 0;
// }


int factrial(int n){
  if(n == 0) return 1;
  return n*factrial(n-1);
}

// int comb(int n, int k){
//   return fact(n) / (fact(n-k)*fact(k));
// }




int main(){
  int N,K;
  cin >> N >> K;
  ll a = 0;
  ll ans = 0;
  ll n = N/K;
  ans += pow(n,3);
  if(K%2 == 0){
    a = (N/(K/2) + 1) / 2;
    ans += pow(a,3);
  }
  cout << ans << endl;
}



Measured memory_bytes: 512
s = input()

s_01 = ''
s_10 = ''

for i in range(1,len(s)+1):
    if i % 2 == 1:
        s_01 += '0'
    
    else:
        s_01 += '1'

for i in range(1,len(s)+1):
    if i % 2 == 1:
        s_10 += '1'
    
    else:
        s_10 += '0'
    
c_01 = 0
c_10 = 0

for i in range(len(s)):
    if s[i] != s_01[i]:
        c_01 += 1
    
    if s[i] != s_10[i]:
        c_10 += 1

print(min(c_10,c_01))

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
//char c;

#define Endl endl


/*--------------------template--------------------*/


int main() {
    cin >> n >> m;
    vi v(n, 1);
    vector<bool> vans(n, false);
    vans[0] = true;
    REP(i, m) {
        ll l;
        cin >> l >> k;
        l--;
        k--;

        if (v[l] == 0) {
            continue;
        }

        if (vans[l]) {
            vans[k] = true;
        }

        v[l]--;
        v[k]++;
        if (v[l] == 0) {
            vans[l] = false;
        }
    }
    REP(i, n) {
        if (vans[i]) {
            cnt++;
        }
    }
    cout << cnt << Endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int a,b[10000],m;
  cin>>a;
  for(int i=0;i<a;i++){
    cin>>b[i];
  }
  cin>>a;
  int c,d,e;
  for(int i=0;i<a;i++){
    int q[10000],n=0;
    cin>>c>>d>>e;
    for(int j=c;j<d;j++){
      q[j]=b[j];
    } 
    m=0;
    for(int k=c;k<d;k++){
      if(e==q[k]) m++;
    }
    cout<<m<<"\n";
  }
}



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

using namespace std;

#define rep(i , n) for(int i=0 ; i<n ; i++)
#define rep1(i , n) for(int i=1 ; i<=n ; i++)

typedef long long int ll;

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

	int d,n;
	cin >> d >> n;

	int ans = 1;
	if(d == 0)
	{
	    int i=1;
	    int count = 0;
	    while(count != n)
	    {
	        if(i%100 != 0)
	            count++;
	        i++;
	    }
	    ans = i-1;
	}
	else if(d == 1)
	{
	    if(n == 100)
	        ans = 10100;
	      else
		    ans = n*100;
	}
	else if(d == 2)
	{
	    if(n == 100)
	        ans = 1010000;
	    else
		    ans = n*10000;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

a, b = sl()

import math
c = int(math.sqrt(int(a + b)))

if c * c == int(a+b):
    print('Yes')
else:
    print('No')



Measured memory_bytes: 3060
#include <stdio.h>
#include <algorithm>
#include <iostream>

using namespace std;

class Heap{
public:
	Heap(){
		array = new int[2000000];
		n = 0;
	}
	void insert(int data){
		array[n] = data;
		int tmp = n;
		while(tmp != 0 && array[tmp] > array[(tmp-1)/2]){
			std::swap(array[tmp], array[(tmp-1)/2]);
			tmp = (tmp-1)/2;
		}
		n++;
	}
	int extract(){
		int ret = array[0];
		n--;
		std::swap(array[0],array[n]);
		int tmp = 0;
		while(2*tmp+1 <= n-1){
			if(2*tmp+2 <= n-1){
				if(array[2*tmp+2] > array[tmp] && array[2*tmp+2] >= array[2*tmp+1]){
					std::swap(array[2*tmp+2],array[tmp]);
					tmp = 2*tmp+2;
				}else if(array[2*tmp+1] > array[tmp] && array[2*tmp+1] >= array[2*tmp+2]){
					std::swap(array[2*tmp+1],array[tmp]);
					tmp = 2*tmp+1;
				}else{
					break;
				}
			}else{
				if(array[tmp] < array[2*tmp+1]){
					std::swap(array[tmp],array[2*tmp+1]);
					tmp = 2*tmp+1;
				}else{
					break;
				}
			}
		}
		return ret;
	}

private:
	int* array;
	int n;
};

int main(){

	int insert_data;
	char buf[22];
	Heap heap;

	while(true){
		fgets(buf,22,stdin);
		if(buf[2] == 'd') break;
		if(buf[0] == 'i'){
			insert_data = 0;
			for(int i = 0; buf[i] != '\0';i++){
				if(buf[i] >= '0' && buf[i] <= '9'){
					insert_data = 10*insert_data + (buf[i] - '0');
				}
			}
			heap.insert(insert_data);
		}else{
			printf("%d\n",heap.extract());
		}
	}
}



Measured memory_bytes: 7108
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
#include<fstream>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)

#define mp make_pair
#define P pair<int,int>
#define ll __int64
P t[10000];
int n,m;

int main(){
	cin>>n>>m;
	int ans=0;
	bool ok=false;
	int a,b;
	for(int i=0;i<m;i++){
		cin>>a>>b;
		t[i]=mp(b,a);
	}
	sort(t,t+m);
	for(int i=0;i<m-1;i++){
		int tt=t[i].second,f=t[i].first;
		if(tt<f)ans+=(f-tt)/2;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3152
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n = readline() |> parseInt
	x = Array{Int}(3,n)
	for i in 1:n
		x[:,i] = readline() |> split |> parseMap
	end
	s = [0,0,0]
	for i in 1:n
		if x[3,i] != 0
			s = x[:,i]
			break
		end
	end
	for i in 0:100
		for j in 0:100
			flg = 0
			h = [i,j,s[3]+abs(i-s[1])+abs(j-s[2])]
			for k in 1:n
				if max(h[3]-abs(i-x[1,k])-abs(j-x[2,k]),0) != x[3,k]
					flg = 1
					break
				end
			end
			if flg == 0
				print(i, " ", j, " ", h[3])
			end
		end
	end
end

main()

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

int main(){
    int n, x, y; cin >> n >> x >> y;
    vector<int> ans(n);
    for(int i = 1; i < n; i++){
        for(int j = i + 1; j <= n; j++){
            int m = min(j-i, abs(x - i) + 1 + abs(y - j));
            ans.at(m - 1)++;
        }
    } 
    for(int i = 0; i < n - 1; i++){
        cout << ans.at(i) << endl;
    }
}

Measured memory_bytes: 256
s = list(input())
ans = 0
for i in range(1 << (len(s)-1)):
    f = s[0]
    for j in range(len(s)-1):
        if ((i >> j) & 1) == 1:
            f += "+"
        else:
            f += "-"
        f += s[j+1]
    if eval(f) == 7:
        print(f+"=7")
        exit()

Measured memory_bytes: 3064
n=int(input())
ans=[]
if n%2==0:
    s=n*(n-1)//2-1
    ss=n*(n+1)//2
    for i in range(1,n):
        t=ss-s-i
        for j in range(i+1,n+1):
            if j!=t:
                ans.append((i,j))
if n%2==1:
    s=n*(n-1)//2
    ss=n*(n+1)//2
    for i in range(1,n):
        t=ss-s-i
        for j in range(i+1,n+1):
            if j!=t:
                ans.append((i,j))
print(len(ans))
for x,y in ans:
    print(x,y)

Measured memory_bytes: 9464
#include <cstdio>

double a,b;

int main(){
	while(scanf("%lf%lf",&a,&b) != EOF){
		if(a < 35.5 && b < 71){
			printf("AAA\n");
		}
		else if(a < 37.5 && b < 77){
			printf("AA\n");
		}
		else if(a < 40 && b < 83){
			printf("A\n");
		}
		else if(a < 43 && b < 89){
			printf("B\n");
		}
		else if(a < 50 && b < 105){
			printf("C\n");
		}
		else if(a < 55 && b < 116){
			printf("D\n");
		}
		else if(a < 70 && b < 148){
			printf("E\n");
		}
		else{
			printf("NA\n");
		}
	}
	return 0;
}

Measured memory_bytes: 2692
# m = map(int, raw_input().split())
n,m = map(int, raw_input().split())
ans = 0
for i in xrange(1,n+1):
  for j in xrange(1,m+1):
    ten = j/10
    one = j%10
    if j < 22 or ten < 2 or one < 2:
      continue
    if j/10 * (j%10) == i:
      ans += 1
print ans


Measured memory_bytes: 2568
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N, ans = 0;
    cin >> N;

    for (int i = 1; i <= N; i += 2)
    {
        int count = 0;
        for (int j = 1; j <= i; j++)
        {
            if (i % j == 0)
            {
                count++;
            }
        }
        if (count == 8)
        {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main
{
    public static void main(String[] args)
    {
        int i=1;
        int jud=0;
        int x=0;
        Scanner sc=new Scanner(System.in);
        
        int n=sc.nextInt();
        
        while(true)
        {
            //CHECK_NUM
            if(jud==0)
            {
                i++;
                x=i;
            }
            
            if(x%3==0 && jud!=-1)
            {
                System.out.printf(" %d",i);
                jud=0;
            }
            else
            {
                if(x%10==3)
                {
                    System.out.printf(" %d",i);
                    jud=0;
                    //goto END_CHECK_NUM
                }
                else
                {
                    x/=10;
                    if(x!=0)
                    {
                        jud=-1;
                    }   //goto INCLUDE3
                    else
                    {
                        jud=0;
                    }
                }
            }
            
            //END_CHECK_NUM
            
            if(i+1>n)
            {
                break;
            }
            //goto CHECK_NUM
        }
        System.out.print("\n");
    }
}

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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

#ifndef ONLINE_JUDGE
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
#else
#define print(...)
#endif


void bfs(queue<pair<ll,ll>>& q,vector<list<ll>>& g, vector<ll>& flag){
    queue<pair<ll,ll>> next_q;
    while(!q.empty()){
        ll f = q.front().first;
        ll x = q.front().second;
        q.pop();
        print("#",f,">",x);
        for(auto&& y: g[x]){
            print("$",x,">",y);
            if(flag[y] > flag.size()){
                flag[y] = x;
                next_q.push(pair<ll,ll>(x,y));
            }
        }
    }
    if(!next_q.empty())
        bfs(next_q, g, flag);
    print(flag);
}

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

    ll n,m;

    cin >> n >> m;

    vector<list<ll>> g(n,list<ll>());
    vector<ll> flag(n,n+1);
    flag[0] = 0;
    
    for(int i=0; i<m; i++){
        ll a,b;
        cin >> a >> b;

        a--;b--;

        g[a].push_back(b);
        g[b].push_back(a);
    }

    queue<pair<ll,ll>> q;
    for(auto&& x : g[0]){
        q.push(pair<ll,ll>(0,x));
        flag[x] = 0;
    }

    bfs(q,g,flag);

    cout << "Yes" << endl;

    for(int i=1; i<n; i++)
        cout << flag[i]+1 << endl;

    return 0;
}

Measured memory_bytes: 90852
use std::io::*;
use std::str::FromStr;
fn yn<T>(condition: bool, yes: T, no: T) -> T { if condition { yes } else { no } }
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a = read::<u32>();
    read::<u32>();
    read::<u32>();
    read::<u32>();
    let e = read::<u32>();
    let k = read::<u32>();
    println!("{}", yn(e-a<=k, "Yay!", ":(" ));
}

Measured memory_bytes: 4352
using System;
    using System.Text;
    using System.Collections.Generic;
    using static System.Math;
    using System.Linq;
    using static System.Array;
    
    namespace ConsoleApp2
    {
    class Program
    {
        static long H;
        static long W;
        static String[] map;
        static void Main(string[] args)
        {
            //var N = long.Parse(Console.ReadLine());
            var S = Console.ReadLine();
            //var ABC = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();


            if (S[S.Length-1] == '3')
            {
                Console.WriteLine("bon");
            }else if (S[S.Length - 1] == '0' || S[S.Length - 1] == '1' || S[S.Length - 1] == '6' || S[S.Length - 1] == '8')
            {
                Console.WriteLine("pon");
            }
            else
            {
                Console.WriteLine("hon");
            }


        }
    }

}


Measured memory_bytes: 17332
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    private static final int INF = (int) 1e9 + 5;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        PrintWriter writer = new PrintWriter(System.out);
        solve(scanner, writer);
        scanner.close();
        writer.close();
    }

    public static void solve(Scanner scanner, PrintWriter writer) {
        int n = scanner.nextInt();
        int w = scanner.nextInt();
        int[] weights = new int[n];
        int[] values = new int[n];
        for (int i = 0; i < n; i++) {
            weights[i] = scanner.nextInt();
            values[i] = scanner.nextInt();
        }

        int maxSum = 0;
        for (int x : values) {
            maxSum += x;
        }

        // dp[i] denote minimum total weights when values exactly i
        long[] dp = new long[maxSum + 1];
        Arrays.fill(dp, (long) Math.pow(10, 18) + 5);
        dp[0] = 0;

        for (int i = 0; i < n; i++) {
            for (int j = maxSum; j >= 0; j--) {
                if (j - values[i] >= 0) {
                    dp[j] = Math.min(dp[j], dp[j - values[i]] + weights[i]);
                }
            }
        }

        long ans = 0;
        for (int i = 0; i <= maxSum; i++) {
            if (dp[i] <= w) {
                ans = Math.max(ans, i);
            }
        }

        //writer.println(Arrays.toString(dp));

        writer.println(ans);
    }
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll=long long;

int main(){
    ll n,i,ans=0;
    cin>>n;
    for(i=1;i<=n;i++){
        if(i%3==0 || i%5==0){
        }else{
            ans+=i;
        }
    }
    cout<<ans;

    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
using namespace std;
string w[100];
int main(int argc, const char * argv[])
{
    char l;
    int n;
    cin>>n;
    bool ans=true;
    for(int i=0;i<n;i++)
        cin>>w[i];
    for(int i=0;i<n;i++)
    {
        if(i==0)
            l=w[0][w[0].size()-1];
        else if(w[i][0]!=l)
        {
            ans=false;
            break;
        }
        else
            l=w[i][w[i].size()-1];
        for(int j=0;j<i;j++)
        {
            if(w[j]==w[i])
            {
                ans=false;
                break;
            }
        }
        if(!ans)
            break;
    }
    if(ans)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    
    return 0;
}

Measured memory_bytes: 256
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	h, w, _ := scanInt(), scanInt(), scanInt()
	s := make([]string, h)
	for i := 0; i < h; i++ {
		s[i] = scanString()
	}

	a := make([][]int, h)
	c := 1
	for i := 0; i < h; i++ {
		f := false
		a[i] = make([]int, w)
		for j := 0; j < w; j++ {
			if s[i][j] == '#' {
				if !f {
					for k := j; k >= 0; k-- {
						a[i][k] = c
					}
					f = true
				} else {
					c++
					a[i][j] = c
				}
			} else {
				if f {
					a[i][j] = c
				}
			}
		}
		if f {
			c++
		}
	}

	for i := h - 1; i >= 0; i-- {
		for j := 0; j < w; j++ {
			if a[i][j] == 0 {
				if i != h-1 && a[i+1][j] != 0 {
					a[i][j] = a[i+1][j]
				}
			}
		}
	}

	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			if a[i][j] == 0 {
				a[i][j] = a[i-1][j]
			}
			fmt.Fprint(wr, a[i][j], " ")
		}
		fmt.Fprintln(wr)
	}

}


Measured memory_bytes: 3536
#include <iostream>
using namespace std;
int main(void){
       int a[100] ={0};
       int n;
       cin >> n;
       for (int i=0;i<n;i++){
           cin >> a[i];
       }
       cout << a[n-1];
       for (int i=1; i<n; i++){
           int j=n-1-i;
           
           cout << " "<< a[j];
           
       }
       cout << endl;
    
}



Measured memory_bytes: 3080
N,u,v=map(int,input().split())
from collections import deque
g=[[] for _ in range(N)]
for i in range(N-1):
  A,B=map(int,input().split())
  g[A-1].append(B-1)
  g[B-1].append(A-1)
def bfs(n):
  stack=deque([])
  depth=[-1]*N
  depth[n-1]=0
  stack.append(n-1)
  while stack:
    a=stack.popleft()
    for b in g[a]:
      if depth[b]==-1:
        depth[b]=depth[a]+1
        stack.append(b)
  return depth
U=bfs(u)
V=bfs(v)
List=[]
for i in range(N):
  if len(g[i])==1 and U[i]<V[i]:
    List.append(i)
ans=0

for i in List:
  ans=max(ans,V[i]-1)

print(ans)  

Measured memory_bytes: 29692
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>
#include <map>
#include <set>
#include <math.h>
#include <cmath>
#define ll long long

using namespace std;
using P = pair<int,int>;

int main(){

  int N, a;
  cin >> N;
  int ans = 0;

  vector<P> p(N);
  
  for (int i = 0; i < N; i++) {
    cin >> a;
    p[i].first = i+1;
    p[i].second = a;
  }

  for (int i = 0; i < N; i++) {
    int s = p[i].second;    
    if(p[i].first == p[s-1].second) ans++;
  }

  cout << ans/2 << endl;

  return 0;
}

Measured memory_bytes: 4060
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
const double EPS = 1e-10;
const double PI  = acos(-1.0);


const int MAX_N=200010;
int par[MAX_N];
int myrank[MAX_N];

void init(int n){
	for(int i=0;i<n;i++){
		par[i]=i;
		myrank[i]=0;
	}
}

int find(int x){
	if(par[x]==x){
		return x;
	}else{
		return par[x]=find(par[x]);
	}
}

void unite(int x,int y){
	x=find(x);
	y=find(y);
	if(x==y)return;

	if(myrank[x]<myrank[y]){
		par[x]=y;
	}else{
		par[y]=x;
		if(myrank[x]==myrank[y])myrank[x]++;
	}
}

bool same(int x,int y){
	return find(x)==find(y);
}
int dx[]={0,1,1,0,-1},dy[]={0,0,1,1,1};
int main(){
	int n;
	cin>>n;
	string rs;
	cin>>rs;
	string::iterator r_pos=rs.begin()+rs.find('.',0);
	rs.replace(r_pos,r_pos+1,"");
	int r=toInt(rs);
	init(n);

	map<pii,int> pia;
	REP(i,n){
		string x,y;
		cin>>x>>y;
		string::iterator x_pos=x.begin()+x.find('.',0);
		x.replace(x_pos,x_pos+1,"");
		string::iterator y_pos=y.begin()+y.find('.',0);
		y.replace(y_pos,y_pos+1,"");
		pii p=make_pair(toInt(x),toInt(y));
		pii index=make_pair(p.first/r,p.second/r);
		if(!EXIST(pia,index)){
			pia[index]=0;
		}
		pia[index]++;
	}
	int ans=n;
	vector<pii> ps;
	map<pii,int> index;
	for(map<pii,int>::iterator it=pia.begin();it!=pia.end();it++){
		ps.push_back(it->first);
		index[it->first]=ps.size()-1;
	}
	REP(i,ps.size()){
		pii key=ps[i];
		REP(d,5){
			pii nbr=make_pair(key.first+dx[d],key.second+dy[d]);
			if(d==0){
				ans-=pia[nbr]-1;
			}else{
				if(EXIST(pia,nbr)){
					if(!same(i,index[nbr])){
						ans--;
						unite(i,index[nbr]);
					}
				}
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 26792
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<string>
#include<string.h>
#include<functional>
using namespace std;

#define INF 1<<21
#define DIV 1000000007

typedef pair<int, int>P;

int w, h;
int sx,sy;
int ans;
char f[21][21];
int dx[] = { 1,-1,0,0 }, dy[] = { 0,0,1,-1 };

void rec(int x, int y,int cnt) {
  if (cnt >= ans)return;
  int nx, ny;
  for (int i = 0; i < 4; i++) {
	nx = x + dx[i];
	ny = y + dy[i];
	if (nx <= 0 || w < nx || ny <= 0 || h < ny || f[ny][nx] == '1')continue;

	while (1) {
	  if (f[ny][nx] == '3') {
		ans = cnt;
		return;
	  }
	  nx += dx[i];
	  ny += dy[i];
	  if (nx <= 0 || w < nx || ny <= 0 || h < ny)break;

	  if (f[ny][nx] == '1') {
		f[ny][nx] = '0';
		rec(nx - dx[i], ny - dy[i], cnt + 1);
		f[ny][nx] = '1';
		break;
	  }
	}
  }
}

int main() {
  while (cin>>w>>h,(w||h)) {
	for (int y = 1; y <= h; y++) {
	  for (int x = 1; x <= w; x++) {
		cin >> f[y][x];
		if (f[y][x] == '2') {
		  sx = x;
		  sy = y;
		}
	  }
	}
	ans = 11;
	rec(sx, sy, 1);
	if (ans > 10)ans = -1;
	cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3000
#pragma GCC optimize("O4")
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
//#define MOD (ll)(998244353)
#define MOD (ll)(1e9+7)
#define INF (1e17)
//#define int ll
#define EPS (1e-6)
using namespace std;
using ll=long long;
using pii=pair<int,int>;

int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) { return a/gcd(a,b)*b; }
int fpow(int b,int p){
	b%=MOD;
	int ans=1;
	while(p>0){
		if(p&1) ans=(ans*b)%MOD;
		p/=2;
		b=(b*b)%MOD;
	}
	return ans;
}

int res[15][15];

int32_t main() {
#ifdef LOCAL_TEST
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\input.in","r",stdin);
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\output.out","w",stdout);
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\error.out","w",stderr);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);

	//code...
	int n; cin>>n;
	For(i,0,n-1){
		int t; cin>>t;
		int x,y;
		while(t--){
			cin>>x>>y;
			x--;
			res[i][x]=y*2-1;
		}
	}
	int ans=0;
	For(msk,0,(1<<n)-1){
		bool ac=true;
		For(i,0,n-1){
			if(msk&(1<<i)){
				For(j,0,n-1){
					if(j==i) continue;
					if((msk&(1<<j))    && res[i][j]==-1){ac=false; break;}
					if((msk&(1<<j))==0 && res[i][j]==1 ){ac=false; break;}
				}
			}
			if(!ac) break;
		}
		if(ac) ans=max(ans,__builtin_popcount(msk));
	}
	cout<<ans<<"\n";
	return 0;
}


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

int main() {
  ll M, K;
  cin >> M >> K;
  if (K == 0) {
    for (ll i = 0; i < (1 << M); i++) cout << i << " " << i << " ";
    cout << endl;
    return 0;
  } else if (M >= 2) {
    for (ll i = 0; i < (1 << M); i++) {
      if ((i ^ K) < (1 << M)) {
        ll left = i, right = i ^ K;
        cout << left << " ";
        for (ll j = 0; j < (1 << M); j++) {
          if (j == left || j == right) continue;
          cout << j << " ";
        }
        cout << left << " " << right << " ";
        for (ll j = (1 << M) - 1; j >= 0; j--) {
          if (j == left || j == right) continue;
          cout << j << " ";
        }
        cout << right;
        return 0;
      }
    }
  }
  cout << -1 << endl;
}

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

int main(){
   int n, m;
   cin >> n >> m;
   int wa[n+1] = {};
   int ac[n+1] = {};
   int p;
   string s;
   for(int i=0; i<m; i++){
      cin >> p >> s;
      if(s=="WA" && ac[p]!=1) wa[p]++;
      if(s=="AC") ac[p]=1;
   }
   int acc = 0;
   int wac = 0;
   for(int i=1; i<n+1; i++){
      acc += ac[i];
      if(ac[i]==1) wac += wa[i];
   }
   cout << acc << " " << wac << endl;
}

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

H.append(10**9+7)
count = 0
ans = 0

for i in range(N):
    if H[i] >= H[i+1]:
        count += 1
    else:
        ans = max(ans,count)
        count = 0
        
print(ans)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const int MAX_N = 100005;
const ll INF = 1e15;

struct edge
{
	int to,cost;
};

vector<edge> G[MAX_N];
ll d[MAX_N];

void init()
{
	rep(i,MAX_N)
	{
		d[i] = INF;
	}
}

int main()
{
	init();
	int N,M;
	edge e;
	cin >> N >> M;
	rep(i,N-1)
	{
		e.to = i;
		e.cost = 0;
		G[i+1].push_back(e);
	}
	rep(i,M)
	{
		int l,r,c;
		cin >> l >> r >> c;
		e.to = r-1;
		e.cost = c;
		G[l-1].push_back(e);
	}

	priority_queue<P, vector<P>, greater<P> > Q;
	d[0] = 0;
	Q.push(P(0,0));
	while(!Q.empty())
	{
		P p = Q.top();
		Q.pop();
		int v = p.second;
		if (d[v] < p.first) continue;
		for (int i = 0; i < G[v].size(); ++i)
		{
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.cost)
			{
				d[e.to] = d[v] + e.cost;
				Q.push(P(d[e.to],e.to));
			}
		}
	}

	if (d[N-1] == INF) cout << "-1" << endl;
	else cout << d[N-1] << endl;
	return 0;
}

Measured memory_bytes: 8568
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <map>

typedef long long ll;
#define rep(i, b) for(int i = 0; i < b; i++)
#define repi(i, a, b) for(int i = a; i < b; i++)
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define MAX_V 1001
#define MAX_E 401
#define MOD 1000000007
#define EPS 1e-7
#define INF INT_MAX
#define PI  3.14159265358979323846264338327950288
inline ll toll(std::string s) { ll v; std::istringstream sin(s); sin >> v; return v; }
template<class T> inline std::string toString(T x) { std::ostringstream sout; sout << x; return sout.str(); }
using namespace std;
typedef pair<ll, ll> pll;

int main()
{
    ll H,W;
    cin >> H >> W;
    string s;
    repi(i,1,H + 1)
        repi(j,1,W + 1)
        {
            cin >> s;
            if (s == "snuke")
            {
                cout << char('A' + (j - 1)) << i << endl;
            }
        }
    
    return 0;
}

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

using namespace std;

int main() {
	int n;
	cin >> n;
	int m = 100;

	for (int i = 0; i < n; ++i) {
		int a;
		cin >> a;
		int d = 0;
		while (a % 2 == 0) {
			a /= 2;
			++d;
		}
		m = min(m, d);
	}
		cout << m << endl;

	return 0;
}

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

string s;

inline void work(){
	cin >> s;
	if (s.size() == 6 && s[2] == s[3] && s[4] == s[5]) puts("Yes");
	else puts("No");
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sqr(x) ((x)*(x))

using namespace std;
const double eps = 1e-7;
const int INF = (int)1e9 + 7;
const long long linf = (long long)1e16 + 7;
typedef long long ll;
const int MOD = (int)1e9 + 7;
const int MAXN =(int)1e5 + 7;

int main() {
    //int a, b, c, d, e, f;
    //cin >> a >> b >> c >> d >> e >> f;
    int n;
    cin >> n;
    vector <vector <int>> g(n, vector <int> (n));
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < n; ++j)
            cin >> g[i][j];
    vector <vector <int>> bad(n, vector <int> (n)), dist = g;
    bool ans = 1;
    for (int k = 0; k < n; ++k)
        for (int i = 0; i < n; ++i)
            for (int j = 0; j < n; ++j) {
                if (dist[i][j] == dist[i][k] + dist[k][j] && k != j && k != i)
                    bad[i][j] = 1;
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
                if (dist[i][j] != g[i][j])
                    ans = 0;
            }
    if (!ans)
        cout << -1;
    else {
        long long res = 0;
        for (int i = 0; i < n; ++i)
            for (int j = 0; j < n; ++j)
                if (!bad[i][j])
                    res += dist[i][j];
        cout << res / 2;
    }

    return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define lint long long int
using namespace std;

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

    vector<lint>x(n),y(n),z(n);

    lint i,j;
    for(i=0;i<n;i++)
        cin>>x[i]>>y[i]>>z[i];

    int a[]={1,1,1,1,-1,-1,-1,-1};
    int b[]={1,1,-1,-1,1,1,-1,-1};
    int c[]={1,-1,1,-1,1,-1,1,-1};

    lint ans=0;

    for(i=0;i<8;i++)
    {
        vector<lint >arr(n);
        for(j=0;j<n;j++)
        {
            arr[j]=x[j]*a[i] +y[j]*b[i] + z[j]*c[i] ;
        }
        sort(arr.begin(),arr.end());

        lint sum=0;
        for(j=0;j<m;j++)
            sum+=arr[j];

        ans=max(ans,sum);
        for(j;j<n;j++)
        {
            sum+=arr[j];
            sum-=arr[j-m];
            ans=max(ans,sum);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(ll i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
const ll INF = 1000000000000000;
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
#define DBG(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl
//DBG("","","","");

signed main(){
	IO_STREAM;
	ll N;	cin>>N;
	vl Y(N+1);
	rep(i,1,N+1){
		ll cnt=1;
		while(cnt*i<=N){
			Y[cnt*i]+=1;
			cnt++;
		}
	}
	ll ans=0;
	rep(i,1,N+1){
		ans+=Y[i]*i;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 81304
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 C = sc.nextInt();

		while (true) {
			if (A == B || C == 0) {
				System.out.println(C);
				break;
			}
			B++;
			C--;
		}
	}
}

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

class UnionFind {
    vector<int> data;
    ll num;
public:
    UnionFind(int size) : data(size, -1), num(size) { }
    bool unite(int x, int y) {//xとyの集合を統合する
        x = root(x); y = root(y);
        if (x != y) {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y]; data[y] = x;
        }
        num -= (x != y);
        return x != y;
    }
    bool findSet(int x, int y) {//xとyが同じ集合か返す
        return root(x) == root(y);
    }
    int root(int x) {//xのルートを返す
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    ll size(int x) {//xの集合のサイズを返す
        return -data[root(x)];
    }
    ll numSet() {//集合の数を返す
        return num;
    }
};


int main(){
  int n,m;
  cin>>n>>m;
  UnionFind uf(n);
  vector<int> p(n);
  rep(i,n){
    cin>>p[i];
    p[i]--;
  }
  rep(i,m){
    int x,y;
    cin>>x>>y;
    x--;y--;
    uf.unite(x,y);
  }
  int ans=0;
  rep(i,n){
    if(uf.findSet(i,p[i])) ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4052
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;
typedef string::const_iterator State;
class ParseError {};

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll INM = 114514;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll dx[4] = {1, 0, -1, 0};
ll dy[4] = {0, 1, 0, -1};

int main() {
	IOS();
	ll n;
	cin >> n;
	vector<ll> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	bool ok = true;
	for (int i = n - 1; i >= 1; i--) {
		if (a[i] < a[i - 1]) {
			if (a[i - 1] == a[i] + 1) {
				a[i - 1]--;
			} else {
				ok = false;
			}
		}
	}
	dump(ok ? "Yes" : "No");
	return 0;
}


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

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, inp, cnt1 = 0, cnt2 = 0, cnt3 = 0;
	double dp[305][305][305];
	// vector<vector<vector<double>>> dp (305, vector<vector<double>> (305 , vector<double> (305)));
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> inp;
		if (inp == 1)
			cnt1++;
		else if (inp == 2)
			cnt2++;
		else
			cnt3++;
	}
	dp[0][0][0] = 0;
	for (int k = 0; k <= cnt3; k++) {
		for (int j = 0; j <= cnt2 + cnt3; j++) {
			for (int i = 0; i <= cnt1 + cnt2 + cnt3; i++) {
				if (i == 0 && j == 0 && k == 0)
					continue;
				int s = i + j + k;
				if (k)
					dp[i][j][k] += 1.0 * k / s * dp[i][j+1][k-1];
				if (j)
					dp[i][j][k] += 1.0 * j / s * dp[i+1][j-1][k];
				if (i)
					dp[i][j][k] += 1.0 * i / s * dp[i-1][j][k];
				dp[i][j][k] += 1.0 * n / s;
			}
		}
	}
	printf("%.9f", dp[cnt1][cnt2][cnt3]);
}

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

int main(){
  int N, L;
  cin >> N >> L;
  vector<string> S(N);
  for (int i = 0; i < N; i++) {
    cin >> S.at(i);
  }
  sort(S.begin(),S.end());

  for (int i = 0; i < N; i++) {
    cout << S.at(i);
  }
  cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define sf1(a); scanf("%d",&a);
#define sf2(a,b); scanf("%d %d",&a, &b);
#define sf3(a,b,c); scanf("%d %d %d",&a, &b,&c);
#define sf4(a,b,c,d); scanf("%d %d %d %d",&a, &b,&c,&d);
#define pf1(a); printf("%d\n",a);
#define pf2(a,b); printf("%d %d\n",a,b);
#define pf3(a,b,c); printf("%d %d %d\n",a,b,c);
#define pf4(a,b,c,d); printf("%d %d %d %d\n",a,b,c,d);

using namespace std;

int main()
{
    string s,t;
    cin>>s>>t;
    map<char,int> ms,mt;
    if(s==t)
    {
        cout<<"Yes"<<endl;
        return 0;
    }
    for(int i=0;i<s.size();i++)
    {
        ms[s[i]]++;
        mt[t[i]]++;
    }
    vector<int> vs,vt;
    for(auto it=ms.begin();it!=ms.end();it++)
    {
        vs.push_back(it->second);
    }
    for(auto it=mt.begin();it!=mt.end();it++)
    {
        vt.push_back(it->second);
    }
    if(vs.size()!=vt.size())
    {
        cout<<"No"<<endl;
        return 0;
    }
    sort(vs.begin(),vs.end());
    sort(vt.begin(),vt.end());
    for(int i=0;i<vs.size();i++)
    {
        if(vs[i]!=vt[i])
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


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

using namespace std;
#define ll long long
#define ld long double

set<int> s;

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
    ll n, k;
    cin >> n >> k;
    int cnt = 0;
    while(n > 0) {
        n /= k;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256