akhauriyash/Code-Regression huggingface dataset:
from sys import stdin
from collections import deque

def read_graph(n):
    A = [ [-1]*(n+1) for _ in range(n+1) ]
    for _ in range(n):
        line = deque(stdin.readline().strip().split())
        u = line.popleft()
        line.popleft()
        for l, k in enumerate(line):
            if l % 2 == 0:
                v = k
            else:
                A[int(u)][int(v)] = int(k)
    return A

def dijkstra(n, A, s):
    color = [ 'WHITE' for i in range(n) ]
    d = [ float('inf') for i in range(n) ]
    d[s] = 0
    p = [-1] * n

    while True:
        mincost = float('inf')
        for i in range(n):
            if color[i] != 'BLACK' and d[i] < mincost:
                mincost = d[i]
                u = i

        if mincost == float('inf'):
            break

        color[u] = 'BLACK'

        for v in range(n):
            if color[v] != 'BLACK' and A[u][v] != -1:
                if d[u] + A[u][v] < d[v]:
                    d[v] = d[u] + A[u][v]
                    p[v] = u
                    color[v] = 'GRAY'

    return d

n = int(input())
A = read_graph(n)
for i, k in enumerate(dijkstra(n, A, 0)):
    print(i, k)


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

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

  std::vector<int> w(n);
  for (auto&& wi : w) std::cin >> wi;

  std::vector<int> cum(n);
  cum[0] = w[0];
  for (int i = 1; i < n; ++i) cum[i] = w[i] + cum[i-1];

  int min = cum[n-1];
  for (int i = 0; i < n; ++i) {
    const auto diff = std::abs(cum[n-1] - 2*cum[i]);
    if (min > diff) min = diff;
  }
  std::cout << min << std::endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class Main {

	static List<Long> list = new ArrayList<>();

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		dfs(0, n);

		long ans = 0;

		for (long l : list) {
			String s = String.valueOf(l);
			if (s.contains("3") && s.contains("5") && s.contains("7")) {
				ans++;
			}
		}

		System.out.println(ans);
	}

	static void dfs(long x, int n) {
		if (x > n) {
			return;
		}
		if (x != 0) {
			list.add(x);
		}
		dfs(10 * x + 3, n);
		dfs(10 * x + 5, n);
		dfs(10 * x + 7, n);
	}
}


Measured memory_bytes: 24832
from numpy import arctan, pi
a, b, x = list(map(int, input().split()))
if x > 0.5*a*a*b:
    print(arctan(2/a*(b-x/(a*a))) / (pi) * 180)
else:
    print(arctan(a*b*b/(2*x))/(pi)*180)

Measured memory_bytes: 12392
#include <bits/stdc++.h>
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

typedef tuple<ll, ll, ll> T;

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c;
    cin>>a>>b>>c;
    string ans="No";
    if(a+b==c) ans="Yes";
    if(a+c==b) ans="Yes";
    if(b+c==a) ans="Yes";
    cout<<ans<<endl;
}

