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

int main(){
    long N, Q;
    string s;
    cin >> N >> Q >> s;
    long l = 0, r = N;
    vector<pair<char, long>> v(Q);
    for(auto& i : v){
        char c;
        cin >> i.first >> c;
        i.second = !(c & 2);
    }
    reverse(v.begin(), v.end());
    for(const auto& i : v){
        if(i.second){
            if(s[l] == i.first)++l;
            if(r < N && s[r] == i.first)++r;
        }else{
            if(l && s[l - 1] == i.first)--l;
            if(s[r - 1] == i.first)--r;
        }
    }
    cout << r - l << endl;
    return 0;
}

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

int a[112345];

int main()
{
	int n,k,num,ans=0,MIN;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	if(a[1]<0 && a[k]>=0)ans=min(-2*a[1]+a[k] , -a[1]+2*a[k]);
	else if(a[1]<=0 && a[k]<=0) ans=-a[1];
	else ans=a[k];
	MIN=ans;
	
	for(int i=k+1;i<=n;i++)
	{
		if(a[i-k+1]<0 && a[i]>=0)ans=min(-2*a[i-k+1]+a[i] , -a[i-k+1]+2*a[i]);
		else if(a[i-k+1]<=0 && a[i]<=0) ans=-a[i-k+1];
		else ans=a[i];
		if(MIN>ans)MIN=ans;
	}
	printf("%d",MIN);
}


Measured memory_bytes: 640
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

func main() {
	solve(NewScanner())
}

func solve(s *Scanner) {
	wtr := bufio.NewWriter(os.Stdout)
	N := s.nextInt()

	carry := N % 2
	ans := N/2 + carry

	fmt.Fprintln(wtr, ans)
	wtr.Flush()
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
using namespace std;

int main() {

	cout << fixed << setprecision(10);
	long long int a, b, c, d, n, m;
	long double x[200000],res=0;
	string str[200000];
	cin >> n;

	for (int i = 1; i <= n; i++) {
		cin >> x[i] >> str[i];
		if (str[i] == "JPY") {
			res += x[i];
		}
		else {
			res += x[i] * 380000.0;
		}
	}
	cout << res;

}

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

int  main(){
  ll n,m;cin>>n>>m;
  if(n==1&&m==1){cout<<1;}
  else if(n==1){cout<<m-2;}
  else if(m==1){cout<<n-2;}
  else{cout<<(n-2)*(m-2);}
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;

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

	ll n, m;
	cin >> n >> m;
	vector<ll> a(m);
	rep(i, m) cin >> a[i];

	ll sum = 0LL;
	rep(i, m) {
		sum += a[i];
	}

	ll ans = n - sum;
	if (ans >= 0) {
		out(ans);
	}
	else {
		out(-1);
	}

	return 0;
}

Measured memory_bytes: 3656
#include<iostream>
using namespace std;
int main(){
	int a,b,c,d,e;
	cin>>a>>b>>c;
	d=(a>b)?a:b;
	e=(a>b)?b:a;
	d=(c>d)?d:c;
	cout<<(e*d)/2;
	return 0;
}

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

int main(){
    int N; cin >> N;
    bool jud = false;

    rep(i,9){
        rep(j,9){
            if((i+1)*(j+1) == N){
                jud = true;
            }
        }
    }

    if(jud){
        cout << "Yes" << endl;
    }

    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mod 1000000007

int main() {

    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    ll t = 1;
    //cin>>t;

    while(t--) {
        double r;
        cin>>r;

        double ans = 2 * r * (3.14159);
        cout<<ans<<"\n";

    }

}



Measured memory_bytes: 3800
//#pragma comment(linker, "/stack:200000000") //  (UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")  // $ (UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define fast_cin ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
#define pb push_back
#define all(con) (con).begin(), (con).end()
#define fi first
#define se second
#define rep(i,a,b) for(int i=a;i<b;++i)
#define fre(i,a,b) for(int i=a;i<=b;i++)
#define rpe(i,a,b) for(i=a-1;i>=b;i--)
#define rp(i,n) rep(i,0,n)
#define fr(i,n) fre(i,1,n)
#define ff(i,a,b) for(int i=a;i<=b;i++)

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

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the iterator to kth largest element.(0-based)

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<"  ";__f(comma+1, args...);}
#else
#define trace(...)
#endif

template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}

int modpow(int x, int n, int m) {
	x %= m;
	int res = 1;
	while(n > 0) {
		if(n & 1)
		res = res * x % m;
		x = x * x % m;
		n >>= 1;
	}
	return res;
}

const long long inf = 2e18 ;
const int mod = 1e9+7 ;
// const int mod = 998244353 ;

const int N = 1e5 + 10 ;

void solve() {
        int x,n;
        cin>>x>>n;
        int s=0;
        for(int i=0;i<n;i++) {
                int y;
                cin>>y;
                s+=y;
        }
        if(s>=x) {
                cout<<"Yes"<<endl;
        }
        else {
                cout<<"No";
        }
}

signed main() {
        fast_cin;
	srand(chrono::high_resolution_clock::now().time_since_epoch().count());
        #ifndef ONLINE_JUDGE
        // freopen("input.txt", "r", stdin);
        // freopen("output.txt", "w", stdout);
    	#endif

	int tests=1;
	// cin>>tests;
	while(tests--) {
		solve();
	}

return 0 ;
}



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

