akhauriyash/Code-Regression huggingface dataset:
n, m = map(int, input().split())
l = []

for i in range(m):
    p, y = input().split()
    l.append([p, int(y), i])

l.sort()

l[0][1] = 1

for i in range(1, m):
    if l[i][0] == l[i - 1][0]:
        l[i][1] = l[i - 1][1] + 1
    else:
        l[i][1] = 1

sortthird = lambda val: val[2]
l.sort(key = sortthird)

for i in l:
    ans = "0"*(6 - len(i[0])) + i[0] + "0"*(6 - len(str(i[1]))) + str(i[1])
    print(ans)

Measured memory_bytes: 27812
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  string X, Y;
  cin >> X >> Y;
  string ans;
  if (X > Y)
    ans = ">";
  else if (X == Y)
    ans = "=";
  if (X < Y)
    ans = "<";

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

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

using namespace std;

typedef pair<int, int> Pii;
typedef pair<int, pair<Pii, Pii> > Tpl;
#define fi first
#define se second
int W, H;
int const INF = 1<<29;
inline bool inF(int x, int y) {
  return 0<=x&&x<W&&0<=y&&y<H;
}

int main() {

  int const dx[] = {-1,0,1,0};
  int const dy[] = {0,-1,0,1};
  while(cin >> W >> H && (W|H)) {
    int tx, ty, kx, ky; cin >> tx >> ty >> kx >> ky; tx--; ty--; kx--; ky--;
    int grid[51][51];
    for(int i=0; i<H; i++)
      for(int j=0; j<W; j++)
	cin >> grid[i][j];
    
    static int vis[51][51][51][51];
    fill(vis[0][0][0], vis[51][0][0], INF);
    
    queue<Tpl> Q;
    Q.push(Tpl(make_pair(0, make_pair(Pii(tx, ty), Pii(kx, ky)))));
    vis[ty][tx][ky][kx] = 0;
    int ans = -1;
    while(!Q.empty()) {
      Tpl t = Q.front(); Q.pop();
      const int tx = t.se.fi.fi, ty = t.se.fi.se, kx = t.se.se.fi, ky = t.se.se.se;
      const int cost = t.fi;
      for(int i=0; i<4; i++) {
	int ntx = tx+dx[i], nty = ty+dy[i];
	int nkx = kx-dx[i], nky = ky-dy[i];
	if(tx == kx && ty == ky) { ans = cost; goto EXIT; }
	if(!inF(ntx, nty) && !inF(nkx, nky)) continue;
	if(!inF(ntx, nty)) ntx = tx, nty = ty;
	if(!inF(nkx, nky)) nkx = kx, nky = ky;
	if(grid[nty][ntx] && grid[nky][nkx]) continue;
	if(grid[nty][ntx]) ntx = tx, nty = ty;
	if(grid[nky][nkx]) nkx = kx, nky = ky;
	if(vis[nty][ntx][nky][nkx] > cost+1) {
	  vis[nty][ntx][nky][nkx] = cost+1;
	  Q.push(Tpl(cost+1, make_pair(Pii(ntx, nty), Pii(nkx, nky))));
	}
      }
    }
    
  EXIT:;
    if(ans == -1) cout << "NA" << endl;
    else cout << ans << endl;
  }
  
  return 0;
}

Measured memory_bytes: 27784
#include <iostream>
#include <sstream>
#include <iterator>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <list>
#include <cmath>

#define YESNO(x) x ? printf("YES") : printf("NO")
#define YesNo(x) x ? printf("Yes") : printf("No")
#define scani(x) scanf("%d", &x)
#define printi(x) printf("%d", x)

using namespace std;

