akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Out.Flush();
            Read();
        }
        static void Solve()
        {
            var N = Sarray()[0];
            var A = Sarray();
            var hs = new HashSet<long>();
            var duplNo = -1L;
            for (var i = 0; i < N + 1; ++i)
            {
                if (hs.Contains(A[i]))
                {
                    duplNo = A[i];
                    break;
                }
                hs.Add(A[i]);
            }
            var duplpos = new long[2];
            var cnt = 0;
            for (var i = 0; i < N + 1; ++i)
            {
                if (A[i] == duplNo)
                    duplpos[cnt++] = i + 1;
            }
            //順列
            var cmb = new Combination((int)N + 1);
            var s1 = duplpos[0] - 1;
            var s2 = N + 1 - duplpos[1];
            for (var i = 1; i <= N + 1; ++i)
            {
                var t = cmb.nCk((int)N + 1, i) - cmb.nCk((int)(s1 + s2), i - 1) + Mod;
                WriteLine(t % Mod);
            }
        }
        public class Combination
        {
            readonly long mod;
            readonly long[] fac, finv, inv;
            public Combination(long n, long mod = 1000000007)
            {
                long max = n + 1;
                this.mod = mod;
                fac = new long[max];
                finv = new long[max];
                inv = new long[max];
                fac[0] = fac[1] = 1;
                finv[0] = finv[1] = 1;
                inv[1] = 1;
                for (int i = 2; i < max; ++i)
                {
                    fac[i] = fac[i - 1] * i % mod;
                    inv[i] = mod - inv[mod % i] * (mod / i) % mod;
                    finv[i] = finv[i - 1] * inv[i] % mod;
                }
            }
            public long nCk(int n, int k)
            {
                if (n < k) return 0;
                if (n < 0 | k < 0) return 0;
                return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
            }
        }
    }
}

Measured memory_bytes: 41920
// template
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<long long, long long> LP;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define REP_AB(i, a, b) for (ll i = ll(a); i <= ll(b); ++i)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end());
#define SIZE(x) ((ll)(x).size())
#define REVERSE(v) reverse(ALL(v))
// true / false
#define BIN_SEARCH(v, a) binary_search(ALL(v), a)
// index
#define BIN_LEFT(v, a) (lower_bound(ALL(v), a) - v.begin())
#define BIN_RIGHT(v, a) (upper_bound(ALL(v), a) - v.begin())
#define BIN_INSERT(v, a) (v.insert(v.begin() + BIN_LEFT(v, a), a))
#define DEL(v, i) v.erase(v.begin() + i)
#define INSERT(v, i, a) v.insert(v.begin() + i, a)
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;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define out cout
#define in cin
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
// template end

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, t;
    in >> n >> t;
    ll cur_t, pre_t = 0, ans = 0;
    REP(i, n){
        in >> cur_t;
        if (cur_t - pre_t > t){
            ans += t;
        }else{
            ans += cur_t - pre_t;
        }
        pre_t = cur_t;
    }


    out << ans + t << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ft first
#define sd second
#define pb push_back
#define sort(x) sort((x).begin(), (x).end())
using ll = long long;
const int INF = 1e9+7;
const int EPS = -1e6;
inline void fastio() {ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);}
const int maxn = 100000+5;



int main(){
    //freopen("input.txt", "r", stdin);
    fastio();

    int a, b, k;
    cin>>a>>b>>k;

    vector<int> vec;
    int ag = __gcd(a, b);
    for(int i = 1; i * i <= ag; ++i)
        if(ag % i == 0){
            vec.pb(i);
            if(i != ag/i)
                vec.pb(ag / i);
        }

    sort(vec);
    size_t idx = vec.size()-k;
    cout<<vec[idx]<<endl;


    return 0;
}


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

using namespace std;
#define ll long long
ll mod = 1000000007 ;

int main()
{
 ll ans = 1 , n;
 cin >> n;

 for(ll i=1; i<=n; i++)
 {
     ans = ((ans%mod)*(i%mod))%mod;
 }


 cout << ans << endl;
}


Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    string S;   cin >> S;
    string T;   cin >> T;

    vector<char> sv;
    vector<char> tv;

    for (auto c: S) sv.push_back(c);
    for (auto c: T) tv.push_back(c);
    
    sort(sv.begin(), sv.end());
    sort(tv.begin(), tv.end(), greater<char>());

    string _S = "";
    string _T = "";

    for (auto c: sv) _S += c;
    for (auto c: tv) _T += c;

    if (_S < _T)    cout << "Yes" << endl;
    else            cout << "No" << endl;


    return 0;
}

Measured memory_bytes: 256
def calc_times_divided_by_two(num):
  """
  Args:
    num (int)
  >>> calc_times__divided_by_two(8)
  3
  >>> calc_times__divided_by_two(7)
  0
  """
  cnt = 0
  while num % 2 == 0:
     num //= 2
     cnt += 1
  return cnt