Measured memory_bytes: 256
a = input()
b = len(a)
if a == a[::-1]:
  if a[:(b-1)//2] == a[:(b-1)//2][::-1] and a[(b+1)//2:] == a[(b+1)//2:][::-1]:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Measured memory_bytes: 3060
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
typedef long long ll;
const int mod= 1e+9+7;

int main() {
    int H,W; cin>>H>>W;
    vector<vector<char>>h(H,vector<char>(W));
    rep(i,H){
        rep(j,W)cin>>h[i][j];
    }
    int cnt;
    //cout<<endl;
    //
    rep(i,H){
        cnt=0;
        rep(j,W){
            if(h[i][j]=='.')cnt++;
            }
             if(cnt==W){
                rep(k,W){
                    h[i][k]=' ';
                }
        }
    }
    //
    int ww=W;
    rep(i,W){
        cnt=0;
        rep(j,H){
            if(h[j][i]=='.' || h[j][i]==' ')cnt++;
            }
             if(cnt==H){
                 ww--;
                rep(k,H){
                    h[k][i]=' ';
                }
        }
    }
    rep(i,H){
        cnt=0;
        rep(j,W){
            if(h[i][j]==' ')continue;
            cnt++;
            cout<<h[i][j];
            if(cnt==ww)cout<<endl;
        }
    }
}

Measured memory_bytes: 256
import numpy as np

def main():

        X, N = list(map(int, input().split()))
        P = list(map(int, input().split()))

        P = np.array(P)
        gap = P-X
        gap = list(gap)

        ans = X

        for i in range(200):
                temp = ((i+1)//2) * (-1)**(i)
                if temp not in gap:
                        ans = X+temp
                        break
        return ans

if __name__=="__main__":
        ans = main()
        print(ans)

Measured memory_bytes: 27188
def main():
    N = int(input())
    A = [int(a) for a in input().split()]
    minp = float('inf')
    for a in A:
        p = 0
        while a>0 and a % 2 == 0:
            p += 1
            a = a // 2
        minp = min(minp, p)
    return minp

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<double,double> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;
const LL INF=1<<30;




int main(){
    int n,d,x;
    cin >> n >> d >> x;
    int dp[100001];
    int p[n][n];
    for(int i=0;i<d;i++){
        for(int j=0;j<n;j++){
            cin >> p[i][j];
        }
    }
    int maxi=x;
    for(int i=0;i<d-1;i++){
        memset(dp,0,sizeof(dp));
        int tmp=0;
        for(int j=0;j<n;j++){
            for(int k=p[i][j];k<=maxi;k++){
                if(!dp[k-p[i][j]]&&k-p[i][j]!=0) continue;
                if(k-p[i][j]<0) continue;
                dp[k]=max(dp[k],dp[k-p[i][j]]+p[i+1][j]);
                tmp=max(dp[k]+maxi-k,tmp);
            }
        }
        maxi=max(maxi,tmp);
    }
    cout << maxi << endl;
    return 0;
}



Measured memory_bytes: 3500
#include <iostream>
#include <cmath>
#include <limits>

using namespace std;

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

	int res = 0;

	if (n != 0)
		res += n * (n - 1) / 2;
	
	if (m != 0)
		res += m * (m - 1) / 2;

	cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 999999999

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

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

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

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

    int len = s.length();
    int i = 0;
    while(i != len) {
        int x = 'z' - s[i] + 1;
        if(k < x || s[i] == 'a') i++;
        else {
            k -= x;
            s[i] = 'a';
            i++;
        }
    }
    s[i-1] = (char)(((int)s[i-1] + k - 97) % 26 + 97);
    cout << s << endl;
    return 0;
}

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

// typedef
// -----------------------------------------------------------------------------
typedef long long ll;
typedef long double ld;

// container util
// -----------------------------------------------------------------------------
#define ALL(c)  (c).begin(),(c).end()
#define SZ(c) ((ll)(c).size())
#define MAX(c) *max_element(ALL(c))
#define MIN(c) *min_element(ALL(c))
#define SORT(c) sort((c).begin(),(c).end())

// repetition
// -----------------------------------------------------------------------------
#define FOR(i, a, b) for(ll i= (a); i < (ll)(b); ++i)
#define REP(i, n) FOR(i, 0, n)

// constant
// -----------------------------------------------------------------------------
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

// debug
// -----------------------------------------------------------------------------
#define DUMP(x)  cerr << #x << " = " << (x) << endl


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    string S, T; cin >> S >> T;
    ll ans = 0;
    REP(i, S.length()) {
        if(S[i] != T[i]) {
            ans++;
        }
    }
    cout << ans << "\n";
}


Measured memory_bytes: 3784
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int a = scanner.nextInt();
    int b = scanner.nextInt();
    if (a <= 8 && b <= 8) {
      System.out.println("Yay!");
    } else {
      System.out.println(":(");
    }
  }
}

Measured memory_bytes: 21716
// https://atcoder.jp/contests/abcXXX/tasks/abcXXX_x

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pll = pair<ll, ll>;

static const ll INF = 1001001001;
static const ll LLINF = 1001001001001001001;
static const ll MOD = (ll)1e9 + 7;
static const double EPS = 1e-9;

#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define RANGE(i, m, n) for(ll i = (m); i <= (n); ++i)
#define RRANGE(i, m, n) for(ll i = (m); i >= (n); --i)
#define POSITIVE(x) (x)=((x) < 0) ? 0 : (x)

ll power(ll x, ll y) {
    ll ret = 1;
    while(y-- > 0) ret *= x;
    return ret;
}

ll gcd(ll a, ll b) {
    assert(a >= 0);
    assert(b >= 0);
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll extgcd(ll a, ll b, ll& x, ll& y) {
    x = 1; y = 0;
    assert(a >= 0);
    assert(b >= 0);
    if (b == 0) return a;
    ll X, Y;
    auto d = extgcd(b, a % b, X, Y);
    x = Y;
    y = X - (a / b) * Y;
    return d;
}

int run(istream& in, ostream& out) {
    ll X;
    in >> X;
    ll ans = 0;
    RANGE(A, -1000, 1000) {
        RANGE(B, -1000, 1000) {
            if (A*A*A*A*A - B*B*B*B*B == X) {
                out << A << " " << B << endl;
                return 0;
            }
        }
    }
    std::abort();
    return 0;
}

int main() {
    return run(cin, cout);
}


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

string s;

struct st{
    int c1,c2,mn1,mn2;
};
vector < st > L, R;

int main(){

    int j,i,n,c1,c2,mn1,mn2;
    cin>>n;
    for(i=1; i<=n; i++){
        cin>>s;
        c1=c2=mn1=mn2=0;
        for(j=0; j<s.size(); j++){
            if(s[j]=='(')c1++;
            else c1--;
            mn1=min(mn1,c1);
        }
        for(j=s.size()-1; j>=0; j--){
            if(s[j]==')')c2++;
            else c2--;
            mn2=min(mn2,c2);
        }
        if(c1>=0)L.push_back({c1,c2,mn1,mn2});
        else R.push_back({c1,c2,mn1,mn2});
    }
    sort(L.begin(),L.end(), [] (st a , st b){return a.mn1>b.mn1;});
    sort(R.begin(),R.end(), [] (st a , st b){return a.mn2<b.mn2;});

    int cnt=0;
    for(auto k:L){
        if(cnt+k.mn1<0){
            cout<<"No"<<endl;
            return 0;
        }
        cnt+=k.c1;
    }
    for(auto k:R){
        if(cnt+k.mn1<0){
            cout<<"No"<<endl;
            return 0;
        }
        cnt+=k.c1;
    }
    if(cnt)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;

    return 0;
}


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

#define FOR(i, j, k) for (int i = j; i < k; i++)
#define REP(i, j) FOR(i, 0, j)
#define RFOR(i, k, j) for (int i = k - 1; i >= j; i--)
#define RREP(i, j) RFOR(i, j, 0)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<pii> vpii;

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

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

template <typename T> istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec) is >> x; 
    return is;
}

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

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

    int ans = (b - a) / (a - 1) + 1;
    if ((b - a) % (a - 1) > 0) ans++;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
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();

        int[] arr = {a, b, c};
        Arrays.sort(arr);
        boolean result = arr[0] + arr[1] == arr[2];

        System.out.println(result ? "Yes" : "No");
    }
}


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

