akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define range(i, l, r) for(int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

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

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    string S;
    cin >> S;
    lint num_trans = 0;
    char prev = S.at(0);
    range(i, 1, S.size()) {
        char c = S.at(i);
        if (c != prev) {
            num_trans += 1;
            prev = c;
        }
    }
    cout << num_trans << "\n";
}

Measured memory_bytes: 512
h,w = map(int,input().split())
m=[]
for i in range(h):
    m.append(list(input()))

for hi in range(h):
    for wi in range(w):
        if m[hi][wi] == "#":
            f = False
            for l in ([0,-1],[1,0],[0,1],[-1,0]):
                x=l[0]
                y=l[1]
                x +=hi
                y +=wi
                if 0<=x<h and 0<=y<w:
                    if m[x][y] == "#":
                        f=True
            if not f:
                print("No")
                exit()
print("Yes")



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

int main() {
	int n, m;
	scanf("%d %d", &n, &m);
	string s(n, ' ');
	scanf("%s", s.data());

	vector<vector<int>> graph(n);
	vector<array<int, 2>> cnt(n);

	while (m--) {
		int a, b;
		scanf("%d %d", &a, &b); a--; b--;
		graph[a].push_back(b);
		graph[b].push_back(a);
		cnt[a][s[b]-'A']++;
		cnt[b][s[a]-'A']++;
	}

	vector<int> rem;
	vector<bool> removed(n, false);
	for (int i = 0; i < n; i++)
		if (cnt[i][0] == 0 || cnt[i][1] == 0) {
			removed[i] = true;
			rem.push_back(i);
		}

	for (int i = 0; i < rem.size(); i++) {
		int x = rem[i];

		int inx = s[x] - 'A';
		
		for (int y : graph[x]) {
			if ((--cnt[y][inx]) == 0 && !removed[y]) {
				removed[y] = true;
				rem.push_back(y);
			}
		}
	}

	if (rem.size() == n) printf("No\n");
	else printf("Yes\n");

	return 0;
}

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


int main() {
	long long int a, b, n, k, cou = 2, h[1000005] = {}, w[1000] = {}, sum = 0;
	string str;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> h[i];
		if (h[i] - h[i - 1] > 0) { sum += h[i] - h[i - 1]; }
	}

	cout << sum;
}

Measured memory_bytes: 8064
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 06/13/20 21:03:09
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int n,k; cin>>n>>k;
  vector<int> A(n); for (auto& a:A) cin>>a;
  vector<int> ans(n);
  while (k--) {
    ans.assign(n, 0);
    for (int i = 0; i < n; i++) {
      ans[max(0, i-A[i])]++;
      if (i+A[i]+1 < n)
        ans[i+A[i]+1]--;
    }
    for (int i = 1; i < n; i++)
      ans[i] += ans[i-1];
    bool skip = true;
    for (int i = 0; i < n; i++) {
      if (ans[i] < n) {
        skip = false;
        break;
      }
    }
    if (skip)
      break;
    A = ans;
  }
  for (auto a:ans)
    cout << a << " ";
  cout << endl;

  return 0;
}


Measured memory_bytes: 4780
cards = []
for i in xrange(3):
	cards.append(raw_input())
inds = [0,0,0]
win = ['A','B','C']
cur = 0
while True:
	if inds[cur] >= len(cards[cur]):
		print win[cur]
		break
	else:
		temp = cards[cur][inds[cur]]
		inds[cur] += 1
		if temp == 'a':
			cur = 0
		elif temp == 'b':
			cur = 1
		else:
			cur = 2

Measured memory_bytes: 2568
n = int(input())
lst = []
for _ in range(n):
  x, y, h = map(int, input().split())
  if h != 0:
    lst.append([x, y, h])
if len(lst) == 1:
  print(*lst[0])
  quit()
for cx in range(101):
  for cy in range(101):
    a = True
    preh = abs(lst[0][0] - cx) + abs(lst[0][1] - cy) +lst[0][2]
    for x, y, h in lst[1:]:
      H = abs(x - cx) + abs(y - cy) + h
      if H != preh:
        a = False
        break
    if a:
      print(cx, cy, H)
      quit()
    

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int mod = 1e9 + 7;
const int N = 2005;
const int K = 50;
set < int > g1[N], g2[N];
int a[N][N];
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int H, W, h, w;
    cin >> H >> W >> h >> w;
    if (H % h == 0 && W % w == 0){
        cout << "No";
        return 0;
    }
    cout << "Yes" << endl;
    if (H % h != 0){
        int r = H % h;
        int x = 1e9;
        x /= h;
        int s1 = x * w * r;
        int y = -(s1 / (w * h - w * r) + 1);
        for (int i = 0; i < H; i++){
            for (int j = 0; j < W; j++){
                if (i % h < r){
                    a[i][j] = x;
                } else{
                    a[i][j] = y;
                }
            }
        }
    } else{
        int r = W % w;
        int x = 1e9;
        x /= w;
        int s1 = x * h * r;
        int y = -(s1 / (w * h - h * r) + 1);
        for (int i = 0; i < H; i++){
            for (int j = 0; j < W; j++){
                if (j % w < r){
                    a[i][j] = x;
                } else{
                    a[i][j] = y;
                }
            }
        }
    }
    for (int i = 0; i < H; i++){
        for (int j = 0; j < W; j++){
            cout << a[i][j] << " ";
        }
        cout << endl;
    }
}


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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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; }



