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

int main(void)
{
    int N;
    cin >> N;
    int color[8];
    for(int i = 0; i < 8; i++)
    {
        color[i] = 0;
    }
    int over = 0;
    for (int i = 0; i < N; i++)
    {
        int a;
        cin >> a;
        if (1 <= a && a <= 399)
        {
            color[0] = 1;
        }
        else if(400 <= a && a <= 799)
        {
            color[1] = 1;
        }
        else if(800 <= a && a <= 1199)
        {
            color[2] = 1;
        }
        else if(1200 <= a && a <= 1599)
        {
            color[3] = 1;
        }
        else if(1600 <= a && a <= 1999)
        {
            color[4] = 1;
        }
        else if(2000 <= a && a <= 2399)
        {
            color[5] = 1;
        }
        else if(2400 <= a && a <= 2799)
        {
            color[6] = 1;
        }
        else if(2800 <= a && a <= 3199)
        {
            color[7] = 1;
        }
        else if(3200 <= a)
        {
            over++;
        }
    }
    int min = 0;
    for (int i = 0; i < 8; i++)
    {
        min += color[i];
    }
    if(min) cout << min << " " << min + over << endl;
    else cout << "1 " << over << endl;
    
}

Measured memory_bytes: 256
from collections import defaultdict

n = int(input())
a = list(map(int, input().split()))

ans = n
data = defaultdict(int)
for i in range(n):
    data[a[i]] += 1
    if data[a[i]] >= 2:
        ans -= 1
print(ans if ans % 2 == 1 else ans - 1)

Measured memory_bytes: 18656
#include<stdio.h>

int main(){
  int i,j,k,key,N,A[100];
  
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  
  for(k=0;k<N;k++){
    if(k>=1) printf(" ");
    printf("%d",A[k]);
  }
  printf("\n");
  
  for(i=1;i<N;i++){
    key=A[i];
    j=i-1;
    
    while(j>=0 && A[j]>key){
      A[j+1]=A[j];
      j=j-1;
    }
    A[j+1]=key;
    
    for(k=0;k<N;k++){
      if(k>=1) printf(" ");
      printf("%d",A[k]);
    }
    printf("\n");
  }
  
  return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
int main()
{
    int k,x;
    cin >> k >> x;
    rep(i, 2 * k - 1) cout << x - k + 1 + i << ' ';
    cout << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int n;
	int a;
	int min = 1000000;
	int max = -1000000;
	long long sum;
	sum = 0;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a;
		sum = sum + a;

		//最小値
		if (min > a)
		{
			min = a;
		}
		//最大値
		if (max < a)
		{
			max = a;
		}


	}
	cout << min << " " << max << " " << sum << endl;

	return 0;
}


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

using int64 = long long;

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

    static int F[110][10];
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 10; j++) {
            cin >> F[i][j];
        }
    }

    static int64 P[110][20];
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= 10; j++) {
            cin >> P[i][j];
        }
    }

    int64 ans = -(1LL << 50);
    for (int mask = 1; mask < (1 << 10); mask++) {
        int64 score = 0;
        for (int i = 0; i < N; i++) {
            int num = 0;
            for (int j = 0; j < 10; j++) {
                if (!((mask >> j) & 1))
                    continue;
                num += F[i][j];
            }
            score += P[i][num];
        }
        ans = max(ans, score);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [0] * n
b = 1
for i in range(n):
	a[i] = list(map(int, input().split()))
for i in range(n - 1):
	for j in range(i + 1, n):
		for k in range(4):
			t = a[i][0]
			a[i][0] = a[i][1]
			a[i][1] = a[i][5]
			a[i][5] = a[i][4]
			a[i][4] = t
			for u in range(4):
				v = a[i][1]
				a[i][1] = a[i][2]
				a[i][2] = a[i][4]
				a[i][4] = a[i][3]
				a[i][3] = v
				if a[i] == a[j]:
					b = 0
		for k in range(4):
			t = a[i][0]
			a[i][0] = a[i][2]
			a[i][2] = a[i][5]
			a[i][5] = a[i][3]
			a[i][3] = t
			for u in range(4):
				v = a[i][1]
				a[i][1] = a[i][2]
				a[i][2] = a[i][4]
				a[i][4] = a[i][3]
				a[i][3] = v
				if a[i] == a[j]:
					b = 0
if b:
	print("Yes")
else:
	print("No")


Measured memory_bytes: 5612
import math
import fractions
import copy
import numpy as np
def j(q):
    if q==1: print("Yes")
    elif q == 0:print("No")
    exit(0)
rem = pow(10,9)+7
"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def iprow():
    return [int(i) for i in input().split()]
def ips():
    return (int(i) for i in input().split())
def printrow(a):
    for i in a:
        print(i)
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

#n,m = ips()
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(m)]    #入力セット(整数改行あり)(2/2)
#a=[input() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#jの変数はしようできないので注意
#a.pop(0)は10^5あるときTLEしやすい!注意!抜くなら逆ソート!
a = []
for i in range(n):
    b = iprow()
    a.append([b[1],b[0]])
a.sort()
sumtime = 0
for i in range(n):
    sumtime += a[i][1]
    if sumtime > a[i][0]:
        j(0)
j(1)

Measured memory_bytes: 45644
import collections
N,C = map(int,input().split())
D = [list(map(int,input().split())) for i in range(C)]
c = [list(map(int,input().split())) for i in range(N)]
c0 = []; c1 = []; c2 = []
for x in range(N):
    for y in range(N):
        if (x+y)%3 == 0:
            c0.append(c[x][y])
        elif (x+y)%3 == 1:
            c1.append(c[x][y])
        else:
            c2.append(c[x][y])
