akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n ,ans=0;
    cin >> n;
    int p[n];
    for (int i= 0; i<n; i++){
        cin >> p[i];
    }
    for (int i= 1; i<n-1; i++){
        if ((p[i-1] < p[i] && p[i] < p[i+1]) || p[i-1] > p[i] && p[i] > p[i+1]){
            ans++;
        }
    }
    cout << ans <<endl;
}


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

inline pair <int,int> read() {
	string s;
  cin >> s;
  int n = s.size(), miin = 0, sum = 0;
	for (int i = 0; i < n; i++) {
		sum += (s[i] == '(') ? 1 : -1;
		miin = min(miin, sum);
	}
	return {sum, miin};
}

inline bool comp(const pair<int,int> &a, const pair<int,int> &b) {
  return max(-a.second, -(a.first + b.second)) < max(-b.second,-(b.first + a.second));
}

int main () {
	int n; scanf ("%d",&n);
	
  vector <pair <int, int>> v;
  for (int i = 0; i < n; i++) v.push_back(read());

	sort(v.begin(),v.end(), comp);
	
  int sum = 0;

	for (int i = 0; i < n; i++) {
		if (sum + v[i].second < 0) return !printf ("No\n");
		sum += v[i].first;
	}

	if (sum == 0) printf ("Yes"); else printf ("No\n");
}

Measured memory_bytes: 11624
import java.util.Scanner;
public class Main {
	public static void main(String[] args)throws Exception{
		Scanner stdIn=new Scanner(System.in);
		double A=stdIn.nextInt();
		double B=stdIn.nextInt();
		double H=stdIn.nextInt();
		double W=stdIn.nextInt();
		double a=W*6-(H*30+W*0.5);
		a=Math.abs(a);
		if(a>180)
			a=360-a;
		System.out.println(Math.sqrt((A*A+B*B)-2*A*B*Math.cos(Math.toRadians(a))));
	}
}


Measured memory_bytes: 35960
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rrep(i,n) REP(i,1,n+1)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> PII;
typedef vector<ll> Vl;
typedef vector<int> VI;
typedef tuple<int, int, int> TT;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
const int MAX = 500000;
const int inf = 1000000007;
const ll mod = 1000000007;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;

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


ll a;
double b;
ll tmp;

int main() {

	cin >> a >> b;

	b *= 100;

	a = a * llround(b);



	cout << a / 100 << endl;

	return 0;
}


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

int main() {
    int N, P;
    cin >> N >> P;
    int m = 0;
    for (int i = 0; i < N; ++i) {
        int A; cin >> A;
        if (A % 2 == 1) ++m;
    }
    if (m == 0) cout << (P == 0 ? (1LL<<N) : 0) << endl;
    else cout << (1LL<<(N-1)) << endl;
}














Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int q = sc.nextInt();
    String[] line = sc.next().split("");
    int[] nums = new int[n];
    boolean flg = false;
    int current = 0;
    for (int i = 0; i < n; i++) {
      if (flg && "C".equals(line[i])) {
        current++;
        flg = false;
      } else if ("A".equals(line[i])) {
        flg = true;
      } else {
        flg = false;
      }
      nums[i] = current;
    }
    for (int i = 0; i < q; i++) {
      int a = sc.nextInt() - 1;
      int b = sc.nextInt() - 1;
      System.out.println(nums[b] - nums[a]);
    }
  }
}

Measured memory_bytes: 84588
#include <bits/stdc++.h>
using namespace std;
const int MID=505*505*2;
const int dx[4]={-1,0,1,0};
const int dy[4]={0,-1,0,1};
int n,m,i,j,e,x,y,nx,ny,cur,nxt,it,fi,fr,qx[MID*2],qy[MID*2],a[MID],d[505][505],v[505][505],was[505][505];
long long r;
int main() {
  scanf("%d",&n); m=n*n;
  for (i=1; i<=m; i++) scanf("%d",&a[i]);
  for (i=1; i<=n; i++) for (j=1; j<=n; j++) {
    d[i][j]=min(min(i-1,n-i),min(j-1,n-j));
    v[i][j]=1;
  }
  for (i=1; i<=m; i++) {
    x=(a[i]-1)/n+1;
    y=(a[i]-1)%n+1;
    v[x][y]=0;
    for (e=0; e<4; e++) {
      nx=x+dx[e];
      ny=y+dy[e];
      if (v[nx][ny]==0) d[x][y]=min(d[x][y],d[nx][ny]);
    }
    r+=d[x][y]; ++it;
    qx[fi=MID]=x; qy[fi]=y;
    for (fr=MID+1; fi<fr; ) {
      x=qx[fi];
      y=qy[fi++];
      if (was[x][y]==it) continue;
      was[x][y]=it;
      for (e=0; e<4; e++) {
        nx=x+dx[e];
        ny=y+dy[e];
        nxt=d[x][y]+v[x][y];
        if (d[nx][ny]>nxt) {
          d[nx][ny]=nxt;
          if (v[x][y]) {
            qx[fr]=nx; qy[fr++]=ny;
          } else {
            qx[--fi]=nx; qy[fi]=ny;
          }
        }
      }
    }
  }
  printf("%lld\n",r);
  return 0;
}


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

#define all(x) (x).begin(), (x).end()
#define X real()
#define Y imag()