//ABC079C - Train Ticket
int Main() {
	int ans = 0;

	int input;
	scani(input);

	int a, b, c, d;
	a = input / 1000;
	b = (input / 100) % 10;
	c = (input / 10) % 10;
	d = input % 10;

	int isPlus;
	int mul[3];

	for (isPlus = 0; isPlus < 1 << 4; isPlus++) {
		for (int i = 0; i < 3; i++) {
			mul[i] = (isPlus & (1 << i)) ? 1 : -1;
		}
		int seven = a + b * mul[0] + c * mul[1] + d * mul[2];
		if (7 == seven) {
			break;
		}
	}

	printi(a);
	isPlus & 1 ? printf("+") : printf("-");
	printi(b);
	isPlus & 2 ? printf("+") : printf("-");
	printi(c);
	isPlus & 4 ? printf("+") : printf("-");
	printi(d);
	printf("=7");

	return 0;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(x) ((int) (x).size())
using namespace std;

int main() {
    #ifdef LOCAL_RUN
    freopen("task.in", "r", stdin);
    freopen("task.out", "w", stdout);
    //freopen("task.err", "w", stderr);
    #endif // ONLINE_JUDGE
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, w;
    cin >> n >> w;

    vector<vector<int>> dp(n + 1, vector<int>(3 * n + 1, 0));
    vector<vector<int>> ndp(n + 1, vector<int>(3 * n + 1, 0));
    int w1 = -1;
    for (int i = 1; i <= n; ++i) {
        int w, v;
        cin >> w >> v;
        if (i == 1) {
            w1 = w;
        }
        for (int j = 0; j < i; ++j) {
            for (int k = 0; k - w1 + w <= 3 * n; ++k) {
                ndp[j + 1][k - w1 + w] = max(ndp[j + 1][k - w1 + w],
                        dp[j][k] + v);
            }
        }
        dp = ndp;
    }
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j <= 3 * n; ++j) {
            int64_t cw = (int64_t) i * w1 + j;
            if (cw <= w) {
                ans = max(ans, dp[i][j]);
            }
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
 
int main(){
    int tramp[4][13];
    int i,j;
    for (i=0; i<4; i++){
        for (j=0; j<13; j++){
            tramp[i][j] =j+1;
        }
    }
     
    int n;
    cin >>n;
     
    char x;
    int y;
    for (int k=0; k<n; k++){
        cin >>x >>y ;
        for (j=0; j<13; j++){
            if (x=='S' && y==j+1) tramp[0][j] =0;
            if (x=='H' && y==j+1) tramp[1][j] =0;
            if (x=='C' && y==j+1) tramp[2][j] =0;
            if (x=='D' && y==j+1) tramp[3][j] =0;
        }
    }
     
    for (i=0; i<4; i++){
        for (j=0; j<13; j++){
            if (tramp[i][j]==0) continue;
            if (i==0) cout << "S" <<" "<< j+1 <<"\n";
            if (i==1) cout << "H" <<" "<< j+1 <<"\n";
            if (i==2) cout << "C" <<" "<< j+1 <<"\n";
            if (i==3) cout << "D" <<" "<< j+1 <<"\n";
        }
    }   
     
    return 0;
}
	

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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
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; }
typedef long long ll;

const long long INF = 1LL << 60;

int main()
{
    int N;
    cin >> N;

    vector<string> W(N);
    bool flag = true;

    rep(i, N) {
        cin >> W[i];
    }

    repd(i, 1, N) {
        int len = (int)W[i - 1].size();
        if (W[i - 1][len - 1] != W[i][0]) {
            flag = false;
            break;
        }
        rep(j, i) {
            if (W[j] == W[i]) {
                flag = false;
                break;
            }
        }
    }

    if (flag) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll          long long int
#define lld          long double
#define pb          push_back
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define vec         vector<ll>
#define all(a)     (a).begin(),(a).end()
#define F           first
#define S           second
#define mod         1000000007
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repi(i,a,b)	for(ll  i=a;i<=b;i++)
#define per(i,a,b)  for(ll i=a;i>=b;i--)
#define mp          make_pair
#define mit         map<ll,ll>::iterator
#define sit         set<ll>::iterator
#define xy          exit(0);
#define pit         pair<ll,ll>::iterator
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;
ll xo(ll x, ll y) 
{ 
   return (x | y) & (~x | ~y); 
}  
ll bin_Expo(ll x,ll n)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return bin_Expo(x*x,n/2);
    else                             //n is odd
        return x*bin_Expo(x*x,(n-1)/2);
}
ll mod_Expo(ll x,ll n,ll M)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return mod_Expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*mod_Expo((x*x)%M,(n-1)/2,M))%M;
 
}
ll NcR(int n, int r) 
{ 
    ll p = 1, k = 1; 
    if (n - r < r) 
        r = n - r; 
  
    if (r != 0) { 
        while (r) { 
            p *= n; 
            k *= r; 
            ll m=__gcd(p, k); 
            p /= m; 
            k /= m; 
            n--; 
            r--; 
        } 
    } 
    else
        p = 1; 
    return p;
}
bool prime_check(ll x)
{
    bool prime = (x >= 2);
    for (ll i = 2; i * i <= x; i++) 
    {
        if (x % i == 0) 
        {
            prime = false;
            break;
        }
    }
    return prime;
}
ll logg(ll base,ll x)
{
    return (ll)(log(x)/log(base));
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
    while(TESTS--)
    {
    	ll i,j,m,b,d,x,a,h,l,r,n,p,q,c,ans;
    	string s;
    	cin>>s;
    	if(s[0]=='7' || s[1]=='7' || s[2]=='7')
    	cout<<"Yes";
    	else
    	cout<<"No";
    	
    	
    	
    	
    	
    	
    	
    	
    	
    }
	return 0;
}

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

signed main(){

  int n,m;
  cin>>n>>m;
  vector<int> a(m);
  for(auto& ai:a)cin>>ai;
  
  constexpr int inf = 1<<28;
  vector<vector<int>> dp(m+1,vector<int>(1e5,inf));
  for(int i=0;i<=m;++i)dp[i][0]=0;

  for(int i=0;i<m;++i){
    for(int j=1;j<=n;++j){
      dp[i+1][j] = min(dp[i+1][j],dp[i][j]);
      if(j-a[i]>=0){
        dp[i+1][j] = min(dp[i+1][j],dp[i][j-a[i]]+1);
        dp[i+1][j] = min(dp[i+1][j],dp[i+1][j-a[i]]+1);
      }
    }
  }
  int ans = inf;
  for(int i=1;i<=m;++i){
    if(dp[i][n]<ans)ans=dp[i][n];
  }
  cout<<(ans)<<endl;


}


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

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

long long MOD = 10000000000 + 7;

int main(){
  cout << setprecision(10);
  int K; cin >> K;

  vector<int> v(K,0);

  int s = 7;
  int ans = -1;
  for(int i = 1; i <= K; i++){
    if(s%K==0){
      ans = i;
      break;
    } else { 
      if(v[s%K] == 0){
        v[s%K] = 1;
        s = s * 10 + 7;
        s = s % K;
      } else {
        break;
      }
    }
  }

  cout << ans << endl;
}



Measured memory_bytes: 7212
import math

x = int(input())

tmp = int(math.sqrt(x))

if x == 2:
    print(2)

