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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
  os << p.first << " " << p.second;
  return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}
/*
   typedef __int128_t Int;
   std::ostream &operator<<(std::ostream &dest, __int128_t value) {
   std::ostream::sentry s(dest);
   if (s) {
   __uint128_t tmp = value < 0 ? -value : value;
   char buffer[128];
   char *d = std::end(buffer);
   do {
   --d;
 *d = "0123456789"[tmp % 10];
 tmp /= 10;
 } while (tmp != 0);
 if (value < 0) {
 --d;
 *d = '-';
 }
 int len = std::end(buffer) - d;
 if (dest.rdbuf()->sputn(d, len) != len) {
 dest.setstate(std::ios_base::badbit);
 }
 }
 return dest;
 }

 __int128 parse(string &s) {
 __int128 ret = 0;
 for (int i = 0; i < s.length(); i++)
 if ('0' <= s[i] && s[i] <= '9')
 ret = 10 * ret + s[i] - '0';
 return ret;
 }
 */

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

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

  string s; cin >> s;
  string t;cin>>t;
  sort(all(s));
  sort(all(t),greater<char>());
  Yes(s<t);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LONGLONGMAX 9223372036854775807
#define LONGLONGMIN -9223372036854775807
#define INTMAX 32767
#define INTMIN -32767
#define ROUNDUP(divisor,dividend) (divisor + (dividend - 1)) / dividend
long long int n,i,l=0;
int main(){
  cin >> n;
  while(l*l<=n){
    i = l*l;
    l++;
  }
  cout << i << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  int main(){
    int N;
    cin >> N;
    int cart = 0;
    int osaihu = 0;
    vector<int> houseki(N);
    vector<int> cost(N);
    for(int i = 0; N > i; i++){
        cin >> houseki.at(i);
    }
    for(int i = 0; N > i; i++){
        cin >> cost.at(i);
    }
    for(int i = 0; N > i; i++){
        if(houseki.at(i) > cost.at(i)){
            cart += houseki.at(i);
            osaihu += cost.at(i);
        }
    }
    cout << cart - osaihu << endl;
  }

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

#define ll long long
#define mtv(kit) cout<<#kit<<" - "<<kit<<"\n";
#define ff first
#define ss second
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define pii pair<ll , ll>
#define ump unordered_map<ll , ll>

void doit(){
	ll n,i,x,ans;
	rep(i,1,6){
		cin>>x;
		if(x==0)ans=i;
	}
	cout<<ans<<"\n";
}	

int main() {
#ifndef ONLINE_JUDGE
	freopen("input1.txt","r",stdin);
	freopen("output1.txt","w",stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t = 1;
	//cin>>t;
	for(ll i = 1; i <= t; i++){
		doit();
	}
}


Measured memory_bytes: 3544
#include <stdio.h>
int main(){
    int i,j,k[31],a,b,c,tmp;
    for(i=1;i<=30;i++){
        k[i]=i;
    }
    scanf("%d %d",&i,&j);
    for(a=0;a<j;a++){
        scanf("%d,%d",&b,&c);
        tmp=k[b];
        k[b]=k[c];
        k[c]=tmp;
    }
    for(a=1;a<=i;a++){
        printf("%d\n",k[a]);
    }
    return (0);
}

Measured memory_bytes: 596
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n, q;
string s;
char t[200100], d[200100];

bool check(int k) {
    int pos = k-1;
    for (int i = 0; i < q; i++) {
        if (pos < 0) return true;
        if (pos >= n) return false;

        if (s[pos] == t[i]) {
            if (d[i] == 'L') {
                pos--;
            } else {
                pos++;
            }
        }
    }
    if (pos < 0) return true;
    return false;
}

int calc() {
    int lb = 0, ub = n+1;
    while (ub - lb > 1) {
        int mid = (lb + ub) / 2;
        if (check(mid)) {
            lb = mid;
        } else {
            ub = mid;
        }
    }
    return lb;
}

int solve() {
    int res = n;
    res -= calc();

    reverse(s.begin(), s.end());
    for (int i = 0; i < q; i++) {
        if (d[i] == 'L') d[i] = 'R';
        else d[i] = 'L';
    }
    res -= calc();
    return res;
}

void input() {
    cin >> n >> q >> s;
    for (int i = 0; i < q; i++) cin >> t[i] >> d[i];
}

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

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 1020
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a) = min((a), (b)))
#define chmax(a, b) ((a) = max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const double pi = acos(-1);
const double eps = 1e-10;

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

int main(){
    vector<int> e(12);
    for(int i=0; i<12; i++) cin>>e[i];
    sort(e.begin(), e.end());

    if(e[0] == e[3] && e[4] == e[7] && e[8] == e[11]){
        cout << "yes" << endl;
    }
    else{
        cout << "no" << endl;
    }
}


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

int main() {
  int a,ans,min;
  ans=0;
  min=1000000; 
  cin>>a;
  for(int i=0;i<a;i++){
  	int tmp;
  	cin>>tmp;
  	if(min>tmp){
  	  min=tmp;
  	  ans++;
  	}
  }
  cout<<ans<<endl;
 }


Measured memory_bytes: 256
n, d = map(int, input().split())

def dist(p, q): return (p*p + q*q) ** 0.5

xy = [list(map(int, input().split())) for _ in range(n)]
res = 0
for x, y in xy:
    if(dist(x, y) <= d): res += 1

