akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <numeric>
#include <stack>
#include <map> // pair
#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
typedef std::stack<int> IntStack;
typedef std::stack<char> charStack;

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

int main()
{
	ll a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	ll n, m, K;
	ll memo[1003][1003] = { {} };
	ll memox[1003] = {};
	ll memoy[1003] = {};
	ll x[1000006] = {};
	ll y[200005] = {};
	ll z[200005] = {};
	string s;
	string s1, s2;
	//IntStack yStack;
	//charStack Stack;
	//vector<pair<int, int> > pairs(a);
	cin >> a;
	cin >> b;
	cout << setprecision(15) << double(a)/b << endl;

	//cout << ans << endl;


	////std::cout << std::fixed;
	//cout << std::setprecision(20) << << endl;
	//cout << d+1 << endl;
	//cout << "" << endl;

	return 0;
}
//char型の文字数字は、-'0'で数値に変換できる
//accumulate(x, x + a, 0);//int型までの配列の合計
//memcpy(x, visited, sizeof(ll)*n);
//void kansuu(ll num, ll visited[10]) {}
//kansuu(1, zz);
//cout << setprecision(15) << v << endl;
//cout << char(z - 'a');
//log10(i) + 1 //10進数の桁数を取得

//int temp;
//for (int i = 0; i < n - 1; i++) {
//	for (int j = n - 1; j > i; j--) {
//		if (w[j - 1] < w[j]) {  /* 前の要素の方が大きかったら */
//			temp = w[j];        /* 交換する */
//			w[j] = w[j - 1];
//			w[j - 1] = temp;
//		}
//	}
//}

//最小公倍数
//ll x = a * b;
//ll tmp;
///* 自然数 a > b を確認・入替 */
//if (a<b) {
//	tmp = a;
//	a = b;
//	b = tmp;
//}
///* ユークリッドの互除法 */
//ll r = a % b;
//while (r != 0) {
//	a = b;
//	b = r;
//	r = a % b;
//}
//a = x / b;//答え

Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <cstring>
#include <map> 
#include <set>
#include <queue>
#include <iomanip>
#include <sstream>
typedef long long ll;

#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h,n, w,m,t; string s;
ll R, C;
ll sy, sx, gy, gx;
char maze[510][510];
ll dis[20][20];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);
}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}
ll Combination(int n, int r)
{
	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> numerator(r);
	vector<ll> denominator(r);

	for (int k = 0; k < r; k++)
	{
		numerator[k] = n - r + k + 1;
		denominator[k] = k + 1;
	}

	for (int p = 2; p <= r; p++)
	{
		int pivot = denominator[p - 1];
		if (pivot > 1)
		{
			int offset = (n - r) % p;
			for (int k = p - 1; k < r; k += p)
			{
				numerator[k - offset] /= pivot;
				denominator[k] /= pivot;
			}
		}
	}

	ll result = 1;
	for (int k = 0; k < r; k++)
	{
		if (numerator[k] > 1) result *= numerator[k];
		result %= ma;
	}

	return result;
}

ll bfs() {
	queue<P> que;
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < C; j++) dis[i][j] = INF;
	}
	que.push(P(sy - 1, sx - 1));
	dis[sy - 1][sx - 1] = 0;

	while (que.size() > 0) {
		P p = que.front();
		que.pop();
		if (p.first == gy - 1 && p.second == gx - 1) break;
		for (ll i = 0; i < 4; i++) {
			ll ny = p.first + dy[i];
			ll nx = p.second + dx[i];
			if (0 <= ny && ny < R && 0 <= nx && nx < C && maze[ny][nx] == '.' && dis[ny][nx] == INF) {
				que.push(P(ny, nx));
				dis[ny][nx] = dis[p.first][p.second] + 1;
			}
		}
	}
	return dis[gy - 1][gx - 1];
}

int main() {
	ll h1, m1, h2, m2, k;
	cin >> h1 >> m1 >> h2 >> m2 >> k;
	cout << h2 * 60 + m2 - h1 * 60 - m1 - k << endl;
}

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

int d(int x) {
	if (x <= 0) return -x;
	int ans = 0;
	if (x % 2) x++, ans++;
	ans += x / 2;
	return ans;
}

int main() {
	vector<int> a(3);
	for (int i = 0; i < 3; i++) cin >> a[i];
	int mi = 1 << 30;
	for (int x = -1000; x <= 1000; x++) {
		int sum = 0;
		for (int i = 0; i < 3; i++) sum += d(x - a[i]);
		mi = min(mi, sum);
	}
	cout << mi << endl;
    return 0;
}

Measured memory_bytes: 256
a = input().split()
a[0] = int(a[0])
a[1] = int(a[1])
x = []
y = []
z = []

for i in range(a[0]):
    b = input().split()
    for j in range(a[1]):
        b[j] = int(b[j])
    x.append(b)
    z.append(0)
for i in range(a[1]):
    c = int(input())
    y.append(c)  
for i in range(a[0]):
    for j in range(a[1]):
        z[i] += x[i][j]*y[j]