typedef array<int, 3> tri;
typedef long long ll;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; cout << '\n'; return O;}


void _main() {
        //WRWWRWRR
        //RRRWWWWW
        int n; cin >> n;
        string str; cin >> str;
        int cnt = 0;
        int freq = count(all(str), 'R');
        queue<int> q;
        for (int i = 0; i < n; i++) {
                if (str[i] == 'R') {
                        if (i >= freq && q.size()) {
                                str[q.front()] = 'R';
                                str[i] = 'W';
                                q.pop();
                                cnt++;
                        }
                } else {
                        q.emplace(i);
                }
        }

        cout << cnt;
}

int main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}

Measured memory_bytes: 4212
// 解説AC
#include<iostream>
#include<vector>
using namespace std;

int f(int n, int k){
    if(n == 1)  return 0;
    return (f(n-1, k)+k)%n;
}

int main(){
    int n, k, m;
    while(cin >> n >> k >> m, n+k+m){
        //cout << (f(n-1,k)+m)%n+1 << endl;
        vector<int> v;
        for(int i = 1; i <= n; i++) v.push_back(i);
        v.erase(v.begin()+m-1);
        int pos = (m-2+k)%((int)v.size());
        while(v.size() > 1){
            v.erase(v.begin()+pos);
            pos = (pos-1+k)%((int)(v.size()));
        }
        cout << v[0] << endl;
    }
    return 0;
}


Measured memory_bytes: 3224
import Foundation

let input_line1 = readLine()!
let input_line2 = readLine()!

let split = input_line1.componentsSeparatedByString(" ") //components(separatedBy:)と実質同じ
let length = Int(split[0])!
let changePosition = Int(split[1])!
var targetCharacter = Array(input_line2.characters)
let changedCharacter = String(targetCharacter[changePosition - 1]).lowercaseString
targetCharacter[changePosition - 1] = Array(changedCharacter.characters)[0]

print(String(targetCharacter))

Measured memory_bytes: 7780
n, k = map(int, input().split())
sunukes = list(range(1, n+1))
for _ in range(k):
  d = int(input())
  a = list(map(int, input().split()))
  
  for i in a:
    if i in sunukes:
      sunukes.remove(i)
    
print(len(sunukes))

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

int main()
{
	int n, q;
	long a[1000];

	cin >> n;

	for(int i = 0; i < n; i++)
		cin >> a[i];

	cin >> q;

	for (int i = 0; i < q; i++) {
		int b, e, t;
		cin >> b >> e >> t;

		for (int i = 0; i < e - b; i++)
			swap(a[b + i], a[t + i]);
	}

	for (int i = 0; i < n - 1; i++) {
		cout << a[i] << " ";
	}
	cout << a[n - 1] << endl;

	return 0;
}


Measured memory_bytes: 3024
# B
a, b, c = map(int, input().split())

l = []
bool = True
i = 0
while bool:
    l.append(a*i%b)
    i += 1
    if l[0] == l[-1] and len(l) != 1:
        bool = False
        
if l.count(c) > 0:
    print('YES')
else:
    print('NO')

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

#define all(x) x.begin(),x.end() 
#define size(x) ll(x.size())
#define pb push_back
#define mp make_pair
#define F first
#define S second

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

int main() {
  int n,cnt=0;
  cin >> n;
  for(int i = 1; i <= n; i++) {
    string s;
    s = to_string(i);
    if(s.length () % 2 == 1) {
      cnt++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3656
using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string sCount =Console.ReadLine();
            int ncount = int.Parse(sCount);
            for (int i = 0; i < ncount; i++)
            {
                string input = Console.ReadLine();
                string[] data = input.Split();
                int data1 = int.Parse(data[0]);
                int data2 = int.Parse(data[1]);
                int data3 = int.Parse(data[2]);
                
                int ans = 0;
                if (data1 * data1 + data2 * data2 == data3 * data3)
                    ans++;
                if (data1 * data1 + data3 * data3 == data2 * data2)
                    ans++;
                if (data3 * data3 + data2 * data2 == data1 * data1)
                    ans++;

                if (ans == 0)
                    Console.WriteLine("NO");
                else
                    Console.WriteLine("YES");
            }
            Console.ReadLine();
            //while (true)
            //{
            //    string a = Console.ReadLine();
            //        if (a == null)
            //            break;
            //    string[] aa = a.Split();
            //    int data1 = int.Parse(aa[0]);
            //    int data2 = int.Parse(aa[1]);

            //    int data0 = data1 + data2;

            //    int count = 1;
            //    while (true)
            //    {

            //        data0 /= 10;
            //        if (data0 != 0)
            //            count++;
            //        else
            //            break;
            //    }
            //    Console.WriteLine(count);
            //}
            //Console.ReadLine();
            //int[] ans = { 0, 0, 0 };
            //for (int i = 0; i < 10; i++)
            //{
            //    string a = Console.ReadLine();
            //    int aa = int.Parse(a);

            //    if (ans[0] < aa)
            //    {
            //        ans[2] = ans[1];
            //        ans[1] = ans[0];
            //        ans[0] = aa;
            //    }
            //    else if (ans[1] < aa)
            //    {
            //        ans[2] = ans[1];
            //        ans[1] = aa;
            //    }
            //    else if (ans[2] < aa)
            //    {
            //        ans[2] = aa;
            //    }
            //}

            //Console.WriteLine(ans[0]);
            //Console.WriteLine(ans[1]);
            //Console.WriteLine(ans[2]);
            //Console.ReadLine();

            //    for (int i = 1; i <= 9; i++)
            //    {
            //        for (int ii = 1; ii <= 9; ii++)
            //        {
            //            string ans;
            //            ans = i+"x"+ii+"="+i*ii;
            //            Console.WriteLine(ans);

            //        }

            //    }
            //            Console.ReadLine();        }
        }
    }
}