print(res)

Measured memory_bytes: 45764
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 100000000;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
const ll MAX = 200010;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    bool ok = 0;
    rep(i,s.length()-1){
        if (s.substr(i,2) == "AC") ok = 1;
    }
    Yes(ok);
}



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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

int nextInt() { int x; scanf("%d", &x); return x;}

const int MAX_N = 505;
int a[MAX_N][MAX_N];

void solve(vector<int> v, int level) {
  int N = v.size();
  if (N <= 1) return;

  vector<int> L, R;
  REP(i, N) {
    if (i % 2 == 0) L.push_back(v[i]);
    else R.push_back(v[i]);
  }
  REP(i, L.size()) {
    REP(j, R.size()) {
      a[L[i]][R[j]] = level;
      a[R[j]][L[i]] = level;
    }
  }
  solve(L, level + 1);
  solve(R, level + 1);
}

int main2() {
  int N = nextInt();


  vector<int> v(N);
  REP(i, N) v[i] = i;

  CLR(a, 0);
  solve(v, 1);

  // REP(i, N) {
    // REP(j, N) cout << a[i][j] << " ";
    // cout << endl;
  // }

  for (int i = 0; i < N - 1; i++) {
    bool first = true;
    for (int j = i + 1; j < N; j++) {
      if (first) { first = false; } else cout << " ";
      cout << a[i][j];
    }
    cout << endl;
  }
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 1000000000
#define InfLL 1000000000000000000LL
#define mod 2019
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=(n-1);(i)>=(0);(i)--)
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	string S;
	cin >> S;
	int N = S.length();
	vi Smod(N + 1);
	Smod[0] = 0;
	int pow10 = 1;
	rep(i, N) {
		Smod[i + 1] = Smod[i];
		Smod[i + 1] += pow10 * (S[N - 1 - i] - '0');

		pow10 *= 10;
		pow10 %= mod;
		Smod[i + 1] %= mod;
	}
	vl Ssum(mod, 0);
	ll ans = 0;
	rep(i, N + 1) {
		int modtmp = Smod[i];
		ans += Ssum[modtmp];
		Ssum[modtmp]++;
	}


	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4452
#include <bits/stdc++.h>
#define IO             freopen (task".inp", "r", stdin), freopen (task".out", "w", stdout)
#define FORR(i, a, b)  for (long long i = (a), _b = (b); i <= _b; i++)
#define FORD(i, a, b)  for (long long i = (b), _a = (a); i >= _a; i--)
#define REPP(i, a, b)  for (long long i = (a); _b = (b); i < _b; ++i)
#define REPD(i, a, b)  for (long long i = (b); _a = (a); i > _a; --i)
#define mem(a, x)      memset(x, (a), sizeof(x))
#define cmin(a, b)     if ((a) > (b)) (a) = (b)
#define cmax(a, b)     if ((a) < (b)) (a) = (b)
#define reset(x)       memset(x, 0, sizeof(x))
#define bitcount(x)    __builtin_popcountll((x))
#define all(a)         (a).begin(), (a).end()
#define debug(x)       cout << (x) << "\n"
#define BIT(x, i)      (((x) >> (i)) & 1)
#define sz(a)          ((long long) (a).size())
#define ii             pair<long long, long long>
#define MASK(i)        (1LL << (i))
#define pf             push_front
#define mp             make_pair
#define pb             push_back
#define se             second
#define fi             first
#define task           ""

using namespace std;

const long long MOD = 1000000007;
const long long inf = 2000000000;
const long long mod = 1007050321;
const long long base = 521;
const long long N = 200005;

long long poww (long long n, long long a) {
    if (n == 1)
        return a;
    if (n == 0)
        return 1;
    long long t = poww(n/2, a);
    t = 1LL * t * t % MOD;
    if (n % 2)
        t = 1LL * t * a % MOD;
    return t;
}

long long n, m, k;
long long a[N], b[N];

int main() {
    ios_base :: sync_with_stdio(0),cin.tie(0),cout.tie(0);

    cin >> n >> m >> k;
    for (long long i = 1; i <= n; ++i) {
        cin >> a[i];
        a[i] += a[i-1];
    }
    for (long long i = 1; i <= m; ++i) {
        cin >> b[i];
        b[i] += b[i-1];
    }
    long long ans = 0;
    for (long long i = 1; i <= n; ++i) {
        if (a[i] > k) break;
        long long pos = upper_bound(b, b + 1 + m, k - a[i]) - b - 1;
        ans = max(ans, i + pos);
    }
    for (long long i = 1; i <= m; ++i) {
        if (b[i] > k) break;
        long long pos = upper_bound(a, a + 1 + n, k - b[i]) - a - 1;
        ans = max(ans, i + pos);
    }
    cout << ans;
    return 0;

}


Measured memory_bytes: 6764
s = int(input())

def f(n):
    if n%2 == 0:
        return n // 2
    else:
        return n*3+1

ans = 0
set1 = set()
while True:
    if s in set1:
        print(ans+1)
        exit()
    else:
        set1.add(s)
        s = f(s)
        ans += 1


Measured memory_bytes: 38448
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <vector>
#include <map>
#include<cstdio>
#include<functional>
#include <bitset>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define ll long long
using namespace std;
template <typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;

std::string substrBack(std::string str, size_t pos, size_t len) {
	const size_t strLen = str.length();

	return str.substr(strLen - pos, len);
}