int main() {
  int M;
  cin >> M;
  int N=M;
  int n;
  while(N>0) {
    n+=N%10;
    N=N/10;
  }
  string ans="No";
  if(M%n==0) ans="Yes";
  cout << ans << endl;
  return 0;
}    

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

int main(){
  int A,B,K;
  cin >> A >> B >> K;
  int count=0;
  for(int i=100; i>=1; i--){
    if((A%i==0) && (B%i==0)){
      count++;
      if(count == K){
        cout << i << endl;
        break;
      }
    }
  }
}

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

int main(){
  std::ios::sync_with_stdio(false);
  int n, k, i;
  cin >> n;
  for(i = 0; i < n; ++i){
    cin >> k;
    if((k & 1)){
      puts("first");
      return 0;
    }
  }
  puts("second");
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define p push
#define ll long long
#define f first
#define s second
#define vi vector<int>
#define vll vector<long long>
#define all(vec) begin(vec), end(vec)
#define pii pair<int,int>
#define plli pair<ll,int>
#define pill pair<ill>
#define ft front()
#define bk back()
#define pf push_front
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
using namespace std;

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int x; cin >> x;
    cout << (x == 0 ? 1 : 0) << '\n';
    return 0;
}



Measured memory_bytes: 3552
#include <math.h>

#include <algorithm>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;

int main() {
  double a, b, x;
  cin >> a >> b >> x;
  double tan;
  if (x <= a * a * b / 2) {
    tan = 180.0 * atan(a * b * b / (2 * x)) / M_PI;
    cout << tan;
  } else {
    tan = 180.0 * atan(2 * (a * a * b - x) / (a * a * a)) / M_PI;
    cout << fixed << setprecision(10) << tan;
  }
  return 0;
}

Measured memory_bytes: 512
program distinct_or_not
  implicit none
  integer :: n, a(200000) = 0, i
  read(*,*) n
  read(*,*) a(1:n)
  call quick_sort(a(1:n))
  do i = 2, n
    if (a(i) /= a(i-1)) cycle
    write(*,'(a)') "NO"
    stop
  end do
  write(*,'(a)') "YES"
contains
  subroutine swap(a,b)
    integer, intent(inout) :: a, b
    a = xor(a,b)
    b = xor(a,b)
    a = xor(a,b)
  end
  recursive subroutine quick_sort(a)
    integer, intent(inout) :: a(:)
    integer :: n, l, r, m
    integer :: p
    n = size(a)
    l = 1
    r = n
    m = (n+1)/2
    p = a(l)+a(m)+a(r)-max(a(l),a(m),a(r))-min(a(l),a(m),a(r))
    do
      do while (a(l) < p)
        l = l+1
      end do
      do while (a(r) > p)
        r = r-1
      end do
      if (l >= r) exit
      call swap(a(l),a(r))
      l = l+1
      r = r-1
    end do
    if (l-1 > 1) call quick_sort(a(1:l-1))
    if (n > r+1) call quick_sort(a(r+1:n))
  end
end program distinct_or_not

Measured memory_bytes: 1536
import java.util.Scanner;

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

            int n = scanner.nextInt();
            if (n==0) break;
            scanner.nextLine();
            int countLunch = 0, countDinner = 0, countMidnight = 0;
            int countOkLunch = 0, countOkDinner = 0, countOkMidnight = 0;
            for (int i = 0; i < n; i++) {
                String s = scanner.nextLine();
                int h = Integer.parseInt(s.substring(0, 2));
                int m = Integer.parseInt(s.substring(3, 5));
                int m1 = Integer.parseInt(s.substring(6, 8));

                if (m1 < m) {
                    m1 += 60;
                }

                boolean checkShorter = m1 - m <= 8;
                if (11 <= h && h < 15) {
                    countLunch++;
                    if (checkShorter) {
                        countOkLunch++;
                    }
                } else if (18 <= h && h < 21) {
                    countDinner++;
                    if (checkShorter) {
                        countOkDinner++;
                    }
                } else if (21 <= h || h < 2) {
                    countMidnight++;
                    if (checkShorter) {
                        countOkMidnight++;
                    }
                }
            }


            if (countLunch == 0) {
                System.out.println("lunch no guest");
            } else {
                System.out.println("lunch " +  countOkLunch * 100 / countLunch);
            }
            if (countDinner == 0) {
                System.out.println("dinner no guest");
            } else {
                System.out.println("dinner " +  countOkDinner * 100 / countDinner);
            }

            if (countMidnight == 0) {
                System.out.println("midnight no guest");
            } else {
                System.out.println("midnight " +  countOkMidnight * 100 / countMidnight);
            }


        }
    }
}