cnt0 = collections.Counter(c0)
cnt1 = collections.Counter(c1)
cnt2 = collections.Counter(c2)
m = N*N*1000
for i in range(C):
    for j in range(C):
        for k in range(C):
            if i==j or j==k or k==i:
                s = N*N*1000
            else:
                s = 0
                for n in range(C):
                  s += D[n][i]*cnt0[n+1] + D[n][j]*cnt1[n+1] + D[n][k]*cnt2[n+1]
            if s < m:
                m = s
print(m)

Measured memory_bytes: 7920
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int main(void){
    int a, b, c; cin >> a >> b >> c;
  if(a+b >= c) cout << "Yes" << endl;
  else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const string EMP = " ";
const ll INF = 1LL<<60;
const ll MOD = 1000000007;

int main(){
  ull n; cin >> n;
  string ans = "";
  while(n){
    n--;
    char now = 'a' + n%26;
    ans += now;
    n /= 26;
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3628
N = int(input())
T,A = map(int, input().split())
*H, = map(int, input().split())

ans = 100000000
index = 0

for i in range(len(H)):
    temp = T-H[i]*0.006

    if abs(A-temp)<ans:
        ans = abs(A-temp)
        index = i


print(index+1)

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

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

  if ((N-7)%10==0) {
    cout << "Yes" << endl;
}
  else if((N/10-7)%10==0){
    cout<<"Yes"<<endl;
}
  else if((N/100-7)%10==0){
    cout<<"Yes"<<endl;
}
  else{
    cout<<"No"<<endl;
}
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int n; cin>>n;
	int x = n%10;
	if(x == 2 || x == 4 || x == 5 || x == 7 || x == 9){
		cout<<"hon"<<endl;
	}
	else if(x == 0 || x == 1 || x == 6 || x == 8 )
		cout<<"pon"<<endl;
	else
		cout<<"bon"<<endl;
	return 0;
}

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


def solve(x):
    ret=0
    if x==1:
        ret+=300000
    elif x==2:
        ret+=200000
    elif x==3:
        ret+=100000
    return ret

ans=0

ans+=solve(x)+solve(y)
if x==y==1:
    ans+=400000
print(ans)

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

using namespace std;
using ll = long long;

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

  int n, k;
  cin >> n >> k;

  if (k % 2 == 1) {
    ll cnt = 0;
    for (int a = 1; a <= n; a++) {
      if (a % k == 0)
        cnt++;
    }
    cout << cnt * cnt * cnt << endl;
    return 0;
  }

  ll cnt1 = 0;
  ll cnt2 = 0;
  for (int a = 1; a <= n; a++) {
    if (a % k == 0)
      cnt1++;
    if (a % k == k / 2) 
      cnt2++;
  }
  cout << cnt1 * cnt1 * cnt1 + cnt2 * cnt2 * cnt2 << endl;

  return 0;
}


Measured memory_bytes: 3652
X, Y = map(int,input().split())

flag = 0
for t in range(X + 1):
	for f in range(X + 1):
		if (2 * t + 4 * f == Y) and (t + f == X):
			flag = 1

if flag == 0:
	print("No")
else:
	print("Yes")


Measured memory_bytes: 9072
#include <bits/stdc++.h>
using namespace std;
typedef unsigned int INT;
typedef unsigned long long LONG;
typedef long long LL;
typedef pair<int, int> PII;
const int N = 1e5 + 10;
const int mod = 1e9 + 7;
#define FW freopen("data2.txt", "w", stdout);
//读入输出外挂，只适用于整数，使用时流同步打开，C语言不准关流
// getchar()<<cin(关流)<<scanf()<<cin
template <class T>
inline bool Read(T& ret)
{
    char c;
    int sgn;
    if (static_cast<void>(c = getchar()), c == EOF)
        return 0;
    while (c != '-' && (c < '0' || c > '9'))
        c = getchar();
    sgn = (c == '-') ? -1 : 1;
    ret = (c == '-') ? 0 : (c - '0');
    while (static_cast<void>(c = getchar()), c >= '0' && c <= '9')
        ret = ret * 10 + (c - '0');
    ret *= sgn;
    return 1;
}
//输出只能用于整数
template <class T>
inline void Write(T x)
{
    if (x < 0)
        putchar('-'), x = -x;
    if (x > 9)
        Write(x / 10);
    putchar(x % 10 + '0');
}

void slove(int quetion_num)
{
    int n;
    cin >> n;
    LL cur = 0, ans = 0, pre = 0;
    for (int i = 1; i <= n; ++i) {
        cin >> cur;
        if (i == 1) {
            pre = cur;
            continue;
        }
        if (pre > cur) {
            ans += (pre - cur);
            cur = pre;
        }
        pre = cur;
    }
    cout << ans << endl;
}
int main()
{
    int num = 1;
    // cin >> num;
    for (int i = 1; i <= num; ++i) {
        slove(num);
    }
    //system("pause");
    return 0;
}

Measured memory_bytes: 3552
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
String K=sc.next();
int length = K.length();
int N=sc.nextInt();
Set<String> set = new HashSet<>();

	for (int i = 1; i <= N; i++) {
           for (int j = 0; j <=  length- i; j++){
           		set.add(K.substring(j, j+i));
                
    		}
    	}
List<String> list = new ArrayList<>(set);
    Collections.sort(list);
    System.out.println(list.get(N-1));
}
}