int main()
{
	int n;
	cin >> n;
	vector<pair<double, double>> l(n);
	vector<double> d(n);
	rep(i, n) {
		double x, y;
		cin >> x >> y;
		l[i] = pair<double, double>(x, y);
		d[i] = i;
	}
	double ans = 0;
	double count = 0;
	do
	{
		for (int i = 1; i < d.size(); i++)
		{
			ans += sqrt(pow(abs(l[d[i - 1]].first - l[d[i]].first), 2) + pow(abs(l[d[i - 1]].second - l[d[i]].second), 2));
		}
		++count;
	} while (next_permutation(d.begin(), d.end()));
	ans /= count;
	std::cout << std::fixed;
	std::cout << std::setprecision(7);
	cout << ans << endl;
	system("pause");
}




Measured memory_bytes: 3776
#include <stdio.h>

int main()
{
    int x;
    scanf("%d", &x);

    if (x >= 400 && x <= 599) printf("8");
    if (x >= 600 && x <= 799) printf("7");
    if (x >= 800 && x <= 999) printf("6");
    if (x >= 1000 && x <= 1199) printf("5");
    if (x >= 1200 && x <= 1399) printf("4");
    if (x >= 1400 && x <= 1599) printf("3");
    if (x >= 1600 && x <= 1799) printf("2");
    if (x >= 1800 && x <= 1999) printf("1");

    return 0;
}


Measured memory_bytes: 1644
import math
import fractions

x, y = map(int,input().split())

gcd = fractions.gcd(x,y)

size = int(math.sqrt(gcd)) + 1

def calc_div(num):
    table =  []
    for i in range(2,int(math.sqrt(num))+1):
        if num % i == 0:
            table.append(i)    
            while num % i == 0:
                num //= i
    if num > int(math.sqrt(num)):
        table.append(num)
    return table 

ans = calc_div(gcd)

print(len(ans) + 1)

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    A=LI()
    ans=0
    ceil=A[0]
    for i in range(N):
        if A[i]>ceil:
            ceil=A[i]
        else:
            ans+=ceil-A[i]
            
    print(ans)

main()


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

class Program
{
    public static void Main()
    {
        string[] s = Console.ReadLine().Split(' ');
        int N = int.Parse(s[0]);
        int K = int.Parse(s[1]);
        int[] h = new int[N];
        s = Console.ReadLine().Split(' ');
        for (int i = 0; i < N; i++)
            h[i] = int.Parse(s[i]);

        int[] dp = new int[N];
        for (int i = 0; i < N; i++)
            dp[i] = int.MaxValue;

        dp[0] = 0;
        dp[1] = Math.Abs(h[1] - h[0]);
        for (int i = 1; i < N; i++)
        {
            for (int j = 1; j <= K && i - j >= 0; j++)
                dp[i] = Math.Min(dp[i], dp[i - j] + Math.Abs(h[i] - h[i - j]));
        }
        Console.WriteLine(dp[N - 1]);
    }
}


Measured memory_bytes: 19296
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<complex>
#include<iostream>
#include<algorithm>
#define LL long long
#define add_edge(u,v) nxt[++cnt]=head[u],head[u]=cnt,to[cnt]=v
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
char ch;bool fs;void re(int& x)
{
	while(ch=getchar(),ch<33);
	if(ch=='-')fs=1,x=0;else fs=0,x=ch-48;
	while(ch=getchar(),ch>33)x=x*10+ch-48;
	if(fs)x=-x;	
}
using namespace std;
int n,m,en[101];
char s[100][100];
int main()
{
	re(n),re(m);
	for(int i=1;i<=n;++i)
		scanf("%s",s[i]+1);
	en[0]=1;
	for(int i=1;i<=n;++i)
	{
		en[i]=en[i-1];
		for(int j=1;j<en[i];++j)if(s[i][j]=='#')return puts("Impossible"),0;
		if(s[i][en[i]]!='#')return puts("Impossible"),0;
		while(s[i][en[i]+1]=='#')++en[i];
		for(int j=en[i]+1;j<=m;++j)if(s[i][j]=='#')return puts("Impossible"),0;
	}
	puts("Possible");
}

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

