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

int main(){
    int n[3];
    cin >> n[0] >> n[1] >> n[2];
    int sum = 0;
    sort(n, n+3);
    sum += n[2] - n[1];
    n[0] += n[2] - n[1];
    n[1] = n[2];
    sum += (n[1] - n[0] + 1) / 2;
    n[0] += (n[1]-n[0]+1)/2*2;
    if(n[0] > n[1])sum++;

    cout << sum << endl;

    return 0;
}


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

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

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int N;
  while(cin>>N,N){
	VI xs(N);
	cin >> xs;

	bool ok = false;
	int ans = 0;
	for(int x: xs){
	  ok |= x>1;
	  ans += min(1, x);
	}

	if(ok) cout << ans+1 << endl;
	else cout <<"NA" << endl;
  }

  return 0;
}



Measured memory_bytes: 3236
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using static System.Console;

namespace AtCoder.Probrems.Solvers.ABC128
{
    public class C
    {
        static void Main(string[] args)
        {
            var nm = ReadLine().Split().Select(int.Parse).ToArray();
            var n = nm[0];
            var m = nm[1];
            var sx = new List<HashSet<int>>();
            for (int i = 0; i < m; i++)
            {
                sx.Add(new HashSet<int>(ReadLine().Split().Skip(1).Select(int.Parse)));
            }
            var px = ReadLine().Split().Select(int.Parse).ToArray();
            WriteLine(Solve(n, m, sx, px));
        }

        public static long Solve(int n, int m, List<HashSet<int>> sx, int[] px)
        {
            var source = Enumerable.Range(1, n).ToArray();
            var spx = sx.Zip(px, (s, p) => new { s, p });
            int count = 0;
            foreach (var c in ConbinationAll(source))
            {
                if (spx.All(x => Validate(c, x.s, x.p)))
                    count++;
            }
            return count;
        }

        private static IEnumerable<int[]> ConbinationAll(int[] source)
        {
            for (int i = 0; i < Math.Pow(2, source.Length); i++)
            {
                yield return Convert.ToString(i, 2).PadLeft(source.Length, '0').Zip(source, (c, s) => new { c, s }).Where(x => x.c == '1').Select(x => x.s).ToArray();
            }
        }

        private static bool Validate(int[] choices, HashSet<int> s, int p)
        {
            return choices.Where(s.Contains).Count() % 2 == p;
        }
        private const int MOD = 1000000007;
    }
}


Measured memory_bytes: 15840
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
 
typedef vector<int> vi;;
typedef vector<ll> vll;

#define l() length()
#define sz() size()
 
#define b() begin()
#define e() end()
#define all(x) x.begin(), x.end()
 
#define pb(i) push_back(i)
#define PB() pop_back()
 
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
#define mp make_pair
#define Fi first
#define Se second
 
const int maxx=1e6+9;
 
// Happy Coding!


void solve(){
    string str;
    cin>>str;
    
    int a=0;// if the final string : 0101010101
    int b=0;// if the final string : 1010101010
    
    for(int i=0;i<str.l();i++){
        // for a : odd index must be 0 and even must be 0
        a+=(i%2==0) ? (str[i]!='0') : (str[i]!='1') ;
        
        // for b : odd index must be 0 and even must be 1
        b+=(i%2==0) ? (str[i]!='1') : (str[i]!='0') ;
    }
    cout<<min(a,b);
}



int main() {
    faster;
    int t=1;
    // cin>>t;
    while(t-->0){
        solve();
    }
	return 0;
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s , ans; cin>>s;
    int f = (s[0] - '0')* 10 +( s[1] - '0');
    int se = (s[2] - '0') * 10 +( s[3] - '0');
    bool okff = f > 0 && f <= 12;
    //bool okfs = f > 0;
    bool okss = se > 0 && se <= 12;
    if(okff && !okss)ans = "MMYY";
    else if(!okff && okss)ans = "YYMM";
    else if(okff && okss)ans = "AMBIGUOUS";
    else ans = "NA";
    cout<<ans<<endl;


}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int main()
{
    int a;
    cin >> a;
    int b;
    cin >> b;
    // int a = 5; 
    // int b = 4;
    int remain = 16 - a - b;
    int diff = abs(a - b);
    if (remain >= diff) {
        cout << "Yay!";
    } else {
        cout << ":(";
    }
    return 0;
}

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

int main() {
    int m1, m2, d1, d2;
    cin >> m1 >> d1 >> m2>> d2;
    if (m2 - m1 == 1) {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vector<ll>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const ll MOD = 1000000007;
const ll INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(ll i=0;i<(ll)(s.size());++i) {
    cout << s[i];
    if(i == (ll)(s.size())-1) cout << endl;
    else cout << " ";
  }
  cout << endl;
}
signed main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  ll n; cin >> n;
  vector<ll> a(n);
  for(ll i=0;i<n;++i) {
    cin >> a[i];
  }
  vvi b(20, vi(n));
  for(ll i=0;i<n;++i) {
    for(ll j=0;j<20;++j) {
      b[j][i] = (a[i]>>j) & 1;
    }
  }
  vvi r(20, vi(n));
  for(ll i=0;i<20;++i) {
    ll now = n;
    ll prev = n;
    for(ll j=n-1;j>=0;--j) {
      if(b[i][j]) {
        prev = now;
        now = j;
      }
      r[i][j] = prev-1;
    }
  }
  vi mi(n);
  for(ll i=0;i<n;++i) {
    ll tmp = INF;
    for(ll j=0;j<20;++j) {
      tmp = min(tmp, r[j][i]);
    }
    mi[i] = tmp;
  }
  ll ans = 0;
  for(ll i=0;i<n;++i) {
    ans += mi[i] - i + 1;
  }
  cout << ans << endl;
}


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

