akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main() {
  int num;
  int count;
  int data[100];
  int saihinchi[100];
  int i, j;
  for(i = 0; i < 100; i++) data[i] = 0;
  while(scanf("%d", &num) != EOF) {
    data[num-1]++;
  }
  count = 0;
  for(i = 0; i < 100; i++) {
    if(data[i] > count) {
      count = data[i];
      data[i] = -1;
      for(j = i-1; j >= 0; j--) 
	if(data[j] == -1) data[j] = 0;
    } else if(data[i] == count) {
      data[i] = -1;
    }
  }
  for(i = 0; i < 100; i++) {
    if(data[i] == -1) printf("%d\n", i+1);
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <climits>
#include <cstdlib>
using namespace std;

int n, ans;
int t[22];

int main(){
  while(cin >> n, n){
    for(int i = 0; i < n; i++){
      cin >> t[i];
    }

    ans = INT_MAX;

    for(int i = 0; i < (1 << n); i++){
      int sumA = 0, sumB = 0;

      for(int j = 0; j < n; j++){
        if(i & (1 << j)){
          sumA += t[j];
        }
        else{
          sumB += t[j];
        }
      }

      ans = min(ans, abs(sumA - sumB));
    }

    cout << ans << endl;
  }
}

Measured memory_bytes: 868
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long a,v,b,w,t,l;
  cin>>a>>v>>b>>w>>t;
  l=abs(a-b);
  if(l<=(v-w)*t){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void) {
  int n;
  cin >> n;
  vector<bool> a(8, 0);
  int count = 0;
  for (int i = 0; i < n; i++) {
    int b;
    cin >> b;
    if (b <= 399) {
      a[0] = 1;
    } else if (b <= 799) {
      a[1] = 1;
    } else if (b <= 1199) {
      a[2] = 1;
    } else if (b <= 1599) {
      a[3] = 1;
    } else if (b <= 1999) {
      a[4] = 1;
    } else if (b <= 2399) {
      a[5] = 1;
    } else if (b <= 2799) {
      a[6] = 1;
    } else if (b <= 3199) {
      a[7] = 1;
    } else {
      count++;
    }
  }
  int c = a[0] + a[1] + a[2] + a[3] + a[4] + a[5] + a[6] + a[7];
  cout << max(c, (int(count > 0))) << " ";
  cout << c + count << endl;
  return 0;
}

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

using namespace std;

int main() {
    string s;
    cin >> s;
    string ret;
    for (auto c: s) {
        if (c != 'B') {
            ret += c;
        } else {
            if (ret.size() > 0) {
                ret.pop_back();
            }
        }
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
while True:
  H, W = map(int, raw_input().split())
  if H == 0 and W == 0:
    break
  print "#"*W
  for i in range(H-2):
    if W > 2:
      print "#" + "."*(W-2) + "#"
    else:
      print "#"*W 
  print "#"*W
  print ""

Measured memory_bytes: 6336
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define ALL(x) (x).begin(),(x).end()
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)


int main() {
  int H, W; cin >> H >> W;
  string S[H];
  rep(i,H) cin >> S[i];

  int U[H][W], D[H][W], L[H][W], R[H][W];
  int cnt = 0;

  rep(i,H){
    rep(j,W){
      if(S[i][j] == '#'){
        L[i][j] = cnt;
        cnt = 0;
      }else{
        cnt++;
        L[i][j] = cnt;
      }
    }
    cnt = 0;
  }
  rep(i,H){
    REP(j,W){
      if(S[i][j] == '#'){
        R[i][j] = cnt;
        cnt = 0;
      }else{
        cnt++;
        R[i][j] = cnt;
      }
    }
    cnt = 0;
  }
  rep(i,W){
    rep(j,H){
      if(S[j][i] == '#'){
        U[j][i] = cnt;
        cnt = 0;
      }else{
        cnt++;
        U[j][i] = cnt;
      }
    }
    cnt = 0;
  }
  rep(i,W){
    REP(j,H){
      if(S[j][i] == '#'){
        D[j][i] = cnt;
        cnt = 0;
      }else{
        cnt++;
        D[j][i] = cnt;
      }
    }
    cnt = 0;
  }
int ans = 0;
rep(i,H){
  rep(j,W){
    // cout<<R[i][j]<<" ";
    if(S[i][j]=='.'){
      ans = max(ans, L[i][j]+R[i][j]+U[i][j]+D[i][j]-3);
    }
  }
}
cout << ans << endl;

  return 0;
}


Measured memory_bytes: 66816
class Node():
	def __init__(self, v, w):
		self._v = v
		self._w = w
	def v(self):
		return self._v
	def w(self):
		return self._w
def resolve():
	n, k = map(int, input().split())
	arr = []
	for i in range(n):
		a, b = map(int, input().split())
		arr.append(Node(a, b))
	arr.sort(key=lambda x: x.v())
	for v in arr:
		if v.w() >= k:
			print(v.v())
			break
		k -= v.w()
resolve()

Measured memory_bytes: 63704
import java.util.*;

public class Main{
	private static final int MAX = 1000000;

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

		while(true){
			int N = sc.nextInt();
			int M = sc.nextInt();
			int L = sc.nextInt();
			int K = sc.nextInt();
			int A = sc.nextInt();
			int H = sc.nextInt();
			if(N == 0) break;

			boolean[] f = new boolean[N];
			f[A] = f[H] = true;
			for(int i=0;i<L;i++){
				f[sc.nextInt()] = true;
			}

			int[][] map = new int[N][N];
			for(int i=0;i<K;i++){
				int from = sc.nextInt();
				int to = sc.nextInt();
				int cost = sc.nextInt();
				map[from][to] = map[to][from] = cost;
			}

			floyd(map);

			for(int i=0;i<N;i++){
				for(int j=0;j<N;j++){
					if(!f[i] || !f[j] || map[i][j] > M){
						map[i][j] = MAX;
					}
				}
			}

			floyd(map);

			System.out.println(map[A][H]==MAX ? "Help!" : map[A][H]+Math.max(0,map[A][H]-M));
		}
	}

	private static void floyd(int[][] map){
		int n = map.length;

		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				if(map[i][j] == 0) map[i][j] = MAX;
			}
		}

		for (int k = 0; k < n; k++) {
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					if(i == j) continue;
					map[i][j] = Math.min(map[i][j],map[i][k]+map[k][j]);
				}
			}
    }
	}
}

