akhauriyash/Code-Regression huggingface dataset:
const int isDebugMode = 1;
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
struct edge{long long to,cost;};
const int inf = 1 << 27;
const long long INF = 1LL << 60;
const int COMBMAX = 1001001;
const long long MOD = 1000000007;
const long long dy[] = {-1, 0, 0, 1};
const long long dx[] = {0, -1, 1, 0};
string abc = "abcdefghijklmnopqrstuvwxyz";
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define eachdo(v, e) for (const auto &e : (v))
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (long long)distance((v).begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (long long)distance((v).begin(), upper_bound((v).begin(), (v).end(), e))
long long mpow(long long a, long long n, long long mod = MOD){long long res = 1; while(n > 0){if(n & 1)res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
void pt(){cout << endl; return;}
template<class Head> void pt(Head&& head){cout << head; pt(); return;}
template<class Head, class... Tail> void pt(Head&& head, Tail&&... tail){cout << head << " "; pt(forward<Tail>(tail)...);}
void dpt(){if(!isDebugMode) return; cout << endl; return;}
template<class Head> void dpt(Head&& head){if(!isDebugMode) return; cout << head; pt(); return;}
template<class Head, class... Tail> void dpt(Head&& head, Tail&&... tail){if(!isDebugMode) return; cout << head << " "; pt(forward<Tail>(tail)...);}
template<class T> void debug(T v){if(!isDebugMode) return; rep(i, v.size()) cout << v[i] << " " ; cout << endl;}
template<class T> void debug2(T v){if(!isDebugMode) return; rep(i, v.size()){rep(j, v[i].size()) cout << v[i][j] << " " ; cout << endl;}}
template<class T1, class T2> inline bool chmin(T1 &a, T2 b){if(a > b){a = b; return true;} return false;}
template<class T1, class T2> inline bool chmax(T1 &a, T2 b){if(a < b){a = b; return true;} return false;}
template<class T1, class T2> long long recgcd(T1 a, T2 b){return a % b ? recgcd(b , a % b) : b;}
bool valid(long long H, long long W, long long h, long long w) { return 0 <= h && h < H && 0 <= w && w < W; }

int main(){
    ll X, K, D; cin >> X >> K >> D;
    ll pls, neg;
    pls = X % D;
    if(pls < 0) pls += D;
    neg = pls - D;
    ll time = abs(X - pls) / D;
    if(K >= time){
        if(K % 2 == time % 2) pt(pls);
        else pt(abs(neg));
    }else{
        if(X >= 0){
            pt(X - K * D);
        }else{
            pt(abs(X + K * D));
        }
    }

}

Measured memory_bytes: 3636
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	int a = sc.nextInt();
      	int b = sc.nextInt();
      	if(a < 2*b) System.out.println(0);
      	else System.out.println(a-(2*b));
    }
}

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

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

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

/* -----  __MAKE_TIME__  Problem: __PROBLEM__ / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */



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

	LL N, T; cin >> N >> T;
	VL a(N);

	FOR(i, 0, N) {
		cin >> a[i];
	}
	// 最大差分をつくれる区間をカウントすれば良い
	LL Mn = a.front();
	int cnt = 0;
	LL gainmax = -1;
	FOR(i, 0, N) {
		Mn = min(Mn, a[i]);
		if (gainmax == a[i] - Mn)cnt++;
		else if (gainmax < a[i] - Mn) {
			gainmax = a[i] - Mn;
			cnt = 1;
		}
	}

	LL ans = cnt;
	cout << ans << "\n";

	return 0;
}


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

#define int long long int
#define ps push_back
#define mod 1000000007
#define fi first
#define so second
#define pii pair<int,int>
#define TT int tt;cin>>tt;for(int cc=1;cc<=tt;cc++)

signed main()
{
    int n,i;
    cin>>n;
    int p[n+1]={0},c[n+1]={0};
    for(i=2;i<=n;i++) {cin>>p[i];c[p[i]]++;}
    for(i=1;i<=n;i++) cout<<c[i]<<"\n";
}


Measured memory_bytes: 6800
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a[];
		int p[];
		
		p = new int[3];
		a = new String[3];
		
		for(int i = 0; i < 3; ++i) {
			a[i] = sc.nextLine();
			p[i] = 0;
		}
		
		int turn = 0;
		int win = turn;
		
		while(p[turn] != a[turn].length()) {
			++p[turn];
			turn = a[turn].charAt(p[turn] - 1) - 'a';
			win = turn;
		}
		
		System.out.println((char)(win + 'A'));
		
		sc.close();
	}

}


Measured memory_bytes: 22868
#include <stdio.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

#define M 1000000007
ll factm(ll n,ll m){ll x=1;while(n)x=x*n--%m;return x;}

int main(){
	ll n,m;
	scanf("%lld%lld\n",&n,&m);
	if(llabs(n-m)>1)puts("0");	
	else printf("%lld\n",factm(n,M)*factm(m,M)*(n==m?2:1)%M);
}

Measured memory_bytes: 128
n = int(input())
a =list(map(int,input().split()))
b =list(map(int,input().split()))
c = list(map(int,input().split()))

bonus = 0
for i in range(n-1):
    if a[i]+1 == a[i+1]:
        bonus += c[a[i]-1]
print(sum(b)+bonus)

Measured memory_bytes: 9184
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <istream>
#include <sstream>
#include <iomanip>
#include <iterator>
#include <climits>
using namespace std;

