akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#pragma GCC optimize ("-O3")

using namespace std;

#define DEBUG_IS_VALID

#ifdef DEBUG_IS_VALID
#define DEB 1 
#else
#define DEB 0
#endif
#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}
void _main();
int main(){ cin.tie(0); ios::sync_with_stdio(false); _main(); return 0;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

const int mod=1e9+7,INF=1<<29;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<59; 

void _main() {
  int N; cin >> N ;
  vi a(N);
  rep(i,N) cin >> a[i] ;
  bool ok = true;
  rep(i,N) ok &= (a[i]%2==0);
  cout << (ok ? "second":"first") << endl;  
}

Measured memory_bytes: 640
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);

  int n;
  cin>>n;
  std::vector<int> h(n);
  for(int i=0;i<n;i++){
    cin>>h[i];
  }
  int result=0;
  int tmp=0;
  for(int i=0;i<n-1;i++){
    if(h[i]>=h[i+1]){
      tmp++;
    }else{
      result=std::max(result,tmp);
      tmp=0;
    }
  }
  result=std::max(result,tmp);

  cout<<result<<endl;



  return 0;
}


Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;



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

    map<string, int>r;
    string p;
    int a = -1;
    vector<string>x;
    for (int i = 0; i < n; i++) {
        cin >> p;
        r[p]++;
       
        if (a == r[p])x.push_back(p);
        if (a < r[p]) {
            x.clear();
            a = r[p];
            x.push_back(p);
        }
    }
    sort(x.begin(), x.end());
    for (int i = 0; i < x.size(); i++) {
        cout << x[i] << endl;
    }


    return 0;

}

Measured memory_bytes: 26736
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>

using namespace std;

using ull_t = unsigned long long;

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

    vector<int> A(N, 0);
    for (auto &a : A)
        cin >> a;

    sort(A.begin(), A.end(), greater<int>());

    int sum = 0;
    for (auto a : A) sum += a;

    bool f = ((double)A.at(M - 1) >= ((double)sum / (4.0 * M)));
    cout << (f ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
a, b, c, x, y = map(int, input().split())

ans = float('inf')
for i in range(10 ** 5 + 1):
    price = i * 2 * c
    if x > i:
        price += a * (x - i)
    if y > i:
        price += b * (y - i)
    ans = min(ans, price)

print(ans)


Measured memory_bytes: 8972
#include <cmath>
#include <cstdio>

int main() {
  int n, sum = 0;
  bool b = true;
  scanf("%d", &n);
  int t[n + 1], x[n + 1], y[n + 1];
  t[0] = 0;
  x[0] = 0;
  y[0] = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d%d%d", &t[i], &x[i], &y[i]);
  }
  for (int i = 1; i <= n; i++) {
    int T = t[i] - t[i - 1];
    T -= std::abs(x[i] - x[i - 1]);
    T -= std::abs(y[i] - y[i - 1]);
    if (t[i] < (x[i] + y[i])) {
      b = false;
      break;
    }else if (T % 2) {
      b = false;
      break;
    }
  }
  printf(b ? "Yes\n" : "No\n");
  return 0;
}


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

int main()
{

  int N;
  cin >> N;
  int m = N;
  int ans = 0;
  for (int i = 0; i < N; i++)
  {
    if (m > 0)
    {
      m -= 2;
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename T> void vdeb(T v){
    cout << "#vector set debug" << endl;
    for(auto vv : v) cout << vv << " ";
    cout << endl;
}
template<typename T1, typename T2> void adeb(T1 arr[], T2 n){
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}
template<typename T1> void mdeb(T1 mp){
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
void ans(bool b){ cout << (b ? "Yes" : "No") << endl; }
void ans2(bool b){ cout << (b ? "YES" : "NO") << endl; }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};


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

    int n, a[110];
    cin >> n;
    rep(i, n){
        cin >> a[i];
    }

    int cnt=0;
    rep(i, n-1){
        if(a[i] == a[i+1]){
            a[i+1] = 0;
            cnt++;
        }
    }

    cout << cnt << endl;

    return 0;
}


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

int main(int argc, char const *argv[])
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if (a+b>c+d)
	{
		cout<<"Left\n";
	}
	else if (a+b==c+d)
	{
		cout<<"Balanced\n";
	}
	else
	{
		cout<<"Right\n";
	}
	return 0;
}


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

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

  int x = 0;
  int maxi = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'I') {
      x++;
    } else {
      x--;
    }
    maxi = max(maxi, x);
  }

  cout << maxi << endl;

  return 0;
}


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

using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, x;
	int l[1500000];
	int first=0, last=0;
	string com;
	cin>>n;
	for(int i=0; i<n; i++) {
		cin>>com;
		if(com=="insert") {
			cin>>x;
			l[last++]=x;
		} else if(com=="delete") {
			cin>>x;
			for(int j=last-1; j>=first; j--) {
				if(l[j]==x) {
					l[j]=-1;
					break;
				}
			}
		} else if(com=="deleteFirst") {
			while(l[last-1]==-1) --last;
			--last;
		} else if(com=="deleteLast") {
			while(l[first]==-1) ++first;
			++first;
		}
	}

	while(l[first]==-1) ++first;
	while(l[last-1]==-1) --last;
	if(first<last) {
		cout<<l[last-1];
		for(int i=last-2; i>=first; i--) {
			if(l[i]!=-1) cout<<' '<<l[i];
		}
		cout<<'\n';
	}
	return 0;
}