#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define ssort(n) sort((n).begin(),(n).end())
#define rsort(n) sort((n).begin(),(n).end(),greater<int>())
#define mp make_pair
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
typedef pair<P,int> COST;
#define repl(i,n) for(ll i=0;i<(n);++i)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
using Graf=vector<vector<int>>;
#define MAX 1000000007

int main()
{
    string s,t;
    cin >> s;
    cin >> t;
    ssort(s);
    rsort(t);
    rep(i,min(s.size(),t.size())){
        if(s[i]<t[i]){
            Yes;return 0;
        }else if(s[i]>t[i]){
            No;return 0;
        }
    }
    if(s.size()==t.size()){
        No;
    }else if(s.size()<t.size()){
        Yes;
    }else{
        No;
    }


}

Measured memory_bytes: 3584
//* AuThOr GaRyMr *//
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB(a) push_back(a)
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
const int MOD=1e9+7;
string s;
int len,n;
int d[200000+10];
int main(){
	cin>>n;
	len=n+n;
	cin>>s;
	s='$'+s;
	if(s[1]!='B'||s[len]!='B'){
		puts("0");return 0;
	}
	d[1]=0;//l
	rb(i,2,len){
		if(s[i]!=s[i-1]){
			d[i]=d[i-1];	
		}
		else{
			d[i]=d[i-1]^1;
		}	
	}
	int left=0;
	rb(i,1,len) {
		if(!d[i]) left++;
		else left--;
		if(left<0) {
			puts("0");
			return 0;
		}
	}
	if(left!=0) {
		puts("0");
		return 0;
	}
	int l,r;
	l=r=0;
	LL RES=1;
	rb(i,1,len){
		//cout<<d[i]<<" ";
		if(d[i]==1) {
			RES*=(l-r);
			RES%=MOD;
		}
		if(d[i]==0) l++;
		else r++;
	}//cout<<endl;
	rb(i,1,n) RES*=i,RES%=MOD;
	cout<<RES<<endl;
	return 0;
}

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

const int MAXN = 100010;
int N;
vector<pair<int, int>> adj[MAXN];
int ans[MAXN];

void dfs(int cur = 1, int prv = 0) {
	for (auto e : adj[cur]) {
		int nxt, w; tie(nxt, w) = e;
		if (nxt == prv) continue;
		ans[nxt] = (ans[cur] + w) % 2;
		dfs(nxt, cur);
	}
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N;
	for (int i = 0; i < N-1; i++) {
		int a, b, c; cin >> a >> b >> c; c %= 2;
		adj[a].emplace_back(b, c);
		adj[b].emplace_back(a, c);
	}
	dfs();
	for (int i = 1; i <= N; i++) {
		cout << ans[i] << '\n';
	}

	return 0;
}


Measured memory_bytes: 8448
/* 
chirag11032000
Chirag Thakur
*/

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

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;

template < typename T > using OrderedSet = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << " | ";
	__f(comma + 1, args...);
}
#else
#define trace(...)
#endif

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fastIo() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

const db PI = acos(-1);
const ll LINF = LLONG_MAX;
const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;

void testCase();

int main() {
	fastIo();
	testCase();
	cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
	return 0;
}

void testCase() {
	int h, w, n;
	cin >> n >> h >> w;
	if (h > n || w > n) {
		cout << "0\n";
	} else {
		cout << (n - h + 1) * (n - w + 1) << "\n";
	}
}

Measured memory_bytes: 256
#ifdef _MSC_VER
#include "stdc++.h"
#endif
#ifdef __GNUC__
#include<bits/stdc++.h>
#endif
using namespace std;

using ll = long long;

//constant
const double EPS = 1e-10;
ll MOD = 1000000007;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// vector
//template<typename T> vector<vector<T>> vv(ll H, ll W, T v) { return vector<vector<T>> vec(H, vector<T>(W, v)); }

