akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define all(a)      (a).begin(),(a).end()
#define debug_array(a,n) for (ll bccc=(0); bccc<(n); bccc++) cout<<a[bccc]<<" "<<"\n"
#define debug_vector(a) for(ll bccc=(0); bccc<(a.size());bccc++) cout<<a[bccc]<<" "<<"\n"
#define F           first
#define S           second
#define debug_set(s) for(auto p:s) cout<<p<<" "
#define debug_map(m) for(auto p:m) cout<<p.F<<" "<<p.S<<"\n"
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<pair<ll,ll>,null_type,less<pair<ll,ll> >,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;

/* ll t = 0;
ordered_multiset me;
...
me.insert({x, t++});
me.erase(me.lower_bound({x, 0}));
cout << me.order_of_key({x, 0}) << "\n";

///////////   t is insertion time
*/
//#pragma GCC optimize("Ofast")  // works very well
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
typedef long double lld;
lld pi=3.14159265358;
ll powr(ll a,ll b)
{
    ll c=1;
    ll kjk;
    for(kjk=0;kjk<b;kjk++)
        c*=a;
    return c;
}
ll hell=1000000007;
//ll hell=998244353   ;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
// to generate random number , use rng() ... eg cout<<rng();
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n,m,k,i;
    cin>>n>>m>>k;
    ll ans=0;
    ll a[n];
    for(i=0;i<n;i++)
        cin>>a[i];
    ll b[m];
    for(i=0;i<m;i++)
        cin>>b[i];
    for(i=1;i<n;i++)
        a[i]+=a[i-1];
    for(i=1;i<m;i++)
        b[i]+=b[i-1];
    for(i=0;i<n;i++)
    {
        if(a[i]<=k)
        {
            ll x=k-a[i];
            ll pp=lower_bound(b,b+m,x)-b;
            if(pp!=m && b[pp]==x)
                pp++;
            if(pp==m)
                ans=max(i+1+pp,ans);
            else
            {
                ans=max(ans,i+1+pp);
            }
        }
    }
    ll pp=lower_bound(b,b+m,k)-b;
    if(pp!=m and b[pp]==k)
        pp++;
    ans=max(ans,pp);
    cout<<ans;

    return 0;
}


Measured memory_bytes: 6776
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    int N, l, r;
    cin >> N;
    int res = 0;
    REP(i, N) {
        cin >> l >> r;
        res += r - l + 1;
    }
    cout << res << endl;
    return 0;
}


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

#define len(s) int(s.size())
#define res(x) cout<<((x)?"No\n":"Yes\n")
#define all(v) v.begin(),v.end()

typedef long long ll;
typedef long double ld;

ll mod = 1e9+7;

void solution() {
	int n, p;
	cin >> n >> p;
	
	res(p % 2 || n >= p || n*4 < p || p < n*2);
	
}

int main(){
	
	int t = 1;
	//cin >> t;
	
	while(t--)
		solution();
	
	return 0;
}


Measured memory_bytes: 3628
#include <stdio.h>

int main(void)
{
  int scr[5],i,sum=0,ans;

  for(i=0;i<5;i++){
    scanf("%d", &scr[i]);
    if(scr[i]>=40) sum+=scr[i];
    if(scr[i]<40) sum+=40;
  }
  ans=sum/5;
  printf("%d\n", ans);

  return 0;
}


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

int main(int argc, char const *argv[])
{
  int num = 0;
  cin >> num;
  for(int i=1; i<10; i++){
    for(int j=1; j<10; j++){
      if (i*j == num){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n,d;
	cin>>n>>d;
	d*=d;
	int ans=0;
	for(int i=0;i<n;i++){
		ll x,y;
		cin>>x>>y;

		if(x*x + y*y <= d)ans++;
	}
	cout<<ans<<'\n';

	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
	int n;cin>>n;
	ll ans=0;
	vector<vector<char>>s(2,vector<char>(n));
	rep(i,2)rep(j,n)cin>>s[i][j];
	if(s[0][0]==s[1][0]){
		ans=3;
		bool a=true;
		for(int i=1;i<n;++i){
			if(s[0][i]==s[1][i]&&a){
				ans*=2;
				ans%=MOD;
			}
			else if(s[0][i]==s[1][i]&&!a){
				a=true;
			}
			else if(s[0][i]!=s[1][i]&&a){
				a=false;
                ans*=2;
                ans%=MOD;
                i++;
			}
			else if(s[0][i]!=s[1][i]&&!a){
				ans*=3;
				ans%=MOD;
                i++;
			}
		}
	}
	if(s[0][0]!=s[1][0]){
		ans=6;
		bool a=false;
		for(int i=2;i<n;++i){
			if(s[0][i]==s[1][i]&&a){
				ans*=2;
				ans%=MOD;
			}
			else if(s[0][i]==s[1][i]&&!a){
				a=true;
			}
			else if(s[0][i]!=s[1][i]&&a){
                ans*=2;
                ans%=MOD;
				a=false;
                i++;
			}
			else if(s[0][i]!=s[1][i]&&!a){
				ans*=3;
				ans%=MOD;
                i++;
			}
		}
	}
	cout<<ans<<endl;
}

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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define pll pair<ll, ll>
#define vll vector<ll>
#define mll map<ll, ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

int main() {
  // std::cout << std::fixed << std::setprecision(10);
  ll A, B;
  scanf("%lld %lld", &A, &B);

  cout << (A * B) << endl;
}


Measured memory_bytes: 3764
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String s = in.next();
            s = s.substring(0, s.length() - 1);

            while (!s.isEmpty()) {
                String s1 = s.substring(0, s.length() / 2);
                String s2 = s.substring(s.length() / 2);

                //out.println(s1);
                //out.println(s2);
                if (s1.equals(s2)) {
                    out.println(s.length());
                    return;
                }

                s = s.substring(0, s.length() - 1);
            }

        }

    }
}