Measured memory_bytes: 7020
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		if(a==b+c||a+b==c||a+c==b){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}

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

using namespace std;
using vi = vector<int>;

int main()
{
    int n; cin >> n;
    vi a(n), b(n), ind_a(n + 1, -1), sum(n + 1);
    int k = 0;
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        ind_a[a[i]] = i;
        sum[a[i]]++;
    }
    for(int i = 0; i < n; ++i){
        cin >> b[i];
        if((!i || b[i] != b[i - 1]) && ind_a[b[i]] != -1){
            k = max(k, ind_a[b[i]] - i + 1);
        }
        sum[b[i]]++;
    }
    for(int i = 0; i <= n; ++i){
        if(sum[i] > n){
            cout << "No";
            return 0;
        }
    }
    cout << "Yes\n";
    for(int i = n - k; i < n; ++i){
        cout << b[i] << " ";
    }
    for(int i = 0; i < n - k; ++i)
        cout << b[i] << " ";
    return 0;
}


Measured memory_bytes: 6384
n = int(input())

s = [input() for _ in range(n)]
ac = 0
wa = 0
tle = 0
re = 0

for i in range(n):
	if s[i] == 'AC':
		ac += 1
	elif s[i] == 'WA':
		wa += 1
	elif s[i] == 'TLE':
		tle += 1
	elif s[i] == 'RE':
		re += 1

print("AC x " + str(ac))
print("WA x " + str(wa))
print("TLE x " + str(tle))
print("RE x " + str(re))

Measured memory_bytes: 16268
#include<bits/stdc++.h>
using namespace std;
#define ll int64_t
#define rep(i,n) for(int64_t i=0;i<n;++i)
#define P pair<ll,ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr int64_t INF=(1ll<<60);
constexpr int64_t mod=1000000007;
constexpr double pi=3.14159265358979323846;
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    vector<vector<ll>> a(3,vector<ll>(3));
    rep(i,3){
        rep(j,3){
            cin>>a[i][j];
        }
    }
    ll n;cin>>n;
    
    rep(i,n){
        ll b;cin>>b;
        rep(j,3){
            rep(l,3){
                if(a[j][l]==b) a[j][l]=-1;
            }
        }
    }

    bool check=false;
    rep(i,3){
        bool hai=true;
        rep(j,2){
            if(a[i][j]!=a[i][j+1]) hai=false;
        }
        if(hai==true){
            check=true;
            break;
        }
    }

    rep(i,3){
        bool hai=true;
        rep(j,2){
            if(a[j][i]!=a[j+1][i]) hai=false;
        }
        if(hai==true){
            check=true;
            break;
        }
    }

    if(a[0][0]==a[1][1] && a[1][1]==a[2][2]){
        check=true;
    }
    if(a[0][2]==a[2][0] && a[1][1]==a[0][2]){
        check=true;
    }

    if(check) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
    ll X;
    cin >> X;

    ll a = X/500;
    ll ans = a*1000+(X-a*500)/5*5;
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# みんなのプロコン 2019：B - Path


def main():
    p = {}
    for _ in range(3):
        A, B = [int(i) for i in raw_input().strip().split(' ')]
        if A in p:
            p[A] += 1
        else:
            p[A] = 1
        if B in p:
            p[B] += 1
        else:
            p[B] = 1
    l = p.values()
    if 3 in l:
        print 'NO'
    else:
        print 'YES'


if __name__ == '__main__':
    main()


Measured memory_bytes: 2568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int MX = 1e3;
const ll INF = 1e18L + 10;

void minVal(ll& a, ll b) {
	a = min(a, b);
}
void maxVal(ll& a, ll b) {
	a = max(a, b);
}