elif x % 2 == 0:
    x += 1
    while True:
        count = 0
        for i in range(3, tmp, 2):
            if x % i == 0:
                x += 2
                count = 1
                break

        if count == 0:
            print(x)
            break

else:
    while True:
        count = 0
        for i in range(3, tmp, 2):
            if x % i == 0:
                x += 2
                count = 1
                break

        if count == 0:
            print(x)
            break


Measured memory_bytes: 3064
s = input()
u = s[:2]
d = s[2:]
if '12'>= u >= '01':
    umm = True
else:
    umm = False
if '12'>= d >= '01':
    dmm = True
else:
    dmm = False
if umm and dmm:
    print('AMBIGUOUS')
elif umm:
    print('MMYY')
elif dmm:
    print('YYMM')
else:
    print('NA')

Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<ctype.h>
#include<string.h>
#include<assert.h>

typedef long long ull;
typedef unsigned long long ll;

int main()
{
	char s[101] = { 0 }, t[101] = { 0 };
	scanf("%s %s", s, t);
	printf("%s%s", t, s);
}




Measured memory_bytes: 128
n = gets.to_i
common = Hash.new(0)
n.times do |i|
  s = gets.chomp.chars
  if i == 0
    s.each do |ch|
      common[ch] += 1
    end
  else
    tmp = Hash.new(0)
    s.each do |ch|
      if common.has_key?(ch)
        tmp[ch] += i + 1
        common[ch] -= i
        if common[ch] == 0
          common.delete(ch)
        end
      end
    end
    common = tmp
  end
end

result = ""
common.sort.each do |item|
  result += item[0] * (item[1] / n)
end

puts result

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,t,a;
  cin >> n >> t >> a ;
  double ans;
  double max1 = 1000000;
  int index;
  for(int i=1;i<n+1;i++){
    int h;
    cin >> h;
    ans = t - h*0.006;
    if(abs(a-ans)<max1){
      max1 = abs(a-ans);
      index = i;
    }
  }
  cout << index << endl;
}

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

ll n,q,pt[200001] = {};
bool visited[200001] = {};
vector<int> G[200001];

void dfs(int r,ll p){
    visited[r] = true;
    pt[r] = p;
    for(int i = 0;i < G[r].size();i ++){
        int to = G[r][i];
        if(!visited[to]) dfs(to,pt[r]+pt[to]);
    }
}