#define ll long long int

int a,b,c,c5,c7;

int main()
{

    cin>>a>>b>>c;
   	a=a+b+c;

   	if(a==17)
   		cout<<"YES";
   	else
   		cout<<"NO";

}


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

namespace test
{
    class MainClass
    {
        public static void Main(string[] args)
        {

            //問題158

            //A <= x * 1.08 < A + 1
            //100 * A <= x * 108 < 100 * A + 100
            //B * 100 <= x * 110 < B * 100 + 100

            //A * 100 / 108 <= x < (A + 100) / 108
            //B * 100 / 110 <= x < (B + 100) / 110

            //a <= x * 0.08

            string[] line = Console.ReadLine().Split(' ');
            int a = int.Parse(line[0]);
            int b = int.Parse(line[1]);

            int first = 100 * a / 8;
            int last = (100 * a + 100) / 8;

            for (int i = first; i <= last; i++)
            {
                if (100 * a <= i * 8 && i * 8 < 100 * a + 100)
                {
                    if (100 * b <= i * 10 && i * 10 < b * 100 + 100)
                    {
                        Console.WriteLine(i);
                        return;
                    }
                }
            }

            Console.WriteLine(-1);
        }

    }





    
}


Measured memory_bytes: 27400
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long LL;
const int N = 306, M = 666, Mod = 1e9 + 7;

inline void Read(int &x) {
	x = 0; register char cc = '\0'; int fff = 1;
	for (; cc < '0' || cc > '9'; cc = getchar())
		if (cc == '-') fff = -1;
	for (; cc >= '0' && cc <= '9'; cc = getchar())
		x = (x << 1) + (x << 3) + (cc & 15);
	x *= fff;
}

int n, m, tot, fans, Head[N], Next[M], Adj[M], W[M], f[N][N][N];

int main()
{
	Read(n), Read(m);
	for (int i = 1, x, y, z; i <= m; ++i) {
		Read(x), Read(y), Read(z);
		Next[++tot] = Head[y]; Head[y] = tot; Adj[tot] = x; W[tot] = z;
	}
	f[1][0][0] = 1;
	for (int i = 1; i < n; ++i) {
		for (int e = Head[i]; e; e = Next[e]) {
			for (int j = 0; j < i; ++j)
				for (int k = 0; k <= j; ++k)
					if ((j >= Adj[e] ? 1 : 0) + (k >= Adj[e] ? 1 : 0) + 1 != /* > */ W[e])
						f[i][j][k] = 0;
		}
		for (int j = 0; j < i; ++j)
			for (int k = 0; k <= j; ++k /* ++ j*/)
				if (f[i][j][k]) {
					//printf("%d %d %d %d\n", i, j, k, f[i][j][k]);
					(f[i + 1][j][k] += f[i][j][k]) %= Mod;
					(f[i + 1][i][j] += f[i][j][k]) %= Mod;
					/*if (j != 0 || k != 0) 本质上此"0"非彼"0" j, k虽然同为0 但代表两种颜色*/
					(f[i + 1][i][k] += f[i][j][k]) %= Mod;
				}
	}
	for (int e = Head[n]; e; e = Next[e]) {
		for (int j = 0; j < n; ++j)
			for (int k = 0; k <= j; ++k)
				if ((j >= Adj[e] ? 1 : 0) + (k >= Adj[e] ? 1 : 0) + 1 != /* > */ W[e])
					f[n][j][k] = 0;
	}
	for (int i = 0; i < n; ++i)
		for (int j = 0; j <= i; ++j)
			fans = (fans + f[n][i][j]) % Mod;
	fans = (LL)fans * 3LL % Mod;
	printf("%d\n", fans);
	
	return 0;
}


Measured memory_bytes: 108800
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

int main() {
    int n;
    cin >> n;
    vector<int> temp(26, 0), cnt(26, 100);
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        temp = vector<int>(26, 0);
        for (int j = 0; j < (int) s.size(); ++j) {
            ++temp[s[j] - 'a'];
        }

        for (int j = 0; j < 26; ++j) {
            cnt[j] = min(cnt[j], temp[j]);
        }
    }

    for (int i = 0; i < 26; ++i) {
        for (int j = 0; j < cnt[i]; ++j) {
            cout << (char)('a' + i);
        }
    }

    cout << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[]){
	int i,j,n,data[105][105];
	while(scanf("%d ",&n),n){
		memset(data, 0, sizeof(data));
		for(i=0;i<n;i++)
			for(j=0;j<n;j++){
				scanf("%d ", &data[i][j]);
				data[i][n] += data[i][j];
				data[n][j] += data[i][j];
				data[n][n] += data[i][j];
			}
		for(i=0;i<=n;i++,printf("\n"))
			for(j=0;j<=n;j++) printf("%5d", data[i][j]);
		
	}
    return 0;
}

Measured memory_bytes: 0
import std.stdio, std.string, std.algorithm, std.range, std.conv, std.typecons, std.math;
void main(){
    auto x = readln.chomp.to!ulong;
    auto n = x / 11 * 2;
    auto m = x % 11;
    if (1 <= m && m <= 6) {
        n++;
    } else if (7 <= m) {
        n += 2;
    }
    writeln(n);
}

Measured memory_bytes: 256
from collections import deque
n, Q = map(int, input().split())
edges = [[] for _ in range(n+1)]
count = [0]*(n+1)
q = deque()
q.append((1, 0))