void solve() {
	ll n, w, tot = 0, res = 0; cin >> n >> w;
	vector<ll> W(n), V(n);
	for (int i = 0; i < n; ++i) {
		cin >> W[i] >> V[i];
		tot += V[i];
	}
	vector<ll> dp(tot + 1, INF);
	dp[0] = 0;
	for (int i = 0; i < n; ++i) {
		for (int j = tot; j >= V[i]; --j) {
			minVal(dp[j], dp[j - V[i]] + W[i]);
		}
		// for (auto val : dp) cout << val << "\t"; cout << "\n";
	}
	for (ll i = 0; i <= tot; ++i) {
		if (dp[i] <= w) {
			maxVal(res, (ll) i);
		}
	}
	cout << res;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
	// #ifndef ONLINE_JUDGE
	//     freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
	// #endif
	solve();
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

int n, m, q;
vector<P> dist(100010);
vector<vector<P>> G(100010);

void dijkstra(int s){
    for(int i=0; i<n; i++) dist[i] = P(1e9, 1e9);

    priority_queue<T, vector<T>, greater<T>> que;
    dist[s] = P(0, q);
    que.push(T(0, s, q));

    while(!que.empty()){
        int ccost, cv, cyear;
        tie(ccost, cv, cyear) = que.top();
        que.pop();

        if(ccost == dist[cv].fs){
            if(dist[cv].sc > cyear) continue;
        }

        //if(dist[cv].fs < ccost) continue;

        for(auto x : G[cv]){
            int nv, nyear;
            tie(nv, nyear) = x;

            int nnyear = min(nyear, cyear);
            int ncost = ccost + 1;

            if(ncost == dist[nv].fs){
                if(dist[nv].sc < nnyear){
                    dist[nv] = P(ncost, nnyear);
                    que.push(T(dist[nv].fs, nv, nnyear));
                }
            }
            else if(ncost < dist[nv].fs){
                dist[nv] = P(ncost, nnyear);
                que.push(T(dist[nv].fs, nv, nnyear));
            }
        }
    }
}

int main(){
    cin>>n>>m>>q;
    vector<int> u(m), v(m);
    for(int i=0; i<m; i++){
        cin>>u[i]>>v[i];
        u[i]--, v[i]--;
    }

    vector<int> changeYear(m, q);
    for(int i=0; i<q; i++){
        int r; cin>>r;
        r--;
        changeYear[r] = i;
    }

    for(int i=0; i<m; i++){
        G[u[i]].eb(P(v[i], changeYear[i]));
        G[v[i]].eb(P(u[i], changeYear[i]));
    }

    dijkstra(0);

    vector<int> cnt(q+1);
    for(int i=0; i<n; i++){
        cnt[dist[i].sc]++;
    }

    for(int i=0; i<q; i++){
        if(0 < i) cnt[i] += cnt[i-1];
        cout << cnt[i] << endl;
    }
}


Measured memory_bytes: 15528
import java.util.*;
public class Main{
	public static void main(String args[]){
		
		Scanner ob = new Scanner(System.in);
		int N = ob.nextInt();
		int M = ob.nextInt();
		int R = 0;

		int[] array = new int[M];
		for(int i = 0; i < M; i++){
			array[i] = ob.nextInt();
		}

		for(int j = 0; j < M; j++){
			R += array[j]; 
		}

		if((N - R) < 0){
			System.out.println(-1);
		}
		else{
			System.out.println(N - R);
		}
	}
}


Measured memory_bytes: 37876
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        
        int A = sc.nextInt();
        int B = sc.nextInt();
        String S = sc.next();
        
        if(S.substring(0,A).contains("-")){
            System.out.println("No");
            return;
        }
        if(!(S.substring(A,A + 1).contains("-"))){
            System.out.println("No");
            return;
        }
        if(S.substring(A + 1, A + B + 1).contains("-")){
            System.out.println("No");
            return;
        }
        System.out.println("Yes");
    }
}


