akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define REP(i, n) for (int i=0; i<n; ++i)
#define print(x) cout << x << endl;

using namespace std;

void solve() {
    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N) cin >> A[i];

    int total = 0;
    int even = 0;
    REP(i, N) {
        if ((i+1)%2 == 0) {
            even += A[i];
        }
        total += A[i];
    }

    vector<int> x(N);
    x[0] = total - 2 * even;
    for (int i=1; i<N; ++i) {
        x[i] = 2*A[i-1] - x[i-1];
    }
    
    REP(i, N) {
        cout << x[i];
        if (i == N-1) {
            cout << endl;
        } else {
            cout << " ";
        }
    }
}

int main() {

    solve();
    return 0;
}


Measured memory_bytes: 2048
n,k = map(int,input().split())
plist = list(map(int,input().split()))
psum = [0]*n
psum[0] = plist[0] + 1
if n == k:
    print((sum(plist) + n)/2)
    exit()
for i in range(1,n):
    psum[i] = psum[i-1] + plist[i] + 1


mx = 0
for i in range(1,n-k+1):
    delta = psum[i+k-1] - psum[i-1]
    if mx < delta:
        mx = delta
print(mx/2)

Measured memory_bytes: 71792
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;

int main(){
  string s;cin >> s;
  if(s=="Sunny") cout << "Cloudy" << endl;
  else if(s=="Rainy") cout << "Sunny" << endl;
  else cout << "Rainy" << endl;
}


Measured memory_bytes: 256
//{
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FILL(i,n) memset(i,n,sizeof i)
#define X first
#define Y second
#define SZ(_a) (int)_a.size()
#define ALL(_a) _a.begin(),_a.end()
#define pb push_back
#ifdef brian
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // brian
//}


const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=ll(1e15);

int main()
{
    IOS();
    ll n,k;
    cin>>n>>k;
    if(n % k == 0)cout<<0<<endl;
    else cout<<1<<endl;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d %d", $n, $y);
$op = "-1 -1 -1";

for($i = 0; $i <= $n; $i++){

    for($j= 0; $j <= $n - $i; $j++){
        
        $k = $n - $i - $j;
        if(1000 * ($k) == $y - (10000 * $i + 5000 * $j)){           
            $op = "{$i} {$j} {$k}";
        break;
        }

    }

}

print($op);

Measured memory_bytes: 4856
// aarsh01rsh@gmail.com
// Aarsh Sharma
#include<bits/stdc++.h>
using namespace std;

string to_string(string s) {
  return '"' + s + '"';
}
string to_string(char ch) {
  string s(1, ch);
  return '\'' + s + '\'';
}
string to_string(const char *s) {
  return to_string((string)s);
}
string to_string(bool b) {
  return (b ? "true" : "false");
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

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

#define f(i, x, n) for (int i = x; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

typedef long long int ll;
#define int ll
typedef pair<ll, ll> pll;
typedef vector<vector<ll>> matrix;
typedef vector<ll> vll;

const ll mod = 1e9 + 7;
const ll inf = LLONG_MAX;
const ll N = 1e5 + 10;

int32_t main() {
  fast_io();

  int n; cin >> n;
  vll a(n); f (i, 0, n) cin >> a[i];
  if (n == 2) {
    cout << abs(a[1] - a[0]);
    return 0;
  }
  vll dp(n);
  dp[0] = a[0];
  dp[1] = abs(a[1] - a[0]);
  dp[2] = min(abs(a[2]-a[0]), abs(a[2]-a[1]) + abs(a[1]-a[0]));
  f (i, 3, n) {
    dp[i] = min(dp[i-1]+abs(a[i]-a[i-1]), dp[i-2]+abs(a[i]-a[i-2]));
  }
  debug(dp);
  cout << dp[n-1];

  return 0;
}

Measured memory_bytes: 5636
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
//    return *(long long*)a - *(long long*)b;
}
//  qsort(A, b, sizeof(int), compare_int);

int main()
{
 
//  int a, b, c, d, e, X, Y;
  int a, b, c,  d, e,f;
  //  double  c;
//  long long  A[1000001]={};
  int  A[2000001]={};
  int  B[2000001]={};
  int  ans[100003]={};
  int  sum[100003]={};
  int  cnt_flag[100003]={};

  int  L[1003]={};


//  long long  a, b, c, d, X, Y;
//  long long   d, X, Y;
  long long JPY;
  double BTC;
  char s[200001]={};
  char t[200001]={};
  char u[200001]={};
//  int N, M;
//  int A[1000000001]={};
//  long long  C[101]={};
  int i,j,k,point;
  int point_A=0, point_B=0;
  int flag=0;
//  int flag[10000003]={};
  int tmp=0;
//  int min=1000000;
  int min=10;
  int len=0;
  int cnt=0;
  int cnt0=0;
  int cnt1=0;
  int num=0;
//  double ans=0.0;
//  long long ans=0;
  int max=0;
//  int sum=0;
//  char alp[26]={'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'};

  //  a=0;
//  scanf("%lld %lld", &a, &b);
 
  scanf("%d", &a);
  scanf("%s", &s);
  scanf("%d", &b);
//  scanf("%s", &s);
//  scanf("%d", &max);
  t[0]=s[b-1];
  
  for(i=0;i<a;i++){
    if(s[i]!=t[0]) s[i]='*';
  }
  printf("%s\n",s);
/*    
    */

//  printf("%s\n",s);
//    else  
  
return 0;
}


Measured memory_bytes: 384
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;
list<long long int> Prime(int M) {
	list<long long int>P;
	P.push_back(2);
	P.push_back(3);
	for (int i = 5; i <= M; i += 6) {
		bool flag = true;
		for (auto j : P) {
			if (i%j == 0) {
				flag = false;
				break;
			}
		}
		if (flag)P.push_back(i);
		flag = true;
		for (auto j : P) {
			if ((i + 2) % j == 0) {
				flag = false;
				break;
			}
		}
		if (flag)P.push_back(i + 2);
	}
	return P;
}

long long int N, K, Q;
long long int ans;

int num;
int box;
int flag[8];

int main() {
	ios::sync_with_stdio(false);
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> num;
		if (num >= 3200)box++;
		else flag[num / 400]++;
	}
	for (int i = 0; i < 8; i++)if (flag[i])ans++;
	cout << max(1, (int)ans) << " " << (int)ans + box << endl;
	return 0;
}