typedef ostringstream OSS;
typedef istringstream ISS;

typedef vector<int> VI;
typedef vector< VI > VVI;

typedef long long LL;

typedef pair<int, int> PII;
typedef vector<PII> VPII;

#define X first
#define Y second

int H, W;
int N;
vector< vector<bool> > bads;
VVI memo;

int solve(int y, int x) {
	if (y < 0 || H <= y || x < 0 || W <= x) return 0;
	if (memo[y][x] != -1) return memo[y][x];
	if (y == H - 1 && x == W - 1) return memo[y][x] = 1;
	if (bads[y][x]) return memo[y][x] = 0;

	return memo[y][x] = solve(y + 1, x) + solve(y, x + 1);
}

int main(void) {
	while (cin >> W >> H, W) {
		cin >> N;
		bads = vector<vector<bool>>(H, vector<bool>(W));
		memo = VVI(H, VI(W, -1));

		for (int i = 0; i < N; i++) {
			int x, y;
			cin >> x >> y;
			bads[--y][--x] = true;
		}

		cout << solve(0, 0) << endl;
	}

	return 0;
}

Measured memory_bytes: 1216
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int k = sc.nextInt();
        int maxSum = 0;

        if (k<=a) {
            maxSum = k;
        }else if (k <= a+b) {
            maxSum = a;
        }else if (k <= a+b+c) {
            maxSum = a - (k-a-b);
        }


        // 出力
        System.out.println(maxSum);
    }
}

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

using namespace std;