Measured memory_bytes: 22740
#include <bits/stdc++.h>
#define MOD 998244353
using namespace std;
typedef long long ll;
int main()
{
	int n, lst = 0;
	cin >> n;
	vector<int> arr(n);
	copy(istream_iterator<int>(cin), istream_iterator<int>(), arr.begin());
	vector<pair<int, int> > bel(n + 1, { -1, -1});
	arr.push_back(arr[0]);
	for (int i = 1; i <= n; i++) {
		if (arr[i] == arr[i - 1]) {
			continue;
		}
		auto &val = bel[arr[i - 1]];
		if (~val.second) {
			cout << 0 << endl;
			return 0;
		}
		val = {lst, i - 1};
		lst = i;
	}
	if (arr[n - 1] == arr[n]) {
		bel[arr[n]].first = lst;
	}
	if (!lst) {
		ll ans = arr[0] == 1;
		for (int i = 1; i <= n; i++) {
			ans = ans * i % MOD;
		}
		cout << ans << endl;
		return 0;
	}
	if (-1 == bel[1].second) {
		cout << 0 << endl;
		return 0;
	}
	auto calc = [&] (auto & rg) { return rg.second - rg.first + (rg.first <= rg.second ? 1 : n + 1); };
	int lim = calc(bel[1]), rem = 0;
	ll ans = 1;
	for (int i = 1; i <= n; i++) {
		if (-1 == bel[i].second) {
			ans = ans * rem-- % MOD;
		} else {
			int l = bel[i].first, r = bel[i].second, len = calc(bel[i]);
			int sum = (arr[r + 1] < i) + (arr[l - 1 + (!l ? n : 0)] < i);
			if (len > lim || (!sum && len != lim)) {
				cout << 0 << endl;
				return 0;
			}
			if (sum == 1) {
				rem += len - 1;
			} else if (sum == 2) {
				rem += lim + len - 2;
				ans = ans * (lim - len + 1) % MOD;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6144
#include<stdio.h>
int main ()
{
	int a,b=0,sum=0,i,z;
	float p;
	scanf("%d",&a);
	int x[a];
	for(i=0;i<a;i++)
    {
        scanf("%d",&x[i]);
        sum=sum+x[i];
    }
    p=(float)sum/(float)a;
    z=p;
    p=p-z;
    if(p>0.5)
    {
        z++;
    }
    for(i=0;i<a;i++)
    {
        x[i]=x[i]-z;
        b=b+(x[i]*x[i]);
    }
    printf("%d\n",b);
 
 
	return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<cstdlib>
#include<iomanip>
#include<queue>
#include<set>
#include <valarray>
#include<stack>
#include<sstream>
#include<math.h>
     
using namespace std;
 
//pay attention to relative position
class Dice
{
    public: 
    int temp1;
    int temp2;
    int a[100];
      
   // Dice(int top, int south, int east, int west, int north, int bottom)
    //{        
       // a[1] = top;
       // a[2] = south;
      //  a[3] = east;
      //  a[4] = west;
      //  a[5] = north;
     //   a[6] = bottom;
  //  }
      
    void RollS()
    {
            temp1 = a[1];
            temp2 = a[2];
            a[1] = a[5];
            a[2] = temp1;
            a[5] = a[6];
            a[6] = temp2;
    }
      
     void RollN()
    {
            temp1 = a[1];
            temp2 = a[5];
            a[1] = a[2];
            a[2] = a[6];
            a[5] = temp1;
            a[6] = temp2;   
    }
      
     void RollW()
    {
            temp1 = a[1];
            temp2 = a[4];
            a[1] = a[3];
            a[3] = a[6];
            a[4] = temp1;
            a[6] = temp2;
    }
      
     void RollE()
    {
            temp1 = a[1];
            temp2 = a[3];
            a[1] = a[4];
            a[3] = temp1;
            a[4] = a[6];
            a[6] = temp2;
    }
     
    void Spin()  //??¨?????????¬?????????????
    {
        temp1 = a[2];
        temp2 = a[4];
        a[2] = a[3]; 
        a[3] = a[5];
        a[4] = temp1;
        a[5] = temp2;
    }
};
  
void Solution()
{    
    Dice p1, p2;
       
    for(int i = 1; i <= 6; i++)
    {
        cin>>p1.a[i];
    }
     
    for(int i = 1; i <= 6; i++)
    {
        cin>>p2.a[i];
    }
      
    //Dice p1(a[1], a[2], a[3], a[4], a[5], a[6]); 
 
          
    if(p1.a[4] == p2.a[1] || p1.a[3] == p2.a[1]) {p1.RollE();}
     
    for(int i = 0; i < 4; i++)
    {
        if(p1.a[1] == p2.a[1]) break;
        p1.RollN(); // spin based on x axis
    }
    //after ensure the a[1] == b[1], there is a[2] left
    for(int i = 0; i < 4; i++)
    {
        if(p1.a[2] == p2.a[2]) break;
        p1.Spin(); // spin based on y axis
    }
     
    if(p1.a[1] == p2.a[1] &&
      p1.a[2] == p2.a[2] &&
      p1.a[3] == p2.a[3] &&
      p1.a[4] == p2.a[4] &&
      p1.a[5] == p2.a[5] &&
      p1.a[6] == p2.a[6])
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
             
               
}
     
int main()
{
    Solution();
    return 0;
}

Measured memory_bytes: 1156
require "set"
x = gets.chomp.to_i

MAX = 10 ** 5 + 1000
set = Set.new
2.upto(Math.sqrt(MAX)) do |i|
  next if set.include?(i)
  tmp = i * 2
  while tmp <= MAX do
    set << tmp
    tmp += i
  end
end

x.upto(MAX) do |i|
  unless set.include?(i)
    puts i
    exit
  end
end


Measured memory_bytes: 19224
#include <stdio.h>
int main(void){
    int n,i,cnt=0;
    scanf("%d",&n);
    char s[n+1];
    scanf("%s",s);
    for(i=0;i<n-2;i++){
        if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C') cnt++;
    }
    printf("%d",cnt);
    return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] fArr = new int[n];
		for (int i = 0; i < n; i++) {
		    for (int j = 0; j < 10; j++) {
		        fArr[i] *= 2;
		        fArr[i] += sc.nextInt();
		    }
		}
		int[][] pArr = new int[n][11];
		for (int i = 0; i < n; i++) {
		    for (int j = 0; j <= 10; j++) {
		        pArr[i][j] = sc.nextInt();
		    }
		}
		int max = Integer.MIN_VALUE;
		for (int target = 1; target < Math.pow(2, 10); target++) {
		    int sum = 0;
		    for (int i = 0; i < n; i++) {
		        int result = fArr[i] & target;
		        int count = 0;
		        while(result > 0) {
		            count += result % 2;
		            result /= 2;
		        }
		        sum += pArr[i][count];
		    }
		    max = Math.max(max, sum);
		}
       System.out.println(max);
	}
}


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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	long long a, b;
	cin >> a >> b;
	if ((a+b) % 2 == 0) cout << (a+b) / 2 << '\n';
	else cout << "IMPOSSIBLE" << '\n';
	return 0;
}

Measured memory_bytes: 3524
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
	cin>>n>>k;
	int arr[n];
	for(int i=0;i<n;i++)
	cin>>arr[i];

	bool dp[k+1];
	dp[0]=false;
	for(int i=1;i<=k;i++)
	{
		bool flag=false;
		for(int j=0;j<n;j++)
		{
			if(i-arr[j]>=0)
			{
				if(dp[i-arr[j]]==false)
				flag=true;
			}
		}
		dp[i]=flag;
	}

	string ans=(dp[k]==true)?"First":"Second";
	cout<<ans;
    return 0;
}

Measured memory_bytes: 384
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 lower_bound(d,a,b,e){for(var c;1<b-a;)d[c=0|(a+b)>>1]<e?a=c:b=c;return d[a]<e?b:a};

console.log(main());
function main(){
  var n = o.a();
  var l = o.l();
  l.sort((a,b)=>a-b);
  var ans = 0;
  for(var i = 1; i < n-1; i++){
    for(var j = 0; j < i; j++){
      ans += lower_bound(l,i+1,n,l[j]+l[i])-i-1;
    }
  }
  return ans;
}

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

long long A, B, C, X, Y, ans;
vector<long long> p, q, r;
int main() {
	cin >> X >> Y >> A >> B >> C;
	for (int i = 0; i < A; i++) {
		long long temp;
		cin >> temp;
		p.push_back(temp);
	}
	for (int i = 0; i < B; i++) {
		long long temp;
		cin >> temp;
		q.push_back(temp);
	}
	for (int i = 0; i < C; i++) {
		long long temp;
		cin >> temp;
		r.push_back(temp);
	}
	sort(p.begin(), p.end());
	sort(q.begin(), q.end());
	sort(r.begin(), r.end());
	int count = 0;
	while (X + Y > count) {
		int maxi;
		if (X == 0) {
			maxi = max(q.back(), r.back());
		} else if (Y == 0) {
			maxi = max(p.back(), r.back());
		} else {
			maxi = max(p.back(), max(q.back(), r.back()));
		}
		if (maxi == p.back()) {
			ans += p.back();
			p.pop_back();
			X--;
		} else if (maxi == q.back()) {
			ans += q.back();
			q.pop_back();
			Y--;
		} else {
			ans += r.back();
			r.pop_back();
			count++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

#define ll 			long long
#define db			double
#define up(i,j,n)		for (int i = j; i <= n; i++)
#define down(i,j,n)	for (int i = j; i >= n; i--)
#define cadd(a,b)		a = add (a, b)
#define cpop(a,b)		a = pop (a, b)
#define cmul(a,b)		a = mul (a, b)
#define pr			pair<int, int>
#define fi			first
#define se			second
#define SZ(x)		(int)x.size()
#define bin(i)		(1 << (i))
#define Auto(i,node)	for (int i = LINK[node]; i; i = e[i].next)

template<typename T> inline bool cmax(T & x, T y){return y > x ? x = y, true : false;}
template<typename T> inline bool cmin(T & x, T y){return y < x ? x = y, true : false;}

const int MAXN = 1e4 + 5;

int N, a[2][MAXN], cnt[2], x, y;
bitset<(MAXN << 1)> S;
char s[MAXN];

bool vaild(int o, int M) {
	if (abs(M) > N) return 0; 
	S.reset();
	S.set(N);
	up (i, 1, cnt[o]) S = (S << a[o][i]) | (S >> a[o][i]);
	return S[N + M];
}

int main(){
	scanf("%s", s + 1);
	N = strlen(s + 1);
	int pos = 0, cur = 0;
	s[N + 1] = 'T';
	up (i, 1, N + 1) if (s[i] == 'T') {
		a[cur][++cnt[cur]] = i - pos - 1;
		cur ^= 1;
		pos = i;
	}
	scanf("%d%d", &x, &y);
	if (s[1] == 'F') {
		x -= a[0][1];
		a[0][1] = 0;
	}
	if (vaild(0, x) && vaild(1, y)) puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 256
package main

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

func max(a, b int) int {
  if a > b {
    return a
  } else {
    return b
  }
}
func min(a, b int) int {
  if a > b {
    return b
  } else {
    return a
  }
}

func main() {
    r := bufio.NewReader(os.Stdin)
    wr := bufio.NewWriter(os.Stdout)
    defer wr.Flush()

    var(
      h int
      w int
    )
    fmt.Fscan(r, &h, &w)
    s := make([][]byte, h)
    for i := 0; i < h; i++ {
      s[i] = make([]byte, w)
      fmt.Fscan(r, &s[i])
    }
    for i := 0; i < h; i++ {
      for j := 0; j < w; j++ {
        ans := 0
        for x := max(i - 1, 0); x < min(i + 2, h); x++ {
          for y := max(j - 1, 0); y < min(j + 2, w); y++ {
            if x == i && y == j {
              continue
            } else if s[x][y] == '#' {
              ans++
            }
          }
        }
        if s[i][j] == '#' {
          fmt.Fprint(wr, "#")
        } else {
          fmt.Fprint(wr, ans)
        }
      }
      fmt.Fprintln(wr)
    }
}


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

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

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

    int x,a,b;cin>>x>>a>>b;
    if(abs(x-a)<=abs(x-b)) cout<<"A"<<endl;
    else cout<<"B"<<endl;

}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int s;
    cin>>s;
    int h,m,t;
    h=s/3600;
    m=(s%3600)/60;
    t=(s%3600)%60;
    cout<<h<<':'<<m<<':'<<t<<endl;
}



Measured memory_bytes: 3096
n,m = map(int,input().split())

if n*m == 1:
    print(1)
elif n*m == 2:
    print(0)
elif min(n,m) == 1:
    print(max(n,m)-2)
elif min(n,m) == 2:
    print(0)
else:
    print((n-2)*(m-2))



Measured memory_bytes: 38256
import java.util.ArrayList;
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int m = in.nextInt();
		@SuppressWarnings("unchecked") ArrayList<Integer>[] jobs = new ArrayList[m + 1]; // 遅延日数ごとに仕事をグルーピングする
		for ( int i = 0; i <= m; i++ ) {
			ArrayList<Integer> a = new ArrayList<>();
			a.add(0); // ダミー要素
			jobs[i] = a;
		}

		for ( int i = 0; i < n; i++ ) {
			int d = in.nextInt();
			int f = in.nextInt();
			if ( d > m ) continue; // 遅延日数的に候補になりえない仕事は除外
			jobs[d].add(f);
		}

		long total = 0;
		PriorityQueue<Integer> pool = new PriorityQueue<Integer>(Collections.reverseOrder()); // job候補のプール
		// pool.add(0); // ダミー

		// m日目をゼロとして考え後退していく days:残り日数
		for ( int today = 0; today <= m; today++ ) {
			pool.addAll(jobs[today]);
			total += (long)pool.poll();
		}

		System.out.println(total);
		in.close();
	}
}


Measured memory_bytes: 101244
#include <math.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using namespace std;

int main() {
  int A, B;
  cin >> A >> B;

  cout << ceil( (double)(B-1)/(A-1) ) << endl;

  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.IO;

class Program
{
    private static long Solve(int x, int y)
    {
        int x1 =  x;
        int x2 = -x;
        int y1 =  y;
        int y2 = -y;
        int ans = int.MaxValue;
        if (x1 <= y1) { ans = Math.Min(y1 - x1 + 0, ans); }
        if (x1 <= y2) { ans = Math.Min(y2 - x1 + 1, ans); }
        if (x2 <= y1) { ans = Math.Min(y1 - x2 + 1, ans); }
        if (x2 <= y2) { ans = Math.Min(y2 - x2 + 2, ans); }
        return ans;
    }
    static void Main(string[] args)
    {
        int[] values = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        Console.WriteLine(Solve(values[0], values[1]));
    }
}


Measured memory_bytes: 2776
#include<iostream>
#include<math.h>
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	int B = b;
	int ab = 0;
	int n = 0;
	while (B > 0) {
		B = B / 10;
		n++;
	}
	ab = a * pow(10, n) + b;
	int rec = 1;
	for (int i = 0; i < 1000; i++) {
		if (i * i == ab) {
			cout << "Yes" << endl;
			rec = 0;
			break;
		}
	}
	if (rec == 1) {
		cout << "No" <<  endl;
	}
	return 0;
}

Measured memory_bytes: 3976
#include <cstdio>
#include <vector>
#include <algorithm>

std::vector<long long> divisor(long long n)
{
  std::vector<long long> r;
  for (long long i = 1; i * i <= n; i++)
  {
    if (n % i == 0)
    {
      r.emplace_back(i);
      if(i * i != n) r.emplace_back(n / i);
    }
  }
  std::sort(r.begin(), r.end());
  return r;
}

int main()
{
  long long n, m;
  scanf("%lld %lld", &n, &m);
  
  long long ans = 1;
  auto ds = divisor(m);
  for (auto d : ds)
  {
    if (n <= m / d)
    {
      if (ans < d) ans = d;
    }
  }
  printf("%lld\n", ans);
  return 0;
}

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

using namespace std;

int main() {
    string w, t;
    int32_t count = 0;

    cin >> w;

    transform(w.cbegin(), w.cend(), w.begin(), ::tolower);

    while (cin >> t) {
        transform(t.cbegin(), t.cend(), t.begin(), ::tolower);
        if (w == t) {
            count++;
        }
    }

    cout << count << endl;

    return 0;
}

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

void trace(int A[], int N){
    int i;
    for (i=0; i<N; i++){
        if (i > 0) {
            cout << " ";
        }
        cout << A[i];
    }
    cout << endl;
}
void insertionSort(int A[], int N){
    int j, i, v;
    for (i = 1; i < N; i++){
        v = A[i];
        j = i - 1;
        while (j >= 0 && A[j] > v){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        trace(A, N);
    }
}

int main(){
    int N, i, j;
    int A[100];
    
    cin >> N;
    for (i=0; i<N; i++){
        cin >> A[i];
    }
    trace(A, N);
    insertionSort(A, N);
    
    return 0;
}





Measured memory_bytes: 3096
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


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

    int N;
    map< string, int > mp;
    cin >> N;

    string s;
    int M = 0;
    rep (i, N)
    {
        cin >> s;
        ++mp[s];
        M = MAX(M, mp[s]);
    }

    for (auto a : mp)
    {
        if (a.second == M)
        {
            cout << a.first << "\n";
        }
    }

    return 0;
}



Measured memory_bytes: 23808
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <algorithm>

using namespace std;

int main() {

  long long H, W, N;
  vector<int> a, b;
  cin>>H>>W>>N;

  for(int k=0; k<N; k++){
    int ta, tb;
    cin>>ta>>tb;
    a.push_back(ta);
    b.push_back(tb);
  }

  map<pair<int, int>, int> m;
  for(int k=0; k<N; k++){
    for(int i=a[k]-2; i<=a[k]; i++){
      for(int j=b[k]-2; j<=b[k]; j++){
        if(i < 1 || H < i+2 || j < 1 || W < j+2) continue;
        m[make_pair(i,j)]++;
      }
    }
  }

  int ans[9] = {};
  map<pair<int, int>, int>::iterator it = m.begin();
  while(it != m.end()){
    ans[(*it).second - 1]++;
    it++;
  }

  cout<<(W-2)*(H-2) - m.size()<<endl;
  for(int i=0; i<9; i++){
    cout<<ans[i]<<endl;
  }

  return 0;
}


Measured memory_bytes: 57332
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import defaultdict, Counter
from bisect import *

setrecursionlimit(10**7)

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

class union_find:
  def __init__(self, n, X):
    self.par = [-1] * n
    self.rank = [0] * n
    self._count = [0] * n
    self._sum = list(X)

  def __repr__(self):
    return "union_find({0})".format([self.root(i) for i in range(n)])

  def unite(self, x, y):
    x = self.root(x)
    y = self.root(y)
    self._count[x] += 1
    if x == y:      
      return
    if self.rank[x] < self.rank[y]:
      self.par[x] = y
      self._count[y] += self._count[x]
      self._sum[y] += self._sum[x]
    else:
      self.par[y] = x
      self._count[x] += self._count[y]
      self._sum[x] += self._sum[y]
      if self.rank[x] == self.rank[y]:
        self.rank[x] += 1

  def reset_count(self, x):
    x = self.root(x)
    self._count[x] = 0

  def root(self, x):
    if self.par[x] == -1:
      return x
    else:
      self.par[x] = self.root(self.par[x])
      return self.par[x]

  def count(self, x):
    return self._count[self.root(x)]

  def sum(self, x):
    return self._sum[self.root(x)]

  def same(self, x, y):
    return self.root(x) == self.root(y)

N, M = reads()
X = reads()
edges = []
for _ in range(M):
  a, b, y = reads()
  a, b = a-1, b-1
  edges.append((y, a, b))
edges.sort()

uf = union_find(N, X)
ans = 0
for y, a, b in edges:
  uf.unite(a, b)
  if uf.sum(a) >= y:
    ans += uf.count(a)
    uf.reset_count(a)
print(M - ans)


Measured memory_bytes: 125848
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;
        PrintWriter pw = new PrintWriter(System.out);
        
        try {
            int t = Integer.parseInt(br.readLine());
            int[] a = new int[4];
            while(t-->0) {
                String s = br.readLine();
                if(s.equals("AC")) a[0]++;
                else if(s.equals("WA")) a[1]++;
                else if(s.equals("TLE")) a[2]++;
                else if(s.equals("RE")) a[3]++;
            }

            pw.println("AC x " + a[0]);
            pw.println("WA x " + a[1]);
            pw.println("TLE x " + a[2]);
            pw.println("RE x " + a[3]);
        }
        finally {
            pw.flush();
            pw.close();
        }
    }
}