for _ in range(n-1):
    a, b = map(int, input().split())
    edges[a].append(b)
    edges[b].append(a)
for _ in range(Q):
    p, x = map(int, input().split())
    count[p] += x

while(q):
    k = q.popleft()
    count[k[0]] += count[k[1]]
    for i in edges[k[0]]:
        if not i == k[1]:
            q.append((i, k[0]))

print(*count[1:])


Measured memory_bytes: 57696
#include <cstdio>
int main()
{
    int a, b, c;
    std::scanf("%d %d %d", &a, &b, &c);

    if(a > b){
        int temp = b;
        b = a;
        a = temp;
    }
    if(b > c){
        int temp = c;
        c = b;
        b = temp;
    }
    if(a > b){
        int temp = b;
        b = a;
        a = temp;
    }
    printf("%d %d %d\n", a, b, c);

    return 0;
}

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

int main() {
	int A[200]={},B[200]={},N,ans=0;
	cin>>N;
	for(int i=1; i<N; i++)cin>>B[i];
	for(int i=1; i<N-1; i++){
		A[i] = (B[i]<B[i+1])?B[i]:B[i+1];
	}
	A[0]=B[1];
	A[N-1] = B[N-1];
	for(int i=0; i<N; i++){
		ans += A[i];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();
            long[] H = new long[N];
            for (int i = 0; i < N; i++) {
                H[i] = sc.nextLong();
            }

            int ans = 0;

            int count = 0;
            for (int i = 0; i < N - 1; i++) {
                if (H[i] >= H[i + 1]) {
                    count++;
                    if (ans < count) {
                        ans = count;
                    }
                } else {
                    count = 0;
                }
            }

            System.out.println(ans);
        }
    }

}


Measured memory_bytes: 64264
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#include <vector>
#include <numeric>
#include <map>
using ll =long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;

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


    int min = 1000000000;
    for(int i=0; i<N; i++) cin >> X.at(i) ;

    for(int p=1; p<=100; p++){
        int sum = 0;
        for(int i=0; i<N; i++){
            sum += (p-X.at(i)) * (p-X.at(i));
        }
        if(sum < min){
            min = sum;
        }
    }
    cout << min << endl;
}


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

using namespace std;

int main()
{
    long long int A,B;
    cin>>A>>B;
 if(A!=B&&A>=0&&B>=0&&A<=1000000000&&B<=1000000000){   
    if(A%2==B%2){
        cout<<(A+B)/2;
    }
    else{
        cout<<"IMPOSSIBLE";
    }
 }
    return 0;
}

Measured memory_bytes: 3616
//region Template
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
template<typename T> void debug_out(string name, T arg) { cerr<<name<<"="<<arg<<endl; }
template<typename T1, typename... T2> void debug_out(string name, T1 arg, T2... args) {
    cerr<<name.substr(0, name.find(','))<<"="<<arg<<", ";
    debug_out(name.substr(name.find(',') + 1), args...); }
#define debug(...) debug_out(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cout<<fixed<<setprecision(12);
#define FOR(i, n) for(int i=0; i<int(n); i++)
#define RNG(i, f, t) for(int i=int(f); i<=int(t); i++)
#define REV(i, f, t) for(int i=int(f); i>=int(t); --i)
#define ALL(v) (v).begin(), (v).end()
#define EXIT(answer) { cerr<<"EXIT #"<<__LINE__<<endl; cout<<answer<<endl; exit(0); }
#define sz(v) int(v.size())
bool RELAXED = false;
template<int,typename T> struct MINMAX{ T val; MINMAX(T val) : val(val) {} };
template<typename T> MINMAX<1,T> MAX(T val) { return MINMAX<1,T>(val); };
template<typename T> MINMAX<2,T> MIN(T val) { return MINMAX<2,T>(val); };
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<1,U> rhs) { return lhs = (rhs.val > lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<2,U> rhs) { return lhs = (rhs.val < lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T, typename U> istream& operator>>(istream& in, pair<T,U> &p) { in>>p.first>>p.second; return in; }
template<typename T> inline vector<T> READ(int n) { vector<T> vec(n); FOR(i,n) cin>>vec[i]; return vec; }
template<typename T> using min_heap = priority_queue<T, vector<T>, greater<T> >;
typedef signed long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
//endregion



int main() {
    FASTIO

    int n,m; cin>>n>>m;
    vi a = READ<int>(m);
    ll sum = accumulate(ALL(a), 0LL);

    cout<<max(-1LL, n-sum)<<endl;




}

Measured memory_bytes: 3696
// https://beta.atcoder.jp/contests/abc064

#define SUBMIT
#include <bits/stdc++.h>
using namespace std;

int main() {
#ifdef SUBMIT
    auto& stream = cin;
#else
    stringstream stream(R"(9
3200 3200 1600 2000 3200 3200 3200 3200 3200
)");
#endif

    int count8 = 0;
    // (color, count)
    set<int> color_counts;
    int n;
    stream >> n;
    for (int i = 0; i < n; ++i) {
        int a;
        stream >> a;
        a = min(3200, a);
        a /= 400;
        color_counts.insert(a);
        if(a == 8) count8++;
    }

    int ans_min = color_counts.size() - (0 < count8);
    if (ans_min == 0) ans_min = 1;
    int ans_max = color_counts.size() - (0 < count8) + count8;
    cout << ans_min << " " << ans_max << endl;
    return 0;
}

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

typedef long long ll;
typedef pair<int,int> ii;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n,m; cin>>n>>m; n--; m--; cout << n*m << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int slen = s.length();
        char c[] = s.toCharArray();
        int count = 0;
        for (int i = 0; i < (slen / 2); i++) {
            if (c[i] != c[(slen - 1) - i]) {
                count++;
            }
        }
        System.out.println(count);
        sc.close();
    }
}


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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N, M; cin >> N >> M;
	vector<vi> graph (N);
	vi HS (N);
	F0R(i, N) cin >> HS[i];
	F0R(i, M) {
		int u, v; cin >> u >> v; --u; --v;
		graph[u].push_back(v);
		graph[v].push_back(u);
	}

	int res =0 ;
	F0R(i, N) {
		bool big = true;
		for (int n : graph[i]) {
			if (HS[n] >= HS[i]) big = false;
		}
		res += big;
	}
	print(res);

}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD 1000000000 + 7
#define PI 3.14159265359