Measured memory_bytes: 5420
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(ll i##_len=(n) ,i=i##_len-1;i>=0;--i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define fe(vec,lambda) std::for_each(vec.begin(), vec.end(), lambda );
#define printd(val) std::cout<< #val" = " <<val<<"\n";
#define printv(val) std::for_each(val.begin(),val.end(),[](auto x){cout<<x<<"\n";});
#define lim 1000000007ll
#include<bits/stdc++.h>
using ll = long long;
using pii = std::pair<ll,ll>;
using namespace std;
template<class T>T chmin(T& a,T b){if(a>b){a^=b;b^=a;a^=b;return 1;}return 0;}
template<class T>T chmax(T& b,T a){if(a>b){a^=b;b^=a;a^=b;return 1;}return 0;}
template <class T> T gcd(T a, T b){if (a < b) {a ^= b;b ^= a;a ^= b;} return b ? gcd(b, a % b) : a;}
template <class T> T lcm(T a, T b){return a * b / gcd(a, b);}
inline bool operator<(const pii &lhs,const pii &rhs){return(lhs.second<rhs.second);}
template<class T> vector<pair<T,T>> duplicator(const vector<T>& input){vector<pair<T,T>> out(input.size()-1);rep(i,input.size()-1){out[i].first =input[i  ];out[i].second=input[i+1];}return(out);}
vector<char> String_to_vector_char(const string& input){vector<char> out(input.size());rep(i,input.size()){out[i]=input[i];}return out;}
void YesNo(bool flag){ cout<<(flag? "Possible":"Impossible");}

ll a,b,c,d,n,x;
vector<ll>v[3];
map<ll,ll>m;
string s,s2;
void input(){
    cin>>a>>b;
}
void src(){
    cout<<(a-1)*(b-1);
}

int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

Measured memory_bytes: 256
/*
    A - White Cells
    https://atcoder.jp/contests/abc121/tasks/abc121_a
*/
#include <bits/stdc++.h>
using namespace std;

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

    int H, W, h, w;
    cin >> H >> W;
    cin >> h >> w;
    cout << ((H - h) * (W - w)) << endl;
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  int ans = 0;
  int sum = 0;
  for (int i = 0; i < n; ++i) {
    int x;
    scanf("%d", &x);
    ans += x * sum;
    sum += x;
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 128
class Segtree():  # Segtree

    def segfunc(self, x, y):  # 区間にしたい操作
        return max(x, y)  # ex) max,min,gcd,lcm,sum,product

    def __init__(self, LIST, ide_ele):  # LIST: 配列の初期値, ide_ele: 単位元
        n = len(LIST)
        self.ide_ele = ide_ele
        self.num = 1 << (n - 1).bit_length()
        self.tree = [ide_ele] * 2 * self.num
        for i in range(n):  # 配列の値を葉にセット
            self.tree[self.num + i] = LIST[i]
        for i in range(self.num - 1, 0, -1):  # 構築していく
            self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])

    def update(self, k, x):  # k番目の値をxに更新
        k += self.num
        self.tree[k] = x
        while k > 1:
            self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1

    def query(self, l, r):  # [l, r)のsegfuncしたものを得る
        res = self.ide_ele
        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r - 1])
            l >>= 1
            r >>= 1
        return res


n = int(input())
h = list(map(int, input().split()))
a = list(map(int, input().split()))

dp = Segtree([0] * (n + 1), 0)
for ai, hi in zip(a, h):
    dp.update(hi, dp.query(0, hi) + ai)
print(dp.query(0, n + 1))


Measured memory_bytes: 119848
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

class SegmentTree(object):
	def __init__(self, N):
		self.N = N
		self.N0 = 2 ** (N - 1).bit_length()
		self.initVal = 0
		self.data = [self.initVal] * (2 * self.N0)
 
	# 区間クエリの種類
	def calc(self, a, b):
		return max(a, b)
 
	#k番目の値をxに更新
	def update(self, k, x):
		k += self.N0 - 1
		self.data[k] = x
		while k > 0:
			k = (k - 1) // 2
			self.data[k] = self.calc(self.data[2 * k + 1], self.data[2 * k + 2])
 
	#区間[l, r]の演算値
	def query(self, l, r):
		L = l + self.N0; R = r + self.N0 + 1
		m = self.initVal
		while L < R:
			if R & 1:
				R -= 1
				m = self.calc(m, self.data[R - 1])
			if L & 1:
				m = self.calc(m, self.data[L - 1])
				L += 1
			L >>= 1; R >>= 1
 
		return m

def main():
	N, K = i_map()
	n = 3 * (10 ** 5) + 2
	Seg = SegmentTree(n)
	for _ in range(N):
		a = int(input())
		l = max(0, a - K)
		r = min(n - 1, a + K)
		res = Seg.query(l, r)
		Seg.update(a, res + 1)
 
	ans = Seg.query(0, n - 1)
	print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 86576