int main() {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;

  // 1
  for(int i = 0; i < tx - sx; i++)
    cout << "R";
  for(int i = 0; i < ty - sy; i++)
    cout << "U";
  for(int i = 0; i < tx - sx; i++)
    cout << "L";
  for(int i = 0; i < ty - sy; i++)
    cout << "D";

  // 2
  cout << "D";
  for(int i = 0; i < tx - sx + 1; i++)
    cout << "R";
  for(int i = 0; i < ty - sy + 1; i++)
    cout << "U";
  cout << "L";

  cout << "U";
  for(int i = 0; i < tx - sx + 1; i++)
    cout << "L";
  for(int i = 0; i < ty - sy + 1; i++)
    cout << "D";
  cout << "R";

  cout << endl;

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
long long abs(long long a,long long b){
  if(a>b)
    return a-b;
  else
    return b-a;
}

int main(){
 int n,k;
  cin >> n >> k;
  vector<long long> da(n);
  for(int i=0;i<n;i++)
    cin >> da[i];
  vector<long long> dp(n,1000000000);
  dp[0]=0;
  for(int i=0;i<n;i++){
    for(int j=1;j<k+1;j++){
      if(i+j<n){
        dp[i+j]=min(dp[i+j],dp[i]+abs(da[i],da[i+j]));
      }
    }
  }
  cout << dp[n-1] << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<sstream>
#include<complex>
#include<functional>
#include<vector>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include<set>

using namespace std;



int main(){
    int i,j=1,k=1,n;
    cin >> n;
    int x[n-1],y[n-1],a[n],b[n];
    for(i=0;i<n;i++){
        cin >> a[i];
    }

    sort(a,a+n);

    for(i=0;i<n-2;i++){
        if(a[j]<=0){
            x[i]=a[n-1];
            y[i]=a[j];
            a[n-1]-=y[i];
            j++;
        }else if(a[n-k-1]>0){
            x[i]=a[0];
            y[i]=a[n-k-1];
            a[0]-=y[i];
            k++;
        }
    
    }

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

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

void factorize2(ll n, vector<pair<ll, ll>>& out) {
    out.clear();
    for (ll i = 2; i * i <= n; ++i) {
        if(n % i){
            continue;
        }
        out.emplace_back(i, 0);
        while(n % i == 0){
            n /= i;
            out.back().second++;
        }
    }
    if(n != 1){
        out.emplace_back(n, 1);
    }
}

void solve(long long N, long long P){
    vector<pair<ll, ll>> f;
    factorize2(P, f);
    ll ans = 1;
    REP(i, f.size()){
        REP(j, f.at(i).second / N){
            ans *= f.at(i).first;
        }
    }
    cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
int main(){
    long long N;
    scanf("%lld",&N);
    long long P;
    scanf("%lld",&P);
    solve(N, P);
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        String x[] = line.split(" ");
        int hen1 = Integer.valueOf(x[0]);
        int hen2 = Integer.valueOf(x[1]);
        int hen3 = Integer.valueOf(x[2]);
        if(hen1==hen2&&hen2==hen3&&hen1==hen3){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 21844
(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());
  const arr = lines.shift().split(' ').map(Number);
  console.log(' ' + buildMaxHeap(arr).join(' '));
})();

function buildMaxHeap(arr) {
  const n = arr.length;
  const maxHeapify = (i) => {
    let left, right, largest;
    left = 2 * i + 1;
    right = 2 * i + 2;
    if (left < n && arr[left] > arr[i]) largest = left;
    else largest = i;
    if (right < n && arr[right] > arr[largest]) largest = right;
    if (largest != i) {
      arr[largest] = [arr[i], arr[i] = arr[largest]][0];
      maxHeapify(largest);
    }
  };

  for (let i = Math.floor(arr.length / 2); i >= 0; i--) maxHeapify(i);
  return arr;
}



Measured memory_bytes: 112780
#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    int a, b;
//    cin>> a;
//    a = a+a/2;
//    cout << a;
    cin>> a>> b;

    int flavor[a];
    int pieflavor = 0;
    int m =400;
    int output = 0;
    for (int i = 0; i< a; i++){
        flavor[i] = b;
        flavor[i]+=i;
        pieflavor+=flavor[i];
    }
    for (int i = 0; i< a; i++){ //for every time you skip the ith apple
        int iflavor = 0;
        int iflavorcompare = 0;
        for (int j = 0; j< a; j++){
            if (j==i){
                continue;
            }
            else {
                iflavor+=flavor[j];
            }
        }
        //makke the iflavor diference to pieflavor
    
        iflavorcompare = pieflavor - iflavor;
        if (iflavorcompare<=0){
            iflavorcompare*=-1;
        }
//        cout << iflavor<< " "<< m<< endl ;
        if (iflavorcompare <= m){
            m = iflavorcompare;
            output = iflavor;
        }
        
    }
    cout << output;
    
    
    
    
    return 0;
}

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

using namespace std;

int main(){
    string s, t;
    while(cin >> s >> t){
        vector<vector<int>> next(26, vector<int>(s.size(), -1));
        const int n = s.size();
        for(int i=0;i<n;i++){
            if(next[s[i]-'a'][i] != -1) continue;
            int p = i;
            for(int j=1;j<=n;j++){
                int idx = (i-j+n)%n;
                next[s[i]-'a'][idx] = p;
                if(s[idx] == s[i]) p = idx;
            }
        }
        long long res = 0;
        int pos = 0;
        bool first = true;
        for(auto& c : t){
            if(first){
                first = false;
                if(c == s[0]) continue;
            }
            if(next[c-'a'][pos] == -1){
                res = -1;
                break;
            }
            if(next[c-'a'][pos] <= pos) ++res;
            pos = next[c-'a'][pos];
        }
        cout << (res < 0 ? -1 : res*n + pos + 1) << endl;
    }
}

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  string s,t; cin >> s >> t;

  int ans = INF;
  if(s.size()==1){
    if(s[0]==t[0]) ans = 0;
    else ans = 1;
    cout << ans << endl;
    return 0;
  }
  
  rep(i,s.size()){
    int tmp = 0;
    rep(j,t.size()){
      if(i+t.size()>s.size()) continue;
      if(s[i+j]!=t[j]) tmp++;
      //cout << s[i+j];
    }    
    if(i+t.size()>s.size()) continue;
    //cout << endl << t << " " << tmp << endl;
    ans = min(ans,tmp);
  }

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


Measured memory_bytes: 3636
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define uint unsigned int
#define ull  unsigned long long
typedef string str;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define fi first
#define se second
#define in insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
const int INF = 1e9 + 5;
const int N = 2e5 + 123;
int main(){
    speed;
    int n, m;
    cin >> n >> m;
    int mx = max(n, m);
    int mn = n + m - mx;
    for(int i = 0; i < mx; i++){
        cout << mn;
    }
}

Measured memory_bytes: 256
// J'aime
// Chemise Blanche

#include <bits/stdc++.h>
using namespace std;

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  int n; cin >> n;
  vector<int> a(n);
  int is_pw = 1;
  for (auto &i : a) cin >> i;
  set<int> s;
  for (auto &i : a) {
    int t = i;
    for (int j = 2; j * j <= t; j++) {
      if (t % j == 0) {
        if (s.count(j)) is_pw = 0;
        while (t % j == 0) t /= j;
        s.insert(j);
      }
    }
    if (t > 1) {
      if (s.count(t)) is_pw = 0;
      s.insert(t);
    }
  }
  if (is_pw) {
    cout << "pairwise coprime" << '\n';
    return;
  }
  int t = a[0];
  for (int i = 1; i < n; i++) {
    t = __gcd(t, a[i]);
  }
  if (t == 1) {
    cout << "setwise coprime" << '\n';
  }
  else {
    cout << "not coprime" << '\n';
  }
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 14728
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest
import itertools
import copy

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    h,w,k=map(int, readline().rstrip().split())
    masu=[""]*h
    for i in range(h):
        masu[i]=readline().rstrip() #.split()

    ans=0
    for x in itertools.product([0,1], repeat=(h+w)):
        m=copy.deepcopy(masu)
        kuro=0
        for i in range(h):
            if x[i]==1:
                m[i]=" "*w
        for i in range(w):
            if x[i+h]==1:
                continue
            for j in range(h):
                if m[j][i]=="#":
                    kuro+=1
        if kuro==k:
            ans+=1
    print(ans)
    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

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

int main() {
  int A,B;
  cin >> A>>B;
  if((A+B)%2!=0) cout <<"IMPOSSIBLE"<<endl;
  else cout<<(A+B)/2<<endl;
}


Measured memory_bytes: 3620
import sys
from itertools import combinations

stdin = sys.stdin
 
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N = ri()
x = int((2 * N) ** (0.5))
if x * (x+1) == 2 * N:
    print('Yes')
else:
    print('No')
    exit()

k = x + 1 #部分集合の個数 
num = 2 * N // k #部分集合の要素数
answer = [[] for _ in range(k)]
for i, (a, b) in enumerate(combinations(range(k), 2), 1):
    answer[a].append(i)
    answer[b].append(i)

print(k)
for a in answer:
    print(num, *a)


Measured memory_bytes: 9496
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int X,A,B;
  cin>>X>>A>>B;
  cout << X-A-(X-A)/B*B<<endl;
  return 0;
}


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

using namespace std;
typedef pair<int, int> pii;

int main(){

    while(1){
        int N;
        cin>> N;
        if(N==1) break;

        vector<int> u;
        for(int i=2; i<=N; i++){
            if(i%7==1||i%7==6) u.push_back(i);
        }
        vector<int> v;
        for(int i=0; i<u.size(); i++){
            if(N%u[i]==0){
                bool f=true;
                for(int j=0; j<u.size(); j++){
                    if(u[j]*u[j]>u[i]) break;
                    if(u[i]%u[j]==0){f=false; break;}
                }
                if(f) v.push_back(u[i]);
            }
        }

        cout<< N<< ":";
        for(int i=0; i<v.size(); i++){
            cout<< " "<< v[i];
        }cout<< endl;
    }

    return 0;
}

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

int main(){
  string c = "YES", S;
  cin >> S;
  reverse(S.begin(),S.end());
  string a[4]={"maerd","remaerd","esare","resare"};
  for(int i=0;i<S.size();){
    bool can=0;
    for(int j=0;j<4;j++){
      string d=a[j];
      if(S.substr(i,d.size())==d){
        i += d.size();
        can = 1;
      }
    }
    if(!can){
      c = "NO";
      break;
    }
  }
  cout << c << endl;
}


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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

ll minll(ll a, ll b){
    if(a >= b)  return b;
    else    return a;
}

ll maxll(ll a, ll b){
    if(a >= b)  return a;
    else    return b;
}

ll n,k;
ll max_num;
struct gr{
    ll rin_num;
    ll up_rin;
    ll low_rin;
};
ll graph[110][110];
gr gra_data[110];

void solve(ll add_p){

}

int main(){
    cin >> n >> k;
    max_num = 0;
    for(int i = 1; i <= n-2; i++){
        max_num += i;
    }

    if(k > max_num){
        cout << "-1\n";
        return 0;
    }

    ll cou = n-1;
    cou += max_num-k;

    cout << cou << endl;

    for(int i = 2; i <= n; i++){
        cout << "1 " << i << endl;
    }

    ll num = max_num-k;
    ll st = 2,st_cou = 3;
    while(num != 0){
        if(st_cou > n){
            ++st;
            st_cou = st+1;
        }
        cout << st << " " << st_cou << endl; 
        ++st_cou;
        --num;
    }


}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s=scan.nextLine();
		if(s.contains("SAT")) System.out.println("1");
		else if (s.contains("MON"))System.out.println("6");
		else if (s.contains("TUE")) System.out.println("5");
		else if (s.contains("WED")) System.out.println("4");
		else if (s.contains("THU")) System.out.println("3");
		else if (s.contains("FRI")) System.out.println("2");
		else System.out.println("7");
	}

}