Measured memory_bytes: 256
eval"N,M,K="+`tr ' ' ,`
f=t=1,*(1..N).map{(t=_1*U=t%Z=998244353).pow Z-2,Z}
p M*U*(0..K).sum{f[j=N+~_1]*f[_1]*(M-1).pow(j,Z)}%Z

Measured memory_bytes: 55876
import java.util.Scanner;
 
public class Main {
   public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
      
      int N = sc.nextInt();
     
      for(int i=0; i<1000; i++) {
        int cal = 1000 * i - N;
        if(cal >= 0) {
          System.out.println(cal);
          break;
        } else {
          continue;
        }
      }
   }
}

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

using namespace std;

#define ll long long int
#define ld long double
#define loop(i, n) for (int i = 0; i < n; i++)
#define loops(i, s, n) for (int i = s; i < n; i++)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
#define deb(x) cout<< #x << '=' << x <<endl
#define MOD 1000000007

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

    string s,t;
    cin>>s>>t;
    int ans = 0;
    int n = sz(s);
    for(int i = 0; i<n; i++){
        if(s[i] != t[i]){
            ans++;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 3884
#include <iomanip>
#include <random>
#include <time.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <functional>
#include <map>
#include <string>
#include <cstdlib>
#include <typeinfo>
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
	long long int n, a, x[55], dp[55][55][2550] = {}, b, ans = 0, yojo = 1;
	cin >> n >> a;
	for (int i = 1; i <= n; i++) {
		cin >> x[i];
	}
	dp[1][1][x[1]] = 1;
	for (int i = 2; i <= n; i++) {
		for (int j = 1; j <= i;j++) {
			for (int k = 1; k <= 2500; k++) {
				dp[i][j][k] += dp[i - 1][j][k];
				dp[i][j][k + x[i]] += dp[i - 1][j - 1][k];
			}
		}
		dp[i][1][x[i]]++;
	}
	/*for (int i = 1; i <= n; i++) {
		for (int j = 2; j <= i; j++) {
			for (int k = 1; k <= 50; k++) {
				cout << dp[i][j][k] << " ";
			}
			cout << endl;
		}
	}*/
	for (int i = 1; i <= n; i++) {
		ans += dp[n][i][a*i];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 60544
#include<bits/stdc++.h>
#define fo(i, x, y) for(int i = x, B = y; i <= B; i ++)
#define ff(i, x, y) for(int i = x, B = y; i <  B; i ++)
#define fd(i, x, y) for(int i = x, B = y; i >= B; i --)
#define ll long long
#define pp printf
#define hh pp("\n")
using namespace std;

const int N = 105;

int n, a[N], b[N], m, na[N];
map<int, int> ba;

const int mo = 1e9 + 7;

ll ksm(ll x, ll y) {
	ll s = 1;
	for(; y; y /= 2, x = x * x % mo)
		if(y & 1) s = s * x % mo;
	return s;
}

ll qu(int x, int y) {
	return (ksm(2, y + 1) - ksm(2, x) + mo) % mo;
}

ll a2[N];
ll f[N][N];

void add(ll &x, ll y) {
	(x += y) %= mo;
}

int main() {
	scanf("%d", &n);
	fo(i, 1, n) scanf("%d", &a[i]), b[i] = a[i];
	sort(b + 1, b + n + 1);
	m = unique(b + 1, b + n + 1) - (b + 1);
	fo(i, 1, m) ba[b[i]] = i;
	fo(i, 1, n) na[i] = ba[a[i]];
	b[m + 1] = 2e9; f[0][m + 1] = 1;
	fo(i, 1, n) {
		fo(j, 1, m + 1) if(f[i - 1][j]) {
			if(a[i - 1] <= a[i]) {
				if(b[j] <= a[i]) {
					add(f[i][j], f[i - 1][j] * ksm(2, a[i] - a[i - 1]));
				} else {
					fo(k, na[i - 1] + 1, na[i]) {
						int x = b[k - 1] + 1, y = b[k];
						if(x == 1) x ++;
						if(x <= y)
						add(f[i][k], f[i - 1][j] * qu(a[i] - y + 1, a[i] - x + 1)) ;
					}
					add(f[i][m + 1], f[i - 1][j] * 2);
				}
			} else {
				if(b[j] <= a[i]) {
					add(f[i][j], f[i - 1][j]);
				} else {
					add(f[i][m + 1], f[i - 1][j] * 2);
				}
			}
		}
	}
	ll ans = 0;
	fo(j, 1, m + 1) ans = (ans + f[n][j]) % mo;
	pp("%lld\n", ans);
}


Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  
  while(x->left != NIL){
    x = x->left;
  }
  return x;
}

Node treeSearch(Node u, int k){
  
  if(u == NIL || k == u->key) return u;
  if(k < u->key) return treeSearch(u->left,k);
  else  return treeSearch(u->right,k);
  
}

Node treeSuccessor(Node x){
  Node y = NIL;
  
  if(x->right != NIL) return treeMinimum(x->right);
  y = x->parent;
  
  while(y != NIL && x == y->right){
    x =y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if(z->left == NIL || z->right == NIL) y = z;
  else y = treeSuccessor(z);
  
  if(y->left != NIL) x = y->left;
  else x = y->right;
  
  if(x != NIL) x->parent = y->parent;
  if(y->parent == NIL) root = x;
  else if(y == y->parent->left) y->parent->left = x;
  else y->parent->right = x;
  
  if(y != z) z->key = y->key;
  
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
  
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  
  while(x != NIL){
    y = x;
    
    if(k < x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;
  
  if(y == NIL) root = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;
}

void inorder(Node u){
  
  if(u ->left != NIL) {
    inorder(u->left);
    printf(" %d",u->key);
  }
  
  else printf(" %d",u->key);
  
  if(u->right != NIL) inorder(u->right);
}

void preorder(Node u){
  printf(" %d",u->key);
  
  if(u->left != NIL) preorder(u->left);
  if(u->right != NIL) preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
  
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }
  return 0;
}

Measured memory_bytes: 24036
#include<iostream>
using namespace std;
int main(){
	int n,p;
	int s[1000000];
	int t[1000000];
	int i,j;
	int c=0;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>s[i];
	}
	cin>>p;
	for(i=0;i<p;i++){
		cin>>t[i];
	}
	for(i=0;i<n;i++){
		for(j=0;j<p;j++){
			if(s[i]==t[j]){
				t[j]=-1;
				c++;
			}
		}
	}
	cout<<c<<endl;
	return 0;
}
	

Measured memory_bytes: 3140
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int H, W;
char F[1011][1011];
int A[1011][1011];

void MAIN() {
    scanf("%d%d", &H, &W);
    REP (i, H) scanf("%s", F[i]);
    memset(A, 0x3f, sizeof A);
    REP (i, H) REP (j, W) if (F[i][j] == '#') A[i][j] = 0;


    REP (i, H) {
	REP (j, W-1) amin(A[i][j+1], A[i][j]+1);
	for (int j=W-1; j--;) amin(A[i][j], A[i][j+1]+1);
    }

    REP (j, W) {
	REP (i, H-1) amin(A[i+1][j], A[i][j]+1);
	for (int i=H-1; i--;) amin(A[i][j], A[i+1][j]+1);
    }

    int ans = 0;
    REP (i, H) REP (j, W) amax(ans, A[i][j]);
    printf("%d\n", ans);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 5248
// スタックサイズ: 100MB

#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1e18;
const double EPS = 1e-10;
const ll mod = 1e9 + 7;
#define fastio  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define fst first
#define snd second
ll pw(ll x, ll y) { ll r = 1;  rep(i, y) { r *= x; }; return r; }




int main() {
	fastio;

	string s,t;
	cin >> s;
	t = s;
	reverse(all(t));
	cout << (s == t ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
n = int(input())

lst = {'AC': 0, 'WA': 0, 'TLE': 0, 'RE': 0}


for i in range(n):
  s = input()
  lst[s] += 1

lst_ans = ['AC', 'WA', 'TLE', 'RE']
for i in lst_ans:
  print("{} x {}".format(i, lst[i]))

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

int main(){

    int N;
    cin>>N;
    vector<int> S(9);
    for(int i=0;i<N;i++){
        int a;cin>>a;
        if(a<400) S[0]=1;
        else if(a<800) S[1]=1;
        else if(a<1200) S[2]=1;
        else if(a<1600) S[3]=1;
        else if(a<2000) S[4]=1;
        else if(a<2400) S[5]=1;
        else if(a<2800) S[6]=1;
        else if(a<3200) S[7]=1;
        else S[8]++;
    }
    int cnt=0;
    for(int i=0;i<8;i++){
        cnt+=S[i];
    }
    if(cnt==0) cout<<1<<" "<<S[8]<<endl;
    else cout<<cnt<<" "<<cnt+S[8]<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<algorithm>
using namespace std;
int main(void){

  int N;  cin >> N;
  vector<int> d(N);
  for(int i = 0 ; i < N ; i++)   cin >> d[i];
  sort(d.begin(), d.begin() + N);

  int ans = 1;
  for(int i = 1 ; i < N ; i++)
    if(d[i - 1] < d[i]) ans++;

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
const ll INF=1e9+7;
const ll N = 200002;
multiset<string> a,b;
vector<string> v;
 
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int c[3][3],b;
	FOR(i,0,3){
		FOR(j,0,3){
			cin>>c[i][j];
		}
	}
	bool ok=true;
	b=c[0][0]-c[1][0];
	FOR(i,0,3){
		if((c[0][i]-c[1][i])!=b)ok=false;
	}
	b=c[1][0]-c[2][0];
	FOR(i,0,3){
		if((c[1][i]-c[2][i])!=b)ok=false;
	}

	b=c[0][1]-c[0][2];
	FOR(i,0,3){
		if((c[i][1]-c[i][2])!=b)ok=false;
	}

	b=c[0][0]-c[0][1];
	FOR(i,0,3){
		if((c[i][0]-c[i][1])!=b)ok=false;
	}
	if(ok)pri("Yes");
	else pri("No");
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
int a,b,c,d=0,e,f,g=0;
while(d==0){
scanf("%d %d\n",&a,&b);
if(a==0 && b==0){
break;
}
else{
for(c=1;c<=a;c++){
for(e=c+1;e<=a;e++){
for(f=e+1;f<=a;f++){
if(c+e+f==b){
g++;
}
}
}
}
printf("%d\n",g);
g=0;
}
}
return 0;
}


Measured memory_bytes: 2060
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 1000000007 // //100000000 998244353 //
#define inf 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

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

void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}


void solve(){
    string s;
    cin >> s;
    ll n = s.size(), cnt = 0, t1 = 0, t2 = 0;
    stack<char> ss;
    rep(i, n)
    {
        if(ss.empty()) ss.push(s[i]);
        else {
            if(ss.top() != s[i]) {
                cnt++; ss.pop();
            }
            else ss.push(s[i]);
        }
    }

    cout << cnt*2;
}
main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
    public static void main(String [] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int q = scanner.nextInt();
        String s = scanner.next();
        String[] t = new String[q];
        String[] d = new String[q];
        for (int i = 0; i < q; ++i) {
            t[i] = scanner.next();
            d[i] = scanner.next();
        }
        // find left dropped maxIndex

        int leftDropMaxIndex = binarySearchLeftDrop(t, d, s, q);

        // find right dropped minIndex
        int rightDropMinIndex = binarySearchRightDrop(t, d, s, q);

        int leftDropNum =
                leftDropMaxIndex == -1 ? 0 : leftDropMaxIndex + 1;
        int rightDropNum =
                rightDropMinIndex == s.length() ? 0 : n - rightDropMinIndex;

        System.out.println((n - leftDropNum - rightDropNum));

    }

    public static int binarySearchLeftDrop(String[] t, String[] d, String s, int q) {
        int l = -1; // fit
        int r = s.length();
        while (r - l > 1) {
            int mid = (l + r) / 2;
            int dropped = isDropped(mid, t, d, s, q);
            if (dropped == 1) {
                l = mid;
            } else {
                r = mid;
            }
        }
        return l;
    }

    public static int binarySearchRightDrop(String[] t, String[] d, String s, int q) {
        int l = -1;
        int r = s.length(); // fit
        while (r - l > 1) {

            int mid = (l + r) / 2;
            int dropped = isDropped(mid, t, d, s, q);
            if (dropped == 2) {
                r = mid;
            } else {
                l = mid;
            }
        }
        return r;
    }

    public static int isDropped(int index, String[] t, String[] d, String s, int q) {
        int current = s.charAt(index) - 'A';
        int[] num = new int[s.length()];
        for (int i = 0; i < s.length(); ++i) {
            num[i] = 1;
        }

        for (int i = 0; i < q; ++i) {
            if (t[i].charAt(0) - 'A' != current) {
                continue;
            }

            if (d[i].equals("L")) {
                if (index == 0) {
                    return 1;
                }
                current = s.charAt(index - 1) - 'A';
                --index;
            } else {
                if (index == s.length() - 1) {
                    return 2;
                }
                current = s.charAt(index + 1) - 'A';
                ++index;
            }
        }
        return 0;
    }
}


Measured memory_bytes: 113640
N, M = map(int, input().split())
s, c = [], []
for i in range(M):
    S, C = map(int, input().split())
    s.append(S)
    c.append(C)

for i in range(M):
    for j in range(M):
        if i == j:
            break
        elif s[i] == s[j] and c[i] != c[j]:
            print(-1)
            exit()

for i in range(M):
    if s[i] == 1 and c[i] == 0 and not N == 1:
        print(-1)
        exit()

num = [0]*N

if N == 1:
    if M > 0:
        print(c[0])
    else:
        print(0)

elif N == 2:
    for i in range(M):
        if s[i] == 1 and c[i] == 0:
            print(-1)
            exit()
    for i in range(M):
        num[s[i]-1] = c[i]
    if num[0] == 0:
        print("1"+str(num[1]))
    else:
        print(str(num[0])+str(num[1]))

else:
    top_f = 0
    sec_f = 0

    for i in range(M):
        if s[i] == 1 and c[i] == 0:
            top_f = 1
        elif s[i] == 2 and c[i] == 0:
            sec_f = 1
    if top_f == 1 and sec_f == 1:
        print(-1)
        exit()
    for i in range(M):
        num[s[i]-1] = c[i]
    if num[0] == 0:
        print("1"+str(num[1])+str(num[2]))
    else:
        print(str(num[0])+str(num[1])+str(num[2]))


Measured memory_bytes: 3188
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010


int main(){
  int N, K;
  int ans = 0, use = 0;

  cin >> N >> K;
  
  for(int i=0;i<N;i++){
    int p = max(1, (use + K - 1)/K);
    if(use + p > N) break;
    use += p;
    ans++;
  }

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




Measured memory_bytes: 3100
a,b,c,d,e=[int(input()) for i in range(5)]
a1=a//10
a2=a%10
if a2==0:
    a1-=1
    a2=10
b1=b//10
b2=b%10
if b2==0:
    b1-=1
    b2=10
c1=c//10
c2=c%10
if c2==0:
    c1-=1
    c2=10
d1=d//10
d2=d%10
if d2==0:
    d1-=1
    d2=10
n=e//10
m=e%10
if m==0:
    n-=1
    m=10
min1=min(a2,b2,c2,d2,m)
if a2==10 or b2==10 or c2==10 or d2==10 or m==10:
    ans=(a1+b1+c1+d1+n+4)*10+min1
else:
    ans=(a1+b1+c1+d1+n+4)*10+min1
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
using namespace std;
int n,a,t,ans,maxx;
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;++i)
	{
		scanf("%d",&a);
		ans+=a;
		maxx=max(maxx,a);
	}
	printf("%d",ans-maxx/2); 
}

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

using namespace std;

int main()
{
	int l, r;
	std::cin >> l >> r;
	long long int result = 2019;
	long long int temp;


	for (long long int i = l; i < r; i++) {
		for (long long int j = i + 1; j <= r; j++) {
			temp = i * j % 2019;
			if (temp == 0) {
				std::cout << 0 << std::endl;
				return 0;
			}
			else if (result > temp) {
				result = temp;
			}
		}
	}

	std::cout << result << std::endl;

	return 0;
}

Measured memory_bytes: 256
while True:
  try:
    a_set = list(map(int, input().split()))
    b_set = list(map(int, input().split()))
  except EOFError:
    break
  hit = 0
  blow = 0
  for i in range(4):
    if a_set[i] == b_set[i]:
      hit += 1
  for i in range(4):
    for j in range(4):
      if a_set[i] == b_set[j] and i != j:
        blow += 1
  print(hit,blow)


Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
int main(){
    int K;
    cin >> K;
    if(K==1){
        cout << 1 << endl << 1 << endl;
        return 0;
    }
    int n = (K+3)/4*2;
    cout << n << endl;

    int b[500][500];
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            if(i%2==0) b[i][j]=(i+j)%n;
            else b[i][j]=(i+j)%n+n;

    for(int i=0;i<n;i++){
        cout << (b[i][0]<K?b[i][0]+1:b[i][0]+1-n);
        for(int j=1;j<n;j++)
            cout << ' ' << (b[i][j]<K?b[i][j]+1:b[i][j]+1-n);
        cout << endl;
    }    
    return 0;
}

Measured memory_bytes: 2176
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		while(true){
			int count = sc.nextInt();
			if(count == 0) {
				break;
			}
			int [] s =new int [count];
			int sum = 0;
			for(int i=0 ; i<count; i++){
				s[i] = sc.nextInt();
				sum += s[i];
			}
			double m = sum/(double)count;
			double a = 0.0;
			for(int i =0; i<count; i++) {
				a +=(s[i]-m)*(s[i]-m);
			}
			a=a/(double)count;
			System.out.println(Math.sqrt(a));
		}
	}
}



Measured memory_bytes: 31688
def main():
    n = int(input())
    A1 = list(map(int, input().split()))
    A2 = list(map(int, input().split()))
    ans = 0

    for i in range(n - 1):
        A1[i + 1] += A1[i]
        A2[n - i - 2] += A2[n - i - 1]
        
    for i in range(n):
        ans = max(ans, A1[i] + A2[i])
    
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main() {
    deque<int> q;
    int T;
    cin >> T;
    while (T--) {
        int x;
        cin >> x;
        if (x==0) {
            int t;
            cin >> t;
            int d;
            cin >> d;
            if (t==0) q.push_front(d);
            else q.push_back(d);
        }
        if (x==1) {
            int t;
            cin >>t;
            printf("%d\n", q[t]);
        }
        if (x==2) {
            int d;
            cin >> d;
            if (d==1) q.pop_back();
            else q.pop_front();
        }
    }
    return 0;
}



Measured memory_bytes: 4644
#include <bits/stdc++.h>
#define MOD 1000000007
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define rep(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
inline ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
inline ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
inline ll char_to_ll(char c) { return (int)(c - '0'); }
inline ll string_to_ll(string s) { return atoi(s.c_str()); }
inline bool is_prime(ll x){ if(x <= 1) return false; for(ll i = 2; sqrt(i) <= x; i++) if(x % i == 0) return false; return true; }

int main(){
    ll a, b, c;
    cin >> a >> b >> c;
    if(a < b && b < c) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}



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

using namespace std;

/// typedef long long ll;
typedef long double ld;

const int N = 8;
int n;
ld x[N];
ld y[N];
ld d[N][N];
ld fct;

ld get(vector<int> ord)
{
    ld ans = 0;
    for (int i = 0; i + 1 < n; i++)
    {
        ans += d[ord[i]][ord[i + 1]];
    }
    return ans;
}

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

    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> x[i] >> y[i];
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            ld dx = x[i] - x[j];
            ld dy = y[i] - y[j];
            d[i][j] = sqrt(dx * dx + dy * dy);
        }
    }
    vector<int> ord;
    fct = 1;
    for (int i = 0; i < n; i++)
    {
        fct *= (i + 1);
        ord.push_back(i);
    }
    ld ans = get(ord);
    while (next_permutation(ord.begin(), ord.end()))
    {
        ans += get(ord);
    }
    ans /= fct;
    cout << fixed << setprecision(6) << ans << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
typedef long double lb;
typedef vector<int,vector<int>> vvec;
typedef long double ld;

//----***Like a Pythonista***----
#define REP(i,j,n) for (ll i=j;i<(n);i++)
#define RREP(i,n,j) for (ll i = n; j<i;i--)
#define each(i,...) for(auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(all(__VA_ARGS__),0LL)
#define dsum(...) accumulate(all(__VA_ARGS__),0.0L)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(all(a)); }
template<class T> inline auto min(const T& a){ return *min_element(all(a)); }
inline ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
inline ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / gcd(a, b); }