// view vector
template<typename T> void view(T e) { cout << e << endl; }
template<typename T> void view(const vector<T>& v) { for (const auto& e : v) { cout << e << " "; } cout << endl; }
template<typename T> void view(const vector<vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

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

// ***************************************

int main(void) {

	int K, N;
	cin >> K >> N;

	vector<ll> A(N);
	for (auto& a : A) {
		cin >> a;
	}

	ll ans = A[N - 1] - A[0];
	FOR(i, 1, N) {
		chmin(ans, K - A[i] + A[i - 1]);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<algorithm>
using namespace std;
int n, m;
long long s = 1, Mod = 1000000007, r;
int main() {
	int i;
	scanf("%d%d", &n, &m);
	for (i = 1; i <= n; i++)s = s*i%Mod;
	for (i = 1; i <= m; i++)s = s*i%Mod;
	if (0 <= n - m&&n - m <= 1)r = (r + s) % Mod;
	if (0 <= m - n && m - n <= 1)r = (r + s) % Mod;
	printf("%lld\n", r);
}

Measured memory_bytes: 128
//
//  main.cpp
//  F
//
//  Created by 曾憲揚 on 2020/8/21.
//  Copyright © 2020 曾憲揚. All rights reserved.
//

#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5+5;
int a[maxn];
long long dp[maxn];
long long sum[maxn];

int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    memset(dp, -1, sizeof(dp));
    int n; cin>>n;
    for(int i=1; i<=n; i++) cin>>a[i];
    
    for(int i=1; i<=n; i+=2){
        sum[i] = i>2? sum[i-2]+a[i] : a[i];
    }
    
    dp[0] = dp[1] = 0;
    for(int i=2; i<=n; i++){
        if(i&1) dp[i] = max(dp[i-1], dp[i-2]+a[i]);
        else    dp[i] = max(sum[i-1], dp[i-2]+a[i]);
    }
    cout<<dp[n]<<endl;
    return 0;
}


Measured memory_bytes: 7536
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
#define INF 1e9
#define All(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;


int main() {
  string s;
  cin>>s;
  vector<bool> ch(26);
  for(int i=0;i<(int)s.size();i++){
    ch[s[i]-'a']=true;
  }

  for(int i=0;i<26;i++){
    if(!ch[i]){
      cout<<(char)('a'+i)<<"\n";
      return 0;
    }
  }
  cout<<"None\n";

  return 0;
}


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

template< class t>
long long int gcd( t g,t h )
{
    return ( h==0 ? g : gcd(h,g%h) );
}
 
int main()
{
    #ifdef Saiyan
  freopen("inp.txt","r",stdin) ;
  freopen("out.txt","w",stdout) ;
  #endif
 
  ios_base::sync_with_stdio(false) ; cin.tie(0) ;
 
  long long int t,i,j,a[100],k,temp;
  
  cin>>k;
  cout<<50<<endl;
  
  for(i=0;i<50;i++)
  {
      a[i]=i;
  }
  
  temp=k/50;
  
  for(i=0;i<50;i++)
  {
      a[i]+=temp;
  }
  
  temp=k%50;
  j=49;
  
  for(i=0;i<temp;i++)
  {
     a[j]++;
     j--;
  }
  
  for(i=0;i<50;i++)
  {
      cout<<a[i]<<" ";
  }
  
   return 0;
}

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

using ll = long long;
#define countof(a) (sizeof(a)/sizeof((a)[0]))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }

template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 

template <typename T> inline T gcd(T a, T b) {
	if (b == 0) return a;
	T r; while ((r = a % b) != 0) a = b, b = r;
	return b;
}

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

    int N;
    cin >> N;
    vector<int> A(N);
    cin >> A;
    vector<int> L(N);
    vector<int> R(N);
    
    L[0] = A[0];
    R[N-1] = A[N-1];
    rep1(i, N) {
        L[i] = gcd(L[i-1], A[i]);
        R[N-1-i] = gcd(R[N-i], A[N-1-i]);
    }
    // cout<<"A:";cout_h(A);
    // cout<<"L:";cout_h(L);
    // cout<<"R:";cout_h(R);
    int ans = -1;
    chmax(ans, R[1]);
    rep1(i, N - 1) {
        chmax(ans, gcd(L[i-1], R[i+1]));
    }
    chmax(ans, L[N-2]);

    cout << ans << endl;
}


Measured memory_bytes: 1408
#[allow(unused_imports)]
use std::{cmp::Reverse, collections::*};

#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Chars, Usize1},
};

#[allow(unused_imports)]
use itertools::Itertools;

#[allow(unused_imports)]
use num::Integer;

#[fastout]
pub fn main() {
    input! {
        n: usize, a: usize, b: usize,
    }

    if n <= a {
        println!("{}", n);
    } else if n <= a + b {
        println!("{}", a);
    } else {
        println!("{}", n / (a + b) * a + (n % (a + b)).min(a));
    }
}


Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    double a, b, x;
    cin >> a >> b >> x;
    cout << fixed << setprecision(12) << (a * a * b > 2 * x ? atan2(b * b * a, 2 * x) : atan(2 * (b - x / a / a) / a)) * 180 / acos(-1);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;

int main()
{
  int N;
  string s, t;
  int res=0;
  cin >> N >> s >> t;

  int m = 0;
  FOR(i, 1, N) {
    string subs = s.substr(N-i, i);
    string subt = t.substr(0, i);
    if( subs == subt ) m = i;
  }
  res = N * 2 - m;
  cout << res << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n,i,j,t,b=0,c=1;
	scanf("%d",&n);
	int a[100];
	for(i=0;i<=n-1;i++){scanf("%d",&a[i]);}
	for(i=n-1;i>=1;i--)for(j=1;j<=i;j++){
		t=a[j-1];
		if(a[j-1]<a[j]){a[j-1]=a[j];a[j]=t;}
		}
	for(i=0;i<n;i++){b+=c*a[i];c*=(-1);}
	printf("%d",b);
	return 0;
}

Measured memory_bytes: 128
while ary  =  gets
  ary.chomp
  stack = []
  ary = ary.split(" ")
  while ary.size>0
    a = ary.shift
    if  a == "+"
      x = stack.shift.to_i + stack.shift.to_i
    elsif a == "-"
      x = -stack.shift.to_i + stack.shift.to_i
    elsif a == "*"
      x = stack.shift.to_i * stack.shift.to_i 
    else
      x = a
    end
    stack.unshift(x)
    
    end
    puts stack[0]
end

Measured memory_bytes: 8684
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
using namespace std;

