akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<i64>();
    let (l, r) = (v[0], v[1]);
    if r - l >= 2019 {
        println!("{}", 0);
        return;
    }
    let mut ans = std::i64::MAX;
    for i in l..r {
        for j in i + 1..r + 1 {
            ans = min(ans, (i * j) % 2019);
        }
    }
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cassert>
#include <algorithm>
#include <iterator>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <tuple>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <complex>
#include <bitset>
#include <numeric>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n) ;++(i))
#define REPN(i,a,n) FOR((i),(a),(a)+(n))
#define FOR(i,a,b) for(int (i)=(a); (i)<(b) ;++(i))
#define PB push_back
#define MP make_pair
#define SE second
#define FI first
#define DBG(a) cerr<<(a)<<endl;
#define ALL(v) (v).begin(),(v).end()
typedef long long LL;  typedef pair<LL, LL> PLL; typedef vector<LL> VLL;
const LL LINF=334ll<<53; const int INF=15<<26; const LL MOD=1E9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,s=0,ans;cin >>n;
    REPN(i,1,n){
        s+=i;
        if(n<=s){
            ans=i;
            break;
        }
    }
    vector<int> ret;

    for(int i=ans;i>=1;--i){
        if(i<=n){
            ret.PB(i);
            n-=i;
        }
    }
    REP(i,ret.size())cout << ret[ret.size()-i-1]<<endl;


    return 0;
}


Measured memory_bytes: 384
S = input()
 
a = S[:2]
b = S[2:]
  
if (int(a) > 12 and int(b) <= 12 and int(b) > 0):
  print('YYMM')
elif (int(b) > 12 and int(a) <= 12 and int(a) > 0):
  print('MMYY')
elif (int(a) <= 12 and int(a) > 0 and int(b) <= 12 and int(b) > 0):
  print('AMBIGUOUS')
elif (int(a) == 0 and int(b) <= 12 and int(b) > 0):
  print('YYMM')
elif (int(b) == 0 and int(a) <= 12 and int(a) > 0):
  print('MMYY')  
else:
  print('NA')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
typedef long long ll;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define FOR(i,n) for(int i=0;i<n;i++)
#define all(s) s.begin(),s.end()
#define lla(s) s.rbegin(),s.rend()
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const ll INF = 1e18;
int h,w;
char c[21][21];
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
bool contain(int x,int y){
    return (0<=x&&x<h&&0<=y&&y<w);
}
bool cell(int x,int y){
    return (c[x][y]=='.');//右辺もいじろう
}

int BFS(int sx,int sy){
    int d[h][w];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            d[i][j] = INF;
        }
    }
    d[sx][sy]=0;
    queue<P> q;
    q.push({sx,sy});
    int nx,ny;
    while(!q.empty()){
        P p = q.front();q.pop();
        int x = p.first,y = p.second;
        for(int i=0;i<4;i++){
            nx = x + dx[i];
            ny = y + dy[i];
            if(contain(nx,ny)&&cell(nx,ny)&&d[nx][ny]==INF){
                d[nx][ny] = d[x][y] + 1;
                q.push({nx,ny});
            }
        } 
    }
    int ret = 0;
    rep(i,0,h){
        rep(j,0,w){
            if(cell(i,j)){ret=max(ret,d[i][j]);}
        }
    }
    return ret;
}

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin>>h>>w;
    int ans = 0;
    rep(i,0,h){
        rep(j,0,w){
            cin>>c[i][j];
        }
    }
    rep(i,0,h){
        rep(j,0,w){
            if(cell(i,j))ans = max(ans,BFS(i,j));
        }
    }
    cout<<ans<<endl;
}

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

using namespace std;

int main()
{
	int n;
	cin >> n;
	switch(n%10){
	case 2:
	case 4:
	case 5:
	case 7:
	case 9:
		cout << "hon" << endl;
		break;

	case 0:
	case 1:
	case 6:
	case 8:
		cout << "pon" << endl;
		break;

	case 3:
		cout << "bon" << endl;
	}
}

Measured memory_bytes: 3600
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <list>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(d) string(1,d)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

vector<vector<int> > v;

int dd[2002];
int dd1[2002];
int dd2[2002];

void dfs(int p, int c) {
	dd[p] = c;
	rep(i, 0, v[p].sz) {
		if (dd[v[p][i]] == -1) {
			dfs(v[p][i], c + 1);
		}
	}
}

void dfs1(int p, int c) {
	dd1[p] = c;
	rep(i, 0, v[p].sz) {
		if (dd1[v[p][i]] == -1) {
			dfs1(v[p][i], c + 1);
		}
	}
}

void dfs2(int p, int c) {
	dd2[p] = c;
	rep(i, 0, v[p].sz) {
		if (dd2[v[p][i]] == -1) {
			dfs2(v[p][i], c + 1);
		}
	}
}

