akhauriyash/Code-Regression huggingface dataset:
//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimize ("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-O2")


using namespace std;

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

const int N = 200000 + 10;
const ll MOD = 1000000000 + 7;
const ll INF = 1000000010;
const ll LOG = 25;

struct Seg{
	int l, r, id;
};

int n, mark[N];
Seg seg[N];
Seg seg2[N];

bool cmp(Seg x, Seg y){
	return x.l > y.l;
}

bool cmp2(Seg x, Seg y){
	return x.r < y.r;
}

int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	ll res = 0;
	for (int i = 1; i <= n; i++){
		cin >>seg[i].l >> seg[i].r;
		seg[i].id = i;
		seg2[i] = seg[i];
	}
	sort(seg + 1, seg + n + 1, cmp);
	sort(seg2 + 1, seg2 + n + 1, cmp2);
	ll ans = 0;
	int cur = 0;
	for (int i = 1; i <= n; i++){
		if (!mark[seg[i].id]){
			mark[seg[i].id] = 1;
			int L = seg[i].l;
			int R = seg[i].r;
			if (L > cur || cur > R){
				if (cur < L) ans += L - cur, cur = L;
				else ans += cur - R, cur = R;
			}
		}
		if (!mark[seg2[i].id]){
			mark[seg2[i].id] = 1;
			int L =seg2[i].l, R = seg2[i].r;
			if (L > cur || cur > R){
				if (cur < L) ans += L - cur, cur = L;
				else ans += cur - R, cur = R;
			}
		}
	}
	ans += abs(cur);
	res = ans;
	memset(mark, 0, sizeof mark);
	ans = 0;
	cur = 0;
	for (int i = 1; i <= n; i++) swap(seg[i], seg2[i]);
	for (int i = 1; i <= n; i++){
		if (!mark[seg[i].id]){
			mark[seg[i].id] = 1;
			int L = seg[i].l;
			int R = seg[i].r;
			if (L > cur || cur > R){
				if (cur < L) ans += L - cur, cur = L;
				else ans += cur - R, cur = R;
			}
		}
		if (!mark[seg2[i].id]){
			mark[seg2[i].id] = 1;
			int L =seg2[i].l, R = seg2[i].r;
			if (L > cur || cur > R){
				if (cur < L) ans += L - cur, cur = L;
				else ans += cur - R, cur = R;
			}
		}
	}
	ans += abs(cur);
	res = max(res, ans);
	cout << res;









	return 0;
}


Measured memory_bytes: 4224
import std.stdio;
import std.conv;
import std.string;
import std.algorithm;
import std.math;

long nextlnln(long x) {
  if(x<10) return x+1;
  bool carry = false;
  int ten = (x/10)%10;
  int one = (x+1) % 10;
  if(abs(ten - one) > 1) carry = true;
  if(carry) {
    long y = nextlnln(x/10);
    int z = y%10;
    return y*10 + (z>0 ? z-1 : 0);
  }
  else {
    return x+1;
  }
}