int main(){
    int i,j,a,b,c,d;
    cin >> a >> b >> c >> d;
    for(j=0;j<2;j++){
        if(j==1){
            cout << "LU";
        }
        for(i=0;i<(d-b);i++){
            cout << "U";
        }
        for(i=0;i<(c-a);i++){
            cout << "R";
        }
        if(j==1){
            cout << "RDRD";
        }
        for(i=0;i<(d-b);i++){
            cout << "D";
        }
        for(i=0;i<(c-a);i++){
            cout << "L";
        }
        if(j==1){
            cout << "LU";
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
// AOJ ITP1_10_D Distance II
// 2018.4.29 bal4u

#include <stdio.h>
#include <math.h>

#define gc() getchar_unlocked()
int in()
{
	int n = 0, c = gc();
	do n = 10*n + (c & 0xf), c = gc();
	while (c >= '0');
	return n;
}

int x[102], y[102];

int main()
{
	int n, i, t, t2;
	int d, d1, d2;
	long long d3;
	
	n = in();
	for (i = 0; i < n; i++) x[i] = in();
	for (i = 0; i < n; i++) y[i] = in();
	d = 0, d1 = 0, d2 = 0, d3 = 0;
	for (i = 0; i < n; i++) {
		t = x[i] - y[i];
		if (t < 0) t = -t;
		if (t > d) d = t;
		d1 += t;
		t2 = t*t, d2 += t2;
		d3 += t2*t;
	}
	printf("%d\n", d1);
	printf("%.8lf\n", sqrt((double)d2));
	printf("%.8lf\n", pow((double)d3, 1.0/3));
	printf("%d\n", d);
	return 0;
}


Measured memory_bytes: 2100
k = int(input())
alst = list(map(int, input().split()))[::-1]
l = 2
r = 2

def check(l, r, a):
    if l % a == 0:
        return True
    elif r // a == l // a:
        return False
    else:
        return True

for a in alst:
    if not check(l, r, a):
        print(-1)
        exit()
    l = (l + a - 1) // a * a
    r = r // a * a + (a - 1)
print(l, r)

Measured memory_bytes: 20396
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#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;
typedef long long ll;
const int N = 1e+5;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

void solve() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a + b > c + d) cout << "Left" << endl;
    else if (a + b < c + d) cout << "Right" << endl;
    else cout << "Balanced" << endl;
}

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


Measured memory_bytes: 256
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE RankNTypes #-}

import Data.Array (Array, listArray, (!))
import Data.Array.ST (STArray, MArray, runSTArray, readArray, writeArray, newArray)
import Data.Maybe (fromJust, catMaybes)
import Data.Foldable (maximumBy)

import Control.Monad (forM_, when)
import Control.Monad.ST (ST)

type StrL = (String, Int)
cons x (xs, n) = (x:xs, n+1)

cmp (s1,l1) (s2,l2)
  | l1 < l2 = LT
  | l1 > l2 = GT
  | otherwise = compare s1 s2

match = listArray ('1', '9') [2,5,5,4,5,6,3,7,6]

mm :: [Char] -> Int -> (forall s. ST s (STArray s Int (Maybe StrL)))
mm as n = do
    arr <- newArray (0,n) Nothing
    writeArray arr 0 (Just ("", 0))
    forM_ [2..n] $ \i -> nth arr i >>= writeArray arr i
    return arr
  where
    nth arr i = do
      cands <- fmap catMaybes . sequence $
                [fmap (cons a)<$>readArray arr (i-m)|a<-as, let m=match!a, i-m>=0]
      case cands of
        [] -> return Nothing
        xs -> return $ Just $ maximumBy cmp xs

main :: IO ()
main = do
  n <- read . head . words <$> getLine
  as <- map head . words <$> getLine
  let result = runSTArray $ mm as n
  putStrLn . fst . fromJust $ result!n


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

int main() {

        string s;
        int k,n;
        cin >> k;
        cin >> s;

        n = s.size();

        if (n <= k) {
                cout << s << endl;
        }
        else {
                std::string ans = s;
                std::string substr = ans.substr(0, k);
                cout << substr + "..." << endl;
        }



}

Measured memory_bytes: 3640
#include<iostream>
#include<numeric>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<climits>
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define mkp make_pair
#define pll pair<ll,ll>
#define rep(i,from,to) for(int i=from;i<to;i++)
#define repd(i,from,till) for(int i=from;i>=till;i--)
#define waste ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inf 1e9+1
#define mod 1e9+7
#define inf1 1e18+1
#define pie 3.14159265358979323846
#define N 100005
using namespace std;
/*
ll bin(ll i,ll j){
	ll mid=(i+j)/2;
	if(a[mid]==x)reutrn mid;
	else if(ans>x)return bin(i,mid-1);
	else return bin(mid+1,j);
}/*
ll power(ll base,ll power){
    ll res=1;
    base=base%mod;
    while(power>0){
    	if(power&1){
    		res=(res*base)%mod;
		}
		power=power>>1;
		base=(base*base)%mod;
	}
	return res;
}
*/
/*
int nCr(int x, int y){
	if(y>x)return 0;
	int num=fact[x];
	num*=invfact[y];
	num%=mod;
	num*=invfact[x-y];
	num%=mod;
	return num;
}
*/
/*bool prime[n+1];
void SieveOfEratosthenes(int n){
	rep(i,0,n+1)prime[i]=true
    for (int p=2;p*p<=n;p++)
        if (prime[p])
            for (int i=p*p;i<=n;i+=p)prime[i]=false;
}*/
/*
int gcd(int a,int b){
	if(b==0)return a;
	else return gcd(b,a%b);
}
*/
int solve(){
    int n;
    cin>>n;
	if(n==1)return cout<<"Hello World"<<endl,0;
	else {
		int a,b;
		cin>>a>>b;
		cout<<a+b<<endl;
	}
	return 0;
}
int main(){
    waste;
    int t;
    //cin>>t;
    t=1;
    while(t--){
       	solve();
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        if(n % ((2 * d)+ 1) == 0){
            System.out.println(n / ((2 * d)+ 1));
        } else {
            System.out.println(n / ((2 * d)+ 1) + 1);
        }
        
    }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
#define F(i,s,e) for(int i=s;i<e;++i)
const int MOD=1e9+7;

int main()
{
    long n;
    cin >> n;
    long a[n]={};
    int cnt[60]={};
    F(i,0,n) cin >> a[i];
    long sum=0;
    F(i,0,n){
        int j=0;
        while(a[i]>0){
            if(a[i]%2==1) cnt[j]++;
            a[i]/=2;
            j++;
        }
    }
    int j=1;
    F(i,0,60){
        sum=(sum+cnt[i]*(n-cnt[i])%MOD*j%MOD)%MOD;
        j=j*2%MOD;
    }
    cout << sum << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

int main() {
  int N; cin >> N;
  string S; cin >> S;
  int Q; cin >> Q;

  set<int> pos[26];
  rep(i,N) pos[S[i]-'a'].insert(i);
  rep(q,Q) {
    int n; cin >> n;
    if (n==1) {
      int i; cin >> i; i--;
      char c; cin >> c;
      pos[S[i]-'a'].erase(i);
      pos[c-'a'].insert(i);
      S[i] = c;
    }
    else if (n==2) {
      int l, r; cin >> l >> r; l--; r--;
      int result = 0;
      rep(i,26) {
        auto lp = pos[i].lower_bound(l), rp = pos[i].lower_bound(r+1);
        if (lp!=rp) result++;
      }
      cout << result << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 24196
#include <iostream>
#include<bits/stdc++.h>
#include<map>
#include<vector>

using namespace std;

int main() {
	// your code goes here
       int arr[5];
       int ans;
       for(int i=0;i<5;i++)
       {
           cin>>arr[i];
           if(arr[i]==0)
           {
               ans=i+1;
           }
       }
	    cout<<ans<<endl;
	    
	    
	
	
}

Measured memory_bytes: 3592
void main() {
  import std.stdio, std.string, std.conv, std.algorithm;

  auto s = readln.chomp.to!(char[]);
  auto t = readln.chomp.to!(char[]);

  int[char] f1, f2;
  foreach (c; s) {
    if (c in f1)
      f1[c]++;
    else
      f1[c] = 1;
  }
  foreach (c; t) {
    if (c in f2)
      f2[c]++;
    else
      f2[c] = 1;
  }
  int[] a, b;
  foreach (cnt; f1)
    a ~= cnt;
  foreach (cnt; f2)
    b ~= cnt;

  if (a.length != b.length) {
    writeln("No");
    return;
  }
  sort(a);
  sort(b);
  bool ok = true;
  foreach (i; 0 .. a.length) {
    ok &= a[i] == b[i];
  }
  writeln(ok ? "Yes" : "No");
}

void rd(T...)(ref T x) {
  import std.stdio, std.string, std.conv;

  auto l = readln.split;
  assert(l.length == x.length);
  foreach (i, ref e; x)
    e = l[i].to!(typeof(e));
}


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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

template<typename T>
constexpr T inf = static_cast<T>(pow(10, static_cast<int>(log10(numeric_limits<T>::max())))) + 7;
constexpr llong mod = 1e9+7;

int main() {
  llong A, B;
  cin >> A >> B;

  for (llong i = 0; i < 1e7; ++ i) {
    if ((llong)(i * 0.08) == A && (llong)(i * 0.1) == B) {
      cout << i << endl;
      return 0;
    }
  }

  cout << -1 << endl;

  return 0;
}

Measured memory_bytes: 256
import scala.io.Source.stdin

object Main {

  def getFigure(a:Array[Array[Int]]):String = {
    def f(i:Int,j:Int) = if(i>=0 && j>=0 && i<8 && j<8) a(i)(j) else 0
    def loop(i:Int,j:Int):String = {
      (i,j) match {
        case (7,7) => "NG"
        case (i,j) =>
          if(a(i)(j) == 1) {
            (f(i,j+1),f(i,j+2),f(i+1,j),f(i+2,j),f(i+1,j+1),f(i+1,j-1)) match {
              case (1,0,1,0,1,0) => "A"
              case (0,0,1,1,0,0) => "B"
              case (1,1,0,0,0,0) => "C"
              case (0,0,1,0,0,1) => "D"
              case (1,0,0,0,1,0) => "E"
              case (0,0,1,0,1,0) => "F"
              case (1,0,1,0,0,1) => "G"
              case (_,_,_,_,_,_) => "NG"
            }
          } else { if(j==7) loop(i+1,0) else loop(i,j+1) }
      }
    }
    loop(0,0)
  }

  def main(args:Array[String]) = {
    stdin.getLines.filter(_!="").sliding(8,8).foreach { s =>
      println { getFigure({for(i <- s) yield i.toArray.map(_.asDigit)}.toArray) }
    }
  }
}

Measured memory_bytes: 44012
import java.util.Scanner;
public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(a < b) System.out.println("a < b");
		else if(a > b) System.out.println("a > b");
		else System.out.println("a == b");
	}
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new Main().run();
	}

}



Measured memory_bytes: 26200
#include <bits/stdc++.h>
using namespace std;
  
#define fo(i, n) for (long long i = 0; i < n; i++)
#define sc(x) cin >> x
#define pr(x) cout << x << endl;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define br cout << endl
typedef long long int lli;
typedef pair<int, int> pii;
typedef pair<lli, lli> pll;
typedef vector<int> vi;
typedef vector<lli> vlli;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
lli max(lli a, lli b){ return (a>b)?a:b; }
lli min(lli a, lli b){ return (a<b)?a:b; }

lli gcd(lli a, lli b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

int main()
{
    // Fast Input/Output
    ios_base::sync_with_stdio(0);
    cin.tie(0);

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

    while (t--) {
        lli n, k; sc(n); sc(k);
        vlli h(n);
        fo(i, n)
        {
            sc(h[i]);
        }
        vlli dp(n);
        dp[0] = 0;
        dp[1] = abs(h[1]-h[0]);
        for(int i=2; i<n; i++)
        {
            dp[i] = 1e9;
            for(int j = max(0, i-k); j<i; j++)
            {
                dp[i] = min(dp[i], dp[j]+abs(h[i]-h[j]));
            }
        }
        pr(dp[n-1]);
    }
    return 0;
}







Measured memory_bytes: 4776
#include<cstdio>

using namespace std;

int main(){
	int n; scanf("%d", &n);
	while(1){
		if(n / 100 == (n / 10) % 10 && (n / 10) % 10 == n % 10) break;
		n++;
	}
	printf("%d\n", n);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main()
{
	int n;
	int i, j, k, t;
	int cnt=0;
	//cin >> n;
	while (cin >> n)
	{
		cnt = 0;
		for (i = 0; i <= 9; i++)
		{
			for (j = 0; j <= 9; j++)
			{
				for (k = 0; k <= 9; k++)
				{
					for (t = 0; t <= 9; t++)
					{
						if (i + j + k + t == n)
						{
							cnt++;
						}
					}
				}
			}
		}
		cout << cnt << endl;
		//cin >> n;
	}
	return 0;
}

Measured memory_bytes: 3064
def dfs(i):
    global nodes, flags
    if flags[i]:
        return
    flags[i]=True
    for n in nodes[i]:
        dfs(n)
    
    
    


line=input().split()
n=int(line[0])
m=int(line[1])

edges=[] #[a,b] for every edge
nodes=[[] for i in range (n)] #list of all neighbours for all nodes
flags=[False for i in range(n)]
for i in range(m):
    line=input().split()
    a=int(line[0])-1
    b=int(line[1])-1
    edges.append([a,b])
    nodes[a].append(b)
    nodes[b].append(a)
count=0
for i in range(m):
    a=edges[i][0]
    b=edges[i][1]
    nodes[a].remove(b)
    nodes[b].remove(a)
    dfs(0)
    bridge=False
    for j in range(n):
        if flags[j]==False:
            bridge = True
        flags[j]=False
    if bridge:
        count+=1
    nodes[a].append(b)
    nodes[b].append(a)
print(count)


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

using namespace std;

#define debug(args...) fprintf(stderr, args)

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

#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()

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

const int MAXN = 2e3 + 10;

int N, A[MAXN];

bitset<MAXN * MAXN> dp;

int solve() {
	int sum = 0;

	FOR(i, 1, N) sum += A[i];

	dp.set(0);
	FOR(i, 1, N)
		dp |= dp << A[i];

	FOR(i, (sum + 1) / 2, MAXN * MAXN - 1)
		if(dp[i])
			return i;
}

int main() {
	scanf("%d", &N);

	FOR(i, 1, N) scanf("%d", &A[i]);

	printf("%d\n", solve());
	return 0;
}


Measured memory_bytes: 1792
package main
 
import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
  "sort"
)
 
var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  var line, buffer []byte
  var isPrefix bool = true
  var err error
  for isPrefix {
    line, isPrefix, err = reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
  }
  return string(buffer)
}
func NextInt() int {
  var n int
  n, _ = strconv.Atoi(NextLine())
  return n
}
func NextIntVec() []int {
  L := strings.Split(NextLine(), " ")
  N := make([]int, len(L))
  for i := range N {
    N[i], _ = strconv.Atoi(L[i])
  }
  return N
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func Output() {
  _ = writer.Flush()
}

func main() {
  N := NextInt()
  A := NextIntVec()
  S := make([]int, N)
  sort.Ints(A)
  S[0] = A[0]
  B := 0
  for i := 1; i < N; i++ {
    S[i] = S[i - 1] + A[i]
    if 2 * S[i - 1] < A[i] { B = i }
  }
  Write(N - B)
  Output()
}

Measured memory_bytes: 6656
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include<numeric>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
//scanf("%d", &a); '\n';

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	ll sum_a = 0;
	int max_b = -MOD;
	cin >> n;
	vector<pair<int, int>> w(n),y(n);
	rep(i, n) {
		int a, b;
		cin >> a >> b;
		if(a>b) { cout << "No"; return 0; }
		max_b = max(max_b, b);
		sum_a += a;
		w[i] = make_pair(a, b);
		y[i] = make_pair(b, a);
	}
	if (sum_a > max_b) { cout << "No"; return 0; }
	sort(y.begin(), y.end());
	ll sum = 0;
	rep(i, n) {
		sum += y[i].second;
		if(sum>y[i].first) { cout << "No"; return 0; }
	}
	cout << "Yes";
}



Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;
int n,t,l,x[N],w[N],ans[N],q[N];
typedef pair<int,int> pii;
pii p[N];
bool cmp(int a,int b){return p[a]<p[b];}
int main()
{
	scanf("%d%d%d",&n,&l,&t);
	for (int i=1;i<=n;i++){
		scanf("%d%d",&x[i],&w[i]);
		if (w[i]==2) w[i]=-1;
		p[i]=pii((l+(x[i]+w[i]*t)%l)%l,w[i]);
		q[i]=i;
	}
	sort(q+1,q+n+1,cmp);
	for (int i=1;i<=n;i++) q[i+n]=q[i];
	int cnt=0;
	for (int i=1;i<=n;i++)
	if (w[i]!=w[1]){
		int len=2*t,dis=(w[1]*(x[i]-x[1])+l)%l;
		if (len>=dis) len-=dis,cnt++;
		cnt+=len/l;
	}
	int id=(n+(1+w[1]*cnt)%n)%n,pos;
	if (id==0) id=n;
	for (int i=1;i<=n;i++) if (q[i]==1) pos=i;
	for (int i=0;i<n;i++) ans[id]=p[q[pos+i]].first,id=(id==n?1:id+1);
	for (int i=1;i<=n;i++) printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 4736
def dfs(num,s):
    cnt = 0
    s.add(num)
    if(len(s)==N):
        s.discard(num)
        return 1
    for x in li[num]:
        if(x not in s):
            cnt += dfs(x,s)
    s.discard(num)
    return cnt
#%%
N,M = [int(x) for x in input().split()]
li = [[]for _ in range(N+1)]
for _ in range(M):
    a,b = [int(x) for x in input().split()]
    li[a].append(b)
    li[b].append(a)
#%%
sets = set()
ans = dfs(1,sets)
print(ans)


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

#define ll long long int
#define ld long double
#define u128 __int128 
#define ff first
#define ss second
#define pb push_back
#define PI 3.141592653589793

#define MOD 1000000007
#define N 100100
#define M 1000010

int n, m;
int a[N];

int main() 
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(10);
	
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}

	int f = 1;
	int max = a[0];
	for(int i = 1; i < n; ++i)
	{
		if(a[i] > max)
			max = a[i];
		if(a[i] < max && max - a[i] > 1)
		{
			f = 0;
			break;
		}
	}
	if(f)
		cout << "Yes\n";
	else
		cout << "No\n";
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct CBTData *CBT;

#define parent(x) ((x-1)/2)
#define left(x)   (2*(x)+1)
#define right(x)  (2*(x)+2)

struct CBTData
{
    int *array;
    int size;
    int last;
};

CBT CBTnew(int size);
void CBTinsert(CBT heap, int item);
void CBTprint(CBT heap);
void CBTFree(CBT heap);

CBT
CBTnew(int size)
{
    CBT newHeap = (CBT)malloc(sizeof(struct CBTData));
    newHeap->array = (int*)malloc(sizeof(int) * size);
    newHeap->size = size;
    newHeap->last = -1;
    return newHeap;
}

void
CBTinsert(CBT heap, int item)
{
    if (heap->last == heap->size - 1)
    {
	int *newArray = malloc(sizeof(int) * heap->size * 2);
	int i;
	for (i=0; i<heap->size; i++)
	    newArray[i] = heap->array[i];
	free(heap->array);
	newArray[++heap->last] = item;
	heap->array = newArray;
	heap->size *= 2;
    }
    else
	heap->array[++heap->last] = item;
}

void
CBTprint(CBT heap)
{
    int i;
    for (i=0; i <= heap->last; i++)
    {
	int parent = parent(i),
	    left = left(i),
	    right = right(i);
	char message[256] = {}, buf[256] = {};
	sprintf(message, "node %d: key = %d, ", i+1, heap->array[i]);
	if (i != 0)
	{
	    sprintf(buf, "parent key = %d, ", heap->array[parent]);
	    strcat(message, buf);
	}
	if (left <= heap->last)
	{
	    sprintf(buf, "left key = %d, ", heap->array[left]);
	    strcat(message, buf);
	}
	if (right <= heap->last)
	{
	    sprintf(buf, "right key = %d, ", heap->array[right]);
	    strcat(message, buf);
	}
	printf("%s\n", message);
    }
}

void
CBTFree(CBT heap)
{
    free(heap->array);
    free(heap);
}

int
main(void)
{
    int i, heapSize, key;
    CBT heap = CBTnew(100);
    scanf("%d\n", &heapSize);
    for (i=0; i<heapSize; i++)
    {
	scanf("%d", &key);
	CBTinsert(heap, key);
    }
    CBTprint(heap);
    CBTFree(heap);
    return 0;
}

Measured memory_bytes: 624
#include <cstdio>
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>

#define int long long
#define rr register

#define inf 1e9
#define MAXN 2000010

using namespace std;

inline int read() {
	int s = 0, f = 0;
	char ch = getchar();
	while (!isdigit(ch)) f |= ch == '-', ch = getchar();
	while (isdigit(ch)) s = s * 10 + (ch ^ 48), ch = getchar();
	return f ? -s : s;
}

void print(int x) {
	if (x < 0) putchar('-'), x = -x;
	if (x > 9) print(x / 10);
	putchar(x % 10 + 48);
}

int k;

int ans;

int a[MAXN];

signed main() {
	k = read();
	for (rr int i = 1; i <= k; i++) {
		a[i] = a[i - 1] * 10 + 7;
		a[i] %= k;
		// cout << i << "\n";
		if (a[i] == 0) {
			cout << i;
			return 0;
		}
	}
	cout << -1;
}

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

int main()
{
    LL n,i,j,k,t,temp;
    cin>>k>>n;
    LL maxima=-1;
    LL first,last;
    LL prev;
    cin>>first;
    prev=first;
    for(i=1;i<n;i++)
    {
        cin>>last;
        maxima=max(maxima,last-prev);
        prev=last;
    }
    maxima=max(maxima,k-last+first);
    cout<<k-maxima<<endl;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;

int gcd(int a,int b) {//最大公約数の算出
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
}

int main(void) {
	int n;
	string s;
	cin >> n;
	cin >> s;
	ll p = 0;
	ll a = 0, b = 0, c = 0;

	for (int i = 0; i < n; i++) {
		if (s[i] == 'R') {
			a++;
		}
		else if (s[i] == 'G') {
			b++;
		}
		else if (s[i] == 'B') {
			c++;
		}
	}
	p = a * b*c;

	for (int i = 0; i < n - 2; i++) {
		for (int j = i + 1; j < n - 1; j++) {
			if ((2 * j - i) < n) {
				int k = 2 * j - i;
				if (s[i] != s[j] && s[j] != s[k] && s[k] != s[i]) {
					p--;
				}
			}


		}
	}

	cout << p;
	return 0;
}

Measured memory_bytes: 3564
#include<stdio.h>

int main(){
	int N, A;
	scanf("%d", &N);
	scanf("%d", &A);

	int i, j, k;
	int s = 0;
	for (i = 0; i <= 200; i++){
		k = i * 500;
		for (j = 0; j <= A; j++){
			if (k == N){
				s = 1;
			}
			k++;
		}
	}
	if (s == 1){
		printf("Yes");
	}
	else{
		printf("No");
	}

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()
{
int a,b,c,d,ans;
cin >> a >> b >> c;
d=a-b;
if(c-d>0)
  {
    ans=c-a+b;
  }
  else{
        ans=0;
      }
  cout << ans <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s;
	string sq,sh;
	int q;
	cin>>s>>q;
	bool rev=0;
	for(int i=0;i<q;i++)
	{
		
		int t;cin>>t;
		if(t==1) rev^=1;	 
		if(t==2)
		{
			int f;
			char c;
			cin>>f>>c;
			if((f==1)^rev) sq=sq+c;
			else sh=sh+c;
		}
		//cout<<sq<<" "<<s<<" "<<sh<<endl;
	}
	reverse(sq.begin(),sq.end());
	s=sq+s+sh;
	if(rev) reverse(s.begin(),s.end());
	cout<<s;
	return 0;
}

Measured memory_bytes: 1452
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
int ans=0,total[100005]={},n,totlebih=0;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		int input;
		scanf("%d",&input);
		total[input]++;
	}
	for(int i=1;i<=100000;i++)
	{
		if(total[i]==0)
			continue;
		total[i]%=2;
		if(total[i]==1)
			ans++;
		else
			totlebih++;
	}
	ans+=(totlebih/2)*2;
	cout<<ans<<endl;
}

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

using namespace std;

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

using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vs = vector<string>;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

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

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

	const int n = 10;

	int h, w;
	cin >> h >> w;

	vvi c(n, vi(n));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> c[i][j];
		}
	}

	for (int k = 0; k < n; k++) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (c[i][j] > c[i][k] + c[k][j]) {
					c[i][j] = c[i][k] + c[k][j];
				}
			}
		}
	}

	int res = 0;
	for (int i = 0; i < h * w; i++) {
		int a;
		cin >> a;

		if (a == -1) {
			continue;
		}
		res += c[a][1];
	}

	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