for i in z:
    print(i)


Measured memory_bytes: 6024
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int main(){
  int a[4],b[4];
  int hit,blow;
  while(cin >> a[0]){
    for(int i=1;i<4;i++)cin >> a[i];
    for(int i=0;i<4;i++)cin >> b[i];
    hit = blow = 0;
    for(int i=0;i<4;i++){
      if(a[i] == b[i])hit++;
      for(int j=0;j<4;j++){
	if(i != j && a[i] == b[j])blow++;
      }
    }
    cout << hit << ' ' << blow << endl;
  }
}

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define in(v) cin>>v;
#define out(v) cout<<v<<"\n"

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

  rep(i, (N/4)+1) {
    if ((N-4*i) % 7 == 0) {
      out("Yes");
      return 0;
    }
  }
  out("No");

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>          // printf(), scanf()

int
main(int argc, char **argv)
{
	int n;
	scanf("%d", &n);
	long sum = 0;
	for (int i = 0; i < n; ++i)
	{
		int a;
		scanf("%d", &a);
		sum += a;
	}

	int avr = sum / n;
	printf("%d\n", avr);
	return 0;
}

Measured memory_bytes: 1748
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define vec vector
#define pb push_back
#define mp make_pair
#define ll long long
#define MOD 1000000007

int main(void)
{
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vec<char> t(q), d(q);
  rep(i, q) {
    cin >> t[i] >> d[i];
  }

  int left = 0, right = n - 1;
  while(left <= right) {
    int mid = (left + right) / 2;
    int cur = mid;
    rep(i, q) {
      if (s[cur] != t[i]) continue;
      if (d[i] == 'L') cur--;
      else cur++;
      if (cur < 0 || cur >= n) break;
    }
    if (cur < 0) left = mid + 1;
    else right = mid - 1;
  }
  int ansl = left - 1; // s[ansl]まで左に落ちる

  left = 0, right = n - 1;
  while(left <= right) {
    int mid = (left + right) / 2;
    int cur = mid;
    rep(i, q) {
      if (s[cur] != t[i]) continue;
      if (d[i] == 'L') cur--;
      else cur++;
      if (cur < 0 || cur >= n) break;
    }
    if (cur >= n) right = mid - 1;
    else left = mid + 1;
  }
  int ansr = right + 1; // s[ansr]まで右に落ちる

  cout << ansr - ansl - 1 << endl;
  return 0;
}


Measured memory_bytes: 1028
flag = 0
a = input()
b = list(map(int,input().split()))
for c in b:
    if c%2 == 0:
        if not (c%3 == 0 or c%5 == 0):
            flag = 1

if flag == 1:
    print("DENIED")
else:
    print("APPROVED")

Measured memory_bytes: 2940
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

long long int X, Y;


int main() {
	cin >> X >> Y;
	if (abs(X - Y) <= 1)cout << "Brown\n";
	else cout << "Alice\n";
	return 0;
}


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