Measured memory_bytes: 24604
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int k,n,h;
    cin>>n>>k;
    int arr[n];
    for(int i=0;i<n;i++){
        cin>>h;
        arr[i]=h;
    }
    sort(arr,arr+n);
    long long int m=10000000000;
    for(int i=0;i<=n-k;i++){
        int dif=arr[i+k-1]-arr[i];
        if(dif<m) m=dif;
    }
    cout<<m<<endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,l;
  cin >> n >> l;
  if (l>=0){
    cout << ((l+n-1) + l+1) * (n-1) /2 << endl;
  }
  else if (l+n-1<=0){
    cout << ((l+n-2) + l) * (n-1) / 2 << endl;
  }
  else{
    cout << ((l+n-1) + l) * n /2 << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args)
	{
		Scanner s=new Scanner(System.in);
		
		long p=1000000007;
		
		int n=s.nextInt();
		int m=s.nextInt();
		
		char[][] arr=new char[n][m];
		
		for(int i=0;i<n;i++)
		{
			String str=s.next();
			
			for(int j=0;j<str.length();j++)
			{
				arr[i][j]=str.charAt(j);
			}
		}
		
		long[][] dp=new long[n+1][m+1];
		
		dp[0][0]=1;
		
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<m;j++)
			{
				if(arr[i][j]!='#')
				{
					dp[i+1][j]=(dp[i+1][j]%p+dp[i][j]%p)%p;
					dp[i][j+1]=(dp[i][j+1]%p+dp[i][j]%p)%p;
				}
			}
		}
		
		System.out.println(dp[n-1][m-1]);
		
	}
	
}

Measured memory_bytes: 39144
from collections import defaultdict


def main():
    N, T = map(int, input().split())
    t_list = list(map(int, input().split()))
    ans = 0
    n = 0
    for t in t_list:
        if t >= n:
            ans += T
        else:
            ans += T - (n - t)
        n = t + T
    print(ans)


if __name__ == '__main__':
    main()


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

int main(){ 
  int n, m;
  cin >> n >> m;
  vector<P> edge(m);
  rep(i,m) {
    int a, b;
    cin >> a >> b;
    edge[i].first = b;
    edge[i].second = a;
  }
  sort(edge.begin(), edge.end());
  int res = 0;
  int pr = -1;
  for (int i = 0; i < m; i++) {
    if (pr <= edge[i].second) {
      pr = edge[i].first;
      res++;
    }
  }
  cout << res << endl;
  return 0;
} 

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n;
  cin >> n;
  vector<pair<ll,ll>> a(n);
  for(int i = 0;i < n;i++)cin >> a[i].first,a[i].second = i;
  sort(a.rbegin(),a.rend());
  ll ma = a[0].first;
  ll it = a[0].second;
  bool one = true;
  if(a[0].first == a[1].first)one = false;
  if(one){
    for(int i = 0;i < it;i++)cout << ma << endl;
    cout << a[1].first << endl;
    for(int i = it + 1;i < n;i++)cout << ma << endl;
  }
  else{
    for(int i = 0;i < n;i++)cout << ma << endl;
  }
}