Measured memory_bytes: 42792
#include<stdio.h>

int min(int a,int b){
    if(a<=b){
        return a;
    }else{
        return b;
    }
}

int main(){
    int H,N,i,j,div;
    int A[1000],B[1000],dp[1000][10000];
    scanf("%d %d",&H,&N);
    for(i=0;i<N;i++)scanf("%d %d",&A[i],&B[i]);
    for(i=0;i<N;i++){
        for(j=0;j<H;j++){
            div=(j+1)/A[i];
            if((j+1)%A[i]!=0)div++;
            if(i==0){
                dp[i][j]=B[i]*div;
            }else{
                if((j+1)<=A[i]){
                    dp[i][j]=min(dp[i-1][j],B[i]);
                }else{
                    dp[i][j]=min(dp[i-1][j],dp[i][j-A[i]]+B[i]);
                }
            }
        }
    }

    printf("%d\n",dp[N-1][H-1]);
}

Measured memory_bytes: 39168
n = int(input())

mem = [[0]*10 for _ in range(10)]

for i in range(n):
  a = int(str(i+1)[0])
  b = int(str(i+1)[-1])
  mem[a][b] += 1
  
ans = 0

for i in range(1, 10):
  for j in range(1, 10):
    ans += mem[i][j] * mem[j][i]
      