Measured memory_bytes: 13000
//////////////////////////
/*      _        ____   */
/*  U  /"\  u U /"___|  */
/*   \/ _ \/  \| | u    */
/*   / ___ \   | |/__   */
/*  /_/   \_\   \____|  */
/*   \\    >>  _// \\   */
/*  (__)  (__)(__)(__)  */
/*  Compro by NULL_CT©  */
//////////////////////////
/*STL Libs*/
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

/*Boost*/
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#define int long long //Black Magic
#define REP(I, LIM) for (int I = 0; I < LIM; I++)
#define ALL(LIST) (LIST.begin()), (LIST.end())

using namespace std;
using bint = boost::multiprecision::cpp_int;

constexpr int MOD = 10000007;

vector<int> divisor(int n) {
  vector<int> head, tail;
  for (int i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      head.push_back(i);
      if (i * i != n)
        tail.push_back(n / i);
    }
  }
  head.insert(head.end(), tail.rbegin(), tail.rend());
  return (head);
}

template <typename T>
T input(void) {
  T data;
  cin >> data;
  return (data);
}

//--------------------------------

void execute() {
  string s = input<string>();

  string head = s.substr(0, s.size()/2);
  string tail = s.substr((s.size()+1)/2,s.size());

  reverse(tail.rbegin(),tail.rend());

  int ans=0;
  REP(i, s.size() / 2) { ans += head[i] != tail[i]; }

  cout<<ans<<endl;
}

//--------------------------------

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  // cout<<fixed<<setprecision(20);

  execute();

  return (0);
}


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

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

    int cent[] = {25, 10, 5, 1};
    int sum = 0;
    int n;
    cin >> n;
    for (int i = 0; i < 4; i++) {
        sum += (n / cent[i]);
        n %= cent[i];
        if (n == 0)
            break;
    }
    cout << sum << endl;
}


Measured memory_bytes: 3220
#include<bits/stdc++.h>
using namespace std ;
using ll = long long ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
using pll = pair<ll,ll> ;
const int INF = 1e9 ;
void chmin(int &a,int b){if(a>b) a = b ;}
void chmax(ll &a,ll b){if(a<b) a = b ;}
void YorN(bool a){cout << (a?"YES":"NO") << "\n" ;}

int main(){
	ll n,k ;
	cin >> n >> k ;
	vvll black(k,vll(k,0)),white(k,vll(k,0)) ;
	for(int i=0;i<n;i++){
		int x,y ;
		char c ;
		cin >> x >> y >> c ;
		int d = (c=='B') ;
		d ^= (x/k+y/k)%2 ;
		x %= k ;
		y %= k ;
		if(d) black[x][y]++ ;
		else white[x][y]++ ;
	}
	for(int i=0;i<k;i++) for(int j=1;j<k;j++){
		black[i][j] += black[i][j-1] ;
		white[i][j] += white[i][j-1] ;
	}
	for(int j=0;j<k;j++) for(int i=1;i<k;i++){
		black[i][j] += black[i-1][j] ;
		white[i][j] += white[i-1][j] ;
	}
	ll ans = 0 ;
	for(int i=0;i<k;i++) for(int j=0;j<k;j++){
		ll sub = 0 ;
		sub += black[i][j] ;
		sub += black[k-1][k-1]-black[i][k-1]-black[k-1][j]+black[i][j] ;
		sub += white[i][k-1]-white[i][j] ;
		sub += white[k-1][j]-white[i][j] ;
		chmax(ans,sub) ;
		// cout << i << " " << j << " B " << sub << endl ;
		sub = 0 ;
		sub += white[i][j] ;
		sub += white[k-1][k-1]-white[i][k-1]-white[k-1][j]+white[i][j] ;
		sub += black[i][k-1]-black[i][j] ;
		sub += black[k-1][j]-black[i][j] ;
		chmax(ans,sub) ;
		// cout << i << " " << j << " S " << sub << endl ;
	}
	cout << ans << endl ;
}

Measured memory_bytes: 19080
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String str1 = sc.next();
        char[] c1 = str1.toCharArray();
        String str2 = sc.next();
        char[] c2 = str2.toCharArray();
        
        if (c1.length < c2.length) {
            System.out.println("UNRESTORABLE");
            return;
        }
        
        boolean ok = false;
        for (int i = c1.length-1; i >= c2.length -1 ;  i--) {
            for (int j = 0; j < c2.length; j++) {
                // System.out.println(c1[(i+j)] + " "+ c2[j]);
                if (c1[i-j] == '?') {
                    
                } else if (c1[i-j] != c2[c2.length - 1 - j]) {
                    break;
                }
                
                if (j == c2.length - 1) {
                    ok = true;
                    for (int k = 0; k < c2.length; k++) {
                        c1[i-k] = c2[c2.length - 1 -k];
                    }
                }
                
                
                if (ok) break;
            }
            
            if (ok) break;
        }
        
        if (!ok) {
            System.out.println("UNRESTORABLE");
            return;
        }
        
        for (int i = 0; i < c1.length; i++) {
            if (c1[i] == '?') c1[i] = 'a';
            System.out.print(c1[i]);
        }
        System.out.println();
        
    }
}