Measured memory_bytes: 6420
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
void *wmem;
char memarr[96000000];
template<class T> inline void walloc1d(T **arr, int x, void **mem = &wmem){
  static int skip[16] = {0, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
  (*mem) = (void*)( ((char*)(*mem)) + skip[((unsigned long long)(*mem)) & 15] );
  (*arr)=(T*)(*mem);
  (*mem)=((*arr)+x);
}
template<class T1> void sortA_L(int N, T1 a[], void *mem = wmem){
  sort(a, a+N);
}
template<class T1, class T2> void sortA_L(int N, T1 a[], T2 b[], void *mem = wmem){
  int i;
  pair<T1, T2> *arr;
  walloc1d(&arr, N, &mem);
  for(i=(0);i<(N);i++){
    arr[i].first = a[i];
    arr[i].second = b[i];
  }
  sort(arr, arr+N);
  for(i=(0);i<(N);i++){
    a[i] = arr[i].first;
    b[i] = arr[i].second;
  }
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void rd(long long &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class S, class T> inline S chmin(S &a, T b){
  if(a>b){
    a=b;
  }
  return a;
}
int N;
long long X[100000];
long long L[100000];
int main(){
  int i;
  wmem = memarr;
  int res = 0;
  int mn;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=(0);Lj4PdHRW<(N);Lj4PdHRW++){
      rd(X[Lj4PdHRW]);
      rd(L[Lj4PdHRW]);
    }
  }
  for(i=(0);i<(N);i++){
    X[i] -= L[i];
  }
  for(i=(0);i<(N);i++){
    L[i] = X[i] + 2 * L[i];
  }
  sortA_L(N, X, L);
  mn = -4611686016279904256LL;
  for(i=(0);i<(N);i++){
    if(X[i] >= mn){
      res++;
      mn = L[i];
      continue;
    }
    chmin(mn, L[i]);
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20200116-1 [beta]

// --- original code ---
// int N; ll X[1d5], L[1d5];
// {
//   int res = 0, mn;
//   rd(N,(X,L)(N));
//   rep(i,N) X[i] -= L[i];
//   rep(i,N) L[i] = X[i] + 2 * L[i];
//   sortA(N, X, L);
//   mn = -ll_inf;
//   rep(i,N){
//     if(X[i] >= mn) res++, mn = L[i], continue;
//     mn <?= L[i];
//   }
//   wt(res);
// }


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);++i)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int gcd(int a,int b) { return b ? gcd(b,a%b) : a;}
int lcm(int a,int b) { return a/gcd(a,b)*b;}
void printb(unsigned int v) {
  unsigned int mask = (int)1 << (sizeof(v) * CHAR_BIT - 1);
  do putchar(mask & v ? '1' : '0');
  while (mask >>= 1);
}
void putb(unsigned int v) {putchar('0'), putchar('b'), printb(v), putchar('\n');}
#define ALL(W) (W).begin(),(W).end()

signed main(){
  string s;
  cin >> s;
  if(s=="Sunny") cout << "Cloudy" << endl;
  else if(s=="Rainy") cout << "Sunny" << endl;
  else if(s=="Cloudy") cout << "Rainy" << endl;
  return 0;
}


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

using namespace std;

using ll = long long;

int main() {
  int n, q; cin >> n >> q;
  vector<int> adj[n + 1];
  for (int i = 0; i < n - 1; i++) {
    int a, b; cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  
  vector<ll> lazy(n + 1, 0);
  while (q--) {
    int p, x; cin >> p >> x;
    lazy[p] += x;
  }
  
  vector<ll> val(n + 1, 0);
  function<void(int, int, ll)> dfs = [&](int u, int p, ll v) -> void {
    val[u] = lazy[u] + v;
    for (int x : adj[u]) {
      if (x == p) continue;
      dfs(x, u, v + lazy[u]);
    }
  };
  
  dfs(1, 0, 0);
  
  for (int i = 1; i <= n; i++)
    cout << val[i] << " ";
  cout << endl;
  
  return 0;
}

Measured memory_bytes: 35200
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let input: Vec<i32> = s.split_whitespace().map(|x| x.parse::<i32>().unwrap()).collect();

    let mut state =0;
    if (input[0]- input[2]).abs() <= input[3]{ state =1 }
    if (input[0]- input[1]).abs() <= input[3] &&
        (input[2]- input[1]).abs() <= input[3] { state =1 }

    let ans = vec!["No","Yes"];
    println!("{}",ans[state]);
}


Measured memory_bytes: 4352
#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<int> v(n);
	rep(i,n)cin>>v[i];
	sort(v.begin(),v.end());
	cout<<abs(v[0]-v[n-1])<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
        int a,b,c;
        cin>>a>>b>>c;
        int ans=0;
        ans=a+b+c;
        ans=ans+max(max(a,b),c)*10-max(max(a,b),c);
        cout<<ans<<endl;
        return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
const int mod = 1e9+7, A = 2e5+5;

int main()
{
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int n, x, y;
	cin >> n >> x >> y;
    vector<int> v[n + 1];
	v[x].pb(y), v[y].pb(x);
	for (int i = 1; i < n; i++)
		v[i].pb(i + 1), v[i + 1].pb(i);
	queue<int> q;
	int ans[n + 1][n + 1] = {};
	int level[n + 1];
	bool vis[n + 1];
	for (int i = 1; i <= n; i++)
	{
		while(!q.empty()) q.pop();
		for (int j = 1; j <= n; vis[j++] = 0);
		q.push(i), level[i] = 0;
		while(!q.empty())
		{
			int cur = q.front();
			q.pop();
			if (ans[min(i, cur)][max(i, cur)] == 0)
				ans[min(i, cur)][max(i, cur)] = level[cur];
			for (auto to : v[cur])
			{
				if (!vis[to])
				{
					vis[to] = 1, q.push(to);
					level[to] = level[cur] + 1;
				}
			}
		}
	}
	int freq[n] = {};
	for (int i = 1; i <= n; i++)
	{
		for (int j = i + 1; j <= n; j++)
			freq[ans[i][j]]++;
	}
	for (int i = 1; i < n; i++)
		cout << freq[i] << '\n';
	return 0;
}


Measured memory_bytes: 16000
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int n = sc.nextInt();
		int[] xArr = new int[x];
		int[] yArr = new int[y];
		int minX = Integer.MAX_VALUE;
		for (int i = 0; i < x; i++) {
			xArr[i] = sc.nextInt();
			minX = Math.min(xArr[i], minX);
		}
		int minY = Integer.MAX_VALUE;
		for (int i = 0; i < y; i++) {
			yArr[i] = sc.nextInt();
			minY = Math.min(yArr[i], minY);
		}
		int min = minX + minY;
		for (int i = 0; i < n; i++) {
			int iX = sc.nextInt();
			int iY = sc.nextInt();
			min = Math.min(min, xArr[iX-1] + yArr[iY-1] - sc.nextInt());
		}
		System.out.println(min);
	}
}


Measured memory_bytes: 132276
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto& p : a) cin >> p;
  int m;
  cin >> m;
  vector<int> b(m);
  for (auto& p : b) cin >> p;
  cout << includes(a.begin(), a.end(), b.begin(), b.end()) << endl;
  return 0;
}