Measured memory_bytes: 26936
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <string>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <fstream>
using namespace std;
const long long inf=1e9+7;
const long long mod=1e9+7;
const int64_t CYCLES_PER_SEC=2800000000;
//
inline uint32_t Xor128(){
	static uint32_t x=123456789;
	static uint32_t y=362436069;
	static uint32_t z=521288629;
	static uint32_t w=88675123;
	uint32_t t=x^(x<<11);
	x=y;y=z;z=w;
	return w=(w^(w>>19))^(t^(t>>8));
}
struct Timer{
	int64_t start;
	Timer(){reset();}
	void reset(){start=getcycle();}
	void plus(double a){start-=(a*CYCLES_PER_SEC);}
	inline double get(){return (double)(getcycle()-start)/CYCLES_PER_SEC;}
	inline int64_t getcycle(){
		uint32_t low,high;
		__asm__ volatile ("rdtsc":"=a"(low),"=d"(high));
		return ((int64_t)low)|((int64_t)high<<32);
	}
};
int main(){
	long long n,k;
	long long a[100000];
	cin>>n>>k;
	long long cnt[45]={};
	for(long long i=0;i<n;i++){
		cin>>a[i];
		for(long long j=0;j<40;j++){
			if(a[i]&(1LL<<j)){
				cnt[j]++;
			}
		}
	}
	long long x=0;
	for(long long i=39;i>=0;i--){
		if(cnt[i]<=n/2){
			if(x+(1LL<<i)>k){
				continue;
			}
			x+=(1LL<<i);
		}
	}
	long long ans=0;
	for(long long i=0;i<n;i++){
		ans+=(x^a[i]);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1024
use std::io::*;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    
    let mut sp: Vec<(String, i64, usize)> = Vec::new();
    for i in 0..n {
        let s: String = read();
        let p: i64 = read();
        sp.push((s, -p, i));
    }
    sp.sort();

    for i in 0..n {
        println!("{}", sp[i].2 + 1);
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define inf LLONG_MAX
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll n, m; cin >> n >> m;
    priority_queue<ll> que;
    rep(i, n) {
        ll num; cin >> num;
        que.push(num);
    }

    rep(i, m) {
        ll num = que.top(); que.pop();
        que.push(num / 2);
    }

    ll sum = 0;
    while (que.size()) {
        sum += que.top(); que.pop();
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1400
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

a,p = na()
b = a*3+p
print(b//2)

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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = 1e9 + 100;
const long long LLINF = 2e18 + 129;
const long long MOD = 1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

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

    int n, m;
    cin >> n >> m;

    vector< set<int> > v(n);
    rep(i, n){
        int k;
        cin >> k;
        rep(j, k){
            int a;
            cin >> a;
            v[i].insert(a);
        }
    }

    int ans = 0;
    REP(i, 1, m + 1){
        bool flag = true;
        rep(j, n){
            flag &= v[j].count(i);
        }
        ans += flag;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n = gets.to_i

S = []
n.times do |i|
    s = gets.chomp.chars.sort
    S << s 
end

S.sort!

ans = 0
cnt = 0
n.times do |i|
    
    if i == n - 1 or S[i] != S[i+1]
        ans += (cnt+1)*cnt/2
        cnt = 0
    else
        cnt += 1
    end
end

puts ans

Measured memory_bytes: 66432
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000, boost::int128_type>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }
template<class T> vector<vector<T>> split (const vector<T>& S, T delim) { vector<vector<T>> ret{}; vector<T> buff{}; for (auto c : S) { if (c == delim) { if (!buff.empty()) ret.push_back(buff); buff.clear(); } else { buff.push_back(c); } } if (!buff.empty()) ret.push_back(buff); return ret; }
template<class T> inline void printYesNo(const T& t) { cout << (t ? "Yes" : "No") << CRLF; }
template<class T = int64_t> T modpow(T N, T P, T M) { T ret{1}; N %= M; while (P) { if (P & 0x01) { ret *= N; ret %= M; } P >>= 1; N *= N; N %= M; } return ret; }

/** code for assert debug begin */
int gErr = 0;
#define ASSERT(p) if(!(p)){ gErr = 1; }else{ ; }
/** code for assert debug end */

struct Tmp
{
public:
  int N;
  Tmp(int N)
  : N(N)
  {}
};

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

  map<int, int> mp{};
  for (int n = 1; n <= N; ++n) {
    int m = n;
    for (int k = 2; k <= m; ++k) {
      while (m % k == 0) {
        ++mp[k];
        m /= k;
      }
    }
  }

  ll res = 1;
  for (const auto& p : mp) {
    ll s = p.second + 1;
    s %= MOD;
    res *= s;
    res %= MOD;
  }
  cout << res << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
/*      ░░█ ▄▀█ █   █▀ █░█ █▀█ █▀▀ █▀▀   █▀█ ▄▀█ █▀▄▀█
        █▄█ █▀█ █   ▄█ █▀█ █▀▄ ██▄ ██▄   █▀▄ █▀█ █░▀░█     */

// Author : Udit "luctivud" Gupta @ (https://www.linkedin.com/in/udit-gupta-1b7863135/)


#include <bits/stdc++.h>
#pragma GCC optimize "trapv"

using namespace std;

typedef long long int lld;
typedef unsigned long long int llu;


#define       TESTCASES()  cin >> (T3X0); T353 = T3X0; while(T3X0--)
#define       _input(V3C)  for(auto &V3C_I7 : (V3C)) cin >> (V3C_I7)
#define mems(A77AY, V4LU)  memset((A77AY), (V4LU), sizeof((A77AY)))
#define  CH3K(I7, E4, S7)  (((S7)<0) ? (I7)>(E4) : (I7)<(E4))
#define for4(I7,S4,E4,S7)  for(auto I7=(S4); CH3K(I7,E4,S7); (I7)+=(S7))




void solveEachTest(lld T35TC453N = 1) {

	lld n; cin >> n;
	vector<lld> arr(n);
	_input(arr);
	cout << *max_element(arr.begin(), arr.end()) - *min_element(arr.begin(), arr.end());

	return;
}


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

	lld T3X0 = 0, T353 = 1;

	// TESTCASES()
	solveEachTest(T353 - T3X0);
	return 0;
}
// Random Thought :  null

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

int main(void) {
  int n, q;
  cin >> n;
  int hash[100009] = {0};
  vector<ll> a(n);
  ll sum = 0;
  rep(i, n) {
    cin >> a[i];
    hash[a[i]]++;
    sum += a[i];
  }
  cin >> q;
  vector<ll> b(q), c(q);
  rep(i, q) {
    cin >> b[i] >> c[i];
    sum -= b[i] * hash[b[i]];
    sum += c[i] * hash[b[i]];
    cout << sum << endl;
    hash[c[i]] += hash[b[i]];
    hash[b[i]] = 0;
  }
  return 0;
}

Measured memory_bytes: 5892
#include <iostream>
#include <cstring>
#include <string>

int n, m, k;
int a[10][10], b[10][10], c[10][10];
int ans;

void dfs(int now, int type) {
    if (type == 0 && now == n + 1) { memcpy(c, b, sizeof(b)); dfs(1, 1); return; }
    if (type == 1 && now == m + 1) {
        int sum = 0;
        for (int i = 1; i <= n; ++i)
            for (int j = 1; j <= m; ++j)
                sum += c[i][j];
        if (sum == k) ++ans;
        return;
    }
    dfs(now + 1, type);
    if (type == 0)
        for (int i = 1; i <= m; ++i)
            b[now][i] = 0;
    else
        for (int i = 1; i <= n; ++i)
            c[i][now] = 0;
    dfs(now + 1, type);
    if (type == 0)
        for (int i = 1; i <= m; ++i)
            b[now][i] = a[now][i];
    else
        for (int i = 1; i <= n; ++i)
            c[i][now] = b[i][now];
}

int main() {
    std::ios::sync_with_stdio(false), std::cin.tie(nullptr), std::cout.tie(nullptr);
    std::cin >> n >> m >> k;
    for (int i = 1; i <= n; ++i) {
        std::string s;
        std::cin >> s;
        for (int j = 1; j <= m; ++j) c[i][j] = b[i][j] = a[i][j] = s[j - 1] == '#';
    }
    dfs(1, 0);
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 3652
use proconio::input;


fn factorize(mut base: i64) -> Vec<(i64, i64)> {
    let mut fs = Vec::<(i64, i64)>::new();
    let mut i: i64 = 2;

    while i*i <= base {
        if base % i == 0 {
            let mut cnt: i64 = 0;

            while base % i == 0 {
                base /= i;
                cnt += 1;
            }
            fs.push((i, cnt));
        }
        i += 1;
    }

    if base > 1 {
        fs.push((base, 1));
    }

    return fs;
}


fn main() {
    input! {
        n: i32,
        a: [i64; n],
    }

    let mut ans = 0;

    for ai in a {
        for (i, c) in factorize(ai) {
            if i == 2 {
                ans += c;
            }
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 2348
#include<bits/stdc++.h>
#define ll long long int
using namespace std;

int main(void) {
  int n,m,c;
  cin >> n >> m >> c;

  vector<int>b(m);
  for (int i = 0; i < m; i++) {
    cin >> b[i];    
  }

  int res = 0;
  for (int i = 0; i < n; i++) {
    int a=c;
    for (int i = 0; i < m; i++) {
      int aa;
      cin >> aa;
      a+=aa*b[i];
    }
    if(a>0){
      res++;
    }
  }

  cout << res << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


struct Info{
	Info(ll arg_minus_value,ll arg_loc){
		minus_value = arg_minus_value;
		loc = arg_loc;
	}
	ll minus_value,loc;
};


int main(){

	ll S,T,D;
	scanf("%lld %lld %lld",&S,&T,&D);

	ll* table = new ll[D];
	for(int i = 0; i < D; i++)scanf("%lld",&table[i]);

	vector<Info> V;
	if(table[0] < 0){
		V.push_back(Info(abs(table[0]),0));
	}

	for(int i = 1; i <= D-1; i++){
		table[i] += table[i-1];
		if(table[i] < 0){
			V.push_back(Info(abs(table[i]),i));
		}
	}

	ll tmp = S;

	for(int day = 1; day <= D; day++){
		tmp = S+table[day-1];
		if(tmp <= T){
			printf("%d\n",day);
			return 0;
		}
	}

	if(tmp >= S){
		printf("-1\n");
		return 0;
	}

	ll pre_loc = -1;
	ll ans = D;

	while(true){

		for(int i = 0; i < V.size(); i++){

			if(V[i].loc <= pre_loc){
				ans += (V[i].loc+D)-pre_loc;
			}else{
				ans += V[i].loc-pre_loc;
			}
			if(tmp -V[i].minus_value<= T){
				printf("%lld\n",ans);
				return 0;
			}
			pre_loc = V[i].loc;
		}
		tmp -= V[V.size()-1].minus_value;
	}

	return 0;
}

Measured memory_bytes: 5664
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy

n = input()
if n[-1] == "2" or n[-1] == "4" or n[-1] == "5" or n[-1] == "7" or n[-1] == "9":
    print("hon")
elif n[-1] == "0" or n[-1] == "1" or n[-1] == "6" or n[-1] == "8":
    print("pon")
else:
    print("bon")

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

int days(int y, int m, int d) {
    if (m < 3) {
        --y;
        m += 12;
    }
    return 365 * y + y / 4 - y / 100 + y / 400 + (306 * (m + 1)) / 10 + d - 428;
}

int main() {
    int y1, m1, d1, y2, m2, d2;
    while (cin >> y1 >> m1 >> d1 >> y2 >> m2 >> d2) {
        if (y1<0 || m1<0 || d1<0 || y2<0 || m2<0 || d2<0) {
            break;
        }
        cout << days(y2,m2,d2) - days(y1,m1,d1) << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include<iostream>
using namespace std;
long long gcd(long long ,long long);
int main(){
  long long a,b,c,d;
  while(cin>>a>>b){

  c=gcd(a,b);
  d=a*(b/c);
  cout<<c<<' '<<d<<endl;
  }
  return 0;
}

long long gcd(long long x,long long y){
  while(x!=y){
    if(x>y){
      x=x%y;
      if(x==0) return y;
    }
    else{
      y=y%x;
      if(y==0) return x;
    }
  }
  return x;
}

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

using namespace std;

int main()
{
    int a, b, c, n5 = 0, n7 = 0;
    cin >> a >> b >> c;
    if (a == 5) n5 ++;
    if (a == 7) n7 ++;
    if (b == 5) n5 ++;
    if (b == 7) n7 ++;
    if (c == 5) n5 ++;
    if (c == 7) n7 ++;
    if (n5 == 2 && n7 == 1) {
        cout << "YES";
    }
    else {
        cout << "NO";
    }
    return 0;
}

Measured memory_bytes: 3580
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<set>
#include<string>
#include<iomanip>
#include<math.h>
#include<bitset>
#include<functional>
#include<map>
using namespace std;
typedef long long ll;
#define lscan(x) scanf("%I64d",&x);
#define lprint(x) printf("%I64d",x);
ll gcd(ll a, ll b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
long long extGCD(long long a, long long b, long long &x, long long &y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a%b, y, x);
	y -= a / b * x;
	return d;
}
struct UnionFind {
	vector<int> par;

	UnionFind(int N) : par(N) {
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) {
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		if (rx == ry) return;
		par[rx] = ry;
	}

	bool same(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

ll M = 1000000007;

vector<ll> fac(1000001); //n!(mod M)
vector<ll> ifac(1000001); //k!^{M-2} (mod M)

ll mpow(ll x, ll n) {
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}
ll mpow2(ll x, ll n, ll mod) {
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % mod;
		x = x * x % mod;
		n = n >> 1;
	}
	return ans;
}
void setcomb() {
	fac[0] = 1;
	ifac[0] = 1;
	for (ll i = 0; i < 1000000; i++) {
		fac[i + 1] = fac[i] * (i + 1) % M; // n!(mod M)
	}
	ifac[1000000] = mpow(fac[1000000], M - 2);
	for (ll i = 1000000; i > 0; i--) {
		ifac[i - 1] = ifac[i] * i%M;
	}
}
ll comb(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}
ll perm(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	return fac[a] * ifac[a - b] % M;
}
long long modinv(long long a) {
	long long b = M, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= M;
	if (u < 0) u += M;
	return u;
}

vector<vector<ll>> li(222222);
int main() {
	ll n,k,r,s,p, i, j, m,dp[111111][3];
	char t[111111];
	cin >> n>>k>>r>>s>>p>>t;
	for (i = 0; i < k; i++) {
		for (j = 0; j < 3; j++) {
			if (j == 0 && t[i] == 's')
				dp[i][j] = r;
			else if (j == 1 && t[i] == 'p')
				dp[i][j] = s;
			else if (j == 2 && t[i] == 'r')
				dp[i][j] = p;
			else
				dp[i][j] = 0;
		}
	}
	for (; i < n; i++) {
		for (j = 0; j < 3; j++) {
			dp[i][j] = 0;
			for (m = 0; m < 3; m++) {
				if (j != m) {
					if (j == 0 && t[i] == 's')
						dp[i][j] = max(dp[i][j],dp[i-k][m]+r);
					else if (j == 1 && t[i] == 'p')
						dp[i][j] = max(dp[i][j], dp[i - k][m] + s);
					else if (j == 2 && t[i] == 'r')
						dp[i][j] = max(dp[i][j], dp[i - k][m] + p);
					else
						dp[i][j] = max(dp[i][j], dp[i - k][m]);
				}
			}
		}
	}
	ll ans = 0;
	for (i = 0; i < k; i++)
		ans += max(max(dp[n - 1 - i][0], dp[n - 1 - i][1]), dp[n - 1 - i][2]);
	cout << ans << endl;
}


Measured memory_bytes: 23808
#include<bits/stdc++.h>
#define ll long long
#define dbg1(x) cerr<<#x<<"="<<(x)<<" "
#define dbg2(x) cerr<<#x<<"="<<(x)<<"\n"
#define dbg3(x) cerr<<#x<<"\n"
using namespace std;
#define reg register
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
	return x*f;
}
int a[200005];
ll ans;
int main()
{
	int N=read();
	reg int i;
	for(i=1;i<=N;++i) a[i]=read()-i;
	std::sort(a+1,a+N+1);
	int mid=(N+1)/2;
	for(i=1;i<=N;++i) ans+=abs(a[i]-a[mid]);
	return 0*printf("%lld\n",ans);
}

Measured memory_bytes: 1024
X = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    save = -1
    for i in range(len(divisors)):
        if divisors[i] >= 130:
            save = i
            break
    if save > 0:
        divisors = divisors[:save]
    return divisors

def f(a, b):
  return a**5 - b**5

divs = make_divisors(X)
ans = 0
for div in divs:
  a = -120
  b = -120+div
  while f(a, b) < X and a < 2:
    a += 1
    b += 1
  if f(a, b) == X:
    ans = (a, b)
  a = -120+div
  b = -120
  while f(a, b) > X and b < 2:
    a += 1
    b += 1
  if f(a, b) == X:
    ans = (a, b)
    
print(ans[0], ans[1])


Measured memory_bytes: 9392
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
  	cin.tie(NULL);
  	int a,b;
  	cin>>a>>b;
  	if(b<a)
    {
    	cout<<"No";
    }
    else 
    {
		cout<<"Yes";
    }
}

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

using namespace std;

int main() { 
  double a, b, c;
  scanf("%lf %lf %lf", &a, &b, &c);
  c = c / 180.0 * M_PI;
  printf("%f\n%f\n%f\n", 
    a * b * sin(c) / 2.0,
    a + b + sqrt(pow(a * sin(c), 2) + pow(b - a * cos(c), 2)),
    b * sin(c)
  );
  return 0;
}



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

typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    ll K;
    cin >> N >> K;
    vector<ll> A(N);
    for (ll i=0;i<N;i++) {
        cin >> A[i];
        A[i]--;
    }
    vector<ll> stop(N,-1);
    vector<ll> loop(2*N);
    ll last = 0;
    stop[0] = 0;
    loop[0] = 0;
    ll loopstart, loopend;
    for (ll i=0;i<=2*N;i++) {
        loop[i+1] = A[loop[i]];
        if (stop[A[last]] == -1){
            stop[A[last]] = i+1;
            last = A[last];
        } else {
            loopstart = stop[A[last]];
            loopend = i+1;
            break;
        }
    }

    if (loopstart >= K) {
        cout << loop[K] + 1 << "\n";
        return 0;
    }

    K -= loopstart;
    ll res = K % (loopend - loopstart);
    ll ans = loop[loopstart + res]+1; 

    cout << ans << "\n";
}


Measured memory_bytes: 9536
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <random>
#include <set>
#include <stack>

//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater<int>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#include <time.h>
typedef std::pair<int,int> pii;
typedef std::vector<int> vi;
typedef std::vector<pii> vii;
using namespace std;
using ll = long long;
#define PI 3.14159265358979323846264338327950L
const int mod = 1000000007;




void solve(){
    int n;
    string s;
    cin >> n >> s;
    
    map<int,int> c;
    for(auto e:s){
        c[e-'a']++;
    }
    ll ans = 1;
    for(auto e:c){
        ans *= (e.second+1);
        ans %= mod;
    }
    
    cout << ans-1;
    
}

int main(){
    int T;
    T = 1;
    while(T--){
        solve();
        cout << endl;
    }
}






Measured memory_bytes: 3704
#include <iostream>
#include <cstdio>
using namespace std;


int st[500005];
int a[100005];
int n,m;


void update(int id,int l,int r,int i,int v)
{
    if (i<l || r<i) return;
    if (l==r)
    {
        st[id]=v;
        return;
    }
    int mid=(l+r)>>1;
    update(id*2,l,mid,i,v);
    update(id*2+1,mid+1,r,i,v);
    st[id]=max(st[id*2],st[id*2+1]);
}

int get(int id,int l,int r)//return id of thing
{
    if (l==r) return l;
    int mid=(l+r)>>1;
    if (st[id*2]==st[id]) return get(id*2,l,mid);
    else return get(id*2+1,mid+1,r);
}


int main()
{
    //freopen("file.inp","r",stdin);
    //freopen("file.out","w",stdout);
    cin>>n>>m;
    for (int i=1;i<=n;i++)
    {
        cin>>a[i];
        update(1,1,n,i,a[i]);
    }
    while (m--)
    {
        int x=get(1,1,n);
        a[x]=a[x]>>1;
        update(1,1,n,x,a[x]);
    }
    long long ans=0;
    for (int i=1;i<=n;i++) ans+=(long long)a[i];
    cout<<ans;
    return 0;
}


Measured memory_bytes: 1664
#!/usr/bin/env python

from collections import deque, defaultdict
import itertools as ite
import sys
import math
import decimal

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

L_, R_ = map(int, raw_input().split())

ans = 0
for MSB in range(70):
    S = 2 ** MSB
    if S * 2 <= L_ or R_ < S:
        continue
    L, R = L_, R_
    if L <= S:
        L = S
    if 2 * S - 1 <= R:
        R = 2 * S - 1
    n1 = nL = nR = 0
    nLR = 1
    SL = SR = 1
    for i in range(MSB)[::-1]:
        flag1 = ((1 << i) & L != 0)
        flag2 = ((1 << i) & R != 0)
        SL *= 2
        SR *= 2
        SL += flag1
        SR += flag2
        n1 *= 3
        if flag1 and not flag2:
            nLR = 0
        if SR - SL >= 2:
            n1 += SR / 2 - SL / 2 - 1
            if not flag1:
                n1 += nL
            if flag2:
                n1 += nR
            if not flag1:
                nL *= 2
                nL += 1
            if flag2:
                nR *= 2
                nR += 1
            if not flag1 and flag2:
                nL += nLR
                nR += nLR
    if L == R:
        ans += 1
    else:
        ans += n1 + (SR - SL + 1) + nL + nR + nLR
print ans % MOD


Measured memory_bytes: 4780
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  string S;
  cin >> S;
  int N = S.size();
  vector<int> ans(N);
  rep(i, N-1) {
    if(S[i] == 'R' && S[i+1] == 'L') {
      int tmp = i-1;
      ans[i]++;
      ans[i+1]++;
      while(tmp >= 0 && S[tmp] == 'R') {
        if((i - tmp) % 2 == 0)
          ans[i]++;
        else
          ans[i+1]++;
        tmp--;
      }
      tmp = i+2;
      while(tmp < N && S[tmp] == 'L') {
        if((tmp - i) % 2 == 0)
          ans[i]++;
        else
          ans[i+1]++;
        tmp++;
      }
    }
  }
  rep(i, N)
    cout << ans[i] << ' ';
  cout << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
    #include <string>
    #include <algorithm>
    #include <map>
    #include <set>
    #include <vector>
    #include <queue>
    #include <cmath>
     
    using namespace std;
    typedef long long  ll;
    #define rep(i,s,n)for(ll i = s;i<n;i++)
     
    int main() {
    	int N; cin >> N;
    	char S[100][1];
    	rep(i, 0, N) {
    		cin >> S[i];
    		if (S[i][0] == 'Y') {
    			cout << "Four" << endl;;
    			return 0;
    		}
    	}
    	cout << "Three" << endl;;
     
    	return 0;
    }

Measured memory_bytes: 256