typedef long long ll;

ll euclidean_gcd(ll a, ll b)
{
    if(a<b) swap(a, b);
    ll r;
    while((r=a%b)!=0){
        a=b;
        b=r;
    }

    return b;
}

int main()
{
    int N,K;
    cin >> N >> K;
    if(N*(N-1)/2-(N-1)<K) cout << -1 << endl;
    else{
        int M=N-1;
        M+=N*(N-1)/2-(N-1)-K;
        cout << M << endl;
        for(int i=0; i<N-1; i++){
            cout << 1 << ' ' << i+2 << endl;
        }

        int start=2;
        int cnt=0;
        for(int i=0; i<N*(N-1)/2-(N-1)-K; i++){
            cnt++;
            cout << start << ' ' << start+cnt << endl;
            if(cnt+start==N){
                start++;
                cnt=0;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include<stdio.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<string.h>
#include<algorithm>
#include<sstream>
using namespace std;

int main() {
	int count = 0;//文字を消す回数
	int num = 0;
	
	string s;
	//stringstream ss;
//	string s2;
	
	cin >> s;
	count = s.size() - 1;


	for (int i= 1;i<count;i++) {
		s.erase(s.begin()+1);
		num++;
	}
	string s3;
	s3 = s[s.size()-1];
	s.pop_back();
	

	
	s += to_string(num) + s3;



	
	cout << s<< endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    long long n,m,i,sum=0,lv;
scanf("%lld%lld",&n,&m);
long long A[m];
    for(i=0; i<m ;i++){
        scanf("%lld", &A[i]);
        sum = sum + A[i];
    }
 lv=n-sum;
    if(sum>n){
            printf("-1\n");
    }
else if(sum<=n){
        printf("%lld\n",lv);
}
    return 0;
}

Measured memory_bytes: 2128
# coding: utf-8
# Your code here!

i = list(input())
if i[-1] == "3":# 
    print("bon")
if i[-1]=="0" or i[-1]=="1" or i[-1]=="6" or i[-1]=="8":
    print("pon")
if i[-1]=="2" or i[-1]=="4" or i[-1]=="5" or i[-1]=="7" or i[-1]=="9":
    print("hon")
    

Measured memory_bytes: 9088
ex1 = gets()
ex2 = ex1.split()
x = ex2[0].to_i
y = ex2[1].to_i

until x == 0 && y == 0
  if x <= y
    puts "#{x} #{y}"
 else
    puts "#{y} #{x}"
 end

 ex1 = gets()
 ex2 = ex1.split()
 x = ex2[0].to_i
 y = ex2[1].to_i

end


Measured memory_bytes: 6848
#include <stdio.h>
#pragma warning (disable:4996)

int main() {
	int L, R, d;
	(void)scanf("%d%d%d", &L, &R, &d);
	int count = 0;
	int i = 1;
	while (R >= d * i) {
		if (L > d * i) {
			i++;
			continue;
		}
		i++;
		count++;
	}
	printf("%d", count);
}

Measured memory_bytes: 1676
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define sayyes cout<<"Yes"<<endl;
#define sayno cout<<"No"<<endl;
#define vv(a,b) vector< vector<int> > v(a,vector<int>(b,0));
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const int mod =1e9+7;

int main()
{
    string a;
    cin>>a;
    for(int bit=0;bit<(1<<3);bit++)
    {
        string s;
        int ans=a[0]-'0';
        s+=a[0];
        rep(i,3)
        {
            if(bit & (1<<i))
            {
                ans+=a[i+1]-'0';
                s+="+";
                s+=a[i+1];
            }
            else
            {
                ans-=a[i+1]-'0';
                s+="-";
                s+=a[i+1];
            }
            
        }
        if(ans==7)
        {
            cout<<s+"=7";
            return 0;
        }
    }
}


Measured memory_bytes: 256
n=int(input().rstrip())
data=input().rstrip().split()
t=int(data[0])
a=int(data[1])
h=input().rstrip().split()
deg=[abs((t-int(x)*0.006)-a) for x in h]
for i in range(len(deg)):
  if min(deg)==deg[i]:
    print(i+1)
    break

Measured memory_bytes: 3064
import sys
readline = sys.stdin.readline
write = sys.stdout.write

def main():
    MOD = 10**9 + 7
    def query(k0):
        s = 0
        k = k0
        while k:
            s += data[k]
            k -= k & -k
        k = k0
        while k <= N:
            data[k] += 1
            k += k & -k
        return s % MOD

    L = 100000
    fact = [1]*(L+1)
    rfact = [1]*(L+1)
    r = 1
    for i in range(2, L+1):
        fact[i] = r = i * r % MOD
    rfact[i] = r = pow(fact[i], MOD-2, MOD)
    for i in range(L, 0, -1):
        rfact[i-1] = r = i * r % MOD

    while 1:
        N = int(readline())
        if N == 0:
            break
        R = int(readline())
        *S, = range(N)
        for i in range(R):
            s, t = map(int, readline().split()); s -= 1; t -= 1
            S[s], S[t] = S[t], S[s]
        data = [0]*(N+1)
        write("%d\n" % (sum(fact[N-1-i] * (e - query(e+1)) % MOD for i, e in enumerate(S)) % MOD))
main()


Measured memory_bytes: 23888
s = input()


def solve(query):
    while 1:
        for frag in ("erase", "eraser", "dream", "dreamer"):
            if query.endswith(frag):
                query = query[:-len(frag)]
                break
        else:
            print("NO")
            break
        if not query:
            print("YES")
            break



solve(s)

Measured memory_bytes: 9136
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());
            int cnt = 0;
            for (int i = 1; i <= N; i++)
            {
                if (i.ToString().Length % 2 !=0)
                {
                    cnt++;
                }
            }
            Console.WriteLine(cnt);
        }
    }
}
// 文字列の入力
//string s = Console.ReadLine();