int main() {
    int a,b,c;
    cin >> a >> b >> c;
	vector<int> A{a,b,c};
    sort(A.begin(),A.end());
    if(A.at(0)+A.at(1) == A.at(2)){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
}


Measured memory_bytes: 256
int_a = int(input())
root_a = int(int_a ** 0.5)
if int_a <= 3:
    print(int_a)
else:
    for b in range(int_a, int_a + 1000):
        flag = True
        for c in range(2, root_a + 2):
            if b % c == 0:
                flag = False
                break
        if flag:
            print(b)
            break


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

int main()
{
ll k , x ;
cin >> k >> x ;
vector<ll> v;
rep(i,k){
  v.push_back(x-k+1+i);
}
rep(i,k-1){
  v.push_back(x+i+1);
}
for (int i = 0; i < v.size(); ++i) {
    if(-1000000<=v[i]&&v[i]<=1000000)
    cout << v[i] << " ";    
}cout  << endl;

return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES {cout<<"YES"<<'\n';}
#define NO {cout<<"NO"<<'\n';}
#define Yes {cout<<"Yes"<<'\n';}
#define No {cout<<"No"<<'\n';}
#define yes {cout<<"yes"<<'\n';}
#define no {cout<<"no"<<'\n';}
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) {cout << n << '\n';}
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
int ABS(int a) {if(a<0) a = -a; return a;}
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数の個数*/int divisor_number(int n){auto p = prime_factor(n); int res = 1; for(auto x:p)res*=(x.second+1); return res;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

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

    int a,b; cin >> a >> b;
    if(a*b%2){out("Odd");}
    else out("Even");

    return 0;
}

Measured memory_bytes: 256
/*
[abc137] C - Green Bin
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

const int MAX_N = 1e5;

int N;
string s[MAX_N];
int cnt[MAX_N]['z' - 'a' + 1];
vector<int> idx;

bool same(int i, int j) {
    for (int c = 0; c < 'z' - 'a' + 1; c++) {
        if (cnt[idx[i]][c] != cnt[idx[j]][c]) {
            return false;
        }
    }
    return true;
}

ll solve() {
    for (int i = 0; i < N; i++) {
        for (char c : s[i]) {
            cnt[i][c - 'a']++;
        }
    }

    for (int i = 0; i < N; i++) {
        idx.push_back(i);
    }
    sort(idx.begin(), idx.end(), [](int i, int j) {
        for (int c = 0; c < 'z' - 'a'; c++) {
            if (cnt[i][c] != cnt[j][c]) {
                return cnt[i][c] < cnt[j][c];
            }
        }
        return cnt[i]['z' - 'a'] < cnt[j]['z' - 'a'];
    });

    ll ans = 0;
    for (int i = 1, pre = 0; i < N; i++) {
        if (same(i, pre)) {
            ans += i - pre;
        } else {
            pre = i;
        }
    }

    return ans;
}

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

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 18048
#include <stdio.h>

int main( void ){
    int a,b,c;
    for(;;){
        scanf(" %d %d %d", &a, &b, &c);
        if ( a + b + c == -3){
            break;
        }else if ( a + b >= 80 ){
            printf("A\n");
        }else if ( a + b >= 65 ){
            printf("B\n");
        }else if ( a + b >= 50 || ( a + b >=30 && c >= 50) ){
            printf("C\n");
        }else if ( a + b >= 30 && a != -1 && b != -1 ){
            printf("D\n");
        }else{
            printf("F\n");
        } 
            
    }
    return 0;
}


Measured memory_bytes: 2076
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);

    LL N,A,B; cin >>N>> A >> B;

    if(A > B) swap(A,B);
    if((B-A)%2 == 0){
        cout << (B-A) / 2 << endl;
    }else{
        LL ans1,ans2;
        ans1 = A-1 + (B-A+1) / 2;
        ans2 = N-B + (B-A+1) / 2;
        cout << min(ans1,ans2) << endl;
    }

}


Measured memory_bytes: 256
H, W = map(int, input().split())
N = int(input())
a = [int(x) for x in input().split()]

c = [None] * H * W
j = 0
for i in range(N):
    for k in range(j, j + a[i]):
        c[k] = i + 1
    j += a[i]

ans = [[None for _ in range(W)] for _ in range(H)]
for i in range(H):
    for j in range(W):
        ans[i][j] = c[i * W + j]
    if i % 2 == 1:
        ans[i] = ans[i][::-1]

for i in range(H):
    print(*ans[i])

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


int main()
{
    ll n;
    cin>>n;
    map<string,ll> umap;
    for(ll i=0;i<n;i++)
    
    {
        string s;
        cin>>s;
        umap[s]++;
    }
    cout<<"AC x "<<umap["AC"]<<"\n";
    cout<<"WA x "<<umap["WA"]<<"\n";
    cout<<"TLE x "<<umap["TLE"]<<"\n";
    cout<<"RE x "<<umap["RE"]<<"\n";


}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/
ll solve(ll W, vl a, vl b){
	vl w,v;
	rep(i,3){
		if(b[i]>a[i]){
			w.push_back(a[i]);
			v.push_back(b[i]-a[i]);
		}
	}
	int n=w.size();
	if(n==0)return W;
	vvl dp(2,vl(W+1,0));
	rep(i,n)rep(j,W+1){
		if(j<w[i]){
			dp[(i+1)&1][j]=dp[i&1][j];
		}else{
			dp[(i+1)&1][j]=max(dp[i&1][j], dp[(i+1)&1][j-w[i]]+v[i]);
		}
	}
	return W+dp[n&1][W];
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n; vl a(3),b(3);
	cin>>n>>a>>b;
	ll val=solve(n,a,b);
	ll ans=solve(val,b,a);
	puta(ans);
	return 0;
}

Measured memory_bytes: 586368
#include<cstdio>
#include<vector>
#include<algorithm>
#include<iostream>
#include<complex>

using namespace std;

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

const int INF = 1000000000;

#define X real()
#define Y imag()

typedef complex<double> Point;

class Line{
	public:
	double A,B,C;
	Line(double A,double B,double C):A(A),B(B),C(C){}
	Line(){}
};
class Circle : public Point{
	public:
	double R;
	Circle(Point pt, double R):Point(pt),R(R){}
	Circle(){}
};


double Dot(Point p1, Point p2){return p1.X*p2.X + p1.Y*p2.Y;}
double Cross(Point p1, Point p2){return p1.X*p2.Y - p1.Y*p2.X;}

bool ccw(Point p1, Point p2, Point p3){return  Cross(p2-p1, p3-p1)>=0;}

pair<Point,Point> Suisen(Line line, Point pt){
	Point v(line.A, line.B);  v/=Point(abs(v),0);
	Point toPoint;
	
	if(line.B!=0){
		Point slide = pt-Point(0, -line.C/line.B);
		toPoint = v*Point(Dot(v,slide),0);
	}else{
		toPoint = Point(pt.X + line.C/line.A, 0);
	}
	return pair<Point,Point>(pt-toPoint, toPoint); //場所と方向
}
bool CircleHit(Circle a, Circle b){return abs(a-b) <= a.R + b.R;}
Line CircleCommonLine(Circle a,Circle b){
	double C = pow(b.R, 2)-pow(a.R, 2)+norm(a)-norm(b);
	return Line(2*(b.X-a.X), 2*(b.Y-a.Y), C);
}
pair<Point,Point> CircleCross(Circle a, Circle b){
	Line commonLine = CircleCommonLine(a,b);
	pair<Point,Point> s = Suisen(commonLine, a);
	
	double d = abs(s.second);
	if(d!=0){
		Point e = s.second*Point(0,1)/d;
		if(a.R<d)d=a.R;
		double dist = sqrt(a.R*a.R - d*d);
		return pair<Point,Point>(s.first+e*Point(dist,0), s.first+e*Point(-dist,0));
	}
	return pair<Point,Point>(s.first-Point(0,a.R), s.first+Point(0,a.R));
}


const int N = 11;

int n;
Circle cir[N];
Circle cirnext[N];

bool checknext(){
	vector<Point> pt;
	rep(i,n)pt.push_back(cirnext[i]);
	/*
	rep(i,n){
		cout<<cirnext[i]<<cirnext[i].R<<" ";
	}puts("");
	*/
	rep(i,n){
		reps(j,i+1,n){
			if(!CircleHit(cirnext[i],cirnext[j]))continue;
			pair<Point,Point> cross = CircleCross(cirnext[i],cirnext[j]);
			pt.push_back(cross.first);
			pt.push_back(cross.second);
		}
	}
	
	const double EPS_IN = 0.00000001;
	bool has = false;
	rep(i,pt.size()){
		bool ok = true;
		rep(j,n){
			if(abs(pt[i]-cirnext[j]) > cirnext[j].R+EPS_IN)ok=false;
		}
		if(ok)has=true;
	}
	
	return has;
}