Measured memory_bytes: 21844
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
 
using namespace std;
 
#define PB push_back
#define MP make_pair
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vii;
 
const int MOD = 1e9+7;
const int INF = 1e9;
 
int main() {
  while (true) {
    int n, ans = 0;
    bool canDrop[310][310];
    int dp[310][310];
    cin >> n;
    if (n == 0) break;
    vi c;
    for (int i = 0; i < n; i++) {
      int tmp;
      cin >> tmp;
      c.PB(tmp);
    }
    for (int i = 0; i <= 300; i++) {
      for (int j = 0; j <= 300; j++) {
        canDrop[i][j] = false;
        dp[i][j] = 0;
      }
    }
    for (int len = 2; len <= n; len+=2) {
      for (int left = 0; left+len-1 < n; left++) {
        int right = left + len - 1;
        if (abs(c[left]-c[right])<=1) {
          if (len==2) {
            canDrop[left][right] = true;
            // cout << len << ": " << left << "_a_" << right << endl;
            continue;
          } else {
            if (canDrop[left+1][right-1]) {
              canDrop[left][right] = true;
              // cout << len << ": " << left << "_b_" << right << endl;
              continue;
            }
          }
        }
        for (int pos = left+1; pos < right; pos+=2) {
          if (canDrop[left][pos] && canDrop[pos+1][right]) {
            canDrop[left][right] = true;
            // cout << len << ": " << left << "_c_" << right << endl;
            break;
          }
        }
      }
    }
    for (int len = 2; len <= n; len++) {
      for (int left = 0; left+len-1 < n; left++) {
        int right = left + len;
        if (canDrop[left][right-1]) {
          dp[left][right] = len;
        }
        for (int pos = left+1; pos < right; pos++) {
          dp[left][right] = max(dp[left][right], dp[left][pos]+dp[pos][right]);
        }
        dp[0][n] = max(dp[0][n], dp[0][left]+dp[left][right]+dp[right][n]);
      }
    }
    cout << dp[0][n] << endl;
  }
  return 0;
}



Measured memory_bytes: 3636
n=int(input())
l=[[0 for i in range(13)]for j in range(4)]
for k in range(n):
    s,r=map(str,input().split())
    r=int(r)-1
    if s=='S':
        l[0][r]+=1
    elif s=='H':
        l[1][r]+=1
    elif s=='C':
        l[2][r]+=1
    else:
        l[3][r]+=1
for S in range(4):
    for R in range(13):
        if l[S][R]==0:
            if S==0:
                print('S',R+1)
            elif S==1:
                print('H',R+1)
            elif S==2:
                print('C',R+1)
            else:
                print('D',R+1)
        else:
            pass


Measured memory_bytes: 5612
//#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#define MAX_INT 2100000000
#define ex5 (100000+10)
using namespace std;
typedef long long int ll;
#ifdef COMPILE_IN_VCPP
#include <windows.h>
HWND GetConsoleHwnd(void)
{
#define MY_BUFSIZE 1024 // Buffer size for console window titles.
	HWND hwndFound;         // This is what is returned to the caller.
	char pszNewWindowTitle[MY_BUFSIZE]; // Contains fabricated// WindowTitle.
	char pszOldWindowTitle[MY_BUFSIZE]; // Contains original// WindowTitle.
	ULARGE_INTEGER nt;
	nt.QuadPart = GetTickCount64();
	GetConsoleTitle(pszOldWindowTitle, MY_BUFSIZE);
	wsprintf(pszNewWindowTitle, "%d%d/%d",nt.HighPart,nt.LowPart,GetCurrentProcessId());
	SetConsoleTitle(pszNewWindowTitle);
	Sleep(40);
	hwndFound = FindWindow(NULL, pszNewWindowTitle);
	SetConsoleTitle(pszOldWindowTitle);
	return(hwndFound);
}
#endif
int main()
{
#ifdef COMPILE_IN_VCPP
	SetWindowPos(GetConsoleHwnd(), HWND_TOPMOST, 0, 0, 0, 0,
		(SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW));
#endif
	int n, k;
	cin >> n >> k;
	if (k == 1) cout << '0' << endl ;
	else cout << n - k << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string S;
int main(){
  cin >> S;
  sort(S.begin(),S.end());
  for(int i=0;i<S.size()-1;i++){
    if(S[i]==S[i+1]){
      cout << "no" << endl;
      return 0;
    }
  }
  cout << "yes" << endl;
  return 0;
}


Measured memory_bytes: 256
import math
pi = math.pi

a, b, h, m = map(int, input().split())

ta = h * pi/6 + m * pi/360
tb = m * pi/30
t = abs(ta - tb)

c = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(t))
print(c)


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

using ll = long long;

constexpr int mod = 1e9+7;

ll pw(ll a, int n)
{
    if(!n) return 1;
    if(n&1) return a*pw(a,n-1)%mod;
    return pw(a*a%mod,n/2);
}

