akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vll = vector<ll> ;
#define all(v) v.begin(),v.end()

int main(){
  int n, k;
  cin >> n >> k;

  string s;
  cin >> s;

  if(s.size() == 1){
    return cout << 1 << '\n', 0;
  }

  int l = 0, cnt = (s.front() == '0' ? 1 : 0), res = 0;

  for(int r = 1; r < n; ++r){
    // ……10……ごとにcnt++
    if(s[r] == '0' && s[r-1] == '1'){
      ++cnt;
    }
    // cnt>kなら……01……まで左端を動かす
    while(cnt > k){
      ++l;
      if(s[l] == '1' && s[l-1] == '0'){
        --cnt;
      }
    }
    if(cnt <= k){
      if(res < r - l + 1) res = r - l + 1;
    }
  }
  cout << res << '\n';
  return 0;
}

Measured memory_bytes: 3724
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main{
  public static void main(String args[]) throws IOException{
   BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

   double alph;

   while(true){

	   String st = br.readLine();
	   if( st.equals("0") ) break;
       double n = Double.parseDouble( st );
       String[] s = br.readLine().split(" ");

       double sum = 0;
       for(int i = 0; i < n ; i++){
    	   sum += Double.parseDouble( s[i] );
       }

       double ave = sum / n;

       double sigma = 0;

       for(int i = 0; i < n ; i++){
    	   sigma += Math.pow(Double.parseDouble( s[i] ) - ave , 2) ;
       }

       alph =Math.sqrt (sigma / n );
       System.out.println(alph);

   }


  }
}

Measured memory_bytes: 26424
//Author:- Yatin Patel
//Mail:- yatinpatel.gt@gmail.com

#include <bits/stdc++.h>
#define FILEIN ifstream fin;fin.open("input.txt");
#define FILEOUT ofstream fout;fout.open("output.txt");

using namespace std;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}

#define FAST ios::sync_with_stdio(false);ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

#define ll long long
#define ld long double
#define pb push_back
#define ff first
#define ss second

#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define minQueue priority_queue<ll,vector<ll>,greater<ll> >
#define maxQueue priority_queue<ll,vector<ll>,less<ll> > 

#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define RFOR(i,a,b) for(ll i=a;i>b;i--)
#define FILL(a,b) memset((a),(b),sizeof((a)))

#define MOD 1000000007
#define INF LONG_MAX
#define MINF LONG_MIN

ll power(ll x, unsigned ll y){
    if (y == 0)
        return 1;
    else if (y%2 == 0)
        return power(x, y/2)*power(x, y/2);
    else
        return x*power(x, y/2)*power(x, y/2);
}

//#define fin cin
//#define fout cout
void DFS(ll n,list<ll> *adj,vector<bool> &visited,stack<ll> &st){
    visited[n] = true;
    //cout<<n<<" ";
    for(auto itr = adj[n].begin();itr!=adj[n].end();itr++){
         if(!visited[(*itr)])
        DFS((*itr),adj,visited,st);
    }
    st.push(n);
}

int main(){

    FAST;
    ll n,m;
    cin>>n>>m;
    list<ll> *adj;
    adj = new list<ll>[n];
    for(ll i=0;i<m;i++){
        ll a,b;
        cin>>a>>b;
        a--;b--;
        adj[a].pb(b);
    }
    vector<bool> visited(n,false);
    stack<ll> st;
    for(ll i=0;i<n;i++){
        if(!visited[i]){
            DFS(i,adj,visited,st);
        }
    }
    vector<ll> v(n);
    for(ll i=0;i<n;i++){
        v[i] = st.top();
        st.pop();
    }
    vector<ll> dp(n,0);
    // cout<<"-----------------\n";
    for(ll i=0;i<v.size();i++){
        for(auto itr:adj[v[i]]){
            // cout<<v[i]<<" "<<itr<<endl;
            dp[itr] = max(dp[itr],dp[v[i]]+1);
        }
    }
    cout<<*max_element(dp.begin(),dp.end());
    return 0;
}






Measured memory_bytes: 9880
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int,int> pii;
typedef pair<long long, long long> pll;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
/*--------------------------------------------*/

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

    int H,N;
    cin >> H >> N;

    vector<int> a(N);
    rep(i,N) cin >> a[i];

    sort(ALL(a));
    reverse(ALL(a));

    rep(i,N){
        H -= a[i];
        if(H <= 0){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;





}

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


int main() {
	long long n, a, b;
	cin >> n >> a >> b; 
	long long x = b - a;
	if(n >= 2 && a <= b)
	cout << (n-2)*x + 1;
	else if (n == 1 && a == b)
	cout << 1;
	else 
	cout << 0;
}

Measured memory_bytes: 512
//karna padega 
#include<bits/stdc++.h>
using namespace std;  
#pragma GCC optimize("Ofast") 
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n; i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define endl '\n'
#define PI  3.14159265358979323846
#define MOD 1000000007
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
const int N = 2e6+5;
const int INF = 1e18L;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << 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...);
}
int ar[N];
int dp[N];
signed main(){
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
  IOS;
  int T=1;
  // cin >> T;
  while(T--){
    int n;
    cin >> n ;
    fn{
      cin >> ar[i];
    }
    int ans =0;
    int i =0;
    while(i<n){
      int cur =0 ;
      while(i+1<n && ar[i]>=ar[i+1] )cur++,i++;
      if(cur==0)i++;
      ans=max(ans,cur);
    }
    cout<<ans;
  
  }
  return 0;
}