const int N = 3e5 + 7;

vector<int> g[N];

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

	int n;
	cin >> n;
	for (int i = 1; i < n; i++) {
		int p;
		cin >> p;
		p--;
		g[p].push_back(i);
	}
	for (int i = 0; i < n; i++) {
		cout << g[i].size() << ' ';
	}
	cout << '\n';
}


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

int main(){
    int n;
    cin >> n;
    vector<int> isuse(n+1, false);
    int sum = 0;
    for(int i = 1; i <= n; i++){
        if(sum == n) break;
        else{
            sum += i;
            isuse[i] = true;
            if(sum > n){
                isuse[sum-n] = false;
                sum = n;
            }
        }
    }

    for(int i = 1; i <= n; i++){
        if(isuse[i]) cout << i << endl;
    }
    return 0;
}

Measured memory_bytes: 42308
import java.io.*;

public class Main {
    public static void main(String... args) throws IOException {
        final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        final StringBuilder sb = new StringBuilder();
        while (true) {
            final String line = br.readLine();
            final int index = line.indexOf(" ");
            final int x = Integer.parseInt(line.substring(0, index));
            final int y = Integer.parseInt(line.substring(index+1, line.length()));
            if (x == 0 && y == 0) break;
            sb.append(x < y ? x + " " + y : y + " " + x).append("\n");
        }
        System.out.print(sb);
    }
}

Measured memory_bytes: 26020
#include <iostream>

int n, a[101], b[101], sum1, sum2;

int main()
{
  int i, j, ans = 0;
  std::cin >> n;
  for(i=0; i<n; i++) std::cin >> a[i];
  for(i=0; i<n; i++) std::cin >> b[i];

  for(i=0; i<n; i++)
  { sum2 = 0;
    sum1 += a[i];
      for(j=i; j<n; j++)
      sum2 += b[j];
    ans = std::max(ans, sum1+sum2);
  }

  std::cout << ans << '\n';
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int N, K, max;
    cin >> N >> K;
    max = (N  - 1) / 2 + 1;
    if (max >= K){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256