int main() {
	ll n, k;
	cin >> n >> k;
	vector<vector<int> > v_(n, vector<int>());
	v = v_;
	vector<int> va;
	vector<int> vb;
	rep(i, 0, n - 1) {
		ll a, b;
		cin >> a >> b;
		a--; b--;
		va.pb(a);
		vb.pb(b);
		v[a].pb(b);
		v[b].pb(a);
	}
	ll mn = n;
	if (k % 2 == 0) {
		rep(i, 0, n) {
			clr(dd, -1);
			dfs(i, 0);
			ll c = 0;
			rep(i, 0, n) {
				if (dd[i] > k / 2) {
					c++;
				}
			}
			mn = min(mn, c);
		}
	}
	else {
		rep(i, 0, va.sz) {
			clr(dd1, -1);
			clr(dd2, -1);
			dfs1(va[i], 0);
			dfs2(vb[i], 0);
			ll c = 0;
			rep(i, 0, n) {
				if (dd1[i] > k / 2 && dd2[i] > k / 2) {
					c++;
				}
			}
			mn = min(mn, c);
		}
	}
	cout << mn << endl;
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
void fastIO(){
  ios_base::sync_with_stdio(0); cin.tie(0);
}


int main(){
  string s,ans;
  cin>>s;
  bool a = s[0]==s[1]||s[1]==s[2]||s[2]==s[3];
  a?ans="Bad":ans="Good";
  cout<<ans;
}








Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{int A,B,C,D,E;
scanf("%d",&E);
A=E/1000;
B=(E/100)%10;
C=(E/10)%10;
D=E%10;


if(A+B+C+D==7){
	printf("%d+%d+%d+%d=7",A,B,C,D);}else if(A+B+C-D==7){
		printf("%d+%d+%d-%d=7",A,B,C,D);}else if(A+B-C+D==7){
		printf("%d+%d-%d+%d=7",A,B,C,D);}else if(A+B-C-D==7){
		printf("%d+%d-%d-%d=7",A,B,C,D);}else if(A-B+C+D==7){
		printf("%d-%d+%d+%d=7",A,B,C,D);}else if(A-B+C-D==7){
		printf("%d-%d+%d-%d=7",A,B,C,D);}else if(A-B-C+D==7){
		printf("%d-%d-%d+%d=7",A,B,C,D);}else if(A-B-C-D==7){
		printf("%d-%d-%d-%d=7",A,B,C,D);}
	
	

 
 
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <math.h>
#include <numeric>
#include <iomanip>
#include <climits>
using namespace std;
int main(){
  int x,y;
  cin >> x >> y;
  int tmp=(y-2*x);
  if((y%2==0)&&(tmp>=0)&&(tmp%2==0)&&(tmp/2<=x))cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int i,j;
int main (){

  ll a,b,c,k,ans;
  ans=0;
  cin >> a >> b >> c >> k;
  if(k<a)
  {
    ans=k;
  }
  else
  {
    ans=a;
    k=k-a;
    if(k>b)
    {
      k=k-b;
      ans=ans-k;
    }
  }
      
 cout << ans << endl;   
}
  
  

Measured memory_bytes: 3620
//#pragma GCC optimize "trapv"
#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rand rng
#define fios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define M_PI 3.14159265358979323846
typedef long long ll;



int main() {
	//fios;
	int n;
	cin >> n;
	vector<int> v;
	for(int i = 0, inp1, inp2; i < n; i++) {
		cin >> inp1 >> inp2;
		if(inp1 == inp2) v.push_back(i);
	}
	bool flg = false;
	for(int i = 0;  i + 2 < (int) v.size(); i++) {
		if(i + 2 < (int) v.size()) {
			if(v[i] + 1 == v[i+1] && v[i+1] + 1 == v[i+2]) {
				flg = true;
				break;
			}
		}
	}
	if(flg) {
		cout << "Yes";
	} else {
		cout << "No";
	}

	cout << endl;

}

Measured memory_bytes: 3628
import java.util.*;

public class Main{
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        sc.close();
        int right = 0;
        int left = 0;

        for(int i = 0; i < N; i++){
            if(S.charAt(i) == ')')
                left++;
            else
                right++;
            if(left > right) {
                System.out.print('(');
                left--;
            } else {
                if(left > 0){
                    right--;
                    left--;
                }
            }
        }
        System.out.print(S);
        for(int i = 0; i < right; i++)
            System.out.print(')');
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
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 qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}



signed main(){

  int n,a,b;
  string str;

  int x, y;
  int d[] = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
  cin >> x >> y;
  cout <<(d[x]==d[y] ? "Yes" : "No") fin;
  return 0;
}



struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;



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

#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vpll vector<pair<ll,ll>>
#define fr(i,k,n) for (ll i = k; i < n; ++i)
#define fri(i,k,n) for (int i = k; i >= n; --i)
#define INF (int)1e9
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define all(arr) arr.begin(),arr.end()

void boost(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

const int N=1e5+5;
ll arr[N];
ll mark[N];

void solve(){
	ll n,x,m;
	cin>>n>>x>>m;
	if(n==1){
		cout<<x<<endl;
		return;
	}
	ll i=2;
	arr[1]=x;
	mark[x]=1;
	ll sum=x;
	vll rem;
	while(i<=n){
		x=(x*x)%m;
		if(x==0){
			cout<<sum<<endl;
			return;
		}
		if(mark[x]!=0){
			for(int j=mark[x];j<i;j++){
				rem.pb(arr[j]);
			}
			i--;
			break;
		}
		sum+=x;
		arr[i]=x;
		mark[x]=i;
		i++;
		if(i>n){
			cout<<sum<<endl;
			return;
		}

	}
	// cout<<i<<endl;
	i=n-i;
	ll temp=0;
	ll sz=rem.size();
	fr(j,0,sz){
		temp+=rem[j];
	}
	ll y=i/(sz);
	sum=sum+(y*temp);
	i=i%(sz);
	fr(j,0,i){
		sum+=rem[j];
	}
	cout<<sum<<endl;
	return;
}

int main()
{
	boost();
	
	int tc=1;
	//cin>>tc;
	while(tc--)
		solve();
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.setf(ios::fixed); cout.precision(20);
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    int n;
    cin >> n;
    vector <int> a(n), b(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    for (int i = 0; i < n; ++i) cin >> b[i];
    for (int i = 0; i < n; ++i) {
        if (a[i] > b[i]) {
            cout << "-1\n";
            return 0;
        }
    }
    ll ans = 0;
    set <int> id;
    for (int i = 0; i < n; ++i) id.insert(i);
    while (!id.empty()) {
        bool fl = false;
        for (int i : id) {
            int x = b[(i - 1 + n) % n] + b[(i + 1) % n];
            if (b[i] - x >= a[i]) {
                fl = true;
                int wl = a[i] + ((b[i] % x) - (a[i] % x) + x) % x;
                ans += (b[i] - wl) / x;
                b[i] = wl;
            }
        }
        if (!fl) {
            cout << "-1\n";
            return 0;
        }
        set <int> nid;
        auto check = [&] (int i) {
            if (b[i] - b[(i - 1 + n) % n] - b[(i + 1) % n] >= a[i]) nid.insert(i);
        };
        for (int i : id) {
            check((i - 1 + n) % n);
            check(i);
            check((i + 1) % n);
        }
        id = nid;
    }
    if (a != b) {
        cout << "-1\n";
        return 0;
    }
    cout << ans << '\n';
}

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

int main() {
    ll N; cin >> N;
    ll A[N];
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    ll ans = 0;
    ans += A[0]/2;
    A[0] = A[0]%2;
    for (int i = 1; i < N; i++)
    {
        if(A[i] == 0) continue;
        A[i] += A[i-1];
        ans += A[i]/2;
        A[i] = A[i]%2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;



int main(){
	int n;
	cin >> n;
	int graph[n+1][n+1];
	for(int i = 0;i <= n;i++){
		for(int j = 0;j <= n;j++){
			graph[i][j] = 0;
		}
	}
	for(int k = 0;k < n;k++){
		int i;
		cin >> i;
		int t;
		cin >> t;
		for(int l = 0;l < t;l++){
			int p;
			cin >> p;
			graph[i][p] = 1;
		}
	}
	for(int i = 1;i <= n;i++){
		for(int j = 1;j <= n;j++){
			if(j != n){
				cout << graph[i][j] << " ";
			}else{
				cout << graph[i][j];
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1200
import sys
sys.setrecursionlimit(10 ** 7)

def main():
    n = int(input())
    s = input()
    cnt = 1
    for i in range(len(s)-1):
        if s[i] == s[i+1]:
            continue
        else:
            cnt += 1
    print(cnt)


if __name__ == '__main__':
        main()


Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String W = (sc.nextLine()).toUpperCase();

		String T = "";
		int count = 0;
		while (true) {
			T = sc.nextLine();
			if (T.equals("END_OF_TEXT")) {
				break;
			}
			String[] str = T.split(" ", -1);
			for (int i = 0; i < str.length; i++) {
				if ((str[i].toUpperCase()).equals(W)) {
					count++;
				}
			}

		}
		System.out.println(count);
	}
}

Measured memory_bytes: 26068
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	string s;
	cin >> s;

	string t = "";
	int sz = s.size();
	int i = sz - 1;
	while (i >= 0) {
		if (i >= 4 && s.substr(i - 4, 5) == "dream") {
			i -= 5;
		}
		else if (i >= 6 && s.substr(i - 6, 7) == "dreamer") {
			i -= 7;
		}
		else if (i >= 4 && s.substr(i - 4, 5) == "erase") {
			i -= 5;
		}
		else if (i >= 5 && s.substr(i - 5, 6) == "eraser") {
			i -= 6;
		} else {
			cout << "NO\n";
			return 0;
		}
	}

	cout << "YES\n";

	return 0;

}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const ll Mod = 998244353;
const int MAX = 510000;
const double PI = 3.14159265358979;
const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i=0; i<N; i++) cin >> a[i];
  int res = 0;
  for (int i=0; i<N; i++) {
    if (i%2==0&&a[i]%2!=0) res++;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include<math.h>

using namespace std;
int main(int argc, char const *argv[])
{
    int N, D;
    cin >> N >> D;

    double ret = (double)N / (double)((D*2)+1);
    cout << ceil(ret) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b) { return *(int *)a - *(int *)b; } /* 1,2,3,4.. */
int des(const void *a, const void *b) { return *(int *)b - *(int *)a; } /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b)
{
  return *(char *)a - *(char *)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b)
{
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)
#define rep(i, n) for (int i = 0; i < n; i++)

int main(void)
{
  int n, a[200001] = {0}, b[200001] = {0};
  scanf("%d", &n);

  int i, j;
  for (i = 1; i <= n; i++)
  {
    scanf("%d", &a[i]);
  }

  int sum, multi, base, balls = 0;
  for (i = n; i > 0; i--)
  {
    sum = 0;
    multi = 2;
    j = i * multi;
    while (j <= n)
    {
      sum += b[j];
      j = i * ++multi;
    }
    b[i] = abs(sum % 2 - a[i]);
    balls += b[i];
  }

  printf("%d\n", balls);
  for (i = 1; i <= n; i++)
  {
    if (b[i])
      printf("%d ", i);
  }
  printf("\n");

  return 0;
}


Measured memory_bytes: 2560
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main{
    static MyReader in = new MyReader();

    public static void main(String[] args) {
        int N, K; {int[] a = in.ii(2); N = a[0]; K = a[1];}
        int[] p = in.ii(N);
        int[] sum = new int[N + 1];
        for(int i = 0; i < N; i++){
            sum[i + 1] = sum[i] + p[i];
        }

        int ans = 0;
        for(int i = 0, M = N - K + 1; i < M; i++){
            ans = Math.max(sum[i + K] - sum[i] + K, ans);
        }
        out.println(ans / 2.0);
    }

    static class MyReader extends BufferedReader {
        char[] cbuf = new char[1 << 10];
        int head = 0;
        int tail = 0;

        MyReader(){
            super(new InputStreamReader(System.in));
        }

        char next() {
            if (head == tail) {
                try {
                    tail = super.read(cbuf, 0, cbuf.length);
                    head = 0;
                } catch (IOException e) {}
            }
            try {
                return cbuf[head++];
            } catch (Exception e) {
                out.println(head + " " + tail);
                return next ();
            }
        }

        void back() {
            head--;
        }

        int i() {
            boolean minus;
            while (true) {
                char c = next();
                if (c != ' ' && c != '\n' && c != '\r') {
                    if (!(minus = c == '-')) back();
                    break;
                }
            }
            int n = 0;
            while (true) {
                int k = next() - '0';
                if (k < 0 || 9 < k) break;
                n = 10 * n + k;
            }
            return minus ? -n : n;
        }

        int[] ii(final int N) {
            int[] a = new int[N];
            for (int j = 0; j < a.length; j++) a[j] = i();
            return a;
        }
    }
}


Measured memory_bytes: 37052
K,A,B=map(int,input().split())
bis=1
if K==1:
  bis+=1
elif A>=B-1 or K-A+1<=0:
  bis+=K
else:
  if (K-(A-1))%2==0:
    bis=A+(B-A)*((K-(A-1))//2)
  else:
    bis=A+(B-A)*((K-(A-1))//2)+1
print(bis)

Measured memory_bytes: 3064
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = Integer.parseInt(sc.next());
			if (n == 0) break;
			int a = 0;
			int min = Integer.MAX_VALUE;
			int max = 0;
			for (int i = 0; i < n; i++) {
				int t = Integer.parseInt(sc.next());
				min = Math.min(min, t);
				max = Math.max(max, t);
				a += t;
			}
			a -= min + max;
			System.out.println(a / (n - 2));
		}
	}
}


Measured memory_bytes: 28040
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int x = Integer.parseInt(sc.next());
        int y = Integer.parseInt(sc.next());
        
        int ans = 0;
        if(x == 1){
            ans += 300000;
        }else if(x == 2){
            ans += 200000;
        }else if(x == 3){
            ans += 100000;
        }
        if(y == 1){
            ans += 300000;
        }else if(y == 2){
            ans += 200000;
        }else if(y == 3){
            ans += 100000;
        }
        if(x == 1 && y == 1){
            ans += 400000;
        }
        
        System.out.println(ans);
    }
}

Measured memory_bytes: 23892
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>

using namespace std;

typedef long long i64;
typedef int int_t;
typedef vector<int_t> vi;
typedef vector<vi> vvi;

typedef pair<int_t, int_t> pi;

#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define REP(s, e, i) for(i=(s); i < (e); ++i)

int main(int argc, char *argv[]) {

  i64 T1, T2, A1, A2, B1, B2;
  cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;

  i64 D1 = A1 - B1;
  i64 D2 = A2 - B2;
  if((D1 > 0 && D2 > 0) || (D1 < 0 && D2 < 0)) {
    cout << 0 << endl;
    return 0;
  }
  if(D1 < D2) {
    D1 *= -1;
    D2 *= -1;
  }

  // D2 < 0 < D1
  i64 L1 = D1 * T1, L2 = - D2 * T2;
  if(L1 == L2) {
    cout << "infinity" << endl;
    return 0;
  }
  if(L1 > L2) {
    cout << 0 << endl;
  }
  else {
    i64 dL = L2 - L1;
    i64 K = L1 / dL;
    if(L1 % dL != 0) {
      K += 1;
      K *= 2;
      K -= 1;
    }
    else {
      K *= 2;
    }    
    
    cout << K << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;


public class Main{
    public  static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
        	while(sc.hasNext()) {
        		long[][] dp=new long[5][4001];
        		int n = sc.nextInt();
        		dp[0][0]=1;
        		for(int i=0; i<4; i++) {//turn
        			int max=i*1000;
        			for(int j=0; j<=max; j++) {//sum
        				for(int k=0; k<=1000; k++) {
        					dp[i+1][j+k]+=dp[i][j];
        				}
        			}
        		}
//        		dfs(sum, turn){
//        			turn++;
//        			if(turn == 4) {
//        				s[sum]++;
//        			}
//        			for(int k=0; k<=1000; i++) {
//        				dfs(sum+k, turn);
//        			}
//        		}
        		System.out.println(dp[4][n]);
        	}
        }
    }
}


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

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

    int cnt=0;
    vector<int> flag(s.size(), 0);
    int i=0;
    while(i < s.size()){
        cnt = 0;
        if(s.at(i)=='R'){
            while(i<s.size() and s.at(i)=='R'){
                i++;
                cnt++;
            }
            flag.at(i-1)+=cnt/2;
            flag.at(i)+=cnt/2;
            if(cnt%2==1) flag.at(i-1)+=1;
        }
        else if(s.at(i)=='L'){
            int j=i;
            while(i<s.size() and s.at(i)=='L'){
                i++;
                cnt++;
            }
            flag.at(j-1)+=cnt/2;
            flag.at(j)+=cnt/2;
            if(cnt%2==1) flag.at(j)+=1;
        }
    }

    rep(i, flag.size()){
            cout << flag.at(i) ;
            if(i!=flag.size())
                cout << ' ';
    }
    
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using ll = long long;
#define rep(i, n) for(ll i = 0; i < n; i++)
using namespace std;

ll modpow(ll a, ll n, ll mod){
  ll res = 1;
  while(n > 0){
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

int main(){
  ll n, m;
  cin >> n >> m;
  cout << modpow(n, m, 1000000007) << endl;
  
  return 0;
}


Measured memory_bytes: 3116
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll;
template<class T>using vv = vector<vector<T>>; template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<class T>bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int n;
    cin >> n;
    vi p(n);
    rep(i, n) cin >> p[i];

    int ans = 0;
    rep(i, 1, n - 1) {
        auto a = { p[i - 1], p[i], p[i + 1] };
        if (p[i] != min(a) && p[i] != max(a)) {
            ans++;
        }
    }
    write(ans);
}

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

int main()

{
    vector<int> nums;
    int input; cin>>input;
    for(int i=0; i<input;i++){
        int n; cin>>n;
        nums.push_back(n);
    }
    double temp=0;
    for(int i=0; i<input;i++){
        temp+=pow(nums[i], -1);
    }
    double result = pow(temp, -1);
    cout<<result<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll H,W;
    cin >> H >> W;
    if(H%3==0 || W%3==0){
        cout << 0 << endl;
        return 0;
    }
    ll ans = INF;
    // Hを3つに分ける場合
    ll a,b,c;
    if(H>2){
        a = H/3;
        b = H/3;
        c = H - a - b;
        if(a==0 || b==0 || c==0);
        else ans = min(ans,abs(c-a)*W);
    }
    // Wを3つに分ける場合
    if(W>2){
        a = W/3;
        b = W/3;
        c = W - a - b;
        if(a==0 || b==0 || c==0);
        else ans = min(ans,abs(c-a)*H);
    }
    for(ll i = 1;i<=(H/2);i++){
        ll aH = i;
        ll Sa = i * W;
        ll bH = H - i ;
        ll cH = bH;
        ll bW = W/2;
        ll cW = W - bW;
        ll Sb = bH * bW;
        ll Sc = cH * cW;
        ll S = max({Sa,Sb,Sc}) - min({Sa,Sb,Sc});
        ans = min(ans,S);
        bH = (H - aH)/2;
        bW = W;
        cH = (H - aH - bH);
        cW = W;
        Sb = bH * bW;
        Sc = cH * cW;
        S = max({Sa,Sb,Sc}) - min({Sa,Sb,Sc});
        ans = min(ans,S);
    }
    swap(H,W);
    for(ll i = 1;i<=(H/2);i++){
        ll aH = i;
        ll Sa = i * W;
        ll bH = H - i ;
        ll cH = bH;
        ll bW = W/2;
        ll cW = W - bW;
        ll Sb = bH * bW;
        ll Sc = cH * cW;
        ll S = max({Sa,Sb,Sc}) - min({Sa,Sb,Sc});
        ans = min(ans,S);
        bH = (H - aH)/2;
        bW = W;
        cH = (H - aH - bH);
        cW = W;
        Sb = bH * bW;
        Sc = cH * cW;
        S = max({Sa,Sb,Sc}) - min({Sa,Sb,Sc});
        ans = min(ans,S);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
def comb(n, r):
    return fact(n) // (fact(r) * fact(n - r))

def fact(n):
    if n < 0:
        return
    if n == 0:
        return 1
    ret = n
    for i in range(n-1, 0, -1):
        ret *= i
    return ret

def main():
    n, p = map(int, input().split())
    A = list(map(int, input().split()))
    AA = [i % 2 for i in A]
    even = AA.count(0)
    odd_cnt = n - even
    ans = 0
    if p:  # oddのとき
        for i in range(odd_cnt + 1):
            if i % 2 != 0:
                ans += comb(odd_cnt, i)
    else:  # evenのとき
        for i in range(odd_cnt + 1):
            if i % 2 == 0:
                ans += comb(odd_cnt, i)
    print(2 ** even * ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <cmath>

using namespace std;

long long MOD = 1000000007;

template<typename T>
void cout_vec(vector<T> &vec){
    for(int i=0; i<vec.size(); i++){
        if (i!=0){
            cout << ' ';
        }
        cout << vec[i];
    }
    cout << endl;
}

template<typename T>
void cout_mat(vector<vector<T> > &mat){
    for(int i=0; i<mat.size(); i++){
        vector<T> vec = mat[i];
        cout_vec(mat[i]);
    }
}

double dijkstra(int s, int g, vector<vector<double > > &path, vector<vector<double> > &distance){
    priority_queue<pair<double, int>, vector<pair<double, int> >, greater<pair<double, int> > > que;

    que.push(make_pair(0., s));
    while((int) que.size()>0){
        int node=que.top().second;
        double dist=que.top().first;
        que.pop();

        if(node==g){
            return dist;
        }

        for(int i=0; (int) i<path[s].size(); i++){
            //cout << path[s][i] << ' ' << dist+path[node][i] << endl;
            if(distance[s][i]>dist+path[node][i]){
                distance[s][i]=dist+path[node][i];
                que.push(make_pair(distance[s][i], i));
            }
        }
    }
}

int main(){
    double x, y, z, w;
    cin >> x >> y >> z >> w;
    int N;
    cin >> N;

    vector<vector<double> > vertex(N+2,vector<double>(3,0));
    vertex[0]={x,y, 0.};
    vertex[N+1]={z, w, 0.};

    for(int i=1; i<=N; i++){
        int x, y, r;
        cin >> vertex[i][0] >> vertex[i][1] >> vertex[i][2];
    }

    vector<vector<double> > path(N+2, vector<double>(N+2, 0));
    for(int i=0; i<N+2; i++){
        for(int j=i; j<N+2; j++){
            double dx = vertex[i][0]-vertex[j][0];
            double dy = vertex[i][1]-vertex[j][1];
            double dr = vertex[i][2]+vertex[j][2];
            path[i][j]=max(0., sqrt(dx*dx+dy*dy)-dr);
            path[j][i]=path[i][j];
        }
    }

    //cout_mat(path);
    vector<vector<double> > distance(N+2,vector<double>(N+2,1.*MOD*MOD));
    cout << setprecision(10) <<dijkstra(0, N+1, path, distance) << endl;

}

Measured memory_bytes: 22124
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  LL W, H, x, y; cin >> W >> H >> x >> y;
  double S = W * H;
  S /= 2;

  if (W % 2 == 1 || H % 2 == 1)
    printf("%.10f %d\n", S, 0);
  else if (W/2 != x || H/2 != y)
    printf("%.10f %d\n", S, 0);
  else
    printf("%.10f %d\n", S, 1);
}


Measured memory_bytes: 3756
k=int(input())
x=k//50
y=k%50
ans=[i+x for i in range(50)]
for i in range(y):
  for j in range(50):
    if ans[j]==x:
      ans[j]+=50
    else:
      ans[j]-=1
for i in range(50):
  ans[i]=str(ans[i])
print(50)
print(' '.join(ans))

Measured memory_bytes: 38512
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
import math
from copy import deepcopy
import queue
#import sympy as syp(素因数分解とか)
Mod = 1000000007
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)

def main():  #startline-------------------------------------------
    a, b, c, k = map(int, input().split())
    ans = 0
    if k < a:
        ans = k
    elif a <= k <=  a + b:
        ans = a
    else:
        ans = a- (k - a-b)
    print(ans)

if __name__ == "__main__":
    main() #endline===============================================

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

result = 0

if a[0] > k:
        result = a[0] -k
        a[0] = k

for i in range(n-1):
    if a[i] + a[i+1] > k:
        result += a[i] + a[i+1] - k #a[i] + a[i+1] -x = k
        a[i+1] = -a[i] + k

print(result)

Measured memory_bytes: 19848
def get_score(medium, final, retry):
    medium_final = medium + final
    if medium == -1 or final == -1:
        return 'F'
    elif 80 <= medium_final:
        return 'A'
    elif 65 <= medium_final:
        return 'B'
    elif 50 <= medium_final:
        return 'C'
    elif 30 <= medium_final:
        if 50 <= retry:
            return 'C'
        else:
            return 'D'
    else:
        return 'F'


data = []
while True:
    [medium, final, retry] = [int(x) for x in raw_input().split()]
    if [medium, final, retry] == [-1, -1, -1]:
        break
    data.append(get_score(medium, final, retry))

for n in data:
    print(n)

Measured memory_bytes: 6364
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vl vector<long long int>
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define vb vector<bool>
#define vvl vector<vector<ll> >
#define vvi vector<vector<int> >
#define pl pair<ll,ll>
#define pb push_back
#define PI 3.14159265
#define mod 998244353
#define pb push_back
#define mp make_pair
#define fri(s,n) for(int i=s;i<n;i++)
#define frj(s,n) for(int j=s;j<n;j++)
#define T(i) int i=1;cin>>i;while(i--)
#define vsi vector<set<int> >
#define pii pair<int,int>
#define inf 1e9
#define vpii vector<pair<int,int> >


ll power(ll a,ll b){
    if(b==0)
        return 1;
    if(b&1)
        return a*power(a,b-1);
    ll temp=power(a,b/2);
    return temp*temp;
    }
bool mycompare(ll a,ll b){
    return a>b;
    }
double dp[301][301][301];
double trials(int x,int y,int z,int n){
    if(x<0 || y<0 || z<0)
        return 0.0;
    if(x==0 && y==0 && z==0)
        return 0.0;
    //cout<<x<<" "<<y<<" "<<z<<"\n";
    if(dp[x][y][z]>-0.1)
        return dp[x][y][z];
    return dp[x][y][z]=(n+x*trials(x-1,y,z,n)+y*trials(x+1,y-1,z,n)+z*trials(x,y+1,z-1,n))/(x+y+z);
    }
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    fast;
    int n;
    cin>>n;
    int x=0,y=0,z=0;
    fri(0,n){
        int temp;
        cin>>temp;
        if(temp==1)
            x++;
        else if(temp==2)
            y++;
        else
            z++;
        }
    memset(dp,-1.0,sizeof dp);
    //vector<vector<vector<double> > > dp(x+1,vector<vector<double> >(y+1,vector<double>(z+1,-1.0)));
    cout<<setprecision(15)<<trials(x,y,z,n);


}


Measured memory_bytes: 216920
// B.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <set>
#include <map>
#include <bitset>

using namespace std;

int main(int argc, char* argv[]) {
#ifdef _MSC_VER
	while (true)
#endif
	{
		int A = -1, B, M, x, y, c, ans = 1 << 30, bm = 1 << 30;
		cin >> A >> B >> M;
		if (A < 0) return 0;
		vector<int> a(A), b(B);
		for (int i = 0; i < A; ++i) {
			cin >> a[i];
			ans = min(ans, a[i]);
		}
		for (int i = 0; i < B; ++i) {
			cin >> b[i];
			bm = min(bm, b[i]);
		}
		ans += bm;
		for (int i = 0; i < M; ++i) {
			cin >> x >> y >> c;
			int cost = a[x - 1] + b[y - 1] - c;
			ans = min(ans, cost);
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 1024
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, gcd, lcm 
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string
#include <vector> // vector
#include <queue> // queue
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <cstdint> // int64_t, int_fast64_t

#define rep(i,n) for(int i = 0; i < n; i++)
#define ENDL "\n"

#define INF 10101010

typedef std::int_fast64_t ll; // at least int64 > 9*10^18
typedef std::uint_fast64_t ull; // at least uint64

struct Edge
{
  int b,c,i;
  Edge() {}
  Edge(int b,int c,int i) : b(b),c(c),i(i) {}
};

struct Node
{
  std::vector<Edge> edges;
};

int n,m;
std::vector<Node> nodes;
std::vector<bool> used;

struct Dijkstra
{
  int s;
  std::vector<int> dist;
  std::vector<int> m_connection;
  std::unordered_set<int> set;
  Dijkstra(int s) : s(s), dist(n,INF), m_connection(n) {
    dist[this->s] = 0;
    rep(i,n) set.emplace(i);
    while(!set.empty()) {
      int next;
      int min = INF;
      for(int i:set) if(dist[i]<min) {
        min = dist[i];
        next = i;
      }
      if(!(next == this->s)) used[m_connection[next]] = true;
      set.erase(next);
      for(Edge e:nodes[next].edges) {
        if(dist[next]+e.c<dist[e.b]) {
          dist[e.b] = dist[next]+e.c;
          m_connection[e.b] = e.i;
        }
      }
    }
  }
};

int main() {
  std::cin >> n >> m;
  nodes.resize(n);
  used.resize(m);
  rep(i,m) used[i] = false;
  rep(i,m) {
    int a,b,c;
    std::cin >> a >> b >> c;
    a--;b--;
    nodes[a].edges.emplace_back(b,c,i);
    nodes[b].edges.emplace_back(a,c,i);
  }
  rep(i,n) {
    Dijkstra d = Dijkstra(i);
  }
  int count = 0;
  rep(i,m) {
    if(used[i] == false) count++;
  }
  std::cout << count << ENDL;

  return 0;
}

Measured memory_bytes: 512
/*
        FFFFFFFFFFFFFFFFFFFFFF
        F::::::::::::::::::::F
        F::::::::::::::::::::F
        FF::::::FFFFFFFFF::::F
          F:::::F       FFFFFF
          F:::::F
          F::::::FFFFFFFFFF
          F:::::::::::::::F
          F:::::::::::::::F
          F::::::FFFFFFFFFF
          F:::::F
          F:::::F
        FF:::::::FF
        F::::::::FF
        F::::::::FF
        FFFFFFFFFFF
*/
#include <bits/stdc++.h>
using namespace std;
#define debug(...) cout<<__FUNCTION__<<":"<<__LINE__<<": ";debugger(#__VA_ARGS__, __VA_ARGS__);
template<typename arg>
void debugger(const char* varname, arg&& var) { cout<<varname<<" = "<<var<<endl; }
template<typename arg, typename... args>
void debugger(const char* varnames, arg&& var, args&&... vars) {
    const char* comma = strchr(varnames + 1, ',');
    cout.write(varnames, comma - varnames)<<" = "<<var<<" | ";
    int sz = 1; if(isspace(comma[sz])) sz++;
    debugger(comma + sz, vars...);
}
#define forr(i, s, n) for(ll i=(ll)(s); i<(ll)(n); ++i)
#define forn(i, n) forr(i, 0, n)
#define eb(n) emplace_back(n)
#define endl '\n'
#define fst first
#define snd second
using ll = long long;
using ii = pair<ll,ll>;
using vi = vector<ll>;
extern const int INF = INT_MAX - 5;
extern const ll LINF = LLONG_MAX - 5;
extern const int MOD = 1e9 + 7;
extern const int N = 2e5 + 200;
int a,b;
int main() {
    cin>>a>>b;
    bool f = false;
    int ans = -1;
    for(int i = 1; i <= 5000; ++i) {
        int p1 = (i * 8) / 100;
        int p2 = (i * 10) / 100;
        if(p1 == a and p2 == b) {
            f = true;
            ans = i;
            break;
        }
    }
    if(!f) puts("-1");
    else cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
ai = lambda: list(map(int, input().split()))

n = int(input())
a = ai()
from collections import Counter
c = Counter(a)
a = [i for i in c if c[i]>1]
a.sort()
if len(a)>0 and c[a[-1]]>=4:
    print(a[-1]**2)
elif len(a)<2:
    print(0)
else:
    print(a[-1]*a[-2])

Measured memory_bytes: 18216
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String [] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
        int rLeft = 0;
        int rRight = 0;
        int [] number = new int[s.length()];
        for (int i = 1; i < s.length(); ++i) {
            if (s.charAt(i) == 'R') {
                if (rLeft == -1) {
                    rLeft = i;
                    rRight = i;
                } else {
                    rRight++;
                }
            } else {
                if (rLeft == -1) {
                    continue;
                }
                int index1 = (rRight - rLeft) % 2 + rRight;
                int index2 = (rRight - rLeft + 1) % 2 + rRight;
                number[index1] += (rRight - rLeft + 1) - (rRight - rLeft + 1) / 2;
                number[index2] += (rRight - rLeft + 1) / 2;


                rLeft = -1;
                rRight = -1;
            }
        }

        int lLeft = s.length() - 1;
        int lRight = s.length() - 1;
        for (int i = s.length() - 2; i >= 0; --i) {
            if (s.charAt(i) == 'L') {
                if (lRight == -1) {
                    lRight = i;
                    lLeft = i;
                } else {
                    lLeft--;
                }
            } else {
                if (lRight == -1) {
                    continue;
                }
                int index1 = lLeft - (lRight - lLeft) % 2 ;
                int index2 = lLeft - (lRight - lLeft + 1) % 2;
                number[index1] += (lRight - lLeft + 1) - (lRight - lLeft + 1) / 2;
                number[index2] += (lRight - lLeft + 1) / 2;

                lLeft = -1;
                lRight = -1;

            }
        }

        for (int i = 0; i < s.length(); ++i) {
            System.out.print(number[i] + " ");
        }
        System.out.println();
    }
}


Measured memory_bytes: 47640
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;
int main() {
	int W, a, b;	cin >> W >> a >> b;
	if (b > W + a) {
		cout << b - W - a << endl;
		cin >> W;
		return 0;
	}
	if (a > W + b) {
		cout << a - W - b << endl;
		cin >> W;
		return 0;
	}
	cout << "0" << endl;
	cin >> W;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;

const int MAX = 26;
int cnt[MAX];

struct Trie{
	Trie *po[26];
	vector <ll> v;
	ll cnt = 0;
};
Trie* newNode()
{
	Trie* node = new Trie();
	node -> cnt = 0;
	node -> v.resize(26); 
	for(int i = 0; i < 26; i++) {
		node -> po[i] = NULL;
		node -> v[i] = 0;
	}
	return node;
}
void insert(Trie *root, string &s, int ind, vector<vector <int> > &w)
{
	if(ind == s.size()) return;
	int x = s[ind] - 'a';
	
	if(root -> po[x] == NULL) root -> po[x] = newNode();
	root -> po[x] -> cnt++;
	for(int i = 0; i < 26; i++)
	root -> po[x] -> v[i] += (w[ind][i] > 0);
	
	insert(root -> po[x], s, ind + 1, w);
}

ll qry1(Trie *root, string &s, int ind)
{
	if(ind == s.size()) return root -> cnt;
	
	int x = s[ind] - 'a';
	if(root -> po[x] == NULL) return 0;
	return qry1(root -> po[x], s, ind + 1);
}

ll qry2(Trie *root, string &s, int ind, int req)
{
	if(ind == s.size() - 1) return root -> v[req];
	
	int x = s[ind] - 'a';
	if(root -> po[x] == NULL) return 0;
	return qry2(root -> po[x], s, ind + 1, req);
}

int main()
{
	boost;
	int n, i;
	cin >> n;
	vector <string> v(n);
	
	string s;
	fo(i, 0, n) {
		cin >> s;
		reverse(all(s));
		v[i] = s;
	}

	sort(all(v), [&](string &s1, string &s2){if(s1.size() == s2.size()) return s1 < s2; return s1.size() > s2.size();});
	Trie *root = newNode();
	
	ll ans = 0;
	fo(i, 0, n) {
		if(v[i].size() > 1) {
			ll res = qry1(root, v[i], 0);
			ans += res;
			ans += qry2(root, v[i], 0, v[i].back() - 'a') - res;
		}
		else 
		ans += cnt[v[i][0] - 'a'];

		s = v[i];
		int x = s.size();
		vector <vector <int> > w(x, vector <int> (26, 0));
		for(char c : s)
		w[0][c - 'a']++;
		
		bool done[26];
		memset(done, 0, sizeof done);
		
		for(char c : s) {
			if(!done[c - 'a']) {
				done[c - 'a'] = 1;
				cnt[c - 'a']++;
			}
		}
		
		for(int j = 0; j < s.size(); j++) {
			if(j) w[j] = w[j - 1];
			w[j][s[j] - 'a']--;
		}
		
		insert(root, s, 0, w);
	}
	cout << ans;
}


Measured memory_bytes: 589428