string s;
void solve(){
	cin >> s;
	int n = s.size();
	
	for(int i = 0; i < n; i+=2){
		cout << s[i];
	}
	cout << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 592
#include <vector>
#include <list>
#include <map>
#include <string>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <utility>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;

ll solve(void);

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

ll solve(void)
{
	ll r;
	cin >> r;
	cout << r * r << endl;

	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#define REP(i, a, b) for (auto i = (a); i < (b); ++i)
using namespace std;

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

	int a, b; cin >> a >> b; cout << max(0, a - 2 * b);
}

Measured memory_bytes: 256
#Maximum Profit

n = int(input())

A = []
for i in range(n):
    A.append(int(input()))

minv = A[0]
maxv = A[1] - A[0]
for i in range(1,n):
    maxv = max(A[i]-minv,maxv)
    minv = min(A[i],minv)


print(maxv) 


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

int main(){
    long long a, b ,n,maxi = 0;
    long long l = 0,r;
    cin >> a >> b >> n;

    r = n + 1;

    while(l < r){
        long long mid = (l + r) / 2;
        if(((a * mid)/ b) - (a * (mid / b)) < maxi)r = mid;
        else{
            l = mid + 1;
            maxi = ((a * mid)/ b) - a * (mid / b);
        }
    }
    cout << maxi << endl;

}

Measured memory_bytes: 3636
s = 0
kei = 0
i = input()
iline = []
iline = input().split(" ")
ilinei = [int(a) for a in iline]
ilinei.sort()
for s in range(int(i)):
    kei = kei + int(ilinei[s])
s = int(i) - 1
print(str(ilinei[0]) + " " + str(ilinei[s]) + " " + str(kei))



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

int main() {
    long long N;
    cin >> N;
    long long tmp = N % 10;
    if (tmp == 2 || tmp == 4 || tmp == 5 || tmp == 7 || tmp == 9) {
        cout << "hon" << endl;
    } else if (tmp == 0 || tmp == 1 || tmp == 6 || tmp == 8) {
        cout << "pon" << endl;
    } else {
        cout << "bon" << endl;
    }
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <map>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

char a, b;
int main() {
	cin >> a >> b;
	if (a == b) cout << 'H' << endl;
	else cout << 'D' << endl;
	
	return 0;
}

Measured memory_bytes: 256
import sys
L,R=map(int, sys.stdin.readline().split())
sho1=L/2019
sho2=R/2019
if 1<=sho2-sho1:
    print 0
else:
    ans=float("inf")
    for i in range(L,R):
        for j in range(i+1,R+1):
            ans=min(ans,i*j%2019) 
    print ans

Measured memory_bytes: 30572
import sys
input = sys.stdin.readline

d = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(d)]

t = [int(input()) for _ in range(d)]
last = [-1] * 26

v = 0

for i in range(d):
    v += s[i][t[i] - 1]
    last[t[i]-1] = i
    for j in range(26):
        v -= (i - last[j]) * c[j]
        
    print(v)


Measured memory_bytes: 9256
#include <iostream>
#include <cmath>

using namespace std;

int A, B, C;
int R;

double norm(double x, double y) {
	return sqrt(x * x + y * y);
}

bool isok() {
	return (norm(A, B) / 2.0 < R || norm(B, C) / 2.0 < R || norm(C, A) / 2.0 < R);
}

int main() {
	while (1) {
		cin >> A >> B >> C; if (A == 0 && B == 0 && C == 0) break;
		int n; cin >> n;
		for (int i = 0; i < n; i++) {
			cin >> R;
			if (isok()) cout << "OK" << endl;
			else cout << "NA" << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1152
#include<stdio.h>

int main(void){
  int n , k;
  scanf("%d %d",&n ,&k);

  int check[10] = {0} , a;
  for(int i = 0;i < k;i ++){
    scanf("%d",&a);
    check[a] ++;
  }

  int ans , flag = 0;
  for(int i = n;i < 1000000;i ++){
    int temp = i , b;
    while(temp > 0){
      b = temp%10;
      if(check[b] != 0){
        temp = 0;
        flag = 1;
      }
      temp /= 10;
    }
    if(flag == 0){
      ans = i;
      i += 10000000;
    }
    flag = 0;
  }


  printf("%d\n",ans);

  return 0;
}

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

namespace Contest20191031
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            bool b1 = true;
            bool b2 = true;

            for(int i = 0; i < s.Length; i++)
            {
                if(i % 2 == 0) // 奇数文字目
                {
                    if (s[i] != 'R' && s[i] != 'U' && s[i] != 'D')
                        b1 = false;     
                }

                else // 偶数文字目
                {
                    if (s[i] != 'L' && s[i] != 'U' && s[i] != 'D')
                        b2 = false;
                }

            }
            if (b1 && b2)
                Console.WriteLine("Yes");

            else
                Console.WriteLine("No");

        }
    }
}


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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
typedef int64_t Int;
typedef std::vector<Int> LI;
const double pi = 3.14159265358979323846264338;
const Int mod = 1000000007;

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(Int& x) { if( scanf("%" PRId64, &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
template<> void scan1(LI& xs) { for(Int &x : xs) scan1(x); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

template<typename T>
struct Maybe {
   T x;
   bool valid;
   Maybe() : valid(false) {}
   Maybe(T x_) : x(x_), valid(true) {}
   operator T() const {
      assert( valid );
      return x;
   }
};

struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   void solve() {
      // Int n; scan(n);
      // for(Int x = 1; x <= 3500; ++x) {
      //    Int a = 4 * x - n;
      //    Int b = n * x;
      //    Int d = a * a - 4 * b;
      //    dumplll(a, b, d);
      //    // if( d < 0 ) continue;
      //    Int r = sqrt(d);
      //    dumpl(r);
      //    // if( r * r != d ) continue;
      //    // if( (a + r) % 2 != 0 ) continue;
      //    Int y = (a + r) / 2;
      //    Int z = (a - r) / 2;
      //    dumpll(y, z);
      //    // if( y < 0 or z < 0 ) continue;
      //    printf("%ld %ld %ld\n", x, y, z);
      //    break;
      // }
      Int n; scan(n);
      for(Int x = 1; x <= 3500; ++x) {
         for(Int y = 1; y <= 3500; ++y) {
            Int a = 4 * x * y - n * (x + y);
            Int b = n * x * y;
            if( a == 0 ) continue;
            if( b % a == 0 and b / a >= 1 ) {
               printf("%ld %ld %ld\n", x, y, b / a);
               return;
            }
         }
      }
   }
};

int main() {
   loop std::unique_ptr<Solver>(new Solver())->solve();
}




Measured memory_bytes: 256
# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
import sys
def main(N, A):
    ans = 0
    for i in range(1, N):
        if A[i] < A[i - 1]:
            t = A[i - 1] - A[i]
            A[i] += t
            ans += t
    print(ans)

if __name__ == '__main__':
    input = sys.stdin.readline
    N = int(input())
    *A, = map(int, input().split())
    main(N, A)


Measured memory_bytes: 95460
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; } value
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  double n;
  cin >> n;
  cout << 6.28 * n << endl;
}

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

int gcd(int a, int b){
  int ma=max(a, b);
  int mb=min(a, b);
  if(ma%mb==0){
    return mb;
  }
  else{
    return gcd(ma%mb, mb);
  }
}

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin >> A.at(i);
  }
  int Ans=gcd(A.at(0), A.at(1));
  for(int i=0; i<N; i++){
    Ans=gcd(Ans, A.at(i));
  }
  cout << Ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b&&b==c){
    cout<<"1"<<endl;
  }
  else if(a==b||b==c||c==a){
    cout<<"2"<<endl;
  }
  else{
    cout<<"3"<<endl;
  }
  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;