n = int(input())
L = list(map(int, input().split()))
print(min(map(calc_times_divided_by_two, L)))


Measured memory_bytes: 38512
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
inline int getInt() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;



int main() {
  int n,d;
  scanf("%d%d",&n,&d);
  vi a(n);
  cin>>a;
  vi x(n+1);
  x[0] = d;
  rep(i,n) x[i+1] = min(x[i], abs(x[i]-a[i]));
  vi r(n+1);
  drep(i,n) {
    r[i] = r[i+1];
    if (a[i]-r[i] > r[i]+1) continue;
    r[i] += a[i];
    mins(r[i],d);
  }
  int q;
  scanf("%d",&q);
  rep(qi,q) {
    int i;
    scanf("%d",&i);
    --i;
    if (x[i] > r[i+1]) yn;
  }
  return 0;
}






















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

int main()
{
    int n;
    string s;
    cin >> n >> s;
    if (n % 2 == 1) cout << "No" << endl;
    else {
        string s1, s2;
        s1 = s.substr(0, s.size()/2);
        s2 = s.substr(s.size()/2);
        if (s1 == s2) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
   int a,b,i,s=0;

   scanf("%d%d",&a,&b);

   for(i=a;i<=b;i++)
      if((i%10==i/10000%10)&&(i/10%10==i/1000%10)) s++;

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

   return 0;
}



Measured memory_bytes: 128
object Main extends App {

  import scala.io.StdIn._
  import scala.math._
  val n = readLine.trim
  println(search(n))
  def search(number: String): Int = {
    def toPalindrone(number: String, digit: Int): Int = {
      (number + number.reverse.takeRight(digit - number.length)).toInt
    }
    List(toPalindrone(number.dropRight(number.length / 2), number.length),
      toPalindrone((number.dropRight(number.length / 2).toInt + 1).toString,number.length),
      toPalindrone((number.dropRight(number.length / 2).toInt - 1).toString, number.length)).sorted.minBy(i ⇒ math.abs(i - number.toInt))
  }
  implicit class Extension[T](val value :T){
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
    def let[R](func: T ⇒ R): R = func(value)
  }
}


Measured memory_bytes: 44000
#include <bits/stdc++.h>
using namespace std;
 
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;i<n;i++)
#define ll long long
 
#define pi pair < ll , ll >
#define pb push_back
#define mp make_pair
#define F first
#define S second
 
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
 
#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
using namespace std;

int main()
{
    fastIO;
    ll n, i, j, k, a[2001], ans=0;
    cin>>n;fo(i,n)cin>>a[i];sort(a,a+n);
    fo(i,n) {
        Fo(j,i+2,n) {
            ll idx = upper_bound(a,a+n,a[j]-a[i]) - a;
            if(idx>=j)continue;
            idx = max(idx, i+1ll);
            ans += j-idx;
        }
    }
    cout<<ans;
}   


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define nl cout<<"\n"
#define dbg(x) cout<<x<<" ";
#define fi(a,b) for(int i=a;i<b;i++)
#define fj(a,b) for(int j=a;j<b;j++)
#define UM unordered_map<int,int>
#define ULL unordered_map<ll,int>
void fun(){
    int n,m,x,y;    cin>>n>>m>>x>>y;
    int mn=INT_MAX,mx=INT_MIN;
    fi(0,n){
        int k;  cin>>k;
        mx=max(k,mx);
    }
    fi(0,n){
        int k;  cin>>k;
        mn=min(k,mn);
    }
    if(mn>x&&mn<=y&&mx<mn)
        cout<<"No War\n";
    else
        cout<<"War\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
   fun();
}

Measured memory_bytes: 256
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

#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>
#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

 size_t strlen(const char *s);
#define rep(i,n) for(long long int i=0;i<n;i++)
#define sz(x) ((int)(x).size())

using namespace std;
std::vector<int> graph[10050];//graph頂点数のsize
const int N=200010;
const int P=1000000007;
using ll = long long;
vector<ll> prime;

//絶対値
int ze(int a, int b){
	if(a>b){
		return a-b;
	}else{
		return b-a;
	}
}
//小さい方
long long int min(long long int a,long long int b){
	if(a>b){
		return b;
	}else{
		return a;
	}
}
//大きい方
long long int max(long long int a,long long int b){
	if(a>b){
		return a;
	}else{
		return b;
	}
}
// a^n mod 
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod 
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

//mod掛け算
long long mt(long long a, long long b, long long mod){
	return (a*b)%mod;
}

//メモ

/*
	memset(b, '\0', sizeof(b));
初期化*/


/*
	string s;
	s.size()
*/

/*
	char s[N];
	strlen(s)
*/
/*
	if(  <  )puts("Yes");
	else puts("No");
*/

/*文字列比較
if(strcmp(name[i],s)==0)
*/

/*
	graph[a].push_back(b);//graph[a][i番目に入れた]==b
	graph[j].size()	//forで回すときとか

*/