Measured memory_bytes: 4372
#include <bits/stdc++.h>
#include <set>
#include <numeric>
#define rep(i,n) for (int i=0; i < (n); ++i)
#define all(a) a.begin(), a.end()
using ll = long long;
using namespace std;
 
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }


// const double PI = acos(-1);
// int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
// int a[12][12];

void solve() {
  int a,b,c,k; cin >> a >> b >> c >> k;

  if (k <= a) cout << k << endl;
  else if (k <= a+b) cout << a << endl;
  else cout << 2*a + b -k << endl;
}


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

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
 
int main(){
  int N,A,B,C;
  cin >> N >> A >> B >> C;
  vector<int> s(N);
  string si;
  for(int i=0;i<N;i++){
    cin >> si;
    if(si=="AB") s[i]=0;
    else if(si=="BC") s[i]=1;
    else s[i]=2;
  }

  vector<string> abc={"A","B","C"};
  vector<int> cur(3);
  cur={A,B,C};
  vector<int> ans(N);
  int l,m;
  for(int i=0;i<N;i++){
    l=s[i]; m=(l+1)%3;
    if(cur[l]==1 && cur[m]==1 && i<N-1){
      if(l!=s[i+1] && l!=(s[i+1]+1)%3){
        swap(l,m);
      }
    }else if(cur[m]<cur[l]){
      swap(l,m);
    }
    ans[i]=l;
    cur[l]++; cur[m]--;

    if(cur[0]<0 || cur[1]<0 || cur[2]<0){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  for(int i=0;i<N;i++){
    cout << abc[ans[i]] << endl;
  }

  return 0;
}


Measured memory_bytes: 4052
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF 1234567890
#define pii pair<int,int>
#define LL long long
using namespace std;

int main () {
    //clock_t start = clock();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    LL n;
    cin >> n;
    string s = "";
    while (n) {
        n--;
        s += (n%26) + 'a';
        n /= 26;
    }
    reverse(s.begin(), s.end());
    cout << s << endl;
    //cerr << fixed << setprecision(3) << (clock()-start)*1./CLOCKS_PER_SEC << endl;
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
#include <cstring> 
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define LLONG_MAXs 9223372036854775800

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

#include <iostream>
#include <cmath>
using namespace std;
 

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}

ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
constexpr ll min(ll a,ll b){
if(a>=b)return b;
if(a<b)return a;
}

constexpr ll max(ll a,ll b){
if(a>=b)return a;
if(a<b)return b;
}

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

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;
 
	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}
 
	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}
 
	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい]
	}
 
	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}
 
		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);
 
		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;
 
		return true;
	}
};




long long fac[510000], finv[510000], inv[510000];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < 510000; 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;
    }
}

// 二項係数計算
long long COM(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;
}


int main() {
  // 前処理
  //COMinit();

  ll N;
  cin>>N;
  ll ans=0;
  ll v[N];
  ll c[N];

  FOR(i,0,N-1){
    cin>>v[i];
  }

  FOR(i,0,N-1){
    cin>>c[i];
  }

  FOR(i,0,N-1){

    if(v[i]>c[i])ans=ans+v[i]-c[i];
  }
  cout<<ans<<endl;

  return 0;
 
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class BStringsWithTheSameLength {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int N;
        string S, T;
        in>>N>>S>>T;
        REP(i, N) out<<S[i]<<T[i];
        out<<'\n';
    }
};


int main() {
	BStringsWithTheSameLength solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using  namespace std;
typedef long long ll;
#define RAP(i, n) for(ll i=0;i<(n);i++)
#define FOR(i, a, b) for(ll i=(a);i<(b);i++)
ll gcd(ll a, ll b){
    ll temp;
    temp = a % b;
    while(temp!=0){
        a = b;
        b = temp;
        temp = a % b;
    }
    return b;
}
int main(){
    ll n, a, ans = 0, check;
    cin >> n;
    ll A[n], F[n], B[n];
    RAP(i, n){
        cin >> A[i];
    }
    F[0] = A[0], B[0] = A[n-1];
    FOR(i, 1, n){
        F[i] = gcd(F[i-1], A[i]);
        B[i] = gcd(B[i-1], A[n-1-i]);
    }
    RAP(i, n){
        if(i==0){
            check = B[n-2];
        }else if(i==n-1){
            check = F[n-2];
        }else{
            check = gcd(F[i-1], B[n-2-i]);
        }
        ans = max(ans, check);
    }

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


Measured memory_bytes: 2560
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
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 readonly long Mod = 1000000000 + 7;

        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var AB = Sarray();
            long A = AB[0];
            long B = AB[1];
            long ans = (long)Math.Ceiling((double)(B - 1) / (A - 1));

            WriteLine(ans);
            //Out.Flush();
        }
    }
}