typedef pair<double, int> P;
int main()
{
    int n;
    string s;
    cin >> s;
    n = s.length();
    int ans = n;
    rep(i, n - 1)
    {
        if (s[i] != s[i + 1])
        {
            ans = min(max(n - i - 1, i + 1), ans);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
/* 163-A.cpp
 *     Created on : Apr 19, 2020 
 *     Time       : 5:57:48 PM
 *     Author     : null_ptr
 */
#include<iostream>
#include<cmath>
#include<iomanip>

using namespace std;

const double pi=acos(-1);
int main()
{
	int n;
	cin>>n;
	cout<<setprecision(2)<<fixed<<pi*2.0*n<<'\n';
}


Measured memory_bytes: 3788
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <utility>
#include <algorithm>
using namespace std;


int main(void){
    // Your code here!
    int n, a, t;
    cin>>n>>t>>a;
    vector<int> h(n);
    
    for(int i=0; i<n; i++){
        cin>>h[i];
    }
    
    int idx=0;
    double cmin=10000.0;
    for(int i=0; i<n; i++){
        double temp=t-0.006*h[i];
        
        if(fabs(a-temp)<cmin){
            cmin=fabs(a-temp);
            idx=i;
        }
    }
    
    cout<<idx+1<<endl;
    
}


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

#define rep(i, n) for(int i = 0; i < n; ++i)
#define all(a) a.begin(), a.end()
#define ll long long
#define mod 1e9+7

using namespace std;

int main()
{
  ll n, k;
  cin >> n >> k;
  ll ans = k * pow(k - 1, n - 1);
  cout << ans << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>

#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;

int main() {
    int n; cin >> n;
    vector<int> nums;
    for(int i = 0; i < n; ++i){
        int x; cin >> x;
        nums.push_back(x);
    }
    sort(nums.begin(), nums.end());
    int ans = 0;
    if(n % 2 == 0){
        ans = nums[n / 2] - nums[n / 2 - 1];
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 892
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <utility>
using std::min;
typedef long long int64;
static const int INF = 0x3fffffff;
static const int MAXN = 103;

namespace nwf {

static const int MAXN = 20004;
static const int MAXM = 1e7 + 3;

int n, m, source, sink;
int head[MAXN], dest[MAXM], cap[MAXM], next[MAXM];

inline void init(int _n) { n = _n, m = 0; for (int i = 0; i < n; ++i) head[i] = -1; }
inline void add_edge(int u, int v, int c) {
    dest[m] = v; cap[m] = c; next[m] = head[u]; head[u] = m++;
    dest[m] = u; cap[m] = 0; next[m] = head[v]; head[v] = m++;
}

int d[MAXN], cur[MAXN];
inline bool level_graph()
{
    static int q[MAXN], qhead, qtail;
    memset(d, -1, sizeof d);
    d[source] = 0, q[0] = source; qhead = 0, qtail = 1;
    while (qhead < qtail) {
        int u = q[qhead++];
        for (int w = head[u]; w != -1; w = next[w])
            if (cap[w] > 0 && d[dest[w]] == -1) {
                d[dest[w]] = d[u] + 1;
                q[qtail++] = dest[w];
            }
    }
    return (d[sink] > 0);
}

int augment(int u, int cur_cap = INF)
{
    if (u == sink) return cur_cap;
    int new_cap;
    for (int &w = cur[u]; w != -1; w = next[w])
        if (cap[w] > 0 && d[dest[w]] == d[u] + 1 && (new_cap = augment(dest[w], min(cur_cap, cap[w]))) > 0) {
            cap[w] -= new_cap;
            cap[w ^ 1] += new_cap;
            return new_cap;
        }
    return 0;
}

inline int plunge(int s, int t)
{
    source = s, sink = t;
    int ans = 0, aug;
    while (level_graph()) {
        for (int i = 0; i < n; ++i) cur[i] = head[i];
        while ((aug = augment(source)) > 0) ans += aug;
    }
    return ans;
}

}

int h, w;
char s[MAXN][MAXN];

inline bool is_lotus(char c) { return c == 'S' || c == 'T' || c == 'o'; }

int main()
{
    scanf("%d%d", &h, &w); getchar();
    for (int i = 0; i < h; ++i)
        for (int j = 0; j <= w; ++j) s[i][j] = getchar();

    nwf::init(h * w * 2);
    for (int i = 0; i < h; ++i)
        for (int j = 0; j < w; ++j) if (is_lotus(s[i][j])) {
            nwf::add_edge((i * w + j) * 2, (i * w + j) * 2 + 1, 1);
            for (int ii = i - 1; ii >= 0; --ii)
                if (is_lotus(s[ii][j])) { nwf::add_edge((i * w + j) * 2 + 1, (ii * w + j) * 2, INF); }
            for (int ii = i + 1; ii < h; ++ii)
                if (is_lotus(s[ii][j])) { nwf::add_edge((i * w + j) * 2 + 1, (ii * w + j) * 2, INF); }
            for (int jj = j - 1; jj >= 0; --jj)
                if (is_lotus(s[i][jj])) { nwf::add_edge((i * w + j) * 2 + 1, (i * w + jj) * 2, INF); }
            for (int jj = j + 1; jj < w; ++jj)
                if (is_lotus(s[i][jj])) { nwf::add_edge((i * w + j) * 2 + 1, (i * w + jj) * 2, INF); }
        }

    int s_id = -1, t_id = -1;
    for (int i = 0; i < h; ++i)
        for (int j = 0; j < w; ++j)
            if (s[i][j] == 'S') s_id = (i * w + j) * 2 + 1;
            else if (s[i][j] == 'T') t_id = (i * w + j) * 2;
    int ans = nwf::plunge(s_id, t_id);
    printf("%d\n", ans > INF / 2 ? -1 : ans);

    return 0;
}


Measured memory_bytes: 49408
#include <iostream>
#include <string.h>
using namespace std;

int main() {
	int n;
	int score=0;
	int count=0;
	int base=0;
	string d;
	cin>>n;
	for(int i=0;i<n;i++){
		while(true){
			cin>>d;
			if(d=="HIT"){
				base++;
				if(base==4){
					score++;
					base--;
				}
			}
			else if(d=="HOMERUN"){
				score=score+base+1;
				base=0;
			}
			else if(d=="OUT"){
				count++;
				if(count==3){
					count=0;
					cout<<score<<endl;
					score=0;
					base=0;
					break;
				}
			}
		}
	}
	return 0;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define all(x) begin(x), end(x)
#define loop(i,n) for(int i=0; i<n; i++)
#define rep(i,a,b,c) for(int i=a; i<b; i+=c)
#define brep(i,a,b,c) for(int i=a; i>b; i-=c)
#define tc(t) int t; cin>>t; while(t--)
#define sz(v) int((v).size())
#define pb push_back


using namespace std;

void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {std::cout << x;}
void __print(unsigned x) {std::cout << x;}
void __print(unsigned long x) {std::cout << x;}
void __print(unsigned long long x) {std::cout << x;}
void __print(float x) {std::cout << x;}
void __print(double x) {std::cout << x;}
void __print(long double x) {std::cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i : x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
template <typename T> inline void inp(T &any) {cin >> any;} template <typename T, typename... U>inline void inp(T &a, U &...b) {cin >> a; inp(b...);}
#define rin(args...) ll args; inp(args);
#ifndef ONLINE_JUDGE
#define debug(x...) cout << "[" << #x << "] = ["; _print(x)
#define matdeb(mat,row,col) cout << #mat << "::" << endl; printmat(mat,row,col); printpartition;
#define debugv(v,n) cout << #v << ":" << endl; printv(v,0,n-1); printpartition;
#else
#define debug(x...)
#define matdeb(mat,row,col)
#define debugv(v,n)
#endif

const int maxm = 1000000000 + 7;

const ll MOD = 1e9 + 7;
const int INF = 55;
ll dp [INF] [INF * INF];

double startTime;
double getCurrentTime() {
    return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}


//----------->CODE BEGINS --------------->


int main()
{

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    IOS;

   int t; cin>>t;

   ll a , b;
   cin>>a>>b;

   t--;

   while(t--)
   {
     ll l,r; cin>>l>>r;

     ll j = max((a-1)/l , (b-1)/r)+1;
     debug(j);

     a = j*l;
     b = j*r;
     debug(a);debug(b);
   }
  
  cout<<a+b<<endl;


}


Measured memory_bytes: 3564
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, H;
    cin >> N >> H;
    int a[100010], b[100010];
    int cnt = 0;
    rep(i, N) {
        cin >> a[i] >> b[i];
    }
    sort(a, a + N, greater<int>());
    sort(b, b + N, greater<int>());
    rep(i, N) {
        if (a[0] > b[i]) break;
        H -= b[i];
        cnt++;
        if (H <= 0) {
            cout << cnt << endl;
            return 0;
        }
    }
    cout << cnt + (a[0] + H - 1) / a[0] << endl;

    return 0;
}


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

using namespace std;

// Repetitions
#define FOR(i,a,n) for(ll i = ((ll) a); i < ((ll) n); ++i)
#define FORR(i, s, g) for(ll i = ((ll)s - 1); i >= ((ll) g); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, n, 0)

// Container Utils
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SORTALL(v) sort(ALL(v))
#define SZ(a) int((a).size())
#define CLR(a) memset((a), 0 ,sizeof(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())

// For Debug
#define DMP(x)  cerr << #x << " = " << (x) << endl
#define DBG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

// Aliases
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef string str;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

// I/O Asynchronizing
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

#define MAX_H 1000
#define MAX_W 1000

int h, w;
char board[MAX_H][MAX_W];

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

inline bool is_in_range(const int y, const int x) {
    return 0 <= y && y < h && 0 <= x && x < w;
}

int bfs(const pii &start, const pii &end) {
    bool visited[MAX_H][MAX_W] = { false };
    visited[start.first][start.second] = true;
    queue<pair<int, pii> > que;
    que.push(make_pair(0, start));
    while(!que.empty()) {
        int stp = que.front().first;
        pii now = que.front().second;
        que.pop();
        REP(i, 4) {
            int ny = now.first + dy[i], nx = now.second + dx[i];
            if(is_in_range(ny, nx) && board[ny][nx] != 'X' && !visited[ny][nx]) {
                visited[ny][nx] = true;
                if(ny == end.first && nx == end.second) return stp + 1;
                else {
                    que.push(make_pair(stp + 1, make_pair(ny, nx)));
                }
            }
        }
    }
    return -1;
}

int main() {
    int n;
    cin >> h >> w >> n;
    vpii loc(n + 1);
    REP(j, h) {
        REP(i, w) {
            char c;
            cin >> c;
            if(c == 'S') {
                loc[0].first = j;
                loc[0].second = i;
            }
            else if('1' <= c && c <= '9') {
                int idx = c - '0';
                loc[idx].first = j;
                loc[idx].second = i;
            }
            board[j][i] = c;
        }
    }
    int ans = 0;
    REP(i, n) {
        ans += bfs(loc[i], loc[i + 1]);
    }
    cout << ans << "\n";

    return 0;
}



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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int inf = 1e9;
const int mod = 1e9+7;
const int maxn = 1e5+5;
int A[maxn], dp[maxn];

int dfs(const int i)
{
    if (i == 0)
        return 1;
    int& ans = dp[i];
    if (-1 == ans) {
        ans = 0;
        FOR(d,1,3) {
            const int x = i-d;
            if (0 <= x && A[x]) {
                ans += dfs(x);
                ans %= mod;
            }
        }
    }
    return ans;
}

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    int n,m;
    while (cin >> n >> m) {
        memset(dp,-1,sizeof(dp));
        FOR(i,0,n+1)
            A[i] = 1;
        FOR(i,0,m) {
            int a; cin >> a;
            A[a] = 0;
        }
        cout << dfs(n) << endl;
    }
    return 0;
}


Measured memory_bytes: 5760
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
#include <climits>
using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RREP(i,n) for(int i=(int)n-1; i>=0; i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();++i)
#define ALL(c) (c).begin(), (c).end()

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

const int INF = 1e9;
const int MOD = 1e9+7;

vector<int> eratosthenes (int n){
    vector<int> primes(n);
    primes[0] = primes[1] = 0;
    for (int i = 2; i < n; i++) primes[i] = i;
    for (int i = 2; i < n; i++)
        if (primes[i])
            for (int j = i<<1; j < n; j += i) primes[j] = 0;
    vector<int>::iterator it = remove(primes.begin(), primes.end(), 0);
    primes.erase(it, primes.end());
    return primes;
}

int main(void){
    int n, p;
    vi el = eratosthenes(1000000);
    while(cin >> n >> p, n != -1){
        vi l, r;
        REP(i, el.size()){
            if(el[i] > n) l.push_back(el[i]);
            if(l.size() > p + 1) break;   
        }
        REP(i, l.size()){
            for(int j = i; j < l.size(); j++){
                r.push_back(l[i] + l[j]);
            }
        }
        sort(ALL(r));
        //r.erase(unique(ALL(r)), r.end());
        //REP(i, r.size()) cout <<  i<< "*" << r[i] << endl;


        cout << r[p-1] << endl;
    }

    return 0;
}

Measured memory_bytes: 5164
N=int(input())
li= list(map(int,input().split())) 	
Ans=30
ans=0

for i in range(N):
	if li[i]%2==1:
		Ans=0
		break
	else:
		n=li[i]
		ans=0
		while n%2==0:
			n=n/2
			ans= ans+1
		if Ans>ans:
			Ans =ans

print(Ans)

Measured memory_bytes: 3060
/// In the name of God
#include <bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;

#define y1 def1
#define X first
#define Y second
#define endl '\n'
#define all(o) o.begin(), o.end()
#define IOS ios::sync_with_stdio(0), cin.tie(0)

int upd(int y,int r){
    int t1 = max(y - r, (y + 2) / 2);
    int t2 = y;
    //cout << t1 << " " << t2 << endl;
    int t3 = y, t4 = r + y;
    t1 = max(t1, r + 1);
    t3 = max(t3, r + 1);
    //cout << t1 << " " << t2 << " " << t3 << " " << t4 << endl;
    if(t1 > t3) swap(t1, t3);
    if(t1 > t2 && t3 > t4) return r;
    if(t1 <= t2 && t3 <= t4){
        if(t1 != r + 1) return r;
        t3 = max(t3, t2 + 1);
        if(t3 != t2+1) return t2;
        return t4;
    }
    if(t1 <= t2){
        if(t1 != r + 1) return r;
        return t2;
    }
    swap(t1, t3);
    swap(t2, t4);
    if(t1 != r + 1) return r;
        return t2;

}
const int maxn = 5e5 + 10;
int dp[maxn], a[maxn], ans[maxn];
main(){
    IOS;
    int n, D;
    cin >> n >> D;
    for(int i=0; i<n; i++)
        cin >> a[i];
    for(int i=n-1; i>=0; i--)
        dp[i] = upd(a[i], dp[i + 1]);
    int cur = D;
    for(int i=0; i<n; i++){
        if(cur <= dp[i + 1]) ans[i] = 0;
        else ans[i] = 1;
        if(cur >= a[i]) cur -= a[i];
        else if(a[i] - cur < cur) cur = a[i] - cur;
    }
    int q;
    cin >> q;
    for(int i=0; i<q; i++){
        int ind;
        cin >> ind;
        ind--;
        if(ans[ind])
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }
}


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

const int MOD = 1000000007;

const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

int main()
{
    int A, B;
    cin >> A >> B;
    if (A >= 1 && A <= 9 && B >= 1 && B <= 9) {
        cout << A * B << endl;
    } else {
        cout << -1 << endl;
    }
}


Measured memory_bytes: 256
import java.util.*;

class Main{

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

    void solve(){
        Scanner sc = new Scanner(System.in);

        while(true){
            w = sc.nextInt();
            h = sc.nextInt();
            if(w==0 && h==0) break;

            map = new int[h][w];
            for(int i=0; i<h; i++){
                for(int j=0; j<w; j++) map[i][j] = sc.nextInt();
            }

            int cnt = 0;
            for(int i=0; i<h; i++){
                for(int j=0; j<w; j++){
                    if(map[i][j]==1){
                        bfs(j, i);
                        cnt++;
                    }
                }
            }

            System.out.println(cnt);
        }
    }

    void bfs(int sx, int sy){
        LinkedList<int[]> list = new LinkedList<int[]>();
        list.add(new int[]{sx, sy});
        map[sy][sx] = 0;

        while(list.size()>0){
            int[] xy = list.poll();
            int x = xy[0], y = xy[1];

            for(int i=0; i<8; i++){
                int nx = x + dx[i], ny = y + dy[i];
                if(nx<0 || nx>=w || ny<0 || ny>=h || map[ny][nx]==0) continue;
                list.add(new int[]{nx, ny});
                map[ny][nx] = 0;
            }
        }
    }

    public static void main(String[] args){
        new Main().solve();
    }
}

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

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

using namespace std;
using lint=long long;

vector<lint> divisor(lint a){
	vector<lint> res;
	for(lint i=1;i*i<=a;i++) if(a%i==0) {
		res.emplace_back(i);
		if(i*i<a) res.emplace_back(a/i);
	}
	return res;
}

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

	int ans=0;
	for(int i=1;i<=n;i+=2) if(divisor(i).size()==8) ans++;
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<n;i++)
#define SFOR(i,a,b) for(int i=a;i<b;i++)
#define elif(a) else if(a)
#define INF INT_MAX
#define F first
#define S second
#define endl '\n'
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  int cnt=0,maxi=0;
  FOR(i,s.size()+1){
    if(s[i]=='A' || s[i]=='C' || s[i]=='G' || s[i]=='T'){
      cnt++;
    }else{
      maxi=max(maxi,cnt);
      cnt=0;
    }
  }
  cout<<maxi<<endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a, b) ((a < b) ? a : b)
#define _max(a, b) ((a < b) ? b : a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a) ? 1 : -1)
#define SORT(v) sort(v.begin(), v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

int main() {
    cout << fixed << setprecision(10);
    int A, B, C;
    cin >> A >> B >> C;
    cout << max(C - max(A - B, 0), 0);
    return 0;
}

Measured memory_bytes: 764
<?php

$n = (int)trim(fgets(STDIN));
$input = explode(' ', trim(fgets(STDIN)));

$answer = null;
for ($i=1; $i < $n; $i++) { 
	$tmp = $input[$i];
	if ($answer === null) {
		$answer = euc((int)$input[0], $tmp);
	}else{
		$answer = euc($answer, $tmp);
	}
	if ($answer === 1) {
		break;
	}
}

echo $answer;



function euc($a, $b){
	if ($a > $b) {
		$r = $a % $b;
		$ret = $b;
	}else{
		$r = $b % $a;
		$ret = $a;
	}
	if ($r === 0) {
		return $ret;
	}else{
		return euc($ret, $r);
	}
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<bool> vb;

const int MAXN=100001;

vector<vi> graph(MAXN);
vi from(MAXN), to(MAXN);
vi par(MAXN), deg(MAXN);

int dsfind(int x){
    return (x==par[x]) ? x : (par[x]=dsfind(par[x]));
}

void dfs(int cur, int prev, int e){
    for(int i:graph[cur]){
        int nto = from[i] + to[i] - cur;
        if(nto!=prev) dfs(nto, cur, i);
    }
    if(e==-1) return;
    if(deg[cur]%2){
        from[e]=prev;
        to[e]=cur;
        deg[cur]++;
    }else{
        from[e]=cur;
        to[e]=prev;
        deg[prev]++;
    }
}

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

    int n, m; cin >> n >> m;

    if(m%2){
        cout << "-1\n";
        return 0;
    }

    for(int i=1; i<=n; i++) par[i]=i;
    for(int i=1; i<=m; i++){
        cin >> from[i] >> to[i];
        int x = dsfind(from[i]);
        int y = dsfind(to[i]);
        if(x==y) deg[to[i]]++;
        else{
            par[x] = y;
            graph[from[i]].push_back(i);
            graph[to[i]].push_back(i);
        }
    }

    dfs(1,0,-1);

    for(int i=1; i<=m; i++){
        cout << to[i] << ' ' << from[i] << '\n';
    }

    return 0;
}


Measured memory_bytes: 13696
N, T = map(int, input().split())
prices = map(int, input().split())


profit_memo = []
min_price = next(prices)

for price in prices:
    if price < min_price:
        min_price = price
    else:
        profit_memo.append(price - min_price)

max_profit = max(profit_memo)
print(profit_memo.count(max_profit))


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

#define F first
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 310, M = 110;

int n;
int g[N][N];
bool st[N][N];

int main()
{
	cin >> n;
	for (int i = 1; i <= n; i ++ )
		for (int j = 1; j <= n; j ++ )
			cin >> g[i][j];
	
	for (int i = 1; i <= n; i ++ )
		for (int j = 1; j <= n; j ++ )
			for (int k = 1; k <= n; k ++ )
				if (k != j && k != i)
				{
					if (g[i][k] + g[k][j] < g[i][j])
					{
						puts("-1");
						return 0;
					}
					else if (g[i][k] + g[k][j] == g[i][j]) st[i][j] = true;
				}
				
	LL res = 0;
	for (int i = 1; i <= n; i ++ )
		for (int j = i + 1; j <= n; j ++ )
			if (!st[i][j])
				res += g[i][j];
	
	cout << res << endl;
	return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	int n;
	cin >> n;

	vector<int> a(n), b(n), c(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i] >> c[i];
	}

	vector<vector<int>> dp(n, vector<int>(3));
	// 0: 海(a)
	// 1: 山(b)
	// 2: 家(c)
	dp[0][0] = a[0];
	dp[0][1] = b[0];
	dp[0][2] = c[0];

	for (int i = 1; i < n; i++) {
		// 今日は海に行く
		dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i];
		// 今日は山に行く
		dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b[i];
		// 今日は家で過ごす
		dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c[i];
	}

	int ans = max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2]));
	cout << ans << endl;
	return 0;
}


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