//----***定数***----
#define MOD 1000000007;
#define INF 1e9;
#define EPS 1e-9;

//----***入出力***----
#define print(out) cout<< out  << "\n";
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}initial_;

typedef pair<ll,ll> P;
vector<vector<ll>> DYX{{-1,0},{1,0},{0,-1},{0,1}};

signed main(){
  ll H,W;cin>>H>>W;
  vector<vector<char>> maze(H,vector<char>(W));
  REP(h,0,H)REP(w,0,W){
    cin>>maze.at(h).at(w);
  }
  ll ans=-1;
  REP(h,0,H)REP(w,0,W){
    if(maze[h][w]=='#')continue;
    ll tmp_ans=0;
    vector<vector<ll>> visited(H,vector<ll>(W,-1));
    visited[h][w]=0;
    queue<P> que;
    que.push(P(h,w));
    while(que.size()){
      P p=que.front();que.pop();
      for(auto dyx:DYX){
        ll ny=p.first+dyx[0],nx=p.second+dyx[1];
        if((0<=ny)&&(ny<H)&&(0<=nx)&&(nx<W)&&(maze[ny][nx]!='#')&&(visited[ny][nx]==-1)){
          visited[ny][nx]=visited[p.first][p.second]+1;
          tmp_ans=max(tmp_ans,visited[ny][nx]);
          que.push(P(ny,nx));
        }
      }
    }
    ans=max(ans,tmp_ans);
  }
  print(ans)
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
static const int INF (1<<30);

int D, G, p[15], c[15];
int ans = INF;
bool done[15];

void dfs(int cnt, int rem, int id) {
  int score = (id+1) * 100;

  if ( (rem / score) <= p[id] ) {
    ans = min(ans, cnt + (rem + score - 1) / score);
    return;
  }

  if ( rem <= (score * p[id] + c[id]) ) {
    ans = min(ans, cnt + p[id]);
    return;
  }

  rem -= score * p[id] + c[id];
  cnt += p[id];
  rep(i, D) {
    if (done[i]) continue;

    done[i] = true;
    dfs(cnt, rem, i);
    done[i] = false;
  }

  return;
}


int main() {
  cin >> D >> G;
  rep(i, D) {
    cin >> p[i] >> c[i];
    done[i] = false;
  }

  rep(i, D) {
    done[i] = true;
    dfs(0, G, i);
    done[i] = false;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
import heapq

N, M = map(int, input().split())

h = []
for i in range(N):
    A, B = map(int, input().split())
    heapq.heappush(h, (A, B))

count = 0
ans = 0
for i in range(N):
    A, B = heapq.heappop(h)
    if count + B >= M:
        ans += A * (M - count)
        break
    else:
        ans += A * B
        count += B
        
print(ans)

Measured memory_bytes: 16684
#![allow(non_snake_case)]
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    //let n: usize = sc.read();
    //let a: Vec<u64> = sc.vec(n);
    //let s = sc.chars();
    //let mut A: Vec<Vec<u64>> = (0..n).map(|_| sc.vec(n)).collect();
    let a: u64 = sc.read();
    println!("{}", a+a.pow(2)+a.pow(3));
}

struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        Self(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
        .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}




Measured memory_bytes: 2172
import java.util.*;

public class Main {
  public static void main(String[] args) {
    StringBuffer[] devide = {new StringBuffer("dream"), new StringBuffer("dreamer"), new StringBuffer("erase"), new StringBuffer("eraser")};
    Scanner sc = new Scanner(System.in);
    StringBuffer S = new StringBuffer(sc.next());
    S.reverse(); // 入力された文字列を反転
    for (int i = 0; i < devide.length; i++) {
      devide[i].reverse(); // devideのそれぞれの文字列を反転
    }
    boolean can = true;
    for (int i = 0; i < S.length(); ) {
      boolean can2 = false;
      for (int j = 0; j < devide.length; j++) {
        String d = new String(devide[j]);
        if (i + d.length() <= S.length() && S.substring(i, i + d.length()).equals(d)) {
          can2 = true;
          i += d.length();
        }
      }
      if (!can2) {
        can = false;
        break;
      }
    }
    if (can) {
      System.out.println("YES");
    } else {
      System.out.println("NO");
    }
  }
}

Measured memory_bytes: 29736
#include<iostream>
#include<deque>
#include<string>

const int MAX_N=100000;



struct Process{
	std::string name;
	int time;	
};

void doJobs(std::deque<struct Process>& rest_process,int q){
	struct Process p;
	int passedT=0;
	while(!rest_process.empty()){
		p=rest_process.front();
		if(p.time-q>0){
			p.time-=q;
			rest_process.push_back(p);
			passedT+=q;
		}else{
			std::cout<<p.name<<" "<<(passedT+=p.time)<<std::endl;
		}
		rest_process.pop_front();
	}
}


int main(void){
	int n,q;
	std::cin>>n>>q;
	struct Process p[MAX_N];
	std::deque<struct Process> rest_process;
	for(int i;i<n;i++){
		std::cin>>p[i].name>>p[i].time;
		rest_process.push_back(p[i]);
	}
	doJobs(rest_process,q);
	return 0;
}



Measured memory_bytes: 7736
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

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

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define sz(x) (ll)(x).size()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;
typedef vector<ll> vl;
typedef vector<P> vp;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  ll n, m;
  cin >> n >> m;
  if (n%2 == 1) { // odd
    // Here, we use i , n-i
    rep(i, m) {
      cout << i+1 << " " << n-1-i << endl;
    }
  } else { // even
    // Here, we use i,n-i
    ll pre = (m+1)/2;
    rep(i,pre) {
      cout << i+1 << " " << n-i << endl;
    }
    ll remain = m-pre;
    ll l = pre+1;
    ll r = n-pre;
    // Here, we pick from [l,r]
    rep(i,remain) {
      cout << l+i << " " << r-1-i << endl;
    }
  }
}


Measured memory_bytes: 3656
#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
typedef long long int ll;
using namespace std;

int main (void)
{
	char x, y;

	cin >> x >> y;

	if (x < y) cout << "<" << endl;
	else if (x > y) cout << ">" << endl;
	else cout << "=" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T> >;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repb(i, n) for(ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define reprb(i, a, b) for(ll i = (a)-1; i >= (b); i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(unsigned long long x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
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; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    string s_;
    cin >> s_;
    ll n = SZ(s_);
    ll k;
    cin >> k;
    vi s;
    rep(i, n){
        s.push_back(s_[i]-'a');
    }
    rep(i, n){
        if(s[i] > 0 && k >= (26-s[i])){
            k -= 26-s[i];
            s[i] = 0;
        }
        if(i == n-1){
            s[i] = (s[i]+k)%26;
        }
        cout << char(s[i]+'a');
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1020
#include<bits/stdc++.h>
#define int long long int
#define pb push_back
#define  fill(st,et,val,arr) for(int i=st;i<=et;i++)arr[i]=val;
#define all(v) v.begin(),v.end()
template <class T>
inline void read(T &x) {
    x = 0;
    char ch = getchar(), w = 0;
    while (!isdigit(ch)) w = ch == '-', ch = getchar();
    while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
    x = w ? -x : x;
    return;
}
 
const int M=1e9 + 7;
const int MAX=1e5+7;
using namespace std;
bool comp(int a,int b)
{	
	return a>b;
}
void printQ(vector<int> q)
{   
    cout<<"v->  ";
	for(int i=0;i<q.size();i++)
	{
		cout<<q[i]<<" ";
	}
	cout<<endl;
}
int cel(int d,int n)
{
	int ans=d/(n+1);
	if((d%(n+1))!=0)ans++;
	return ans;
}
int32_t main() 
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n,m;
    cin>>n>>m;
    if(n==m)
    	cout<<"Yes"<<endl;
    else
    	cout<<"No"<<endl;
	return 0;
}













Measured memory_bytes: 256
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
// #include<C:\Users\J\Desktop\AC\athead.h>
#define showa(v) for(int iii = 0; iii < v.size(); iii++){ cout << v[iii] << " ";} cout << endl;
#define show(iiii) cout << iiii << endl; 
#define shows(iiiii) cout << iiiii << " ";
#define divs 1000000007
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <set>
#include <deque>
#include <numeric>
#include<tuple>
#include <utility>
#include <map>
using namespace std;

int saiki(int n, vector<long long int> &memo){
    // showa(memo)
    long long int res = 0;
    if (memo[n] == -1){
        res += ((saiki(n-1, memo))+(saiki(n-2, memo)));
        memo[n] = res%divs;
        return memo[n];
    }
    else{
        return memo[n];
    }
}

int main(){
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  int itr = 0;
  int defhap = 0;
  int count = 0;
  while(itr < n){
      char stc = s[itr];
      int sti = itr;
      while(stc == s[itr] && itr <n){
          itr++;
        
      }
      int happy = (itr-sti) -1;
      defhap += happy;
      count++;
  } 

  if(count == 1){
    cout << defhap;
    return 0;
  }
  if(count == 2){
    cout << defhap+1;
    return 0;
  }
  if(2*k < count){
      defhap += 2*k;            
  }
  else{
      defhap += count-1;
  }
  cout << defhap;
}


Measured memory_bytes: 512