int main()
{
    int s;
    long long ans=0;
    scanf("%d",&s);
    for(int i=1;i<=s;i++)
    {
        int l = s/i, r = (s+i-1)/i;
        if(r<9) break;
        int b = s-l*i, a = i-b;
        if(b) ans++;
        else ans = (ans + mod + pw(10,l-1)*9%mod - a + 1)%mod;
    }
    int cur=0, l=1, ls=1,rs=1, ln=10,rn=10;
    for(int r=1;r<100000000;r++)
    {
        if(r == rn)
        {
            rn *= 10;
            rs++;
        }
        cur += rs;
        while(cur>s)
        {
            cur -= ls;
            l++;
            if(l == ln)
            {
                ln *= 10;
                ls++;
            }
        }
        ans += s == cur;
    }
    printf("%lld\n",ans%mod);
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int n;
pair<int, int> a[100005];
int main ()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i].first;
		a[i].second=i;
	}
	sort(a+1, a+n+1);
	for(int i=1;i<=n;i++)
	{
		if(i!=1)	cout<<" ";
		cout<<a[i].second;
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 0; i < n; ++i)
#define rep3(i, a, b) for (ll i = a; i < b; ++i)
#define rep4(i, a, b, c) for (ll i = a; i < b; i += c)
#define erep(n) for (ll i = 0; i <= n; ++i)
#define erep2(i, n) for (ll i = 0; i <= n; ++i)
#define erep3(i, a, b) for (ll i = a; i <= b; ++i)
#define erep4(i, a, b, c) for (ll i = a; i <= b; i += c)
#define rrep(i, a, b) for (ll i = a; i > b; --i)
#define rrep2(i, a, b, c) for (ll i = a; i > b; i -= c)
#define errep(i, a, b) for (ll i = a; i >= b; --i)
#define errep2(i, a, b, c) for (ll i = a; i >= b; i -= c)
#define print(a) cout << a << endl;
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define cin(x) cin >> x;
const ll MOD = 1000000007;
inline int newline() { putchar('\n'); return 0; }

int main() {
    string s;
    cin(s);

    rep(s.size()) printf("x");
    printf("\n");
    return 0;
}

Measured memory_bytes: 256
MOD = 10**9 + 7

def main():
    s = int(input())
    n = s//3
    if s < 3:
        print(0)
    else:
        ans = 0
        dp = [0]*(s+1)
        dp[0] = 1
        for _ in range(n):
            tmp = [0]*(s+1)
            for i in range(s+1-3):
                tmp[i+3] += dp[i]
            for i in range(s+1):
                tmp[i] %= MOD
                if i < s:
                    tmp[i+1] += tmp[i]
            ans += tmp[s]
            ans %= MOD
            dp = tmp
        print(ans%MOD)

if __name__ == "__main__":
    main()

Measured memory_bytes: 67832
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Out.Flush();
            Read();
        }
        static void Solve()
        {
            var HWAB = Sarray();
            var H = HWAB[0] ;
            var W = HWAB[1] ;
            var A = HWAB[2] ;
            var B = HWAB[3] ;
            var cmb = new Combination(2 * 100000 + 1, Mod);
            var ans = cmb.nCk((int)(H-1 + W-1), (int)H-1);
            for (var i = 0; i < B; ++i)
            {
                var rem = cmb.nCk((int)(H - 1 - A + i), i) * cmb.nCk((int)(A - 1 + W - 1 - i), (int)A - 1) % Mod;
                ans = (ans - rem + Mod) % Mod;
            }
            WriteLine(ans);
        }
        public class Combination
        {
            readonly long mod;
            readonly long[] fac, finv, inv;
            public Combination(long n, long mod = 1000000007)
            {
                long max = n + 1;
                this.mod = mod;
                fac = new long[max];
                finv = new long[max];
                inv = new long[max];
                fac[0] = fac[1] = 1;
                finv[0] = finv[1] = 1;
                inv[1] = 1;
                for (int i = 2; i < max; ++i)
                {
                    fac[i] = fac[i - 1] * i % mod;
                    inv[i] = mod - inv[mod % i] * (mod / i) % mod;
                    finv[i] = finv[i - 1] * inv[i] % mod;
                }
            }
            public long nCk(int n, int k)
            {
                if (n < k) return 0;
                if (n < 0 | k < 0) return 0;
                return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
            }
        }
    }
}

Measured memory_bytes: 33240
/*
PROG: arc081c
LANG: C++
    _____
  .'     '.
 /  0   0  \
|     ^     |
|  \     /  |
 \  '---'  /
  '._____.'
*/
#include <bits/stdc++.h>

using namespace std;

long long readi()
{
	long long input = 0;
	char c = ' ';
	while (c < '-')
	{
		c = getchar();
	}
	bool negative = false;
	if (c == '-')
	{
		negative = true;
		c = getchar();
	}
	while (c >= '0')
	{
		input = 10 * input + (c - '0');
		c = getchar();
	}
	if (negative)
	{
		input = -input;
	}
	return input;
}
void printi(long long output)
{
	if (output == 0)
	{
		putchar('0');
		return;
	}
	if (output < 0)
	{
		putchar('-');
		output = -output;
	}
	int aout[20];
	int ilen = 0;
	while(output)
	{
		aout[ilen] = ((output % 10));
		output /= 10;
		ilen++;
	}
	for (int i = ilen - 1; i >= 0; i--)
	{
		putchar(aout[i] + '0');
	}
	return;
}
string reads()
{
	string input = "";
	char c = ' ';
	while (c <= ' ')
	{
		c = getchar();
	}
	while (c > ' ')
	{
		input += c;
		c = getchar();
	}
	return input;
}
void prints(string output)
{
	for (int i = 0; i < output.length(); i++)
	{
		putchar(output[i]);
	}
	return;
}
long long getrand()
{
	long long rand1 = (rand() % 536870912);
	long long rand2 = (rand() % 536870912);
	return (rand1 * 536870912ll + rand2);
}
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#define MP make_pair
#define PB push_back