int N;
vector<int> d;

int main()
{
  cin >> N;
  d.resize(N);

  for (int i = 0; i < N; i++)
  {
    cin >> d[i];
  }

  sort(d.begin(), d.end());

  cout << d[N / 2] - d[N / 2 - 1] << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string a,b;
	int x;
	int zh(string s);
	cin>>a>>b;
	x=zh(a+b);
	if(int(sqrt(x))==sqrt(x))
	   cout<<"Yes";
	else
	   cout<<"No";
	return 0;
}
int zh(string s)
{
	int tmp=0;
	for(int i=0;i<s.size();i++)
	tmp=tmp*10+(s[i]-'0');
	return tmp;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// atoi : atoi(変数名.c_str())
// to_string(数値)
// %0桁数d とすると表示桁数が「桁数」に満たない場合に0埋めされる
// find(): int i = 変数名.find(“文字列”) 何番目にあるかを得る
// cout << (条件 ? "Yes" : "No") << endl;
// printf("%02d:%02d:%02d",hour,minute,second);
// 降順 sort(a.begin(),a.end(),greater<int>());
// bitset<ビット数> 変数名;  // すべてのビットが0の状態で初期化される
// bitset<ビット数> 変数名("ビット列");  // 指定したビット列で初期化される
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)

int main(){
  int n,m;
  cin >> n >> m;
  long ans = 1800*m + 100*n;
  rep(i,m){
    ans *= 2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
ans = []
while a = gets.split.map(&:to_i)
  break if a[0] == 0
  ans << "\n"
  flag = true
  i = a[0]
  while i % 4 != 0
    i += 1
  end
  loop do
    break if i > a[1]
    if i % 4 == 0 && i % 100 != 0 || i % 400 == 0
       ans << i
      flag = false
    end
    i += 4
  end
  if flag
    ans << "NA"
  end
end
ans.shift
puts ans

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

int main()
{
    int n; cin >> n;
    bool flag = false;
    for (int i = 0; 4 * i <= n; i++) {
        if ((n - 4 * i) % 7 == 0) {
            flag = true;
        }
    }
    cout << ((flag) ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256