print(ans)

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

struct lowlink{
  vector<int> ord,low,used;
  vector<vector<int>> adj,tree;
  int root,n;
  lowlink(){}
  lowlink(vector<vector<int>> const& a,int r):adj(a),root(r){
    n = adj.size();
    ord.resize(n);
    low.resize(n);
    used.resize(n);
    tree.reserve(n);
    int k=0;
    dfs(root,-1,k);
  }
  void dfs(int cur,int par,int& k){
    ord[cur] = k++;
    low[cur] = ord[cur];
    used[cur] = 1;
    for(auto nxt:adj[cur]){
      if(used[nxt]==0){
        dfs(nxt,cur,k);
        tree[cur].emplace_back(nxt);
        low[cur] = min(low[cur],low[nxt]);
      }
      else if(ord[nxt]<ord[cur]&&nxt!=par){
        low[cur] = min(low[cur],ord[nxt]);
      }
    }
  }
  vector<int> articulation_points(){
    // 関節点 := 頂点u,子vについて、ord[u] <= low[v] or 根の次数>1
    vector<int> res;
    if(tree[root].size()>1)res.emplace_back(root);
    for(int u=0;u<n;++u){
      if(u==root)continue;
      for(auto v:tree[u]){
        if(ord[u]<=low[v]){
          res.emplace_back(u);
          break;
        }
      }
    }
    return res;
  }
  vector<pair<int,int>> bridges(){
    // 橋 := 辺uvについて、ord[u]<low[v]
    vector<pair<int,int>> res;
    for(int u=0;u<n;++u){
      for(auto v:tree[u]){
        if(ord[u]<low[v]){
          res.emplace_back(min(u,v),max(u,v));
        }
      }
    }
    sort(res.begin(),res.end());
    return res;
  }
  void dump(){
    cout<<"idx : ";
    for(int i=0;i<n;++i)cout<<i<<(i+1<n?" ":"\n");
    cout<<"ord : ";
    for(int i=0;i<n;++i)cout<<ord[i]<<(i+1<n?" ":"\n");
    cout<<"low : ";
    for(int i=0;i<n;++i)cout<<low[i]<<(i+1<n?" ":"\n");
  }
};

