akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("-O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include<cmath>
#include<cstdio>
#include<algorithm>
#include<bitset>
#include<complex>
#include<deque>
#include<fstream>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<typeinfo>
#include<typeindex>
#include<type_traits>
#include<utility>
#include<valarray>
#include<vector>
#include<array>
#include<forward_list>
#include<random>
#include<ratio>
#include<tuple>
#include<unordered_map>
#include<unordered_set>
#include<cstring>

using namespace std;
using Int = long long;
typedef pair<int,int> Pi; typedef pair<Int,Int> Pl;
const int mod = 1e9+7;
const Int Inf = 1e17;
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define mp make_pair
#define Pr(t) priority_queue<t>
#define gPr(t) priority_queue<t,vector<t>,greater<t>>
#define V(t) vector<t>
#define rep(i,n) for(int(i)=0; i<n; ++i)
#define rer(i,l,r) for(int i=l; i<=r; i++)
#define gnr(i,l,r) for(int i=r; i>=l; i--)
#define eb emplace_back
#define pri1(a) cout<<(a)<<'\n'
#define pri2(a,n) {rep(pri2i,n-1)cout<<a[pri2i]<<' '; cout<<a[n-1]<<'\n';}
#define prip(p) cout<<p.fi<<' '<<p.se<<'\n'
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n,m,_,x,y,q;
string s,sb;
bool ok;
char cf,cb;

int main(){
  cin.tie(nullptr); ios::sync_with_stdio(0);
  //cout<<fixed<<setprecision(20);
  
  cin>>n>>m; int a[n],mv=0; rep(i,n)cin>>a[i]; Pi mi[n]; Pi me=Pi(2e9,-1);
  unordered_map<int,int>p,po; rep(i,n)p[a[i]]++;
  rep(i,n){cmin(me,Pi(a[i],i)); mi[i]=me; cmax(mv,a[i]-me.fi);}
  int ans=0;
  rep(i,n)if(a[i]-mi[i].fi==mv)po[a[i]]++;
  for(auto e:po)ans+=min(e.se,p[e.fi-mv]);
  END
}

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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  while(1){
    if(C - B<= 0){
      cout << "Yes" << endl;
      break;
    }
    C -= B;
    if(A - D <= 0){
      cout << "No" << endl;
      break;
    }
    A -= D;
  }
  
}


Measured memory_bytes: 3636
N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))

cnt = {}
for d in D:
    if d not in cnt:
        cnt[d] = 1
    else:
        cnt[d] += 1
ans = True
for t in T:
    if t not in cnt:
        ans = False
        break
    elif cnt[t] == 0:
        ans = False
        break
    else:
        cnt[t] -= 1

if ans:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 127572
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#include <bits/stdc++.h>

#define pb push_back
#define fi first
#define se second
#define all(v) v.begin(), v.end()

using namespace std;
using ll = int64_t;

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

  string s;
  cin >> s;
  cout << s.substr(0, 4) << " " << s.substr(4) << endl;

  return 0;
}


Measured memory_bytes: 256
n=input().strip()
n=int(n)
if n>=2 and n<=50:
    num=list(map(int,input().strip().split()))
num.sort()

if n==2:
    print(sum(num)/2)
else:
    num.append((num[0]+num[1])/2)
    num=num[2:]
    for i in range(len(num)-1):
        num.append((num[-1]+num[0])/2)
        num=num[1:]
    print(num[-1])

Measured memory_bytes: 3064
n,k=gets.split.map(&:to_i)
lines=[]

lines = []
while line = gets
    lines << line.chomp.split(' ').map(&:to_i)
end
snack=[]
who=[]
 lines.each_with_index do |n,i|
if  i.odd?
who.push(n)
else
snack.push(n)
end
end
whoall=[]
who.each{|m| m.each{|z|whoall.push(z)}}
whoall.uniq!
puts n-whoall.length

Measured memory_bytes: 14464
/*
* Problem link
* 
*/

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector<int> V;
typedef vector<V> VV;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
template<typename T>
inline bool chmax(T &a, T b) {
	bool res = a < b;
	if (res)a = b;
	return res;
}
typedef pair<int, int> P;
typedef vector<P> VP;
#define fi first
#define se second
#define ALL(v) (v).begin(),(v).end()


void rot(VP &v) {
	for (auto &it : v) {
		swap(it.first, it.second);
		it.second *= -1;
	}
}
void fix(VP &v) {
	P x = v[0];
	for (auto &it : v) {
		it.first -= x.first;
		it.second -= x.second;
	}
}

int main() {
#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	auto input=[&]() {
		int m;
		cin >> m;
		VP res(m);
		REP(i, m)cin >> res[i].first >> res[i].second;
		return res;
	};
	int n;
	while (1) {
		cin >> n;
		if (n == 0)break;
		auto v0 = input();
		auto u0 = v0;
		reverse(ALL(u0));
		fix(v0);
		fix(u0);
		FOR(i, 1, n + 1) {
			auto v = input();
			bool f = false;
			REP(j, 4) {
				fix(v);
				if (v0 == v || u0 == v)f = true;
				rot(v);
			}
			if (f)cout << i << endl;
		}
		cout << "+++++" << endl;
	}

	return 0;
}