// 整数の入力
//long n = long.Parse(Console.ReadLine());

// 文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');

// 整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define FOR(i, n) for(int i = 0; i < (n); ++i)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define TRAV(i, n) for(auto &i : n)
#define SZ(x) (int)(x).size()
#define PR std::pair
#define MP std::make_pair
#define X first
#define Y second
typedef long long ll;
typedef std::pair<int, int> PII;
typedef std::vector<int> VI;

int main(){
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(0);
	std::string s;
	std::cin >> s;
	std::string last = "";
	int ans = 0;
	std::string cur = "";
	FOR(i, SZ(s)){
		cur.push_back(s[i]);
		if(cur != last){
			ans++;
			last = cur;
			cur = "";
		}
	}
	std::cout << ans;
	return 0;
}


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

using namespace std;

int main(int, char**) {
        int k;
        string s;
        cin >> k;
        cin >> s;
        int m = s.size();
        if (m <= k) {
                cout << s << endl;
        } else {
                s = s.substr(0, k);
                cout << s << "..." << endl;
        }
        return 0;
}


Measured memory_bytes: 3600
N, Ma, Mb = map(int, input().split())
abc = [list(map(int, input().split())) for _ in range(N)]

inf = float('inf')
dp = [[[inf] * 401 for _ in range(401)] for _ in range(N + 1)]

dp[0][0][0] = 0

for i in range(N):
    for j in range(401):
        for k in range(401):
            dp[i + 1][j][k] = dp[i][j][k]
            if j - abc[i][0] >= 0 and k - abc[i][1] >= 0:
                dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j - abc[i][0]][k - abc[i][1]] + abc[i][2])
ans = inf
for a in range(1, 401):
    for b in range(1, 401):
        if a * Mb == b * Ma:
            ans = min(ans, dp[N][a][b])
if ans == inf:
    ans = -1
print(ans)


Measured memory_bytes: 136412
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int numCount = scanner.nextInt();
        int[] array = new int[numCount];
        for(int i=0; i<numCount; i++) {
            array[i] = scanner.nextInt();
        }

        boolean isBreak = false;
        int dividedCnt = 0;
        while(!isBreak) {
            for(int j=0; j<array.length; j++) {
                if(array[j] % 2 != 0) {
                    isBreak = true;
                    break;
                }
                array[j] = array[j] / 2;
            }
            if(!isBreak) {
                dividedCnt++;
            }
        }
        System.out.println(dividedCnt);
    }
}


Measured memory_bytes: 21332
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
int main()
{
    int n,q;
    cin>>n>>q;

    vector<int> parent(n);  // [0]->error
    for (int i = 1; i < n; i++) {
      int a,b;
      cin>>a>>b;
      parent[b-1]=a-1;
    }

    vector<ll> cost(n,0);
    for (int i = 0; i < q; i++) {
      int p,x;
      cin>>p>>x;
      cost[p-1]+=x;
    }

    cout<<cost[0]<<' ';
    for (int i = 1; i < n; i++) {
      cost[i]+=cost[parent[i]];
      cout<<cost[i]<<' ';
    }

    cout << endl;
    return 0;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef complex<double> xy_t;
typedef pair<xy_t, int> pci;
typedef vector<lint> poly;
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;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 100010;

constexpr double eps=1e-9;

inline int sgn(double x){
    if(x<-eps) return -1;
    if(x>eps) return 1;
    return 0;
}

inline bool EQ(double x, double y){
    return sgn(x-y)==0;
}

inline bool GE(double x, double y){
    return sgn(x-y)==1;
}

inline bool LE(double x, double y){
    return sgn(x-y)==-1;
}

inline bool GEQ(double x, double y){
    return sgn(x-y)>=0;
}

inline bool LEQ(double x, double y){
    return sgn(x-y)<=0;
}

struct Point{
    double x, y;
    Point(double x, double y): x(x), y(y){}

    Point operator+(const Point &p){
        return {x+p.x, y+p.y};
    }

    Point operator-(const Point &p){
        return {x-p.x, y-p.y};
    }

    Point operator*(const double k){
        return {k*x, k*y};
    }

    Point operator/(const double k){
        return {x/k, y/k};
    }

    double operator*(const Point &p){
        return x*p.x+y*p.y;
    }

    double operator^(const Point &p){
        return x*p.y-y*p.x;
    }

    bool operator==(const Point &p){
        return EQ(x, p.x) && EQ(y, p.y);
    }
};

using Vec=Point;
using pdi=pair<double, int>;

double abs(Point p){
    return hypot(p.x, p.y);
}

double arg(Point p){
    return atan2(p.y, p.x);
}

constexpr int CCW_COUNTER_CLOCKWISE=1;
constexpr int CCW_CLOCKWISE=-1;
constexpr int CCW_ONLINE_BACK=-2;
constexpr int CCW_ONLINE_FRONT=2;
constexpr int CCW_ON_SEGMENT=0;

inline int ccw(Point a, Point b, Point c){
    Vec v=b-a, w=c-a;
    if(GE(v^w, 0)) return CCW_COUNTER_CLOCKWISE;
    if(LE(v^w, 0)) return CCW_CLOCKWISE;
    if(LE(v*w, 0)) return CCW_ONLINE_BACK;
    if(LE((a-b)*(c-b), 0)) return CCW_ONLINE_FRONT;
    return CCW_ON_SEGMENT;
}

bool isParallel(Vec a, Vec b){
    return EQ(a^b, 0);
}

bool isOrthogonal(Vec a, Vec b){
    return EQ(a*b, 0);
}

bool intersectSS(Point a, Point b, Point c, Point d){
    return ccw(a, b, c)*ccw(a, b, d)<=0 && ccw(c, d, a)*ccw(c, d, b)<=0;
}

Point getCrossPointLL(Point p, Vec v, Point q, Vec w){
    double s=((q-p)^w)/(v^w);
    return p+v*s;
}

int main(){
    int q;
    scanf("%d", &q);
    while(q--){
        vector<Point> p;
        rep(i, 4){
            double x, y;
            scanf("%lf%lf", &x, &y);
            p.emplace_back(x, y);
        }
        Vec a=p[1]-p[0], b=p[3]-p[2];
        if(isParallel(a, b)) printf("2\n");
        else if(isOrthogonal(a, b)) printf("1\n");
        else printf("0\n");
    }
}


Measured memory_bytes: 3244
n = int(input())
t, a = map(int, input().split())
h_list = map(int, input().split())

min_tempdiff = 10000  # 十分大きい値で！
argmin_tempdiff = None
for i, h_val in enumerate(h_list):
    temp_diff = abs(a - (t - h_val * 0.006))
    if min_tempdiff > temp_diff:
        min_tempdiff = temp_diff
        argmin_tempdiff = i + 1  # 地点は配列インデックス+1

print(argmin_tempdiff)

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int left = a + b, right = c + d;
  
  if (left > right) 
    cout << "Left" << endl;
  else if (left < right)
    cout << "Right" << endl;
  else cout << "Balanced" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S,T;
  cin>>S>>T;
  int U=0;
  for(int X=0;X<3;X++){
    if(S[X]==T[X]){
      U++;
    }
  }
  cout<<U<<endl;
}