Measured memory_bytes: 4408
#include<bits/stdc++.h>
 
 using namespace std;
 typedef long long ll;
 #define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
 #define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
 #define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
 #define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
 template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
 template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }
 
 
 int main() {
     int a, b, q; cin >> a >> b >> q;
     vector<ll> s(a);
     vector<ll> t(b);
     vector<ll> x(q);
     rep(i, a) cin >> s[i];
     rep(i, b) cin >> t[i];
     rep(i, q) cin >> x[i];
 
     // 昇順ソート
     sort(s.begin(), s.end());
     sort(t.begin(), t.end());
 
     rep(i, q) {
         ll ans = LONG_MAX;
 
         ll s_itr = upper_bound(s.begin(), s.end(), x[i]) - s.begin();
         ll t_itr = upper_bound(t.begin(), t.end(), x[i]) - t.begin();
         // 領域外アクセス対応
         if(s_itr == a) s_itr--;
         if(t_itr == b) t_itr--;
 
         rep(j, 2) rep(k, 2) {
             // 領域外アクセス対応
             ll s_tmp = max((ll)0, (s_itr-j));
             ll t_tmp = max((ll)0, (t_itr-k));
 
             ll tmp_a = abs(s[s_tmp] - x[i]) + abs(t[t_tmp]-s[s_tmp]);
             ll tmp_b = abs(t[t_tmp] - x[i]) + abs(s[s_tmp]-t[t_tmp]);
             chmin(ans, tmp_a);
             chmin(ans, tmp_b);
         }
 
         cout << ans << endl;
     }
     
     return 0;
 }
 

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

//long longのシフト演算には気をつけよう

const int INF = (1<<29);

int N, R;
int res;
int d[205][205];
int r[10];
bool used[205];

void dfs(int c, int las, int dist){
    if(c == R){
        if(res > dist) res = dist;
        return;
    }
    for(int i=1; i<=R; i++) if(!used[r[i]]){
        used[r[i]] = true;
        if(las == -1) dfs(c+1, i, 0);
        else dfs(c+1, i, dist+d[r[las]][r[i]]);
        used[r[i]] = false;
    }
}

void floyd(){
    for(int k=1; k<=N; k++){
        for(int i=1; i<=N; i++){
            if(d[i][k] == INF) continue;
            for(int j=1; j<=N; j++){
                if(d[k][j] == INF) continue;
                d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
            }
        }
    }
}

int main(){
    int M; cin >> N >> M >> R;
    for(int i=1; i<=R; i++) cin >> r[i];

    for(int i=1; i<=N; i++){
        for(int j=1; j<=N; j++) d[i][j] = ((i == j)? 0 : INF);
    }

    for(int i=0; i<M; i++){
        int a,b,c; cin >> a >> b >> c;
        d[a][b] = d[b][a] = c;
    }

    floyd();

    res = INF;
    dfs(0, -1, 0);
    cout << res << endl;
}

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

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;

typedef long long ll;
typedef long double ld;

void solve() {
	string s;
	cin >> s;
	int n = int(s.size());
	vector<int> counter(2019, 0);
	vector<int> newcounter(2019, 0);
	ll ans = 0;
	for (int i = n - 1; i >= 0; --i) {
		newcounter.assign(2019, 0);
		newcounter[0] = 1;
		if (i == n - 1) {
			counter = newcounter;
			continue;
		}
		for (int j = 0; j < 2019; ++j) {
			int newmod = (j * 10 + s[i + 1] - '0') % 2019;
			newcounter[j] += counter[newmod];
		}
		ans += newcounter[s[i] - '0'];
		counter = newcounter;
	}
	cout << ans << "\n";
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	solve();
	return 0;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE




signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int N, M, K;
  cin>>N>>M>>K;

  vector<Int> A(N), B(M);
  cin>>A;
  cin>>B;

  A.insert(A.begin(), 0);
  B.insert(B.begin(), 0);
  for(Int i=1;i<N+1;i++) A[i] = A[i-1] + A[i];
  for(Int i=1;i<M+1;i++) B[i] = B[i-1] + B[i];

  Int ans = 0;
  for(Int i=0;i<=N;i++){
    Int a = A[i];
    if(a > K) continue;
    Int j = upper_bound(B.begin(), B.end(), K-a) - B.begin() - 1;
    Int b = B[j];
    assert(a + b <= K);
    Max(ans, i + j);
  }

  cout<<ans<<endl;


  return 0;
}


Measured memory_bytes: 7924
#include <stdio.h>
 
#define MAX 100000
 
