akhauriyash/Code-Regression huggingface dataset:
S = input()
T = ''
Z = [0 for i in range(len(S))]
u = []
v = [-1]

for i in range(len(S)-1):
  if S[i] == 'R' and S[i+1] == 'L':
    Z[i] = 1
    Z[i+1] = 1
    u.append(i)
  elif S[i] == 'L' and S[i+1] == 'R':
    v.append(i)
v.append(len(S)-1)

for i in range(len(u)):
  Z[u[i]] = (u[i] - v[i] + 1) // 2 + (v[i+1] - u[i]) // 2
  Z[u[i]+1] = v[i+1] - v[i] - Z[u[i]]

for i in range(len(Z)):  
  print(Z[i], end = ' ')

Measured memory_bytes: 8748
#include <stdio.h>
#define REP(i, n) for(i = 0; i < n; ++i)
#define FOR(i, a, b) for(i = a; i < b; ++i)

void arrive(int i, int N, int c[N - 1], int s[N -1], int f[N - 1]);

int main(){
    int N, i;
    scanf("%d", &N);
    int c[N - 1], s[N - 1], f[N - 1];

    REP(i, N - 1){
        scanf("%d %d %d", &c[i], &s[i], &f[i]);
    }
    REP(i, N){
        arrive(i, N, c, s, f);
    }
    return 0;
}

void arrive(int i, int N, int c[N - 1], int s[N - 1], int f[N - 1]){
    int T = 0;
    int k;
    FOR(k, i, N - 1){
        if(T <= s[k]){
            T = s[k];
        }else{
            int wait = (T - s[k]) % f[k] > 0 ? 1 : 0;
            T = s[k] + ((T - s[k])/f[k] + wait) * f[k];
        }
        T += c[k];
    }
    printf("%d\n", T);
}

Measured memory_bytes: 128
#include <iostream>
#define N 1000
using namespace std;
int main(){
  int n,P,Q,R,C,t[N],p[N],q[N],r[N],c[N],i,flag;
  while(1){
    cin >> n;
    if(n==0) break;
    for(i=0;i<n;i++){
      cin >> t[i] >> p[i] >> q[i] >> r[i];
      c[i]=(p[i]+r[i])*4+q[i]*9;
    }
    cin >> P >> Q >> R >> C;
    flag=0;
    for(i=0;i<n;i++){
      if(p[i]<=P&&q[i]<=Q&&r[i]<=R&&c[i]<=C){
	cout << t[i] << endl;
	flag=1;
      }
    }
    if(flag==0) cout << "NA" << endl;;
  }
  return 0;
}

Measured memory_bytes: 1180
#include <stdio.h>
#include <string.h>

int main(void) {
  int i;
  int k;//日数
  int count=0;//oの数
  char str[16];

  scanf("%s", str);

  k=strlen(str);

  for(i=0; i<k; i++){
    if(str[i]=='o'){
      count++;
    }
  }
  // printf("%d\n", count);
  if((15-k)+count>=8){
    printf("YES\n");
  }else{
    printf("NO\n");
  }

  return 0;
}


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

int main(int argc, char const *argv[]) {
    int n, m, l;
    cin >> n >> m >> l;
    int A[n][m];
    int B[m][l];
    long long int C[n][l];


    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> A[i][j];
        }
    }

    for (int j = 0; j < m; j++) {
        for (int k = 0; k < l; k++) {
            cin >> B[j][k];
        }
    }

    for (int i = 0; i < n; i++) {
        for (int k = 0; k < l; k++) {
            C[i][k] = 0;
            for (int j = 0; j < m; j++) {
                C[i][k] += A[i][j] * B[j][k]; 
            }
        }
    }


    for (int i = 0; i < n; i++) {
        for (int k = 0; k < l; k++) {
            if (k != 0) {
                cout << ' ' << C[i][k];
            } else {
                cout << C[i][k];
            }
        }
        cout << endl;
    }



    return 0;
}



Measured memory_bytes: 3228
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdint>
#include <limits>
using namespace std;

/**
* 10進数 v を base進数の文字列へ変換する。
* @param [in] v    10進数の整数
* @param [in] base 変換した 2~36 のN進数の値
* @return base進数へ変換した文字列
*/
template <typename TypeInt>
std::string Itoa(const TypeInt v, int base)
{
    static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    string ret;
    static numeric_limits<TypeInt> t;
    TypeInt n = v;
    if (t.is_signed)
    {
        if (v < 0)
            n *= -1;
    }

    while (n >= base)
    {
        ret += table[n % base];
        n /= base;
    }
    ret += table[n];
    if (t.is_signed)
    {
        if (v < 0 && base == 10)
            ret += '-';
    }
    // 文字列の順番を逆にする
    std::reverse(ret.begin(), ret.end());

    return ret;
}

int main(void)
{
    uint64_t n;
    cin >> n;
    int k;
    cin >> k;

    int length = (Itoa(n,k)).length();

    cout << length << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int A, B, C;
  cin >> A >> B >> C;
 
  for(int i = 1; i < B; i++){
    if(A * i % B == C){
    cout << "YES" << endl;
    exit(0);
    }
  }
  cout << "NO" << endl;
}

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