int main(){
	long double a, b, h, m;
    long double pi = 3.141592653589793;
	cin>>a>>b>>h>>m;
    long double ans=pow( a*a+b*b-2*a*b*cos(m*pi/30-(h*60+m)*pi/360)      ,0.5);
 //   printf("%.15lf\n",ans);
  cout << fixed << setprecision(15) <<ans<<endl;
/////      3
}


Measured memory_bytes: 4408
#include<iostream>
#include<climits>
#include<string>
#include<vector>
#include<list>
#include<math.h>
using namespace std;

const long long cPrimeNumber = 1000000007; 

int main()
{
    // get a integer
    int M,N;
    cin >> M >> N;

    long long m = 1; 
    long long n = 1; 
    for (auto&& i = 1; i <= M; ++i ) {
        m = ( m * i ) % cPrimeNumber;
    }
    for (auto&& i = 1; i <= N; ++i ) {
        n = ( n * i ) % cPrimeNumber;
    }

    if( M == N )
        cout << 2 * ( m * n % cPrimeNumber ) % cPrimeNumber << endl;
    else if( abs( M - N ) == 1 )
        cout << m * n % cPrimeNumber << endl;
    else
        cout << 0 << endl;
}



Measured memory_bytes: 256
#pragma GCC optimize("O3", "unroll-loops")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

int n, m;
vector<vector<int>> g;
vector<int> color;
bool bi = true;

void dfs(int s) {
	static vector<bool> visited(n, false);
	visited[s] = true;
	for (auto nx : g[s]) {
		if (color[s] == color[nx]) bi = false;
		else color[nx] = color[s] == 1 ? 0 : 1;
		if (!visited[nx]) dfs(nx);
	}
}

signed main() {
	cin >> n >> m;
	g.resize(n); color.resize(n, -1);
	color[0] = 1;
	for (int i = 0; i < m; ++i) {
		int a, b; cin >> a >> b;
		--a; --b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	dfs(0);
	if (bi) { // 二分グラフ
		int cnt_1 = 0;
		for (auto ci : color)
			if (ci)
				++cnt_1;
		ll mx = (ll)cnt_1 * ((ll)n - (ll)cnt_1);
		cout << (mx - m) << endl;
	}
	else {
		cout << ((ll)n * ((ll)n - 1) / 2 - m) << endl;
	}
	return 0;
}

Measured memory_bytes: 6656
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = a; i < (b); ++i)
#define rrep(i,a,b) for(int i = b; i --> (a);)
#define all(v) v.begin(),v.end()
#define trav(x,v) for(auto &x : v)
#define sz(v) (int)(v).size()
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

bool ask(ll x){
	cout << "? " << x << endl;
	char ans;
	cin >> ans;
	return ans == 'Y';
}

void solve(){
	ll lo = 1e11, hi = 1e12;
	while(lo+1 < hi){
		ll mi = (lo + hi)/2;
		if(ask(mi) == false){
			lo = mi;
		} else {
			hi = mi;
		}
	}
	if(lo%10 == 0){
		hi = lo;
	}
	while(hi%10 == 0) hi/=10;
	if(hi%10 == 9){
		while(hi < 1e11) hi = hi*10;
		while(true){
			if(ask(hi-1)){
				cout << "! " << hi << endl;
				return;
			}
			hi /= 10;
		}
		return;
	}
	while(true){
		if(ask(hi+1)){
			cout << "! " << hi << endl;
			return;
		}
		hi *= 10;
	}
}

int main(){
	solve();
}

Measured memory_bytes: 596
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
string s;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> s;
    int counta = 0;
    int countb = 0;
    char c = s[0];
    char d;
    if (s[0] == s[1] && s[2] == s[3] && s[1] == s[2])
    {
        no;
        return 0;
    }
    if (c == s[1])
    {
        if (s[2] == s[3])
        {
            yes;
            return 0;
        }
        else
        {
            no;
            return 0;
        }
    }
    else
    {
        d = s[1];
        if (c == s[2] && d == s[3])
        {
            yes;
            return 0;
        }
        if (c == s[3] && d == s[2])
        {
            yes;
            return 0;
        }
    }
    no;
}

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

ll kai[(1<<18)];
ll mod = 1e9 + 7;
ll memo[(1<<18)];

void init() {
    kai[0] = 1;
    kai[1] = 1;
    for (ll i = 2; i < (1 << 18); i++) {
        kai[i] = kai[i - 1] * i % mod;
    }
}

ll mp(ll a, ll b) {
    if (b == 0) return 1LL;
    if (b == 1) return a;
    ll ret = mp(a,b/2);
    ret *= ret;
    ret %= mod;
    if (b&1) ret *= a;
    return ret % mod;
}

ll inv(ll k) {
    if (memo[k] != 0) return memo[k];
    return memo[k] = mp(k,mod-2);
}