Measured memory_bytes: 21844
#include <cstdio>
#include <vector>
#include <utility>
#define ll long long
#define isdigit(c) ('0' <= c && c <= '9')
#define rep(i,n) for (int i = 0; i < int(n); ++ i)
using namespace std;

namespace IO {
	const int BUF_SIZE = 1 << 15;
	char IBUF[BUF_SIZE], OBUF[BUF_SIZE];
	char *PIBUF = IBUF + BUF_SIZE - 1, *POBUF = OBUF;
	
	inline int getchar() {
		if (++ PIBUF == IBUF + BUF_SIZE)
			fread(PIBUF = IBUF, 1, BUF_SIZE, stdin);
		return *PIBUF;
	}
	
	inline void putchar(int x) {
		*POBUF = x;
		if (++ POBUF == OBUF + BUF_SIZE)
			fwrite(POBUF = OBUF, 1, BUF_SIZE, stdout);
	}
	
	inline void flush() {
		if (POBUF != OBUF)
			fwrite(OBUF, 1, POBUF - OBUF, stdout);
		fflush(stdout);
	}
}

#define getchar()  IO :: getchar()
#define putchar(x) IO :: putchar(x)

inline
int getint() {
	int a = 0, b = 1, c = getchar();
	for (;!isdigit(c); c = getchar()) if (c == '-') b = -b;
	for (; isdigit(c); c = getchar()) a = (a<<3) + (a<<1) + (c^48);
	return a * b;
}

template <typename T>
inline void putint(T x) {
	if (x < 0) putchar('-'), x = -x;
	if (x >= 10) putint(x / 10);
	putchar(x - x / 10 * 10 + 48);
}

int n, m, a[505][505];
vector <pair <pair <int, int>, pair <int, int> > > cmd;

void Read() {
	n = getint(), m = getint();
	for (int i = 1; i <= n; ++ i) for (int j = 1; j <= m; ++ j)
		a[i][j] = getint();
}

void Init() {
}

void Solve() {
	for (int i = 1; i <= n; ++ i) for (int j = 1; j < m; ++ j)
		if (a[i][j] & 1) {
			a[i][j] --;
			a[i][j + 1] ++;
			cmd.push_back(make_pair(make_pair(i, j), make_pair(i, j + 1)));
		}
	for (int i = 1; i < n; ++ i)
		if (a[i][m] & 1) {
			a[i][m] --;
			a[i + 1][m] ++;
			cmd.push_back(make_pair(make_pair(i, m), make_pair(i + 1, m)));
		}
//	for (int i = 1; i <= n; ++ i) for (int j = 1; j <= m; ++ j)
//		fprintf(stderr, "%d%c", a[i][j], " \n"[j == m]);
	putint(cmd.size()), putchar('\n');
	rep(i, cmd.size()) {
		putint(cmd[i].first.first), putchar(' ');
		putint(cmd[i].first.second), putchar(' ');
		putint(cmd[i].second.first), putchar(' ');
		putint(cmd[i].second.second), putchar('\n');
	}
}

int main() {
	int T = 1;
//	int T = getint();
	for (; T; -- T) {
		Read();
		Init();
		Solve();
	}
	IO :: flush();
	return 0;
}

Measured memory_bytes: 5232
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};

ll modpow(ll n, ll k){
   ll rtn = 1;
   while(k > 0){
       if(k&1) rtn = rtn * n % MOD;
       n = n * n % MOD;
       k = k >> 1;
   }
   return rtn;
}

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    bool ok = true;
    if(n&1) {
        if(a[0] != 0) ok = false;
        for(int i = 1; i < n; i++) {
            if(a[i] != (i+1)/2*2) ok = false;
        }
    }else{
        for(int i = 0; i < n; i++) {
            if(a[i]!=i/2*2+1) ok = false;
        }
    }
    if(!ok) {
        cout << 0 << endl;
    }else{
        ll ans = modpow(2, n/2);
        cout << ans << endl;
    }

}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)

int main() {
	ll N; cin >> N;
	ll x; cin >> x;
	ll a[100001];
	ll cnt = 0;
	rep(i, 0, N) {
		cin >> a[i];
		if (i == 0) {
			if (a[i] > x) {
				cnt += a[i] - x;
				a[i] = a[i] - cnt;
				continue;
			}
		}
		else if (i != 0) {
			if (a[i] + a[i - 1] > x) {
				ll diff = a[i] + a[i - 1] - x;
				cnt += diff;
				a[i] = a[i] - diff;
			}
		}
	}
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<queue>
#include<memory>
#include<map>
#include<set>
#include<unordered_map>
#include<array>
#include<vector>
#include<algorithm>
#include<list>
#include<limits>
#include<stdio.h>
#include<math.h>
#include<string>
#include<thread>

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using lst = list<ll>;

const ll MOD = 1000000007;

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

	cout << N*(N - 1) / 2 << endl;;

	return 0;
}