int main(void)
{
	string s;
	int ans =700;
	cin >> s;
	if (s[0] == 'o') ans  += 100;
	if (s[1] == 'o') ans += 100;
	if (s[2] == 'o') ans += 100;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

N = input()
ans = 0
for i in [0] * 5:
    P = input()
    num = N / P
    if N % P:
        num += 1
    ans = max(ans, num)
print ans + 4


Measured memory_bytes: 2812
#include <bits/stdc++.h>
using namespace std;
const int MAX=1e6+9;

bool prime[MAX];

void pre()
{
    prime[0]=false;
    prime[1]=false;
    for(int i=2;i*i<=MAX;i++)
    {
        if(prime[i])
            for(int j=i*i;j<MAX;j+=i)
                prime[j]=false;
    }
}

int main() {
	// your code goes here
	fill(prime,prime+MAX,true);
	pre();
	long long int n;
  	cin>>n;
  	for(int i=n;i<MAX;i++)
  	if(prime[i]){
  	cout<<i<<endl;break;}
  	
	return 0;
}


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

int main(){
  int n,w;
  string s ="No";
  vector<vector<int>> a(3, vector<int>(3));
  rep(i,3) rep(j,3) cin >> a[i][j];
  cin >> n;
  rep(i,n){
    cin >> w;
    rep(i,3) rep(j,3) if(w==a[i][j]) a[i][j]=1000;
  }
  if(a[0][0] ==1000&&a[0][1]==1000&&a[0][2] ==1000) s="Yes";
  if(a[1][0] ==1000&&a[1][1]==1000&&a[1][2] ==1000) s="Yes";
  if(a[2][0] ==1000&&a[2][1]==1000&&a[2][2] ==1000) s="Yes";
  if(a[0][0] ==1000&&a[1][1]==1000&&a[2][2] ==1000) s="Yes";
  if(a[0][2] ==1000&&a[1][1]==1000&&a[2][0] ==1000) s="Yes";
  if(a[0][0] ==1000&&a[1][0]==1000&&a[2][0] ==1000) s="Yes";
  if(a[0][1] ==1000&&a[1][1]==1000&&a[2][1] ==1000) s="Yes";
  if(a[0][2] ==1000&&a[1][2]==1000&&a[2][2] ==1000) s="Yes";
  cout << s <<endl;
}

Measured memory_bytes: 256
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
int n,m;
int ans=0;
int cnt=0,cntt=0;
string a[100];
string b[100];
cin >>n;
for(int i=0;i<n;i++)
cin>>a[i];
cin>>m;
for(int i=0;i<m;i++)
cin>>b[i];
for (int i=0;i<n;i++)
{cnt=0;
 for (int j=0;j<n;j++) 
 {if (a[i]==a[j])
  cnt++;}
for (int k=0;k<m;k++)
{if(a[i]==b[k])
 cnt--;}
if (cnt >cntt)
cntt =cnt;}
cout<<cntt;
system("pause");
return 0;}

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

int main() {
  int a = 0, b = 0;
  string s, t = "", u = "";
  cin >> s;
  rep(i, s.size()){
    if(i % 2 == 0){
      t += '1';
      u += '0';
    }
    else{
      t += '0';
      u += '1';
    }
  }
  rep(i, s.size()){
    if(s[i] != t[i]) ++a;
    if(s[i] != u[i]) ++b;
  }
  cout << min(a, b) << endl;
  return 0;
}

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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 10;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

bool contain(set<P> &s, P a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);


void print_line(vector<ll> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}


typedef priority_queue<long long, vector<long long>, greater<long long>> PQ_ASK;
const int mod = 1000000007;

int main() {

    int n;
    cin >> n;

    for (int i = 0; i < (1ll << n); i++) {
        printf("%d:", i);
        for (int j = 0; j < n; j++) {
            if ((i >> j) & 1) {
                printf(" %d", j);
            }
        }
        cout << endl;
    }


}



Measured memory_bytes: 3240
n,q=map(int,input().split())
s=input()
count=[0]*n
for i in range(1,n):
    count[i]+=count[i-1]
    if s[i-1:i+1]=="AC":
        count[i]+=1
for i in range(q):
    l,r=map(int,input().split())
    print(count[r-1] - count[l-1])

