akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n;
            long res = Long.MAX_VALUE;
            n = in.nextInt();
            for (int i = 0; i <= n; i++) {
                long tp = 0;
                int tmp = i;
                while (tmp > 0) {
                    tp += tmp % 6;
                    tmp /= 6;


                }
                tmp = n - i;
                while (tmp > 0) {
                    tp += tmp % 9;
                    tmp /= 9;

                }
                res = Math.min(res, tp);
            }
            out.println(res);

        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 21460
while (m, f, r = gets.split(" ").map(&:to_i)) != [-1, -1, -1]
  if m == -1 or f == -1
    puts "F"
  elsif m + f > 79
    puts "A"
  elsif m + f > 64
    puts "B"
  elsif m + f > 49
    puts "C"
  elsif m + f > 29 and r > 49
    puts "C"
  elsif m + f > 29
    puts "D"
  else
    puts "F"
  end
end



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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

int main(){

    int n;
    cin >> n;
    vector<ll> v(n);
    bool over = false;
    ll ans = 1;
    ll pre = 1;
    for(int i = 0; i < n; i++){
        cin >> v[i];
        ans *= v[i];
        if(pre > ans){
            over = true;
        }
        pre = ans;
        if(v[i] == 0){
            cout << 0 << endl;
            return 0;
        }
        if(ans > powl(10, 18)){
            over = true;
        }
    }
    
    if(over){
        cout << -1 << endl;
    }
    else{
        cout << ans << endl;
    }    
    return 0;
}

Measured memory_bytes: 4052
#include <bits/stdc++.h>
// #include "ane.cpp"

const int INF  = 1e9;
const long long INFLL = 1e18;
const int NMAX = 100005;
const int MMAX = 100005;
const int KMAX = 1005;
const int MOD  = 1e9 + 7;
using namespace std;

// comment to disable debug functions
#define DEBUG

// frequently used macros

#if __cplusplus >= 201103L
#define ALL(v) begin(v),end(v)
#define SORT(v) sort(begin(v), end(v))
#define FIND(v,x) find(begin(v), end(v), (x))
#else
#define ALL(v) (v).begin(),(v).end()
#define SORT(v) sort(v.begin(), v.end())
#define FIND(v,x) find(v.begin(), v.end(), (x))
#endif

#define MEMNEXT(from, to) do{ memmove((to), (from), sizeof(from)); \
memset((from), 0, sizeof(from)); } while(0)
#ifdef DEBUG
#define DUMP(x) do{ std::cerr << "(DUMP) " << (#x) << ": " << x << std::endl; }while(0)
#else
#define DUMP(x) do{}while(0)
#endif

// frequent used aliases
typedef long long ll;
typedef pair<int, int> p;
typedef pair<ll, int> pl;
typedef pair<ll, ll> pll;
typedef vector<int> vec;
typedef vector<ll> vecll;
typedef vector<vec> mat;
typedef vector<vecll> matll;

// frequently used constants
static const int di[] = {-1, 0, 1, -1, 1, -1, 0, 1};
static const int dj[] = {-1, -1, -1, 0, 0, 1, 1, 1};

// frequently used structs
struct edge{
  int to,cost;
};

// printf for debug
#ifndef DEBUG
void debug(const char* format, ...){}
#else
void debug(const char* format, ...){
  va_list arg;
  va_start(arg, format);
  vprintf(format, arg);
  va_end(arg);
}
#endif

// std::fill of multi dimensions
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
  std::fill( (T*)array, (T*)(array+N), val );
}

// binary search
ll BSearch(ll _begin, ll _end, bool (*f)(int)){
  ll mid;
  while(_end - _begin > 1LL) {
  mid = (_begin + _end) / 2LL;
  if(f(mid)) {
    debug("BSearch: f(%d) == true\n", mid);
    _end = mid;
  }
  else
  {
    debug("BSearch: f(%d) == false\n", mid);
    _begin = mid;
  }
  }
  return _end;
}


ll N,M,K,A,B,C,D,E;
int dp[NMAX] = {};
std::vector<int> G[51];
string S;
vec v;

ll ans = 0;

void solve(){
  // main algorithm

}
void debug(){
  // output debug information

}
void answer(){
  // output answer
  for (int i = 0; i < N; ++i)
  {
    cout << G[i+1].size() << endl;
  }
}
int main(int argc, char const *argv[])
{
  // operate inputs

  // Fill(dp, -1);
  scanf("%lld%lld", &N,&M);
  for (int i = 0; i < M; ++i)
  {
    int x,y;
    cin >> x >> y;
    G[x].push_back(y);
    G[y].push_back(x);
  };
  solve();
  #ifdef DEBUG
  debug();
  #endif
  answer();

  return 0;
}

Measured memory_bytes: 256
/**
 *    author:  tourist
 *    created: 24.02.2018 15:59:56       
**/
#include <bits/stdc++.h>

using namespace std;

const int N = 1234;

char c[N][N];