Measured memory_bytes: 3592
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s1 = sc.nextLine();
        String s2 = sc.nextLine();
        s1 += s1;
        if(s1.contains(s2)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }

}


Measured memory_bytes: 26216
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;

int main() {
    string s;
    cin >> s;
    deque<char> q;
    for (char c : s) q.push_back(c);
    bool flip = false;
    int Q;
    cin >> Q;
    rep(qi,Q) {
        int ty;
        cin >> ty;
        if (ty == 1) {
            flip = !flip;
        }
        else {
            int f; char c;
            cin >> f >> c;
            if (flip) f = 3-f;
            if (f == 1) {
                q.push_front(c);
            }
            else {
                q.push_back(c);
            }
        }
    }
    if (flip) reverse(q.begin(), q.end());
    string ans;
    for (char c : q) ans += c;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4312
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

n, m = getNM()
point = getList()
point.sort()
diff = []
for i,j in zip(point, point[1:]):
    diff.append(abs(i-j))

diff.sort()
if n != 1:
    diff = diff[:-n+1]
print(sum(diff))

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


void solve(long long N, long long M, std::vector<long long> A){

}


// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::multiset<long long> A;
    long long tmp;
    for(int i = 0 ; i < N ; i++){
      scanf("%lld",&tmp);
      A.insert(tmp);
    }
    
    // 割引券を使う品物を決めていく
    long long maxval;
    for(long long j = 0 ; j < M ; j++){
      // 割引額が一番大きい = 現在最も高いものに割引券を使えばよい
      maxval = *A.rbegin();
      A.erase(std::prev(A.end()));
      A.insert(maxval/2);

    }

    long long ans = accumulate(A.begin(),A.end(),(long long)0);
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <deque>

using namespace std;

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

	int a[110];
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)  cin >> a[i];

	sort(a, a + n);
	reverse(a, a + n);

	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (i % 2 == 0) {
			ans += a[i];
		} else {
			ans -= a[i];
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif


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

    string S, T; cin >> S >> T;
    int N = S.size();

    bool ok = true;
    vvi e(26), r(26);

    REP(i,N) {
        if ((e[S[i]-'a'].size()>0 && e[S[i]-'a'][0]!=T[i]-'a')            
            || (r[T[i]-'a'].size()>0 && r[T[i]-'a'][0]!=S[i]-'a')) {
            ok = false;
            break;
        } else {
            e[S[i] - 'a'].push_back(T[i] - 'a');
            r[T[i] - 'a'].push_back(S[i] - 'a');
        }
    }

    string ans = ok ? "Yes" : "No";
    cout << ans << endl;

    return 0;
}

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

int main(){
  int N;
  cin >>N;
  
  string W;
  string w;
  string ans = "Yes";
  map<string,int> mp;
  rep(i,0,N){
    cin >> W;
    mp[W]++;
    if(i>0){
      if(mp[W]>1 or w[w.size()-1]!=W[0]) ans = "No";
    }
    w = W;
  }
  cout <<ans<< endl;
}

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

using namespace std;
typedef long long ll;
ll MAX_N = 200005;