Measured memory_bytes: 7700
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(void) {
    int N;
    double S;
    scanf("%d",&N);
    if(N==1){
    	S=1.0;
    	}else{
    		if(N%2==0){
    			S=1.0/2.0;
    		}else{
    			S=(N+1)/(N*2.0);
    		}
    	}
    printf("%1.10lf\n",S);
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main()
{
	int participants, total_days, remaining_chocolates, x, ans, i, m;
	scanf("%d %d %d", &participants, &total_days, &remaining_chocolates);
	ans=0;
	for(i=0; i<participants; i++)
	{
		scanf("%d", &x);
		for(m=0; m<total_days; m=m+x)
		{
			ans++;
		}
	}
	printf("%d\n", ans+remaining_chocolates);
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	ll lx = 0, ly = 0, rx, ry, n;
  cin>>rx>>ry>>n;
  rep(i, n){
    ll a, b, c;
    cin>>a>>b>>c;
    if(c==1) chmax(lx, a);
    if(c==2) chmin(rx, a);
    if(c==3) chmax(ly, b);
    if(c==4) chmin(ry, b);
  }
  chmax(rx, lx); chmax(ry, ly);
  cout<<(rx-lx)*(ry-ly)<<endl;
  
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;

int** makeCombi(int n){
  int** comb;
  long size,ii,jj;
  size = 1;

  for(ii=1;ii<=n;ii++){
    size *= ii;
  }
  //size = pow(n,n);
  //n*n分領域確保
  comb = (int**)malloc(sizeof(int*)*size);
  
  for(ii=0;ii<n;ii++){
    comb[ii] = (int*)malloc(sizeof(int)*n);
  }

  long* scale;
  scale = (long*)malloc(sizeof(long)*n);

  for(ii=0;ii<n;ii++){
    scale[ii] = pow(n,ii);
    //cout << scale[ii] <<endl;
  }
  
  for(ii=0;ii<pow(n,n);ii++){
    //cout << "ii=" << ii << "  ";
    for(jj=0;jj<n;jj++){
      //cout << scale[jj] << "  ";
      comb[ii][jj] = ii / scale[jj] ;
      cout << comb[ii][jj] << ",";
    }
    cout << endl;
  }

}

int main(){
  vector<int> time;
  int ii,jj,kk,mm,ll;
//  int** comb;
  time.resize(5);
//  comb = makeCombi(3);
//  for(ii = 0;ii<3;ii++){
//    for(jj=0;jj<3;jj++){
//      cout << comb[ii][jj] << " ";
//    }
//    cout << endl;
//  }
//  set<int> s;
//  for(ii=0;ii<5;ii++){
//    for(jj=0;jj<5;jj++){
//      for(kk=0;kk<5;kk++){
//	for(ll=0;ll<5;ll++){
//	  for(mm=0;mm<5;mm++){
//	    s.clear();
//	    s.insert(ii);
//	    if(s.find(kk
//	  }
//	}
//      }
//    }
//  }
  for(ii=0;ii<=4;ii++){
    cin >> time[ii];
  }
  int lastPos,max=0,tmp;
  for(ii=0;ii<=5;ii++){
    tmp = 10 - time[ii] % 10;
    if(tmp == 10){
      continue;
    }
    if(max < tmp){
      max = tmp;
      lastPos = ii;
    }
  }

  int sum = 0;
  for(ii=0;ii<=4;ii++){
    if(ii == lastPos){
      continue;
    }
    sum += time[ii];
    if(time[ii] % 10 != 0){
      sum += 10 - (time[ii] % 10);
    }
  }

  sum += time[lastPos];

  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
n, m = gets.chomp.split(" ").map(&:to_i)
n_arr = []
m_arr = []
n.times do
    x = gets.chomp.split(" ").map(&:to_i)
    n_arr << x
end
m.times do 
    y = gets.chomp.split(" ").map(&:to_i)
    m_arr << y
end
n_arr.each do |i|
    ans = Float::INFINITY
    st = 0
    arr = []
    #p i
    while true
        goukei = (i[0] - m_arr[st][0]).abs + (i[1] - m_arr[st][1]).abs
        #p goukei
        if ans > goukei
            arr << st
            ans = [ans,goukei].min
        end
        
        if st + 1== m_arr.size
            break
        end
        st += 1
    end
    puts arr.pop + 1
end

Measured memory_bytes: 14180
n = gets.chomp.to_i
a = []
a[0] = gets.chomp.split(" ").map(&:to_i)
a[1] = gets.chomp.split(" ").map(&:to_i)

s_x = 0
s_y = 0

max = 0
c = []
c[0] = []
c[1] = []
2.times do |i|
  n.times do |j|
    if i == 0 && j == 0
      c[i][j] = a[i][j]
    elsif i - 1 < 0 && j - 1 >= 0
      c[i][j] = c[i][j-1] + a[i][j]
    elsif i - 1 >= 0 && j - 1 < 0
      c[i][j] = c[i-1][j] + a[i][j]
    elsif i - 1 >= 0 && j - 1 >= 0
      c[i][j] = [c[i][j-1], c[i-1][j]].max + a[i][j]
    end
  end
end

p c[1][n-1]

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

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

  if (A + B > 9){
    cout << "error" << endl;
  }
  else
  {
    cout << A + B << endl;
  }
  
}

Measured memory_bytes: 3492
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

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

    ll A,B,C,K;
    cin >> A >> B >> C >> K;
    int cnt = 0;
    while(A >= B){
        B*=2;
        cnt++;
    }
    while(B >= C){
        C *= 2;
        cnt++;
    }
    cout << ((cnt <= K) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3664
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda x: [ni() for _ in range(x)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda x: [na() for _ in range(x)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda x: [ns() for _ in range(x)]
nas = lambda: stdin.readline().split()

from collections import defaultdict

a, b = na()

def prime_fact(n):
    f = defaultdict(int)
    i = 2
    while i * i <= n:
        while n % i == 0:
            f[i] += 1
            n //= i
        i += 1
    if n != 1:
        f[n] += 1

    return f

c, d = prime_fact(a), prime_fact(b)
e = [i if i in d.keys() else 1 for i in c.keys()]
e.append(1)
f = set(e)
print(len(f))

Measured memory_bytes: 38512
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())

#define pb emplace_back
#define fi first
#define se second

using namespace std;

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

const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> void UNIQUE(vector<T> &a){ a.erase(unique(a.begin(), a.end()), a.end()); }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll in(){long long int x; scanf("%lld", &x); return x;}
ld fin(){double x; scanf("%lf", &x); return x;}
char yuyushiki[1000010]; string stin(){scanf( "%s", yuyushiki ); return yuyushiki;}

// head

const ll N = 1000000000;

ll cnt = 0;

bool ask(ll a){
  assert(cnt++ < 64);
  assert(1 <= a && a <= N*N);
  printf("? %lld\n", a);
  fflush(stdout);
  string s = stin();
  return s[0] == 'Y';
}

void answer(ll a){
  printf("! %lld\n", a);
  fflush(stdout);
}

void kiri(){
  ll d = 1;
  ll c = 2;
  while(1){
    if(ask(c)){
      answer(d);
      return;
    }
    c *= 10;
    d *= 10;
  }
}

int main(){

  ll d = 1;
  while(1){
    if(!ask(d)){
      break;
    }
    if(d > N){
      kiri();
      return 0;
    }
    d *= 10;
  }
  
  ll lb = d/10-1, ub = d;
  while(ub - lb > 1){
    ll md = (lb + ub) / 2;
    if(ask(md * 10)){
      ub = md;
    } else {
      lb = md;
    }
  }

  answer(ub);
  
  return 0;
}


Measured memory_bytes: 692
M, K = map(int, input().split())
if 2**M <= K:
    print("-1")
else:
    if M == 0:
        if K == 0:
            print("0 0")
        else:
            print("-1")
    elif M == 1:
        if K == 0:
            print("0 0 1 1")
        else:
            print("-1")
    else:
        ret = ""
        for i in range(2**M):
            if i != K:
                ret += str(i)+" "
        ret += str(K) + " "
        for i in range(2**M-1, -1, -1):
            if i != K:
                ret += str(i)+" "
        ret += str(K)
        print(ret)

Measured memory_bytes: 7828
#include<iostream>
using namespace std;
int mp[2][31][31]={};
int sai[7][4]= {{0,0,0,0},{3,5,4,2},{1,4,6,3},{1,2,6,5},{5,6,2,1},{3,6,4,1},{2,4,5,3}};
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};

void die(int t,int f,int x,int y){
  int i,j,x2,y2,mx=3,f2,t2;
  mp[1][y][x]++;
  for(i=0;i<4;i++){
    if(sai[t][i]==f){
      for(j=i;j<i+4;j++){
	int m=j%4,x1=x+dx[j-i],y1=y+dy[j-i];
	if(mp[1][y][x]-1>mp[1][y1][x1]&&sai[t][m]>mx){
	  mx=sai[t][m];
	  x2=x1,y2=y1;
	  t2=7-mx;
	  if(j-i==2)f2=7-t;
	  else if(j-i==0)f2=t;
	  else f2=f;
	}
      }
      break;
    }
  }
  if(mx!=3)mp[1][y][x]--,die(t2,f2,x2,y2);
  else mp[0][y][x]=t;
}

int main(){
  while(1){
    int n;cin>>n;if(n==0)break;
    int i,j,t,f,c[7]={};
    for(i=0;i<n;i++){
      cin>>t>>f;
      die(t,f,15,15);
    }
    for(i=0;i<31;i++)
      for(j=0;j<31;j++){
	c[mp[0][i][j]]++;
	mp[0][i][j]=mp[1][i][j]=0;
      }
    for(i=1;i<6;i++)cout<<c[i]<<" ";cout<<c[6]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1168
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

const ll M = (ll)1e6;

int main() {
    vector<int> is_prime(M+1, 1);
    is_prime[0] = 0;
    is_prime[1] = 0;
    for(int i = 2; i <= M; i++) {
        if(is_prime[i] == 1) {
            for(int j = 2*i; j <= M; j += i) {
                is_prime[j] = 0;
            }
        }
    }

    while(true) {
        ll a, d, n;
        cin >> a >> d >> n;
        if(a == 0 && d == 0 && n == 0) break;
        ll c = 0;
        for (ll m = a; m <= M; m += d) {
            if (is_prime[m]) c++;
            if (c == n) {
                cout << m << endl;
                break;
            }
        }
    }
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  int N; cin >> N;
  vector<ll> A(N), B(N);
  REP(i, N) {
    cin >> A[i];
    B[i] = A[i] - (i + 1);
  }
  ll ans = 0;
  sort(all(B));
  ll median = B[N / 2];
  for(int i = 0; i < N; ++i) {
    ans += abs(median - B[i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3328
# include <bits/stdc++.h>
# define ll int64_t
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007

using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) x*=i;
    return x;
}

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

ll lcm(ll a,ll b)
{
   return a/gcd(a,b)*b;
}



int main(){
    ll n,sum=0;
    cin>>n;
    sum=(n+1)*n/2;
    cout<<sum-n<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int N;
    cin >> N;
    int a = N / 1000;
    int b = N / 100 - a * 10;
    int c = N / 10 - a * 100 - b * 10;
    int d = N - a * 1000 - b * 100 - c * 10;
    
    if (a == b && b == c)
    {
        cout << "Yes" << endl;
    }
    else if (b == c && c == d)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#include<cstdlib>
#include<cstring>

using namespace std;

const int maxn=1010,dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
char s[maxn];

bool vis[maxn][maxn];

int n,m,ans;

struct SQR{
    int x,y,st;
};

queue<SQR> Q;

int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;++i){
        scanf("%s",s+1);
        for(int j=1;j<=m;++j)if(s[j]=='#'){
            vis[i][j]=true;
            Q.push((SQR){i,j,0});
        }
    }
    for(SQR nw;!Q.empty();){
        nw=Q.front();Q.pop();
        ans=max(ans,nw.st);
        for(int i=0,tx,ty;i<4;++i){
            tx=nw.x+dx[i];
            ty=nw.y+dy[i];
            if(tx<=0||ty<=0||tx>n||ty>m)continue;
            if(!vis[tx][ty]){
                vis[tx][ty]=true;
                Q.push((SQR){tx,ty,nw.st+1});
            }
        }
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 13328
// inputに入力データ全体が入る
function Main(input) {
  input = input.split(" ");
  var a = input[0];
  var b = input[1];
  var c = input[2];
  
  if (a[a.length-1]===b[0] && b[b.length-1]===c[0]) {
    console.log("YES");
  } else {
    console.log("NO");
  }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

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

    int ret = 0;
    for (int i = 0; i < n; i++) {
        while (h[i] > 0) {
            ret++;
            for (int j = i; j < n && h[j] > 0; j++)h[j]--;
        }
    }

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 1e5 + 10;

int main() {
	fast_cin();
	int x, y;
	cin >> x >> y;
	int ans = (max(0, 4 - x) + max(0, 4 - y)) * 100000;
	if (x == 1 and y == 1) {
		ans += 400000;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
const ll mod=1000000007;
map<int, ll> mp;


void primeFactorization(int x){
  ll sqrt_x = (ll)sqrt((double)x);
  for(int j=2;j<=x;++j){
    if(x%j==0){
      ll cnt =0;
      while(x%j==0){
        ++cnt;
        x=x/j;
      }
      if(mp.find(j) == mp.end()){
        mp[j] = cnt;
      } else {
        mp[j] += cnt;
      }
    }
  }
  if(x> sqrt_x) mp[x] = 1LL;
}

int main() {
  int n; cin >> n;
  if(n==1){
    cout << 1 << endl;
    return 0;
  } else {
    for(int i=2;i<=n;++i){
      primeFactorization(i);
    }
  }
  ll out =1LL;
  for(auto const& e: mp){
    //cout << e.first <<  " " << e.second << endl;
    out *= (e.second + 1);
    out = out % mod;
  }
  cout << out << endl;
  return 0;
}


Measured memory_bytes: 256
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
using namespace std;
namespace mp = boost::multiprecision;
using llll = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);


int main(){
  ll n,m;
  while(cin>>n>>m,n){
    ll ans=9999999;
    vector<string>v2;
    string ss;
    for(ll i=0;i<n;i++){
      cin>>ss;
      v2.push_back(ss);
    }
    vector<vector<ll> >v(n,vector<ll>(m,0));
    vector<ll>vv(m,0);
    for(ll i=0;i<n;i++){
      for(ll j=0;j<m;j++){
        v[i][j]=v2[i][j]-'0';
        vv[j]^=v[i][j];
      }
    }
    ll ff=0;
    for(ll i=0;i<m;i++){
      if(vv[i]==1)ff=1;
    }
    if(ff==0){
      cout<<n<<endl;
      continue;
    }
    if(m>=23){
      for(ll i=0;i<(ll)1<<n;i++){
        vector<ll>vvv(m,0);
        ll k=0;
        for(ll j=0;j<n;j++){
          if((ll)1<<j&i){
            k++;
            for(ll q=0;q<m;q++){
              vvv[q]^=v[j][q];
            }
          }
        }
        ll j=0;
        for(j=0;j<m;j++){
          if(vvv[j]!=vv[j])break;
        }
        if(j==m)ans=min(k,ans);
      }
    }
    else{
      map<ll,int>st1;
      map<ll,int>st2;
      vector<ll>vvv(n,0);
      for(ll j=0;j<n;j++){
        for(ll i=0;i<m-1;i++){
          vvv[j]|=v[j][i];
          vvv[j]<<=1;
        }
        vvv[j]|=v[j][m-1];
      }
      st1[0]=(-50000);
      ll z=0;
      for(ll i=0;i<m-1;i++){
        z|=vv[i];
        z<<=1;
      }
      z|=vv[m-1];
      for(ll i=0;i<n;i++){
        for(auto itr=st1.begin();itr!=st1.end();itr++){
          st2[itr->first]=(itr->second);
        }
        for(auto itr=st1.begin();itr!=st1.end();itr++){
          st2[((itr->first)^vvv[i])]=min(st2[((itr->first)^vvv[i])],itr->second+1);
        }
        st1=st2;
        st2.clear();
      }
      ans=st1[z]+50000;
    }
    cout<<n-ans<<endl;
  }
}



Measured memory_bytes: 133864
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    string A, B, C;
    cin >> A >> B >> C;

    if(A.back() == B[0] && B.back() == C[0]){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

}

Measured memory_bytes: 256
// Double-linked List

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
import java.lang.*;



public class Main {
    
    public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        Deque<Integer> list = new ArrayDeque<>();
        for (int i = 0; i < n; i++) {
            String command = br.readLine();
            if (command.charAt(0) == 'i') {
                list.addFirst(Integer.valueOf(command.substring(7)));
            } else if (command.charAt(6) == 'F') {
                list.pop();
            } else if (command.charAt(6) == 'L'){
                list.removeLast();
            } else {
                list.remove(Integer.valueOf(command.substring(7)));
            }
            //System.out.println(list);
        }
        int size = list.size();
        for (int i = 0; i < size; i++) {
            System.out.print(list.pop());
            if (i != size - 1) {
                System.out.print(' ');
            }
        }
        System.out.println();
    }
}


Measured memory_bytes: 127136
#include<bits/stdc++.h>
#define forn(a,n) for(int i = a; i < n; i++)
# define mod 10e9 + 7

using namespace std;

typedef long long int ll;
typedef vector<int> vec;
typedef vector<ll> vecl;
typedef unsigned long long int ull;
typedef vector<ull> vecu;


void print(const vec &a)
{
    forn(0,a.size())
        cout << a[i];
    cout << "\n";
}
int num_of_factors(int y)
{
    int x = y;
    int a = 0;
    int ans = 1;
    int flag = 0;
    if(x % 2 == 0)
    {
        flag = 1;
        a++;
        x/=2;
        while(x % 2 == 0)
        {
            a++;
            x/=2;
        } 
        ans *= (1 + a);
    }
    for(int i = 3; i * i <= x; i+=2)
    {
        a = 0;
        if(x % i == 0)
        {
            flag = 1;
            a++;
            x/=i;
            while(x % i == 0)
            {
                a++;
                x /= i;
            }
            ans *= (1 + a);
           
        }
    }
    if(x > 2)
        ans *= 2;
    return ans;
}

int main()
{
    #ifdef WIN32
        freopen("input.txt", "r", stdin);
    #endif
    int n;
    cin >> n;
    ll ans = 0;
    //cout << num_of_factors(99) << endl;
    forn(1, n)
    {
        //cout << num_of_factors(n - i) << endl;
        ans += num_of_factors(n - i);

    } 
    cout << ans;
}

Measured memory_bytes: 3632
#include <stdio.h>
int main()
{
	int W, H, x, y, r;
	scanf("%d %d %d %d %d\n",&W, &H, &x, &y, &r);

	if (x - r <0)
		printf("No\n");

    else if (x + r>W)
		printf("No\n");
	else  if (y-r<0)
		printf("No\n");
	else if (y +r > H)
		printf("No\n");
	else
		printf("Yes\n");
	

	return 0;
}


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define repll(i,n) for(ll i = 0; i < n; i++)
#define REPll(i,n) for(ll i = 1; i < n; i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define yesorno(a) printf(a ? "yes\n" : "no\n")
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define YESorNO(a) printf(a ? "YES\n" : "NO\n") 
#define endl "\n"
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}


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

  int n, m;
  cin >> n >> m;
  vi a(n);
  rep(i,n) cin >> a[i];
  sort(all(a));
  vector<P> bc(m);
  ll sum = 0;
  rep(i,m){
    int b, c;
    cin >> b >> c;
    sum += c;
    bc[i] = make_pair(c,b);
  }
  vi nw;
  sort(rall(bc));
  rep(i,m){
    if(nw.size() > n) break;
    rep(j,bc[i].second) nw.push_back(bc[i].first);
  }
  rep(i,n){
    if(a[i] < nw[i]) a[i] = nw[i];
    else break;
  }
  ll ans = 0;
  rep(i,n){
    ans += a[i];
  }
  cout << ans << endl;

}

Measured memory_bytes: 2552
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
typedef long long LL;

int main() {
  int N; std::cin >> N;
  for (int x = 1; x <= 9; ++x) {
    for (int y = 1; y <= 9; ++y) {
      if (x*y == N) {
        std::cout << "Yes" << std::endl;
        return 0;
      }

      if (x*y > N) break;
    }
  }
  std::cout << "No" << std::endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
int main(void){
    string s1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    string s2 = "abcdefghijklmnopqrstuvwxyz";
    char alp;
    cin>>alp;
    rep(i, 26){
        if(s1[i] == alp){
            cout<<"A"<<endl;
            return 0;
        }
    }
    rep(i, 26){
        if(s2[i] == alp){
            cout<<"a"<<endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3592
#include <climits>
#include <iostream>
#include <stdio.h>

using namespace std;



int main (int argc, char *args[])
{
  int a, b, c;
  cin >> a >> b >> c;

  int total = 0;
  while( true )
  {
    if( ( a & 0x0001 ) != 0 || ( b & 0x0001 ) != 0 || ( c & 0x0001 ) != 0 )
      break;
    if( a == b && b == c )
    {
      total = -1;
      break;
    }
    ++total;
    int ha = a >> 1;
    int hb = b >> 1;
    int hc = c >> 1;
    a = hb + hc;
    b = ha + hc;
    c = ha + hb;
  }
  cout << total << endl;
  return 0;
}  

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

int main()
{
	int K,X;
	cin >> K >> X;
	int mint,maxt,t;
	if (X - K + 1 < -1000000) {
		mint = -1000000;
	}
	else {
		mint = X - K + 1;
	}

	if (X + K - 1 > 1000000) {
		maxt = 1000000;
	}
	else {
		maxt = X + K - 1;
	}

	for (t = mint; t <= maxt; t++) {
		cout << t;
		if (t != maxt) {
			cout << " ";
		}
	}


	return 0;
	
}


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

int main()
{

  vector<tuple<int, int, int> > ans;
  for(int i=1; i<=18; ++i)
  {
    ans.emplace_back(i, i+1, 0);
    ans.emplace_back(i, i+1, 1<<(i-1));
  }
  
  int L; scanf("%d", &L); int rL = L;
  int ii = 19;
  while(L)
  {
    if(L >= (1<<(ii-1)))
    {
      ans.emplace_back(ii, 20, rL-L);
      L -= 1 << (ii-1);
    }
    else --ii;
  }
  printf("20 %d\n", (int)ans.size());
  for(auto x: ans)
  {
    int a, b, c;
    tie(a,b,c) = x;
    printf("%d %d %d\n", a, b, c);
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
using namespace std;

int N;
map<int, int> mp;
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> N;
  for(int i=0; i<N; ++i){
     int x;
     cin >> x;
     ++mp[x];
  }
  int res = 0;
  auto it = mp.begin();
  while(it != mp.end()){
    if(it->first > it->second)
      res += it->second;
    else if(it->first < it->second)
      res += it->second - it->first;
    ++it;
  }
  cout << res << "\n";
  return 0;  
}



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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

int main()
{
    int n, m;
    cin >> n;
    map<string, int> mp;
    rep(i, n)
    {
        string s;
        cin >> s;
        mp[s]++;
    }
    cin >> m;
    rep(i, m)
    {
        string s;
        cin >> s;
        mp[s]--;
    }

    int ans = 0;

    for (auto itr = mp.begin(); itr != mp.end(); itr++)
    {
        int cnt = itr->second;
        ans = max(ans, cnt);
    }

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


Measured memory_bytes: 256
import java.util.Scanner;

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

        long a = scanner.nextInt();
        long b = scanner.nextInt();
        long c = scanner.nextInt();
        long d = scanner.nextInt();

        System.out.println(Math.max(Math.max(a * c, a * d), Math.max(b * c, b * d)));
    }
}

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

#define int long long

signed main()
{
    int i=0, j=0, ans=0;
    
    int k, n;
    cin>>n>>k;
    
    int a;
    a=n%k;
    int b;
    b=abs(a-k);

    if(a>b)
        cout<<b<<endl;
    else
        cout<<a<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define UNVISITED -1
#define _ ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0), cout.precision(15);
using namespace std;

typedef long long int64;
typedef pair<int, int> ii;

int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int lcm(int a, int b) { return a * (b / gcd(a, b)); }

int main(){ _
  int n, x; cin >> n;
  vector<int> arr(n + 1, 0);
  for(int i = 0; i < n + 1; ++i) {
    cin >> arr[i];
  }

  sort(arr.begin(), arr.end());
  vector<int> diff;
  for(int i = 0; i + 1 < arr.size(); ++i) {
    diff.push_back(arr[i + 1] - arr[i]);
  }

  int ans = diff[0];
  for(int i = 1; i < diff.size(); ++i) {
    ans = gcd(ans, diff[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1276
package main

import (
	"bufio"
	"fmt"
	"io"
	"log"
	"os"

	"strconv"
)

func solve(in io.Reader, out io.Writer) error {
	sc := bufio.NewScanner(in)
	sc.Split(bufio.ScanWords)

	n := nextInt(sc)
	a := make([]int, n+2)

	sum := 0
	for i := 1; i < n+1+1; i++ {
		a[i] = nextInt(sc)
		d := abs(a[i-1] - a[i])
		sum += d
	}

	for i := 1; i < n+1; i++ {
		pd := abs(a[i-1]-a[i]) + abs(a[i]-a[i+1])
		nd := abs(a[i-1] - a[i+1])
		fmt.Fprintln(out, sum-pd+nd)
	}

	return nil
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func main() {
	err := solve(os.Stdin, os.Stdout)
	if err != nil {
		log.Fatal(err)
	}
}


Measured memory_bytes: 3712
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.bigint, std.container;

alias Path = Tuple!(int, "to", long, "yen", long, "snook");
alias Route = Tuple!(long, "cost", int, "exchange");

Path[][10^^5] GR;
long[10^^5] S_MIN, T_MIN;
Route[10^^5] SUM_MIN;

void main()
{
    auto nmst = readln.split.to!(int[]);
    auto n = nmst[0];
    auto m = nmst[1];
    auto s = nmst[2] - 1;
    auto t = nmst[3] - 1;

    foreach (_; 0..m) {
        auto uvab = readln.split;
        auto u = uvab[0].to!int - 1;
        auto v = uvab[1].to!int - 1;
        auto a = uvab[2].to!long;
        auto b = uvab[3].to!long;
        GR[u] ~= Path(v, a, b);
        GR[v] ~= Path(u, a, b);
    }

    bool[int] memo;
    auto store = [tuple(s, 0L)];
    store.length = (10^^5)*2;
    auto heap = heapify!"a[1] > b[1]"(store, 1);
    while (!heap.empty) {
        auto h = heap.front;
        heap.popFront;
        auto i = h[0];
        if (i in memo) continue;
        memo[i] = true;
        auto c = h[1];
        S_MIN[i] = c;
        foreach (path; GR[i]) {
            heap.insert(tuple(path.to, c + path.yen));
        }
    }

    bool[int] memo2;
    store = [tuple(t, 0L)];
    store.length = (10^^5)*2;
    heap = heapify!"a[1] > b[1]"(store, 1);
    while (!heap.empty) {
        auto h = heap.front;
        heap.popFront;
        auto i = h[0];
        if (i in memo2) continue;
        memo2[i] = true;
        auto c = h[1];
        T_MIN[i] = c;
        foreach (path; GR[i]) {
            heap.insert(tuple(path.to, c + path.snook));
        }
    }

    foreach (i; 0..n) {
        SUM_MIN[i] = Route(S_MIN[i] + T_MIN[i], i);
    }
    sort(SUM_MIN[0..n]);

    auto rest = SUM_MIN[0..n];
    long hand = 10L^^15;
    foreach (i; 0..n) {
        while (rest[0].exchange < i) rest = rest[1..$];
        writeln(hand - rest[0].cost);
    }
}

Measured memory_bytes: 49532
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		String s=scan.next();
		int count=0;
		for(int i=0;i<3;i++) {
			if(s.charAt(i)=='1') {
				count++;
			}
		}
		System.out.println(count);
	}

}


Measured memory_bytes: 35496
#include <stdio.h>
#include <string.h>

int stricmp(char* ch1,char* ch2){
    int ch1_length = 0,ch2_length = 0,div;
    for(int i=0;ch1[i]!= '\0';i++)ch1_length++;
    for(int i=0;ch2[i]!= '\0';i++)ch2_length++;
    if(ch1_length != ch2_length) return -1;
    for(int i=0;ch1[i]!= '\0';i++){
        div = ch1[i] - ch2[i];
        if(div != 0 && div != 32 && div != -32)
        return -1;
    }
    return 0;
}

int main() {
    char W[11],T[1001];
    int count=0;
    scanf("%s",W);
    while(true){
        scanf("%s",T);
        if(strcmp("END_OF_TEXT",T)==0)
        break;
        if(stricmp(T,W)==0)
        count++;
    }
    printf("%d\n",count);

//	return 0;
}


Measured memory_bytes: 2724
N=int(input())
s=input()
g=0
def ki(a,b):
    global g
    l=[None]*N
    l[-2],l[-1]=a,b
    for i in range(-1,N-1):
        if l[i-1]==l[i] and s[i]=="o":
            l[i+1]=0
        elif l[i-1]!=l[i] and s[i]=="x":
            l[i+1]=0
        else:
            l[i+1]=1
    if l[-2]==a and l[-1]==b and g==0:
        g=1
        for i in l:
            print("W" if i else"S",end="")
ki(0,0)
ki(0,1)
ki(1,0)
ki(1,1)
if not g:
    print(-1)

Measured memory_bytes: 5472
using System;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;
using static System.Console;

class Program {
    internal static void Main(string[] args) {
        var S = ReadLine();

        if (S[0] != 'A') {
            WriteLine("WA");
            return;
        }

        var hoge = S.Length - 2;
        var cnt = 0;
        for (int i = 0; i < S.Length; i++) {
            if (i >= 2 && i <= hoge) {
                if (S[i] == 'C') { cnt++; }
            } else if (i != 0) {
                if (char.IsUpper(S[i])) {
                    WriteLine("WA");
                    return; 
                }
            }
        }

        if (cnt != 1) {
            WriteLine("WA");
            return;
        }
        WriteLine("AC");
    }

}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int main(){
	string s;
	cin>>s;
	int N=s.size();
	rep(i,N-1) if(s[i]==s[i+1]){
		cout<<i+1<<" "<<i+2<<endl;
		return 0;
	}
	rep(i,N-2) if(s[i]==s[i+2]){
		cout<<i+1<<" "<<i+3<<endl;
		return 0;
	}
	puts("-1 -1");
}

Measured memory_bytes: 512
num = int(input())
num_list = list(map(int, input().split(" ")))
for x in range(len(num_list)):
    if x == len(num_list) - 1:
        print(num_list[x])
    else:
        print(num_list[x],end=" ")

for i in range(1, num):
    v = num_list[i]
    j = i - 1
    while j >= 0 and num_list[j] > v:
        num_list[j + 1] = num_list[j]
        j -= 1
        num_list[j + 1] = v
    for x in range(len(num_list)):
        if x == len(num_list) - 1:
            print(num_list[x])
        else:
            print(num_list[x],end=" ")


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

int main()
{
  int a, b, c, total;

  cin >> a >> b >> c;

  total = a + b;

  if (total > b + c) {
    total = b + c;
  }
  if (total > a + c) {
    total = a + c;
  }

  cout << total << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

ll k, a, b;
int main() {
    cin>>k>>a>>b;

    REP(i, a, b+1){
        if(i%k==0){
            cout<<"OK"<<endl;
            return 0;
        }
    }
    cout<<"NG"<<endl;
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=1<<18,INF=1<<30;

int main(){
    
    ll N;cin>>N;
    vector<ll> S(N);
    for(int i=0;i<N;i++) cin>>S[i];
    
    ll ans=0;
    
    for(ll C=1;C<=N-1;C++){
        ll sum=0;
        for(ll k=1;N-1-(k+1)*C>0;k++){
            if((N-1)%C==0&&(N-1)/C<=2*k) break;
            sum+=S[k*C];
            sum+=S[N-1-k*C];
            ans=max(ans,sum);
            //cout<<C<<" "<<k<<" "<<sum<<endl;
        }
    }
    
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<N;i++)
#define INF 1e9
typedef long long LL;
const LL mod = 1e9+7;

int main() {
  LL N, M;
  cin >> N >> M;
  vector<LL> a(N+1);
  rep(i, M) {
    int num;
    cin >> num;
    a[num] = 1;
  }
  
  vector<LL> dp(N+1);
  dp[0] = 1;
  if (a[1] == 0) dp[1] = 1;
  for(int i = 2; i <= N; i++) {
    if (a[i] == 0) {
	  dp[i] = dp[i-2] + dp[i-1];
      dp[i] %= mod;
    }
  }
  
  int answer = dp[N];
  cout << answer << endl;
  
  return 0;
}

Measured memory_bytes: 1792
#include <cmath>
#include <limits>
#include <iostream>
#include <iomanip>
using namespace std;

int main() {
    
    double x1,y1,x2,y2;
  cin>>x1>>y1>>x2>>y2;
  
    double d;
    
    d = sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1) );
    
    cout <<setprecision(10)<< d << endl;

	return 0;
}


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

using namespace std;

#define int unsigned long long

signed main(){
	int n; cin>>n;
	int ans = 0;
	for(int i = 1; i*i <= n; i++){
		if(n%i != 0) continue;
		int j = i-1;
		if(j && (n/j == n%j)){
			ans += j;
		}
		j = n/i - 1;
		if(j && (n/j == n%j)){
			ans += j;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256