void print(int n, int m, int a, int b, int have_a, int have_b) {
  puts("YES");
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (c[i][j] == '<' && have_a > a) {
        c[i][j] = c[i][j + 1] = '.';
        have_a--;
      }
      if (c[i][j] == '^' && have_b > b) {
        c[i][j] = c[i + 1][j] = '.';
        have_b--;
      }
      putchar(c[i][j]);
    }
    putchar('\n');
  }
  exit(0);
}

int main() {
  int n, m, a, b;
  scanf("%d %d %d %d", &n, &m, &a, &b);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      c[i][j] = '.';
    }
  }
  int have_a = 0, have_b = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j + 1 < m; j += 2) {
      have_a++;
      c[i][j] = '<';
      c[i][j + 1] = '>';
    }
  }
  if (m % 2 == 1) {
    for (int i = 0; i + 1 < n; i += 2) {
      have_b++;
      c[i][m - 1] = '^';
      c[i + 1][m - 1] = 'v';
    }
  }
  if (have_a >= a && have_b >= b) {
    print(n, m, a, b, have_a, have_b);
  }
  for (int i = 0; i + 1 < n; i += 2) {
    for (int j = 0; j + 1 < m; j += 2) {
      c[i][j] = '^';
      c[i][j + 1] = '^';
      c[i + 1][j] = 'v';
      c[i + 1][j + 1] = 'v';
      have_a -= 2;
      have_b += 2;
      if (have_a >= a && have_b >= b) {
        print(n, m, a, b, have_a, have_b);
      }
    }
  }
  if (n % 2 == 1 && m % 2 == 1 && n >= 3 && m >= 3) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        c[i][j] = '.';
      }
    }
    c[n - 1 - 0][m - 1 - 0] = 'v';
    c[n - 1 - 1][m - 1 - 0] = '^';
    c[n - 1 - 2][m - 1 - 0] = '>';
    c[n - 1 - 2][m - 1 - 1] = '<';
    c[n - 1 - 2][m - 1 - 2] = '^';
    c[n - 1 - 1][m - 1 - 2] = 'v';
    c[n - 1 - 0][m - 1 - 2] = '<';
    c[n - 1 - 0][m - 1 - 1] = '>';
    have_a = have_b = 2;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j + 1 < m; j += 2) {
        if (i >= n - 3 && j >= m - 3) {
          continue;
        }
        have_a++;
        c[i][j] = '<';
        c[i][j + 1] = '>';
      }
    }
    for (int i = 0; i + 3 < n; i += 2) {
      have_b++;
      c[i][m - 1] = '^';
      c[i + 1][m - 1] = 'v';
    }
    if (have_a >= a && have_b >= b) {
      print(n, m, a, b, have_a, have_b);
    }
    for (int i = 0; i + 1 < n; i += 2) {
      for (int j = 0; j + 1 < m; j += 2) {
        if (i >= n - 3 && j >= m - 3) {
          continue;
        }
        c[i][j] = '^';
        c[i][j + 1] = '^';
        c[i + 1][j] = 'v';
        c[i + 1][j + 1] = 'v';
        have_a -= 2;
        have_b += 2;
        if (have_a >= a && have_b >= b) {
          print(n, m, a, b, have_a, have_b);
        }
      }
    }

  }
  puts("NO");
  return 0;
}


Measured memory_bytes: 2432
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<list>
#include<stack>
#include<map>
#include<set>
#include<string>
#include <sstream>
#include<bitset>

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

using namespace std;
const int INF = 0x7fffffff;

struct Node{
  int key;
  Node *right,*left,*parent;
};

Node *root,*NIL;

void insert(Node* z){

  Node* y;
  Node* x;

  y = NIL;
  x = root;
  //cout << "insert key" << z->key <<endl;
  //printf("root:%x nill:%x",root,NIL);

  while(x != NIL){
    
    //cout << "in while" <<endl;
    y = x;

    if(z->key < x->key){
      x = x->left;
    }

    else{
      x = x->right;
    }
  }
  
  z->parent = y;
  //cout << "set parent";
  if(y == NIL){
    //cout << "decision root" << endl;
    root = z;
  }
  else if(z->key < y->key){
    y->left = z;
  }
  else{
    y->right = z;
  }
    


}

void inorder(Node* u){
  if(u == NIL){return;}

  inorder(u->left);
  cout << " " << u->key;
  inorder(u->right);

}

void preorder(Node* u){
  if(u == NIL){return;}
  cout << " " << u->key;
  preorder(u->left);
  preorder(u->right);
}

int main(){

  long ii,jj,kk;
  vector<int> a;
  int n;

  cin >> n;

  string command;
  int key;
  Node* z;

  //root = (Node*)malloc(sizeof(Node));
  //NIL  = (Node*)malloc(sizeof(Node));

  for(ii=0;ii<n;ii++){
    cin >> command ;

    if(command == "insert"){

      cin >> key;
      z = (Node*)malloc(sizeof(Node));
      z->key = key;
      z->left = NIL;
      z->right = NIL;
      insert(z);
    }
    
    else{
      inorder(root);
      cout << endl;
      preorder(root);
      cout << endl;  
    }

  }



  return 0;
}