int main() {
  ll n, k;
  ll a[MAX_N];
  ll c[MAX_N];
  scanf("%lld %lld", &n, &k);
  for (ll i=0; i<n; i++) {
    scanf("%lld", &a[i]);
    c[a[i]]++;
  }
  sort(c, c+n+1, greater<ll>());
 
  ll s = 0;
  for (ll i=0; i<k; i++) {
    s += c[i];
  }

  printf("%lld\n", max(0ll, n-s));

  return 0;
}


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

int main() {
  int N, K, a, b, i;
  cin >> N >> K;
  a = 1;
  b = 1;
  for(i=0; i<N; i++){
    a *= 2;
    b += K;
    if(a > b){
      a /= 2;
      a += K;
    } else {
      b -= K;
      b *= 2;
    } 
  }
  
  if(a < b) cout << a << endl;
  else cout << b << endl;
}

Measured memory_bytes: 256
N,M,C = map(int,input().split())
B = list(map(int,input().split()))
A = [list(map(int,input().split())) for _ in range(N)]


ans = 0
for i in range(N):
    v = C
    for j in range(M):
        v += A[i][j] * B[j]
    if v > 0:
        ans += 1

print(ans)

Measured memory_bytes: 9140
#include<iostream>



void calc(int n, int m, int *s)
{
 int i = 0;
  for(i = 0; i < n; i++)
  {
    *s += i;
  }
  for(i = 0; i < m; i++)
  {
    *s += i;
  }
}

int main(void)
{
  int n = 0;
  int m = 0;
  int s = 0;
  std::cin >> n >> m;
  calc(n, m, &s);
  std::cout << s;
  return 0;
}
  

Measured memory_bytes: 256
//09
#include<iostream>
#include<map>
#include<set>
#include<string>

using namespace std;