if __name__ == "__main__":
    n = '0' + input()

    ans = 0
    flag = 0

    for i in range(len(n)-1, 0, -1):
        if int(n[i]) + flag == 10:
            flag = 1
        elif int(n[i]) + flag > 5 or (int(n[i]) + flag == 5 and int(n[i-1]) > 4):
            ans += 10 - int(n[i]) - flag
            flag = 1
        else:
            ans += int(n[i]) + flag
            flag = 0

    if flag == 1:
        ans += 1

    print(ans)


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

s = input()

dp = [[0 for i in range(n+1)] for j in range(n+1)]

for i in reversed(range(n)):
    for j in reversed(range(n)):
        if s[i] == s[j]:
            dp[i][j] = dp[i+1][j+1] + 1
            
ans = 0

for i in range(n):
    for j in range(n):
        ans = max(ans,min(dp[i][j],j-i))
        
print(ans)

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

int main() {
    int m, d;
    cin >> m >> d;

    int cnt = 0;
    for (int i = 1; i <= m; i++) {
        for (int j = 1; j <= d; j++) {
            if (j < 10) continue;
            int d1 = j % 10;
            int d10 = j / 10;
            //cout << d1 << " " << d10 << endl;
            if ((d1 >= 2) && (d10 >= 2) && (d1 * d10 == i)) {
                cnt++;
                //cout << j << " " << cnt << endl;
            }
        }
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cctype>
int main(){
    char ch;
    while(1){
        scanf("%c",&ch);
        if(islower(ch)) ch=toupper(ch);
        else if(isupper(ch)) ch=tolower(ch);
        printf("%c",ch);
        if(ch=='\n') break;
    }
    return 0;
}

Measured memory_bytes: 2508
#include<iostream>
using namespace std;
typedef long long ll;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll R, G, B, N;
    cin >> R >> G >> B >> N;
    ll ans = 0;
    for (ll i = 0; i <= 3000; i++) {
        for (ll j = 0; j <= 3000; j++) {
            if (R * i + G * j > N) continue;
            if ((N - (R * i + G * j)) % B == 0) {
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  string S; cin >> S;
  reverse(S.begin(),S.end());
  
  while (1) {
    int N = S.size();
    if (N >= 5) {
      string S5 = S.substr(0,5);
      if (S5 == "maerd" || S5 == "esare") {
      S.erase(0,5);
      } else if (N >= 6) {
        string S6 = S.substr(0,6);    
        if (S6 == "resare") {
          S.erase(0,6);
        } else if (N >= 7) {
          string S7 = S.substr(0,7);
          if (S7 == "remaerd") {
            S.erase(0,7);
          } else {
            break;
          }
        } else {
          break;
        }
      } else {
        break;
      }
    } else {
      break;
    }
  }
  if (S.size() == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 3764
#include<iostream>
#include<string>
using namespace std;
int main(void)
{
    string set;
    int joi = 0;
    int ioi = 0;
    for (int a = 0; a<5; a++)
    {
        cin >> set;
        int b = set.size();
        for (int c = 0; c<b - 2; c++)
        {
            if (set.substr(c, 3) == "JOI") joi++;
            if (set.substr(c, 3) == "IOI") ioi++;
        }
        cout << joi << endl << ioi << endl;
        joi = 0;
        ioi = 0;
    }
    return 0;
}

Measured memory_bytes: 3128
#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
using namespace std;
using namespace __gnu_pbds;
template <class c, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}
typedef long long int ll;
const ll mod =1e9+7;
const int maxn = 100002;
#define endl '\n'
#define int ll
#define ld long double
#define all(x) (x).begin(),(x).end()

int32_t main()
{ 
   IOS
 

  int n,k;
  cin >> n >> k;
  vector<int> a(n);
  for(int i =  0;i<n;i++){
    cin>>a[i];
  }
  sort(all(a));
  if(a[n-1] == 0 and (k&1)){
    cout<<0<<endl;
    return 0;
  }
  if(a[n-1] <= 0 and (k&1)){
    int product = 1;
    for (int i = n - 1; i >= n - k; i--) 
            {product *= (mod + a[i]);product%=mod;} 
    cout<<product<<endl;
    return 0;
  }
   int product = 1;
   int i = 0; 
   int j = n - 1;  
    if (k & 1) { 
        product *= a[j]; 
        j--; 
        k--; 
    } 

      k >>= 1; 
    for (int itr = 0; itr < k; itr++) { 
        int left_product = a[i] * a[i + 1]; 
        int right_product = a[j] * a[j - 1]; 
        if (left_product > right_product) { 
            left_product = (left_product + mod*mod)%mod;
            product *= left_product;
            product%=mod; 
            i += 2; 
        } 
        else { 
            right_product = (right_product + mod*mod)%mod;
            product *= right_product;
            product%=mod; 
            j -= 2; 
        } 
    } 
  
    cout<<product<<endl;
    return 0;
  


  
}

Measured memory_bytes: 4780
#include<iostream>
#include<algorithm>
#include<functional>
int p[100000],df[100001];
int n, k, w = 0;
int main(){
	int t;
	std::cin >> t;
	for (int i = 0; i < t;i++){
		w = 0;
		std::cin >> n >> k;
		for (int i = 0; i < n; i++){
			std::cin >> p[i];
			if (i != 0)df[i - 1] = p[i] - p[i - 1];
		}
		std::sort(df, df + n - 1, std::greater<int>());
		for (int i = 0; i < k - 1; i++){
				w += df[i];
		}
		if (n <= k || n == k){
			std::cout << 0 << "\n";
		}
		else if (n == 2){
			std::cout << p[n - 1] << "\n";
		}
		else{
			std::cout << (p[n - 1] - p[0]) - w << "\n";
		}
	}
}

Measured memory_bytes: 1960
fn solve() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let a: usize = sc.read();
    let b: usize = sc.read();
    let result = std::cmp::max(a + std::cmp::max(a - 1, b), b + std::cmp::max(a, b - 1));
    println!("{}", result);
}

fn main() {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024) // 64MB
        .spawn(|| solve())
        .unwrap()
        .join()
        .unwrap();
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self.stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_line(&mut self) -> String {
        use std::io::Read;
        let buf = self.stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b'\n' || b == b'\r')
            .take_while(|&b| b != b'\n' && b != b'\r')
            .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: 8572
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>
#include <unordered_map>
#include <unordered_set>
#include <assert.h>
using namespace std;


#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>

vector<ll> v, w;
vector<ll> ans;
void IsPrime(ll n) {
	for (ll i = 1; i <= sqrt(n); i++)
	{
		if (n % i == 0) {
			if(i != 1)v.push_back(i);
			if (i != n / i)v.push_back(n / i);
		}
	}
}

int main() {
	ll n;
	cin >> n;
	IsPrime(n);
	REP(i, v.size()) {
		ll now = n;
		while (now % v[i] == 0) {
			now /= v[i];
			//cout << v[i] << " " << now << endl;
		}
		now %= v[i];
		if (now == 1)ans.push_back(v[i]);
	}
	n--;
	v.resize(0);
	IsPrime(n);
	REP(i, v.size())ans.push_back(v[i]);
	sort(ALL(ans));
	ans.erase(unique(ALL(ans)), ans.end());
	//REP(i, ans.size())cout << ans[i] << endl;
	cout << ans.size() << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
//#define DEBUG
#ifdef DEBUG
#define DEBUG_PRINT(fm, ...) do{std::printf("%s:%d(%s)", __FILE__, __LINE__, __func__);std::cout << "DEBUG PRINT ";std::printf(fm, __VA_ARGS__);}while(0)
#define DEBUG_VAL(a, b) do{std::printf("%s:%d(%s)", __FILE__, __LINE__, __func__);std::cout <<"DEBUG VAL " << a << ":" << b << endl;}while(0)
#else
#define DEBUG_PRINT(...)do{}while(0);
#define DEBUG_VAL(a, b)do{}while(0);
#endif

using namespace std;
using ll = long long;
using v1 = vector<int>;
using vl = vector<long long>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;

v1 MM = {1, 0, -1, 0};
v1 WW = {0, 1, 0, -1};

int main(){
    int H, W;
    cin >> H >> W;
    int si, sw, ti, tw;
    cin >> si >> sw >> ti >> tw;
    si--; sw--; ti--; tw--;
    vector<string> A(H);
    rep(i, H){
        cin >> A[i];
    }
    int INF = 1e8;
    v2 Dist(H, v1(W, INF));
    deque<pair<int, int>> Q;
    Dist[si][sw] = 0;
    Q.emplace_back(make_pair(si, sw));
    while(!Q.empty()){
        int h = Q.front().first;
        int w = Q.front().second;
        Q.pop_front();
        int d = Dist[h][w];
        rep(i, 4){
            int nh = h + MM[i];
            int nw = w + WW[i];
            if(nh < 0 || nw < 0 || nh >= H || nw >= W) continue;
            if(A[nh][nw] == '#') continue;
            if(Dist[nh][nw] <= d)continue;
            Dist[nh][nw] = d;
            Q.emplace_front(make_pair(nh, nw));
        }
        DEBUG_VAL("d", d);
        for(int i = -2; i <=2; i++){
            for(int j = -2; j <= 2;j++){
                int nh = h + i;
                int nw = w + j;
                if(nh < 0 || nw < 0 || nh >= H || nw >= W) continue;
                if(A[nh][nw] == '#') continue;
                if(Dist[nh][nw] <= d+1)continue;
                Dist[nh][nw] = d+1;
                Q.emplace_back(make_pair(nh, nw));
            }
        }
    }
    int ans = Dist[ti][tw];
    if(ans == INF) cout << -1 << endl;
    else cout << ans << endl;
}

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

int main(){
    string n;
    cin >> n;
    if(n.length()==3){
        if(n[2]=='2' or n[2]=='4' or n[2]=='5' or n[2]=='7' or n[2]=='9'){
            cout << "hon" << endl;
            return 0;
        }else if(n[2]=='0' or n[2]=='1' or n[2]=='6' or n[2]=='8'){
            cout << "pon" << endl;
            return 0;
        }else if(n[2]=='3'){
            cout << "bon" << endl;
            return 0;
        }
    }else if(n.length()==2){
        if(n[1]=='2' or n[1]=='4' or n[1]=='5' or n[1]=='7' or n[1]=='9'){
            cout << "hon" << endl;
            return 0;
        }else if(n[1]=='0' or n[1]=='1' or n[1]=='6' or n[1]=='8'){
            cout << "pon" << endl;
            return 0;
        }else if(n[1]=='3'){
            cout << "bon" << endl;
            return 0;
        }
    }else if(n.length()==1){
        if(n[0]=='2' or n[0]=='4' or n[0]=='5' or n[0]=='7' or n[0]=='9'){
            cout << "hon" << endl;
            return 0;
        }else if(n[0]=='0' or n[0]=='1' or n[0]=='6' or n[0]=='8'){
            cout << "pon" << endl;
            return 0;
        }else if(n[0]=='3'){
            cout << "bon" << endl;
            return 0;
        }
    }
}

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

int main() {
    int i,j,n;
    int sum=0;
    string temp;
    string s;
    cin >> s;
    n=s.length();
    for(i=1;i<n;i++){
        if(s[i]==s[i-1]){
            if(s[i-1]=='0'){s[i]='1';}
            else{s[i]='0';}
            sum++;
        }
    }
    cout << sum <<endl;
    return 0;
}

Measured memory_bytes: 512
N , K = map(int , input().split())

V = list(map(int , input().split()))

ans = 0
try_num = min(N,K)
for i in range(1 , try_num + 1):#pickする回数
    for j in range(i+1):
        pick_list = V[:i-j] + V[N - j:]
        
        rest_try_num = min(K-i , i)
        pick_list = sorted(pick_list) 
        for k in range(rest_try_num):
            if pick_list[k] <0:
                pick_list[k] = 0
            else:
                break

        ans = max(ans , sum(pick_list))

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }




struct edge {
    int from;
    int to;
    int cost;
    edge(int _from, int _to, int _cost) : from(_from), to(_to), cost(_cost){};
};

vector<edge> ans;

// [add, add + L)のバイパスを作る
void bypass(int add, int L) {
    if (L <= 0) return;
    for (int k = 19; k >= 0; --k) {
        if (L >= (1 << k)) {
            // [add, add + 2^k)を作る
            // k本の辺の後、つまり頂点k+1から20に辺を張る
            ans.push_back(edge(k + 1, 20, add));
            
            // [add + 2^k, add + L)を作る
            bypass(add + (1 << k), L - (1 << k));
            break;
        }
    }
    return;
}

vector<edge> main_ac(int L) {
    ans.clear();
    // 0の辺を全部張る
    for (int i = 1; i < 20; ++i) {
        ans.push_back(edge(i, i + 1, 0));
    }
    
    // 大まかにグラフを作る
    for (int k = 19; k >= 1; --k) {
        if (L >= (1 << k)) {
            // k本辺を張って[0, 2^k)を作る
            for (int i = 1; i <= k; ++i) {
                ans.push_back(edge(i, i + 1, 1 << (i - 1)));
            }
            
            // [2^k, L)を作る
            bypass(1 << k, L - (1 << k));
            break;
        }
    }
    /*
    cout << 20 << " " << ans.size() << endl;
    for (auto e : ans) {
        cout << e.from << " " << e.to << " " << e.cost << endl;
    }
     */
    return ans;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    
    int l;
    cin >> l;
    int L = l;
    
    vector<pair<pii, int> > v;
    rep(i, 19) v.eb(make_pair(pii(i + 1, i + 2), 0));
    int sum = 0;
    rep(i, 60) {
        if (sum + (1 << i) >= l) break;
        v.eb(make_pair(pii(i + 1, i + 2), (1 << i)));
        
        sum += (1 << i);
    }
    sum++; // 111... -> 1000...
    l -= sum;
    int r = v.back().F.S + 1;
    chmin(r, 20);
    // cout << r << " " << l << endl;
    // rep(i, sz(v)) cout << v[i].F.F << " " << v[i].F.S << " " << v[i].S << endl;
    while (l > 0 && l < L) {
        int tmp = 0;
        rep(i, 60) {
            if (tmp + (1 << i) >= l) {
                v.eb(make_pair(pii(i + 1, r), sum));
                break;
            }
            tmp += (1 << i);
        }
        tmp++;
        l -= tmp;
        sum += tmp;
    }
    
    cout << 20 << " " << sz(v) << endl;
    rep(i, sz(v)) cout << v[i].F.F << " " << v[i].F.S << " " << v[i].S << endl;
    
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define N 100010
#define S str[pos]
#define Sp str[pos++]
using namespace std;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
int Max(int &a,int b){return a=max(a,b);}
int Min(int &a,int b){return a=min(a,b);}
typedef complex<double> P;
typedef pair<P,P> L;
string str;
int pos;

double dot(P a, P b){ return real(conj(a)*b); }
double cross(P a, P b){ return imag(conj(a)*b); }
P proj(P p, L l){return l.first + dot(p - l.first, l.second - l.first) / norm(l.second - l.first) * (l.second - l.first);}
P reflect(P p, L l){return p + (proj(p,l) - p) * 2.0;}

P crossPoint(L l, L m){
  double A = cross(l.second - l.first, m.second - m.first);
  double B = cross(l.second - l.first, l.second - m.first);
  if(fabs(A) < EPS && fabs(B) < EPS) return m.first;
  else if(fabs(A) >= EPS) return m.first + B / A * (m.second - m.first);
}

bool isPoint(L a){return a.first == a.second;}

double getNumber(){
  assert(S == '-' || isdigit(S));
  double res=0,f = 1;
  if(S == '-') pos++,f = -1;
  while(isdigit(S)) res = res * 10 + Sp - '0';
  return f * res;
}

P getPoint(){
  assert(Sp == '(' && (isdigit(S) || S=='-'));
  double real = getNumber();assert(Sp == ',');
  double imag = getNumber();assert(Sp == ')');
  return P(real,imag);
}

L expression();

L calc(){
  P a;
  L res;
  if(S == '(' && (isdigit(str[pos+1]) || str[pos+1] == '-'))a = getPoint(),res = L(a,a);
  else if(S == '(' && str[pos+1] == '(')pos++,res = expression(),pos++;
  else assert(!"calc error");
  return res;
}

L calc(L a,L b){
  if(isPoint(a) && isPoint(b)) return L(a.first,b.first);
  if(!isPoint(a) && !isPoint(b))return L(crossPoint(a,b),crossPoint(a,b));
  if(isPoint(a)) return L(reflect(a.first,b),reflect(a.first,b));
  if(isPoint(b)) return L(reflect(b.first,a),reflect(b.first,a));
  assert(!"@ calc error");
}

L expression(){
  L res = calc();
  while(pos < (int)str.size()){
    if(S == '@')pos++,res = calc(res,calc());
    else if(S == ')') break;
    else assert(!"expression error");
  }
  return res;      
}


signed main(){
  while(1){
    cin>>str;
    if(str == "#") break;
    pos = 0;    
    L ans = expression();
    printf("%f %f\n",ans.first.real(),ans.first.imag());
  }
  return 0;
}

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

int main(){
    string s; cin >> s;
    int n = s.length();
    if(s[n-1] == 's')
        s = s + "es";
    else{
        s = s + "s";
    }
    cout << s << endl;

    return 0;
}

Measured memory_bytes: 3608
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	n, err := strconv.Atoi(nextString())
	if err != nil {
		fmt.Printf("strconv.Atoi failed: %v\n", err)
	}
	return n
}

func binarySearch(a []int, k int) int {
	n := len(a)
	if n == 0 {
		return 0
	}
	// fmt.Println(a)
	h := n / 2
	if a[h] == k {
		return 1
	} else if a[h] < k {
		return binarySearch(a[(h+1):], k)
	} else {
		return binarySearch(a[:h], k)
	}
}

func main() {
	scanner.Split(bufio.ScanWords)
	n := nextInt()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt()
	}
	nQueries := nextInt()
	for i := 0; i < nQueries; i++ {
		k := nextInt()
		fmt.Println(binarySearch(a, k))
	}
}



Measured memory_bytes: 5876
hw = [int(i) for i in input().split()]
h = hw[0]
w = hw[1]
rows = []
possible = True
for i in range(h):
  rows.append(input())
i = 0
if h==1 and w==1:
  if rows[0]=='#':
    possible = False
elif h==1 and w>1:
  i = 0
  while i<w:
    if rows[0][i]=='#':
      if i==0:
        if rows[0][i+1]=='.':
          possible = False
          break
      elif i==w-1:
        if rows[0][i-1]=='.':
          possible = False
          break
      else:
        if rows[0][i+1]=='.' and rows[0][i-1]=='.':
          possible = False
          break
    i+=1
elif h>1 and w==1:
  i = 0
  while i<h:
    if rows[i][0]=='#':
      if i==0:
        if rows[i+1][0]=='.':
          possible = False
          break
      elif i==h-1:
        if rows[i-1][0]=='.':
          possible = False
          break
      else:
        if rows[i+1][0]=='.' and rows[i-1][0]=='.':
          possible = False
          break
    i+=1
else:
  while i<h:
    j = 0
    while j<w:
      if rows[i][j]=='#':
        if i==0 and j==0:
          if rows[i][j+1]=='.' and rows[i+1][j]=='.':
            possible=False
            break
        elif i==0 and j==w-1:
          if rows[i+1][j]=='.' and rows[i][j-1]=='.':
            possible = False
            break
        elif i==h-1 and j==0:
          if rows[i-1][j]=='.' and rows[i][j+1]=='.':
            possible = False
            break
        elif i==h-1 and j==w-1:
          if rows[i-1][j]=='.' and rows[i][j-1]=='.':
            possible = False
            break
        elif i==0 and j>0:
          if rows[i][j+1]=='.' and rows[i][j-1]=='.' and rows[i+1][j]=='.':
            possible=False
            break
        elif i>0 and j==0:
          if rows[i+1][j]=='.' and rows[i-1][j]=='.' and rows[i][j+1]=='.':
            possible = False
            break
        elif i>0 and j==w-1:
          if rows[i+1][j]=='.' and rows[i-1][j]=='.' and rows[i][j-1]=='.':
            possible = False
            break
        elif i==h-1 and j>0:
          if rows[i][j+1]=='.' and rows[i-1][j]=='.' and rows[i][j-1]=='.':
            possible = False
            break
        else:
          if rows[i+1][j]=='.' and rows[i-1][j]=='.' and rows[i][j+1]=='.' and rows[i][j-1]=='.':
            possible = False
            break
      j+=1
    if possible==False:
      break
    i+=1
if possible==False:
  print("No")
else:
  print("Yes")

Measured memory_bytes: 3280
#include <iostream>
#include <iomanip>

int main()
{
	int N;
	double ans;
	std::cin >> N;
	if(N%2==0){
		std::cout << std::fixed << std::setprecision(15) << 0.5000000000 << std::endl;

	}
	else{
		ans = N/2;
		ans += 1;
		ans = ans/N;
		std::cout << std::fixed << std::setprecision(15) << ans << std::endl;
	}
	return 0;
}

Measured memory_bytes: 256
require 'set'; require 'prime'; require 'pp'
INF=Float::INFINITY; MOD=10**9+7
n,k = gets.chomp.split.map(&:to_i)
a = gets.chomp.split.map(&:to_i)

current = 1
count = 0
visited = Hash.new
visited[1] = 0
while true
  current = a[current-1]
  count += 1

  if count == k
    puts current
    exit
  end

  if visited.has_key? current
    break
  end
  visited[current] = count
end

index = visited[current]
k -= index
lp = count - index
k %= lp #=
# p [count, current, k, [index, lp]]

count = 0
if count == k
  puts current
  exit
end
while true
  current = a[current-1]
  count += 1
  if count == k
    puts current
    exit
  end
end


Measured memory_bytes: 38276
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████  
//
#include "bits/stdc++.h"
using namespace std;
#define INF (1LL<<60)
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl
#define SP << " " << 
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
#define MSB(x) (63-__builtin_clzll(x))
#define pcnt(x) (__builtin_popcountll(x))
#define parity(i,j) (i&(1LL<<j))
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int n,k;
  cin >> n >> k;

  int ans = 0;
  while(n){
    n /= k;
    ans++;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define REP(i, a, b) for (int i = (a); i <= (b); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORD(i, a, b) for(int i = (a); i > (b); --i)
#define REPD(i, a, b) for(int i = (a); i >=(b); --i)
#define TR(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define endl '\n'
#define mp make_pair
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define unmap unordered_map
#define lb lower_bound //first pos >= val
#define ub upper_bound // first pos > val
#define debug(a) cout << a << endl
using namespace std;

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

const ll maxN = 1e18;
const ll minN = -1e18;
const ll MOD = 1e9 + 7;
const ll MOD1 = 998244353;
const int bignumlen = 2200;
const int Blen = 8;
const ll base = 100000000;
const int baseHash = 31;
const ld PI = acos(-1);

//Remember limit for IT, etc...
const ll limit = 2e5 + 5;
const ll limit1 = 1e6 + 5;

ll n;
ll x, y;
ll cnt[limit];

void solveProblem() {
    REP(i, 1, n - 1) {
        REP(j, i + 1, n) {
            ll temp = min((ll)(j - i), min(abs(x - i) + 1 + abs(y - j), abs(y - i) + 1 + abs(x - j)));
            cnt[temp]++;
        }
    }

    REP(i, 1, n - 1)
        cout << cnt[i] << endl;
}

void fastInput() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

void readInput() {
    cin >> n >> x >> y;
}

int main() {
    fastInput();
    readInput();
    solveProblem();
}



Measured memory_bytes: 256
#pragma GCC optimize("O3")

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <string>
#include <assert.h>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <random>
#include <cmath>
#include <chrono>
#include <bitset>

#define ld long double
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define eb emplace_back
#define int long long
using namespace std;

const int INF = 2e18;
const int MOD = 1e9 + 7;
const int MB = 20;

vector<vector<pair<int, int>>> g;
vector<int> ans;

struct DSU {
	vector<int> s, p;
	DSU(int n) {
		s.resize(n);
		p.resize(n);
		for (int i = 0; i < n; i++) {
			s[i] = 1;
			p[i] = i;
		}
	}
	
	int find(int x) {
		if (x == p[x]) return x;
		return p[x] = find(p[x]);
	}

	bool unite(int a, int b) {
		a = find(a);
		b = find(b);

		if (a == b) return false;
		if (s[a] < s[b]) swap(a, b);

		s[a] += s[b];
		p[b] = a;
		return true;
	}
};

void solve() {
	int n, m;
	cin >> n >> m;
	DSU dsu(n);
	int ans = n;
	for (int i = 0; i < m; i++) {
		int x, y, z;
		cin >> x >> y >> z;
		x--; y--;
		if (dsu.unite(x, y)) ans--;
	}
	cout << ans;
}
signed main() {
	/*
	freopen("search.in", "r", stdin);
	freopen("search.out", "w", stdout);
	*/
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout.precision(12);
	solve();
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
//g++ -std=c++11 

using namespace std;

long long N, M;

int main(){
	cin >> N >> M;
	if(N == M) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3624
n=int(input())
s1=input()
s2=input()

mod=10**9+7

if s1[0]==s2[0]:
    nn=0
    istat="tate"
    icnt=3
elif s1[0]!=s2[0]:
    nn=1    
    istat="yoko"
    icnt=6

while nn<n-1:
    nn+=1
    if s1[nn]==s2[nn]:
        if istat=="tate":
            icnt=(icnt*2)%mod
        elif istat=="yoko":
            icnt=icnt
        istat="tate"
    elif s1[nn]!=s2[nn]:
        nn+=1
        if istat=="tate":
            icnt=(icnt*2)%mod
        elif istat=="yoko":
            icnt=(icnt*3)%mod
        istat="yoko"

print(icnt)
    

Measured memory_bytes: 9116