Measured memory_bytes: 13396
#include<stdio.h>
main(){
  int a,b,cnt=0,n;
  int ab[2001]={0};
  int abcd[4001]={0};

  for(a=0;a<=1000;a++)for(b=0;b<=1000;b++)ab[a+b]++;
  for(a=0;a<=2000;a++)for(b=0;b<=2000;b++)abcd[a+b]+=ab[a]*ab[b];
 
  while( scanf("%d",&b)!=EOF)
  printf("%d\n",abcd[b]);
  return 0;
}

Measured memory_bytes: 628
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		try {
			int n = Integer.parseInt(sc.nextLine());

			List<Integer> list = new ArrayList<Integer>();
			for (int i = 0; i < n; i++) {
				list.add(sc.nextInt());
			}
			Collections.sort(list);

			System.out.println(list.get(list.size() - 1) - list.get(0));
		} finally {
			sc.close();
		}
	}
}

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

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    for(int i=0; i<n; i++){
        cin >> p[i];
    }
    int ans=0;
    for(int i=0; i<n; i++){
        if(p[i]==i+1)ans++;
    }
    for(int i=0; i<n-1; i++){
        if(p[i]==i+1&&p[i+1]==i+2){
            ans--;
            i++;
        }
    }
    cout << ans << endl;
}

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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(V),v.end()));
#define DUMP(v) REP(i, (v).size()) { cout << v[i]; if (i != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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

typedef long long ll;
using namespace std;