const long long INF = 100000;
typedef pair<int,int> P;
typedef long long ll;

using Graph = vector<vector<int>>;

vector<ll> v;

void bfs(int K) {
	for (ll i = 1; i <= 9; i++) {
		v.push_back(i);
	}
	queue<ll> que;
	for (ll i = 1; i <= 9; i++) {
		que.push(i);
	}

	while (1) {
		ll iTop = que.front();
		que.pop();

		int iLast = iTop % 10;//iTopの末尾の桁
		for(int i = iLast - 1; i <= iLast + 1; i++) {

			if (i < 0 || i > 9) continue;
			que.push(iTop*10 + i);
			v.push_back(iTop*10 + i);
		}
		if (v.size() >= K) break;
	}
}

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

	bfs(K);
	cout << v[K - 1] << endl;
	
}

Measured memory_bytes: 1620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;

#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////////////////

int main(){
    ll n,m;cin>>n>>m;
    if(m%2==1){
        cout<<-1<<endl;return 0;
    }
    vector<ll>v[n];
    rep(i,1,m){
        ll a,b;cin>>a>>b;a--;b--;
        v[a].pb(b);v[b].pb(a);
    }
    queue<ll>q;
    stack<ll>s;
    bool used[n];memset(used,false,sizeof(used));
    ll par[n];
    q.push(0);used[0]=true;
    while(!q.empty()){
        ll t=q.front();q.pop();s.push(t);
        for(auto x:v[t]){
            if(!used[x]){
                q.push(x);
                used[x]=true;
                par[x]=t;
            }
        }
    }
    ll c[n];memset(c,0,sizeof(c));
    vector<l_l>ans;
    memset(used,false,sizeof(used));
    while(!s.empty()){
        ll t=s.top();s.pop();
        if(t==0)break;
        used[t]=true;
        for(auto x:v[t]){
            if(used[x])continue;
            if(c[t]%2==1){
                ans.pb(l_l(t,x));
                c[t]++;
            }else{
                ans.pb(l_l(x,t));
                c[x]++;
            }
        }
    }
    for(auto x:ans){
        cout<<x.first+1<<" "<<x.second+1<<endl;
    }
    return 0;
}