signed main(){

  int n,m;
  cin>>n>>m;
  vector<vector<int>> adj(n);
  for(int i=0;i<m;++i){
    int u,v;cin>>u>>v;
    adj[u].emplace_back(v);
    adj[v].emplace_back(u);
  }

  lowlink g(adj,0);
  for(auto ans:g.bridges()){
    cout<<ans.first<<" "<<ans.second<<endl;
  }

}


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

#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()





int main(){
  unsigned long int N, A, B, x, ans = 0;
  cin >> N >> A >> B;
  if(A + B == 0){
    cout << 0 << endl;
    return 0;
  }

  x = N%(A+B);
  ans += N/(A+B) * A;

  if(x > A){
    ans += A;
  }else{
    ans += x;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
// package app;

import java.math.BigDecimal;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Scanner;
import java.util.StringJoiner;
import java.util.stream.Stream;

public class Main {

    public static void main(final String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);

        String S = sc.next();
        // long u = sc.nextLong();

        int firstHalf = Integer.parseInt(S.substring(0, 2));
        int endHalf = Integer.parseInt(S.substring(2, S.length()));

        String msg = "";
        if (firstHalf > 0 && firstHalf <= 12 && endHalf > 0 && endHalf <= 12) {
            msg = "AMBIGUOUS";
        } else if (firstHalf > 0 && firstHalf <= 12) {
            msg = "MMYY";
        } else if (endHalf > 0 && endHalf <= 12) {
            msg = "YYMM";
        } else {
            msg = "NA";
        }

        System.out.println(msg);
    }
}

Measured memory_bytes: 21716
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
--import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import GHC.ST
-- import System.IO.Unsafe

-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
getDoubles = map readDouble . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
tjoin :: (Show a, Show b) => (a, b) -> String
tjoin (x, y) = show x ++ (' ' : show y)
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
ibsearch :: (Int -> Bool) -> (Int,Int) -> Int
ibsearch f (ok,ng) = if abs (ok-ng) <= 1 then ok else let mid = (ok + ng) `div` 2 in ibsearch f (if f mid then (mid,ng) else (ok,mid))
-- templete

seg 0 = [1,1,1,1,1,1,0]
seg 1 = [0,1,1,0,0,0,0]
seg 2 = [1,1,0,1,1,0,1]
seg 3 = [1,1,1,1,0,0,1]
seg 4 = [0,1,1,0,0,1,1]
seg 5 = [1,0,1,1,0,1,1]
seg 6 = [1,0,1,1,1,1,1]
seg 7 = [1,1,1,0,0,1,0]
seg 8 = [1,1,1,1,1,1,1]
seg 9 = [1,1,1,1,0,1,1]
initial = [0,0,0,0,0,0,0]

diff = zipWith ((flip mod 2 .) . (+))
showDigits = map intToDigit . reverse

main = do
    n <- getInt
    unless (n==(-1)) $ replicateM n getInt >>= mapM_ putStrLn . map showDigits . binMap diff . (initial:) . map seg >> main


Measured memory_bytes: 4076
#include<bits/stdc++.h>
using namespace std;
int n, a, b, c, temp, ans, num[2005];
int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++)cin >> num[i];
	sort (num + 1, num + n + 1);
	for (int i = 1; i <= n - 2; i++)
	{
		for (int j = i + 1; j <= n - 1; j++)
		{
			a = num[i];
			b = num[j];
			temp = j + 1;
			while (temp <= n)
			{
				c = num[temp];
				if (a + b <= c)break;
				temp++;
				ans++;
			}
		}
	}
	cout << ans;
	return 0;
} 

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

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

    cout << ('A' <= s && s <= 'Z' ? "A" : "a" ) << endl;
    return 0;
}