Measured memory_bytes: 29704
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()

cnt = 0
flg = True

while flg:
	for i in range(N):
		if A[i]%2 == 0:
			A[i] //= 2
		else:
			flg = False
	if flg:
		cnt += 1

print(cnt) 

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

int main(void) {   
    int n, m;
    cin >> n >> m;
    vector<int> h(n);
    rep(i,n) cin >> h[i];

    vector<vector<int>> e(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        e[a].push_back(b);
        e[b].push_back(a);
    }

    int ans = 0;
    rep(i, n) {
        bool flag = true;
        for(auto nv: e[i]) {
            if(h[nv] >= h[i]) flag = false;
        }
        if(flag) ans++;
    }

    cout << ans << endl;
    return 0;
}

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

using namespace std;

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

  string w;
  cin >> w;
  unordered_map<char, int> count;
  for (size_t i = 0; i < w.size(); ++i) {
    count[w[i]]++;
  }
  for (auto& c : count) {
    if (c.second %2 != 0){
      cout <<"No\n";
      return 0;
    }
  }
  cout <<"Yes\n";
}


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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
   template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (a == 0) return 0; else if (b % 2 == 0) return (pow((a * a) % m, b / 2, m) % m); else return (pow((a * a) % m, b / 2, m) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

   ll dx[4]={1,0,-1,0};
   ll dy[4]={0,1,0,-1};
const ll MAX_N = 1000;
ll N;
ll T[MAX_N], A[MAX_N];

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

   ll t_temp = T[0], a_temp = A[0];
   REP(i, N){
      ll x = (t_temp + T[i] - 1) / T[i];
      ll y = (a_temp + A[i] - 1) / A[i];
      t_temp = T[i] * max(x, y);
      a_temp = A[i] * max(x, y);
   }
   cout << t_temp + a_temp << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

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

    int A, B, C;
    cin >> A >> B >> C;
    if(A+B >= C){
        cout << "Yes" << "\n";
    }else{
        cout << "No" << "\n";
    }
    return 0;
}

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

int main() {
    int n;
    scanf("%d", &n);
    int xs[n];
    int as[n];
    for (int i = 0; i < n; i++) {
        scanf("%d", &xs[i]);
        as[i] = xs[i];
    }
    sort(as, as + n);
    int fm = as[n / 2 - 1];
    int lm = as[n / 2];
    for (int x : xs) {
        printf("%d\n", (x <= fm) ? lm : fm);

    }
    return 0;
}



Measured memory_bytes: 3712
#include<bits/stdc++.h>
#define endl '\n'
#define ll long long
using namespace std;
ll n, k;
vector<ll> dis;
ll sum = 0;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> k >> n;
    dis.resize(n);
    ll lst, now;
    cin >> lst;
    int one = lst;
    bool flag = false;
    if(lst == 0){
        flag = true;
    }
    for(int i = 1; i < n; i++){
        cin >> now;
        dis[i-1] = now - lst;
        lst = now;
    }
    if(flag){
        dis[n-1] = k - now;
    } else {
        dis[n-1] = k - now + one;
    }
    sort(dis.begin(),dis.end());
    for(int i = 0; i <= n - 2; i++){
        sum += dis[i];
    }
    cout << sum;
    return 0;
}

Measured memory_bytes: 1792
n = int(input())
for i in range(n):
    a,b,c = map(int,input().split())
    if a>b:
        a,b=b,a
    if b>c:
        b,c=c,b
    if a>b:
        a,b=b,a
    if(a**2 + b**2 == c**2):
        print('YES')
    else:
        print('NO')


Measured memory_bytes: 5596
x, y = gets.split.map(&:to_i)
group = [1, 3, 5, 7, 8, 10, 12]

if group.include? x
  puts group.include?(y) ? 'Yes' : 'No'
elsif x == 2
  puts y == 2 ? 'Yes' : 'No'
else
  puts [4, 6, 9, 11].include?(y) ? 'Yes' : 'No'
end

Measured memory_bytes: 1788
x,n = map(int, input().split())
p = list(map(int, input().split()))

up = x
down = x
ans = 0

while ans == 0:
    if p.count(down) == 0:
        ans = down
        break
    elif p.count(up) == 0:
        ans = up
        break
    else:
        up += 1
        down -= 1