bool check(double val){
	bool ret = true;
	rep(i,n){
		if(val>cir[i].R)return false;
		double theta = asin(val/cir[i].R);
		double len = cir[i].R * cos(theta);
		cirnext[i]=Circle(cir[i], len);
	}
	ret &= checknext();
	return ret;
}


double solve(){
	rep(i,n){
		double a,b,c;
		cin>>a>>b>>c;
		cir[i] = Circle(Point(a,b),c);
	}
	
	double left = 0;
	double right = INF;
	const double EPS_BS = 0.0000001;
	
	while(1){
		double half = (left+right)/2;
		
		if(check(half)){
			left = half;
		}else{
			right = half;
		}
		if(left+EPS_BS>right)break;
	}
	
	return left;
}

int main(){
	while(1){
		cin>>n;
		if(n==0)break;
		printf("%.9lf\n",solve());
		//break;
	}
}

Measured memory_bytes: 1356
#include "bits/stdc++.h"
using namespace std;
#define int long long
#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, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
template<class T>inline bool CHMIN(T&a,T b){if(a > b){a = b;return true;}return false;}
template<class T>inline bool CHMAX(T&a,T b){if(a < b){a = b;return true;}return false;}
constexpr int INF = 1e18;


signed main(){
	int X;
	cin >> X;
	int d = 360;
	int g = gcd(X,d);
	X /= g;
	d /= g;
	out(d);
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    long long i,j,k,l,m,n,p,q;
 while(cin>>m>>n){
    m*=n;
    if(m%2==0)cout<<"Even"<<endl;
    else cout<<"Odd"<<endl;
 }
    return 0;
}


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