int main(){
  map<string,set<int> >idx;
  string s;
  int i;
  while(cin>>s>>i){
    idx[s].insert(i);
  }
  for(map<string,set<int> >::iterator it=idx.begin();it!=idx.end();it++){
    cout<<it->first<<endl;
    bool out=false;
    for(set<int>::iterator itt=it->second.begin();itt!=it->second.end();itt++){
      if(out){
	cout<<' ';
      }
      out=true;
      cout<<*itt;
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
N, M = input().strip().split()
N, M = [int(N), int(M)]


if N <= 1 and M >= 2:
  result = M*(M - 1)/2
  print(int(result))
  
elif M <= 1 and N >= 2:
  result = N*(N - 1)/2
  print(int(result))
  
elif N == 1 and N == 1:
  print('0')
  
else :
  result = M*(M - 1)/2 + N*(N - 1)/2
  print(int(result))

Measured memory_bytes: 3064
import bisect
n = int(input())
l = list(map(int,input().split()))
l.sort()
ans = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        wa = l[i] + l[j]
        indent = bisect.bisect_left(l,wa)
        #print(wa,indent)
        ans += indent - j - 1
print(ans)

Measured memory_bytes: 3188
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		SC sc = new SC(System.in);
		int sum=0;
		for(int i=0; i<10; i++) {
			sum+=sc.nextInt();
		}
		pl(sum);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
	static int root(int a) {

		int ketasu=0;
		int tmp=a;
		while(tmp>0) {
			ketasu++;
			tmp/=10;
		}
		int constant=(ketasu+1)/2;	//よく使うので定数化
		if(ketasu>=1) {
			int[] suuji=new int[constant];
			tmp=a;
			for(int i=0; i<constant; i++) {
				suuji[constant-1-i]=a%100;
				a/=100;
			}
			int ans=0;
			int kai=0;
			int mae=0;
			if(constant<=1) {
				for(int i=10; i>=0; i--) {
					if(suuji[0]>=i*i) {
						return i;
					}
				}
			}
			else {
				for(int i=0; i<constant; i++) {
					mae+=kai*2;
					for(int j=9; j>=0; j--) {
						if((mae*10+j)*j<=suuji[i]) {
							ans=ans*10+j;
							mae*=10;
							kai=j;
							if(i+1<constant) {
								suuji[i+1]+=(suuji[i]-(mae+j)*j)*100;
							}
							break;
						}
					}
				}
			}
			return ans;
		}
		else {
			return 0;
		}
	}
}


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

int main() {
 string s;
  cin >> s;
  	if(s[2] == s[3] && s[4] == s[5]){
    	cout << "Yes" << endl; 
    }
  	else{
    	cout << "No" << endl;
    }
}


Measured memory_bytes: 256
import math
from functools import reduce
import sys
import collections
K=int(input())
def gcd(*numbers):
    return reduce(math.gcd, numbers)
S=0
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            S+=gcd(i,j,k)
print(S)



Measured memory_bytes: 69864
import sys
readline = sys.stdin.readline

def main():
    S = readline().rstrip()
    T = S.replace('eraser', '').replace('erase', '').replace('dreamer', '').replace('dream', '')
    if not T:
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    main()

Measured memory_bytes: 3188
n = int(input())
p = [int(_) for _ in input().split()]
a = []
b = []
for i in range(1, n + 1):
    a.append(i * 2 * n)
    b.append((n + 1 - i) * 2 * n)
d = 1
for i in p:
    if d % 2 == 0:
        a[i - 1] += d // 2
        b[i - 1] += d // 2
    else:
        a[i - 1] += d // 2
        b[i - 1] += d // 2
        if a[i - 1] >= b[i - 1]:
            b[i - 1] += 1
        else:
            a[i - 1] += 1
    d += 1
for i in a:
    print(i, end=' ')
print()
for i in b:
    print(i, end=' ')

Measured memory_bytes: 6120
#include <iostream>
#include <string>
#include <vector>
#include <set>
using namespace std;
const int D[4][2]={ //Right,Up,Left,Down
	{0,1},
	{-1,0},
	{0,-1},
	{1,0},
};

class Maze{
	vector<string> &v;
public:
	int x,y,d;
	Maze(int _x,int _y,int _d,vector<string>&_v)
		: x(_x),y(_y),d(_d),v(_v){
	}
	void move(){
		int d_orig=(d+3)%4,i=0;
		for(;i<4;i++){
			d=(d_orig+i)%4;
			if(v[y+D[d][0]][x+D[d][1]]=='.')break;
		}
		y=y+D[d][0];
		x=x+D[d][1];
	}
};

int main(){
	int sx,sy,gx,gy,d;
	int N,M;
	cin>>N>>M;
	vector<string> m(N+2);
	m[0]=m[N+1]=string(M+2,'#');
	for(int i=1;i<=N;i++){
		string s;
		cin>>s;
		for(int j=0;j<M;j++){
			if(s[j]=='G')gx=j+1,gy=i,s[j]='.';
			if(s[j]=='>')sx=j+1,sy=i,d=0,s[j]='.';
			if(s[j]=='^')sx=j+1,sy=i,d=1,s[j]='.';
			if(s[j]=='<')sx=j+1,sy=i,d=2,s[j]='.';
			if(s[j]=='v')sx=j+1,sy=i,d=3,s[j]='.';
		}
		m[i]=string(1,'#')+s+'#';
	}
	Maze maze(sx,sy,d,m);
	set<pair<int,int> >se;
	se.insert(make_pair(sx,sy));
	for(int i=0;i<N*M*4;i++){
		maze.move();
		se.insert(make_pair(maze.x,maze.y));
		if(maze.x==gx&&maze.y==gy){
			cout<<se.size()<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;
}

Measured memory_bytes: 1288
n = int(input())
A = list(map(int,input().split()))
MOD = 10**9+7

cnt = [0] * (n+1)
cnt[0] = 3

res = 1
for i,a in enumerate(A):
  res *= cnt[a]
  res %= MOD
  cnt[a] -= 1
  cnt[a+1] += 1

print(res % MOD)

Measured memory_bytes: 87324
import java.util.*;
import java.lang.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        if (k % 2 != 0) {
            System.out.println((long)Math.pow(n/k, 3));
        }else{
            System.out.println((long)(Math.pow((n+(k/2))/k, 3) + Math.pow(n/k, 3)));
        }
    }
}

Measured memory_bytes: 21716
using System;
class Program {
        static void Main(string[] args) {
           
            Console.WriteLine(Q2() );
        }
   		private static int Q2() {
            string[] ab = Console.ReadLine().Split(' ');
            int a = int.Parse(ab[0]);
            int b = int.Parse(ab[1]);
            return ((a - 1) * (b - 1));
        }
}

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

int h, w;
int a[510][510];
typedef pair<int, int> P;
typedef pair<P, P> PP;
vector<PP> v;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> h >> w;
	for(int i=0; i<h; ++i)
		for(int j=0; j<w; ++j)
			cin >> a[i][j];
	for(int i=0; i<h-1; ++i){
		for(int j=0; j<w; ++j){
			if(a[i][j] % 2 == 1){
				v.push_back(PP(P(i, j), P(i+1, j)));
				--a[i][j];
				++a[i+1][j];
			}
		}
	}
	for(int i=0; i<w-1; ++i){
		if(a[h-1][i] % 2 == 1){
			v.push_back(PP(P(h-1, i), P(h-1, i+1)));
			--a[h-1][i];
			++a[h-1][i+1];
		}
	}
	cout << v.size() << "\n";
	for(int i=0; i<v.size(); ++i)
		cout << v[i].first.first+1 << " " << v[i].first.second+1 << " " << v[i].second.first+1 << " " << v[i].second.second+1 << "\n";
}

Measured memory_bytes: 5232
import sys,math
n=int(input())
a=list(map(int,input().split()))
sieve=[0]*(10**6+1)
numbers={}
flag=0
for i in range(n):
  if a[i] in numbers:
    numbers[a[i]]+=1
  else:
    numbers[a[i]]=1
pointer=2
while pointer<10**6+1:
  if sieve[pointer]==1:
    pointer+=1
    continue
  count=0
  pointer2=pointer
  while pointer2<10**6+1:
    if pointer2 in numbers:
      count+=numbers[pointer2]
    sieve[pointer2]=1
    pointer2+=pointer
  if count>=2:
    flag=1
    break
if flag==0:
  print('pairwise coprime')
  sys.exit()
ans=a[0]
for i in range(1,n):
  ans=math.gcd(a[i],ans)
if ans==1:
  print('setwise coprime')
else:
  print('not coprime')

Measured memory_bytes: 233492
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  string S;cin>>S;
  
  int ans=0;
  for(int i=0;i<4;i++){
    if(S[i]=='+'){
      ans++;
    }
    else{
      ans--;
    }
  }
  
  cout<<ans<<endl;
}


Measured memory_bytes: 3568