int main(){
    cin >> n >> q;
    for(int i = 0;i < n-1;i ++){
        int a,b;
        cin >> a >> b;
        a --;b --;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    for(int i = 0;i < q;i ++){
        ll p,x;
        cin >> p >> x;
        p --;
        pt[p] += x;
    }
    dfs(0,pt[0]);
    for(int i = 0;i < n;i ++){
        cout << pt[i] << " ";
    }
    cout << endl;
    return 0;
}

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

#define  pf                  printf
#define  sc                  scanf
#define  PI                  2*acos(0.0)
#define  fast                ios_base::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#define  mem(a,b)            memset(a, b, sizeof(a) )
#define  gcd(a,b)            __gcd(a,b)
#define  lcm(a,b)            (a*(b/gcd(a,b)))
#define  MAX                 1234567899
#define  mod                 1000000007
#define  all(v)              (v).begin(),(v).end()
#define  vSort(v)            sort(all(v))
#define  maxSort(v)          sort(all(v),greater<int>())
#define  Unique(v)           v.erase(unique(all(v)),v.end())
#define  sqr(x)              ((x)*(x))
#define  qube(x)             ((x)*(x)*(x))
#define  deci(n)             cout<<fixed<<setprecision(n)
#define  sci(n)              sc("%d",&(n))
#define  scii(x,y)           sc("%d %d",&(x),&(y))
#define  scl(x)              sc("%lld",&(x))
#define  scll(x,y)           sc("%lld %lld",&(x),&(y))
#define  vi                  vector<int>
#define  hi                  pf(" HI \n")
#define  pp                  pair<int,int>
#define  pb(x)               push_back(x)
#define  mp(x,y)             make_pair(x,y)
#define  F                   first
#define  S                   second
#define  check(n,pos)        (n & (1<<(pos)))
#define  biton(n,pos)        (n  (1<<(pos)))
#define  bitoff(n,pos)       (n & ~(1<<(pos)))
typedef  long long int       lli;
typedef  unsigned long long int ulli;
int dx4[] = { 0 , 0 , -1 , 1 } ;
int dy4[] = { -1 , 1 , 0 , 0 } ;
bool valid( int r , int c , int x , int y ){
    if( x >= 1 && x <= r && y >= 1 && y <= c ) return 1 ; return 0 ;}

using namespace std;

int main ()
{
    int m,d;
    int cnt=0;
    cin >> m >> d;
    if(d<22){
        cout <<0<<endl;
        return 0;}
    for(int i=22;i<=d;i++)
    {
        int k=i;
        int p= k%10;
        k/=10;
        int q= k%10;
        if(p<2 || q<2)
            continue;
        int tot= (p*q);
        if(tot<=m)
            cnt++;
    }
    cout << cnt <<endl;



    return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
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; }

#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end())

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	for (int N; cin >> N;) {
		vector<int> v(N); rep(i, 0, N) { cin >> v[i]; }
		map<int, pair<int, int>> mp;
		rep(i, 0, N) {
			//mp[v[i]].emplace_back(i + 1);
			if (mp[v[i]].first == 0)mp[v[i]].second = i + 1;
			mp[v[i]].first++;
		}
		dump(mp);
		vector<int> k = v;
		sort(all(k));
		UNIQUE(k);
		dump(k);
		vector<int> ans(N);
		rrep(i, 1, k.size()) {
			mp[k[i - 1]].first += mp[k[i]].first;
			ans[mp[k[i]].second - 1] += (k[i] - k[i - 1])*mp[k[i]].first;
			chmin(mp[k[i - 1]].second, mp[k[i]].second);
		}
		dump(mp);
		ans[0] += k[0] * mp[k[0]].first;
		rep(i, 0, ans.size()) {
			cout << ans[i] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 9728
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
using ll = long long;

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; }
template<class T> inline void dump(vector<T> v) { for (auto& x : v) cerr << x << " "; cerr << endl; }
template<class T> inline void dump(vector<pair<T, T>> v) { for (auto& p : v) cerr << p.first << " " << p.second << endl; }
template<class T> inline void dump(vector<vector<T>> vv) { for (auto& v : vv) {for (auto& x : v) cerr << x << " "; cerr << endl;} }

constexpr int INF = 1e9 + 5;
constexpr long long INFLL = 1LL << 62;
constexpr double eps = (1e-9);

using P = pair<int, int>;
int dh[] = {-1, 0, 0, 1};
int dw[] = {0, -1, 1, 0};

int calc(vector<string> s, int sh, int sw, int gh, int gw) {
  vector<vector<ll>> d(s.size(), vector<ll>(s[0].size(), INF));
  d[sh][sw] = 0;
  queue<P> q;
  q.push({sh, sw});
  while (!q.empty()) {
    P m = q.front(); q.pop();
    rep(i, 4) {
      int h = m.first + dh[i];
      int w = m.second + dw[i];
      if (h < 0 || h >= s.size() || w < 0 || w >= s[0].size()) continue;
      if (s[h][w] == '#') continue;
      if (chmin(d[h][w], d[m.first][m.second] + 1)) {
        q.push({h, w});
      }
    }
  }
  return d[gh][gw];
}

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

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

  vector<string> s(h);
  rep(i, h) cin >> s[i];

  int ans = 0;
  for (int sh = 0; sh < h; sh++) {
    for (int sw = 0; sw < w; sw++) {
      if (s[sh][sw] == '#') continue;
      for (int gh = 0; gh < h; gh++) {
        for (int gw = 0; gw < w; gw++) {
          if (s[gh][gw] == '#') continue;
          if (sh == gh && sw == gw) continue;
          chmax(ans, calc(s, sh, sw, gh, gw));
        }
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
  	cin>>n;
  	vector<int>a(n);
  	long long ans=0;
  	int neg=0;
  	int flag=0;
  	for(int i=0;i<n;i++)
    {
      cin>>a[i];
      if(a[i]<0)neg++;
      if(a[i]==0)flag=1;
      a[i]=abs(a[i]);
    }
  	sort(a.begin(),a.end());
  	for(int i=0;i<n;i++)ans+=a[i];
  	if(!flag && neg%2==1)ans-=(2*a[0]);
  	cout<<ans<<endl;

  return 0;
  
}

Measured memory_bytes: 3772
#define _USE_MATH_DEFINES
#include <math.h>
#include <time.h>
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <iterator>
#include <algorithm>

using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define reprrev(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); i--)
#define reprev(i, n) reprrev(i, 0, n)

#define PI M_PI
#define INF 1000000000
#define MOD 1000000007;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<bool>> vvb;


int main()
{
	string s;
	cin >> s;
	string ans = "2018";

	repr(i, 4, s.length())
	{
		ans += s[i];
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;

int main()
{
	double r;
	cin >> r;
	double S = M_PI * r * r;
	double l = 2 * M_PI * r;
	cout << fixed
         << setprecision(5) 
		 << S 
		 << " " 
		 << l 
		 << endl;
	return 0;
}

Measured memory_bytes: 3228
#include "bits/stdc++.h"
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

typedef long long ll;
typedef pair<ll, ll> ii;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxN = 1e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 335, lg = 20, bs = 29;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif

	vector<ll> vc({500, 5});
	vector<ll> ot({2, 1});

	ll k, sm = 0;
	cin >> k;
	for(int i = 0; i < 2; i++) {
		ll cr = k / vc[i] * vc[i];
		k -= cr, sm += cr * ot[i];
	}
	cout << sm << '\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;cin>>N;
    vector<int> a(N);
    for(int i=0;i<N;i++){
        cin>>a.at(i);
    }
    int maxi = 0;
    int inte, submaxi;
    inte = 0;
    for(int i=0;i<N;i++){
        if(maxi < a.at(i)){
            submaxi=maxi;
            maxi = a.at(i);
            inte = i;
        }
        else if(submaxi <a.at(i)){
            submaxi = a.at(i);
        }
    }
    for(int i=0;i<N;i++){
        if(inte == i){
            cout << submaxi <<endl;
        }
        else cout << maxi <<endl;
    }
}

Measured memory_bytes: 2432
N = int(input())
w = list(map(int,input().split()))

W = 0
for i in range(N):
	W += w[i]

min = W
s = 0
for i in range(N):
	s += w[i]
	sa = abs(W-2*s)
	if min > sa:
		min = sa
print(int(min))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
using ll=long long int;
ll mod=1e9+7;
int main()
{
    ll s;
    cin>>s;
    vector<ll> dp(s+1,0);
    dp[0]=1;
    for(ll i=3;i<=s;i++){
        for(ll j=3;j<=s;j++){
            if(i-j>=0){
                (dp[i]+=dp[i-j])%=mod;
            }
        }
    }
    cout<<dp[s]<<endl;
}


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

using namespace std;
using ll = long long;

int main() {
	ll k;
	cin >> k;
	queue<ll> q;
	rep(i, 9) q.emplace(i + 1);
	int i = 0;
	while(1) {
		ll x = q.front();
		ll m = x % 10;
		q.pop();
		i++;
		if (i == k) {
			cout << x << endl;
			break;;
		}
		if (m != 0) q.emplace(x * 10 + m - 1);
		q.emplace(x * 10 + m);
		if (m != 9) q.emplace(x * 10 + m + 1);
	}
	return 0;
}


Measured memory_bytes: 5128
#include<bits/stdc++.h>
#define pi acos(-1)
#define ll long long
#define pii pair<ll,ll>
#define debug(a) cout<<a<<'\n'
#define maxn 500009 /// I wanna be a marshmello
#define MOD 1000000007
#define F first
#define S second
#define rep(i, a, b) for(ll i = a; i < (b); ++i)
#define per(i, b, a) for(ll i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (ll)(x).size()
using namespace std;
const ll INF = 1e17 + 9;
ll bit[maxn];
void update(int pos,int val){
    while(pos<maxn){
        bit[pos]+=val;
        pos+=pos&-pos;
    }
}
ll query(int pos){
    ll ret=0;
    while(pos>0){
        ret+=bit[pos];
        pos-=pos&-pos;
    }
    return ret;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,q;
    cin>>n>>q;
    vector<int> vet;
    vet.push_back(0);
    rep(i,1,n+1){
        ll a;
        cin>>a;
        vet.push_back(a);
    }
    vector<pair<pii,int>> qs;
    rep(i,0,q){
        ll a,b;
        cin>>a>>b;
        qs.push_back({{b,a},i});
    }
    ll ans[maxn];
    sort(all(qs));
    ll ult[maxn];
    memset(ult,-1,sizeof ult);
    ll ind=0;
    rep(i,1,n+1){
        if(ult[vet[i]]==-1){
            update(i,1);
            ult[vet[i]]=i;
        }
        else{
            update(ult[vet[i]],-1);
            update(i,1);
            ult[vet[i]]=i;
        }
        while(ind<sz(qs) && qs[ind].F.F==i){
            if(qs[ind].F.S>1) ans[qs[ind].S] = query(qs[ind].F.F)-query(qs[ind].F.S-1);
            else ans[qs[ind].S] = query(qs[ind].F.F);
            ind++;
        }
    }
    rep(i,0,sz(qs)){
        cout<<ans[i]<<"\n";
    }
    return 0;  
}           

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

constexpr ll MOD = 1'000'000'007;
ll A, B, X;

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

    std::cin >> A >> B >> X;

    ll res;

    if(X < A){
        res = X % MOD;
    }else{
        res = (X % MOD + (X - B) / (A - B) % MOD * (B % MOD) % MOD) % MOD;
    }

    std::cout << res << std::endl;
}



Measured memory_bytes: 3184
input_array = list(map(int,input().split()))
N = input_array[0]
input_array = list(map(int,input().split()))

num = [1,1,1,1,1,1,1,1,1,1]
ok = []
out = []

for l in range(len(input_array)):
    num[input_array[l]] = 0

for i in range(len(num)):
    if num[i] == 0:
        ok.append(i)

while True:
    key = 0
    for n in list(str(N)):
        if int (n) in ok:
            key += 1
    if key == 0:
        print(N)
        break
    else:
        N+=1

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

#define ANS(f) if(f) cout << "YES" << endl; else cout << "NO" << endl;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }
void debug(mat m){REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl; }}



signed main(){

    string A, B; cin >> A >> B;
    int N = A.size();

    bool f = false;
    REP(i, N) if(B[i] == '1') f = true;
    if(!f){
        if(A == B) cout << 0;
        else cout << -1;
        return 0;
    }

    vec l(N), r(N);
    REP(i, N){
        REP(j, N){
            if(B[(i + j) % N] == '1'){
                r[i] = j;
                break;
            }
        }
        REP(j, N){
            if(B[(i - j + N) % N] == '1'){
                l[i] = j;
                break;
            }
        }
    }

    int ans = INF;
    FOR(t, -N, N + 1){
        int L = -min(0LL, t);
        int R = max(0LL, t);
        int t0 = (t + N) % N;
        priority_queue<Pii> que;
        int tmp = llabs(t);
        REP(i, N){
            if(A[(i + t0) % N] != B[i]){
                tmp++;
                if(l[i] > L && r[i] > R){
                    que.push(Pii(r[i], l[i]));
                }
            }
        }
        //cout << t << "," << tmp << endl;
        //ans = min(ans, tmp);

        int RM = R, LM = L;
        while(!que.empty()){
            Pii p = que.top(); que.pop();
            RM = p.first;
            ans = min(ans, tmp + 2 * (RM - R + LM - L));
            LM = max(LM, p.second);
        }
        ans = min(ans, tmp + 2 * (LM - L));
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    int N,K;
    cin >> N>>K;
    vector<int> v(N);
    rep(i,N){
        cin >> v[i];
    }
    sort(v.begin(),v.end());
    int ans=0;
    rep(i,K){
        ans+=v[i];
    }
    cout <<ans<<endl;

    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <stdlib.h>

using namespace std;

int main(void){
	//FILE* fp_in = freopen("data.txt", "r", stdin);

	//0なら左手、1なら右手
	int ch[] = {
	//	a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z
		0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,1,0,0,0,1,0
	};

	while(1) {
		string s;
		int flg, ans = 0;

		cin >> s;
		if(s == "#") break;
		
		flg = ch[s.at(0) - 'a'];
		for(int i = 0; i < s.length(); i++) {
			int tmp = s.at(i) - 'a';
			if(flg != ch[tmp]) ans ++;
			flg = ch[tmp];
		}
		cout << ans << endl;

	}

	//while(1){}
	return 0;
}

Measured memory_bytes: 1188
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <numeric>
#include <bitset>

using namespace std;
using ll = long long;
using ld = long double;
const ll mod =  1000000007;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (ll i = (j); i < (n); ++i)
#define all(x) (x).begin(),(x).end()

ll power(ll base, ll exponent, ll module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ ll root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2, mod);}
ll gcd(ll a, ll b) {if(a < b) gcd(b, a);ll r;while(r=a%b) {a=b;b=r;}return b;}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

int bsearch(const vector<ll>& a, ll x){
  int lft = 0;
  int rgt = a.size();
  while (rgt - lft > 1) {
    int mid = (lft + rgt) / 2;
    if(a[mid] < x) {
      lft = mid;
    }
    else {
      rgt = mid;
    }
  }
  return lft;
}


signed main() {
  ios::sync_with_stdio(false);
  ll h, w;
  cin >> h >> w;
  vector<string> x = vector<string>(h);
  REP(i, h) {
      cin >> x[i];
  }
  int lft = -1;
  REP(i, h) {
    REP(j, w) {
      if(j < lft && x[i][j] == '#') {
        cout << "Impossible" << endl;
        return 0;
      }
      if(x[i][j] == '#') {
        if(lft == j) {
        }
        else if(lft + 1 == j || lft == -1) {
          lft = j;
        }
        else {
          cout << "Impossible" << endl;
          return 0;
        }
      }
    }
  }
  cout << "Possible" << endl;
  return 0;
}


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

using ll = int64_t;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

  int h, w, n;
  std::cin >> h >> w >> n;
  int ma = max(h, w);
  std::cout << (n + ma - 1) / ma << "\n";
}


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

#define PI acos(-1)
#define int long long int
#define pb push_back
#define pi pair<int, int>
#define fir first
#define sec second
#define MAXN 1000001
#define mod 1000000007

int n;
int dp[MAXN][2][2];

int solve(int i, int j, int k)
{
  if (i == n)
    return dp[i][j][k] = (j && k);
  if (dp[i][j][k] != -1)
    return dp[i][j][k];
  int ret = 0;
  for (int f = 0; f <= 9; f++)
  {
    if (f == 0)
      ret = (ret + solve(i + 1, 1, k)) % mod;
    else if (f == 9)
      ret = (ret + solve(i + 1, j, 1)) % mod;
    else
      ret = (ret + solve(i + 1, j, k)) % mod;
  }
  return dp[i][j][k] = ret;
}
signed main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  memset(dp, -1, sizeof(dp));
  cout << solve(0, 0, 0) << endl;
}

Measured memory_bytes: 112876
//** aman**/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define dl          double
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define lb lower_bound
#define ub upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
int main(){
	ll n;cin>>n;
	ll a[n+1],dp[n+1];a[0]=0;
	memset(dp,0,sizeof(dp));
	for(ll i=1;i<=n;i++)cin>>a[i];
	dp[2]=abs(a[2]-a[1]);
	for(ll i=3;i<=n;i++){
		dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
		//cout<<dp[i]<<endl;
	} 
	cout<<dp[n]<<endl;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<vector>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
typedef vector<int> ver;

ver v[5005];
int n,m;

int st[5005]={},stp,gone[5005]={},uni=0;
void dfs(int no){
	gone[no]=1;
	rep(i,0,v[no].size()){
		int to=v[no][i];
		if(gone[to]==0)dfs(to);
	}
	bool tpd=false;
	rep(i,0,v[no].size()){
		if(v[no][i]==st[stp+1])tpd=true;
	}
	if(stp!=n-1 && !tpd)uni=1;
	st[stp]=no;
	stp--;
}
int main(void){
	scanf("%d%d",&n,&m);
	stp=n-1;
	st[n]=-1;
	rep(i,0,m){
		int a,b;
		scanf("%d%d",&a,&b);
		v[a-1].push_back(b-1);
	}
	rep(i,0,n){
		if(gone[i]==0)dfs(i);
	}
	
	rep(i,0,n)printf("%d\n",st[i]+1);
	printf("%d\n",uni);
	return 0;
}

Measured memory_bytes: 1892
import java.util.Scanner;

public class Main {
    private static final int MOD = 1000000007;

    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        scanner.nextLine();
        final char[] s = scanner.nextLine().toCharArray();

        if (s[0] == 'W') {
            System.out.println(0);
            return;
        }

        final char[] lrs = new char[s.length];
        lrs[0] = 'L';

        long numOfL = 1;
        long numOfR = 0;
        long answer = 1;

        for (int i = 1; i < s.length; i++) {
            if (s[i] == s[i - 1]) {
                lrs[i] = lrs[i - 1] == 'L' ? 'R' : 'L';
            } else {
                lrs[i] = lrs[i - 1] == 'L' ? 'L' : 'R';
            }

            if (lrs[i] == 'L') {
                numOfL++;
            } else {
                answer = answer * (numOfL - numOfR) % MOD;
                numOfR++;
            }
        }

        if (numOfL != numOfR) {
            System.out.println(0);
            return;
        }

        for (int i = 2; i <= s.length / 2; i++) {
            answer = answer * (long) i % MOD;
        }

        System.out.println(answer);
    }
}


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


void solve(long long N, long long A, long long B){
    long long bas = N/(A+B) * A;
    long long rem = N%(A+B);
    long long ans = bas + (rem > A ? A : rem);
    cout<<ans<<endl; 
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(N, A, B);
    return 0;
}


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

        


def main():
    Ans = [[0]*W for _ in range(H)]
    cnt = 0
    for i in range(N):
        a = A[i]
        for _ in range(a):
            Ans[cnt // W][cnt%W] = i + 1
            cnt += 1
    
    for j in range(0,H,2):
        Ans[j] = Ans[j][::-1]
    for ans in Ans:
        print(*ans, sep =" ")
    return
main()
        


Measured memory_bytes: 3912
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
 
typedef long long ll;
const ll MOD = 1e9+7;
const ll INF = 1e18;


#define PB push_back
#define MP make_pair
#define F first
#define S second

template<typename T,typename U>
bool chmax(T& max, const U& x){
	if(max<x){
		max = x;
		return true;
	}
	return false;
}

template<typename T,typename U>
bool chmin(T& min, const U& x){
	if(min>x){
		min = x;
		return true;
	}
	return false;
}


int main(){
	ll a,b,c,d;
  	cin >> a >> b >> c >> d;
  	ll t1=ceil((double)c/b-0.000001),t2=ceil((double)a/d-0.00000001);
  	if(t1<=t2){
    	cout << "Yes" << endl;
    }else{
    	cout << "No" << endl;
    }
}

Measured memory_bytes: 3716
def main():
    input()
    array = [int(x) for x in input().split()]
    ans = 0
    for i, v in enumerate(array):
        i += 1
        if i % 2 == 1 and v % 2 == 1:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;
using namespace __gnu_cxx;

typedef double db;
typedef long long ll;
typedef pair<db, db> pdd;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef unsigned long long ull;

#define F          first
#define S          second
#define pnl        printf("\n")
#define sz(x)      (int)x.size()
#define sf(x)      scanf("%d",&x)
#define pf(x)      printf("%d\n",x)
#define all(x)     x.begin(),x.end()
#define rall(x)    x.rbegin(),x.rend()
#define rep(i, n)  for(int i = 0; i < n; ++i)

const db eps = 1e-9;
const db pi = acos(-1);
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const int mod = 1000 * 1000 * 1000 + 7;

int n;
double p[3030];
double dp[3030][3030];

double solve(int i, int cnt) {
    if (i == n) return (cnt > n / 2 ? 1 : 0);
    double &ret = dp[i][cnt];
    if (ret == ret) return ret;
    ret = solve(i + 1, cnt + 1) * p[i] + solve(i + 1, cnt) * (1 - p[i]);
    return ret;
}

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; ++i)
        scanf("%lf", &p[i]);
    memset(dp, -1, sizeof dp);
    printf("%.9lf\n", solve(0, 0));
    return 0;
}