ll c(ll n, ll k) {
    if (k == 0) return 1;
    if (n == k) return 1;
    ll ret = 1;
    for (ll i = 0; i < k; i++) {
        ret *= (n - i);
        ret %= mod;
    }
    for (ll i = 1; i <= k; i++) {
        ret *= inv(i);
        ret %= mod;
    }
    return ret;
}
int main() {
    init();
    ll n,a,b;
    cin >> n >> a >> b;
    ll ans = mp(2LL,n) - 1;
    ans = ans + mod * mod;
    ans %= mod;
    ans -= c(n,a);
    ans += mod * mod;
    ans %= mod;
    ans -= c(n,b);
    ans += mod * mod;
    ans %= mod;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3840
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

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

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

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
  string s;
  cin >> s;
  int n = s.size();

  if(s[0] == '0' || s[n-1] == '1'){
    cout << -1 << endl;
    return 0;
  }

  s = s[n-1] + s;

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

  int now = 2;
  vector<P> ans;
  ans.push_back(P(1,2));
  int v = 3;
  for(int i = 2; i <= n; i++){
    if(s[i] == '0'){
      ans.push_back(P(now,v));
      v++;
    }else{
      ans.push_back(P(now,v));
      now = v;
      v++;
    }

    if(v > n) break;
  }

  for(int i = 0; i < ans.size(); i++){
    cout << ans[i].first << " " << ans[i].second << endl;
  }


  return 0;
}

Measured memory_bytes: 2416
import java.util.Scanner;

public class Main {

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

        int a = sc.nextInt();
        String op = sc.next();
        int b = sc.nextInt();

        sc.close();

        int ans = 0;

        if (op.equals("+")) {
            ans = a + b;
        } else {
            ans = a - b;
        }

        System.out.println(ans);
    }

}

Measured memory_bytes: 21204
import numpy as np

n = int(input())
count = 0
ans = []
for i in range(2, int(np.sqrt(n+1))+1):
    if n%i ==0:
        ans.append(i)
if len(ans) == 0:
    print(n-1)