int main()
{
  int n, q;
  char s[MAX];
  int l[MAX], r[MAX];
 
  int i, j, count = 0, sum[MAX];
 
  scanf("%d%d", &n, &q);
  scanf("%s", s);
  for (i = 0; i < q; i++) {
    scanf("%d%d", &l[i], &r[i]);
  }

  sum[0] = 0;

  for (i = 1; i < n; i++) {
    if (s[i - 1] == 'A' && s[i] == 'C') {
      count++;
    }
    sum[i] = count;
  }
 
  for (i = 0; i < q; i++) {
    printf("%d\n", sum[r[i] - 1] - sum[l[i] - 1]);
  }
 
  return 0;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

int main(){
  int h, w, sx, sy, ex, ey;
  cin >> h >> w >> sx >> sy >> ex >> ey;
  sx--; sy--; ex--; ey--;

  string m[h];
  for(int i=0; i<h; ++i) cin >> m[i];

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

  int v[h][w];
  for(int i=0; i<h; ++i){
    for(int j=0; j<w; ++j) v[i][j] = -1;
  }
  v[sx][sy] = 0;

  queue<P> q, r;
  q.push(P(sx, sy));

  while(!q.empty() || !r.empty()){
    if(!q.empty()) {
      P p = q.front();
      q.pop();
      cx = p.first; cy = p.second;
      r.push(P(cx, cy));
      for(int i=0; i<4; ++i){
        int nx = cx+dx[i], ny = cy+dy[i];
        if(nx < 0 || nx >= h || ny < 0 || ny >= w) continue;
        if(m[nx][ny] == '#') continue;  
        if(v[nx][ny] == -1){
          q.push(P(nx, ny));
          v[nx][ny] = v[cx][cy];
        }
      }
    }else{
      P p = r.front();
      r.pop();
      cx = p.first; cy = p.second;
      for(int wx = cx-2; wx<cx+3; ++wx){
        for(int wy = cy-2; wy<cy+3; ++wy){
          if(wx < 0 || wx >= h || wy < 0 || wy >= w) continue;
          if(m[wx][wy] == '#') continue;  
          if(v[wx][wy] == -1 || v[wx][wy] > v[cx][cy]+1){
            q.push(P(wx, wy));
            v[wx][wy] = v[cx][cy]+1;
          }
        }
      }
    }
  }
  cout << v[ex][ey] << endl;
}

Measured memory_bytes: 9400
#include <iostream>
using namespace std;
int main() {
    int n, m, c;
    cin >> n >> m >> c;
    int b[m];
    for (int i=0; i<m; i++) {
        cin >> b[i];
    }
    int result = 0;
    for (int i=0; i<n; i++) {
        int sum = 0;
        for (int j=0; j<m; j++) {
            int a;
            cin >> a;
            sum += a*b[j];
        }
        if (sum+c > 0) {
            result++;
        }
    }
    cout << result << endl;
}

Measured memory_bytes: 3572
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), cout, ", ") << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, ostream &os = cout, string sep = " ")
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), os, ", ") << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, N);
    AIN(ll, A, N);
    bool ok = true;
    FOR(a, A)
    {
        ok &= (a & 1) or a % 3 == 0 or a % 5 == 0;
    }
    YES(ok, "APPROVED", "DENIED");
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	int a, b;
	cin >> a >> b;
	int ans = 0;
	for (int x = 2; x < 10; x++)
		for (int y = 2; y < 10; y++) {
			if (10 * x + y > b) continue;
			if (x * y > a) continue;
			ans++;
		}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N;
LL A[200000];

LL ans[200000];

void solve(){
	if(N%2==0){
		LL all_xor = 0;
		for(int i=0;i<N;i++) all_xor ^= A[i];
		for(int i=0;i<N;i++) ans[i] = A[i]^all_xor;
	}
}