void main() {
  int k;
  long lnln = 0;
  readf("%d\n", &k);
  for(int i=0; i<k; i++) {
    lnln = nextlnln(lnln);
  }
  writeln(lnln);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma warning(disable:4996)
using namespace std;
using ll = long long;
using ld = long double;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
//const long double PI = acos(-1.0);
#define int long long
signed main() {
	int n;
	cin >> n;
	vector<int>v(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	int r = 0;
	int now_sum = 0;
	int now_xor = 0;
	ll ans = 0;
	for (int l = 0; l < n; l++) {
		while (r < n && (now_sum + v[r]) == (now_xor^v[r])) {
			now_sum += v[r];
			now_xor ^= v[r];
			r++;
		}
		ans += r - l;
		now_sum -= v[l];
		now_xor ^= v[l];//(A xor B xor C) xor B = (A xor B xor C)
	}

	cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
std::string a, b;

int main() {
    cin >> a >> b;
    if (a.size() > b.size()) {
        cout << "GREATER" << endl;
        return 0;
    }
    else if (b.size() > a.size()) {
        cout << "LESS" << std::endl;
        return 0;
    }
    for (int i = 0; i < a.size(); i++) {
        int a_num = a[i] - '0';
        int b_num = b[i] - '0';
        if (a_num > b_num) {
            cout << "GREATER" << endl;
            return 0;
        }
        else if (b_num > a_num) {
            cout << "LESS" << endl;
            return 0;
        }
    }
    cout << "EQUAL" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N; cin >> N;
    int t[110000], x[110000], y[110000];
    t[0] = x[0] = y[0] = 0;
    for(int i=0; i < N; i++) cin >> t[i+1] >> x[i+1] >> y[i+1];
    bool can = true;
    for (int i=0; i < N; i++){
        int dt = t[i+1] - t[i];
        int dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
        if (dt < dist) can = false;
        if (dist % 2 != dt % 2) can = false;
    }

    if(can) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

bool binary_search(vector<int> &a, int key) {
    int left = 0; 
    int right = a.size() - 1;
    while (left <= right) {
        int mid = (left + right) / 2;
        if (a[mid] == key) return true;
        else if (a[mid] < key) left = mid + 1;
        else right = mid - 1;
    }
    return false;
}

int main() {
    int n;
    scanf("%d", &n);
    vector<int> s(n);
    rep(i, n) {
        scanf("%d", &s[i]);
    }
    int q;
    scanf("%d", &q);
    vector<int> t(q);
    int count = 0;
    rep(i, q) {
        scanf("%d", &t[i]);
        if (binary_search(s, t[i])) count++;
    }
    printf("%d\n", count);
}


Measured memory_bytes: 3332
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};
typedef pair<int,int> P;
int R[110];
int main()
{
  int a,b;
  char c;
  vector<P> V;
  while(cin>>a>>c>>b,a||b){
    V.push_back(P(b,a));
  }
  sort(V.begin(),V.end(),greater<P>() );
  int k;
  int l;
  while(cin >>k){
  int ans = 1;
  for(int i = 0;i <V.size();i++){
    if(k == V[i].second){
      l = i;
      break;
    }
  }
  int c = -20;
  for(int i = 0;i <V.size();i++){
    if(V[l].first <V[i].first && V[i].first !=c){
      ans++;
      c = V[i].first;
    }
    }
  cout <<ans<<endl;
  }
  return 0;
}

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

using LL = int64_t;
using VL = vector<LL>;

template<class T,class U> void chmax(T&a,U b){if(a<b)a=b;}

int main(int argc, char *argv[])
{
	int n,m,q;
	cin >> n >> m >> q;
	VL a(q), b(q), c(q), d(q);
	for (int i = 0; i < q; i++) {
		cin >> a[i]>> b[i] >> c[i] >> d[i];
		a[i]--;b[i]--;
	}
	VL A(n,1);
	LL ans = 0;
	auto dfs = [&](auto&& dfs, int v) -> void{
		while (A[v] <= m) {
			if (v == n-1) {
				int tmp = 0;
				for (int i = 0; i < q; i++) {
					tmp += A[b[i]] - A[a[i]] == c[i] ? d[i] : 0;
				}
				chmax(ans,tmp);
			}
			else {
				if (A[v+1] < A[v]) {
					A[v+1] = A[v];
				}
				dfs(dfs, v+1);
			}
			A[v]++;
		}
		A[v] = 1;
		return;
	};
	dfs(dfs, 0);
	cout << ans << endl;
	return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
typedef vector<double> vdbl;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<int> > vvint;
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;
typedef priority_queue<int, vector<int>, greater<int> > spqint; //小さい順に取り出し
typedef priority_queue<ll, vector<ll>, greater<ll> > spqll;     //小さい順に取り出し
typedef priority_queue<int, vector<int>, less<int> > bpqint;    //大きい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll> > bpqll;        //大きい順に取り出し

#define REP(i, n) for (int(i) = 0; (i) < (int)(n); i++)
#define FOR(i, a, b) for (int(i) = a; (i) < (int)b; i++)
#define IREP(i, v) for (auto i = v.begin(); i != v.end(); i++)
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define PF push_front
#define TS to_string
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)

const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
const double PI = M_PI;
const int dx[8] = {1, 0, -1, 0, 1, -1, 1, -1};
const int dy[8] = {0, 1, 0, -1, -1, 1, 1, -1};
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; }     //最小公倍数

void yes()
{
    cout << "Yes" << endl;
}
void no()
{
    cout << "No" << endl;
}
//-----------------------------------------

//-----------------------------------------
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s ;
    cin >> s ;
    if(s[2]==s[3] && s[4]==s[5]){
        yes() ;
    }     
    else{
        no() ;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    for(int n; cin >> n, n;){
        vi a(n);
        for(auto& e : a){
            char c; cin >> c;
            e = c - 'A';
        }
        
        const int sz = 'Z' - 'A' + 1;
        vi cnt(sz + 1);

        int res = -1;
        char resi;
        rep(i, n){
            cnt[a[i]]++;
            int cand = max_element(_all(cnt)) - begin(cnt);

            if(cnt[cand] != *max_element(_all(cnt))) continue;
            int snd = sz;
            rep(j, sz){
                if(j != cand and cnt[j] >= cnt[snd]) snd = j;
            }

            if(cnt[snd] + (n - (i + 1)) < cnt[cand]){
                res = i + 1;
                resi = 'A' + cand;
                break;
            }
        }

        if(res == -1){
            cout << "TIE" << endl;
        }
        else {
            cout << resi << " " << res << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3128
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#define sqr(a) ((a)*(a))
using namespace std;

const int N = 10;
int n, x[N], y[N], cnst;
double tmp, ans;

int main()
{
    scanf("%d",&n); cnst = n-1;
    for(int i=1; i<=n-2; ++i) cnst *= i;

    for(int i=1; i<=n; ++i) scanf("%d%d",x+i,y+i);
    for(int i=1; i<=n; ++i) for(int j=1; j<=n; ++j) if (i!=j) {
        tmp = sqrt(sqr(x[i]-x[j]) + sqr(y[i]-y[j]));
        ans += tmp * cnst;
    }

    cnst = 1;
    for(int i=1; i<=n; ++i) cnst *= i;
    printf("%.10f",ans/cnst);
}


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

int main()
{
  int N;
  cin >> N;
  vector<int> X(N), Y(N);
  for (int i = 0; i < N; i++)
  {
    cin >> X.at(i);
    Y.at(i) = X.at(i);
  }
  
  sort(Y.begin(), Y.end());
  int m0 = Y.at(N / 2 - 1);
  int m1 = Y.at(N / 2);
  
  for (int i = 0; i < N; i++)
  {
    int ans;
    if (X.at(i) < m1) ans = m1;
    else ans = m0;
    cout << ans << endl;
  }
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
const int maxm = 1e6 + 5;
const double eps = 1e-8;
const double pi = acos(-1.0);
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a * b / gcd(a,b);}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
bool isp(ll x){if(x <= 1) return 0; for(ll i = 2;i * i <= x;i++){if(x % i == 0) return 0;}return 1;}
ll x,y,a,b,c;
ll p[maxn],q[maxn],r[maxn];
priority_queue<ll,vector<ll>,greater<ll> > pq;
int main(){
 	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> x >> y >> a >> b >> c;
	for(int i = 0;i < a;i++) cin >> p[i];
	for(int i = 0;i < b;i++) cin >> q[i];
	for(int i = 0;i < c;i++) cin >> r[i];
	sort(p,p+a,greater<ll>());
	sort(q,q+b,greater<ll>());
	sort(r,r+c,greater<ll>());
	ll sum = 0;
	for(int i = 0;i < x;i++){
		pq.push(p[i]);
		sum += p[i];
	}
	for(int i = 0;i < y;i++){
		pq.push(q[i]);
		sum += q[i];
	}
	int cur = 0;
	while(true){
		ll x = pq.top();
		if(x < r[cur]){
			sum -= x;
			pq.pop();
			pq.push(r[cur]);
			sum += r[cur++];
		}
		else break;
	}
	cout << sum << endl;
	return 0;
}
//do smt instead of nothing! never give up!
//take care of long long!
//take care of upper or lower case e.g "yes" or "YES"?
//boundary condition! e.g. n = 0?
//brute force is always the first choice!
// print the ans to look for patterns in the data!

Measured memory_bytes: 5748
n = int(input())
list_a = map(int, input().split())
list_a = list(list_a)
total = sum(list_a)
l = 0
res = 100000000000
if n == 2:
    print(abs(list_a[0] - list_a[1]))
else:
    for i in range(0, n-1):
        #print("---")
        #print(l)
        #print(total)
        l += list_a[i]
        total -= list_a[i]
        res = min(res, abs(l - total))
    print(res)

Measured memory_bytes: 76752
#include <iostream>

using namespace std;
int mod(int a)
{
    if(a>=0)
    return a;
    else
    return -a;
}

int main()
{
  int x,n;
  cin>>x>>n;
  int arr[n];
  for(int i=0;i<n;i++)
  {
      cin>>arr[i];
  }
  for(int i=x;i<=900;i++)
  {
      int flag=0;
      int add=0;
      for(int j=0;j<n;j++)
      {
          if((i==arr[j]))
          {
              flag=1;
              break;
          }     
      }
     for(int j=0;j<n;j++)
     {
        if(((2*x-i)==arr[j]))
          {
              add=1;
              break;
          }
     }
      if((flag==0)&&(add!=0))
      {
          cout<<i;
          break;
      }
      else if((flag==0)&&(add==0))
      {
          cout<<(2*x-i);
          break;
      }
      else if((flag!=0)&&(add==0))
      {
          cout<<(2*x-i);
          break;
      }
  }
  return 0;
}

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

typedef vector<string> vi;
typedef vector<tuple<int, int, int>> tup;

string padding(string S){
    int z = 6 - S.size(); 
    for(int i = 0; i < z; i++){
        S = '0' + S;
    }
    return S;
}

int main(){
    int N,M;
    int tmp1,tmp2;
    int cnt = 1;
    tup P;
    cin >> N >> M;
    vi Num(M);
    for(int i = 0; i < M; i++){
        cin >> tmp1 >> tmp2;
        P.push_back(make_tuple(tmp1,tmp2,i));
    }
    sort(P.begin(), P.end());

    Num[get<2>(P[0])] = padding(to_string(get<0>(P[0]))) + padding(to_string(cnt));

    for(int i = 1; i < M; i++){
        if(get<0>(P[i]) != get<0>(P[i-1])) cnt = 0;
        cnt++;
        Num[get<2>(P[i])] = padding(to_string(get<0>(P[i]))) + padding(to_string(cnt));    
    }

    for(int i = 0; i < M; i++){
        cout << Num[i] << endl;    
    }
}

Measured memory_bytes: 8180
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#include "queue"
#include "functional"
#include "map"
#include "unordered_map"
#include "set"
#include "stack"
 
#define lp(n) for (int i = 0; i < n; i++)
#define LP(n,i) for (int i = 0; i < n; i++)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
typedef long long ll;
using namespace std;

ll l,s,ans;
int main(){
	cin>>l>>s;
	ans=l;
	l-=s;
	while(true){
		if(s>l)swap(s,l);
		if(l%s==0){
			ans+=(l/s)*s*2-s;
			break;
		}
		ans+=(l/s)*s*2;
		l%=s;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int h1, h2, m1, m2, k;
	cin >> h1 >> m1 >> h2 >> m2 >> k;
	int a = h1*60+m1;
	int b = h2*60+m2;
	cout << abs(a-b)-k;
	return 0;
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main()
{ int N, ans = 0;
   cin >> N;
  std::vector<int> L(2*N);
  for(int i = 0; i < 2*N; i++){
      cin >> L[i];
  }
  sort(L.begin(),L.end());
  for(int i = 0; i < 2*N; i += 2){
     ans += L[i]; 
  }
  cout << ans;
    
    return 0;
}


Measured memory_bytes: 256
using namespace std;
#include <iostream>
#include <algorithm>
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
ll mod = 1e9+7;


int main(){

    int a,b,c;
    cin >> a >> b >> c;
    cout << max(c-(a-b),0) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR0(i,n) for(ll i=0;i<n;i++)
#define FOR1(i,n) for(ll i=1;i<=n;i++)
#define FORl(i,l,n) for(ll i=l;i<n;i++)
using namespace std;
#define pi pair<ll,ll>
#define pb push_back
#define ll long long
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define mst0(x) memset(x,0,sizeof(x));
#define vi vector<ll>
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define sp <<" "<<
#define intmax 1e14
ll power(ll num,ll g,ll mod){
  if(g==0)return 1;
  if(g%2==1)return (num*power((num*num)%mod,g/2,mod))%mod;
  return power((num*num)%mod,g/2,mod);
}

bool visited[100001]={};
int parent[100001]={};
vi vo[100001],v[100001];
void dfs(int n,int p){
	visited[n] = 1;
	FOR0(i,v[n].size()){
		if (visited[v[n][i]]==0) {
			visited[n]=0;
			return;
		}
	}
	FOR0(i,vo[n].size()){
		if (!visited[vo[n][i]]){
			parent[vo[n][i]] = n;
			dfs(vo[n][i],n);
		} 
	}

}

int main(){
	int n,m,x,y;
	cin>>n>>m;
	FOR0(i,n+m-1){
		cin>>x>>y;
		vo[x].pb(y);
		v[y].pb(x);
	}
	int root;
	FOR1(i,n) if (v[i].size()==0) root = i;
	parent[root]=0;
	dfs(root,0);
	FOR1(i,n) cout<<parent[i]<<endl;
}

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

	
int main(){
	while(true){


	string s1;
	cin>>s1;
	
	if(s1=="."){
		break;
	}

	string s2;
	cin>>s2;
	
	if(s1==s2){
		cout<<"IDENTICAL"<<endl;
		continue;
	}

	string t1=s1;
	string t2=s2;
	
	while(true){
		size_t d1b =t1.find('\"');
		if(d1b==string::npos)
			break;
		
		t1.replace(d1b,1,"@");
		
		size_t d1e=t1.find('\"');
		t1.replace(d1e,1,"@");		

		size_t d2b =t2.find('\"');
		if(d2b==string::npos)
			break;
		t2.replace(d2b,1,"@");
		
		size_t d2e=t2.find('\"');
		t2.replace(d2e,1,"@");

		string u1=s1;
		u1.replace(d1b+1,d1e-d1b-1,"");
		string u2=s2;
		u2.replace(d2b+1,d2e-d2b-1,"");
		
		if(u1==u2){
			t1=u1;
			t2=u2;
			break;
		}
	}
	if(t1==t2){
		cout<<"CLOSE"<<endl;
	}else{
		cout<<"DIFFERENT"<<endl;
	}
	}
return 0;
}

Measured memory_bytes: 3228
S = gets.chomp
N = S.length

num_zero = 0
for i in 1..N do
  if S[i-1] == "0" then
    num_zero += 1
  end
end
num_one = N - num_zero
  
if num_one > num_zero then
  puts num_zero * 2
else
  puts num_one * 2
end

Measured memory_bytes: 14432
#include<stdio.h>
#define NUM 100

int main(){
  
  char c;
  int i,stack[NUM];

  for(i=0;i<NUM;i++){
    stack[i] = 0;
  }
  
  i = 0;
  
  while((c=getchar())!='\n'){

    if(c>='0' && c<='9')
      stack[i] = 10*stack[i]+(c-'0');

    if(c==' ')
      i++;

    if(c=='+'){
      i--;
      stack[i-1]+=stack[i];
      stack[i]=0;
      i--;
    }
    
    if(c=='-'){
      i--;
      stack[i-1]-=stack[i];
      stack[i]=0;
      i--;
    }

    if(c=='*'){
      i--;
      stack[i-1]*=stack[i];
      stack[i]=0;
      i--;
    }
  }

  printf("%d\n",stack[0]);

  return 0;
}

   
    


Measured memory_bytes: 2108
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

#include <bits/stdc++.h>
using namespace std;
int main(){
  string s,t,u="";
  map<string,int> m;
  m[t]=0;
  while(cin>>s){
    m[s]++;
    if(m[s]>m[t]) t=s;
    if(s.size()>u.size()) u=s;
  }
  
  cout<<t<<" "<<u<<endl;
      
  return 0;
}


Measured memory_bytes: 3152
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  string s;
  cin >> s;
  vector<int> v(26, -1);
  rep(i, s.size()){
    int now = s.at(i) - 'a';
    if(v.at(now) != -1){
      int bi = v.at(now);
      if(i - bi < 3){
        cout << bi+1 << " " << i+1 << endl;
        return 0;
      }
    }
    v.at(now) = i;
  }
  cout << -1 << " " << -1 << endl;
  return 0;
}

Measured memory_bytes: 512
import sys
R = lambda:map(int,raw_input().split())
def solve(s,f):
    for i in xrange(30):
        c = []
        for j in xrange(n):
            if f[j][i+1] is True:
                c.append(j)
            #print sys.stderr, i,c
        if len(c) >= 2:
            for k in xrange(1,len(c)):
                #print sys.stderr, s
                s[c[0]].update(s[c[k]])
                #print sys.stderr, s[c[0]],s[c[k]]
                #print sys.stderr, s
            for k in xrange(1,len(c)):
                #print sys.stderr, s
                #print c[k]
                s[c[k]] = s[c[0]].copy()
        #print sys.stderr, s
        for j in xrange(n):
            if len(s[j]) is n: return i+1
    else: return -1
    
while 1:
    n = int(raw_input())
    if n is 0: break
    f = [[False for i in xrange(31)] for j in xrange(n)]
    s = [set() for i in xrange(n)]
    for i in xrange(n):
        m = R()
        for j in xrange(m[0]):
            f[i][m[j+1]] = True
    #print sys.stderr, s
    for i in xrange(n):
        s[i].add(i+1)
    #print sys.stderr, s
    print solve(s,f)

Measured memory_bytes: 5332
import java.util.*;
import java.awt.geom.*;

public class Main{
	double EPS = 1.0e-08;

	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
			int m = sc.nextInt();
			int [][] pass = new int[n][n];
			int INF = 1 << 24;
			for(int i = 0; i < n; i++){
				Arrays.fill(pass[i], INF);
			}
			for(int i = 0; i < m; i++){
				int a = sc.nextInt();
				int b = sc.nextInt();
				int cost = sc.nextInt();
				pass[a][b] = -cost;
			}
			for(int j = 0; j < n; j++){
				for(int i = 0; i < n; i++){
					for(int k = 0; k < n; k++){
						pass[i][k] = Math.min(pass[i][k], pass[i][j] + pass[j][k]);
					}
				}
			}
			System.out.println(pass[0][n-1] * -1);
		}
	}
	
	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

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

Measured memory_bytes: 25184
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<algorithm>
using namespace std;
int main() {
	long long N = 0;
	cin >> N;
	char *A = new char[N];
	char *B = new char[N];
	char *C = new char[N];
	int  count = 0;

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

	for (int i = 0; i < N; i++) {
		if (A[i] == B[i] && B[i] == C[i]) {
			continue;
		}
		
		if(A[i] == B[i] && B[i] != C[i]){
			count++;
			continue;
		}

		if (B[i] == C[i] && C[i] != A[i]) {
			count++;
			continue;
		}

		if (C[i] == A[i] && A[i] != B[i]) {
			count++;
			continue;
		}

		if (A[i] != B[i] && B[i] != C[i]) {
			count += 2;
			continue;
		}


	}
		
	cout << count << endl;

}

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

A = list(map(int, input().split()))

B = []
C = []

for i in range(n):
    if i % 2 == 0:
        B.append(str(A[i]))
    else:
        C.append(str(A[i]))

if n % 2 == 0:
    s = " ".join(list(reversed(C)))
    t = " ".join(B)
    print(s + " " + t)
else:
    s = " ".join(list(reversed(B)))
    t = " ".join(C)
    print(s + " " + t)

Measured memory_bytes: 115156
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <random>
#include <complex>
#include <assert.h>

using namespace std;
typedef long long ll;
#define endl '\n'

template<typename T>
inline bool chmin(T& x, T a) {
	if (x >= a) { x = a; return true; }
	return false;
}

template<typename T>
inline bool chmax(T& x, T a) {
	if (x <= a) { x = a; return true; }
	return false;
}

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

	int N; cin >> N;
	N -= 400;
	N /= 200;
	cout << 8 - N << endl;

	return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>
#include <math.h>

#define PI 3.141592

int main(void)
{
    int d,a;
    double x,y;
    int angle;

    x = y = 0;
    angle = 90;
    while (1){
        scanf("%d,%d", &d, &a);
        if (d == 0 && a == 0){
            break;
        }
        x += cos(angle * PI / 180) * d;
        y += sin(angle * PI / 180) * d;
        angle -= a;
    }
    printf("%d\n", (int)x);
    printf("%d\n", (int)y);

    return (0);
}


Measured memory_bytes: 2020
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;

int main(){
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	ll a,b,t;
    cin >> a >> b >> t;
    cout << t/a*b << endl;
    cin >> a;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;typedef vector<ll> vll;
#define fill(a) memset(a, 0, sizeof (a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0; i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define each(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define unq(v) sort(all(v)),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define getpos(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define _ios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ff first
#define ss second
#define pb push_back
#define sz(x) (int)x.size()
#define sq(x) (x)*(x)
const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int maxn = 2000100;

int main(){
        _ios;

        ll n;
        cin>>n;
        vll x(n);
        rep(i,n){
            cin>>x[i];
        }
        ll ans = 10000000000;
        for(int i = 0; i<100;i++){
            int p = i+1;
            ll sum = 0;
            for(int j = 0; j<n;j++){
                ll res = (x[j]-p);
                sum+= sq(res);
            }
            ans = min(ans,sum);
        }
        cout<<ans<<endl;



return 0;
}







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

int main(){
    long long ans = 0;
    int n, t0, t1 ,T;

    cin >> n >> T;
    cin >> t0;
    for (int i = 2; i <= n; i++)
    {
        cin >> t1;
        ans += min(T, t1 - t0);
        t0 = t1;
    }

    ans += T;
    cout << ans << endl;

}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using static System.Math;
using System.Linq;
 
class Ctest {
    static void Main(string[] args) {
        int n = int.Parse(Console.ReadLine());
        var myTable = new Dictionary<string, int>();
        String wk = "";
        int max = 1;
        for (int i = 0; i < n; i++){
            wk = Console.ReadLine();
            if (myTable.ContainsKey(wk)) {
                myTable[wk]++;
                max = Max(max, myTable[wk]);
            } else {
                myTable[wk] = 1;
            }
        }
        var ans = new List<string>();
        foreach (var x in myTable) {
            if (max == x.Value) ans.Add(x.Key);
        }
        ans.Sort(StringComparer.Ordinal);
        Console.WriteLine(string.Join("\n", ans));
    }
}


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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    int n;
    cin >> n;
    vint c(n - 1), s(n - 1), f(n - 1);
    rep(i, n - 1)
    {
        cin >> c[i] >> s[i] >> f[i];
    }

    rep(i, n)
    {
        int ans = 0;
        REP(j, i, n - 1)
        {
            if (ans <= s[j])
            {
                ans = s[j];
                ans += c[j];
            }
            else
            {
                if (ans % f[j] == 0)
                {
                    ans += c[j];
                }
                else
                {
                    ans += f[j] - (ans % f[j]) + c[j];
                }
            }
        }
        cout << ans << endl;
    }
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

using namespace std;
 
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
 
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<bool> VB;

int main() {
    int n;
    cin >> n;
    rep(i,50001) {
        int k = i*1.08;
        if(n==k) {
            cout << i << endl;
            return 0;
        }
    } 

    cout << ":(" << endl;

}

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

int main() {
  int a, b;
  cin >> a >> b;
  
  if(a + b == 15) {
    cout << '+' << endl;
  }
  else if(a * b == 15) {
    cout << '*' << endl;
  }
  else {
    cout << 'x' << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
 int n;
 cin>>n;
 int l,r;
 int count=0;
 while(n--){
   cin>>l>>r;
   count+=r-l+1;
   if(count>100000){
    count=100000;
    break;
   }
 }
 cout<<count<<endl;

}


Measured memory_bytes: 256
import java.util.*;

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

        int x = sc.nextInt();
        int n = sc.nextInt();

        if(n == 0) {
            System.out.println(x);
            System.exit(0);
        }

        int[] p = new int[102];

        for(int i=0; i<n; i++) {
            p[sc.nextInt()] = 1;
        }

        int diff = 0;
        int comp = 0;
        int ans = 0;
        for(int i=0; i<=101; i++) {
            if(p[i] != 1) {
                diff = Math.abs(x-i);
                if(i == 0) comp = diff;
                if(comp > diff) {
                    comp = diff;
                    ans = i;
                }
            }

        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 35928
#!/usr/bin/env python3
n, m = map(int, input().split())
h = list(map(int, input().split()))
ans = []
for _ in range(m):
    a, b = map(int, input().split())
    if h[a-1] > h[b-1]:
        ans.append(b-1)
    elif h[a-1] < h[b-1]:
        ans.append(a-1)
    else:
        ans.append(a-1)
        ans.append(b-1)
print(n - len(set(ans)))

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

 int main()
 {
   int a,b;
   cin>>a>>b;
   
   if(a>=2*b)
   {
   	cout<<a-2*b<<endl;
   }
   else
   {
   	cout<<0<<endl;
   }
  return 0;
}
      

Measured memory_bytes: 256
# include <cstdio>
# include <functional>
# include <algorithm>
using namespace std;
 
int n, a[500];
 
int main () {
	scanf ("%d", &n); n *= 2;
	for (int i = 1; i <= n; ++ i) scanf ("%d", &a[i]);
	sort (a + 1, a + n + 1, greater <int> ());
	int res = 0;
	for (int i = 2; i <= n; i += 2) res += a[i];
	printf ("%d\n", res);
	return 0;
}

Measured memory_bytes: 128
#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>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR
#endif

#define PRINT(s) cout << (s);
#define PRINTLN(s) cout << (s) << endl;

using namespace std;

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

int main() {
    long long int numbers[100001];
    long long int N,K;
    cin >> N >> K;
    REP(i,0,100001){
        numbers[i] = 0LL;
    }
    REP(i,0,N){
        int a,b;
        cin >> a >> b;
        numbers[a] += 1LL*b;
    }
    long long int lower = 0;
    REP(i,0,100001){
        lower += 1LL*numbers[i];
        if(lower >= K){
            PRINTLN(i);
            break;
        }
    }
}


Measured memory_bytes: 1024
s = input()
odd  = ['R','U','D']
even = ['L','U','D']

flg = True
for i in range(len(s)):
    if i % 2 != 0:
        if not s[i] in even:
            flg = False
            break
    else:
        if not s[i] in odd:
            flg = False
            break
if flg:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <stdio.h>
#include <math.h>

int main(void)
{
	int h, w, a[250000], ans[1000000], n, flag=0, dir=0, h1, w1, k=0, p=0, i1, i2, c=0;
	scanf("%d%d", &h, &w);
	h1=h;
	w1=w;
	for (int i = 0; i < h; ++i)
	{
		for (int j = 0; j < w; ++j)
		{
			scanf("%d", &a[500*i+j]);
		}
	}
	while (c < w*h)	
	{
		if (dir==0 || dir==1)
		{
			if (dir==0 && flag==1)
			{
				ans[k]=p/500+1;
				ans[k+1]=(p+500)%500;
				ans[k+2]=ans[k];
				ans[k+3]=ans[k+1]+1;
				k+=4;
				if ((a[p]+2)%2 == 1) 
				{
					flag=0;
					a[p]++;
				}
			}
			i1=(int)pow(-1, dir);
			for (int i = 0; i < w1-1; ++i)
			{
				i2=i1*i;
				if ((flag+a[p+i2]+2)%2 == 1)
				{
					ans[k]=(p+i2)/500+1;
					ans[k+1]=(p+i2+500)%500+1;
					ans[k+2]=ans[k];
					ans[k+3]=ans[k+1]+i1;
					k+=4;
				}
				if ((a[p+i2]+2)%2 == 1) flag=(flag+3)%2;
			}
			if (dir == 0)
			{
				dir=2;
				if (h1==1) c++;
			}
			else
			{
				dir=3;
				if (h1==2) c++;
			}
			p=p+(w1-1)*i1;
			c=c+w1-1;
		} else
		{
			i1=(int)pow(-1, dir);
			if (dir==3) h1--;
			for (int i = 0; i < h1-1; ++i)
			{
				i2=i1*i*500;
				if ((flag+a[p+i2]+2)%2 == 1)
				{
					ans[k]=(p+i2)/500+1;
					ans[k+1]=(p+i2+500)%500+1;
					ans[k+2]=ans[k]+i1;
					ans[k+3]=ans[k+1];
					k+=4;
				}
				if ((a[p+i2]+2)%2 == 1)
				{
					flag=(flag+3)%2;
				}
			}
			if (dir == 2)
			{
				p+=500*(h1-1)*i1;
				c=c+h1-1;
				if (w1==1) c++;
				dir=1;
			}
			else
			{
				dir=0;
				p=p+500*(h1-1)*i1+1;
				if ((a[p-1]+2)%2 == 1)
				{
					flag=(flag+3)%2;
				}
				c=c+h1;
				if (w1==2) c++;
				h1--;
				w1-=2;
			}
		}
	}
	printf("%d\n", k/4);
	for (int i = 0; i < k/4; ++i)
	{
		printf("%d %d %d %d\n", ans[4*i], ans[4*i+1], ans[4*i+2], ans[4*i+3]);
	}
	return 0;
}

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

int main(void){
    int l;
    cin>>l;
    double ans=0.0;
    double a=((double)l)/3;
    ans=a*a*a;
    /*for(int i=1;i<=l;i++){
        for(int j=1;j<=l;j++){
            int k=l-i-j;
            if(k<=0) continue;
            double t=(double)i*(double)j*(double)k;
            ans=max(ans, t);
        }
    }*/
    printf("%.10f\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
void solve(){
	int h,w,k;
	cin>>h>>w>>k;
	char arr[h][w];
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>arr[i][j];
		}
	}
	int glob=0;
	int cntr[h];memset(cntr,0,sizeof(cntr));int z;
	int cntc[w];memset(cntc,0,sizeof(cntc));
	for(int i=0;i<h;i++){
		z=0;
		for(int j=0;j<w;j++){
			if(arr[i][j]=='#'){
			z++;glob++;}
		}
		cntr[i]=z;
	}
	for(int j=0;j<w;j++){
		z=0;
		for(int i=0;i<h;i++){
			if(arr[i][j]=='#'){
			z++;}
		}
		cntc[j]=z;
	}
//	for(auto x:cntr) cout<<x<<" ";
//	cout<<'\n';
//	for(auto x:cntc) cout<<x<<" ";
//	cout<<glob<<'\n';
	int max=(1<<(h+w));int ans=0;
	for(int mask=0;mask<max;mask++){
		int total=0;map<int,bool>mpr,mpc;
		for(int j=0;j<h+w;j++){
			if(mask&(1<<j)){
				if(j<=h-1){
					mpr[j]=true;
					total+=cntr[j];
				}
				else if(j>=h){
					mpc[j-h]=true;
					total+=cntc[j-h];
				}
			}
		}
		for(auto x:mpc){
			for(auto y:mpr){
				if(arr[y.first][x.first]=='#')
				total--;
			}
		}
//		cout<<mask<<" "<<total<<'\n';
		if(glob-total==k) ans++;
	}
	cout<<ans;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);	 
	int T=1;
	//cin>>T;
	while(T--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
 
using namespace std;
 
#define int long long 
#define INF 1e9
#define LINF 1e18
 
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<int, P> Pi;
typedef pair<P, P> PP;
 
const int MOD = 1e9 + 7;
const int dy[] = { 0, 0, 1, -1 };
const int dx[] = { 1, -1, 0, 0 };
 
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int x, y, z, k;
int a[1000], b[1000], c[1000];
vector<int> com, res;

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

    cin >> x >> y >> z >> k;
    for(int i = 0; i < x; ++i) cin >> a[i];
    for(int i = 0; i < y; ++i) cin >> b[i];
    for(int i = 0; i < z; ++i) cin >> c[i];
    
    for(int i = 0; i < x; ++i) {
        for(int j = 0; j < y; ++j) com.push_back(a[i] + b[j]);
    }
    sort(com.begin(), com.end(), greater<int>());
    for(int i = 0; i < min((int)k, (int)com.size()); ++i) {
        for(int j = 0; j < z; ++j) res.push_back(com[i] + c[j]);
    }
    sort(res.begin(), res.end(), greater<int>());
    for(int i = 0; i < k; ++i) cout << res[i] << endl;

    return 0;
}

Measured memory_bytes: 43108
#include<stdio.h>

int main(void){

	int w,n,num[40],i,j,x[40],y[40],tmp;
	
	scanf("%d",&w);
	scanf("%d",&n);
	
	for(i=1;i<=w;++i)num[i]=i;
	for(i=1;i<=n;++i)scanf("%d,%d",&x[i],&y[i]);
	for(i=1;i<=n;++i){
		tmp=num[x[i]];
		num[x[i]]=num[y[i]];
		num[y[i]]=tmp;
	}
	
	for(i=1;i<=w;++i)printf("%d\n",num[i]);

return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll mod = 1000000007;
ll INF = 1000000009;


void solve(){
    int n,x;
    cin >> n >> x;
    int m[n+10];
    int mi = INF;
    int sum=0;
    rep(i,n){
        cin >> m[i];
        mi = min(mi, m[i]);
        sum += m[i];
    }
    int tmp = (x-sum)/mi;
    cout << n+tmp << endl;

}

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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <map>
#include <queue>
#include <set>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i <= n; i++)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
using namespace std;
ll mod = 1e9 + 7;

int main()
{
	string s;
	cin >> s;
	int k;
	cin >> k;
	set<string>ss;
	vector<string>sv;
	for (int i = 0; i < s.size(); i++)
	{
		for (int j = i; j <= i+k; j++)
		{
			string ssub = s.substr(i, j - i + 1);
			ss.insert(ssub);
		}
	}
	for (auto x:ss)
	{
		sv.push_back(x);
	}
	sort(ALL(sv));

	co(sv[k - 1]);
}

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, Q;
    cin >> N >> Q;
    fenwick_tree<ll> ft(N);
    for(int i=0; i<N; i++)
    {
        int a;
        cin >> a;
        ft.add(i, a);
    }
    for(int i=0; i<Q; i++)
    {
        int a, b, c;
        cin >> a >> b >> c;
        if(a == 0)
        {
            ft.add(b, c);
        }
        else
        {
            cout << ft.sum(b, c) << '\n';
        }
        
    }

    return 0;
}


Measured memory_bytes: 8256
// A. 

#include <iostream>
#include <algorithm>
#include <sstream>
#include <cstdio>
#include <cstring>

using namespace std;

int main(int argc, char *argv[])
{
	string s;
	cin >> s;
	int sum = 0, length = (int)s.length();
	for (int i = 1; i < length; ++i) {
		sum += s[i] - '0';
	}
	if (sum != (length - 1) * 9) {
		sum = (length - 1) * 9 - 1;
	}
	sum += s[0] - '0';
	cout << sum << endl;
	return 0;
}


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

using std::cin;
using std::cout;
using std::endl;

using std::vector;
using std::string;

int n;
string s;

int main () {

    cin >> n;
    cin >> s;

    for (auto p = s.begin(); p != s.end(); p++ ) {
        auto c = *p;
        c += n;
        if('Z' < c) {
            c = 'A' + (c - 'Z' - 1);
        }
        *p = c;
    }

    cout << s << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repv(t,it,v) for(vector<t>::iterator it = v.begin() ; it != v.end() ; ++it)

typedef long long LL;

int N;
int T[100010];
int A[100010];
const LL mod = 1e9 + 7;
LL ans = 1;
int h[100010][2];

int main(){
	scanf("%d" , &N);
	repp(i,0,N){
		scanf("%d" , T + i);
	}
	repp(i,0,N){
		scanf("%d" , A + i);
	}
	h[0][0] = h[0][1] = T[0];
	++h[0][1];
	repp(i,1,N){
		if(T[i-1] == T[i]){
			h[i][0] = 1;
			h[i][1] = T[i] + 1;
		} else {
			h[i][0] = T[i];
			h[i][1] = T[i] + 1;
		}
	}
	h[N-1][0] = max(A[N-1] , h[N-1][0]);
	h[N-1][1] = min(A[N-1] + 1 , h[N-1][1]);
	repm(i,N-2,-1){
		if(A[i+1] == A[i]){
			h[i][1] = min(h[i][1] , A[i] + 1);
		} else {
			h[i][0] = max(h[i][0] , A[i]);
			h[i][1] = min(h[i][1] , A[i] + 1);
		}
	}
	repp(i,0,N){
		if(h[i][0] >= h[i][1]){
			ans = 0;
		} else {
			ans = ans * (h[i][1] - h[i][0]) % mod;
		}
	}
	printf("%lld\n" , ans);
	return 0;
}


Measured memory_bytes: 1664
#include <stdio.h>

int main() {
  int h, w, h_roop, w_roop;

  while(scanf("%d %d", &h, &w)) {
    if(h == 0 && w == 0) {
      break;
    } else {
      for(h_roop = 0; h_roop < h; h_roop++) {
        for(w_roop = 0; w_roop < w; w_roop++) {
          if((h_roop % 2 == 0 && w_roop % 2 == 0) || (h_roop % 2 == 1 && w_roop % 2 == 1)) {
            printf("#");
          } else {
            printf(".");
          }
        }
        puts("");
      }
      puts("");
    }
  }

  return 0;
}

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

int main()
{
	int N, M;
	cin >> N >> M;
	vector<int> s( M );
	vector<int> c( M );
	for( int i = 0; i < M; i++ ) {
		cin >> s[i] >> c[i];
		s[i]--;
	}

	vector<int> num[3];
	for( int i = 0; i < M; i++ ) {
		for( int j = 0; j < num[ s[i] ].size(); j++ ) {
			if( num[ s[i] ][j] != c[i] ) {
				cout << -1 << endl;
				return 0;
			}
		}
		num[ s[i] ].push_back( c[i] );
	}
	vector<char> ans( N, '0' );
	int flag = 0;
	for( int i = 0; i < M; i++ ) {
		ans[ s[i] ] = c[i] + '0';
		if( s[i] == 0 && c[i] == 0 ) flag = 1;
	}
	if( flag ) {
		if( N > 1 ) {
			cout << -1 << endl;
			return 0;
		}
	}
	else if( ans[0] == '0' && N > 1 ) ans[0] = '1';

	for( int i = 0; i < N; i++ ) {
		cout << ans[i];
	}
	cout << endl;
}


Measured memory_bytes: 256