print(ans)

Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int n;
	cin >> n;
	ll arr[n + 5];
	ll mini = 1e16, maxi = -1e16;
	int idxmin = -1, idxmax = -1;
	for (int i = 1; i <= n; i++)
	{
		cin >> arr[i];
		if (maxi < arr[i])
			maxi = arr[i], idxmax = i;
		if (mini > arr[i])
			mini = arr[i], idxmin = i;
	}
	vector<pair<int, int> > v;
	if (mini < 0 && maxi > 0)
	{
		ll tmp, idx;
		if (abs(maxi) >= abs(mini))
		{
			tmp = maxi;
			idx = idxmax;
		}
		else
		{
			tmp = mini;
			idx = idxmin;
		}
		maxi = -1e16;
		mini = 1e16;
		for (int i = 1; i <= n; i++)
		{
			arr[i] += tmp;
			v.push_back({idx,i});
			maxi = max(maxi,arr[i]);
			mini = min(mini,arr[i]);
		}
	}
	if (maxi >= 0 && mini >= 0)
	{
		for (int i = 2; i <= n; i++)
			v.push_back({ i - 1, i });
	}
	else if(maxi <= 0 && mini <= 0)
	{
		for(int i = n-1 ; i >= 1 ; i--)
			v.push_back({i+1,i});
	}
	else assert(0);
	cout << v.size() << endl;
	for(int i = 0 ; i < v.size() ; i++)
		cout << v[i].first << " " << v[i].second << endl;
}


Measured memory_bytes: 256
package main

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

func newScanner() *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	return scanner
}

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

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

var sc = newScanner()