Measured memory_bytes: 256
function Main(input) {
	input = input.trim().split("\n").map(function(x) { return x.split(" ")});    
	let N = parseInt(input[0][0], 10);
	let ans = N + 1;
	for (let d = 1; d < N - 1; d++){
		ans += (N - d) * (d + 1);
	}
	let line, tmp1, tmp2;
	for (let i = 0; i < N - 1; i++){
		line = input[i + 1].map(e => parseInt(e, 10));
		if (line[1] < line[0]) line = [line[1], line[0]];
		tmp1 = Math.min(N - line[1], line[0] - 1) + 1;
		tmp2 = N - (line[1] - line[0]) - 1;
		ans -= ((tmp1 * tmp1) + tmp1 * (tmp2 - 2 * tmp1 + 2) - 1);
	}
	if (N === 1) ans = 1;
	console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 106212
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define dbg(x) cout<<#x<<":"<<x<<endl
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;

int main(){
  int n;
  cin>>n;
  vector<int> x(n),a(n*n,-1);
  for(int i=0;i<n;i++){
    cin>>x[i];
    x[i]--;
    a[x[i]]=i;
  }
  int cnt=0;
  for(int i=0;i<n*n;i++){
    if(a[i]==-1)continue;
    for(int j=0;j<a[i];j++){
	 while(a[cnt]!=-1){
	   cnt++;
	 }
	 if(cnt>i){
	   cout<<"No"<<endl;
	   return 0;
	 }
	 a[cnt]=a[i];
    }
  }
  cnt=n*n-1;
  vector<int> used(n,0);
  for(int i=n*n-1;i>=0;i--){
    if(a[i]==-1)continue;
    if(used[a[i]])continue;
    used[a[i]]=1;
    for(int j=0;j<n-a[i]-1;j++){
	 while(a[cnt]!=-1){
	   cnt--;
	 }
	 if(cnt<i){
	   cout<<"No"<<endl;
	   return 0;
	 }
	 a[cnt]=a[i];
    }
  }
  cout<<"Yes"<<endl;
  for(int i=0;i<n*n;i++){
    if(i)cout<<" ";
    cout<<a[i]+1;
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 2176
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

//Code Short
#define REP(i,n) for(int i = 0;i < n;++i)
#define PB(s) push_back(s)
#define DSORT(n) sort(n.begin(),n.end())
#define QECHO(n) cout << n
#define QECHOS(n) cout << n << " "

//Define Math
const double EPS = 1e-10;
const double PI  = acos(-1.0);

using namespace std;
typedef long long ll;
/* prototype */
int EDSum(ll);//各桁の和
vector<int> SOE(int,int);//素数 (Min,Max)
int MinCM(int,int);//最小公倍数(num1,num2)
int MaxCD(int,int);//最大公約数(num1,num2)
vector<int> igets(int);//cin * N
ll nPr(ll,ll); //(n,r)
ll nE(ll); //(n)
ll nCr(ll,ll); //(n,r)

void solve(){
    //START
  vector <int> a = igets(3);
  sort(a.begin(),a.end());
  cout << (a[2]-a[1])+a[1]-a[0] <<endl;
}

int main(void){cin.tie(0);ios::sync_with_stdio(false);solve();}
int EDSum(ll number) {
  int ans = 0;
  while (1) {
    ans += number % 10;
    number /= 10;
    if (number == 0) break;
  }
  return ans;
}

vector < int > SOE(int min, int max) {
  if (min < 2) min = 2;
  vector < int > int_array;
  for (int i = min; i <= max; i++) int_array.push_back(i);
  vector < int > sosu;
  double stop = sqrt(max);
  while (true) {
    sosu.push_back(int_array.front());
    int_array.erase(int_array.begin());
    if (stop < (double)(sosu.back())) break;
    for (int i = 0; i < (int) int_array.size(); i++) {
      if (int_array[i] % sosu.back() == 0)
        int_array.erase(int_array.begin() + i);
    }
  }
  sosu.insert(sosu.end(), int_array.begin(), int_array.end());
  return sosu;
}

int MinCM(int a, int b) {
  int c = a * b;
  if (a < b)
    swap(a, b);
  int r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return c / b;
}

int MaxCD(int a, int b) {
  if (a < b)
    swap(a, b);
  int r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}
vector < int > igets(int N) {
  vector < int > A;
  int temp;
  for (int i = 0; i < N; ++i) {
    cin >> temp;
    A.push_back(temp);
  }
  return A;
}

ll nPr(ll n, ll r) {
  ll ans = 1;
  r = n - r;
  while (n != r) {
    ans *= n;
    --n;
  }
  return ans;
}

ll nE(ll n) {
  return nPr(n, n);
}

ll nCr(ll n, ll r) {
  if (r == 0) return -1;
  else {
    if (0 != n - r && n - r < r) r = n - r;
    return nPr(n, r) / nE(r);
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod 1000000009
#define tc(t) 			int t;cin >> t;while(t--)
#define for0(i , n)		for(int i=0;i<n;i++)
#define loop(i , a, b)	for(int i=a;i<=b;i++)
#define endl '\n'

int n,k;
int a[100005];
int dp[100005];


int frogB(int ind){
	if(ind == (n-1))
		return 0;

	if(dp[ind] != -1) return dp[ind];
	
	int c = INT_MAX;
	for(int i=ind+1;i<=min(ind+k,n-1);i++){
		c = min(c,abs(a[ind]-a[i])+frogB(i));
	}

	return dp[ind] = c;
}


signed main() {

	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
#ifndef ONLINE_JUDGE
	freopen("input.txt" , "r" , stdin);
	freopen("output.txt" , "w" , stdout);
#endif

	cin >> n >> k;

	for0(i,n){
		cin >> a[i];
	}

	memset(dp,-1,sizeof(dp));

	cout << frogB(0);

	return 0;
}

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

using namespace std;

#define ll long long
#define rep(i,p,q) for(ll i = p;i < q;i++)

int main(void){
    ll n,k;
    cin >> n >> k;
    ll amari = n % k;
    cout << min(amari, abs(amari - k)) << endl;
}

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

int main(){
  long n;
  cin >> n;
  long a[n];
  for (long i = 0; i < n; i++) cin >> a[i];
  long maxValue = 0;
  long nextMaxValue = 0;
  for (long i = 0; i < n; i++){
    if(maxValue < a[i]){
      nextMaxValue = maxValue;
      maxValue = a[i];
    }else if(nextMaxValue < a[i]){
      nextMaxValue = a[i];
    }
  }
  for (long i = 0; i < n; i++){
    if(maxValue == a[i]){
      cout << nextMaxValue << endl;
    }else{
      cout << maxValue << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3200
-- Is it a Right Triangle?
import Data.List -- sortBy
import Data.Ord  -- comparing Down
import Control.Applicative -- <$>, <*>

main = (solve <$> getLine) <*> getContents >>= putStr

solve :: String -> String -> String
solve _ = unlines . map (isRight . sortBy (comparing Down) . map read . words) . lines

isRight :: [Int] -> String
isRight [a,b,c] | a^2 == b^2 + c^2 = "YES"
                | otherwise        = "NO"

Measured memory_bytes: 4232
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <math.h>
#include <algorithm> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll INF = 1000000000000000000LL;
using namespace std;

const int MOD = 1000000007;

string seki[] = {"Vacant", "Male", "Female"};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    // Maleだったら、半分で

    ll N;
    cin >> N;
    ll res;
    ll t;
    string zero = "";
    string a;
    int l,r,m;
    l = 0;
    r = N;
    m = (N-1) / 2;

    //1回目
    cout << 0 << endl;
    cout.flush();

    cin >> zero;
    if(zero == seki[0])
    {
        return 0;
    }

    //N-1回目
    cout << N-1 << endl;
    cout.flush();

    cin >> a;
    if(a == seki[0])
    {
        return 0;
    }

    while(true)
    {
        cout << m << endl;
        cout.flush();
        string s;
        cin >> s;

        if(s == seki[0])
        {
            return 0;
        }
        //0との位置を判定
        else if(s == zero)
        {
            //区間が偶数であれば間にない
            if(m % 2 == 0)
            {
                l = m+1;
            }
            else
            {
                r = m-1;
            }
        }
        else
        {
            //区間が偶数であれば間にない
            if(m % 2 == 0)
            {
                r = m-1;
            }
            else
            {
                l = m+1;
            }
        }

        m = (l + r) / 2;
    }

    return 0;    
}


Measured memory_bytes: 852
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
priority_queue<long long> pq;
int main(){
    long long n;
    cin>>n;
    cout<<50<<endl;
    for(long long i=1;i<=50;i++){
        cout<<n/50 + (50-i) + (n%50>(i-1))<<" ";
    }
}

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

namespace Algorithm
{
    class Program
    {
        static long[] dp;
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            dp = new long[N+10];

            var ans = fib(N+1);
            Console.WriteLine(ans);
        }

        static long fib(long a)
        {
            if (a == 1) return 2;
            if (a == 2) return 1;
            if (dp[a] != 0) return dp[a];
            return dp[a] = fib(a - 1) + fib(a - 2);
        }
    }
}


Measured memory_bytes: 11220
import sys

for i in sys.stdin.readlines():
    a, b, c, d, e, f = [int(x) for x in i.split()]
    y = (c * d - a * f) / (b * d - a * e)
    x = (c - b * y) / a
    print('{0:.3f} {1:.3f}'.format(x, y))

Measured memory_bytes: 7540
import java.util.*;



public class Main {
    public static void main(String Args[]) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();

        if(A%3==0||B%3==0||(A+B)%3==0)

        {
            System.out.println("Possible");
        }
        else

        {
            System.out.println("Impossible");
        }
    }


}



Measured memory_bytes: 21844
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int N, M, t, s, d, ans;
  vector< vector<int> > packets;
  while (cin >> N >> M, N) {
    vector<bool> infected(N, false);
    infected[0] = true;
    for (int i = 0; i < M; ++i) {
      cin >> t >> s >> d;
      packets.push_back({t, s-1, d-1});
    }
    sort(packets.begin(), packets.end());
    for (int i = 0; i < M; ++i) {
      s = packets[i][1];
      d = packets[i][2];
      if (infected[s]) infected[d] = true;
    }
    ans = 0;
    for (int i = 0; i < N; ++i) if (infected[i]) ++ans;
    cout << ans << endl;
    packets.erase(packets.begin(), packets.end());
  }
  return 0;
}

Measured memory_bytes: 4184
#include <bits/stdc++.h>
#define N 100001
using namespace std;
typedef pair<int,int> P;

int A[N];
int main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++)cin>>A[i];
  A[n] = 1e9;
  sort(A,A+n);

  if(A[0] == n-1)cout<<"Yes"<<endl,exit(0);
  if(A[n-1] - A[0] >=2) cout<<"No"<<endl,exit(0);
  if(A[0]== A[n-1]){
    if(n/A[0] <2) cout<<"No"<<endl,exit(0);
    cout<<"Yes"<<endl,exit(0);
  }
  
  int idx = 0;
  while(idx<n && A[idx]==A[idx+1]) idx++;
  if(idx>0&&A[0] == idx+1) cout<<"Yes"<<endl,exit(0);
  if(idx>0&&A[0] < idx+1) cout<<"No"<<endl,exit(0);
  if((n-idx-1)/(A[0]-idx)<2)cout<<"No"<<endl,exit(0);
  cout<<"Yes"<<endl,exit(0);
  
  assert(0);
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    map<int,int> P1;
    map<int,int> P2;
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        P1[a]++;
    }
    int m;
    cin>>m;
    for(int i=0;i<m;i++){
        int a;
        cin>>a;
        P2[a]++;
    }
    for(auto x:P2){
        if(P1[x.first]<x.second){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
}


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

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound

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

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

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// setprecision()

LL Gcd(LL a, LL b) {
  if (a < b) {
    return Gcd(b,a);
  }
  if (b == 0) {
    return a;
  }
  else {
    return Gcd(b,a%b);
  }
}

LL Lcm(LL a, LL b) {
  LL abd = Gcd(a,b);
  LL x = a / abd, y = b / abd;
  
  return x*y*abd;
}


LL RepSqu(LL N, LL P, LL M) {
  if(P == 0) {
    return 1;
  }
  if(P%2 == 0) {
    LL t = RepSqu(N, P/2, M);
    return t*t % M;
  }
  return (N * RepSqu(N, P-1, M)) % M;
}


//-------------------------------------------

int main() {
  
  LL A,B;
  cin >> A >> B;
  
  LL x = Gcd(A,B);
  LL i = 2, ans=1;
  while(x>1){
    if(i*i > x){
      ans++;
      break;
    }
    if(x%i == 0){
      ans++;
      while(x%i == 0){
        x /= i;
      }
    }
    else i++;
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
function main(input) {
  const N = parseInt(input, 10);
  let AN = N;
  let S = 0;
  
  while(true) {
    if (AN < 1) {
      S += AN;
      break;
    }
    S += Math.floor(AN % 10);
    AN = Math.floor(AN / 10);
  }
  
  if (N % S === 0) {
    console.log('Yes');
  } else {
    console.log('No');
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29512
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

typedef unsigned long long ULLONG;
typedef long long LLONG;

template <class _T> static _T tp_abs(const _T& a) {
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void getint(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void getint(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void getint(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}
static void getstring(char* buff) {
	if (scanf(" %s", buff) < 0) {
		printf("getstr error!\n");
	}
}
static const long long MOD_NUM = 1000000007LL;

static void C_task();

int main()
{
	C_task();
	fflush(stdout);
	return 0;
}

static void C_task()
{
	int N;
	getint(N);

	std::map<int, int> imap;

	for (int i = 0; i < N; i++) {
		int tmp; getint(tmp);
		imap[tmp]++;
	}

	const char* msg = "YES\n";
	for (auto it = imap.begin(); it != imap.end(); it++) {
		if (it->second != 1) {
			msg = "NO\n";
			break;
		}
	}
	printf(msg);
}



Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define ll long long
#define PI 3.14159265358979323846
using namespace std;
int main()
{
 ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  ll aa =max(a*c,a*d);
  ll bb = max(b*c,b*d);
  ll ans = max(aa,bb);
  cout << ans << endl;





}


Measured memory_bytes: 3648
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <functional>
#include <map>
using namespace std;

long long N, K, dp[44][100009];

int main() {
	cin >> N >> K;
	if (K >= 40) { cout << "0" << endl; return 0; }

	for (int i = 1; i <= N; i++) dp[1][i] = 1;
	for (int i = 2; i <= 40; i++) {
		for (int j = 1; j <= N; j++) {
			for (int k = 2 * j; k <= N; k += j) {
				dp[i][k] += dp[i - 1][j];
			}
		}
	}
	long long sum = 0;
	for (int i = 1; i <= N; i++) sum += dp[K][i];
	cout << sum << endl;
	return 0;
}


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


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


    ll a, b, c, d; cin >> a >> b >> c >> d;

    cout << max(max(a*c, a*d), max(b*c, b*d)) << endl;


    return 0;
}


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

typedef long long ll;
const ll N = 2e5 + 100, inF = 1e18;

ll n, k, a[N], b[N];

bool ok(ll c) {
	ll cnt = 0;
	for (int i = 0; i < n; i++)
		cnt += max(0LL, a[i] - (c / b[i]));
	return cnt <= k;
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n >> k;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n; i++)
		cin >> b[i];
	sort(a, a + n);
	sort(b, b + n, greater<ll>());
	ll l = -1, r = inF;
	while (r - l > 1) {
		ll c = (l + r) / 2;
		if (ok(c))
			r = c;
		else
			l = c;
	}
	cout << r;
}


Measured memory_bytes: 3328
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <list>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define p(x) cout << x << endl;

#define MOD 1000000007
#define PI 3.14159265359

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

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

    sort(a, a + n);

    p(a[n - 1] - a[0]);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
ll n,m,ans=1;
bool flag;
map<ll,ll> X;
const int MAX = 200000;
const int MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

void fact(){
    while(m){
        flag=false;
        For(i,2,sqrt(m)+2){
            if(m%i==0){
                flag=true;
                m/=i;
                X[i]++;
                break;
            }
        }
        if(flag) continue;
        X[m]++;
        break;
    }
}
void Main(){    
    cin>>n>>m;
    COMinit();
    fact();
    for(auto i:X){
        if(i.first!=1){
            ll x=i.second;
            ans*=COM(n-1+x,x);
            ans%=MOD;
        }
    }
    cout<<ans%MOD<<endl;
}
int main(){
    Main();
    return 0;
}


Measured memory_bytes: 4992
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

int main(){
        
    ios_base::sync_with_stdio(0);
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int n;
    cin>>n;
    cout<<1000*(n/500)+5*((n%500)/5)<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>

#define FOR(i, a, b) for (int i = a; i < b; i++)
#define FORN(i, a, b) for (int i = a; i <= b; i++)
#define P(s) cout << s << endl
#define PC(condition, _true, _false) if (condition) _true; else _false;

using namespace std;
//
// Created by karayuu on 2019-3-28.
//

int main() {
    int a[26] = {0};
    char c;

    while (cin >> c) {
        if (c == EOF) break;
        if (c == ' ' || c == '.') continue;
        c = (char) tolower(c);
        a[c - 'a'] += 1;
    }
    //アルファベットは26文字
    FOR(i, 0, 26) {
        char d = static_cast<char>('a' + i);
        cout << d << " : " << a[i] << endl;
    }
}


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

int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	int All = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		All ^= A[i];
	}
	for (int i = 0; i < N; i++) cout << (All ^ A[i]) << (i < N - 1 ? " " : "\n");
}


Measured memory_bytes: 3992
#define y1 askjdkasldjlkasd
#include <bits/stdc++.h>
#undef y1

using namespace std;

#define pb push_back
#define mp make_pair
#define fi(a, b) for(int i=a; i<=b; i++)
#define fj(a, b) for(int j=a; j<=b; j++)
#define fo(a, b) for(int o=a; o<=b; o++)
#define fdi(a, b) for(int i=a; i>=b; i--)
#define fdj(a, b) for(int j=a; j>=b; j--)
#define fdo(a, b) for(int o=a; o>=b; o--)
#define sz(x) (int)x.size()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<ll> vll;

#ifdef LOCAL
#define err(...) fprintf(stderr, __VA_ARGS__)
#else
#define err(...) while (0)
#endif

double START_TIME;

void exit() {
#ifdef LOCAL	
	cerr << "TIME: " << setprecision(5) << fixed << (clock() - START_TIME) / CLOCKS_PER_SEC << endl;
#endif	
	exit(0);
}

template<typename A, typename B>
ostream& operator<<(ostream& os, pair<A, B> p) {
	os << "(" << p.first << ", " << p.second << ")";
	return os;
}

template<typename T>
ostream& operator<<(ostream& os, vector<T> v) {
	fi(0, sz(v) - 1) {
		os << v[i] << " ";
	}
	return os;
}

template<typename T>
ostream& operator<<(ostream& os, set<T> t) {
	for (auto z : t) {
		os << z << " ";
	}
	return os;
}

template<typename T1, typename T2>
ostream& operator<<(ostream& os, map<T1, T2> t) {
	cerr << endl;
	for (auto z : t) {
		os << "\t" << z.first << " -> " << z.second << endl;
	}
	return os;
}

#ifdef LOCAL
#define dbg(x) {cerr << __LINE__ << "\t" << #x << ": " << x << endl;}
#define dbg0(x, n) {cerr << __LINE__ << "\t" << #x << ": "; for (int ABC = 0; ABC < n; ABC++) cerr << x[ABC] << ' '; cerr << endl;}
#else
#define dbg(x) while(0){}
#define dbg0(x, n) while(0){}
#endif

#ifdef LOCAL
#define ass(x) if (!(x)) { cerr << __LINE__ << "\tassertion failed: " << #x << endl, abort(); }
#else
#define ass(x) assert(x)
#endif

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

const int MAX = 1e5 + 41;

int n, m;
vi e[MAX];
set<pii> ans;

int deg[MAX];
int u[MAX];

void add(int x, int y) {
	if (ans.find(mp(y, x)) != ans.end()) {
		ans.erase(mp(y, x));
		deg[y] ^= 1;		
	}
	ans.insert(mp(x, y));
	deg[x] ^= 1;
}

void dfs(int x, int p = -1) {
	u[x] = 1;
	for (int y : e[x]) {
		if (y == p) continue;
		if (u[y] == 2) continue;
		if (u[y]) {
			add(y, x);
		} else {
			dfs(y, x);
			if (deg[y]) {
				add(y, x);
			} else {
				add(x, y);
			}
		}
	}
	u[x] = 2;
}

void solve () {
	dfs(0);
	dbg0(deg, n);
	dbg(ans);
	if (deg[0]) {
		printf("-1\n");
		return;
	} 
	for (auto z : ans) {
		printf("%d %d\n", z.first + 1, z.second + 1);
	}
}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	START_TIME = (double)clock();
#endif

	scanf("%d %d", &n, &m);
	fo(1, m) {
		int x, y;
		scanf("%d %d", &x, &y);
		x--, y--;
		e[x].pb(y);
		e[y].pb(x);
	}
	solve();

	exit();
	return 0;
}





Measured memory_bytes: 20096
//by Top1
#include <bits/stdc++.h>
          
#define f first
#define s second
#define int long long
#define ld long double
#define ull unsigned long long
#define pii pair <int, int>
#define pll pair <long, long>
#define mp make_pair
#define pb push_back
#define pf push_front
#define pp pop_back
#define cerr cout
#define rev reverse
#define all(s) s.begin(), s.end()
#define sz(s) (int)s.size()
#define forn(i, a, b) for (int i = a; i <= b; i++)
#define boost ios_base::sync_with_stdio(false); cin.tie(0),cout.tie(0);
#define nxtp next_permutation
#define pvtp prev_permutation
#define KZ return 
#define x1 x21212121
#define y1 y21212121
#define sqr(x) x * x 
      
const int inf = (1e9) + 1;
const int mod = 479001599;
const int maxn = 1e6 + 111;
        
using namespace std;          

int x, y, A, B, C, a[maxn], b[maxn], c[maxn]; 

void solve(){
	cin >> x >> y >> A >> B >> C;
    
    for (int i = 1; i <= A; i++)
    	cin >> a[i];

    for (int i = 1; i <= B; i++)
    	cin >> b[i];

    for (int i = 1; i <= C; i++)
    	cin >> c[i];

    sort(a + 1, a + A + 1);
    sort(b + 1, b + B + 1);
    sort(c + 1, c + C + 1);
    rev(a + 1, a + A + 1);
    rev(b + 1, b + B + 1);
    rev(c + 1, c + C + 1);      

    int sum = 0, pos1 = 1, pos2 = 1, pos3 = 1;

    multiset <int> s, t;

    for (int i = 1; i <= x; i++){
    	sum += a[i];
    	s.insert(a[i]);
    }

    for (int i = 1; i <= y; i++){
    	sum += b[i];
    	s.insert(b[i]);
    }

    for (int i = 1; i <= C; i++){
    	sum += c[i];
    	s.insert(c[i]);
    	sum -= *s.begin();
    	s.erase(s.begin());
    }

    cout << sum;
}                              
      
main(){
    boost;
    
    int q = 1;
 
    //cin >> q;
    
    while (q--){
        solve();
    }
}

Measured memory_bytes: 17664
#include <bits/stdc++.h>
using namespace std;
int main() {
  int H,W;
  cin >> H >> W;
  vector<vector<char> > C(H, vector<char>(W));
  vector<vector<char> > ans(2 * H, vector<char>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> C[i][j];
    }
  }
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      ans[i * 2][j] = C[i][j];
      ans[i * 2 + 1][j] = C[i][j];
    }
  }
  for (int i = 0; i < 2 * H; i++) {
    for (int j = 0; j < W; j++) {
      cout << ans[i][j];
    }
    cout << endl;
  }
  return 0;
}

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

#define pb push_back
#define F first
#define S second
#define y1 dasdasfasfas
#define x1 wqdadfasfasfas
#define All(c) c.begin(), c.end()
#define SZ(A) (int((A).size()))
#define umap unordered_map
#define __ fflush(stdout)
#define FILENAME ""

typedef long long ll;
typedef long double ld;    

using namespace std;

void FREOPEN() {
	#ifdef LOCAL
		freopen(".in", "r", stdin);
		freopen("1.out", "w", stdout);
	#else
		//freopen(FILENAME".in", "r", stdin);
		//freopen(FILENAME".out", "w", stdout);
	#endif
}

inline double Time() {return (clock() * 1.0) / CLOCKS_PER_SEC; }             

const int N = 17, inf = 1e9 * 2;

const ll MOD = 1e9 + 7ll, INF = 1e18;

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

int n;

int Bit(int x, int b) {
	if (x & (1 << b)) return 1;
	return 0;
}

int diff(int A, int B) {
	int d = 0;
	for (int i = 0; i < n; i++) {
		if (Bit(A, i) != Bit(B, i)) d++;
	}
	return d;
}

int rem(int A, int bit) {
	int fi = A & ((1 << bit) - 1);
	int se = (A >> (bit + 1)) << bit;
	return fi | se;
}

int add(int A, int bit, int x) {
	int fi = A & ((1 << bit) - 1);
	int se = (A >> bit) << (bit + 1);
	if (x) se |= (1 << bit);
	return fi | se;
}

vector<int> solve(int A, int B, int n) {
	if (n == 1) {
		return {A, B};
	}
	vector<int> ret;
	int x = -1;
	for (int bit = 0; bit < n; bit++) {
		if (Bit(A, bit) != Bit(B, bit)) {
			x = bit;
			break;
		}
	}	
	assert(x != -1);
	int nA = rem(A, x), nB = rem(B, x);
	int C = nA;
	C ^= 1;
	vector<int> first = solve(nA, C, n - 1), second = solve(C, nB, n - 1);
	for (auto i : first) ret.pb(add(i, x, Bit(A, x)));
	for (auto i : second) ret.pb(add(i, x, Bit(B, x)));
	return ret;
}

int main() {
	FREOPEN();
	int A, B;
	cin >> n >> A >> B;
	if (diff(A, B) & 1) {
		puts("YES");
		vector<int> ans = solve(A, B, n);
		for (auto i : ans) printf("%d ", i);
	} 
	else puts("NO");
	return 0;
}


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

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

  if ( A + B > C + D ) {
    cout << "Left" << endl;
  } else if ( A + B == C + D ){
    cout << "Balanced" << endl;
  } else {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Class312
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            var v = Console.ReadLine().Split().Select(int.Parse).ToArray();
            PriorityQueue<double> que = new PriorityQueue<double>(N, (x, y) => x.CompareTo(y));
            for (int i = 0; i < N; i++) que.Push(v[i]);

            while (que.Size > 1)
            {
                double a = que.Pop();
                double b = que.Pop();
                que.Push((a + b) / 2);
            }
            Console.WriteLine(que.Pop());
        }
    }

    //ヒープ
    //初期化は(x,y)=>x.compareto(y) 比較演算子で比較している
    public class PriorityQueue<T>
    {
        public long Size { get; private set; } = 0;
        public long MaxSize { get; private set; } = 0;
        private T[] m_heap;
        private Comparison<T> Comp = null;

        public PriorityQueue(long maxSize, Comparison<T> comp)
        {
            if (maxSize <= 0)
                throw new Exception();
            MaxSize = maxSize;
            m_heap = new T[maxSize];

            Comp = comp;
        }

        public void Push(T x)
        {
            if (Size == MaxSize)
            {
                T[] new_heap = new T[MaxSize << 1];
                Array.Copy(m_heap, new_heap, MaxSize);
                m_heap = new_heap;
                MaxSize <<= 1;
            }

            long i = Size++;
            while (i > 0)
            {
                long p = (i - 1) / 2;
                if (Comp(m_heap[p], x) <= 0)
                    break;
                m_heap[i] = m_heap[p];
                i = p;
            }
            m_heap[i] = x;
        }

        public T Pop()
        {
            if (Size == 0)
                throw new Exception("Queue is empty.");

            T result = m_heap[0];
            T x = m_heap[--Size];
            long i = 0;
            while (i * 2 + 1 < Size)
            {
                long c1 = i * 2 + 1, c2 = i * 2 + 2;
                if (c2 < Size && Comp(m_heap[c2], m_heap[c1]) < 0)
                    c1 = c2;
                if (Comp(m_heap[c1], x) >= 0)
                    break;
                m_heap[i] = m_heap[c1];
                i = c1;
            }
            m_heap[i] = x;

            return result;
        }
    }
}


Measured memory_bytes: 11348