int main(void){
  long long ans, t;
  char c;
  
  ans = t = 0;
  while (cin >> c){
    if (c=='W'){
      ans += t;
    } else {
      t++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
main = do
  x <- getLine
  let xs = momo x
  print $ sisi (gosan xs)

momo :: String -> [Int]
momo (x:xs) = (read [x] :: Int) : momo xs
momo _      = []

gosan :: [Int] -> [Int]
gosan (x:y:z:ss) = 100*x + 10*y + z : gosan (y:z:ss)
gosan _          = []

sisi :: [Int] -> Int
sisi xs = minimum $ map (abs . (-) 753) xs

Measured memory_bytes: 508
import java.util.*;
public class Main{
  public static void main(String[]args){
      Scanner sc = new Scanner(System.in);

      String a = sc.next();
      String b = sc.next();
      String c = sc.next();
      char a1 = a.charAt(a.length()-1);
      char b1 = b.charAt(0);
      char b2 = b.charAt(b.length()-1);
      char c1 = c.charAt(0);

      if (a1==b1&&b2==c1) {
        System.out.println("YES");
      }else{
        System.out.println("NO");
      }
}
}


Measured memory_bytes: 23764
#include <stdio.h>
int e[26];
int main ()
{
	char s[5];
	int i,g=0;
	scanf("%s",&s);
	for(i=0;i<=3;i++)
	{
		e[s[i]-'A']++;
	}
	for(i=0;i<=25;i++)
	{
		if(e[i]==2)
		{
			g++;
		}
	}
	if(g==2)
	{
		printf("Yes");
	}
	else
	{
		printf("No");
	}
	return 0;
}


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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

template <class T>
struct Kruskal {
  struct UnionFind {
    int N;
    vector<int> sz_tree, parent;
    UnionFind() {}
    UnionFind(int N) : N(N), sz_tree(N, 1), parent(N) {
      iota(parent.begin(), parent.end(), 0);
    }
    int root(int x) {
      return parent[x] == x ? x : parent[x] = root(parent[x]);
    }
    void merge(int x, int y) {
      if ((x = root(x)) == (y = root(y))) return;
      if (sz_tree[x] < sz_tree[y]) swap(x, y);
      sz_tree[x] += sz_tree[y];
      parent[y] = x;
    }
    bool same(int x, int y) {
      return root(x) == root(y);
    }
    int size(int x) {
      return sz_tree[root(x)];
    }
  };
  struct edge {
    int from, to; T cost; bool used;
    edge() {}
    edge(int f, int t, T c) : from(f), to(t), cost(c) {
      used = false;
    }
  };
 
  int N;
  vector<edge> es;
  Kruskal() {}
  Kruskal(int N) : N(N) {}
 
  void add_edge(int from, int to, T cost) {
    es.emplace_back(from, to, cost);
  }
  T mst() {
    T res = 0;
    UnionFind uf(N);
    sort(es.begin(), es.end(), [&](edge a, edge b) {
      return a.cost < b.cost;
    });
    for (auto &e : es) {
      if (uf.same(e.from, e.to)) continue;
      uf.merge(e.from, e.to);
      e.used = true;
      res += e.cost;
    }
    return res;
  }
  T query(edge e2) {
    T res = 0;
    UnionFind uf(N);
    for (auto &e : es) {
      if (e.from == e2.from && e.to == e2.to) continue;
      if (uf.same(e.from, e.to)) continue;
      uf.merge(e.from, e.to);
      res += e.cost;
    }
    return res;
  }
};

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int N, M;
  cin >> N >> M;
  Kruskal<int> K(N);
  for (int i = 0; i < M; i++) {
    int S, D, C;
    cin >> S >> D >> C;
    S--, D--;
    K.add_edge(S, D, C);
  }
  int mst = K.mst(), cnt = 0, sum = 0;
  for (auto &e : K.es) {
    if (e.used && K.query(e) != mst) {
      cnt++, sum += e.cost;
    }
  }
  cout << cnt << " " << sum << endl;

  return 0;
}


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

int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	long long a[n],f=1;
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
		if (a[i]>0LL)
		{
			f=0;
		}
	}
	if (f)
	{
		long long ma=-100000000000LL;
		int p=-1;
		for (int i = 0; i < n; ++i)
		{
			if (ma<a[i])
			{
				ma=a[i];
				p=i;
			}
		}
		cout<<ma<<endl<<n-1<<endl;
		int m=n;
		for (int i = 0; i < n-p-1; ++i)
		{
			cout<<m<<endl;
			--m;
		}
		for (int i = 0; i < p; ++i)
		{
			cout<<"1\n";
		}
	}
	else
	{
		long long ans1=0LL,ans2=0LL;
		for (int i = 0; i < n; ++i)
		{
			if (i%2==0)
			{
				ans1+=max(0LL,a[i]);
			}
			else
			{
				ans2+=max(0LL,a[i]);
			}
		}
		vector<int> ans;
		if (ans1>ans2)
		{
			if (n%2==0)
			{
				ans.push_back(n);
				--n;
			}
			while (a[n-1]<0)
			{
				ans.push_back(n);
				ans.push_back(n-1);
				n-=2;
			}
			int now=0;
			while (a[now]<0)
			{
				ans.push_back(1);
				ans.push_back(1);
				now+=2;
			}
			for (int i = now+2; i < n; i+=2)
			{
				if (a[i]>0)
				{
					ans.push_back(2);
				}
				else
				{
					ans.push_back(3);
				}
			}
			cout<<ans1<<endl<<ans.size()<<endl;
			for (auto v:ans)
			{
				cout<<v<<endl;
			}
		}
		else
		{
			if (n%2==1)
			{
				ans.push_back(n);
				--n;
			}
			while (a[n-1]<0)
			{
				ans.push_back(n);
				ans.push_back(n-1);
				n-=2;
			}
			ans.push_back(1);
			int now=1;
			while (a[now]<0)
			{
				ans.push_back(1);
				ans.push_back(1);
				now+=2;
			}
			for (int i = now+2; i < n; i+=2)
			{
				if (a[i]>0)
				{
					ans.push_back(2);
				}
				else
				{
					ans.push_back(3);
				}
			}
			cout<<ans2<<endl<<ans.size()<<endl;
			for (auto v:ans)
			{
				cout<<v<<endl;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int D;
  cin >> D;
  if(D == 22) cout << "Christmas Eve Eve Eve" << endl;
  if(D == 23) cout << "Christmas Eve Eve" << endl;
  if(D == 24) cout << "Christmas Eve" << endl;
  if(D == 25) cout << "Christmas" << endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
class Program
{
	static void Main()
	{
	string[] input = Console.ReadLine().Split(' ');//Splitで区切り文字を指定して複数個受け取る。
	long n = long.Parse(input[0]);
	long x = long.Parse(input[1]);
  long answer = 0;
  long a = 0;
  long b = 0;

  answer += n;
  a = Math.Min(x,n-x);
  b = Math.Max(x,n-x);

    while(true)
    {
      //Console.WriteLine(a + " " + b + " " + answer);
      answer += 2 * a * (b/a);
      if(b % a == 0) 
      {
        answer -= a;
        break;
      }else
      {
      b = b % a;
      long temp = a;
      a = b;
      b = temp;
      }
    }
  
	Console.WriteLine(answer);//WriteLineをWriteとすると、改行なしで出力。
	}
}


Measured memory_bytes: 11092
/*

                         YATIN KWATRA                   _03_08_14


Let's Hoop..

------------------------------------------------

           o
 /|   o         o
 \|=--            o
    ##
                    \\
                 /   \O
                O_/   T
                T    /|
                |\  | |
 _______________|_|________

------------------------------------------------

o- - -  \o          __|
   o/   /|          vv`\
  /|     |              |
   |    / \_            |
  / \   |               |
 /  |                   |


------------------------------------------------

HOOPER_4_LYF..

*/

// AC BAKSHI RABBA

// #pragma GCC optimize "trapv"

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll                      long long
#define int                     ll
#define FIO                     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pbds                    tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define ld                      long double
#define ull                     unsigned long long
#define endl                    "\n"
#define fo(i,a,b)               for(int i = a; i<=b ; i++)
#define rfo(i,a,b)              for(int i = a; i>=b ; i--)
#define vii                     vector<int>
#define vll                     vector<ll>
#define pq                      priority_queue
#define uom                     unordered_map
#define all(v)                  v.begin(),v.end()
#define mp                      make_pair
#define pb                      push_back
#define pob                     pop_back
#define ff                      first
#define ss                      second
#define pii                     pair<int,int>
#define pll                     pair<ll,ll>
#define mll                     map<ll,ll>
#define mii                     map<int,int>
#define vvii                    vector<vii>
#define vvll                    vector<vll>
#define mod                     1000000007
#define MIN                     -1e9
#define pi                      3.1415926535897932384626433832795

using namespace std;
using namespace __gnu_pbds;

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

/*
----------------------------------------------------------------

   -> Check For Overflows
   -> Out of Bounds
   -> Initialisations of global arrays and variables
   -> Read the Question and the sample test cases carefully
   -> Its not Always Complex, Try to simplify
   -> write it down and try to solve
   -> Have Faith in urself and in ur approach
   -> If it seems totally out of reach, switch to next :)
   -> And Come Back later, if possible ..

----------------------------------------------------------------*/


void solve()
{

  ld d, t, s;
  cin >> d >> t >> s;

  ld time = d / (ld)s;

  if (time <= t) cout << "Yes\n";
  else cout << "No\n";

}

signed main() {

  FIO
  INPUT();

  int t;
  t = 1;
// cin >> t;

  fo(i, 0, t - 1)
  {
    solve();
  }
  return 0;
}

Measured memory_bytes: 3736
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }
void modpow(ref long x, long y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }

struct Cmb
{
	void init(long n)
	{
		long powmod(long a, long p)
		{
			long ans = 1;
			long mul = a;
			while (p > 0)
			{
				if ((p & 1) == 1)
					ans.modm(mul);
				p >>= 1;
				mul.modm(mul);
			}
			return ans;
		}

		++n;
		fact = new long[2][](n);
		fact[0][0] = 1;
		foreach (i; 1..n)
		{
			fact[i][0] = fact[i-1][0];
			fact[i][0].modm(i);
		}
		fact[n-1][1] = powmod(fact[n-1][0], mod - 2);
		foreach_reverse (i; 0..n-1)
		{
			fact[i][1] = fact[i+1][1];
			fact[i][1].modm(i+1);
		}
	}

	long get(long n, long r)
	{
		long res = fact[n][0];
		res.modm(fact[r][1]);
		res.modm(fact[n-r][1]);
		return res;
	}

	long[2][] fact;
}

void main()
{
	auto N = RD;
	auto K = RD;
	auto A = RDA;
	A.sort();

	Cmb cmb;
	cmb.init(N);

	long ans;
	foreach (i; 0..N)
	{
		if (N-i >= K)
		{
			long t = A[i];
			t.modm(cmb.get(N-i-1, K-1));
			ans.mods(t);
		}
		if (i+1 >= K)
		{
			long t = A[i];
			t.modm(cmb.get(i, K-1));
			ans.moda(t);
		}
	}

	writeln(ans);
	stdout.flush;
	debug readln;
}


Measured memory_bytes: 4244
import java.util.*;

public class Main {

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

	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		long W=sc.nextLong();

		long w0=0;
		ArrayList<ArrayList<Long>> list = new ArrayList<>();
		for(int i=0; i<n; i++) {
			list.add(new ArrayList<>());
		}
		for(int i=0; i<n; i++) {
			long w=sc.nextLong();
			long v=sc.nextLong();
			if(i==0) w0=w;
			list.get((int)(w-w0)).add(v);
		}
		for(int i=0; i<n; i++) {
			Collections.sort(list.get(i),Collections.reverseOrder());
		}

		long sum[][] = new long[4][n+1];

		for(int i=0; i<4; i++) {
			sum[i][0]=0;
		}

		for(int i=0; i<4; i++) {
			ArrayList<Long> ll = list.get(i);
			for(int j=0; j<ll.size(); j++) {
				sum[i][j+1] = sum[i][j]+ll.get(j);
			}
		}

		long max = 0;
		for(int i=0; i<=list.get(0).size();i++) {
			for(int j=0;j<=list.get(1).size(); j++) {
				for(int k=0; k<=list.get(2).size(); k++) {
					for(int l=0; l<=list.get(3).size(); l++) {
						if(i*(w0) + j*(w0+1) + k*(w0+2) + l*(w0+3) > W) continue;
						max = Math.max(max, sum[0][i]+sum[1][j]+sum[2][k]+sum[3][l]);
					}
				}
			}
		}
		System.out.println(max);
		sc.close();
	}


}


Measured memory_bytes: 37672
void main() {
  problem();
}

void problem() {
  const K = scan!int;
  const N = scan!int;
  const A = scan!(int)(N);

  int solve() {

    auto delta = new int[N];
    foreach(i; 0..N-1) {
      delta[i] = A[i+1] - A[i];
    }
    delta[N-1] = K - A[N-1] + A[0];

    int max;
    foreach(d; delta){
      if (max < d) max = d;
    }

    return delta.sum - max;
  }

  solve().writeln;
}

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

import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; }
T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
void deb(T ...)(T t){ debug writeln(t); }
alias Point = Tuple!(long, "x", long, "y");

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


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

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

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

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

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

using namespace output;

int N, M;
vector<pii> edges;
vector<vi> graph;
set<pii> used;
vector<pii> finalEdges;
vi goingOut;
bool fail = false;

vector<bool> seen;

void dfs(int cur) {
	seen[cur] = true;
	for (int n : graph[cur]) if (!seen[n]) {
		used.insert(pii {min(cur, n), max(cur, n)});
		dfs(n);
	}
}

void calc(int cur, int par) {
	seen[cur] = true;
	for (int n : graph[cur]) if (!seen[n]) {
		calc(n, cur);
	}

	if (goingOut[cur] % 2 == 0) {
		if (par != -1) {
			finalEdges.push_back({par, cur});
			goingOut[par]++;
		}
	} else {
		if (par != -1) {
			finalEdges.push_back({cur, par});
			goingOut[cur]++;
		} else fail = true;
	}
}

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N >> M;
	
	graph.resize(N);
	edges.resize(M);
	goingOut.resize(N);

	F0R(i, M) {
		int a, b; cin >> a >> b; --a; --b;
		edges[i] = {a, b};
		graph[a].push_back(b);
		graph[b].push_back(a);
	}
	seen = vector<bool> (N);
	dfs(0);

	for (pii e : edges) {
		pii ie = {min(e.first, e.second), max(e.first, e.second)};
		if (used.find(ie) == used.end()) {
			finalEdges.push_back(ie);
			goingOut[ie.first]++;
		}
	}
	seen = vector<bool> (N);
	calc(0, -1);

	if (fail) {
		print(-1);
	} else {
		for (pii e : finalEdges) {
			print(e.first + 1, e.second + 1);
		}
	}
}