Measured memory_bytes: 26584
import sys
def input():
    return sys.stdin.readline()[:-1]

n = int(input())
A = list(map(int, input().split()))

def partition(A,p,r):
    x = A[r]
    i = p-1
    for j in range(p,r):
        if A[j] <= x:
            i += 1
            A[i],A[j] = A[j],A[i]
    A[i+1],A[r] = A[r],A[i+1]
    return i+1

q = partition(A,0,n-1)

A[q] = [A[q]]
print(*A)


Measured memory_bytes: 16384
n = int(input())
x = list(map(int, input().split()))

a = int(sum(x)//len(x))
b = a + 1
c = 0
d = 0

for i in range(n):
    c = c + (x[i]-a)**2
    d = d + (x[i]-b)**2

print(int(min(c,d)))

Measured memory_bytes: 3060
#include<iostream>
#include<cmath>
using namespace std;
int a,b,c,d;
int main() {
	while(cin>>a>>b>>c>>d) {
		int r1 = c/b+(c%b ? 1:0);
		int r2 = a/d+(a%d ? 1:0);
//		cout<<"r1="<<r1<<endl<<"r2="<<r2<<endl;
		if(r1<=r2) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}


}


Measured memory_bytes: 3580
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{
    int x,y,z;
    scanf("%d%d",&x,&y);
    for(z=1;z<=3;z++)
    {
        if(x*y*z%2)
        {
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");
    return 0;
}


Measured memory_bytes: 128
import java.util.*;

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

	public Main() {
		double max=0;
        double min=99999999;
        while(in.hasNext()){
            double h=in.nextDouble();
            max = Math.max(max, h);
            min = Math.min(min, h);
        }
        System.out.println(max-min);
	}
	
}

Measured memory_bytes: 18612
N = int(input())
A = input()
B = input()
C = input()

count = 0

for i in range(N):
    if A[i] == B[i]:
        if C[i] != A[i]:
            count += 1
    elif A[i] == C[i]:
        if B[i] != C[i]:
            count += 1
    elif B[i] == C[i]:
        count += 1
    else:
        count += 2

print(count)

Measured memory_bytes: 3064
package main

import (
	"fmt"
	"sort"
)

func main() {
	var k, n int
	fmt.Scanf("%d %d", &k, &n)
	houses := scanIntSlice(n)
	sort.Ints(houses)
	max := houses[0] + (k - houses[n-1])
	for i := 1; i < n; i++ {
		if houses[i]-houses[i-1] > max {
			max = houses[i] - houses[i-1]
		}
	}
	fmt.Printf("%d\n", k-max)
}

func scanIntSlice(size int) []int {
	input := []int{}
	for i := 0; i < size; i++ {
		var in int
		fmt.Scanf("%d", &in)
		input = append(input, in)
	}
	return input
}


Measured memory_bytes: 7552
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
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;}
const ll INF = 1LL << 60;
const double pi = acos(-1.0);

ll dp[11000];

int main() {
    ll h, n; cin >> h >> n;
    rep(i, 11000) dp[i] = INF;
    dp[0] = 0;
    rep(i, n) {
        ll a, b; cin >> a >> b;
        rep(j, h) chmin(dp[min(h, j+a)], dp[j] + b);
    }
    cout << dp[h] << endl;
}


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

//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

#define rep(i,n) for(i=1;i<=n;i++)
#define Rep(i,n) for(i=0;i<n;i++)
#define For(i,a,b) for(i=a;i<=b;i++)

#define pb(x) push_back(x)
#define sz(x) x.size()

#define mem(ara,val) memset(ara,val,sizeof(ara))
#define eps 1e-9

#define si(x) scanf("%d",&x)
#define sii(x,y) scanf("%d %d",&x,&y)
#define siii(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define sl(x) scanf("%lld",&x)
#define sll(x,y) scanf("%lld %lld",&x,&y)
#define slll(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define ss(ch) scanf("%s",ch)
#define pi(x) printf("%d",x)
#define pii(x,y) printf("%d %d",x,y)
#define piii(x,y,z) printf("%d %d %d",x,y,z)
#define pl(x) printf("%lld",x)
#define pll(x,y) printf("%lld %lld",x,y)
#define plll(x,y,z) printf("%lld %lld %lld",x,y,z)
#define ps(ch) printf("%s",ch)
#define Afridi 0
#define NL printf("\n")
#define debug(x) printf("wow  %d !!\n",x)
#define Max 8005
#define INF (LL)1e18
#define mod 1000000007

#define FI freopen("in.txt","r",stdin)

#define D(x) cout << #x << " = " << x << endl
#define DD(x,y) cout << #x << " = " << x << "   " << #y << " = " << y << endl

typedef long long LL;
typedef unsigned long long ULL;

using namespace std;


LL bigmod(LL b,LL p,LL m)
{
    if(p == 0)return 1;
    LL my = bigmod(b,p/2,m);
    my*=my;my%=m;
    if(p & 1)my*=b,my%=m;
    return my;
}
int setb(int n,int pos){return n=n | (1 << pos);}
int resb(int n,int pos){return n=n & ~(1 << pos);}
bool checkb(int n,int pos){return (bool)(n & (1 << pos));}

char str[100];

int main()
{
	LL a,b,x,y;
    sll(a,b);
    sll(x,y);
    LL l = max(a,x);
    LL r = min(b,y);
    LL ret = r - l;
    if(ret < 0)ret = 0;
    pl(ret); NL;
	return 0;
}


Measured memory_bytes: 256
from collections import Counter
t = []
for i in range(3):
    a, b = map(int, input().split())
    t.append(a)
    t.append(b)

a = Counter(t).most_common()
if len(a) < 4:
    print("NO")
else:
    for i in range(4):
        if i <= 1:
            if a[i][1] == 2:
                continue
            else:
                print("NO")
                exit()
print("YES")


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD =1e9+7;
using ll=long long;

int main() {
    ll n, m;
    cin >> n >> m;
    if(2*n >= m) cout << m/2 << endl;
    else cout << n + (m - 2*n)/4 << endl;
}

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

int main()
{
long long W;
long long H;
long long x;
long long y;
long double D;

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> W;
	cin >> H;
	cin >> x;
	cin >> y;

	D = W * H;
	if( W == 2 * x && H == 2 * y )
		cout << D / 2 << " 1" << endl;
	else
		cout << D / 2 << " 0" << endl;

	return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

ll mod(ll a){
  return (a % 1000000007);
}

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


int main(){
  ll a,b,c,d; cin >> a >> b >> c >> d;
  cout << min(a,b) + min(c,d) << endl;
}

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil,pi,factorial
    from operator import itemgetter
    def I(): return int(input())
    def MI(): return map(int, input().split())
    def LI(): return list(map(int, input().split()))
    def LI2(): return [int(input()) for i in range(n)]
    def MXI(): return [[LI()]for i in range(n)]
    def SI(): return input().rstrip()
    def printns(x): print('\n'.join(x))
    def printni(x): print('\n'.join(list(map(str,x))))
    inf = 10**17
    mod = 10**9 + 7
#main code here!
    s=SI()
    k=I()
    u=len(s)
    seq=0
    x=1
    for i in range(u-1):
        if s[i]==s[i+1]:
            x+=1
        else:
            seq+=x//2
            x=1
    seq+=x//2
    #print(seq)
            
    a=1
    for i in range(u-1):
        if s[0]==s[i+1]:
            a+=1
        else:
            break
    b=1
    for i in range(u-1):
        if s[-1]==s[u-1-(1+i)]:
            b+=1
        else:
            break
    #print(a,b)
    if x==u:
        ans=(u*k)//2
    else:
        if s[0]!=s[-1]:
            ans=(seq)*k
        else:
            ans=(seq)*k-(a//2+b//2-(a+b)//2)*(k-1)
    print(ans)
        





if __name__=="__main__":
    main()


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

bool month(int n){
    return n >= 1 && n <= 12;
}

int main(){
    string S;
    cin >> S;

    int head = (S[0]-'0')*10 + (S[1]-'0');
    int bot = (S[2]-'0')*10 + (S[3]-'0');

    if(!(month(head) || month(bot))) cout << "NA" << '\n';
    else if(!(month(head))) cout << "YYMM" << '\n';
    else if(!(month(bot))) cout << "MMYY" << '\n';
    else cout << "AMBIGUOUS" << '\n';

    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

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

ll factorial(ll n) {
  ll answer = 1;
  while (n > 1) {
    answer *= n;
    answer %= mod;
    n--;
  }
  return answer;
}

ll combination(ll n, ll r) {
  return factorial(n) / (factorial(r) * factorial(n - r));
}

ll permutation(ll n, ll r) { return factorial(n) / factorial(n - r); }

template <typename T>
void remove(std::vector<T>& vector, unsigned int index) {
  vector.erase(vector.begin() + index);
}

map<ll, ll> prime_factor(ll n) {
  map<ll, ll> ret;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1) ret[n] = 1;
  return ret;
}
// for (auto p : prime_factor(n)) {
//	while (p.second--) {
//		cout << p.first << endl;
//	}
//}

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

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

vector<ll> Eratosthenes(const ll N) {
  bool is_prime[1000000 + 1];
  vector<ll> P;
  for (ll i = 0; i <= N; i++) {
    is_prime[i] = true;
  }
  for (ll i = 2; i <= N; i++) {
    if (is_prime[i]) {
      for (ll j = 2 * i; j <= N; j += i) {
        is_prime[j] = false;
      }
      P.emplace_back(i);
    }
  }
  return P;
}

typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

int main() {
  int N, L;
  cin >> N >> L;
  ll ans = 0;
  ll minAzi = INF;
  REP(i, N) {
    ll azi = L + i - 1 + 1;
    ans += azi;
    minAzi = (abs(minAzi) > abs(azi) ? azi : minAzi);
  }
  ans -= minAzi;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SORT(i) sort((i).begin(),(i).end())
constexpr int INF = 2000000000;
constexpr int mod = 1000000007;

template<class T>inline bool chmin(T & a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}


int main() {
	string s; cin >> s;
	string ans;
	rep(i, s.size()) {
		if (s[i] == '0')ans.push_back('0');
		if (s[i] == '1')ans.push_back('1');
		if (s[i] == 'B' && !ans.empty())ans.pop_back();
	}
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) throws Exception {
        Thread thread = new Thread(null, new TaskAdapter(), "", 1 << 27);
        thread.start();
        thread.join();
    }

    static class TaskAdapter implements Runnable {
        @Override
        public void run() {
            InputStream inputStream = System.in;
            OutputStream outputStream = System.out;
            FastReader in = new FastReader(inputStream);
            PrintWriter out = new PrintWriter(outputStream);
            APluralForm solver = new APluralForm();
            solver.solve(1, in, out);
            out.close();
        }
    }

    static class APluralForm {
        public void solve(int testNumber, FastReader s, PrintWriter w) {
            char[] c = s.next().toCharArray();
            if (c[c.length - 1] == 's') {
                w.print(c);
                w.println("es");
            } else {
                w.print(c);
                w.println("s");
            }
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {

            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {

                curChar = 0;

                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }

            return buf[curChar++];
        }

        public String next() {

            int c = read();

            while (isSpaceChar(c))
                c = read();

            StringBuilder res = new StringBuilder();

            do {
                res.appendCodePoint(c);
                c = read();
            }
            while (!isSpaceChar(c));

            return res.toString();
        }

        public boolean isSpaceChar(int c) {

            if (filter != null)
                return filter.isSpaceChar(c);

            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



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

int main() {
      auto able = [](string S) {
        for (unsigned int i = 0; i < S.length(); i++) {
            if (i % 2 == 0) {
                // 奇数文字目
                if (S[i] == 'L')
                    return false;
            } else {
                // 偶数文字目
                if (S[i] == 'R')
                    return false;
            }
        }
        return true;
    };
    string S;
    cin >> S;

    if (able(S))
        cout << "Yes";
    else
        cout << "No";
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define fr(i,s,e) for(i=s;i<e;i++)
#define rf(i,s,e) for(i=s-1;i>=e;i--)
#define pb push_back
#define eb emblace_back
#define mp make_pair
#define ff first
#define ss second
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vvvi> vvvvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<vvvll> vvvvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<vvc> vvvc;
typedef vector<pair<long long,long long> > vpll;
typedef vector<vector<pair<ll,ll> > > vvpll;
typedef vector<bool> vb;
typedef vector<vb> vvb;

#define PI 3.141592653589793
#define MOD 1000000007

template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }


int main()
{
	IOS;
	ll n;
	cin>>n;
	vll v(n);
	for(ll i=0;i<n;i++)
	{
		cin>>v[i];
	}
	vll a(5,0);
	for(ll i=0;i<n;i++)
	{
		if(v[i]%2)
		{
			a[1]++;
		}
		else
		{
			if(v[i]%4==0)
			{
				a[4]++;
			}
			else
			{
				a[2]++;	
			}	
		}
	}
	if(a[2]>0)
	{
		a[1]++;
	}
	if(a[1]<=a[4]+1)
	{
		cout<<"Yes";
	}
	else
	{
		cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include <functional>
#include <queue>
#include <regex>
#include<time.h>

using namespace std;

constexpr int MOD = 1000000007;
constexpr int INF = 1050000000;

#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl

#define Tof(x) (x) ? Yes : No
#define TOF(x) (x) ? YES : NO
#define tof(x) (x) ? yes : no

using ll = long long;


/*vectorの要素を全部確認するやつだよ。


for (vector<int>::iterator itr = ans.begin(); itr != ans.end(); ++itr) {
	cout << *itr << " ";
}


*/


/*for文でx,yを上下左右確認するやつだよ。

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


for (int i = 0; i < 4; i++) {
	int ny = y + dy[i];
	int nx = x + dx[i];
}
*/

/*繰り返し二乗法だよ。modもとってくれるよ。n^kをmodで割った余りでやってくれるよ。

ll POW_MOD(ll n, ll k, ll mod) {
	ll r = 1;

	for (; k > 0; k >>= 1) {
		if (k & 1) {
			r = (r * n) % mod;
		}
		n = (n * n) % mod;
	}
	return r;
}

*/

/*2重for文書くのめんどくなった時用だよ。

for (int i = 0; i < h; i++) {
	for (int j = 0; j < w; j++) {

	}
}

*/

/*まだ使えないテクニックのメモだよ。
for (int bit = 0; bit < (1<<n); ++bit)//bit全探索用のfor文だよ
*/

#pragma GCC optimize ("-O3", "unroll-loops")

constexpr int MN = 200000;

int main(void) {

	size_t n;; cin >> n;

	unsigned a[MN], b[MN];

	for (size_t i = 0; i < n; ++i) {
		scanf("%d",&a[i]);
	}
	for (size_t i = 0; i < n; ++i) {
		scanf("%d", &b[i]);
	}

	constexpr size_t aa = 4, bb = 8192;
	constexpr size_t AA = 3, BB = 8191;
	unsigned ans = 0;

	for (size_t i = 0; i + AA < n; i += aa) {
		for (size_t j = 0; j + BB < n; j += bb) {
			for (size_t k = j; k < j + bb; ++k) {
				ans ^= (a[i] + b[k]) ^ (a[i + 1] + b[k]);
				ans ^= (a[i + 2] + b[k]) ^ (a[i + 3] + b[k]);
			}
		}
		for (size_t j = n & ~(BB); j < n; ++j) {
			ans ^= (a[i] + b[j]) ^ (a[i + 1] + b[j]);
			ans ^= (a[i + 2] + b[j]) ^ (a[i + 3] + b[j]);
		}
	}

	for (size_t i = n & ~(AA); i < n; ++i) {
		for (size_t j = 0; j + (BB) < n; j += bb) {
			for (size_t k = j; k < j + bb; ++k) {
				ans ^= a[i] + b[k];
			}
		}

		for (size_t j = n & ~(BB); j < n; ++j) {
			ans ^= a[i] + b[j];
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] a = new int[n];
        int sum = 0;
        for (int i=0;i<n;i++){
            a[i]=sc.nextInt();
            sum+=a[i];
        }
        int ans = 0;
        for (int i=0;i<n;i++){
            if (a[i]*4*m>=sum) {
                ans++;
            }
        }
        if (ans>=m)System.out.println("Yes");
        else System.out.println("No");
    }
    static long factorial(long num){
        if (num<2)return 1;
        else return num*factorial(num-1);
    }
    static int arraySum(int[] array){
        int ans = 0;
        for (int value : array) ans += value;
        return ans;
    }
    static long combination(long a, long b){
        long data = 1;
        for (int i=0;i<b;i++){
            data*=a-i;
        }
        return data/factorial(b);
    }
    static double log(double base,double antilogarithm){
        return Math.log(antilogarithm)/Math.log(base);
    }

    static long gcd(long x,long y){
        if (y==0)return x;
        else return gcd(y,x%y);
    }
    static long lcm(long x,long y){
        return x/gcd(x,y)*y;
    }

}


Measured memory_bytes: 35776
import copy
h,w,k=map(int,input().split())
c=[list(map(lambda x:x=="#", input())) for _ in range(h)]
ans=0
for p in range(2**h):
	for q in range(2**w):
		d=copy.deepcopy(c)
		for i in range(h):
			for j in range(w):
				if (p>>i)%2==1 or (q>>j)%2==1:
					d[i][j]=False
		x=0
		for i in range(h):
			for j in range(w):
				if d[i][j]:
					x+=1
		if x==k:
			ans+=1
print(ans)

Measured memory_bytes: 9280
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<queue>
#define _USE_MATH_DEFINES
#include<math.h>
#include<cmath>
#include<ctime>
#include<map>
#include<typeinfo>
#define R(i, n) for(int i = 0;i < n; i++)
#define S(a) scanf("%d", &a)
#define S2(a, b) scanf("%d%d", &a, &b)
#define S3(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define SL(a) scanf("%lld", &a)
#define SL2(a, b) scanf("%lld%lld", &a, &b)
#define SL3(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)
#define SA(i, n, a) R(i, n) scanf("%d", &a[i])
#define SAL(i, n, a) R(i, n) scanf("%lld", &a[i])
#define SC(a) scanf("%c", &a)
#define P(a) printf("%d", a)
#define PL(a) printf("%lld", a)
#define PY printf("YES")
#define PN printf("NO")
#define Py printf("Yes")
#define Pn printf("No")
using namespace std;
using ll = long long;
using PR = pair<int, int>;
const ll MOD = 1e+9 + 7;
const int INF = 1e+9;
const double PI = acos(-1);

int main() {
	int x, n;
	S2(x, n);
	vector<int> v(n);
	R(i, n) {
		int num;
		S(num);
		v[i] = num;
	}
	if (find(v.begin(), v.end(), x) == v.end()) P(x);
	else {
		R(i, n) {
			if (v[i] == x) {
				int d = 1;
				while (true) {
					if (find(v.begin(), v.end(), x - d) == v.end()) {
						P(x - d);
						return 0;
					}
					else if (find(v.begin(), v.end(), x + d) == v.end()) {
						P(x + d);
						return 0;
					}
					d++;
				}
			}
		}
	}
}

Measured memory_bytes: 3792
import java.util.*;
import java.util.stream.Collectors;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		int N = Integer.parseInt(in.readLine());
		int remain = 10000 - N;
		remain %= 1000;
		System.out.println(remain);
	}

	void calc() {
	}

	void showResult() {
	}
}


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

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

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/04/24  Problem: ABC 123 A / Link: http://abc123.contest.atcoder.jp/tasks/abc123_a  ----- */


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

	int N = 5;
	vector<int> a(N);
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
	}
	int K; cin >> K;
	LL ans = a.back()-a.front();
	
	
	cout <<(ans<=K?"Yay!":":(") << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

void solve() {
  long N;
  cin >> N;
  long ttt = 0;
  long aaa = 0;
  rep (i, N) {
    long t, a;
    cin >> t >> a;
    if (i == 0) {
      ttt = t;
      aaa = a;
      continue;
    }
    long _t = ttt / t;
    if (_t * t < ttt) _t++;
    long _a = aaa / a;
    if (_a * a < aaa) _a++;
    ttt = max(_t, _a) * t;
    aaa = max(_t, _a) * a;
  }
  cout << ttt + aaa << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


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

int main()
{
	string str;
	cin >> str;
	int flag1 = 0, flag2 = 0;
	for(int i = 0; i < str.size(); i ++)
	{
		if(str[i] == 'A') flag1 = 1;
		if(str[i] == 'B') flag2 = 1;
	}
	if(flag1 && flag2) cout << "Yes" <<'\n';
	else cout << "No" << '\n';
	return 0;
 } 

Measured memory_bytes: 256
from collections import Counter

s = str(input())

d = Counter(s)
l = [0] * 3
k = 0
for i, j in d.items():
    l[k] = j
    k += 1
Palindrome = False
for i in range(3):
    if abs(l[i-1] - l[i]) > 1:
        Palindrome = True

if Palindrome:
    print('NO')
else:
    print('YES')

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
int n,a[100007],s;
int main(){
  cin >> n;
  for(int i = 1; i<=n; i++) cin >> a[i];
  for(int i = 0; i<=n; i++) s+=abs(a[i]-a[i+1]);
  for(int i = 1; i<=n; i++)
    cout<<s+abs(a[i-1]-a[i+1])-abs(a[i]-a[i+1])-abs(a[i]-a[i-1])<<endl;
}


Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

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

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll to;
	ll d;
};


///////////////////////////

int main() {

	ll N, M;
	cin >> N >> M;

	vector<ll> st(N + 1,0), fn(N + 1,0);

	repn(i, M) {
		ll a, b;
		cin >> a >> b;
		if (a == 1) { st[b] = 1; }
		if (b == N) { fn[a] = 1; }
	}

	string ans = "IMPOSSIBLE";

	repn(i, N - 1) {
		if (st[i] == 1 && fn[i] == 1) { ans = "POSSIBLE"; }
	}

	cout << ans;

	system("PAUSE");
}


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

ll N;
ll sum = 0;
int main()
{
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        sum += i;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3608
# include<bits/stdc++.h>
# define ll long long
# define lli long long int
using namespace std;
int main(){
  int n;
  cin>>n;
  int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cout<<a[n-1]<<"\n";
return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef vector<vi> vvi;
const int MOD = 1e9 + 7;

#define fastIO \
ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define endl '\n'
#define pb push_back
#define ff first
#define ss second
#define mp make_pair 

int main() {
    fastIO;
    int N;
    cin >> N;
    ll ans = 0;
    for (int i = 1; i <= N; i++) {
        ans += i * 1ll * (N - i + 1);
    }
    for (int i = 0; i < N - 1; i++) {
        int u, v;
        cin >> u >> v;
        if (u > v)  swap(u, v);
        ans -= u * 1ll * (N - v + 1);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3664
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<utility>
#include<math.h>
#include<set>
#include<map>
#include<string.h>
#include<stack>
#define n 200000
#define loop(i, a, b) for(int i = a; i<=b; i++)
using namespace std;
typedef pair<int, int> P;
typedef long long lli;
typedef double llf;
struct edge{
	int from, to, weight;
	bool operator < (const edge& thing) const
	{
		return thing.weight < weight;
	}
};
vector<edge> V[n + 50];
bool visit[n + 50];
int arr[n + 50], a, b, c, d, e;
string str1, str2;
void addedge(int a, int b, int c)
{
	edge temp;
	temp.from = a;
	temp.to = b;
	temp.weight = c;
	V[a].push_back(temp);
}


//////////////////////////////////////////


void solve()
{
	cin >> a >> b >> c;
	int one = 0, two = 0;
	loop(i, 0, b - 1)
	{
		int temp;
		cin >> temp;
		if(temp < c) one ++;
		else         two ++;
	}
	cout << min(one, two) << '\n';
}
int main()
{
	int times = 1;
//	cin << times;
	loop(i, 1, times)
	{
		solve();
		printf("\n");
	}
	return 0;
}




Measured memory_bytes: 4992
#include <bits/stdc++.h>
    using namespace std;
     
    #define AS(arr)  (sizeof(arr)/sizeof(arr[0]))
    #define ALL(c) (c).begin(),(c).end() 
    #define SIZE(a) int((a).size())
    #define EACH(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
    #define REP(i,n) for(int i=0;i<(int)n;++i)
     
    #define DEBUG(x) cout<<#x<<": "<<x<<endl
    #define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
     
    #define pb push_back
    #define mp make_pair
     
    typedef vector<int> VI;
    typedef vector<string> VS;
    typedef long long LL;
     
    const double EPS = 1e-11;
    #define EQ(a,b) (abs(a-b)<EPS)
    #define EQ0(x) (abs(x)<EPS)
     
    int a[100005];
    int main(void){
       int N;
       cin >> N;
       REP(i, N)
       {
           cin >> a[i];
       }
       int ret = 0;
       REP(i, N)
       {
           int si = a[i];
           if(a[a[i]-1] == i+1)
           {
               ret++;
           }
       }
       ret /= 2;
       cout << ret << endl;
       
    }

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

#define MOD 1000000007

int main()
{
    int H, W;
    cin >> H >> W;

    string C;
    for (int i = 0; i < H; i++)
    {
        cin >> C;
        cout << C << endl;
        cout << C << endl;
    }
}


Measured memory_bytes: 256
// Last Change: 01/13/2019 22:57:33.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}

int main() {
  int N;
  cin >> N;
  vector<ll> A(N);
  vector<ll> B(N);
  vector<ll> C(N);

  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  for (int i = 0; i < N; i++) {
    cin >> B[i];
  }

  ll diff = 0;
  for (int i = 0; i < N; i++) {
    C[i] = A[i] - B[i];
    diff += C[i];
  }

  if (diff < 0) {
    cout << -1 << endl;
    LoopUntilZeroInpput();
    return 0;
  }

  int front = 0;
  int back = N - 1;
  sort(C.begin(), C.end());

  while (C[front] < 0) {
    if (C[back] == 0) {
      back--;
    }
    if (C[front] * -1 > C[back]) {
      C[front] += C[back];
      C[back] = 0;
    } else {
      C[back] += C[front];
      front++;
    }
  }
  int ans = front;
  if (front != 0) {
    ans += N - back;
  }
  cout << ans << endl;
}


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

int main(int argc, char const* argv[])
{
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if (abs(a-c) <= d) {
        cout << "Yes" << endl;
    }else if ((abs(a-b) <= d) && (abs(b-c) <= d)) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;
const int INF = 1001001001;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
  int n;
  cin >> n;
  vector<int> a(n);

  mint sum = 0;
  rep(i, n) {
    cin >> a[i];
    sum += a[i];
  }

  mint ans = 0;
  rep(i, n - 1) {
    sum -= a[i];
    ans += sum * a[i];
  }

  cout << ans << endl;

}


Measured memory_bytes: 4060
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
  
#define mp make_pair
#define f first
#define s second
#define ll long long
#define pb push_back
#define popb pop_back
#define popf pop_front

using namespace std;

using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int inf = 2e9+7, mod=1e9+7;
const int N = 1e6+321, E=14e5;

ll xx[8]={1, 1, -1, -1, 1, -1, 0, 0};
ll yy[8]={1, -1, 1, -1, 0, 0, 1, -1};

bool a[200];

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
	int n, x;
	cin >> x >> n;
	for(int i=0; i<n; i++){
		int q;
		cin >> q;
		a[q]=1;
	}
	if(!a[x]){
		cout << x;
		return 0;
	}
	int k=1;
	while(1){
		if(!a[x-k]){
			cout << x-k;
			return 0;
		}
	
		if(!a[x+k]){
			cout << x+k;
			return 0;
		}
		k++;
	}
    return 0;
}

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

#define f first
#define s second
#define pb push_back
#define all(x) x.begin(), x.end()

using LL   =  long long;
using pii  =  pair <int, int>;
using vii  =  vector <pii>;

const int INF = INT_MAX;
const int MOD = 1e9 + 7;
const int N = 1e5 + 5;

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

    int n;
    cin>>n;
    cout<<48-n<<"\n";

    return 0;
}


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

long long n, a[200005], sum[200005], ans=LONG_LONG_MAX;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    for(int i=1; i<=n; i++) {
        cin >> a[i];
        sum[i] = sum[i-1]+a[i];
    }

    for(int i=1; i<=n-1; i++) {
        long long s = sum[i], r = sum[n]-sum[i];
        ans = min(ans, abs(s-r));
    }
    cout << ans << '\n';

    return 0;
}


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

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1e15;

int main() {
  string s;
  cin >> s;
  ll n = s.size();
  ll ans = n;
  ll cnt = 0;
  REP(i, n - 1) {
    if (s[i] != s[i + 1]) {
      ++cnt;
      ll l = max((ll)i, n - 1 - i);
      ll r = max((ll)i + 1, n - 2 - i);
      ll mx = max(l, r);
      ans = min(ans, mx);
    }
  }
  if (cnt == 0) ans = n;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512