pair<bool, string> solve(string a0, string a1, string s) {
	string state = a0 + a1;
	FOR(i, 1, s.size()) {
		if (state[i] == 'S') {
			if (s[i] == 'o') {
				state += state[state.size() - 2];
			}
			else {
				if (state[state.size() - 2] == 'W') {
					state += 'S';
				}
				else {
					state += 'W';
				}
			}
		}
		else {
			if (s[i] == 'x') {
				state += state[state.size() - 2];
			}
			else {
				if (state[state.size() - 2] == 'W') {
					state += 'S';
				}
				else {
					state += 'W';
				}
			}
		}
	}
	int ok = 1;
	if (state[0] == 'S') {
		if (s[0] == 'o') {
			if (state[1] != state[state.size() - 2])ok = 0;
		}
		else {
			if (state[1] == state[state.size() - 2])ok = 0;
		}
	}
	else {
		if (s[0] == 'x') {
			if (state[1] != state[state.size() - 2])ok = 0;
		}
		else {
			if (state[1] == state[state.size() - 2])ok = 0;
		}
	}
	if (state[0] == state[state.size() - 1] && ok)return{ true, state.substr(0,state.size() - 1) };
	else return{ false,state.substr(0,state.size() - 1) };
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	string s;
	cin >> n >> s;
	vector<pair<bool, string>> p = { solve("S", "S", s), solve("S", "W", s), solve("W", "W", s), solve("W", "S", s) };

	REP(i, 4) {
		if (p[i].first) {
			cout << p[i].second << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(ll i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(ll i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
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;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int n;
vl vec;
ll calc(ll x){
    ll res=0;
    REP(i,n){
        res+=abs(vec[i]-(x+i+1));
    }
    return res;
}
int main(){
    cin>>n;
    vec.resize(n);
    REP(i,n){
        cin>>vec[i];
    }
    ll l=-1e6;
    ll r=INF;
    REP(i,500){
        ll p=(l*2+r)/3;
        ll q=(l+r*2)/3;
        ll x=calc(p);
        ll y=calc(q);
        if(x>y){
            l=p;
        }else{
            r=q;
        }
    }
    ll ans=LINF;
    FOR(i,-100,100){
        chmin(ans,calc(l+i));
    }
    cout<<ans<<endl;
    return 0;
}

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

int main() {
    string s;
    int w;
    cin >> s >> w;

    string ans;
    for (int i = 0; i < s.length(); i++) {
        if (i % w == 0) ans += s[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	int n;
	cin>>n;
	vi in(n);
	rep(i,n)cin>>in[i];
	rep(i,n)in[i]--;
	vi a(n),b(n);
	rep(i,n)a[i]=(i+1)*40000,b[n-i-1]=(i+1)*40000;

	rep(i,n){
		a[in[i]]+=i;
		b[in[i]]+=i;
	}
	
	rep(i,n-1)cout<<a[i]<<" ";cout<<a[n-1]<<endl;
	rep(i,n-1)cout<<b[i]<<" ";cout<<b[n-1]<<endl;
	
}









Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#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++)
typedef long long unsigned int llong;
#define n_max int(1e5)


int main(){
    int n;
    cin >> n;
    int A[n_max+1]={};
    int ans=0;
    REP(i,n){
        scanf("%d",&A[i+1]);
    }

    for(int i=1;i<=n;i++){
        if(A[i]==i){
            i+=1;
            ans+=1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
import numpy as np
import math
from fractions import gcd
n,m = map(int,input().split())
a = np.array(input().split(),dtype=int)
a /= 2

def t_per2(k):
    return format(k,'b')[::-1].find('1')

f = False
dcm = a[0]
t_2 = t_per2(a[0])
for i in a:
    dcm = (dcm*i)//gcd(dcm,i)
    if dcm > m or not t_per2(i) == t_2:
        f = True
        break

count = 0
if not f:
    count = math.ceil(int(m/dcm)/2)

print(count)


Measured memory_bytes: 25760
#include<stdio.h>
int min[2010]={0};
int a[2010],pos[2010];
int main(void){
	int n,x,max=0;
	scanf("%d%d",&n,&x);
	long long ans=0;
	for (int i=1;i<=n;i++) 
	{scanf("%d",&a[i]);min[i]=a[i];ans+=a[i];}
	for (int d=1;d<n;d++){
		long long sum=1ll*d*x;
		for (int i=1;i<=n;i++){
			int j=i-d<=0?i-d+n:i-d;
			if (a[j]<min[i]){
				min[i]=a[j];
			}
			sum+=min[i];
		}
		if (sum<ans) ans=sum;
	}
	printf("%lld\n",ans);
}

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

typedef long long ll;
#define rep(i,n) for(i=0;i<n;++i)
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define mp make_pair
#define pb push_back
#define fi first
#define sc second

int main(int argc, char const *argv[]) {
  int i,j;

  while(1){
    int n;
    cin >>n;
    if(n==0) break;

    std::vector<long> a(n+1);
    rep(i,n) scanf(" %ld", &a[i+1]);

    std::vector<long> sum(n+1); //a[1]~a[i]??????
    sum[0]=0;
    for(i=1; i<=n; ++i) sum[i]=sum[i-1]+a[i];

    long ans=-5000*100000-1;
    for(i=1; i<=n; ++i){
      for(j=i; j<=n; ++j){
        ans=max(ans,sum[j]-sum[i-1]);
      }
    }

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

Measured memory_bytes: 1288
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = Console.ReadLine();
            Console.WriteLine((N[0]==N[1]&&N[1]==N[2])||(N[1] == N[2] && N[2] == N[3])?"Yes":"No");
        }
    }
}


Measured memory_bytes: 11092
n,m,c = map(int,input().split())
lst_b = [int(i) for i in input().split()]
cnt = 0
for i in range(n):
    total = 0
    lst_a=[int(i) for i in input().split()]
    for j in range(m):
        total += lst_a[j]*lst_b[j]
    if total>-c:
        cnt+=1
print(cnt)

Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>

int
main()
{
    std::vector<int> values;
    std::size_t n = 0;
    int k = 0;
    std::cin >> n >> k;
    values.reserve(n);
    for (std::size_t i = 0; i<n; ++i)
    {
        int fp = 0;
        std::cin >> fp;
        values.emplace_back(fp);
    }

    std::sort(values.begin(), values.end());
    auto sum = std::accumulate(values.begin(), std::next(values.begin(), k), 0);

    std::cout << sum << "\n";
    return 0;
}


Measured memory_bytes: 3612
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    Scanner in = new Scanner(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    C solver = new C();
    solver.solve(1, in, out);
    out.close();
  }

  static class C {
    public void solve(int testNumber, Scanner in, PrintWriter out) {
      int N = in.nextInt();
      int M = in.nextInt();
      Set<Integer> set = new HashSet<>();
      int[] h = new int[N];

      for (int i = 0; i < N; i++) {
        h[i] = in.nextInt();
      }

      for (int j = 0; j < M; j++) {
        int a = in.nextInt();
        int b = in.nextInt();

        if (h[a - 1] == h[b - 1]) {
          set.add(a);
          set.add(b);
        } else {
          set.add(h[a - 1] < h[b - 1] ? a : b);
        }
      }
      out.print(N - set.size());
    }

  }
}



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

#define int long long
#define rep(i,a,n) for(int i = a; i < n; i++)
#define pb push_back
#define eb emplace_back
#define dump(x) cout << #x << " = " << (x) << endl
#define chk() cout << "now" << endl;
#define SORT(c) sort((c).begin(), (c).end())
#define SORTG(c) sort((c).begin(), (c).end(), greater<int>());
#define fi first
#define se second
  
typedef pair<int,int> P;
typedef vector<int> vi;

int n;
signed main() {
    cin>>n;
    vi p(n+1);
    p[0]=0;
    rep(i,0,n) cin>>p[i+1];


    int ans=0;
    for(int i=2;i<=n-1;i++) {
        if((p[i-1]<p[i] and p[i]<p[i+1]) or (p[i-1]>p[i] and p[i]>p[i+1])) {
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
using namespace std;

int main() {
  string a[3];
  for (size_t i = 0; i < 3; i++) {
    /* code */
    cin >> a[i];
  }
  cout << a[0][0] << a[1][1] << a[2][2] << endl; 
}


Measured memory_bytes: 256
from sys import setrecursionlimit
setrecursionlimit(10 ** 6)

n = int(input())
ab = [list(map(lambda x:int(x)-1, input().split())) for _ in range(n-1)]

e = [[] for _ in range(n)]

p = [0] * n
c = [0] * n
d = [0] * n

for a, b in ab:
    e[a].append(b)
    e[b].append(a)

me = 0

q = [0]
p[0] = -1

while q:
    x = q.pop()
    temp = c[x]
    color = 1
    me = max(me, len(e[x]))
    #print(x, temp)
    for y in e[x]:
        if color == temp:
            color += 1
        if d[y] == 0:
            q.append(y)
            c[y] = color
            p[y] = x
            color += 1
    d[x] = 1

#print(c)
#print(p)

print(me)

for a, b in ab:
    if p[a] == b:
        print(c[a])
    else:
        print(c[b])

Measured memory_bytes: 84952
A = int(input())
B = int(input())
C = int(input())

X = int(input())

an = 0
#500
for i in range(A+1):
    if 500*(A-i) <= X:
        a = X - 500*(A-i)

        for j in range(B+1):
            if 100*(B-j) <= a:
                b = a - 100*(B-j)

                for k in range(C+1):
                    if 50*(C-k) <= b:
                        c = b - 50*(C-k)

                        if c == 0:
                            an += 1

print(an)


Measured memory_bytes: 3064
#include <cstdio>
#include <string>
#include <math.h>
using namespace std;

int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    int b_keta=1;
    for(b_keta;int(b/pow(10,b_keta))>=1;b_keta++);
    int c;
    c= a*(pow(10,b_keta)) + b;
    int i;
    for(i=0; c > i*i ; i++);
    if(c== i*i) printf("Yes\n");
    else printf("No\n");
}

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

using namespace std;

struct UnionFind
{
  vector< int > data;

  UnionFind(int sz)
  {
    data.assign(sz, -1);
  }

  bool unite(int x, int y)
  {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }

  int find(int k)
  {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  int size(int k)
  {
    return (-data[find(k)]);
  }
};

int main()
{
  int N;
  while(cin >> N, N) {
    map< string, int > conv;
    bool mat[201][201] = {{}}, beet[201][201] = {{}};
    int M = 200;
    UnionFind tree(M + M);

    for(int i = 0; i < M; i++) beet[i][i] = true;

    for(int i = 0; i < N; i++) {
      string S;
      cin >> S;
      string T = S.substr(S.find('-') + 1);
      S = S.substr(0, S.find('-'));
      if(!conv.count(S)) conv[S] = conv.size() - 1;
      if(!conv.count(T)) conv[T] = conv.size() - 1;
      int a = conv[S], b = conv[T];
      mat[a][b] = beet[a][b] = true;
      tree.unite(a + M, b);
      tree.unite(b + M, a);
    }
    for(int i = 0; i < M; i++) {
      for(int j = i + 1; j < M; j++) {
        if([&]()
        {
          bool flag = false;
          for(int k = 0; k < M; k++) {
            if(mat[i][k] & mat[j][k]) flag = true;
            if(mat[k][i] & mat[k][j]) flag = true;
            if(mat[i][k] & mat[k][j]) return (false);
            if(mat[j][k] & mat[k][i]) return (false);
          }
          return (flag);
        }())
          beet[i][j] = beet[j][i] = true;
      }
    }
    for(int k = 0; k < M; k++) {
      for(int i = 0; i < M; i++) {
        for(int j = 0; j < M; j++) {
          beet[i][j] |= beet[i][k] & beet[k][j];
        }
      }
    }

    int Q;
    cin >> Q;
    cout << conv.size() << endl;
    while(Q--) {
      string S;
      cin >> S;
      string T = S.substr(S.find('-') + 1);
      S = S.substr(0, S.find('-'));
      if(!conv.count(S) || !conv.count(T)) {
        cout << "NO" << endl;
      } else {
        int a = conv[S];
        int b = conv[T];
        if(tree.find(a) != tree.find(b + M) || tree.find(b) != tree.find(a + M) || !beet[a][b]) {
          cout << "NO" << endl;
        } else {
          cout << "YES" << endl;
        }
      }
    }

  }
}

Measured memory_bytes: 3192
#include<stdio.h>
int main(){
  int a, b, d, r;
  double f;
  scanf("%d %d", &a, &b);
  d = a / b;
  r = a % b;
  f = (double)a / b;
  printf("%d %d %lf\n", d, r, f);
  return 0;
}


Measured memory_bytes: 2136
#include <bits/stdc++.h>
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
using namespace std;
typedef long long int ll;
const int k_mod = 1e9 + 7;
void chmin( int &a, int b ){
	if (a > b)
		a = b;
	return;
}

int main( void ){
	int n;
	cin >> n;
	int array[ 3 ] = {};
	int dp[ 3 ] = {};
	int temp[3];
	rep( i, 0, n ){
		rep( j, 0, 3 ){
			cin >> array[ j ];
		}
		temp[0] = max( dp[ 1 ], dp[ 2 ] );
		temp[1] = max( dp[ 0 ], dp[ 2 ] );
		temp[2] = max( dp[ 1 ], dp[ 0 ] );
		dp[ 0 ] = array[ 0 ] + temp[0];
		dp[ 1 ] = array[ 1 ] + temp[1];
		dp[ 2 ] = array[ 2 ] + temp[2];
	}
	printf( "%d\n", max( dp[ 0 ], max( dp[ 1 ], dp[ 2 ] )));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

int main() {
    int n;
    cin >> n;
    int m[n+1];
    int b[n];
    for(int i = 0;i < n+1;i++){
        cin >> m[i];
    }
    for(int i = 0;i < n;i++){
        cin >> b[i];
    }
    ll ans = 0;
    for(int i = 0;i < n;i++){
        ans +=min(m[i],b[i]);
        b[i] -= min(m[i],b[i]);
        m[i] -= min(m[i],b[i]);
        ans += min(m[i+1],b[i]);
        m[i+1] -= min(m[i+1],b[i]);
    }
    cout << ans << endl;
}




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

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (T& x : v)
    is >> x;
  return is;
}

ostream& operator<<(ostream& os, const pair<char, int>& unit) {
  return os << unit.first << "^" << unit.second;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i)
      os << ' ' << v[i];
  }
  return os;
}

const int N = 1010, M = 200010;

int n, m;
bool vis[N];
vector<pair<int, int>> g[N], ig[N];

bool ans[M];

void reachable(int u) {
  vis[u] = true;
  for (const auto& pr : g[u])
    if (!vis[pr.first])
      reachable(pr.first);
}

int main() {
#ifdef LBT
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    int u, v;
    cin >> u >> v;
    g[u].emplace_back(v, i);
    ig[v].emplace_back(u, i);
  }

  for (int i = 1; i <= n; ++i) {
    for (int rep = 0; rep < 2; ++rep) {
      memset(vis, 0, sizeof(vis));
      vis[i] = true;
      for (const auto &pr : g[i])
        if (vis[pr.first])
          ans[pr.second] = true;
        else
          reachable(pr.first);
      reverse(g[i].begin(), g[i].end());
    }
  }

  for (int i = 1; i <= n; ++i) {
    memset(vis, 0, sizeof(vis));
    reachable(i);
    for (const auto& pr : ig[i]) {
      int j, id;
      tie(j, id) = pr;
      ans[id] ^= vis[j];
    }
  }
  for (int i = 1; i <= m; ++i)
    cout << (ans[i] ? "diff\n" : "same\n");

#ifdef LBT
  LOG("Time: %dms\n", int ((clock()
      -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}



Measured memory_bytes: 7552
#include<stdio.h>

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

    char s[N+1];
    char t[N+1];
    scanf("%s",s);
    scanf("%s",t);

    int i;
    for (i=0;i<N;i++){
           printf("%c",s[i]);
           printf("%c",t[i]);
    }

    printf("\n");
    return 0;
}

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
typedef pair<int,int> P;

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

const int SZ=1300000;
bool isPrime[SZ];

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

    for(int i=2;i<SZ;i++) isPrime[i]=true;
    for(int i=2;i<SZ;i++){
        if(!isPrime[i]) continue;
        for(int j=2*i;j<SZ;j+=i) isPrime[j]=false;
    }
    
    int n;
    while(cin>>n,n)
    {
        int p1=n,p2=n;
        while(!isPrime[p1]) p1++;
        while(!isPrime[p2]) p2--;
        cout<<p1-p2<<endl;
    }

}



Measured memory_bytes: 4356
import java.util.*;

public class Main{
    public static void main(String[]args){
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();
        
        if(a + b == c){
            System.out.println("Yes");
        }else if(b + c == a){
            System.out.println("Yes");
        }else if(a + c == b){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21844
import java.util.*;
public class Main {
	public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
	int T = sc.nextInt();
	int A = sc.nextInt();
	double [] hairetu= new double[N];
	int []H = new int[N];
	for(int i=0;i<N;i++){
	    H[i] = sc.nextInt(); 
		hairetu[i] = T-H[i]*0.006;
	}
	double []hairetu2 = new double[N];
	for(int i=0;i<N;i++) {
		double ans = A - hairetu[i];
		hairetu2[i] = Math.abs(ans);
	}
	int i;
	int p=1;
	double min = hairetu2[0];
	for(i=1;i<N;i++) {
		if(min>hairetu2[i]){
			min=hairetu2[i];
			p=i;
		  }
	   }
	if(p==1) {System.out.println(1);}
	else {System.out.println(p+1);
	}	}
  } 


Measured memory_bytes: 22868
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <cstring>

using namespace std;
//author_name:
//date://
//title:
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define eb emplace_back
#define mp make_pair
//tsurune
typedef pair<int,int> pii;
typedef unsigned int uint;

int n,a,con=0; 

int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a;
		if(a!=i) con++;
	}
	if(con!=0&&con!=2) cout<<"NO"<<endl;
	else cout<<"YES"<<endl;
	return 0;
} 

Measured memory_bytes: 256
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

#include<bits/stdc++.h>
using namespace std;

#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

const int N=2e5+5;
const int mod=1e9+7;

signed main(){
    FastIO;
    int a;
    cin>>a;
    cout<<a+a*a+a*a*a;
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod = 1000000007;

ll r(ll x, ll y) {
  if (y == 0) return 1;
  else if (y % 2 == 0) return r(x, y/2) * r(x, y/2) % mod;
  else return x * r(x, (y-1)/2) % mod * r(x, (y-1)/2) % mod;
}


int main() {
  string s;
  cin >> s;
  int n = s.size();
  int P = 0, G = 0;
  vector<int> pp(n);
  for (int i = 0; i < n; i++) {
    if (s[i] == 'g') {
      G++;
      pp[i] = G;
    }
    else {
      G--;
      pp[i] = G;
    }
  }
  cout << pp[n-1]/2 <<endl;
}

Measured memory_bytes: 896
N=readline.to_i
points = N.times.each.map do |i|
  readline.chomp.split.map(&:to_i)
end

p1 = points[0]
parity = (p1[0]+p1[1])%2
if points.any? {|x,y| (x+y)%2 != parity }
  puts -1
  exit
end

def direc(x, y)
  res = []
  (0..30).reverse_each do |k|
    if y > -x and y > x
      res[k] = :U
      y -= 2**k
    elsif y > -x and y < x
      res[k] = :R
      x -= 2**k
    elsif y < -x and y > x
      res[k] = :L
      x += 2**k
    elsif y < -x and y < x
      res[k] = :D
      y += 2**k
    end
  end
  #raise unless x == 0 and y == 0
  res
end

if parity == 1
  puts 31
  puts (0..30).each.map {|k| 2**k}.join(' ')
  points.each do |x,y|
    puts direc(x,y).join
  end
else
  puts 32
  puts "1 " + (0..30).each.map {|k| 2**k}.join(' ')
  points.each do |x,y|
    puts "R"+direc(x-1,y).join
  end
end



Measured memory_bytes: 2428
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;

int main(void){
	string S;
	cin >> S;
	int l = S.size();

	int res = 0;
	int tmp = 0;
	for(int i = 0; i < l; i++){
		if(i&1) res += (S[i] == '0');
		else res += (S[i] == '1');
	}
	for(int i = 0; i < l; i++){
		if(i&1) tmp += (S[i] == '1');
		else tmp += (S[i] == '0');
	}
	res = min(res, tmp);

	cout << res << '\n';

	return 0;
}

Measured memory_bytes: 512
n, m = raw_input().split(' ');
n = int(n);
m = int(m);
if ((n == 1) & (m == 1)):
    print 1;
elif (n == 1):
    print m - 2;
elif (m == 1):
    print n - 2;
else :
    print n * m - 2 * (n - 1) - 2 * (m - 1);

Measured memory_bytes: 2568
def calculate(n, arr):
    result = [0] * len(arr)

    for index, value in enumerate(arr):
        result[value - 1] = str(index + 1)

    return result


N = int(input())
S = input().split(' ')
arr = list(map(int, list(S)))
result = calculate(N, arr)


print(' '.join(result))


Measured memory_bytes: 21860
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    S=[None]+list(map(int,input()))
    n=len(S)-1

    # check
    if(not (S[1]==1 and S[n-1]==1)):
        print(-1)
        return
    if(S[n]==1):
        print(-1)
        return
    if(any(S[i]!=S[n-i] for i in range(1,n-1))):
        print(-1)
        return

    v=1
    nv=2
    for i in range(n-1,0,-1):
        print(v,nv)
        nv+=1
        if(S[i]==1): v=nv-1
resolve()

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

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define lb lower_bound
#define ub upper_bound

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

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b ? gcd(b,a%b) : a;}

//head
char g[1001][1001];
int r, c;
int dp[1001][1001];
int solve(int i, int j) {
	if(dp[i][j] > -1) return dp[i][j];
	if(j == c - 1 && i == r - 1){
		return dp[i][j] = 1;
	}
	int num = 0;
	int num2 = 0;
	if(i + 1 < r && g[i+1][j] == '.') {
		num = solve(i+1, j) % mod;
	}
	if(j + 1 < c && g[i][j+1] == '.') {
		num2 = solve(i, j + 1) % mod;
	}
	return dp[i][j] = (num + num2) % mod;
}
int main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

	cin >> r >> c;
	memset(dp, -1, sizeof(dp));
	for(int i = 0; i < r; ++i) {
		string s;
		cin >> s;
		for(int j = 0; j < c; j++) {
			g[i][j] = s[j];
		}
	}

	cout << solve(0,0) << endl;

	return 0;
}


Measured memory_bytes: 5248
#include<iostream>
#include <algorithm>
#include<queue>
using namespace std;


char s[200005];
int n, k, c;
int main() 
{
	cin >> n >> k >> c >> s;
	vector<int> l, r;
	int temp = 0x3f3f3f3f;
	for (int i = 0; i < n; i++)
	{
		if (l.size() == k)
			break;
		if (s[i] == 'o' && temp >= c)
		{
			l.push_back(i);
			temp = 0;
		}
		else
			temp++;
	}
	temp = 0x3f3f3f3f;
	for (int i = n - 1; i >= 0; i--)
	{
		if (r.size() == k)
			break;
		if (s[i] == 'o' && temp >= c)
		{
			r.push_back(i);
			temp = 0;
		}
		else
			temp++;
	}
  	reverse(r.begin(),r.end());
	for (int i = 0; i < k; i++)
	{
		if (l[i] == r[i])
			cout << l[i]+1 << endl;
	}
	return 0;
}


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

int main(){

  int n,m,menor=1000000000,r,x_aluno[150],y_aluno[150],x_local[150],y_local[150],total[150];

  scanf("%d %d", &n,&m);

  for(int i=0;i<n;i++){
    scanf("%d %d",&x_aluno[i],&y_aluno[i]);
  }
  for(int i=0;i<m;i++){
    scanf("%d %d",&x_local[i],&y_local[i]);
  }

  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
        total[j]=abs(x_aluno[i]-x_local[j]) + abs(y_aluno[i]-y_local[j]);
    }
    for(int k=0;k<m;k++){
      if(total[k]<menor){
        menor=total[k];
        r=k+1;
      }
    }
    printf("%d\n",r);
    for(int o=0;o<m+n;o++){
      menor=1000000000;
      total[o]=0;
    }

  }

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long 
#define mp make_pair
#define pb push_back
#define ld long double
#define pii pair<int,int>
#define sz(x) (int)x.size()
#define piii pair<pii,pii>
#define precise cout<<fixed<<setprecision(10)
#define st first
#define nd second
#define ins insert
#define vi vector<int>
#define BOOST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
const int MAX=1e5+5;
int B[MAX][2];
int licznik=1;
int ans=0,L;
void dfs(int u,int dist){
	for (int i=0;i<2;i++){
		if (!B[u][i])ans^=((L-dist)&-(L-dist));
		else dfs(B[u][i],dist+1);
	}
}
int32_t main()
{
  BOOST;
  int n;
  cin>>n>>L;
  for (int i=1;i<=n;i++){
  	string s;
  	cin>>s;
  	for (int i=0,parent=1,bit;i<sz(s);i++,parent=B[parent][bit]){
  		if (!B[parent][bit=(s[i]&1)])B[parent][bit]=++licznik;
  	}
  }
  //1 to root;
  	dfs(1,0);
  cout<<(ans?"Alice":"Bob");
  return 0;
}


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long long ll;
const int INT_INF = 1e9;
const ll INF = 1LL << 30;
const ll MOD = 1e9 + 7;


int main() {
    int n; cin >> n;
    V<ll> x(n), y(n), h(n);
    for(int i = 0; i < n; i++) cin >> x[i] >> y[i] >> h[i];

    int s;
    for(int i = 0; i < n; i++){
        if(h[i]){
            s = i;
            break;
        }
    }

    for(int i = 0; i <= 100; i++){
        for(int j = 0; j <= 100; j++){
            bool flag = true;
            ll H = max(abs(x[s] - i) + abs(y[s] - j) + h[s], 0LL);
            for(int k = 0; k < n; k++){
                ll tmp = max(H - abs(x[k] - i) - abs(y[k] - j), 0LL);
                if(tmp != h[k]){
                    flag = false;
                    break;
                }
            }
            if(flag){
                cout << i << " " << j << " " << H << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))

a_sum = sum(A)

xor = 0
for i in range(N//2):
    xor += A[2*i+1]*2

rain=[0]*N
rain[0] = a_sum-xor

for i in range(1,N):
    rain[i] = 2*A[i-1]-rain[i-1]

print(" ".join(map(str,rain)))

Measured memory_bytes: 84580