Measured memory_bytes: 2984
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d;
long long ans;
int main()
{
	ans=-1e18;
	cin>>a>>b>>c>>d;
	if(a*c>ans)
	{
		ans=a*c;
	}
	if(a*d>ans)
	{
		ans=a*d;
	}
	if(b*c>ans)
	ans=b*c;
	if(b*d>ans)
	ans=b*d;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3620
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::{vec, cmp, num};


struct Scanner<'a> {
    cin: StdinLock<'a>,
}

impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner {cin: cin}
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
                    .skip_while(|c| c.is_whitespace())
                    .take_while(|c| !c.is_whitespace())
                    .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

// create Vec<char> from String
#[allow(dead_code)]
fn to_chars(s: String) -> vec::Vec<char> {
    let mut cs = s.chars();
    let mut res = vec::Vec::new();
    while let Some(c) = cs.next() {
        res.push(c);
    }
    res
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);
    let a: i32 = sc.read();
    let mut op: String = sc.read();
    let op = op.pop().expect("Err");
    let b: i32 = sc.read();
    if op == '+' {
        println!("{}", a + b);
    } else {
        println!("{}", a - b);
    }
}

Measured memory_bytes: 4352
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var A = int.Parse(Console.ReadLine());
            var B = int.Parse(Console.ReadLine());
            var C = int.Parse(Console.ReadLine());
            var X = int.Parse(Console.ReadLine());
            var count = 0;

            for (var i = 0; i <= A; i++)
            {
                for (var j = 0; j <= B; j++)
                {
                    for (var k = 0; k <= C; k++)
                    {
                        if (i * 500 + j * 100 + k * 50 == X) count++;
                    }
                }
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 13140
# coding: utf-8
import os, sys

N, A, B = map(int, input().split())
# print(N, A, B)

rep = N // (A+B)
rest = N - (A + B) * rep

# diff = A if rest >= A else rest  
ans = A * (rep) + min(rest, A)

print(int(ans))

Measured memory_bytes: 3060
N,M=map(int,input().split())
mod=10**9+7
isbroken=[1 for i in range(N+1)]
dp=[0 for i in range(N+1)]
dp[0]=1
for i in range(M):
    ai=int(input())
    isbroken[ai]=0
for i in range(N):
    dp[i+1]=isbroken[i]*dp[i]+isbroken[i-1]*dp[i-1]
    dp[i+1]%=mod
print(dp[N])

Measured memory_bytes: 7888
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
int main() {
  double N,M;
  cin>>N>>M;
  vector<double>a(N);
  double sum=0;
  for(int i=0;i<N;i++){
    cin>>a[i];
    sum+=a[i];
  }
  int cnt=0;
  for(int i=0;i<N;i++){
    if(a[i]>=sum/(4*M)){cnt++;}
  }
  if(cnt>=M){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
  return 0;
}

Measured memory_bytes: 3740
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}
function PriorityQueue(){
  this.heap = [];
}
PriorityQueue.prototype = {
  push : function(x){
    var h = this.heap, i = h.length++, j;
    while(i){
      j = i-1 >> 1;
      if(h[j] <= x)break;
      h[i] = h[j];
      i = j;
    }
    h[i] = x;
  },
  pop : function(){
    var h = this.heap, r = h[0], x = h.pop();
    var i = 0, k = h.length >> 1, j;
    while (i < k) {
      j = (i << 1) + 1;
      if(h[j+1] < h[j])++j;
      if(x <= h[j])break;
      h[i] = h[j];
      i = j;
    }
    if(h.length)h[i] = x;
    return r;
  },
  size : function(){return this.heap.length;},
  top : function(){return this.heap[0];},
};

console.log(main());
function main(){
  var n = o.a();
  var m = o.a();
  var a = o.l();
  var pq = new PriorityQueue();
  for(var i = 0; i < n; i++){
    pq.push(-a[i]);
  }
  for(var i = 0; i < m; i++){
    var q = -pq.pop();
    q >>= 1;
    pq.push(-q);
  }
  var ans = 0;
  for(var i = 0; i < n; i++){
    ans -= pq.pop();
  }
  return 0+ans;
}

Measured memory_bytes: 29832
#include <iostream>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
int a[300030];
int co[300030] = { 0 };
int op(int a, int b) {
	return max(a, b);
}
int e() {
	return (int)(0);
}
segtree<int, op, e> seg(300030);
int main() {
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		int l = max(0, a[i] - k);
		int r = min(300010, a[i] + k + 1);
		int m = seg.prod(l, r);
		co[i] = m + 1;
		seg.set(a[i], co[i]);
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (ans < co[i]) {
			ans = co[i];
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 9624
n = int(input())
ans = [0 for _ in range(10001)]
for i in range(1, 100):
    for j in range(1, 100):
        for k in range(1, 100):
            summ = i**2 + j**2 + k**2 + i * j + j * k + k * i
            if summ < 10001:
                ans[summ] += 1

for i in range(1, n + 1):
    print(ans[i])
# print(ans[20])


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

typedef long long ll;
typedef pair<int,int> pint;
#define INF 99999999
#define rep(i,n) for(int i=0,temp=(int)(n);i<temp;++i) 
#define repi(i,start,end) for(int i=start,temp=(int)(end);i<end;++i)
#define rfor(v,x) for(const auto& x : v) //xは値を表す
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort(v, v+n)
#define vsort(v) sort(v.begin(), v.end())
#define vfsort(v,lambda) sort(v.begin(),v.end(),lambda)
#define vint vector<int>
#define vvint vector<vector<int>> //vvint v(n,vint(n))のように宣言できる
#define vin(v) rep(i,v.size()) {cin >> v[i];}
//最終奥義
#define int long long
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int ctoi(char c) {return c-'0';}
//lambda式 -> [&](int x, int y){return x<y;}
//vector内の重複を削除-> v.erase(unique(all(v)),v.end());
signed main(void){
  int n,m;cin >> n >> m;
  /*vint a(n);vin(a);
  vfsort(a,[](int x,int y){return x>y;});
  rep(i,m){
    a[0]/=2;

  }*/
  multiset<int> s;
  rep(i,n){
    int t;cin >> t;
    s.insert(t);
  }
  rep(i,m){
    int t=*s.rbegin();
    auto itr=s.find(t);
    s.erase(itr);
    s.insert(t/2);
  }
  cout << accumulate(all(s),0LL) << endl;



}


Measured memory_bytes: 4992
import java.util.Scanner;

public class Main {


	public static void main(String[] args) {

	Scanner sca = new Scanner(System.in);
	String s = sca.next();
	String t = sca.next();
	int a = sca.nextInt();
	int b = sca.nextInt();
	String u = sca.next();

	if(u.equals(s)) {
		a--;
	}
	else {
		b--;
	}

	System.out.print(a);
	System.out.print(" ");
	System.out.println(b);

	// 後始末
	sca.close();
	}
}

Measured memory_bytes: 22736
#include<stdio.h>
#include<iostream>
#include<string>
#include<math.h>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<time.h>
#include<ctime>
#include<functional>
using namespace std;
typedef long long ll;
int inf = 1000000000;
template<typename T>
T GCD(T a, T b) {
	while (max(a, b) % min(a, b)) {
		if (a > b)a = a % b;
		else b = b % a;
	}
	return min(a, b);
}
template<typename T>
T LCM(T a, T b) {
	return a / GCD(a, b)*b;
}
stack<int>f;
int main() {
	ll n;
	cin >> n;
	ll a = 1;
	bool b = false;
	while (true) {
		if (abs(n) % (a * 2)) {
			f.push(1);
			if (b)n -= -a;
			else n -= a;
		}
		else f.push(0);
		if (b)b = false;
		else b = true;
		if (!n) break;
		a *= 2;
	}
	while (!f.empty()) {
		int d = f.top();
		f.pop();
		cout << d;
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

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


    map<int, int> mp;

    {
        int prev = 0;
        while (mp.find(prev) == mp.end()) {
            int next = prev * 10 + 7;
            next %= k;
            mp[prev] = next;
            prev = next;
        }
    }

    bool b = [&] {
        for (auto e : mp) {
            if (e.second == 0) return true;
        }
        return false;
    }();
    if (!b) {
        cout << -1 << endl;
        ret();
    }

    int ans = 1;
    for (int prev = 0; mp[prev] != 0; prev = mp[prev]) {
        ans++;
    }

    cout << ans << endl;

}


Measured memory_bytes: 50372
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define pb push_back
#define ff first
#define ss second
#define ll long long
#define ld long double
typedef pair<ll,ll> pll;
typedef pair<pll,pll> ppll;
typedef vector <pll> vi;
#define out(x) return cout<<x,0;
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define lc(n) 2*n+1
#define rc(n) 2*n+2
#define fill(a,b) memset((a),(b),sizeof((a)))
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
ll M = 1e9 + 7 , X , Y ;

ll power( ll x , ll y ){
    x %= M;
    ll res = 1;
    while ( y ){
        if ( y & 1 ) 
            res = (res * x)%M;
        y /= 2;
        x = (x * x)%M;
    }
    return res;
}

void EE ( ll a , ll b ){
	if( b == 0 ){
		X = 1;
		Y = 0;
		return;
	}
	EE ( b , a%b );
	ll t = X;
	X = Y;
	Y = t - (a/b)*Y;
}

ll get( ll a ){
	EE( a , M );
	return (X%M + M)%M;
}

int main() {
    FAST;
    ll i, n, k, m, x = 0, y = 0, t, z = 0, ans = 0, j, c = 0;
    cin >> n;
    ll a[n];
    int b[1000005] = { 0 };
    for ( i = 0 ; i < n ; i ++ ){
    	cin >> a[i];
    	x = a[i];
    	for ( j = 2 ; j*j <= x ; j ++ ){
    		if ( x%j == 0 ){
    			int C = 0;
    			while ( x%j == 0 ){
    				C ++;
    				x /= j;
    			} 
    			b[j] = max(b[j] , C);
    		}
    	}
    	if ( x > 1 ) b[x] = max(1 , b[x] );
    }
    y = 1;
    for ( i = 2 ; i < 1000005 ; i ++ ){
        if ( b[i] != 0 ) {
            y = (y * power(i , b[i]))%M; 
        }
    }
    for ( i = 0 ; i < n ; i ++ ){
        ans = (ans + (y*get(a[i])%M + M)%M )%M;
    }
    cout << ans ;
}

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

long long n;
vector<long long> a, cnt;

long long solve();
long long dfs(long long s, long long nextid, long long sum);

int main() {
  cin >> n;
  a.resize(n);
  cnt.assign(n, 0);
  for(int i = 0; i < n; ++i) cin >> a[i];
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long res = 0;
  for(int i = 0; i < n; ++i) res += a[i];
  return res - dfs(0, 0, 0);
}

long long dfs(long long s, long long nextid,
              long long sum) {
  if(nextid == (1LL << n)) return sum;
  long long res = sum;
  P nowp = make_pair(s, nextid);
  // nextid:false
  res = max(res, dfs(s, nextid + 1, sum));
  // nextid:true
  vector<int> lst;
  for(int i = 0; i < n; ++i)
    if(nextid >> i & 1) lst.push_back(i);
  int lstsize = lst.size();
  if(lstsize <= 1) return res;
  for(int i = 0; i < lstsize; ++i)
    for(int j = i + 1; j < lstsize; ++j) {
      if(s >> (lst[i] * n + lst[j]) & 1) return res;
      s += (1LL << (lst[i] * n + lst[j]));
    }
  for(int i = 0; i < lstsize; ++i) {
    if(++cnt[lst[i]] > a[lst[i]]) {
      for(int j = i; j >= 0; --j) --cnt[lst[j]];
      return res;
    }
  }
  sum += lstsize - 1;
  nowp = make_pair(s, nextid);
  res = max(res, dfs(s, nextid + 1, sum));
  for(int i = 0; i < lstsize; ++i) --cnt[lst[i]];
  return res;
}


Measured memory_bytes: 3176
N = int(input())
C = [input() for i in range(N)]

MOD = 1e9 + 7

C2 = []
re = ""
L = {}
LL = [-1] * N
for i in C:
  if i != re:
    if i in L:
      LL[L[i]] = len(C2)
      L[i] = len(C2)
    else:
      L[i] = len(C2)
    C2.append(i)
  re = i


DP = [-1] * (len(C2) + 1)

DP[-1] = 1
for i in range(len(C2) - 1, -1, -1):
  DP[i] = DP[i + 1]
  if LL[i] != -1:
    DP[i] += DP[LL[i]] % MOD
print(int(DP[0] % MOD))


Measured memory_bytes: 109188
#include <atcoder/all>
#include <bits/stdc++.h>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
using ld = long double;
const ul mod = 1000000007;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll k;
    cin >> k;
    rep(i, k) { cout << "ACL"; }
    cout << endl;
    return 0;
}



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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cout << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	string s = "SCRS";
	map<char, string> mp;
	mp['S'] = "Sunny";
	mp['C'] = "Cloudy";
	mp['R'] = "Rainy";
	char x;
	cin >> x;
	FOR(i, 0, 4) if (s[i] == x)
	{
		cout << mp[s[i + 1]];
		return 0;
	}
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}



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

int main() {
    int n, X; scanf("%d%d", &n, &X);
    int x;
    vector<int> diff;
    for (int i = 0; i < n; i++) {
        scanf("%d", &x);
        diff.push_back(abs(X-x));
    }
    sort(diff.begin(), diff.end());
    unique(diff.begin(), diff.end());

    vector<int> dev;
    for (int i = 1; i <= pow(diff[0], 0.5); i++) {
        if (diff[0]%i==0) {
            dev.push_back(i);
            dev.push_back(diff[0]/i);
        }
    }
    sort(dev.begin(), dev.end());
    unique(dev.begin(), dev.end());
    reverse(dev.begin(), dev.end());

    int num = 0;
    int ret = dev[num];
    for (int i = 1; i < diff.size(); i++) {
        while (diff[i] % dev[num] != 0) {num++;}
        ret = dev[num];
        if (ret == 1) break;
    }

    printf("%d\n", ret);
    return 0;
}

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

 int main()
 {
   int n,number,i,j,amount_of_prime=0,flag = 0;

   scanf("%d",&n);
   for(i = 0 ; i < n ;i++)
     {
       scanf("%d",&number);
       //cast = sqrt(number);
       //printf("cast = %d\n",cast);
       
       flag = 0;
       
       for(j = 2 ; j <= sqrt(number) ; j++)
	   {
	     
	     if(number % j == 0)
	       {
		 flag = 1;
		 continue;
	       }
	     
	   }
       
       if(flag == 0) amount_of_prime++;
       
     }
   printf("%d\n",amount_of_prime);
 }



Measured memory_bytes: 2072
#include <stdio.h>
int main()
{
  int H,A,s,a;
  
  scanf("%d %d",&H,&A);
  
  a=H/A;
  s=H%A;
  if(s==0){
    printf("%d\n",a);
  }
  else{
    a+=1;
    printf("%d\n",a);
  }
  return 0;
}


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

int main()
{
  int n, a[200000], nV[200000] = {0};
  uint64_t k;
  cin >> n >> k;
  for (int i = 0; i < n; i++)
  {
    int tmp;
    cin >> tmp;
    a[i] = tmp - 1;
  }

  int cur = 0, loopstart, loopstep = 0;
  ;
  nV[0]++;
  while (1)
  {
    cur = a[cur];
    nV[cur]++;
    loopstep++;
    if (nV[cur] == 2)
    {
      loopstart = cur;
      break;
    }
  }

  cur = 0;
  int step = 0;
  while (1)
  {
    if (cur == loopstart)
    {
      break;
    }
    cur = a[cur];
    step++;
  }
  loopstep -= step;

  if (step > k)
  {
    cur = 0;
  }
  else
  {
    k -= step;
    k %= loopstep;
    cur = loopstart;
  }
  for (uint64_t i = 0; i < k; i++)
  {
    cur = a[cur];
  }

  cout << cur + 1 << endl;
}


Measured memory_bytes: 5200
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<climits>//long long型の最大値(LLONG_MAX)など
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;
typedef long double lb; 

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)


int main() { 
    ll A,B,C,X;
    cin >> A >> B >> C >> X;

    ll ans=0;
    rep(i,A+1){
        rep(j,B+1){
            rep(k,C+1){
                ll result = 500*i+100*j+50*k;
                if(result == X){
                    ans++;
                }
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
import numpy as np
A, B, M = map(int,input().split())
a = np.array([int(num) for num in input().split()])
a_min = np.min(a)

b = np.array([int(num) for num in input().split()])
b_min = np.min(b)
total_min= a_min + b_min

for i in range(0, M):
    x, y, c = map(int,input().split())
    min_can = a[x-1] + b[y-1] -c
    if total_min > min_can:
        total_min = min_can
print(total_min)

Measured memory_bytes: 24440
//Bishmillahir Rahmanir Rahim
//sajeedreefy
#include<bits/stdc++.h>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long int a,b,c,i,t,n,count=0,sum=0,k;
    cin >> n;
    if(n==0)
    {
        cout << 1 << endl;
    }
    else
    {
        cout << 0 << endl;
    }
    return 0;
}



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

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
const int INF = 100000000;

struct C{
    int x0, y0, x1, y1;
    int id;
    bool operator < (const C& s) const {
        if(x0 != s.x0) return x0 < s.x0;
        return y0 < s.y0;
    }
};
void rec(set<C> S, vector<int>& order){
    if(S.empty()) return ;

    C target = *S.begin();
    S.erase(target);
    order.push_back(target.id);

    int extend = INF;
    for(auto c : S){
        if(c.y0 < target.y1 && target.y1 < c.y1) extend = min(extend, c.x0);
    }
    assert(extend >= target.x1);

    set<C> upper, lower;
    for(auto c : S){
        if(c.x1 <= extend && c.y1 <= target.y1) lower.insert(c);
        else upper.insert(c);
    }
    rec(lower, order);
    rec(upper, order);
}

int main(){
    bool first = true;
    for(int N; cin >> N && N;){
        if(first) first = false;
        else cout << endl;

        set<C> S;
        REP(i, N){
            C c;
            c.id = i;
            cin >> c.x0 >> c.y0 >> c.x1 >> c.y1;
            if(c.x0 > c.x1) swap(c.x0, c.x1);
            if(c.y0 > c.y1) swap(c.y0, c.y1);
            S.insert(c);
        }

        vector<int> order;
        rec(S, order);
        
        assert(order.size() == N);
        vector<int> ans(N, -1);
        REP(i, N) ans[order[i]] = i + 1;

        REP(i, ans.size()){
            assert(ans[i] >= 1);
            cout << ans[i] << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1220
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <deque>
using namespace std;

using VI = vector <int> ;
using VVI = vector <VI> ;

int main() {
    int R;
    int C;

    cin >> R >> C;
    vector <string> grid(R)
    ;
    for (int i = 0; i < R; ++i) {
        cin >> grid[i];
    }

    const int INF = 10000000;
    vector<vector<vector<int>>> dp(R, vector<vector<int>>(C, vector<int>(2, INF)));

    dp[0][0][grid[0][0] == '#'] = (grid[0][0] == '#');

    for (int i = 0; i < R; ++i) {
        for (int j = 0; j < C; ++j) {
            int c = (grid[i][j] == '#');

            if (i) {
                dp[i][j][c] = min(dp[i][j][c], dp[i-1][j][c]);
                dp[i][j][c] = min(dp[i][j][c], dp[i-1][j][c^1] + c);
            }

            if (j) {
                dp[i][j][c] = min(dp[i][j][c], dp[i][j-1][c]);
                dp[i][j][c] = min(dp[i][j][c], dp[i][j-1][c^1] + c);
            }
        }
    }

    int c = (grid[R-1][C-1] == '#');
    cout << dp[R-1][C-1][c] << endl;

    return 0;
}

Measured memory_bytes: 768
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <climits>
#include <cmath>
#include <functional>
#include <map>
#include <queue>
#include <set>

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define size_t unsigned long long
#define ll long long
#define rep(i,a) for(int i=0;i<(a);i++)
#define repr(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

const int MOD = 1e9 + 7;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

string s,t;
int n,m,result;

int main () {
  t = "No";
  cin >> n >> m;
  if (n >= 10 || m >= 10) result = -1;
  else result = n*m;
  cout << result << endl;
}


Measured memory_bytes: 256
from sys import stdin


def find_sum_of_digits(n, base=10):
    _sum = 0
    while n>0:
        _sum += n%base
        n //= base
    return _sum


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N, A, B = list(map(int,_in[0].split(' ')))  # type:list(int)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    cnt = 0
    for n in range(1,N+1):
        _sum = find_sum_of_digits(n)
        if A <= _sum <= B:
            cnt += n
    ## ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)


Measured memory_bytes: 39536
#include <bits/stdc++.h>
#define fr(i, n) for (int i = 0; i < n; i++)
#define frab(i, a, b) for (int i = a; i < b; i++)
#define pb push_back

using namespace std;

typedef long long ll;
typedef long double ld;

const ll MOD = 1e9 + 7;
const ll INF = 2e15 + 10;
const ll MAX = 1e14 + 10;
const ld EPS = 1e-9;
const int N = 3e3 + 10;
const int M = 1e5 + 10;

ll a[N];
ll d[N][N];

void solve() {
    int n;
    cin >> n;
    fr(i, n)
        cin >> a[i];
    fr(i, n) {
        if (n % 2)
            d[i][i] = a[i];
        else
            d[i][i] = -a[i];
    }

    frab(len, 2, n + 1)
        for (int l = 0; l + len - 1 < n; l++) {
            int r = l + len - 1;
            if (n % 2 == len % 2) {
                d[l][r] = max(d[l][r - 1] + a[r], d[l + 1][r] + a[l]);
            } else {
                d[l][r] = min(d[l][r - 1] - a[r], d[l + 1][r] - a[l]);
            }
        }
    cout << d[0][n - 1];
}



int main() {
    //freopen("a.in", "r", stdin);
    ios_base::sync_with_stdio(false);
    solve();
}


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

using namespace std;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	long long int a,b;
	cin>>a>>b;
	if(b%a==0){
		cout<<a+b;
	}
	else{
		cout<<b-a;
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vii vector<vi>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	int n;
    cin>>n;
    vector<LL> a(n);
    int f=0;
    FOR(i,0,n){
        cin>>a[i];
        if(a[i]==1)f=1;
    }
    if(f==0){
        cout<<-1<<endl;
        return 0;
    }
    int l=1,r=202020,m=(l+r)/2;
    while(l!=m){
        int nw=1;
        FOR(i,0,n){
            if(a[i]==nw){
                nw++;
            }
        }
        cout<<n-nw+1<<endl;
        break;
    }

}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
vector <pair<int,int> >g[55];
int cnt=0;
bool u[55]={1};
void dfs(int k,int x){
	u[k]=0;
	for(int j=0;j<g[k].size();j++)
		if(u[g[k][j].first]&&g[k][j].second!=x)
			dfs(g[k][j].first,x);
}
int main() 
{
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int a,b;
		cin>>a>>b;
		g[a].push_back(make_pair(b,i));
		g[b].push_back(make_pair(a,i));
	}
	for(int i=0;i<m;i++)
	{
		for(int z=1;z<=n;z++)
			u[z]=1;
		dfs(1,i);
		for(int z=1;z<=n;z++)
			if(u[z]){cnt++;
				break;}
	}
	cout<<cnt<<endl;
	return 0;
}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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 (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int N;
vector<pii> G[100010];
int Q, K;
int D[100010];

void dfs(int v, int c, int par)
{
	D[v] = c;
	for (auto e : G[v])
	{
		if (e.first == par)continue;
		dfs(e.first, c + e.second, v);
	}
}

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

	cin >> N;
	int a, b, c;
	rep(i, 0, N - 1)
	{
		cin >> a >> b >> c;
		a--, b--;
		G[a].push_back(mp(b, c));
		G[b].push_back(mp(a, c));
	}

	cin >> Q >> K;
	K--;

	dfs(K, 0, -1);

	int x, y;
	rep(i, 0, Q)
	{
		cin >> x >> y;
		x--, y--;
		cout << D[x] + D[y] << endl;
	}

	return 0;
}

Measured memory_bytes: 14336
#include <iostream>

using namespace std;

int main(void){
  while(1){
    int n;
    cin >> n;
    if(n == 0){return 0;}

    char c[n];
    for(int i = 0 ; i < n ; i++){
      cin >> c[i];
    }

    int kind[27];
    for(int i = 0 ; i < 27 ; i++){
        kind[i] = 0;
    }

    // 1?????¨2??????????????????????\¨??°????¶???????????????§1????¢???????

    int max = 0;
    int maxc = -1;
    int semimax = 0;
    int rest = n;
    bool def = false;
    int ans;

    for(int i = 0 ; i < n ; i++){
      kind[c[i] - 65]++;
      rest--;

      for(int j = 0 ; j < 27 ; j++){
        if(max < kind[j]){
          max = kind[j];
          maxc = j;
        }else if(maxc != j && semimax < kind[j]){
          semimax = kind[j];
        }
      }

//      cout << (char)(maxc + 65) << " " << "(" << max << ")" << " semi:" << semimax << endl;

      if(max - semimax > rest){
        def = true;
        ans = i + 1;
        break;
      }else if(rest == 0 && max == semimax){
        break;
      }
    }

    if(def){
      cout << (char)(maxc + 65) << " " << ans << endl;
    }else{
      cout << "TIE" << endl;
    }

  }

}

Measured memory_bytes: 3068
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

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

Measured memory_bytes: 3524
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<complex>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<algorithm>
#include<list>
#include<functional>
#include<cassert>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define INF 987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset(a,0,sizeof(a));
#define MEM_1(a) memset(a,-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<int, int, int, int> iiii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const int MOD = 123456789;
ll POW(ll a, ll b, ll MMM = MOD) { ll ret = 1; for (; b; b >>= 1, a = (a*a) % MMM)if (b & 1)ret = (ret*a) % MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1 }, dy[] = { 1,0,-1,0 };
int ddx[] = { 0,0,1,1,1,-1,-1,-1 }, ddy[] = { 1,-1,1,0,-1,1,0,-1 };

Pi p[90001];
inline int dist(Pi p1,Pi p2)
{
	return abs(p1.X-p2.X)+abs(p1.Y-p2.Y);
}
int s[90001];
int main() {
	int n,m,d;
	scanf("%d%d%d",&n,&m,&d);
	fup(i,0,n-1,1)
		fup(j,0,m-1,1)
	{
		int x;
		scanf("%d",&x);
		p[x]=mp(i,j);
	}
	fup(i,d+1,n*m,1)
	{
		s[i]=s[i-d]+dist(p[i],p[i-d]);
	}
	int q;
	scanf("%d",&q);
	while(q--)
	{
		int l,r;
		scanf("%d%d",&l,&r);
		printf("%d\n",s[r]-s[l]);
	}
}

Measured memory_bytes: 2176
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

limit=50
graph=[[False]*limit for _ in range(limit)]
visited=[False]*limit

def dfs(n,v):
  visited[v]=True
  for v2 in range(n):
    if graph[v][v2]==False:
      continue
    if visited[v2]:
      continue
    dfs(n,v2)

def main():
  n,m=LI()
  a=[[] for _ in range(n*n)]
  b=[[] for _ in range(n*n)]
  for i in range(m):
    _a,_b=LI()
    _a-=1
    _b-=1
    a[i]=_a
    b[i]=_b
    graph[_a][_b]=True
    graph[_b][_a]=True

  ans=0
  for i in range(m):
    graph[a[i]][b[i]]=False
    graph[b[i]][a[i]]=False

    for j in range(n):
      visited[j]=False
    dfs(n,0)
    no_visited=False
    for j in range(n):
      if visited[j]==False:
        no_visited=True
    if no_visited:
      ans+=1
    graph[a[i]][b[i]]=True
    graph[b[i]][a[i]]=True

  return ans

# main()
print(main())


Measured memory_bytes: 5428
#include <cstdio>
const int N=200005,mo=1000000007;
int a[N],c[N],w[N],cnt[N];

int ksm(int x,int y){
	int i=1;
	for (;y;y>>=1,x=1ll*x*x%mo)
		if (y&1) i=1ll*i*x%mo;
	return i;
}

int main(){
	int n,X,Y;
	scanf("%d%d%d",&n,&X,&Y);
	for (int i=0;i<=n;i++) a[i]=mo;
	for (int i=1;i<=n;i++){
		scanf("%d%d",&c[i],&w[i]);
		if (w[i]<a[c[i]]) a[c[i]]=w[i];
	}
	int c1=0,c2=0;
	for (int i=1;i<=n;i++)
		if (a[i]<a[c1]) c2=c1,c1=i;
			else if (a[i]<a[c2]) c2=i;
	for (int i=1;i<=n;i++)
		if ((c[i]!=c1 && w[i]+a[c1]<=Y)||(c[i]!=c2 && w[i]+a[c2]<=Y)
			||(w[i]+a[c[i]]<=X && a[c[i]]+a[c1]<=Y)) cnt[c[i]]++;
	int ans1=1,ans2=1;
	for (int i=1,j=0;i<=n;i++)
		for (int k=1;k<=cnt[i];k++){
			ans1=1ll*ans1*(++j)%mo;
			ans2=1ll*ans2*k%mo;
		}
	ans1=1ll*ans1*ksm(ans2,mo-2)%mo;
	printf("%d\n",ans1);
}

Measured memory_bytes: 3328
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int INF = 1e9;

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

    vector<int> w(n);
    int sum = 0;
    rep(i, n) {
        cin >> w[i];
        sum += w[i];
    }

    int s1, s2, ans = INF; 
    rep(i, n) {
        s1 = 0;
        rep(j, i+1) {
            s1 += w[j];
        }
        s2 = sum - s1;
        ans = min(ans, abs(s1-s2));
    }

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

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

using namespace std;
typedef long long ll;
const ll inf = 1e18;
const int Nmax = 2*1e5 + 100;

int n, a[Nmax];
ll ps[Nmax], ans = inf;

int main() {
    scanf("%d", &n);
    for(int i = 1; i <= n; ++i) {
        scanf("%d", &a[i]);
        ps[i] = ps[i-1] + a[i];
    }
    for(int i = 1; i <= n-1; ++i) {
        ans = min(ans, abs(ps[n] - 2*ps[i]));
    }
    cout << ans;
}


Measured memory_bytes: 2560
#include<iostream>
#include<cmath>
using namespace std;
int A[105];
int main()
{
	int n,m,x;
	cin>>n>>m>>x;
	int temp;
	for(int i=1;i<=m;i++)
	{
		cin>>temp;
		A[temp]=1;
	}
	int sum1=0,sum2=0;
	for(int i=1;i<x;i++) sum1+=A[i];
	for(int i=x+1;i<=n;i++) sum2+=A[i];
	cout<<min(sum1,sum2)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
long long n,act,r,add,urm,sol,v[53];
int main()
{
    cin>>n;
    for(int i=1;i<=n;++i) cin>>v[i];
    bool ok=true;
    while(ok==true)
    {
        sort(v+1,v+n+1);
        ok=false;
        add=0;
        if(v[n]>n-1)
        {
            ok=true;
            r=v[n]%n;
            add=v[n]/n;
            for(int i=1;i<n;++i) v[i]+=add;
            v[n]=r;
        }
        sol+=add;
    }
    cout<<sol;
    return 0;
}


Measured memory_bytes: 256
n= int(input())
a= list(map(int, input().split()))

val=0
bfr=0
a.append(0)

for ai in a:
    val+=abs(ai-bfr)
    bfr=ai

for i in range(n):
    diff=0
    if (a[i-1]<a[i] and a[i]>a[i+1]):
        if a[i+1]>a[i-1]:
            diff=2*(abs(a[i+1]-a[i]))
        else:
            diff=2*(abs(a[i]-a[i-1]))
    elif(a[i-1]>a[i] and a[i]<a[i+1]):
        if a[i+1]>a[i-1]:
            diff=2*(abs(a[i]-a[i-1]))
        else:
            diff=2*(abs(a[i+1]-a[i]))
    print(val-diff)
        


Measured memory_bytes: 14048
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

long[10^^5*2] AS;
long[10^^5*2][5] MEMO;

void main()
{
    auto L = readln.chomp.to!int;
    foreach (i; 0..L) {
        AS[i] = readln.chomp.to!long;
    }

    foreach (ref m; MEMO) m[] = -1;

    long solve(int i, int t) {
        if (i == L) return 0;
        if (MEMO[t][i] != -1) return MEMO[t][i];
        return MEMO[t][i] = min(
            t > 0 ? long.max : AS[i] + solve(i+1, 0),
            t > 1 ? long.max : (AS[i] == 0 ? 2 : AS[i] % 2) + solve(i+1, 1),
            t > 2 ? long.max : (AS[i] == 0 ? 1 : (AS[i]+1) % 2) + solve(i+1, 2),
            t > 3 ? long.max : (AS[i] == 0 ? 2 : AS[i] % 2) + solve(i+1, 3),
            AS[i] + solve(i+1, 4)
        );
    }

    writeln(solve(0, 0));
}

Measured memory_bytes: 48124
N = int(input())
S = input()

from collections import defaultdict
# d = defaultdict(list)
d = defaultdict(int)

for ix, c in enumerate(S):
    # d[c].append(ix+1)
    d[c] += 1

# ans = len(d["B"]) * len(d["G"]) * len(d["R"])
ans = d["R"] * d["G"] * d["B"]

for i in range(1, N+1):
    ci = S[i-1]
    for j in range(i+1, N+1):
        cj = S[j-1]

        if ci == cj:
            continue

        k = j + j - i
        if k <= N:
            ck = S[k-1]
            if ci != ck and cj != ck:
                ans -= 1
        else:
            break
print(ans)


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

using namespace std;

typedef long long int Int;

int main(void)
{
    Int n;
    map<int,int> m;
    cin>>n;

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

    if(m.size() % 2)
    {
	cout<<m.size()<<endl;
    } else {
	cout<<m.size()-1<<endl;
    }

    return 0;
}


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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[a]; if (a != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)///
bool fall(vvi &v) {
	int h = v.size();
	bool updated = false;
	REP(j, 5) {
		int flag = true;
		while (flag) {
			flag = false;
			RREP(i, h - 1) {
				if (v[i + 1][j] == 0 && v[i][j] != 0) {
					v[i + 1][j] = v[i][j];
					v[i][j] = 0;
					flag = true;
					updated = true;
				}
			}
		}
	}
	return updated;
}
int erase(vvi &v) {
	int h = v.size();
	int ret = 0;
	vvi b(h, vi(5, 0));
	REP(i, h) {
		REP(j, 3) {
			int c = v[i][j], flag = 1;
			REP(k, 3) {
				if (v[i][j + k] != c)flag = 0;
			}
			if (flag) {
				REP(k, 3) {
					b[i][j + k] = 1;
				}
			}
		}
	}
	REP(i, h) {
		REP(j, 5) {
			if (b[i][j]) {
				ret += v[i][j];
				v[i][j] = 0;

			}
		}
	}
	return ret;
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	while (1) {
		int h;
		cin >> h;
		if (!h)break;
		vvi v(h, vi(5));
		REP(i, h) {
			REP(j, 5) {
				cin >> v[i][j];
			}
		}
		int ans = 0;
		do {
			ans += erase(v);
		} while (fall(v));
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3116
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a); i<(b);++i)
#define rep(i, n) FOR(i, 0, n)

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

// solve

int main(int argc, char const* argv[])
{
  int n;
  cin >> n;
  double x[2], y[2], r[2];
  rep(i, n){
    rep(j, 2){
      cin >> x[j] >> y[j] >> r[j];
    }
    double dis = sqrt((x[1] - x[0]) * (x[1] - x[0]) + (y[1] - y[0]) * (y[1] - y[0]));
    if(dis > r[0] + r[1])cout << 0 << endl;
    else if(abs(r[0] - r[1]) <= dis){
      cout << 1 << endl;
    }else{
      if(r[0] > r[1]){
        cout << 2 << endl;
      }else{
        cout << - 2 << endl;
      }
    }
  }
	return 0;
}



Measured memory_bytes: 3064