#define MAGIC 400
#define SINF 10001
#define INF 1000000861
#define LLINF 1000000000000000861ll
#define MOD 1000000007
#define CO 1000861
#define EPS 0.000000000000001
#define PI 3.141592653589793

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

int N;
map<int, int> mp;
ll b4, b20, b21;
ll ans;

int32_t main()
{
	srand(time(NULL));
	cout << fixed << setprecision(10);	
	cerr << fixed << setprecision(10);
	ios_base::sync_with_stdio(false);
	if (fopen("arc081c.in", "r"))
	{	
		freopen ("arc081c.in", "r", stdin);
		//freopen ("arc081c.out", "w", stdout);
	}
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		int x;
		cin >> x;
		mp[x]++;
	}
	for (auto it = mp.rbegin(); it != mp.rend(); it++)
	{
		if (it -> second >= 4)
		{
			b4 = it -> first;
			break;
		}
	}
	for (auto it = mp.rbegin(); it != mp.rend(); it++)
	{
//		cerr << it -> second << endl;
		if (it -> second >= 2)
		{
			if (b20)
			{
				b21 = it -> first;
				break;
			}
			else
			{
				b20 = it -> first;
			}
		}
	}
	ans = max(b4 * b4, b20 * b21);
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    int m=0;
    for(int i=a;i<=b;i++){
         string s=to_string(i);
         string t=s;
        reverse(s.begin(),s.end());
        if(s==t){
            m++;
        }
    }
    cout<<m<<endl;
}

Measured memory_bytes: 256
import std.stdio;
import std.array;
import std.conv;
import std.algorithm;
import std.string;

void main(){
    int totalTime = 0;
    for(int i = 0; i < 4; i++){
        totalTime += readln().chomp().to!int();
    }
    writeln(totalTime / 60);
    writeln(totalTime % 60);
}

Measured memory_bytes: 960
#include<iostream>
#include <cmath>

using namespace std;

int main(){
  int i,n,l,ans=200,ans2,total=0;
  int a[205];

  cin >>n>>l;
  for(i=1;i<n+1;i++) a[i-1]=i+l-1;

  for(i=0;i<n;i++) {
    if(ans > abs(a[i])){
      ans=abs(a[i]);
      ans2=i;
    }
  }

  for(i=0;i<n;i++){
    if(i!=ans2) total += a[i];
  }
  cout << total <<endl;
  return 0;

}

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

int main() {
    int N;
    cin >> N;
    while (N--) {
        vector<int> a(3);
        for (int i = 0; i < 3; ++i) cin >> a[i];
        sort(a.begin(), a.end());
        cout << (a[0] * a[0] + a[1] * a[1] == a[2] * a[2] ? "YES" : "NO") << endl;
    }
}



Measured memory_bytes: 3016
from collections import defaultdict
from heapq import heappush, heappop, heapify
from bisect import bisect_left

class Solution:
    def main(self):
        N = int(input())
        A = list(map(lambda x: int(x)-1, input().split()))
        B = list(map(int, input().split()))
        C = list(map(int, input().split()))

        res = 0
        for i in range(N):
            res += B[A[i]]
            if i > 0 and A[i] == A[i-1] + 1:
                res += C[A[i-1]]
        print(res)

if __name__ == '__main__':
    Solution().main()


Measured memory_bytes: 3444
#include<stdio.h>

void maxHeapify(int);
void buildMaxHeap();
int A[500001];
int length;

int main(){
  int H,i;

  scanf("%d",&H);
  length=H;
  for(i=1;i<=H;i++)scanf("%d",&A[i]);

  buildMaxHeap();

  for(i=1;i<=H;i++)printf(" %d",A[i]);
  printf("\n");
  return 0;
}

void buildMaxHeap(){
  int i;
  for(i=length/2;i>=1;i--) maxHeapify(i);

}

void maxHeapify(int i){
  int l,r,largest,a;
  l=i*2;
  r=i*2+1;

  if(l<=length && A[l]>A[i]) largest=l;
  else largest=i;

  if(r<=length && A[r]>A[largest]) largest=r;

  if(largest!=i){
    a=A[i];
    A[i]=A[largest];
    A[largest]=a;
    maxHeapify(largest);
  } 

}

Measured memory_bytes: 2552
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		for(int i = 0; i < n; i++){
			int num = sc.nextInt();
			
			System.out.println("Case " + (i+1) + ":");
			for(int j = 0; j < 10; j++){
				int new_num = ((num * num) / 100) % 10000;
				System.out.println(new_num);
				num = new_num;
			}
		}
	}
	
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>

using namespace std;
using ll = long long;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double PI = 4.0 * atan(1.0);

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, a, n) for (int i = a; i <= (n); ++i)