int main(){
    cin >> N;
    for(int i=0;i<N;i++) cin >> A[i];

    solve();

    for(int i=0;i<N;i++) cout << ans[i] << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 6244
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvl vector<vector<ll>>
#define print(n) cout<<n<<endl
const int M=100010;
const int MOD=1000000007;
const int inf=1000000007;
const long long INF=1000000000000000007;
using ll=long long;
//int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};



int main(){
	int n;
	const int MAX=10010;
	while(1){
		int ans_1[MAX],ans_2[MAX],cnt=0,ans=0;
		cin>>n;
		if(n==0)break;
		string s;
		rep(i,0,n){
			cin>>s;
			ans_1[i]=(int)((s[0]-'0')*10+s[1]-'0')*3600+(int)((s[3]-'0')*10+s[4]-'0')*60+(int)((s[6]-'0')*10+s[7]-'0');
			cin>>s;
			ans_2[i]=(int)((s[0]-'0')*10+s[1]-'0')*3600+(int)((s[3]-'0')*10+s[4]-'0')*60+(int)((s[6]-'0')*10+s[7]-'0');
		}
		int a[90000]={};
		rep(i,0,n)a[ans_1[i]]++,a[ans_2[i]]--;
		rep(i,0,90000)if(a[i]!=0)cnt+=a[i],ans=max(ans,cnt);
		print(ans);
	}
	return 0;
}


Measured memory_bytes: 3528
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

const int N=1e6+5;
int a[N],b[N],n;
bool exists;

int C(int n,int m){
	if(n<m) return 0;
	if(n<=1) return 1;
	return C(n&1,m&1)&C(n>>1,m>>1);
}

int calc(int *a){
	int ans=0;
	for(int i=1;i<=n;i++) if(a[i]) ans^=C(n-1,i-1);
	return ans;
}

signed main(){
	read(n);
	for(int i=1,x;i<=n;i++){
		scanf("%1d",&x);x--;
		exists|=x==1;
		a[i]=x&1;
		b[i]=x>>1;
	}
	if(exists) write(calc(a));
	else write(calc(b)<<1);
}

Measured memory_bytes: 11460
#include <bits/stdc++.h>
using namespace std;
char s[1000002];
int dp[1000002][2];
int main(){
    scanf("%s", s+1);   
    int n = strlen(s+1);
    for(int i=1;i<=n;i++) s[i] -= '0';
    for(int i=0;i<=n+1;i++) dp[i][0] = dp[i][1] = 1e9;
    dp[n+1][0] = 0;
    for(int i=n;i>=1;i--){
        for(int j=0;j<=9;j++){
            for(int k=0;k<=1;k++){
                int d = s[i]+j+k;
                if(d >= 10) dp[i][1] = min(dp[i][1], dp[i+1][k] + j + d%10);
                else dp[i][0] = min(dp[i][0], dp[i+1][k] + j + d%10);
            }
        }
    }
    printf("%d\n", min(dp[1][0], dp[1][1]+1));
}

Measured memory_bytes: 9088
#include <stdio.h>

int main(void) {

  long x,n;
  scanf("%ld %ld", &x, &n);
  if (n == 0) {
    printf("%ld\n", x);
    return 0;
  }
  long list[102];
  for (long i = 0; i <= 101; i++) {
    list[i] = 0;
  }
  long p;
  for (long i = 0; i < n; i++) {
    scanf("%ld", &p);
    list[p] = 1;
  }
  for (long i = 0; ; i++) {
    if (list[x-i] == 0) {
      printf("%ld\n", x-i);
      return 0;
    }
    if (list[x+i] == 0) {
      printf("%ld\n", x+i);
      return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 1732
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdlib>
#include<cstdio>
#include<utility>
#include<list>
using namespace std;
int main(){
	int n; cin>>n;
	string S; cin>>S;
	string left;
	string right;
	int maxs=0;

	for(int i=0;i<n-1;i++){
		left = S.substr(0, i+1);
		right = S.substr(i+1, S.size());
		//cout << left<<" "<< right<<endl<<endl;
		char cntL[26] = {};
		char cntR[26] = {};
		for(int j=0;j<left.length();j++){
			cntL[left[j] - 'a']++;//left[j] == 'a' cntL[0]++;
		}
		for(int j=0;j<right.length();j++) {
			cntR[right[j] - 'a']++;
		}

		int tmp = 0;
		for(int j=0;j<26;j++){
			if(min(cntL[j], cntR[j])) tmp++;
		}
		maxs = max(maxs, tmp);
	}

	cout<< maxs <<endl;

	return 0;
}


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


using namespace std;


using ll = long long;


const ll MAX  = 51;

bool adj[MAX][MAX] = { 0 };
ll ord[MAX] = { 0 };
ll low[MAX] = { 0 };
bool visited[MAX] = { false };
ll t = 0;
ll ans = 0;
ll N, M;


void dfs(ll now, ll parent)
{
    visited[now] = true;
    ord[now] = t;
    low[now] = ord[now];
    t++;

    for (ll i = 1; i <= N; i++) {
        if (!adj[now][i])
            continue;

        if (!visited[i]) {
            dfs(i, now);
            low[now] = min(low[now], low[i]);
            if (ord[now] < low[i])
                ans++;
        } else if (i != parent) {
            low[now] = min(low[now], ord[i]);
        }
    }
}


int main()
{
    cin >> N >> M;
    for (ll i = 0; i < M; i++) {
        ll x, y;
        cin >> x >> y;
        adj[x][y] = adj[y][x] = true;
    }

    dfs(1, -1);

    cout << ans << endl;
}


Measured memory_bytes: 256
n=int(input())
box=list(map(int,input().split()))
count=box[0]

def gcd(x,y):
    while y:
        x,y=y,x%y
    return x

for i in range(1,n):
    count=(box[i]*count)//gcd(box[i],count)

point=0
count -=1

for i in box:point +=count%i

print(point)

Measured memory_bytes: 3316
import sys
from collections import deque
sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    H, W = map(int, input().split())
    grid = list(list(input()) for _ in range(H))

    que = deque([])
    maze = [[f_inf] * W for _ in range(H)]
    for h in range(H):
        for w in range(W):
            if grid[h][w] == "#":
                que.append([h, w])
                maze[h][w] = 0

    while que:
        h, w = que.popleft()
        for dh, dw in ((1, 0), (-1, 0), (0, 1), (0, -1)):
            next_h, next_w = h + dh, w + dw
            if next_h < 0 or next_h >= H or next_w < 0 or next_w >= W:
                continue
            if maze[next_h][next_w] > maze[h][w] + 1:
                maze[next_h][next_w] = maze[h][w] + 1
                que.append([next_h, next_w])

    res = 0
    for h in range(H):
        for w in range(W):
            res = max(res, maze[h][w])
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 217564
#include<cstdio>
#include<algorithm>
#include<cstdlib>
using namespace std;
typedef long long LL;
LL in[200005], sum[200005];

int main()
{
   int n; scanf("%d", &n);
   for(int i=1;i<=n;i++)
   {
      scanf("%lld", &in[i]);
      sum[i]=sum[i-1] + in[i];
   }

   LL ans=(LL)1e18;
   for(int i=1;i<n;i++)
   {
      LL x1=sum[i], x2=sum[n]-sum[i];
      ans=min(ans, abs(x1-x2));
   }
   printf("%lld\n", ans);
   return 0;
}

Measured memory_bytes: 3328
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;

void solve()
{
    int64_t N;
	std::cin >> N;

	if (N % 2 == 0) {
		std::cout << 0.5 << std::endl;
	} else {
		std::double_t ans;
		ans = (double)(N / 2 + 1) / (double)N;
		std::cout << ans << std::endl;
	}
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	solve();
}


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

int main()
{
	int a,b,c,d,n,count;
	
	while(cin >> n){
	count=0;
	
	for(a=0; a<=9; a++){
		for(b=0; b<=9; b++){
			for(c=0; c<=9; c++){
				for(d=0; d<=9; d++){
					if(a+b+c+d==n) count++;
				}
			}
		}
	}
	
	cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
using System;

class Program
{
    static void Main()
    {
            int h, m, s;
            int inp = int.Parse(Console.ReadLine());
            if (0 <= inp && inp <= 86400)
            {
                h = inp / 3600;
                inp = inp - h * 3600;
                m = inp / 60;
                inp = inp - m * 60;
                s = inp;
                Console.WriteLine("{0}:{1}:{2}", h, m, s);
            }
}
}


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

#define MOD (1000 * 1000 * 1000 + 7)
#define INF (1LL << 60)
#define pb push_back
#define po pop_back
#define fi first
#define se second

typedef long long ll;
typedef long double ld;

#define maxn 105
#define maxk 100005
int N, K;
int A[maxn];

int dp[maxk][2];

int solution(int s, int p) {
  if (s == K) {
    return (p + 1) % 2;
  }

  if (dp[s][p] != -1) {
    return dp[s][p];
  }

  dp[s][p] = (p + 1) % 2;
  for (int i = 0; i < N; ++i) {
    if (s + A[i] > K)
      break;
    if (solution(s + A[i], (p + 1) % 2) == p) {
      dp[s][p] = p;
    }
  }

  return dp[s][p];
}

int main() {

  scanf("%d%d", &N, &K);
  for (int i = 0; i < N; ++i)
    scanf("%d", A + i);

  memset(dp, -1, sizeof(dp));

  if(solution(0, 0)) {
      printf("Second\n");
  } else {
      printf("First\n");
  }

  return 0;
}

Measured memory_bytes: 8832
import Data.List

main = do
   [a, b] <- (map read).words <$> getLine
   let price = find (\n -> (n * 8 `div` 100) == a && (n * 1 `div` 10) == b ) [1..1000]
   if price == Nothing then print (-1)
   else let Just p = price in print p

Measured memory_bytes: 508
def main():
    N, Z, W = list(map(int, input().split(' ')))
    A = list(map(int, input().split(' ')))
    if N == 1:
        print(abs(A[0] - W))
    else:
        print(max([abs(A[-1] - W), abs(A[-2] - A[-1])]))


if __name__ == '__main__':
    main()

Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>

#define INF (1 << 28)

using namespace std;

string str[2000];

string crest[2];

int map[1001][1001][3];

int main(){
	
	char JOI[3] = {'J', 'O', 'I'};
	
	int M, N;
	
	cin >> M >> N;
	
	for(int i = 0; i < M; i++){
		cin >> str[i];
	}
	
	cin >> crest[0];
	cin >> crest[1];
	
	int ans = 0;
	
	for(int i = 0; i < M; i++){
		for(int j = 0; j < N; j++){
			for(int k = 0; k < 3; k++){
				map[i][j][k] = 0;
			}
		}
	}
	
	for(int i = 0; i < M - 1; i++){
		for(int j = 0; j < N - 1; j++){
			
			int count = 0;
			
			int x_not, y_not, x_crest, y_crest;
			
			for(int x = 0; x < 2; x++){
				for(int y = 0; y < 2; y++){
					if(crest[y][x] == str[i + y][j + x]){
						count++;
					}else{
						x_not = j + x;
						y_not = i + y;
						x_crest = x;
						y_crest = y;
					}
				}
			}
			
			if(count == 4){
				ans++;
				
				for(int x = 0; x < 2; x++){
					for(int y = 0; y < 2; y++){
						for(int k = 0; k < 3; k++){
							map[i + y][j + x][k]--;
						}
					}
				}
			}
			
			if(count == 3){
				for(int k = 0; k < 3; k++){
					if(JOI[k] == crest[y_crest][x_crest])
					map[y_not][x_not][k]++;
				}
			}
		}
	}
	
	int fix_max = 0;
	
	for(int k = 0; k < 3; k++){
		for(int i = 0; i < M; i++){
			for(int j = 0; j < N; j++){
				//cout << map[i][j][k] << " ";
				if(map[i][j][k] > fix_max){
					fix_max = map[i][j][k];
				}
			}
			//cout << endl;
		}
		//cout << endl;
	}
	
	cout << ans + fix_max << endl;
	
	return 0;
}

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

def solve(S):
    A = []
    for i in range(len(S)):
        if(S[i]=="0" or S[i]=="1"):
            A.append(S[i])
        elif(len(A)>0 and S[i]=="B"):
            A.pop()
    print("".join(A))
    
if __name__ == '__main__':
    S = input()
    
    solve(S)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const double INF = numeric_limits<double>::max();
int main()
{
    int N, T, A;
    cin >> N >> T >> A;
    vector<int> H( N );
    for( auto & x : H )
    {
        cin >> x;
    }
    double res = INF;
    int no{};
    REP( i, N )
    {
        double x = T - H[ i ] * 0.006;
        if( res > abs( A - x ) )
        {
            res = abs( A - x );
            no = i + 1;
        }
    }
    cout << no << endl;
    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<complex>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<deque>
#include<functional>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<sstream>
#include<string>
#include<vector>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
typedef long long ll;

using namespace std;

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

	int a, b;
	int ans = 0;
	cin >> a >> b;
	for (int i = a; i <= b; i++) {
		int c = i % 10, d = i / 10000;
		int e = i / 10 % 10, f = i / 1000 % 10;
		if (c == d && e == f)ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3644
#include <iostream>
using namespace std;   
int main()  
{ 
int x;
cin>>x;
int sum=0;
int a,b;
for(int i=1;i<=x;i++)
{
cin>>a>>b;
if(a>=b)sum+=a-b+1;
if(a<b)sum+=b-a+1;
}
cout<<sum;
system("pause");  
return 0;  
} 


Measured memory_bytes: 504
x, n = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
d = 0
loop{
    unless a.include?(x - d)
        puts x - d
        break
    end
    unless a.include?(x + d)
        puts x + d
        break
    end
    d += 1
}


Measured memory_bytes: 14408