Measured memory_bytes: 11636
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n; cin>>n;
	int d[100];
	for(int i=0;i<n;i++) cin>>d[i];
	sort(d,d+n);
	int ans=0;
	int temp=0;
	int pred=0;
	for(int i=0;i<n;i++){
		if(d[i]==pred){
			continue;
		}
		ans++;
		pred=d[i];
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <string>
#define rep(x,to) for(x=0;x<to;x++)
#define rep2(x,from,to) for(x=from;x<to;x++)

using namespace std;


int main(void){

int num,i,j,k,l;
int cnt;

	while(cin >> num){
		cnt=0;
		rep(i,10) rep(j,10) rep(k,10) rep(l,10)
			if(i + j + k + l == num ) cnt++;
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
//                                 Alisher_2211
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        # include <bits/stdc++.h>
# define  long          long long
# define  all(vc)       vc.begin(),vc.end()
# define  allr(vc)      vc.rbegin(),vc.rend()
# define  pb            push_back
# define  fi            first 
# define  se            second
# define  pi            pair <long, long>    
# define  lcm(a, b)     (a * b) / __gcd(a, b)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        using namespace std;
const long N = 100100;
void read(){freopen("input.txt" , "r" , stdin );freopen("output.txt", "w" , stdout );}
long dp[N];
long n;
void solve(){
    cin >> n;
    vector <long> v(n + 1), d(n);
    for (int i = 1; i <= n; ++i) cin >> v[i];
    for (int i = 2; i <= n; ++i){
        long o1 = dp[i - 1] + abs( v[i] - v[i - 1] );
        long o2 = dp[i - 2] + abs( v[i] - v[i - 2] );
        if( i == 2 ) o2 = 1e9 + 100;
        dp[i] = min(o1, o2);
    }
    cout << dp[n];
}
int32_t main(){
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); 
        long T = 1;
        //cin >> T;
        while( T-- ){
            solve();
            cout<<'\n';
        }
cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
}

Measured memory_bytes: 5548
# -*- coding: utf-8 -*-
# モジュールのインポート
import math

# 標準入力を取得
N = int(input())
A = list(map(int, input().split()))

# 求解処理
A = sorted(A, reverse=True)
ans = 0
for n in range(1, N + 1):
    if n == 1:
        continue
    ans += A[math.ceil(n / 2) - 1]

# 結果出力
print(ans)


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

int main(){
    int n;
    double i;
    cin>>n;
    if(n%2==0){
        cout<<0.5<<endl;
    }
    else{
       i=(double)(n+1)/2/n;
       cout<<i<<endl;
    }

    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(){
  char s[102];  scanf("%s", s);
  long k;  scanf("%ld", &k);
  int count = 0;
  while(s[count] == '1')  count++;
  char ans;
  if(k <= count)  ans = '1';
  else  ans = s[count];
  printf("%c\n", ans);
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int hill[10];

int main(void) {
    int a, b;

    for(; ~scanf("%d%d", &a, &b);) {
        int size = 0;
        int sum = a + b;

        while(sum > 0) {
            size += 1;
            sum /= 10;
        }
        printf("%d\n", size);
    }

    return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <iostream>
#include <string>
#include <string.h>
using namespace std;
int n,m;
string s[20];
int swaped[20];
int used[20];
int ans = 0;
bool check()
{
	memset(used,0,sizeof used);
	for(int i=0;i<m;i++){
		for(int j=0;j<m;j++){
			if(used[i]||used[j]||i==j) continue;
			int cur=1;
			for(int k=0;k<n;k++){
				if(s[swaped[k]][i]!=s[k][j]){
					cur=0;
					break;
				}
			}
			if(cur){
				used[i]=used[j]=1;
			}
		}
	}
	int cnt=0,to=0;
	for(int i=0;i<m;i++){
		if(!used[i]){
			cnt++;to=i;
		}
	}
	if(cnt>=2||(m%2==0&&cnt)){
		return false;
	}
	if(!cnt) return true;
	for(int i=0;i<n;i++){
		if(s[swaped[i]][to]!=s[i][to]){
			return false;
		}
	}
	return true;
}


void dfs(int now,bool ji)
{
	if(now==(n+1)/2){
		if(check()){
			ans=1;
		}
		return;
	}
	for(int i=now;i<n;i++){
		for(int j=i+1;j<n;j++){
			if(swaped[i]==-1&&swaped[j]==-1){
				swaped[i]=j;
				swaped[j]=i;
				dfs(now+1,ji);
				swaped[i]=-1;
				swaped[j]=-1;
			}
		}
		if(ji&&swaped[i]==-1){
			swaped[i]=i;
			dfs(now+1,false);
			swaped[i]=-1;
		}
	}

}

int main()
{
	cin>>n>>m;
	for(int i=0;i<n;i++)
	{
		cin>>s[i];
		swaped[i]=-1;
	}
	if(n&1)
	{
		dfs(0,true);
	}
	else
	{
		dfs(0,false);
	}
	if(ans) cout<<"YES";
	else cout<<"NO";
}

Measured memory_bytes: 3648
/*  ***  In The Name of God ... ***  */ 
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int long long
#define all(v) v.begin() , v.end()
#define pb push_back
#define endl '\n' 
template<typename T> inline bool smin(T &a, const T &b){ return b < a ? a = b,1:0;}
template<typename T> inline bool smax(T &a, const T &b){ return a < b ? a = b,1:0;}

int x , y ; 

int32_t main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> x >> y ;
	int res = 1 ;
	while ( x * 2 <= y )
		x *= 2 , ++ res ;
	cout << res << '\n' ; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
const ll MOD=1e9+7;
const long long INF = 1LL<<60;

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

    ll answer = x/500 * 1000 + (x%500)/5 * 5;
    cout << answer << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define PI 3.14159265358979323846
#define fi first
#define se second

ll mod = 1e9+7;

ll max(ll a, ll b ) {
	if(a>b)
		return a;
	else return b;
}
ll min(ll a, ll b ) {
	if(a<b)
		return a;
	else return b;
}

int main() {
	ll ttt;
	//cin>>ttt;
	ttt = 1;
	while(ttt--) {
		ll n,k; cin>>n>>k;
		ll a[n]; for(int i=0; i<n; i++) cin>>a[i];

		ll l = 1, h = 1e9 + 100;
		while(l<h) {
			ll mid = (l+h)/2;
			int flag = 0,totes = 0;
			
			for(int i=0; i<n; i++) {
				totes += (a[i]-1) / mid;
			}

			if(totes<=k) h = mid;
			else l = mid+1;
		}
		cout<<h;
 	}	
	return 0;
}

Measured memory_bytes: 5200
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n, x, y;
    scanf("%d %d %d", &n, &x, &y);
    // Create a Graph
    vector<int> adj[n+1];
    for(int i = 1; i < n; i++)
    {
        adj[i].push_back(i+1);
        adj[i+1].push_back(i);
    }
    adj[x].push_back(y);
    adj[y].push_back(x);
    // storing results
    int res[n+1];
    memset(res, 0, sizeof(res));
//    for(int i = 1; i <= n; i++)
//        cout << res[i] << '\n';
    // bfs
    for(int i = 1; i <= n; i++) {
        queue<int> Q;
        bool visited[n + 1];
        memset(visited, false, n + 1);
        int dist[n + 1];
        memset(dist, 0, sizeof(dist));
        visited[i] = true;
        Q.push(i);
        while (!Q.empty()) {
            int t = Q.front();
            Q.pop();
            // cout << t << '\n';
            for (auto j : adj[t]) {
                if (visited[j]) continue;
                visited[j] = true;
                dist[j] = dist[t] + 1;
                Q.push(j);
            }
        }
        for(int i = 1; i <= n; i++)
            res[dist[i]]++;
//        for (int i:dist)
//            cout << i << ' ';
//        cout << '\n';
    }
    for(int i = 1; i < n; i++)
        printf("%d\n", res[i]/2);
    return 0;
}

Measured memory_bytes: 384
using System;

class Program
{
  static void Main(string[] args)
  {
    string str = Console.ReadLine();
    int n = int.Parse(str);

    int num = 0;
    for (int i=0; i<n; i++) {
      string[] str2 = Console.ReadLine().Split(' ');
      int l = int.Parse(str2[0]);
      int r = int.Parse(str2[1]);
      num += r - l + 1;
    }
    Console.WriteLine(num);
    return;
  }
}


Measured memory_bytes: 13140
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<bitset>

using namespace std;
typedef long long ll;
#define i_7 1000000007
#define i_5 1000000005

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
#define inf 100000000/*10^8*/
#define rep(i,l,r) for(ll i=l;i<=r;i++)

////////////////////////////////////////

int main(){
    ll n,m,d;cin>>n>>m>>d;
    double ans;
    if(d==0)ans=(double)(m-1)*(double)((n-d))/(double)(n*n);
    else ans=(double)(m-1)*(double)(2*(n-d))/(double)(n*n);
    printf("%5.10lf",ans);
    
    
    return 0;
}

Measured memory_bytes: 256
/******************************************
* AUTHOR : RAJAGOPALAN *
* NICK : ARNO *
* INSTITUTION : VIT *
******************************************/
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define alli(a, n, k) (a+k),(a+n+k)
#define FP(i, a, b, k) for(__typeof(a) i = a;i < b;i += k)
#define FS(i, a, b, k) for(__typeof(a) i = a;i > b;i -= k)
#define IT(it, a) for(__typeof(a.begin()) it = a.begin();it != a.end(); ++it)
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define eps 1e-6
#define pi 3.141592653589793
using namespace std;
using namespace __gnu_pbds;

template<class T> inline T gcd(T x, T y) { if (!y) return x; return gcd(y, x%y);}
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector< pair<int, int> > VPII;
typedef vector< pair<int, PII > > VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;

inline ll modulo(ll a, ll m)
{
    return (a % m + m) % m;
}

inline ll modInverse(ll a, ll m)
{
    assert(__gcd(a, m) == 1);
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
        return 0;

    while (a > 1)
    {
        ll q = a / m;
        ll t = m;

        m = a % m, a = t;
        t = y;

        y = x - q * y;
        x = t;
    }

    if (x < 0)
        x += m0;

    return x;
}

inline ll modPow(ll x, ll y, ll m)
{ //x^y % m
    if (y == 0)
        return 1LL;
    else if (y == 1)
        return x;
    else
    {
        ll ans = modPow(x, y / 2, m) % m;
        if (y & 1)
        {
            return (((ans * ans) % m) * x) % m;
        }
        else
        {
            return (ans * ans) % m;
        }
    }
}
struct dd
{
    string n;
    int sc;
    int id;
};
int main(int argc, char* argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    vector<dd> arr(n);
    int id=1;
    for(auto &x:arr)
    {
        x.id=id++;
        cin>>x.n>>x.sc;
    }
    sort(all(arr),[&](dd a,dd b){
        if(a.n==b.n){
            return a.sc>b.sc;
        }
        return a.n<b.n;
    });
    for(auto x:arr)
    cout<<x.id<<endl;
    return 0;
}

Measured memory_bytes: 256
grpA = (1, 3, 5, 7, 8, 10, 12)
grpB = (4, 6, 9, 11)
grpC = (2)
x, y = map(int,input().split())
if (x in grpA and y in grpA) or (x in grpB and y in grpB):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <memory>
#include <initializer_list>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;

int main(){
	int n; cin >>n;
	vector<int> a(n);
	cinf(n,a);
	map<int,int> mp;
	for(int i=0;i<n;i++){
		mp[a[i]]++;
		mp[a[i]-1]++;
		mp[a[i]+1]++;
	}
	int ans=0;
	for(auto p:mp){
		ans=max(ans,p.second);
	}
	cout << ans << endl;
}

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


ll floor_sum(ll n, ll m, ll a, ll b) {
    ll ans = 0;
    if (a >= m) {
        ans += (n - 1) * n * (a / m) / 2;
        a %= m;
    }
    if (b >= m) {
        ans += n * (b / m);
        b %= m;
    }

    ll y_max = (a * n + b) / m, x_max = (y_max * m - b);
    if (y_max == 0) return ans;
    ans += (n - (x_max + a - 1) / a) * y_max;
    ans += floor_sum(y_max, a, m, (a - x_max % a) % a);
    return ans;
}


int main() {
    int T;
    ll N, M, A, B;
    cin >> T;
    for (int i = 0 ; i < T; i++) {
        cin >> N >> M >> A >> B;
        cout << floor_sum(N, M, A, B) << "\n";
    }
    return 0;
}

Measured memory_bytes: 3580
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	n *= 2;
	vector<int> a(n);
	for(int i = 0; i < n; ++i){ cin >> a[i]; }
	sort(a.begin(), a.end(), greater<int>());
	int answer = 0;
	for(int i = 1; i < n; i += 2){
		answer += a[i];
	}
	cout << answer << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
	using namespace std;
	#define IOS ios::sync_with_stdio(false), cin.tie(0)
	#define REP(i, n) for (int i = 0; i < n; i++)
	#define FOR(i, a, b) for (int i = a; i < b; i++)
	#define ALL(x) (x).begin(), (x).end()
	#define dump(x) cout << (x) << endl
	#define LMAX 9223372036854775807LL
	#define LMIN -9223372036854775807LL

	using ll = long long;
	template<typename T>
	using vec = vector<T>;
	using P = pair<ll, ll>;

	template <typename A, size_t N, typename T>
	void Fill(A (&array)[N], const T &val){
		fill((T *)array, (T *)(array + N), val);
	}
	
	const ll INF = 1e16;
	const ll MOD = 1e9 + 7;

	//int dx[4] = {1,0,-1,0};
	//int dy[4] = {0,1,0,-1};
	//ll pas[51][52];
	template <class Abel> struct UnionFind {
		vector<ll> par, rank;
		vector<Abel> dif_weight;
		UnionFind(int n = 1, Abel SUM_UNIT = 0){
			par.resize(n);rank.resize(n);dif_weight.resize(n);
			for(int i = 0;i < n;i++){
				par[i] = i;rank[i] = 0;
				dif_weight[i] = SUM_UNIT;
			}
		}
		Abel weight(int i){
			root(i);
			return dif_weight[i];
		}
		bool merge(int x, int y, Abel w) {
			w += dif_weight[x]; w-= dif_weight[y];
			x = root(x), y = root(y);
			if(x == y)return false;
			if(rank[x] < rank[y])swap(x, y), w = -w;
			if(rank[x] == rank[y])++rank[x];
			par[y] = x;
			dif_weight[y] = w;
			return true;
		}
		bool isSame(int x, int y) {
			return root(x) == root(y);
		}
		int root(int x) {
			if(x == par[x])return x;
			else {
				int r = root(par[x]);
				dif_weight[x] += dif_weight[par[x]];
				return par[x] = r;
			}
		}
		Abel dif(int x, int y){
			return dif_weight[y] - dif_weight[x];
		}
	};
	signed main(){
		IOS;
		int n, m;
		cin >> n >> m;
		UnionFind<ll> uf(n);

		REP(i, m){
			ll l, r, d;
			cin >> l >> r >> d;
			l--;r--;
			if(uf.isSame(l, r)){
				int d1 = uf.dif(l, r);
				if(d != d1){
					dump("No");
					return 0;
				}
			}
			else {
				uf.merge(l, r, d);
			}
		}
		dump("Yes");
	}

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

int main() {
  int N, L;
  cin >> N >> L;
  vector<string> vec(N);
  
  for (int i=0; i<N; i++) {
    cin >> vec.at(i);
  }
  
  sort(vec.begin(),vec.end());
  
  for (int k=0; k<N; k++) {
    cout << vec.at(k);
  }
}

Measured memory_bytes: 256
N=int(input())
H=list(map(int,input().split()))
H=H[::-1]
prev=H[0]
for curr in H[1:]:
    if curr <= prev:
        prev = curr
    elif curr-1 == prev:
        prev = curr-1
    else:
        print("No")
        exit()
print("Yes")


Measured memory_bytes: 63984
#include <bits/stdc++.h>
using namespace std;
#define ll          long long int
#define pll         pair<ll,ll>
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod         1000000007
#define pb          push_back
#define inf         1000000000000000000LL
#define vl          vector<ll>
#define F           first
#define S           second
#define ld          long double
#define fix(n)      cout<<fixed<<setprecision(n)
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define pi          3.14159265358979323

const int N = 1e5+5;
vl g[N];
ll vis[N];
ll d[N],p[N];
ll id=0;
map<pair<ll,ll>,ll>e;

ll dfs(ll s)
{
       vis[s]=1;
       p[id]=s;
       id++;
       ll f=d[s]%2;
       for(ll d : g[s])
       {
              if(vis[d]==0)
                     f += dfs(d);
       }
       id--;
       if(id>0)  e[{min(s,p[id-1]),max(s,p[id-1])}]+=f;
       return f;
}

void solve()
{
       ll n,m; cin>>n>>m;
       ll a[m], b[m];
       rep(i,0,m) cin>>a[i]>>b[i];
       if(m&1) { cout<<-1<<endl; return; }
       rep(i,0,m)
       {
              g[a[i]].push_back(b[i]);
              g[b[i]].push_back(a[i]);
              d[a[i]]++; // outdegree -> edge from a -> b
              e[{min(a[i],b[i]), max(a[i],b[i])}]=0;
       }
       bool need=0;
       ll i=1;
       for(i=1; i<=n; i++) { if(d[i]&1) { need=1; break; } }
       if(need) dfs(i);
       rep(i,0,m)
       {
              ll mn=min(a[i],b[i]);
              ll mx=max(a[i],b[i]);
              //cout<<(e[{mn,mx}]&1)<<endl;
              if(e[{mn,mx}]&1) cout<<b[i]<<" "<<a[i]<<endl;
              else { cout<<a[i]<<" "<<b[i]<<endl;}
       }
}

int main(){
	int T = 1;
       //pre();
	speed_up
	//cin>>T;
	while(T--)
	    solve();
	return 0;
}


Measured memory_bytes: 28032
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	ll a;
	int q[8]={0,1,2,3,5,7,8,9};
	while(cin>>a,a){
		string s="";
		while(a){
			s=(char)(q[a%8]+'0')+s;
			a/=8;
		}
		cout<<s<<endl;
	}
}

Measured memory_bytes: 1204
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <utility>
typedef long long ll;
const int INF = 1e9+1;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
using namespace std;

int main() {
	int a, b, c, x;
	cin >> x >> a >> b;
	cout << (x - a) % b << endl;
	return 0;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using Data = pair<long long,vector<int>>;

int main() {
    int X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    vector<ll> A(X + 2000, -10000000000);
    vector<ll> B(Y + 2000, -10000000000);
    vector<ll> C(Z + 2000, -10000000000);
    rep(i, X) cin >> A[i];
    rep(i, Y) cin >> B[i];
    rep(i, Z) cin >> C[i];
    sort(rall(A));
    sort(rall(B));
    sort(rall(C));

    auto comp = [](Data a, Data b) {
        return a.first < b.first;
    };

    Data P;
    P = {A[0] + B[0] + C[0], {0, 0, 0}};
    priority_queue<Data, vector<Data>,
                   decltype(comp)>
        pq{comp};
    pq.push(P);
    map<Data, int> mp;
    mp[P]++;

    vector<ll> ans;
    while (!pq.empty() && ans.size() <= K) {
        Data q = pq.top();
        ans.push_back(q.first);
        pq.pop();

        vector<Data> newd(3);
        int a   = q.second[0];
        int b   = q.second[1];
        int c   = q.second[2];
        newd[0] = {A[a + 1] + B[b] + C[c], {a + 1, b, c}};
        newd[1] = {A[a] + B[b + 1] + C[c], {a, b + 1, c}};
        newd[2] = {A[a] + B[b] + C[c + 1], {a, b, c + 1}};

        if (mp[newd[0]] == 0 && a + 1 < X) {
            pq.push(newd[0]);
            mp[newd[0]]++;
        }
        if (mp[newd[1]] == 0 && b + 1 < Y) {
            pq.push(newd[1]);
            mp[newd[1]]++;
        }
        if (mp[newd[2]] == 0 && c + 1 < Z) {
            pq.push(newd[2]);
            mp[newd[2]]++;
        }
    }

    rep(i, K) cout << ans[i] << endl;
}


Measured memory_bytes: 1408
#include "bits/stdc++.h"
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;

using namespace std;

// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if (AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


//const int NM = 20000;//ここを問題の制約を見ながらいじる．配列の確保に使う．
//ll A[NM];//あまり褒められたことではないが関数の外側に配列を確保すると怒られにくい．
//bool Minus[NM];//あまり褒められたことではないが関数の外側に配列を確保すると怒られにくい．

         //ll dp[NM];//あまり褒められたことではないが関数の外側に配列を確保すると怒られにくい．
//string S[NM];//あまり褒められたことではないが関数の外側に配列を確保すると怒られにくい．
//int B[NM];//あまり褒められたことではないが関数の外側に配列を確保すると怒られにくい．
//double Perf[NM];

ll MOD = 1000000007;
int digit_length(int num)
{
    int count = 0;
    while (num) {
        num = num / 10;
        ++count;
    }
    return count;
}


ll gcd(ll a, ll b) {
    ll v0 = a, v1 = b, v2 = a % b;
    while (v2 != 0) {
        v0 = v1;
        v1 = v2;
        v2 = v0 % v1;
    };
    return v1;
}


// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

//ll lcm(ll a, ll b) {
//    return a / (gcd(a, b) % MOD) * (b % MOD);
//}

ll lcm(ll a, ll b) {
    return( (a % MOD) *modinv(gcd(a, b), MOD) * (b % MOD)) % MOD;
}
       // Main program


void solve() {
    ll  A[9];
    ll  B[100];
    ll N;
    bool  match[9] = { false };


    for (int i = 0; i < 9; i++) {
        cin >> A[i];
    }
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> B[i];
        
        for (int j = 0; j < 9; j++) {
            if (A[j] == B[i]) {
                match[j] = true;
            }
        }
    }
 
    bool bingo = false;

    if (
        (match[0] && match[1] && match[2]) ||
        (match[3] && match[4] && match[5]) ||
        (match[6] && match[7] && match[8]) ||
        (match[0] && match[3] && match[6]) ||
        (match[1] && match[4] && match[7]) ||
        (match[2] && match[5] && match[8]) ||
        (match[0] && match[4] && match[8]) ||
        (match[2] && match[4] && match[6])
        ) {
        bingo = true;
    }


    if (bingo) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }


    return;
}



int main() {
    solve();
    return 0;
}







Measured memory_bytes: 256
package main
import ("fmt"
         "os"
         "bufio"
         "strings"
)



func StrStdin()  []string {
var stringInput string
  scanner := bufio.NewScanner(os.Stdin)

  scanner.Scan()
  stringInput = scanner.Text()

  stringInput = strings.TrimSpace(stringInput)
  return strings.Split(stringInput, " ")
}


func main(){
var a [] string = StrStdin()
b := []string{a[2],a[0],a[1]}
fmt.Println(strings.Join(b," "))

}

Measured memory_bytes: 640