Measured memory_bytes: 3560
#include <iostream>
#include <memory>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
  int n,m,A,sum;
  vector<int> v;
  double max;
  cin>>n>>m;
  for(int i=0;i<n;i++){
    scanf("%d",&A);
    sum+=A;
    v.push_back(A);
  }
  max=sum/(4.0*m);
  sort(v.begin(),v.end());
  if(v[n-m]>=max){
    cout<<"Yes";
  }else{
    cout<<"No";
  }
  cout<<endl;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
A = set([int(input()) for i in range(M)])
B = [0]*(N+1)
B[0] = 1
for i in range(1, N+1):
    B[i] = B[i-1] + B[i-2]
    if i in A:
        B[i] = 0
print(B[N]%1000000007)

Measured memory_bytes: 470264
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
#include <stdio.h>
#include <cmath>
#include <queue>
typedef long long ll;
using namespace std;

int main(void){
    ll H, W;
    cin >> H >> W;
    if(H==1 || W == 1) {
        cout << 1 << endl;
        return 0;
    }
    if (H*W % 2 == 0) {
        cout << H*W / 2 << endl;
    } else {
        cout << H*W / 2 + 1 << endl;
    }
}



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

int main()
{
	char serve[100];

	while (cin >> serve, serve[0] != '0'){
		int pt[2] = {0};
		for (int i = 0; i < strlen(serve) - 1; i++){
			if (serve[i] != serve[i + 1]){
				pt[serve[i + 1] - 'A']++;
			}
			else {
				pt[serve[i] - 'A']++;
			}
		}
		pt[serve[strlen(serve) - 1] - 'A']++; 
		cout << pt[0] << " " << pt[1] << endl;
	}

	return (0);
}

Measured memory_bytes: 1140
import collections as c
ip = lambda : map(int, input().split())
# ##############
H,W,K = ip()
s = [input() for i in range(H)]
res = [[0]*W for i in range(H)]

nosb = []
yessb = []
k = 0
for i in range(H):
    if '#' not in s[i]:
        nosb.append(i)
    else:
        yessb.append(i)
        cc = 0
        for j in range(W):
            if j == 0:
                k+=1
            if s[i][j] == '#':
                cc+=1
                if cc>1:
                    k+=1
            res[i][j] = k

import bisect
for i in nosb:
    bl = bisect.bisect(yessb,i)
    # print(bl,yessb[bl])
    if bl<len(yessb):
        res[i] = res[yessb[bl]][:]
    else:
        res[i] = res[yessb[bl-1]][:]
for i in res:
    for j in i:
        print(j,end=' ')
    print()

Measured memory_bytes: 7880