int main() {
    int N; cin >> N;
    vector<int> A(N); rep(i, N) cin >> A[i];
    
    int ans = 0;
    string mode = ""; // 空(neutral), i(increase), d(decrease)
    for (int i = 0; i < N; i++) {
        if (i == 0) {
            ans++;
            continue;
        }

        int diff = A[i] - A[i - 1];
        if (diff < 0) {
            if (mode == "") {
                mode = "d";
            } else if (mode == "i") {
                ans++;
                mode = "";
            }
        } else if (diff > 0) {
            if (mode == "") {
                mode = "i";
            } else if (mode == "d"){
                ans++;
                mode = "";
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef vector<ll> vl;

#define sl(x) scanf("%d",&x)
#define pl(x) printf("%d\n",x)
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " " << x << "\n";
#define debug2(x, n) cerr << #x << "\n"; f(i, n) cerr << i << " " << x[i] << "\n";
#define r(v) {reverse(all(v));}
#define pb push_back
#define F first
#define S second
#define f(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)

const ll mod = 1000000007;
const ll inf = (ll)5e16;
const ld eps = 1e-12;
const ll N = 1000005;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
template <typename T>
T power2(T a, ll b) { if(b == 0) return 1; if(b == 1) return a; T x = power2(a, b / 2); x = x * x; if(b % 2) x = x * a; return x;}
ll gcd(ll a, ll b) {if(a < b) swap(a, b); while(b) {ll t = b; b = a % b; a = t;} return a;}
ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

int main()
{
    ios_base::sync_with_stdio(0);
    ll n, m;
    cin >> n >> m;
    ll tot = (1900 * m + (n - m) * 100) * power2(2, m);
    cout << tot << "\n";
    return 0;
}


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

typedef int Weight;
struct Edge {
    int src, dst;
    Weight weight;
    Edge(int src_, int dst_, Weight weight_) :
        src(src_), dst(dst_), weight(weight_) { }
};
bool operator < (const Edge &e, const Edge &f) {
    return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
        e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;

int const MAX_V = 10010;
void stronglyConnectedComponents(Graph const & g, int cmp[MAX_V]){
    static int n, sz, added[MAX_V], visited[MAX_V], ord[MAX_V], S[MAX_V];
    n = g.size();
    Graph rg(n);
    rep(i,n){
        for(auto & e : g[i]) rg[e.dst].eb(e.dst, e.src, e.weight);
        added[i] = visited[i] = cmp[i] = 0;
    }
    sz = 0;
    rep(i,n){
        if(visited[i]) continue;
        int s = 0;
        S[s++] = i;
        while(s){
            int v = S[s-1];
            visited[v] = true;
            bool pushed = false;
            for(auto & e : g[v]){
                int dst = e.dst;
                if(!visited[dst]){
                    S[s++] = dst;
                    pushed = true;
                }
            }
            if(!pushed){
                int t = S[s-1];
                if(!added[t]){
                    added[t] = true;
                    ord[sz++] = t;
                }
                s--;
            }
        }
    }
    sz = 1;
    rep(i,n){
        int u = ord[n-i-1];
        if(cmp[u]) continue;
        int s = 0;
        S[s++] = u;
        while(s){
            int v = S[--s];
            cmp[v] = sz;
            for(auto & e : rg[v]){
                int d = e.dst;
                if(!cmp[d]) S[s++] = d;
            }
        }
        sz++;
    }
    rep(i,n) cmp[i]--;
}

int main(){
    int n,m;
    scanf("%d%d", &n,&m);
    Graph g(n);
    rep(i,m){
        int a,b;
        scanf("%d%d", &a,&b);
        g[a].eb(a,b,0);
    }
    int c[MAX_V];
    stronglyConnectedComponents(g,c);
    int q; cin >> q;
    rep(i,q){
        int a,b;
        scanf("%d%d", &a,&b);
        printf("%d\n", c[a]==c[b]);
    }
}

Measured memory_bytes: 2412
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>

using namespace std;

int main(void)
{
    char buf[1024];
    string str;
    while(1){

        char card[256];
        fgets(buf, sizeof(buf), stdin);
        sscanf(buf, "%s", card);
        str = card;
        if(str == "-") break;

        int num;
        fgets(buf, sizeof(buf), stdin);
        sscanf(buf, "%d", &num);

        int n;
        for(int i = 0; i < num; i++){
            fgets(buf, sizeof(buf), stdin);
            sscanf(buf, "%d", &n);

            str = str.substr(n, str.length()-n) + str.substr(0, n);
        }
        printf("%s\n", str.c_str());
    }

    return 0;
}

Measured memory_bytes: 1068
#include <cstdio>
#include <cstring>
#define MAXN 20
#define MAXS 40000

int n,m,maxs;
int g[MAXS],f[MAXS][MAXN];
int e[MAXN][MAXN];

inline void update(int &x,int y){ x=x>y?x:y; }

int main(){
#ifdef DEBUG
	freopen("F.in","r",stdin);
#endif
	scanf("%d%d",&n,&m);
	int totw=0;
	for(int i=1;i<=m;i++){
		int u,v,w;
		scanf("%d%d%d",&u,&v,&w);
		e[v][u]=e[u][v]=w;
		totw+=w;
	}
	maxs=1<<n;
	for(int i=0;i<maxs;i++){
		for(int j=1;j<=n;j++)
			if(i&(1<<(j-1)))
				for(int k=j+1;k<=n;k++)
					if(i&(1<<(k-1)))
						g[i]+=e[j][k];
	}
	int maxs0=maxs;
	maxs>>=2;
	memset(f,0x88,sizeof f);
	for(int i=0;i<maxs;i++) f[i][1]=g[i<<1|1];
	for(int i=0;i<maxs;i++)
		for(int x=1;x<n;x++){
			if(x!=1 && !(i&(1<<(x-2)))) continue;
			for(int y=2;y<n;y++){
				if((i&(1<<(y-2))) || !e[x][y]) continue;
				int by=1<<(y-2);
				int lims=(maxs-1)^i^by;
				for(int j=lims;;j=(j-1)&lims){
					update(f[i|j|by][y],f[i][x]+e[x][y]+g[(j|by)<<1]);
					if(!j) break;
				}
			}
		}
	int ans=-1;
	for(int i=0;i<maxs;i++)
		for(int j=1;j<n;j++)
			if(j==1 || (i&(1<<(j-2)))){
				if(e[j][n])
					update(ans,f[i][j]+e[j][n]+g[(maxs0-1)^1^(i<<1)]);
			}
	ans=totw-ans;
	if(ans<=totw) printf("%d\n",ans);
	else puts("-233");
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int a,b,h,m;
struct Point{
	double x,y;
};

Point p[2];

Point getpos(int len,double dir){
	Point tp;
	tp.x=cos(dir*M_PI/180.0)*len;
	tp.y=sin(dir*M_PI/180.0)*len;
	return tp;
}

double get_dist(Point p1,Point p2){
	return sqrt((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y));
}

int main(void){
	scanf("%d%d%d%d",&a,&b,&h,&m);
	p[0]=getpos(a,(double)(h*60+m)/2.0);
	p[1]=getpos(b,m*6.0);
	//printf("%.10f %.10f\n",p[0].x,p[0].y);
	//printf("%.10f %.10f\n",p[1].x,p[1].y);
	printf("%.10f\n",get_dist(p[0],p[1]));
	return 0;
}


Measured memory_bytes: 4128
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<functional>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int MOD = 1000000007;
const ll INF=2e18;

ll N,M,K,C;
ll a,b,c,d;
string s;
ll f[100][10];
ll p[100][11];
int main(){
    cin>>N;
    for(ll i=0;i<N;i++){
        for(ll j=0;j<10;j++){
            cin>>f[i][j];
        }
    }
    for(ll i=0;i<N;i++){
        for(ll j=0;j<=10;j++){
            cin>>p[i][j];
        }
    }
    ll ans=-INF;
    for(ll i=1;i<(1<<10);i++){
        ll tmp=0;
        for(ll k=0;k<N;k++){
            ll cnt=0;
            for(ll j=0;j<10;j++){
                if((i&(f[k][j]<<j))!=0){
                    cnt++;
                }
            }
            tmp+=p[k][cnt];
        }
        ans=max(ans,tmp);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*
//#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
*/
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
#define M_INF 1000000000
int n,m,v,i;
void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n>>m;
  std::vector<ll> v(n);
  rep(i,n) cin>>v[i];
  ll ans = INF;
  if(m==1) {
    rep(i,n) if(ans > abs(v[i]-0)) ans = abs(v[i]-0);
  } else {
  repl(i,m,n+1){
    // cout<<ans<<endl;
    if(v[i-m]*v[i-1] >=0) {
      if(v[i-1] >= 0) if(ans>v[i-1]) ans=v[i-1];
      if(v[i-1] < 0) if(ans>abs(v[i-m])) ans=abs(v[i-m]);
    } else {
      if(ans > abs(v[i-m]) * 2 + v[i-1]) ans = abs(v[i-m]) * 2 + v[i-1];
      if(ans > abs(v[i-m]) + v[i-1] * 2) ans = abs(v[i-m])  + v[i-1] * 2;
    }
  }
}
  cout<<ans<<endl;

}

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


Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <string>

using namespace std;
using ll = long long;

ll A, B;

void input() {
    cin >> A >> B;
}

ll xorsum(ll x) {
    ll ans = 0;
    for (ll i = 40; i >= 1; i--) {
        ll top = x & (1ull << i);
        if (top) {
            ll flow = x % (1ull << i);
            ans |= flow % 2 == 0 ? top : 0;
        }
    }
    if (x & (1ull << 1))
        ans |= ~(x & 1) & 1;
    else
        ans |= x & 1;
    return ans;
}

ll solve() {
    return xorsum(B) ^ (A > 0 ? xorsum(A - 1) : 0);
}

int main() {
    input();
    cout << solve() << endl;
    
    return 0;
}



Measured memory_bytes: 256
import scala.collection.mutable

object Main extends App {
  import scala.io.StdIn._
  val Array(n, q) = readLine.trim.split(' ').map(_.toInt)
  val nodes = Array.fill(n){Nil: List[Int]}
  for (_ ← 1 until n) {
    val Array(a, b) = readLine.trim.split(' ').map(_.toInt - 1)
    nodes(a) ::= b
    nodes(b) ::= a
  }
  val additional = Array.fill(n){0}
  for (_ ← 0 until q) {
    val Array(p, x) = readLine.trim.split(' ').map(_.toInt)
    additional(p - 1) += x
  }
  val queue = mutable.Queue[Int](0)
  val isVisited = Array.fill(n){false}
  while (queue.nonEmpty) {
    val top = queue.dequeue()
    isVisited(top) = true
    for (next ← nodes(top) if !isVisited(next)) {
      additional(next) += additional(top)
      queue.enqueue(next)
    }
  }
  println(additional.mkString(" "))
}

Measured memory_bytes: 143556
import * as fs from "fs";

// inputで受け取り配列化する
const input = fs.readFileSync("/dev/stdin", "utf8").split(" ");

const a = Number(input[0]);

let ans = 0;

for (let index = 1; index < a + 1; index++) {
  const divider = Math.floor(a / index);
  const result = (divider * (divider + 1) * index) / 2;
  ans += result;
}

console.log(ans);


Measured memory_bytes: 33268
#include<stdio.h>

/*配列の要素を順番に出力*/
void supertrace(int A[],int N){
    int i;
    for(i=0;i<N;i++){
        if(i>0)printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");
}

/*挿入ソート（0オリジン配列）*/
void insertionSort(int A[],int N){
    int j,i,v;
    for(i=1;i<N;i++){
        v=A[i];
        j=i-1;
        while(j>=0&&A[j]>v){
            A[j+1]=A[j];
            j--;
        }
        A[j+1]=v;
        supertrace(A,N);
    }
}





int main(){
    int N,i,j;
    int A[100];
    
    scanf("%d",&N);
    for(i=0;i<N;i++)
        scanf("%d",&A[i]);
    
    supertrace(A,N);
    insertionSort(A, N);
    
    return 0;
}



Measured memory_bytes: 2044
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<eps)
int money(int w)
{
	return 1150+max(min(w,20)-10,0)*125+max(min(w,30)-20,0)*140+max(w-30,0)*160;
}
int main()
{
	while(1)
	{
		int n;
		cin >> n;
		if(n==-1)break;
		cout << 4280-money(n) << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;

int main(void)
{
	int A, B, C, X;
	cin >> A >> B >> C >> X;

	int ret = 0;
	for(int i=0; i<=A; i++)
		for(int j=0; j<=B; j++)
			for(int k=0; k<=C; k++)
				if(i*500+j*100+k*50 == X)
					ret++;

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int a,b,c,m=0;
	scanf("%d %d %d",&a,&b,&c);
	if(m<a) m = a;
	if(m<b) m = b;
	if(m<c) m = c;
	printf("%d\n",a+b+c-m);
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <queue>
#include <list>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define crep(i) for(char i='a';i<='z';i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define ALL(x) (x).begin(),(x).end()
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
using namespace std;
using pii  = pair<int,int>;
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*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main() {
  ll K,N,A,p;cin >> N >> K;
  rep(i,N){
    cin >> A;
    if(A==1){
      p=i;
    }
  }
  cout << ((N-1)%(K-1)==0 ? (N-1)/(K-1) : (N-1)/(K-1)+1) << endl;
}

Measured memory_bytes: 256
fn main() {
    proconio::input! {
        n: usize,
        a_s: [usize; n],
    }
    let mut count = 0;
    for i in 0..n {
        if (i + 1) % 2 == 1 && a_s[i] % 2 == 1 {
            count += 1;
        }
    }
    println!("{}", count);
}


Measured memory_bytes: 2172
_ = gets.to_i
a = gets.split.map(&:to_i)

minus_count = a.select(&:negative?).count

result = if minus_count.even?
  a.map(&:abs).reduce(:+)
else
  list = a.map(&:abs)
  min = list.min
  list.reduce(:+) - min*2
end

puts result


Measured memory_bytes: 10116
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
	ios::sync_with_stdio(false);
	ll n, k;
	cin >> n >> k;
	ll result = 0;
	for (ll a = 1; a <= n; a++)
	{
		if ((2LL * a) % k == 0LL)
		{
			ll xL = (a + k) / k, xR = (a + n) / k;
			ll d = xR - xL + 1;
			result += d * d;
		}
	}
	cout << result << endl;
}

Measured memory_bytes: 256
def main():
    n, k = map(int, input().split())
    s = input()
    a = s.count("RL")  # RLの順に並んでいる箇所をカウント
    ans = 0  # 答えを初期化
    # print("a=", a)
    for i in range(n - 1):
        if s[i] == s[i + 1]:
            ans += 1  # 最初の点数をカウント
    for i in range(1, k + 1):
        # print("i=", i)
        # print("ans=", ans)
        # print("n-1-ans=", n - 1 - ans)
        if n - 1 - ans > 1:
            ans += 2
        else:
            ans += n - 1 - ans
            break
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3316
#include<bits/stdc++.h>
 using namespace std;
 int main() {
     int num,counter=0;
     cin >> num;
     vector<int> arr(num);

    for(int f = 0; f <num; f++)
     {
         cin >> arr[f];
     }
     for(int f = 0; f <num; f++)
     {
          if(arr[f] != f + 1)
          counter++;
     }
      if(counter <= 2)
      {
            cout << "YES" << endl;
      }

       else
       {
            cout << "NO" << endl;
       }


    return 0;
}


Measured memory_bytes: 3540
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cctype>
#define rep(i,x,y) for(int i=x; i<=y; ++i)

using namespace std;
typedef long long LL;
int n,ga,gb,sa,sb,ba,bb;
LL f[5005*5005];

int main()
{
	scanf("%d",&n);
	scanf("%d%d%d",&ga,&sa,&ba);
	scanf("%d%d%d",&gb,&sb,&bb);
	rep(i,1,n)
	{
		f[i]=f[i-1]+1;
		if(i>=ga) f[i]=max(f[i],f[i-ga]+gb);
		if(i>=sa) f[i]=max(f[i],f[i-sa]+sb);
		if(i>=ba) f[i]=max(f[i],f[i-ba]+bb);
	}
	n=f[n];
	swap(ga,gb),swap(sa,sb),swap(ba,bb);
	memset(f,0,sizeof(f));
	rep(i,1,n)
	{
		f[i]=f[i-1]+1;
		if(i>=ga) f[i]=max(f[i],f[i-ga]+gb);
		if(i>=sa) f[i]=max(f[i],f[i-sa]+sb);
		if(i>=ba) f[i]=max(f[i],f[i-ba]+bb);
	}
	printf("%lld\n",f[n]);
	return 0;
}

Measured memory_bytes: 195840
x, y = map(int, input().split())

if y%2 == 1:
    print("No")
else:
    crane = (x*4 - y)//2
    turtles = x - crane

    if crane + turtles != x or crane < 0 or turtles < 0:
        print("No")
    else:
        print("Yes")

Measured memory_bytes: 9176
#include<iostream>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;

int n, a[100000];

int64_t calc(int sign) {
    int64_t ret = 0, sum = 0;
    rep(i, n) {
        sum += a[i];
        if (sum * sign <= 0) {
            ret += abs(sum) + 1;
            sum = sign;
        }
        sign *= -1;
    }
    return ret;
}

int main() {
    cin >> n;
    rep(i, n) cin >> a[i];
    cout << min(calc(1), calc(-1)) << endl;
}

Measured memory_bytes: 640
/*
 * 2662.cc: Soccer
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100;

/* typedef */

struct Log {
  int f, a, t;
  double x, y;
  Log() {}
};

/* global variables */

Log ls[MAX_N];
double maxds[2], minss[2];

/* subroutines */

/* main */

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> ls[i].f >> ls[i].a >> ls[i].t >> ls[i].x >> ls[i].y;

  maxds[0] = maxds[1] = -1.0;
  minss[0] = minss[1] = 0.0;

  for (int i = 1; i < n; i++) {
    Log &l0 = ls[i - 1], &l1 = ls[i];

    if (l0.t == l1.t && l0.a != l1.a) {
      double dx = l1.x - l0.x, dy = l1.y - l0.y;
      double d = sqrt(dx * dx + dy * dy);
      double s = (l1.f - l0.f) / 60.0;

      if (maxds[l0.t] < d) {
	maxds[l0.t] = d;
	minss[l0.t] = s;
      }
      else if (maxds[l0.t] == d && minss[l0.t] > s)
	minss[l0.t] = s;
    }
  }

  for (int i = 0; i < 2; i++) {
    if (maxds[i] < 0.0) puts("-1 -1");
    else printf("%.8lf %.8lf\n", maxds[i], minss[i]);
  }

  return 0;
}

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

int main(){
  int N,A;
  cin >> N;
  int Even_temp,Even = 100000;
  for(int i = 0;i < N;i++){
    cin >> A;
    Even_temp = 0;
    while(true){
      if(A % 2 == 1)
        break;
      A /= 2;
      Even_temp += 1;
    }
    if(Even > Even_temp)
      Even = Even_temp;
  }
  
  cout << Even << endl;
}
    
    

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;


ll dp[110][102000];   //i番目価値vの重さ最小
int main(){
    ll n, W;
    cin >> n >> W;
    vector<ll> w(n), v(n);
    rep(i, n)cin >> w[i] >> v[i];

    rep(i, 101000)dp[0][i] = INF * INF;
    dp[0][0] = 0;

    rep(i, n){
        rep(j, 100100){
            //dp[i + 1][j] = dp[i][j];
            if(j - v[i] >= 0){
                dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i]);
            }
            else dp[i + 1][j] = dp[i][j];
        }
    }
    for(int i = 100000; i >= 0; i--){
        if(dp[n][i] <= W){
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 82556
#define NDEBUG
#include <bits/stdc++.h>
#define mset(a,b) memset(a,b,sizeof a)
#define mcpy(a,b) memcpy(a,b,sizeof b)
#define xx first
#define yy second
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define pii pair<int,int> 
#define lb(x) ((x)&(-(x)))
#define dalao 1000000007
#define inf 0x3f3f3f3f
#define N 100010
using namespace std;
typedef long long ll;
int n,a[N];
ll f[N][3];
char b[N];
inline int get(int i,int j){return (j&1)^(b[i]=='-')?-a[i]:a[i];}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		if(i==1)b[i]='+';
		else while((b[i]=getchar())!='+'&&b[i]!='-');
		scanf("%d",&a[i]);
	}
	for(int i=1;i<=n+1;i++)for(int j=0;j<3;j++)f[i][j]=-0x3f3f3f3f3f3f3f3fll;
	f[1][0]=0;
	for(int i=1;i<=n;i++)for(int j=0;j<3;j++)if(f[i][j]>-0x3f3f3f3f3f3f3f3fll){
		if(j<2&&b[i]=='-')f[i+1][j+1]=max(f[i+1][j+1],f[i][j]+get(i,j));
		if(j)f[i+1][j-1]=max(f[i+1][j-1],f[i][j]+get(i,j));
		f[i+1][j]=max(f[i+1][j],f[i][j]+get(i,j));
//		cout<<i<<" "<<j<<" "<<f[i][j]<<endl;
	}
	printf("%lld",f[n+1][0]);
	return 0;
}

Measured memory_bytes: 3072