Measured memory_bytes: 24576
#include<bits/stdc++.h>
using namespace std;
typedef  long long   ll;
ll inf=1000000000000000000,mod=1000000007;
int main(){
    ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        
        // ll t;cin>>t;while(t--){
        ll a,b,n;cin>>a>>b>>n;
        ll num,num1,ma=0;
        num=(n/b)*b;
        num=max(1ll,num-1);
        num1=(a*num)/b-(a*(num/b));
        ma=max(ma,num1);
        num=n;
        num1=(a*num)/b-a*(num/b);
        ma=max(ma,num1);
        num=n-1;
        num1=(a*num)/b-a*(num/b);
            ma=max(ma,num1);
        cout<<ma;
        // cout<<endl;
        // }

}


Measured memory_bytes: 3604
import queue
H,W = map(int,input().split())
maze = list()
q = queue.Queue()
for i in range(H):
   maze.append( [x for x in input()])

maxim = 1
for i in range(H):
    for j in range(W):
        if maze[i][j] == "." :
            maze_score = [[0]*W for k in range(H)]
            maze_score[i][j] = 1
            q.put([i,j])
            
        else :
            continue
        
        while(True):
            if q.empty() :
                if maze_score[x][y] > maxim:
                    maxim = maze_score[x][y]
                break
            [x,y] = q.get()
            
            
            
            
            ##top
            if x != 0:
                if maze_score[x-1][y] ==0 and maze[x-1][y] == ".":
                    maze_score[x-1][y] = maze_score[x][y] +1
                    q.put([x-1,y])
            ##right
            if y+1 != W:
                if maze_score[x][y+1] ==0 and maze[x][y+1] == ".":
                    maze_score[x][y+1] = maze_score[x][y] +1
                    q.put([x,y+1])
            ##bottom
            if x != H-1:
                if maze_score[x+1][y] ==0 and maze[x+1][y] == ".":
                    maze_score[x+1][y] = maze_score[x][y] +1
                    q.put([x+1,y])
            ##left
            if y != 0:
                if maze_score[x][y-1] ==0 and maze[x][y-1] == ".":
                    maze_score[x][y-1] = maze_score[x][y] +1
                    q.put([x,y-1])
        