func main() {
	x, y, a, b, c := scanInt(), scanInt(), scanInt(), scanInt(), scanInt()
	p := scanInts(a)
	q := scanInts(b)
	r := scanInts(c)
	p = append(p, math.MaxInt32)
	q = append(q, math.MaxInt32)
	r = append(r, 0)
	sort.Sort(sort.Reverse(sort.IntSlice(p)))
	sort.Sort(sort.Reverse(sort.IntSlice(q)))
	sort.Sort(sort.Reverse(sort.IntSlice(r)))

	ans := int64(0)
	for i := 1; i <= x; i++ {
		ans += int64(p[i])
	}
	for i := 1; i <= y; i++ {
		ans += int64(q[i])
	}

	for x > 0 || y > 0 {
		if p[x] >= r[0] && q[y] >= r[0] {
			break
		}
		ans += int64(r[0])
		r = r[1:]
		if p[x] < q[y] {
			ans -= int64(p[x])
			x--
		} else {
			ans -= int64(q[y])
			y--
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 9088
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const ll INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a>b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////


int main() {
	int n, m; cin >> n >> m;
	bool key[100010];
	int wcnt[100010];
	REP(i, 100010) {
		key[i] = false;
		wcnt[i] = 0;
	}
	int acnt = 0;
	int Wcnt = 0;
	REP(i, m) {
		int p;
		p--;
		string s;
		cin >> p >> s;
		if (s == "AC") {
			key[p] = true;
		}
		else {
			if (!key[p]) {
				wcnt[p]++;
			}
		}
	}
	REP(i, 100010) {
		if (key[i]) {
			acnt++;
			Wcnt += wcnt[i];
		}
	}
	cout << acnt << " " << Wcnt << endl;
	return 0;
}


Measured memory_bytes: 768
#include <stdio.h>
#include <stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define min(p,q)((p)<(q)?(p):(q))


//辺の情報を個別に持つタイプ
typedef struct edge{ll s,g;}E;
typedef struct graph{
	int vcnt,ecnt;
	E  e[30010];//適宜変える(ecnt)
	int id[10010];//適宜変える(vcnt)
}G;
G g;

int esort(const void*a,const void*b){
	E*p=(E*)a,*q=(E*)b;
	if((*p).s<(*q).s)return -1;
	if((*p).s>(*q).s)return  1;
	if((*p).g<(*q).g)return -1;
	return 1;
}

void readgraph(){
	//適宜変える
	ll n,m;
	scanf("%lld%lld",&n,&m);
	rep(i,0,m){
		ll x,y;
		scanf("%lld%lld",&x,&y);
		g.e[i].s=x;
		g.e[i].g=y;
	}
	g.vcnt=n;
	g.ecnt=m;
	qsort(g.e,g.ecnt,sizeof(E),esort);

	int p=0;
	rep(i,0,g.vcnt){
		while(p<g.ecnt&&g.e[p].s<i)p++;
		g.id[i]=p;
	}
	g.id[g.vcnt]=g.ecnt;//番兵
}

//強連結成分分解O(V)
//*
#define VCNT 10010
int SCC[VCNT],SCCcnt;//SCC[i]=頂点iが属する強連結成分の番号
int SCCi[VCNT],SCCidx[VCNT];//SCCi[SCCidx[i]:SCCidx[i+1]]=強連結成分iに属する頂点の番号
int adv[VCNT],back[VCNT];
int sccs[VCNT],sccscnt;
int isin[VCNT],scct;
#undef VCNT
void sccdfs(int v){
	adv[v]=back[v]=++scct;
	sccs[sccscnt++]=v;
	isin[v]=1;
	rep(i,g.id[v],g.id[v+1]){
		int u=g.e[i].g;
		if(isin[u]!=2){
			if(isin[u]==0)sccdfs(u);
			back[v]=min(back[v],back[u]);
		}
	}
	if(back[v]==adv[v]){
		int u;
		do{
			u=sccs[--sccscnt];
			isin[u]=2;
			SCC[u]=SCCcnt;
		}while(u!=v);
		SCCcnt++;
	}
}
int sccc(const void*p,const void*q){
	if(SCC[*(int*)p]<SCC[*(int*)q])return -1;
	if(SCC[*(int*)p]>SCC[*(int*)q])return 1;
	if(*(int*)p<*(int*)q)return -1;
	return 1;
}
void scc(){
	SCCcnt=0;
	rep(i,0,g.vcnt)isin[i]=adv[i]=0;
	rep(i,0,g.vcnt)if(!adv[i])sccdfs(i);
	rep(i,0,g.vcnt)SCCi[i]=i;
	qsort(SCCi,g.vcnt,sizeof(int),sccc);

	SCCidx[0]=0;
	SCCidx[SCCcnt]=g.vcnt;
	rep(i,1,g.vcnt)if(SCC[SCCi[i-1]]!=SCC[SCCi[i]])SCCidx[SCC[SCCi[i]]]=i;
}
//*/

int main(){
	readgraph();
	scc();
	int q;
	scanf("%d",&q);
	while(q--){
		int x,y;
		scanf("%d%d",&x,&y);
		printf("%d\n",SCC[x]==SCC[y]);
	}
}


Measured memory_bytes: 3000
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    int weight[] = {48, 51, 54, 57, 60, 64, 69, 75, 81, 91};
    string name[] = {"light fly", "fly", "bantam", "feather", "light", "light welter", "welter", "light middle", "middle", "light heavy", "heavy"};

    for(;;){
        double n;
        if(!(cin >> n))
            return 0;

        int i = lower_bound(weight, weight+10, n) - weight;
        cout << name[i] << endl;
    }
}

Measured memory_bytes: 0
N = int(input())

h = [1]

t = []
i = 1
while True:
  t.append(6**i)
  i += 1
  if t[-1]>10000:
    break
h.extend(t)

t = []
i = 1
while True:
  t.append(9**i)
  i += 1
  if t[-1]>10000:
    break
h.extend(t)

h.sort()

DP = []
DP.append((0, 0))

hlen = len(h)
for i in range(1,N+1):
  m = 999999
  p = 0
  for j in range(hlen):
    if i-h[j]<0:
      break
    else:
      if m>DP[i-h[j]][0] + 1:
        m = DP[i-h[j]][0] + 1
        p = h[j] + DP[i-h[j]][0]
  DP.append((m, p))  
print(DP[N][0])

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

int main()
{
    int n,ans=0;
    string s;
    cin>>n>>s;
    for(int i=0;i<n-2;i++) ans += s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C';
    cout<<ans;
}

Measured memory_bytes: 3560
def divisor(x):
  i=1
  table = []
  while i * i <= x:
    if x%i == 0:
      table.append(i)
      table.append(x//i)
    i += 1
  table = list(set(table))
  return table

n=int(input())

ans=0
for i in range(1,n+1,2):
  cnt = len(divisor(i))
  if cnt == 8:
    ans += 1

print(ans)   

Measured memory_bytes: 3060
n = int(input())
s = input()


def walk(s):
    """
        Assume that
            up ... '('
            down ... ')'
            start with height 0
            record lowest, endsup.
    """
    height = 0
    lowest = 0
    for x in s:
        if x == '(':
            height += 1
        elif x == ')':
            height -= 1
            lowest = min(height, lowest)
        else:
            pass
    return height, lowest

def inserter(s, height, lowest):
    return '(' * abs(lowest) + s + ')' * (height- lowest)

h, low = walk(s)
print(inserter(s, h, low))




Measured memory_bytes: 3060
from collections import defaultdict
n = int(input())
mod = 10**9 + 7
f = defaultdict(int)

def fctr1(n):
    c = 0
    r = int(n**0.5)
    for i in range(2, r+2):
        while n % i == 0:
            c += 1
            n = n//i
        if c != 0:
            f[i] += c
            c = 0
    if n != 1:
        f[n] += 1
    return f


for i in range(1, n+1):
    f = fctr1(i)

ans = 1
for v in f.values():
    ans = ans * (v+1) % mod
print(ans)





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

using namespace std;

typedef long long ll;

struct Union_Find {
    //各要素が属する集合の代表(根)を管理する
    //もし、要素xが根であればdata[x]は負の値を取り、-data[x]はxが属する集合の大きさに等しい
    vector<int> data;
    
    Union_Find(int size) : data(size, -1) {}
    bool Union(int x, int y) {
        x = Find(x);
        y = Find(y);
        bool is_union = (x != y);
        if (is_union) {
            if (data[x] > data[y]) swap(x, y);
            data[x] += data[y];
            data[y] = x;
        }
        return is_union;
    }
    int Find(int x) {
        if (data[x] < 0) { //要素xが根である
            return x;
        } else {
            data[x] = Find(data[x]); //data[x]がxの属する集合の根でない場合、根になるよう更新される
            return data[x];
        }
    }
    bool same(int x, int y) {
        return Find(x) == Find(y);
    }
    int size(int x) {
        return -data[Find(x)];
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> index(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        index[a[i] - 1] = i;
    }
    Union_Find uf(n);
    ll ans = n;
    for (int i = n - 1; i > 0; i--) {
        int idx = index[i - 1];
        int l = 1, r = 1;
        if (idx != 0 && a[idx - 1] > i) {
            l += uf.size(idx - 1);
            uf.Union(idx, idx - 1);
        }
        if (idx != n - 1 && a[idx + 1] > i) {
            r += uf.size(idx + 1);
            uf.Union(idx, idx + 1);
        }
        ans += (ll)i * l * r;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 2560
import sys
input = lambda: sys.stdin.readline().rstrip()

N, M = map(int, input().split())

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

seen = set()
checked = set()
for i in range(M):
    a, b = map(int, input().split())
    if H[a-1] < H[b-1]:
        checked.add(a)
    elif H[a-1] > H[b-1]:
        checked.add(b)   
    else:
        checked.add(a)
        checked.add(b)    
    seen.add((a,b))
print(N-len(checked))

Measured memory_bytes: 94644
#include <bits/stdc++.h>
using namespace std;
#define scd(t) scanf("%d",&t)
#define scld(t) scanf("%ld",&t)
#define sclld(t) scanf("%lld",&t)
#define scc(t) scanf("%c",&t)
#define scs(t) scanf("%s",t)
#define scf(t) scanf("%f",&t)
#define sclf(t) scanf("%lf",&t)
#define MEM(a, b) memset(a, (b), sizeof(a))
#define ffor(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define rfor(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define rep(i, j) ffor(i, 0, j, 1)
#define rrep(i, j) rfor(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define mp make_pair
#define pb push_back
//#define f first
//#define s second
#define inf (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
#define trace1(x)                     cout <<#x<<": "<<x<< endl;
#define trace2(x, y)                 cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)              cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)           cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)        cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;
const double pi=acos(-1.0);
typedef pair<long long int,long long int> pii;
typedef long long ll;
typedef vector<long long int> vi;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef map<long long int,long long int> mpii;
typedef set<long long int> sei;
typedef multiset<long long int> msei;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
ll dp[101][100001];
ll n;
ll a[101];
ll find(ll n,ll k)
{
    //trace2(n,k)
    if(dp[n][k]!=-1)
    return dp[n][k];
    ll pos=0;
    for(ll i=1;i<=n;i++)
    {
        if(a[i]<=k)
        {
            //trace3(i,a[i],k)
            ll tp=find(n,k-a[i]);
            if(tp==0)
            pos=1;
        }
    }
    dp[n][k]=pos;
    return dp[n][k];
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    ll i,j,m,k;
    cin>>n>>k;
    for(i=1;i<=n;i++)
    cin>>a[i];
    memset(dp,-1,sizeof(dp));
    find(n,k);
    if(dp[n][k]==1)
    cout<<"First";
    else
    cout<<"Second";
    return 0;
}

Measured memory_bytes: 83840
//
//  main.cpp
//  cf
//
//  Created by Dong Truong on 6/3/19.
//  Copyright © 2019 Dong Truong. All rights reserved.
//

#include <iostream>
#include <fstream>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>

using namespace std;
#define maxn 1000001

int n,a,b,c,d;string s;

void nhap()
{
    cin>>n>>a>>b>>c>>d>>s;
    --a;--b;--c;--d;
    bool kt=true,kt1=true,kt2=false;
    for (int i=a;i<c;++i)
        if (s[i]=='#' && s[i+1]=='#') kt=false;
    for (int i=b;i<d;++i)
        if (s[i]=='#' && s[i+1]=='#') kt1=false;
    if (c>d)
    {
        for (int i=b-1;i<d;++i)
            if (s[i]=='.' && s[i+1]=='.' && s[i+2]=='.')
                kt2=true;
        if (kt1==true && kt2==true && kt==true)
            cout<<"Yes";
        else cout<<"No";
    }
    else
        if (kt==true && kt1==true)
            cout<<"Yes";
        else cout<<"No";
}
int main(int argc, const char * argv[]) {
   // freopen("a.inp","r",stdin);
    nhap();
    return 0;
}


Measured memory_bytes: 640
import scala.io.StdIn.readLine
import scala.io.StdIn.readInt

object Main extends App {
    val k = readLine.toInt
    val ab = readLine.split(" ").map(x => x.toInt);
    val a = ab(0)
    val b = ab(1)
    if((a-1)/k < b/k) print("OK");
    else print("NG")

}

Measured memory_bytes: 54728
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;

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

int dfs( P edge, int cnt, int node );

vector< int > graph[55];

bool visit[55];
int n, m;

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

    cin >> n >> m;
    P edge[55];

    for( int i = 0; i < m; ++i ) {
        int a, b;
        cin >> a >> b;
        graph[a].pb( b );
        graph[b].pb( a );
        edge[i] = MP( a, b );
    
    }
    
    int ans = 0;
    for( int i = 0; i < m; ++i ) {
        for( int i = 1; i < 53; ++i ) visit[i] = false;
        
        visit[1] = true;
        int cnt = dfs( edge[i], 1, 1 );
        if( cnt != n ) ++ans;
    }

    cout << ans << endl;

    return 0;
}

int dfs( P edge, int cnt, int node )
{
    if( cnt == n ) return cnt;
    
    for( int i = 0; i < graph[node].size(); ++i ) {
        if( edge.F == node && edge.S == graph[node][i] ||
                edge.F == graph[node][i] && edge.S == node ) {
            continue;
        } else if( !visit[graph[node][i]] ){
            visit[graph[node][i]] = true;
            cnt = dfs( edge, cnt + 1, graph[node][i] );
            if( cnt == n ) return cnt;
        }
        
    }

    return cnt;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var N, K int
	fmt.Scanf("%d %d", &N, &K)

	as := make([]int, N)
	for i := range as {
		fmt.Scan(&as[i])
		as[i]--
	}

	var count int
	m := make(map[int]int)
	m[0] = 0
	ts := make([]int, 0)
	ts = append(ts, 0)

	for count < K {
		last := ts[len(ts)-1]
		next := as[last]
		if p, ok := m[next]; ok {
			cycle := count - p + 1
			offset := (K - p) % cycle
			fmt.Println(ts[p+offset] + 1)
			return
		}
		count++
		m[next] = count
		ts = append(ts, next)
	}
	fmt.Println(ts[len(ts)-1] + 1)
}


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

int main(){
	int train;
	vector<int> dt;
	
	while(cin >>train){
		if(train){
			dt.push_back(train);
		} else{
			cout <<dt.back()<<endl;
			dt.pop_back();
		}
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

string divide[4] = {"dream", "dreamer", "erase", "eraser"};

int main(){
  string S;
  cin >> S;

  reverse(S.begin(), S.end());
  for(int i = 0; i < 4; ++i) reverse(divide[i].begin(), divide[i].end());

  bool can = true;
  for(int i = 0; i < S.size();){
    bool can2 = false;
    for(int j = 0; j < 4; ++j){
      string d = divide[j];
      if(S.substr(i, d.size()) == d){
        can2 = true;
        i += d.size();
      }
    }
    if(!can2){
      can = false;
      break;
    }
  }

  if(can) cout << "YES" << endl;
  else cout << "NO" << endl;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

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

void Main()
{
	int A, B, M;
  	cin >> A >> B >> M;
  	vi a(A), b(B);
  	rep(i,A) cin >> a[i];
  	rep(i,B) cin >> b[i];
  
  	int x, y, c;
  	int mn = INT_MAX;
  	
  	rep(i,M) {
		cin >> x >> y >> c;
      	x--; y--;
      	mn = min(mn, a[x]+b[y]-c);
    }
	
  	sort(all(a));
  	sort(all(b));
  	mn = min(mn, a[0]+b[0]);
  
  	cout << mn << endl;
	return;
}

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

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

int n, mn, c[55][150];
string s;
int main()
{
	int i, j;
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> s;
		for (j = 0; j < s.size(); j++) c[i][s[j]]++;
	}
	for (i = 'a'; i <= 'z'; i++) {
		for (j = 0, mn = 1e9; j < n; j++) mn = min(mn, c[j][i]);
		while (mn--) printf("%c", i);
	}
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	char[][] map;
	int h, w;
	char c;
	
	void run() {
		Scanner scan = new Scanner(System.in);
		while (true) {
			h = scan.nextInt();
			w = scan.nextInt();
			if (w + h == 0) break;
			map = new char[h][];
			for (int i = 0; i < h; i++)
				map[i] = new char[w];
			for (int y = 0; y < h; y++) {
				char[] str = scan.next().toCharArray();
				for (int x = 0; x < w; x++) {
					map[y][x] = str[x];
				}
			}
			int ans = 0;
			for (int y = 0; y < h; y++) {
				for (int x = 0; x < w; x++) {
					if (map[y][x] != 'x') {
						c = map[y][x];
						bfs(y, x);
						ans++;
					}
				}
			}
			System.out.println(ans);
		}
	}
	
	void bfs(int y, int x) {
		if (y < 0 || x < 0 || y >= h || x >= w || map[y][x] != c) return;
		map[y][x] = 'x';
		bfs(y + 1, x);
		bfs(y - 1, x);
		bfs(y, x + 1);
		bfs(y, x - 1);
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 28728
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;

// const
// 円周率
const double pi = M_PI;
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)

int main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  ll l, r;
  cin >> l >> r;
  ll min1 = INF;
  for (ll i = l; i <= min(l + 2019, r); i++) {
    for (ll j = i + 1; j <= min(l + 2019, r); j++) {
      min1 = min(((i % 2019) * (j % 2019)) % 2019, min1);
    }
  }
  cout << min1 << endl;
  return 0;
}


Measured memory_bytes: 256
N, A, B, C = map(int, input().split())
ls = []
for i in range(N):
  l = int(input())
  ls.append(l)
rs = []
for i in range(4**N):
  hA = 0
  hB = 0
  hC = 0
  n = 0
  for j in range(N):
    if i%4 == 1:
      hA += ls[j]
      n += 1
    if i%4 == 2:
      hB += ls[j]
      n += 1
    if i%4 == 3:
      hC += ls[j]
      n += 1
    i = i//4
  if not(hA > 0 and hB > 0 and hC > 0):
    continue
  r = (n-3)*10+abs(hA-A)+abs(hB-B)+abs(hC-C)
  rs.append(r)
r = min(rs)
print(r)


Measured memory_bytes: 4988