Measured memory_bytes: 72192
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define MOD (ll)(1e9+7)
#define INF 1e17
#define int ll
#define EPS (1e-6)
using namespace std;
using ll=long long;
using pii=pair<int,int>;

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

int fpow(int b,int p)
{
	if(p==0) return 1;
	int h=fpow(b,p/2);
	if(p%2) return h*b%MOD*h%MOD;
	return h*h%MOD;
}

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n,k; cin>>n>>k;
	vector<int> v(n);
	for(auto &i:v) cin>>i;
	int ans=INF;
	For(i,k,n){
		int t=abs(v[i-1]-v[i-k]);
		ans=min(ans,min(t+abs(v[i-k]),t+abs(v[i-1])));
	}
	cout<<ans<<"\n";
	return 0;
}





























Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int N,A[2<<17];
main()
{
	cin>>N;
	int now=0;
	for(int i=0;i<N;i++)
	{
		cin>>A[i];
		now^=A[i];
	}
	for(int i=0;i<N;i++)cout<<(now^A[i])<<endl;
}


Measured memory_bytes: 4372
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define File(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
#define maxn 1000010

using namespace std;
typedef long long llg;

struct data{
	int l,r;
	data(int a=0,int b=0):l(a),r(b){}
}s[maxn];
int *q[26],lq[26],ct[26],n;
int R[maxn],ls,d[maxn];
char S[maxn],T[maxn];

int erfen(int *a,int r,int x){
	int l=0,mid;
	while(l!=r){
		mid=(l+r)>>1;
		if(a[mid]>=x) r=mid;
		else l=mid+1;
	}
	return l;
}

int main(){
	scanf("%d",&n);
	scanf("%s\n%s",S+1,T+1);
	for(int i=1;i<=n;i++) ct[S[i]-'a']++;
	for(int i=0;i<26;i++) q[i]=new int[ct[i]+10];
	for(int i=1,x;i<=n;i++)
		x=S[i]-'a',q[x][++lq[x]]=i;
	for(int i=0;i<26;i++) q[i][++lq[i]]=n+1,q[i][0]=0;
	for(int i=n,x,y,l=n;i;i--){
		x=T[i]-'a'; l=min(l,i);
		y=q[x][erfen(q[x],lq[x],l+1)-1];
		if(!y) return printf("-1"),0;
		if(!R[y]) R[y]=i; if(y<l) l=y;
	}
	for(int i=1;i<=n;i++)
		if(R[i]) s[++ls]=data(i,R[i]),d[ls]=i-ls;
	s[++ls]=data(n*2,n*2),d[ls]=n*2-ls;
	int ans=0;
	for(int i=1,j=1;i<=ls;i++){
		while(d[j]<s[i].r-i) j++;
		ans=max(ans,j-i);
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 21760
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDight(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;

//最大公約数
lol gcd(lol x, lol y){
  if(x < y) swap(x, y);
  lol r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

//最小公倍数
lol lcm(lol x, lol y){
  lol a = x * y;
  return (a / gcd(x, y));
}

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

  lol a, b, c, k;
  cin >> a >> b >> c >> k;
  k %= 2LL;
  if(k){
    cout << (b + c) - (a + c) << '\n';
  } else {
    cout << a - b << '\n';
  }
  return 0;
}


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

A.sort()

ans=0

ans+=A[2]-A[1]
A[0]+=ans
A[1]+=ans

if A[0]==A[2]:
    print(ans)
elif (A[2]-A[0])%2==0:
    print(ans+(A[2]-A[0])//2)
else:
    print(ans+1+(A[2]+1-A[0])//2)

Measured memory_bytes: 3064
#from numpy import*
#from scipy import*
from collections import* #defaultdict Counter deque appendleft
from fractions import gcd
from functools import* #reduce
from itertools import* #permutations("AB",repeat=2) combinations("AB",2) product("AB",2) groupby
from operator import mul
from bisect import* #bisect_left bisect_right
from heapq import* #heapify heappop heappushpop
from math import factorial,pi
from copy import deepcopy
import sys
#input=sys.stdin.readline  #危険！基本オフにしろ！
sys.setrecursionlimit(10**6)


def main():
    d=defaultdict(int)
    for i in open(0).read().lower():
        d[i]+=1
    for i in [chr(j)for j in range(97,123)]:
        print(i,":",d[i])
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 6960
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999
#define rep(i,m,n) for(int i = m;i < n;i++)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl;
#define Vecpr vector<pair<lli,lli>>
#define mod 1000000007;
lli gcd(lli num1, lli num2){
  return num2 != 0 ? gcd(num2, num1 % num2) : num1;
}
lli lcm(lli num1, lli num2){
    return num1 / gcd(num1, num2) * num2;
}
int main() {
  lli A,B,C=1,D=0,E=0,F=0,G=0,H=0,N,M;
  cin >> N;
  rep(i,0,N){
    cin >> D;
    C=lcm(C,D);
  }
  Out(C);
}

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

int main() {
  long N;
  cin >> N;
  long a[N];
  for(long i=0; i<N; i++){
    cin >> a[i];
  }

  long ans = 0;
  for(long i=0; i<N; i++){
    if(a[i] %2 == 0){
      for(int j=a[i]; j%2==0; j=j/2){
        ans++;
      }
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
const ll mod = 1e9 + 7;
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; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }

// * ALways PASS arrays, strings etc to functions BY REFERENCE

int main() {
    int t = 1;
    // cin >> t;
    
    while(t--) {
        int n;
        cin >> n;
        
        if (n >= 30)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }

	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N),B(N),C(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  for (int i = 0; i < N; i++) {
    cin >> B.at(i);
  }
  for (int i = 0; i < N; i++) {
    C.at(i) = A.at(i) - B.at(i);
  }
  
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (C.at(i) > 0) {
      ans+= C.at(i);
    }
  }
  
  cout << ans <<endl;
  
}


Measured memory_bytes: 256
#ifdef __APPLE__
#include <iostream>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <iomanip>
#include <cmath>
#include <ctgmath>
#include <math.h>
#include <cassert>
#include <chrono>
#else
#include <bits/stdc++.h>
#endif

using namespace std;
#define io ios_base::sync_with_stdio(false), cin.tie(NULL)
#define GFOR(i,a,n) for (i=a;i<n;i++)
#define FOR(i,a,n) for (int i=a;i<n;i++)
#define RFOR(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define tc(t) for (int tc=1; tc<=t; tc++)
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<long long int> vll;
typedef vector<pair<int, int> > vpi;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
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;}
ll modInverse (ll a) {ll p = mod - 2; return powmod(a, p);}
// head

void solve() {
    int n;
    cin >> n;

    vector<pll> e(n-1);
    for (auto &x: e)
        cin >> x.fi >> x.se;

    ll ans = 0;
    for (ll i = 1; i <= n; i++)
        ans += i*(n-i+1);

    for (auto x : e) {
        if (x.fi > x.se)
            swap(x.fi, x.se);
        ans -= x.fi*(n - x.se + 1);
    }
    cout << ans << "\n";
}

int main() {
    #ifdef LOCAL
    auto t1 = std::chrono::high_resolution_clock::now();
    #endif

    io;
    int t = 1;
    tc(t) {
        solve();
    }

    #ifdef LOCAL
    auto t2 = std::chrono::high_resolution_clock::now();
    auto duration = std::chrono::duration_cast<std::chrono::milliseconds>( t2 - t1 ).count();

    std::cout << "Time Taken: " << duration << "\n";
    #endif

}
//check for edge cases in limits
//printing double may print 1.223232e9 like values, beware of that


Measured memory_bytes: 6364
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main(void){
    // Your code here!
    double  r;
    cin>>r;
    
    double  pi  =acos(-1);
    cout<<fixed<<setprecision(6);
    double  area    =r*r*pi;
    double  cir =(r+r)*pi;
    cout<<area<<" "<<cir<<endl;
}



Measured memory_bytes: 3212