print(maxim-1)


Measured memory_bytes: 3952
import sys


class UnionFind:
    def __init__(self, n):
        self.table = [-1] * n

    def _root(self, x):
        stack = []
        tbl = self.table
        while tbl[x] >= 0:
            stack.append(x)
            x = tbl[x]
        for y in stack:
            tbl[y] = x
        return x

    def find(self, x, y):
        return self._root(x) == self._root(y)

    def union(self, x, y):
        r1 = self._root(x)
        r2 = self._root(y)
        if r1 == r2:
            return
        d1 = self.table[r1]
        d2 = self.table[r2]
        if d1 <= d2:
            self.table[r2] = r1
            self.table[r1] += d2
        else:
            self.table[r1] = r2
            self.table[r2] += d1


def main():
    n, m = map(int, sys.stdin.buffer.readline().split())
    U = UnionFind(n)
    for x in sys.stdin.buffer.readlines():
        a, b = map(int, x.split())
        U.union(a-1, b-1)
    ans = {}
    for i in range(n):
        ans.setdefault(U._root(i), []).append(i)
    print(len(ans) - 1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 23104
t=list(map(int,open(0)))
def divideten(x): 
	if x%10==0:
		return 10
	else: 
		return x%10
u=sorted(map(divideten,t))
def kiriage(x):
	if x%10==0:
		return x
	else:
		return x+10-(x%10)
v=list(map(kiriage,t))
print(sum(v)+min(u)-10)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



int n, a;

signed main() {
	cin >> n;
	rep(i,n) {
		cin >> a;
		if (a%2) return cout << "first" << endl, 0;
	}
	cout << "second" << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> veci;
typedef vector<ll> vecll;
typedef vector<string> vecs;
template<class T,class U> using Hash=unordered_map<T,U>;
 
#define REP(i, a, n) for(ll i = a; i < n; i++)
#define RREP(i, a, n) for(ll i = n-1; i >= a; i--)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) RREP(i, 0, n)
#define MD 1000000007
#define _SPLIT " "
 
template<class T> T read(){T a;cin >> a;return a;}
template<class T> void read(T& a){cin >> a;}
template<class T,class ...Args> void read(T& a, Args&... args){cin >> a; read(args...);} 
template<class T> void rarr(T a, int n){for(int i = 0; i < n; i++) {cin >> a[i];}}
template<class T> void write(T a){cout << setprecision(12) << a << endl;}
template<class T,class ...Args> void write(T a, Args... args){cout << setprecision(12) << a << _SPLIT; write(args...);}
template<class T> void warr(vector<T> a, const char* c = " "){cout << a[0];for(int i = 1; i < (int)a.size(); i++)cout << c << a[i];cout << endl;;}
template<class T> void warr(T a, int n, const char* c = " "){cout << a[0];for(int i = 1; i < n; i++)cout << c << a[i];cout << endl;}
void split(string s, string delim, veci& result){result.clear();string::size_type pos = 0;while(pos != string::npos){string::size_type p = s.find(delim, pos);if(p == string::npos){result.push_back(atoi(s.substr(pos).data()));break;}else {result.push_back(atoi(s.substr(pos, p - pos).data()));}pos = p + delim.size();}}
void split(string s, string delim, vecs& result){result.clear();string::size_type pos = 0;while(pos != string::npos){string::size_type p = s.find(delim, pos);if(p == string::npos){result.push_back(s.substr(pos));break;}else {result.push_back(s.substr(pos, p - pos));}pos = p + delim.size();}}
ll gcd(ll a, ll b){while(true){ll k = a % b;if(k == 0)return b;a = b;b = k;}}
ll comb(ll n, ll m){ll p=1;m=min(m,n-m);for(ll i=1;i<=m;i++){p*=n-i+1;p/=i;}return p;}

int main(void)
{
    int n,k,x,y;
    read(n,k,x,y);
    if(n<=k)write(n*x);
    else write(k*x+(n-k)*y);
    return 0;
}

Measured memory_bytes: 256