else:
    tmp = max(ans)
    print(tmp+(n//tmp)-2)

Measured memory_bytes: 12488
#include <iostream>
#include <cstdio>
#include <string.h>
using namespace std;
int main()
{
	long long a,b,c;
	long long ta,tb,tc;
	cin>>a>>b>>c;
	if(a==b&&b==c&&a%2!=1)
		cout<<"-1";
	else
	{
		int t=0;
		while(a%2!=1&&b%2!=1&&c%2!=1)
		{
			if(a==b&&b==c&&a%2!=1)
			{
				t=-1;
				break;
			}
			t++;
			ta=0;tb=0;tc=0;
			ta=b/2+c/2;
			tb=a/2+c/2;
			tc=a/2+b/2;
			a=ta;
			b=tb;
			c=tc;
		}
		cout<<t<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

int main() {
	int i, j, k,ip;
	int h_array[300], w_array[300];

	for (i = 0; i < 300; i++) {
		scanf("%d %d", &h_array[i], &w_array[i]);
		
		if (h_array[i] == 0 && w_array[i] == 0) {
			ip = i;
			break;
		}

	}
	for ( k = 0; k < ip; k++) {
		for (i = 0; i < h_array[k]; i++) {
			for (j = 0; j < w_array[k]; j++) {
				printf("#");
			}
			printf("\n");
			if (h_array[k] == 0 && w_array[k] == 0) {
				break;
			}
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2140
#include <bits/stdc++.h>
using namespace std;
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define trace(x) cerr<<x<<END;
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i) 
const int mod = 1e9+7;
const int mod1 = 998244353;
const int inf = 9223372036ll;
struct mywish{
  bool operator()(const pair<int,pii> &a, const pair<int,pii> &b)
   {
    if(a.ff == b.ff)
      {
        if(a.ss.ff == b.ss.ff)
           return a.ss.ss < b.ss.ss;
        else
           return a.ss.ff < a.ss.ff;
      }
    return a.ff < b.ff;
   }
};
int n,m,k;
vector<string> grid;
vector<vector<int>> steps;
int sx,sy,fx,fy;
int dy[] = {0,-1,0,1};
int dx[] = {-1,0,1,0};
inline bool valid(int y,int x)
 {
  return (y>=0 && y<n && x>=0 && x<m && grid[y][x] == '.');
 }
int bfs()
 {
  priority_queue<pair<int,pii>,vector<pair<int,pii>>,greater<pair<int,pii>>> q;
  q.push({0ll,{sy,sx}});
  steps[sy][sx] = 0;
  while(!q.empty())
     {
      int cy = q.top().ss.ff,cx = q.top().ss.ss;
      int c_steps = q.top().ff;
      q.pop();
      for(int i=0; i<4; i++)
         {
          int proceed = 1;
          while(proceed<=k)
             {
              int ny = cy + proceed*dy[i],nx = cx + proceed*dx[i];
              if(!valid(ny,nx) || steps[ny][nx]<c_steps+1)
                 break;
              if(steps[ny][nx] == c_steps+1)
                  {
                     proceed++;
                     continue;
                  }
              steps[ny][nx] = min(steps[ny][nx],c_steps + 1);
              q.push({steps[ny][nx],{ny,nx}});
              proceed++;
             }
         }
     }
    return steps[fy][fx];
 }

void solve()
 { 
   cin>>n>>m>>k;
   grid = vector<string> (n);
   steps = vector<vector<int>> (n,vector<int> (m,inf));
   cin>>sy>>sx>>fy>>fx;
   sy--,sx--,fy--,fx--;
   loop(i,0,n)
    cin>>grid[i];
   int ans = bfs();
   if(ans == inf)
     ans = -1;
   cout<<ans;
 }
signed main()
 {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0); 
  solve();
  return 0;
} 

Measured memory_bytes: 18728
def resolve():

    N,M = map(int,input().split())
    root = list(range(N))
    depth = [1 for _ in range(N)]
    dist = [0 for _ in range(N)]

    def find(a,root,dist):
        if root[a] == a:
            return (a,0)
        else:
            root[a],d = find(root[a],root,dist)
            dist[a] += d
            return(root[a],dist[a])

    def unite(a,b,d,root,depth,dist):
        A,dist_a = find(a,root,dist)
        B,dist_b = find(b,root,dist)
        if A == B:
            if dist_b - dist_a == d:
                return True
            else:
                return False
        else:
            if depth[A] > depth[B]:
                root[B] = A
                depth[A] += depth[B]
                dist[B] = dist_a - dist_b + d
            else:
                root[A] = B
                depth[B] += depth[A]
                dist[A] = dist_b - dist_a - d
            return True
        
    ans = True
    for _ in range(M):
        L,R,D = map(int,input().split())
        if not (unite(L-1,R-1,D,root,depth,dist)):
            ans = False
            break
    print("Yes" if ans else "No")
resolve()

Measured memory_bytes: 82336
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rREP(i,m,n) for(int (i)=(n)-1; (i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	ll N; cin >> N;
	vector<ll>vec(5);
	rep(i, 0, 5)cin >> vec[i];
	sort(all(vec));
	ll ans = 5;
	ans += (N + vec[0] - 1) / vec[0];
	--ans;
	cout << ans << "\n";

	


	return 0;
}


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

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

template <typename T>
void print(const vector<T> &v) {
    for (auto e : v) cout << e << ' ';
    cout << endl;
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

void solve() {
    long long N, D; cin >> N >> D;
    int ans = 0;
    for (int i = 0; i < N; i++) {
        long long x, y; cin >> x >> y;
        if (x*x + y*y <= D*D) ans++;
    }
    cout << ans << '\n';
}

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

    solve();

    return 0;
}

Measured memory_bytes: 3556
#include <iostream>
using namespace std;
#define REP(i, n)   for(int i = 0; i < (int)(n); i++)
#define MAX_N   10000



int main (){
    char s[5];
    cin >> s;
    if(s[0] == s[1]){
        if(s[0] != s[2] && s[2] == s[3])
            cout << "Yes" << endl;
        else
            cout << "No" << endl;   
    }
    else if(s[0] == s[2]){
        if(s[0] != s[1] && s[1] == s[3])
            cout << "Yes" << endl;
        else
            cout << "No" << endl;  
    }
    else if(s[0] == s[3]){
        if(s[0] != s[1] && s[1] == s[2])
            cout << "Yes" << endl;
        else
            cout << "No" << endl;  
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

ll pow(ll x, ll y)
{
    int tmp = 1;
    for (int i = 0; i < y; i++)
        tmp *= x;
    return tmp;
}

pair<ll, ll> f(ll x)
{
    pair<ll, ll> p;
    if (x == 0 || x == 1)
    {
        p.first = 0;
        p.second = 0;
        return p;
    }
    else
    {
        int nn = 1;
        int tmp = 2;
        while (tmp * 2 - 1 <= x)
        {
            tmp *= 2;
            nn++;
        }
        p.first = tmp - 1;
        p.second = nn;
        return p;
    }
}

// x... 2^nの値
ll g(ll x, ll y, ll n)
{
    if (y == 0)
        return 0;
    else if (y == 1)
        return 1;
    else if (y == 2)
        return 3;
    else if (y == 3)
        return 0;

    ll tmp = ((y - x) / 2) % 2;
    // cout << "first" << y << "," << tmp << endl;
    for (int i = 1; i <= n - 1; i++)
    {
        ll t1 = (y - x) / pow(2, i + 1);
        ll t2 = (y - x) - t1 * pow(2, i + 1);
        ll t3 = t2 - pow(2, i);
        if (t3 > 0)
        {
            tmp |= ((t3 % 2) << i);
        }
    }
    tmp |= (((y - x) % 2) << n);
    // cout << bitset<40>(tmp) << endl;
    return tmp;
}

signed main()
{
    int a, b;
    cin >> a >> b;
    pair<ll, ll> a_;

    if (a > 0)
        a_ = f(a - 1);
    else
        a_ = f(a);

    pair<ll, ll> b_ = f(b);

    // cout << a_.first << ",," << a_.second << endl;
    // cout << b_.first << ",," << b_.second << endl;
    ll aa;
    if (a > 0)
        aa = g(a_.first, a - 1, a_.second);
    else
        aa = g(a_.first, a, a_.second);
    ll bb = g(b_.first, b, b_.second);

    // cout << "aa = " << aa << endl;
    // cout << "bb = " << bb << endl;
    cout << (aa ^ bb) << endl;
}


Measured memory_bytes: 256
/*********************
*					 *
* Nothing Impossible *
*					 *
*********************/
#include <algorithm>
#include <iostream>
#include <fstream>
#include <ctype.h>
#include <string>
#include <vector>
#include <math.h>
#include <cmath>
#include <map>
#define GetRand(Min, Max) ((rand()%(int)(((Max) + 1)-(Min))) + (Min))
#define Rep(i, min, max) for (int i = min; i < max; ++i)
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef long double ld; 
using namespace std;

int main()
{
	string s1;
	char c;
	Rep(i,0,3)
	{
		cin >> s1;
		c = s1[0];
		putchar(toupper(s1[0]));
	}
	return 0;
}





Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<queue>
#include<map>
#include<math.h>
#include<string>
#include <cctype>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1ll<<60;

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

int main(){
    int n; cin >> n;
    rep(i, n){
        int a; cin >> a;
        if(a%2==0){
            if(a%3!=0&&a%5!=0){out("DENIED"); return 0;}
        }
    }
    out("APPROVED");
}

Measured memory_bytes: 256
# coding:utf-8

import sys

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()


n = I()

dp = [[0] * (n + 1) for _ in range(3)]
for i in range(n):
    H = LI()
    for k in range(3):
        k1, k2 = (k + 1) % 3, (k + 2) % 3
        dp[k1][i + 1] = max(dp[k1][i + 1], dp[k][i] + H[k1])
        dp[k2][i + 1] = max(dp[k2][i + 1], dp[k][i] + H[k2])

print(max([dp[k][n] for k in range(3)]))


Measured memory_bytes: 14892
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;


//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用


int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n, a;
	cin >> n >> a;
	cout << n * n - a << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>
#include <cassert>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;

ll A[5*1010];
ll B[5*1010][210];

ll nexti[5*1010][210];
ll add[5*1010];
int main(){
  int N,M;cin>>N>>M;
  repeat(i,N-1){
    cin>>A[i+1];
    A[i+1]+=A[i];
  }
  repeat(i,N){
    repeat(j,M){
      cin>>B[i][j];
    }
  }

  repeat(j,M){
    B[N][j]=INF;
    stack<pair<ll,int> > S;
    S.push({INF,N});
    nexti[N][j]=N;
    for(ll i=N-1;i>=0;i--){
      while(!S.empty()&&B[i][j]>S.top().first)S.pop();
      nexti[i][j]=S.top().second;
      S.push({B[i][j],i});
    }

    int i=0;
    while(i<N){
      add[nexti[i][j]]+=B[nexti[i][j]][j]-B[i][j];
      i = nexti[i][j];
    }
  }
  ll ans = 0;
  repeat(l,N){
    ll cur=0;
    repeat(j,M) cur+=B[l][j];
    ans = max(ans,cur);
    for(ll r=l+1;r<N;r++){
      cur+=add[r];
      ans = max(ans,cur-(A[r]-A[l]));
    }
    repeat(j,M){
      ll ni = nexti[l][j];
      add[ni] -= B[ni][j]-B[l][j];
      ll i=l+1;
      while(i<ni){
        add[nexti[i][j]]+=B[nexti[i][j]][j]-B[i][j];
        i=nexti[i][j];
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 16768
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

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

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

#define MOD 1000000007
#define INF 2000000000

int GLL(LL& x) {
    return scanf("%lld", &x);
}

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

int a, b, c;

int main() {
    GI(a); GI(b); GI(c);

    if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
        cout << 0 << "\n";
        return 0;
    }
    else {
        cout << min(min(1LL * a * b, 1LL * b * c), 1LL * a * c) << "\n";
        return 0;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;


unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}


int main() {
    string a;
    cin >> a;
    ll s = a.size();
    ll ans = 0;
    for (int i = 1; i < (s+1)/2; i++) {
        int r = 0;
        for (int j = 0; j < i; j++) {
            if (a.at(j) != a.at(i + j))r = 1;
        }
        if (r == 0)ans = i * 2;
    }
    cout << ans << endl;
}

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

int main(){
  int i ,cnt=0 ,len;
  string s;
  while( cin >> s ){
    len = s.length();
    len--;
    for( i=0 ; i<len ; i++ ){
      if( s[i] == s[len] ){
	len--;
      }
      else{
	break;
      }
    }
    if( i >= len ){
      cnt++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 1184
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
bool cmp(int a,int b){
  return a>b;
}
int mini_change(vector<int> v){
  long long sum=0;
  int ans=0;
  long long neg=0;
  vector<int> p;
  for(auto o: v){
    sum+=o;
    if(o>0)
      p.push_back(o);
    if(o<0){
      ans++;
      neg-=o;
    }
  }
  if(sum<0) return -1;
  sort(p.begin(),p.end(),cmp);
  int i=0;
  while(neg>0){
    neg-=p[i];
    i++;
    ans++;
  }
  return ans;
}
int main(){
  int n;
  cin>>n;
  vector<int> v(n);
  for(int i=0;i<n;i++)
    cin>>v[i];
  int temp;
  for(int i=0;i<n;i++){
    cin>>temp;
    v[i]-=temp;
  }
  cout<<mini_change(v)<<endl;
  return 0;
}
    

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

int main() {
  string S;
  cin >> S;
  bool res = true;
  for (int i = 0; i < S.size(); ++i) {
    if (i % 2 == 0 && S[i] == 'L') res = false;
    if (i % 2 == 1 && S[i] == 'R') res = false;
  }
  if (res) puts("Yes");
  else puts("No");
}

Measured memory_bytes: 3608
#include<stdio.h>
#include<string.h>
char s[100][200], x[200];
int n, t[200];
int main() {
    int i, ans = 0, flag = 0;
    scanf("%d", &n);
    for(i = 1; i <= n; ++i) {
        scanf("%s %d", s[i], &t[i]);
    }
    scanf("%s", x);
    for(i = 1; i <= n; ++i) {
        if(flag) ans += t[i];
        else if(!strcmp(x, s[i])) flag = 1;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
/* 	* In the name of GOD 
	* Thanks God */
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
#define F first
#define S second

int32_t main(){
	int n, a, b;
	cin >> n >> a >> b;
	cout << min(a * n, b);
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)

class Point
{
public:
  double x, y;
  Point(double x = 0, double y = 0) : x(x), y(y) {}

  Point operator+(Point p)
  {
    return Point(x + p.x, y + p.y);
  }
  Point operator-(Point p)
  {
    return Point(x - p.x, y - p.y);
  }
  Point operator*(double a)
  {
    return Point(a * x, a * y);
  }
  Point operator/(double a)
  {
    return Point(x / a, y / a);
  }

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

  bool operator<(const Point &p) const
  {
    return x != p.x ? x < p.x : y < p.y;
  }
  bool operator==(const Point &p) const
  {
    return equals(x, p.x) && equals(y, p.y);
  }

  void print()
  {
    printf("%.10f %.10f\n", x, y);
  }
};

typedef Point Vector;

double dot(Vector a, Vector b)
{
  return a.x * b.x + a.y * b.y;
}
double cross(Vector a, Vector b)
{
  return a.x * b.y - a.y * b.x;
}

struct Segment
{
  Point p1, p2;
};

typedef Segment Line;

class Circle
{
public:
  Point c;
  double r;
  Circle(Point c = Point(), double r = 0) : c(c), r(r) {}
};

typedef vector<Point> Polygon;

Vector projection(Line l, Point p)
{
  return (l.p2 - l.p1) * (dot(p - l.p1, l.p2 - l.p1) / (l.p2 - l.p1).norm()) + l.p1;
}

int main()
{
  double x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  Line l = {Point{x1, y1}, Point{x2, y2}};
  int q;
  cin >> q;
  rep(i, q)
  {
    double x, y;
    cin >> x >> y;
    Point p = {x, y};
    Point a = projection(l, p);
    a.print();
  }
}


Measured memory_bytes: 3284
import sys
N = int(input())
if N %2 !=0:
    print(0)
    sys.exit()
else:
    sum = 0
    num = N
    num_tmp = num //5
    while num_tmp > 0:
        num_tmp = num // 5
        sum += num // 10
        num = num_tmp
print(sum)

Measured memory_bytes: 9052
n=int(input())
l=list(map(int,input().split()))
l.sort()
l.reverse()
count=0
for i in range(n-2):
  j=i+1
  k=n-1
  while j<k:
    if l[i]<l[j]+l[k]:
      count+=k-j
      j+=1
    else:
      k-=1
print(count)

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

int main(){
  char b;
  cin >> b;
  
  if(b == 'A'){
    cout << 'T' << endl;
  }
  if(b == 'T'){
    cout << 'A' << endl;
  }
  if(b == 'G'){
    cout << 'C' << endl;
  }
  if(b == 'C'){
    cout << 'G' << endl;
  }
}

Measured memory_bytes: 256
from math import sqrt
x1, y1, x2, y2 = map(int, raw_input().split())
dx = x2 - x1
dy = y2 - y1

for i in xrange(input()):
    x, y = map(int, raw_input().split())
    a = float(dx * (x - x1) + dy * (y - y1)) / (dx ** 2 + dy ** 2)
    print "%.09f %0.09f" % (2 * x1 - x + 2 * a * dx, 2 * y1 - y + 2 * a * dy)


Measured memory_bytes: 4732
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>

using namespace std;

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

int main() {
	string str, ans;
	cin >> str;
	
	REP(i, str.size()) {
		switch(str[i]) {
		case '0':
		case '1':
			ans += str[i];
			break;
		
		case 'B':
			if (!ans.empty())
			ans.erase(ans.end() - 1);
			break;
		}
	}
	
	cout << ans << endl;
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> h(N);
  for (int i = 0; i < N; i++) cin >> h[i];
  vector<int> dp(N);
  dp[1] = abs(h[1] - h[0]);
  for (int i = 2; i < N; i++)
    dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
  cout << dp[N - 1] << endl;
}

Measured memory_bytes: 1024
#include <cassert>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <iomanip>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <numeric>
using namespace std;

string to_string(bool x) {
	return x ? "true" : "false";
}

string to_string(char x) {
	return string(1, x);
}

string to_string(string s) {
	return '"' + s + '"';
}

string to_string(const char *s) {
	return to_string((string) s);
}

template<typename A, typename B>
string to_string(pair<A, B> p) {
	return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template<typename A>
string to_string(A v) {
	bool first = true;
	string res = "{";
	for (const auto &x : v) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(x);
	}
	res += "}";
	return res;
}

void debug_out() {
	cerr << endl;
}

template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define all(x) (x).begin(), (x).end()
#define sz(a) (int)(a).size()
#define pb push_back
#define fi first
#define se second
#define two(a) (1LL << (a))
#define has(mask, i) ((mask >> i) & 1)
//#define int ll

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector < int >;
using vll = vector < ll >;
using vvi = vector < vector < int > >;
using vpii = vector < pii >;
using ld = long double;
using vs = vector < string >;

//mt19937_64 rnd((unsigned long) chrono::high_resolution_clock::now().time_since_epoch().count());

int N;
vi A, B;

const int INF = (int)1e9 + 22;

void solve() {
  cin >> N;
  B.resize(N - 1);
  for (auto &x : B)
    cin >> x;
  A.resize(N, INF);
  for (int i = 0; i < N; i++) {
    if (i) {
      A[i] = min(A[i], B[i - 1]);
    }
    if (i < N - 1)
      A[i] = min(A[i], B[i]);
  }
  //debug(A);
  int ans = 0;
  for (int i = 0; i < N; i++)
    ans += A[i];
  cout << ans;
}

signed main() {
#ifdef LOCAL
	freopen("xxx.in", "r", stdin);
	freopen("xxx.out", "w", stdout);
	auto start_time = clock();
#endif

	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.setf(ios::fixed | ios::showpoint);
	cout.precision(12);
	cerr.setf(ios::fixed | ios::showpoint);
	cerr.precision(4);

	solve();

#ifdef LOCAL
	auto end_time = clock();
	cerr << "time: " << (end_time - start_time) * 1.0 / CLOCKS_PER_SEC << endl;
#endif

	return 0;
}


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

int main(){
 int n;
 double s[1000],sum,dist,m;

 while(1){
  cin >> n;
  sum = 0.0;
  dist = 0.0;
  if(n == 0) break;

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

   sum += s[i];
  }
  m = sum / n; 
 
  for(int i = 0; i < n; i++){
   dist += pow(s[i] - m, 2);
  }

  printf("%lf\n", sqrt(dist / n));
 }

 return 0;
}

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

using namespace std;

//#define FILE_IO

int N;
int v[100005];

void first() {printf("First\n"); exit(0);}
void second() {printf("Second\n"); exit(0);}

void win(int mv) {if(mv == 0) first(); second();}
void lose(int mv) {if(mv == 0) second(); first();}

int gcd(int a, int b)
{
    if(!a)  return b;
    if(!b)  return a;
    return gcd(b % a, a);
}

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    scanf("%d", &N);
    for(int i = 1; i <= N; i++) scanf("%d", &v[i]);

    int mv = 0;
    while(1)
    {
        int f[2];
        f[0] = f[1] = 0;
        for(int i = 1; i <= N; i++) f[ v[i] & 1 ]++;
        if(f[0] % 2 == 1)   win(mv);
        if(f[1] > 1)    lose(mv);
        int d = 0;
        for(int i = 1; i <= N; i++)
        {
            if(v[i] & 1)    v[i]--;
            if(v[i] == 0)   lose(mv);
            d = gcd(d, v[i]);
        }
        for(int i = 1; i <= N; i++) v[i] /= d;
        mv ^= 1;
    }

    return 0;
}


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

int main() {
    int a , b , c , d , k;
    cin >> a >> b >> c >> d >> k;
    int n = c * 60 + d - a * 60 - b;
    cout << n - k << endl;
}

Measured memory_bytes: 3560
import java.util.Scanner;

public class Main {

    
    public static void main(String[] args) {
     Scanner scanner = new Scanner(System.in);
     int n = scanner.nextInt();
     int[] nums = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
             System.out.println(nums[n-1]);
    }
    
}


Measured memory_bytes: 22996