akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.lang.Math.*;

public class Main {
    BufferedReader rd;

    Main() throws IOException {
        rd = new BufferedReader(new InputStreamReader(System.in));
        compute();
    }

    private void compute() throws IOException {
        int n = pint();
        int k = pint();
        int s = 1<<n;
        int mi = Integer.MAX_VALUE;
        for(int i=0;i<s;i++) {
            int v = 1;
            for(int j=0;j<n;j++) {
                if((i&(1<<j)) > 0) {
                    v *= 2;
                } else {
                    v += k;
                }
            }
            mi = min(mi, v);
        }
        out(mi);
    }

    private int pint() throws IOException {
        return pint(rd.readLine());
    }

    private int pint(String s) {
        return Integer.parseInt(s);
    }

    private static void out(Object x) {
        System.out.println(x);
    }

    public static void main(String[] args) throws IOException {
        new Main();
    }
}


Measured memory_bytes: 22996
#include <iostream>
#include <string>
#include <vector>
#include<algorithm>
#include <stdio.h>
#include <bitset>
#include<math.h>
using namespace std;
typedef long long ll;

int main(){
	int a, b,ans=0,k=1;
	cin >> a >> b;
	while (k<b)
	{
		k--;
		ans++;
		k += a;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#include <time.h>
#define F(i,a,b) for(long long i=a;i<=(b);++i)
#define dF(i,a,b) for(long long i=a;i>=(b);--i)
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define pb push_back
#define maxnkp make_pair
#define fi first
#define se second
#define eps 1e-10
using namespace std;
typedef long long ll;
const int mods = 1e9+7;
const int maxn = 1e5+10;
const int N = 1e5+10;
const int E = 2e5+10;  
ll n,m,k;
string s;
int main(){
	cin>>s;
	if(s[1]=='R'){
		cout<<"ABC"<<endl;
	}
	else cout<<"ARC"<<endl;
}


Measured memory_bytes: 3592
<?php

//-------------------------------------------------------
//クラス準備
//-------------------------------------------------------

//標準入力の取得
class Scanner{
    //一文字だけ取得
    public function getChar() {
        $input = trim(fgets(STDIN));
        $input = str_replace(array("\r\n","\r","\n"), '', $input);
        return $input;
    }
    //配列で取得
    public function getArray() {
        $input = trim(fgets(STDIN));
        $input = str_replace(array("\r\n","\r","\n"), '', $input);
        $input = explode(" ", $input);
        return $input;
    }
}

$sc = new Scanner;

//-------------------------------------------------------
//問題コード
//-------------------------------------------------------

$a = $sc->getChar();
$b = $sc->getChar();
$c = $sc->getChar();

$ac = ($a+$b)*$c/2;

echo $ac.PHP_EOL;

?>

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

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

    std::string s;
    std::cin >> s;

    int sum = 0;
    for (char c : s) sum += (c - '0');

    std::cout << ((sum % 9) ? "No" : "Yes");

    return 0;
}



Measured memory_bytes: 3736
li = lambda: list(map(int,input().split()))

n = int(input())
a = li()

aa = [(i+1,a[i]) for i in range(n)]
aa.sort(key=lambda x: x[1])
a = [aaa[0] for aaa in aa]
ans = ''
for aa in a:
    ans += str(aa)
    ans += ' '
print(ans[:-1])

Measured memory_bytes: 19196
import java.util.*;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int a[] = new int[N];
    int color[] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
    
    for(int i=0; i<N; i++){
      a[i]=sc.nextInt();
      if (1 <= a[i] && a[i] <= 399) {
        color[0]++;
      } else if (400 <= a[i] && a[i] <= 799) {
        color[1]++;
      } else if (800 <= a[i] && a[i] <= 1199) {
        color[2]++;
      } else if (1200 <= a[i] && a[i] <= 1599) {
        color[3]++;
      } else if (1600 <= a[i] && a[i] <= 1999) {
        color[4]++;
      } else if (2000 <= a[i] && a[i] <= 2399) {
        color[5]++;
      } else if (2400 <= a[i] && a[i] <= 2799) {
        color[6]++;
      } else if (2800 <= a[i] && a[i] <= 3199) {
        color[7]++;
      } else if (3199 <= a[i]) {
        color[8]++;
      }
    }
    int min = 0;
    int max = 0;
    for(int i = 0; i<8; i++){
      if(color[i]!=0){
        min++;
      }
    }
    if(min == 0){
      min = 1;
      max = color[8];
    }else{
      max = min + color[8];
    }
    System.out.println(min+ " " + max);
  }
}
      

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

int main()
{
  int n;
  cin >> n;
  
  int b[n-1];
  rep(i,n-1) cin >> b[i];
  
  int ans = b[0];
  for(int i = 1; i < n-1; i++)
  {
    ans += min(b[i],b[i-1]);
  }
  ans += b[n-2];
  
  cout << ans << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll h,w,black,ans=0,k;
    cin>>h>>w>>k;
    char str[h+5][w+5];
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            cin>>str[i][j];
        }
    
    }
    for(int i=0;i<(1<<h);i++)
    {
        for(int j=0;j<(1<<w);j++)
        {
            black=0;
            for(int k=0;k<h;k++)
            {
                for(int l=0;l<w;l++)
                {
                    if(((1&(i>>k))==0)&&((1&(j>>l))==0)&&str[k][l]=='#')
                    {
                        black++;
                    }
                }
            }
            if(black==k)
            {
                ans++;
            }
        }
    }
    cout<<ans;
    return 0;  
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef pair<double, double> pdd;

const double EPS = 1e-10;

const double INF = DBL_MAX / 2.0;

bool equals(double a, double b){
	return abs(a-b) < EPS;
}

bool sameline(pdd p0, pdd p1, pdd p2){
	if(p0.first == p1.first && p0.first == p2.first) return true;
	if(p0.second == p1.second && p0.second == p2.second) return true;

	return equals((p1.se - p0.se) / (p1.fi - p0.fi), (p2.se - p0.se) / (p2.fi - p0.fi));
}

double dist(pdd p0, pdd p1){
	return sqrt((p0.fi - p1.fi) * (p0.fi - p1.fi) + (p0.se - p1.se) * (p0.se - p1.se));
}

pdd calc_center(pdd p0, pdd p1, pdd p2){
	double x1 = p0.fi, y1 = p0.se;
	double x2 = p1.fi, y2 = p1.se;
	double x3 = p2.fi, y3 = p2.se;

	double a = x1 - x2;
    double b = y1 - y2;
    double c = x2 - x3;
    double d = y2 - y3;
    double q = 2*(a*d - b*c);
    if(abs(q) < EPS) return {};
    double D1 = x1*x1 + y1*y1;
    double D2 = x2*x2 + y2*y2;
    double D3 = x3*x3 + y3*y3;
    double v1 = D1 - D2;
    double v2 = D2 - D3;
    double cx = (d*v1 - b*v2)/q;
    double cy = (-c*v1 + a*v2)/q;
    return {cx, cy};
}

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

	int n;
	cin >> n;

	vector<pdd> v(n);
	rep(i, n){
		double x, y;
		cin >> x >> y;
		v[i] = {x, y};
	}

	if(n == 2){
		cout << dist(v[0], v[1]) / 2 << endl;
		return 0;
	}

	double ans = INF;
	for(int i0 = 0; i0 < n; i0++){
		for(int i1 = i0 + 1; i1 < n; i1++){
			for(int i2 = i1 + 1; i2 < n; i2++){
				pdd p0 = v[i0], p1 = v[i1], p2 = v[i2];

				pdd pc = calc_center(p0, p1, p2);
				if(pc.fi == INF) continue;
				double r = dist(p0, pc);

				bool ok = true;
				rep(i, n){
					if(dist(v[i], pc) - EPS> r) ok = false;
				} 
				if(ok) ans = min(ans, r);
				
			}
		}
	}

	for(int i0 = 0; i0 < n; i0++){
		for(int i1 = i0 + 1; i1 < n; i1++){
			pdd p0 = v[i0], p1 = v[i1];

			pdd pc = (pdd){(p0.fi + p1.fi) / 2.0, (p0.se + p1.se) / 2.0};
			double r = dist(p0, pc);

			bool ok = true;
			rep(i, n){
				if(dist(v[i], pc) - EPS > r) ok = false;
			} 
			if(ok) ans = min(ans, r);
				
		}
	}
	
	cout << fixed << setprecision(10);
	cout << ans << endl;
}


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

#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

using namespace std;

typedef long long ll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "[ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "]";

    return os;
}

ll pow_mod(ll a, ll p) {
    ll res = 1;
    while(p) {
        if (p & 1) res = (res * a) % MOD;
        a = (a * a) % MOD;
        p >>= 1;
    }

    return res;
}


ll mod_inv(ll a, ll m) {
    ll b = m, u = 0, v = 1;
    while(a) {
        ll t = b / a;
        swap(b -= t * a, a);
        swap(u -= t * v, v);
    }

    return (u % m + m) % m;
}

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


int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    int N, M;
    cin >> N >> M;

    ll x[N], y[N], z[N];
    REP(i, N) {
        cin >> x[i] >> y[i] >> z[i];
    }

    ll ans = -INF;
    REP(i, 1 << 3) {
        vector<ll> t(N);
        REP(j, N) {
            t[j] = i & 1 ? x[j] : -x[j];
            t[j] += (i >> 1) & 1 ? y[j] : -y[j];
            t[j] += (i >> 2) & 1 ? z[j] : -z[j];

        }

        sort(t.begin(), t.end(), greater<ll>());

        ll a = 0;
        REP(i, M) a += t[i];

        ans = max(ans, a);
    }

    cout << fixed << setprecision(20);
    cout << ans << endl;

}


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

int main(void)
{
  int n;
  std::string s;
  std::cin >> n >> s;
  int r = std::count(s.begin(), s.end(), 'R');
  int b = std::count(s.begin(), s.end(), 'B');
  std::cout << (r > b ? "Yes" : "No") << std::endl; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int n, m, x;
    cin >> n >> m >> x;
    vec a(m);
    rep(i, m) cin >> a[i];
    set<int> s;
    rep(i, m) s.insert(a[i]);

    int res = INF;

    int cur = x;
    int tmp = 0;

    while (cur > 0) {
        if (s.find(cur) != s.end()) tmp++;
        cur--;
    }
    res = tmp;

    cur = x;
    tmp = 0;

    while (cur < n) {
        if (s.find(cur) != s.end()) tmp++;
        cur++;
    }
    res = min(res, tmp);

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

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    // 入力を取得
    String c = sc.next();

    if(c.equals("A")){
      System.out.println("T");
    }else if(c.equals("T")){
      System.out.println("A");
    }else if(c.equals("G")){
      System.out.println("C");
    }else if(c.equals("C")){
      System.out.println("G");
    }

    // 出力
  }
}


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

using namespace std;

int N, Q;
string S;
int cnt[100010];

int main() {
    cin >> N >> Q;
    cin >> S;

    for(int i=1; i<N; i++) {
        cnt[i+1] = (S.substr(i-1, 2) == "AC")? cnt[i]+1 : cnt[i];
    }

    for(int i=0; i<Q; i++) {
        int l, r;
        cin >> l >> r;
        cout << cnt[r] - cnt[l] << endl;
    }
}


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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

int main(void) {
    llint x;
    cin >> x;

    llint ans, p1, p2;
    p1 = x / 11LL;
    p2 = x - 11 * p1;
    ans = 2 * p1;

    if(p2==0) ;
    else if(p2<=6) ans++;
    else ans += 2;

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


Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <iterator>
#include <typeinfo>
using namespace std;


// define list


namespace  math{
    const double PI = 3.14;
    const int INF = 1000000007;
    int GCM(int a,int b); //最大公約数
    int LCM(int a,int b); //最小公倍数
    int Pemu(int n,int r); //順列
    int Comb(int n,int m); //組み合わせ
    
    int GCM(int a,int b){
        if(a<b){
            swap(a,b);
        }
        int r = a%b;
        while (r!=0)
        {
            a=b;
            b=r;
            r=a%b;
        }
        return b;
    }

    int LCM(int a,int b){
        return a*(b/GCM(a,b));
    }

    int Pemu(int n,int r){
        int ans = n;
        for(int i=1;i<r;i++){
            ans*=(ans-i);
        }
        return ans;
    }

    int Comb(int n,int m){
        int a=n,b=m;
        for(int i=1;i<m;i++){
            a *= (a-i);
        }
        for(int i=1;i<m;i++){
            b *= (b-i);
        }
        
        return a/b;
    }
}

namespace SubLib{
    #define int long long
    #define double long double
    #define incin(n) int (n); cin >> (n);
    #define incin2(a,b) int a,b; cin >> a >> b; 
    #define rap(n,i) for(int (i) = 0;i<(n);(i)++)
    #define input(n,v) (v) = SubLib::Input((n),(v))
    #define all(v) (v).begin(),(v).end()
    using intv = vector<int>;
    using strv = vector<string>;
    using charv = vector<char>;
    template <class T1>
    using pvec = vector<pair<T1,T1>>;
    template <typename T> vector<T> Input(int n,vector<T> v){
        for(int i=0;i<n;i++){
            cin >> v.at(i);
        }
        return v;
    }
}

using namespace math;
using namespace SubLib;

signed main(){
    string s,t;
    cin >> s >> t;
    sort(all(s));
    sort(all(t),[](const char &a, const char &b){
        return a > b;
    });
    if(s<t){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

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

string mp[2222];
int gor[2222][2222];

int main(){
    int n,m; cin>>n>>m;
    for(int i=0;i<n;++i)cin>>mp[i];
    for(int i=1;i<n;++i){
        for(int j=m-1;j>=0;--j){
            gor[i][j]=1;
            if(j==m-1)continue;
            if((mp[i][j]==mp[i][j+1] && mp[i-1][j]==mp[i-1][j+1]) || (mp[i][j]!=mp[i][j+1] && mp[i-1][j]!=mp[i-1][j+1]))gor[i][j]=gor[i][j+1]+1;
        }
    }
    int area=0;
    for(int j=m-1;j>=0;--j){
        stack<int> iidx;
        iidx.push(0);
        for(int i=1;i<=n;++i){
            // if(j==4)cout<<"gor of "<<i<<" is "<<gor[i][j]<<endl;
            while(iidx.size() && gor[iidx.top()][j]>gor[i][j]){
                int top_gor=gor[iidx.top()][j];
                iidx.pop();
                area=max(area,top_gor*(i-iidx.top()));
                // if(j==4)cout<<"new area "<<top_gor*(i-iidx.top())<<" at "<<i<<endl;
            }
            iidx.push(i);
        }
    }
    cout<<max(area,max(n,m))<<endl;
}


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

int main() {
    int n;
    cin >> n;

    int count = 0;
    for(int i = 1; i <= n; i++) {
        string tmp = to_string(i);
        if (tmp.size() % 2)
            count++;
    }

    cout << count << '\n';
    return 0;
}

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

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

    ll N;
    cin >> N;

    ll ans = N;
    for (ll n = 1; n <= sqrt(N); n++) {
        if (N % n == 0) {
            ans = N / n;
        }
    }

    cout << ((int)log10(ans) + 1) << endl;

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<string> ves;
typedef vector<vector<int>> ve_vei;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define fs first
#define sc second
#define all(a) a.begin(),a.end()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
 
int main() {
	//cout.precision(10);
	cin.tie(0);
	ios::sync_with_stdio(false);

    int N,K; cin >> N >> K;
    vei x(N);
    int sum = 0;
    rep(i,N){
        cin >> x[i];
        sum += min(2*x[i], 2*(K - x[i]));
    }
    cout << sum << endl;
    return 0;
}

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

#include <algorithm>

using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;
const ll INF = 1ll << 60;

ll MOD = 1e9 + 7;

int main()
{

    int a, b;
    cin >> a;
    cin >> b;

    int ans = 0;
    int outlet = 1;
    while (b > outlet)
    {
        --outlet;
        outlet += a;
        ans++;
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
  int sum = 0;
  vector<vector<int>> c(3, vector<int>(3));
  rep(i,3) rep(j,3) cin >> c[i][j];

  rep(i, c[0][0]+1) {
    vector<int> a(3), b(3);
    a[0] = i;
    b[0] = c[0][0] - i;
    rep(j, c[1][1]+1) {
      a[1] = j;
      b[1] = c[1][1] - j;
      rep(k, c[2][2]+1) {
        a[2] = k;
        b[2] = c[2][2] - k;
        int cnt = 0;
        rep(l,3) {
          rep(m,3) {
            if (a[l] + b[m] != c[l][m]) break;
            else cnt++;
          }
        }
        if (cnt == 9) {
          cout << "Yes" << endl;
          return 0;
        }
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3500
package main

import (
	"fmt"
	"sort"
)

type ShopScore struct {
	ID    int
	Name  string
	Score int
}

type ShopScores []ShopScore

func (s ShopScores) Len() int {
	return len(s)
}

func (s ShopScores) Less(i, j int) bool {
	if s[i].Name != s[j].Name {
		return s[i].Name < s[j].Name
	}

	return s[i].Score > s[j].Score
}

func (s ShopScores) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}

func main() {

	var n int
	fmt.Scan(&n)

	var shops = ShopScores{}
	for i := 0; i < n; i++ {
		var name string
		var score int
		fmt.Scan(&name, &score)

		var shop = ShopScore{
			ID:    i + 1,
			Name:  name,
			Score: score,
		}
		shops = append(shops, shop)
	}

	sort.Sort(shops)

	for _, shop := range shops {
		fmt.Println(shop.ID)
	}
}


Measured memory_bytes: 512
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<cstring>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<ctime>
#include<cmath>
#include<cstdlib>
#include<utility>
#include<bitset>
using namespace std;
string s;
int main()
{
	cin>>s;
	for(int i=0;i<8;i++)
	{
		int sum=(int)(s[0]-'0');
		for(int j=0;j<3;j++)
		{
			if(i&(1<<j))
			{
				sum+=(int)(s[j+1]-'0');
			}
			else
			{
				sum-=(int)(s[j+1]-'0');
			}
		}
		if(sum==7)
		{
			cout<<s[0];
			for(int j=0;j<3;j++)
			{
				if(i&(1<<j))
				{
					cout<<"+";
				}
				else
				{
					cout<<"-";
				}
				cout<<s[j+1];
			}
			cout<<"=7"<<endl;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 256
//https://atcoder.jp/contests/abc113/tasks/abc113_c
//C - ID
//vector<vector<ll>> info[Pi][index] 各県について年の昇順インデックス(各項ソート)
//vector<vector<ll>> inforev[Pi][] =
//あたまがおいつかない
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int N, M;
vector<int> P, Y;
vector<vector<int>> info(100010);

int main() {
    cin >> N >> M;
    P.resize(M); Y.resize(M);
    for (int i = 0; i < M; i++) scanf("%d%d", &P[i], &Y[i]), info[P[i]].push_back(Y[i]);
    for (int i = 0; i < N; i++) sort(info[i+1].begin(), info[i+1].end());
    for (int i = 0; i < M; i++) printf("%012Ld\n", ll(P[i])*1000000 + int(lower_bound(info[P[i]].begin(), info[P[i]].end(), Y[i]) - info[P[i]].begin())+1);
    // ↑ 下６けた info[P[i]](配列)がY[i]以上になる最小のイテレータを取得してindexに変換したのち＋１

}

Measured memory_bytes: 7808
N, K = map(int,input().split())
total = 0
num = 1
for i in range(K+1,N+1):
    total += N//i*num
    num += 1
    if K == 0:
        total += max(N%i-K,0)
    else:        
        total += max(N%i-K+1,0)

print(total)

Measured memory_bytes: 64512
#include<bits/stdc++.h>
using namespace std;
int N, M, Q;
vector<int>a;
vector<int>b;
vector<int>c;
vector<int>d;
vector<int>sta;
int search(int si, int la) {
  if (si == N) {
    int ret = 0;
    for (int i = 0; i < Q; i ++) {
      if (sta[b[i] - 1] - sta[a[i] - 1] == c[i]) ret += d[i];
    }
    return ret;
  }
  int ret = -1;
  for (int i = la; i <= M; i ++) {
    sta[si] = i;
    si ++;
    ret = max(ret, search(si, i));
    si --;
  }
  return ret;
}
int main () {
  cin >> N >> M >> Q;
  a.resize(Q);
  b.resize(Q);
  c.resize(Q);
  d.resize(Q);
  sta.resize(100);
  for (int i = 0; i < Q; i ++) cin >> a[i] >> b[i] >> c[i] >> d[i];
  int ans = 0;
  for (int i = 1; i <= M; i ++) {
    sta[0] = i;
    ans = max(ans, search(1, i));
  }
  cout << ans << endl;
}
      


Measured memory_bytes: 3584
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<set>
using namespace std;
typedef long long ll;

int a[105];

ll count(int x, int p) {
	return (x - p) * (x - p);
}

int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i];
	ll minxx = 1000000000, ans = 0;

	for (int i = 1; i <= 100; i++) {
		for (int j = 1; j <= n; j++) { ans += count(a[j], i); }
		minxx = min(minxx, ans);
		ans = 0;

	}

	cout << minxx;





	return 0;
}

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

int main()
{
    int n; 
    cin >> n;
    int c[10][10];
    for(int i=0; i<10; i++){
        for(int j=0; j<10; j++) c[i][j] = 0;
    }


    for(int i=1; i<=n; i++){
        int a = i;
        while(1){
            if(a/10 == 0) break;
            a /= 10;
        }
        c[a][i%10]++;
    }

    int ans = 0;

    for(int i=1; i<10; i++){
        for(int j=1; j<10; j++){
            ans += c[i][j]*c[j][i];
        }
    }

    cout << ans << endl;
}

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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

int main(void)
{
    const int N_MAX = 200000;
    int N;
    int A[N_MAX];
    cin >> N;
    REP(i, N) {
        cin >> A[i];
        A[i] -= (i + 1);
    }
    sort(A, A + N);
    ll result = 0;
    REP(i, N) {
        result += abs(A[i] - A[N / 2]);
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 1024
def resolve():
    N, x = list(map(int, input().split()))
    a = list(map(int, input().split()))
    dist = []

    ans = 0
    a.sort()

    for i, con in enumerate(a):
        if i == len(a)-1:
            dist.append(x - sum(dist))

        if sum(dist) + con <= x:
            dist.append(con)
        else:
            dist.append(0)

    for i in range(len(a)):
        if a[i] == dist[i]:
            ans += 1
    print(ans)
    return
resolve()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;

int main(){
  int n;
  cin >> n;

  vector<int> d(n, 0);
  for(int i = 0; i < n; i++){
    cin >> d[i];
  }

  sort(d.begin(), d.end(), greater<int>());

  int ans = 1;
  for(int i = 0; i < n-1; i++){
    if(d[i] == d[i+1]) continue;
    ans++;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>

using namespace std;

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

ll mod = 998244353;
ll powmod(ll a, ll b) {
	a %= mod;
	ll res = 1;
	while (b > 0) {
		if (b % 2 == 1)res = res * a % mod;
		a = a * a % mod;
		b /= 2;
	}
	return res;
}
ll n, dp[310][91000], dp2[310][91000], s[310],ans = 0, sum;
int main() {
	cin >> n;
	dp[0][0] = 1;
	REP(i, n) {
		cin >> s[i];
		sum += s[i];
	}
	ll ss = sum;
	sum = (sum + 1) / 2;
	REP(i, n) {
		REP(j, 90000) {
			dp[i + 1][j + s[i]] += dp[i][j];
			dp[i + 1][j + s[i]] %= mod;
			dp[i + 1][j] += dp[i][j] * 2;
			dp[i + 1][j] %= mod;
		}
	}
	if (ss % 2 == 0) {
		dp2[0][0] = 1;
		REP(i, n) {
			REP(j, 90000) {
				dp2[i + 1][j + s[i]] += dp2[i][j];
				dp2[i + 1][j + s[i]] %= mod;
				dp2[i + 1][j] += dp2[i][j];
				dp2[i + 1][j] %= mod;
			}
		}
	}
	FOR(i, sum, 90010) {
		ans += 3 * dp[n][i];
		ans %= mod;
	}
	cout << (powmod(3, n) - ans + dp2[n][sum] * 3 + mod * 3) % mod << endl;

}




Measured memory_bytes: 431744
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
typedef pair<int,int> P;
typedef vector<int> vi;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

ll gcd(ll a , ll b){
	if(b == 0) return a;
	return gcd(b , a % b);	
}
ll lcm(ll a , ll b){
	ll g = gcd(a , b);
	ll lc = (a/g) * b;
	return lc;
}

int main(){
    ios::sync_with_stdio(false);
    string s; cin >> s;
    int a=0,b=0;
    int n=s.size();
    if(n%2==0){
        for(int i=0;i<=(n-2)/2;i++){
            if(s[2*i]!='1') a++;
            else b++;
        }
        for(int i=0;i<=(n-2)/2;i++){
            if(s[2*i+1]!='0') a++;
            else b++;
        }
    } else{
        for(int i=0;i<=(n-1)/2;i++){
            if(s[2*i]!='1'){
                a++;
            }
            else{
                b++;
            }
        }
        for(int i=1;i<=(n-1)/2;i++){
            if(s[2*i-1]!='0'){
                a++;
            }
            else{
                b++;
            }
        }
    }
    cout << min(a,b) << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <map>
using namespace std;

int N, M, X;
int C[13];
int A[13][13];
int minC;

void calc(int nowN, vector<int> nowM, int nowC )
{
	if(nowN == N){
		for (int i = 0; i < M; i++)
		{
			if(nowM[i] < X){
				return;
			} 
		}

		if(nowC < minC){
			minC = nowC;
		}
		
		return;
	}else{
		vector<int> nextM = vector<int>(nowM);
		calc(nowN +1, nextM, nowC);

		for (int i = 0; i < M; i++)
		{
			nextM[i] += A[nowN][i];
		}
		calc(nowN +1, nextM, (nowC + C[nowN]));
	}
}

int main()
{
	cin >> N >> M >> X;

	int max[13] = {0};
	int maxC = 0;

	for (int i = 0; i < N; i++)
	{
		cin >> C[i];
		maxC += C[i];

		for (int j = 0; j < M; j++)
		{
			cin >>A[i][j]; 
			max[j] += A[i][j];
		}
	}
	
	// all max[] is over X?
	bool checkX = true;
	for (int i = 0; i < M; i++)
	{
		if(max[i] < X){
			checkX = false;
			break;
		}
	}
	
	if(!checkX){
		minC = -1;
	}else{
		minC = maxC;
		vector<int> tmpV;
		for (int i = 0; i < M; i++)
		{
			tmpV.push_back(0);
		}
		
		calc(0, tmpV, 0);
	}


	cout << minC << endl;
	return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
template<class T, class Compare = less<T> >
using MaxHeap = priority_queue<T, vector<T>, Compare>;
template<class T, class Compare = greater<T> >
using MinHeap = priority_queue<T, vector<T>, Compare>;
using llong = long long;


int main() {

    llong n;
    cin >> n;
    cout << n * n * n << endl;

    return 0;
}


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

int n, m, s1, s2;
char a[1005][1005];
void f(int p, int q) {
	if (a[p][q] == '.' && a[p + 1][q] == '.') {
		a[p][q]='^';
		a[p + 1][q] = 'v';
		s2--;
	}
}

void g(int p, int q) {
	if (a[p][q] == '.' && a[p][q + 1] == '.') {
		a[p][q]='<';
		a[p][q + 1] = '>';
		s1--;
	}
}
int main()
{
	int i, j;
	cin >> n >> m >> s1 >> s2;
	for (i= 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			a[i][j] = '.';
		}
	}
	if (m % 2 ==1) {
//		for (i = 0; i + 1 < n; i += 2) f(i, m - 1);
		for (i = 0; i + 1 < n && s2; i += 2) f(i, m - 1);
		if (s2 > 0 && m >= 3 && n >= 3 && s2 % 2 == 1) f(n - 2, m - 3);
	}
	for (i = 0; i + 1 < n; i++) {
		for (j = 0; j < m; j++) {
			if (s2 == 0) break;
			f(i, j);
		}
		if (s2 == 0) break;
	}
	for (i =0; i < n; i++) {
		for (j = 0; j + 1 < m; j++) {
			if(s1 == 0) break;
			g(i, j);
		}
		if (s1 == 0) break;
	}
	if (s1 == 0 && s2 == 0) {
		cout << "YES" << endl;
		for (i = 0; i < n; i++) {
			printf("%s\n",a[i]);
		}
	} else {
		cout << "NO" << endl;
	}
    return 0;
}


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

using namespace std;

const int mod = 1e9 + 7;

int main(){
  int N;
  string S;
  cin >> N >> S;
  
  long long p = 1;
  
  string T;
  T.resize(2 * N);
  T[0] = 'L';
  for(int i = 1; i < 2 * N; i++){
    if(S[i - 1] == S[i]){
      if(T[i - 1] == 'L') T[i] = 'R';
      else T[i] = 'L';
    }else{
      T[i] = T[i - 1];
    }
  }
  
  for(int i = 1; i <= N; i++){
    p *= i;
    p %= mod;
  }
  
  if(S[0] == 'W' || S[2 * N - 1] == 'W') p = 0;
  
  int num_of_R = 0;
  for(int i = 2 * N - 1; i >= 0; i--){
    if(T[i] == 'R') num_of_R++;
    else{
      p *= num_of_R;
      p %= mod;
      num_of_R--;
    }
  }
  if(num_of_R) p = 0;
  
  cout << p << endl;
  
  return 0;
}

Measured memory_bytes: 772
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <stack>
#define N 8
using namespace std;

stack<char> s[N][N];
char map[N][N];
int kazu;

void post(int a,int b){
	for(int i=0;i<N;i++){
		s[i][b].push(1);
		if(i!=b) s[a][i].push(1);
	}
	for(int i=1;i+a<N&&i+b<N;i++){
		s[a+i][b+i].push(1);
	}
	for(int i=1;a-i>=0&&b-i>=0;i++){
		s[a-i][b-i].push(1);
	}
	for(int i=1;a+i<N&&b-i>=0;i++){
		s[a+i][b-i].push(1);
	}
	for(int i=1;a-i>=0&&b+i<N;i++){
		s[a-i][b+i].push(1);
	}
}

void receive(int a,int b){
	for(int i=0;i<N;i++){
		s[i][b].pop();
		if(i!=b)s[a][i].pop();
	}
	for(int i=1;i+a<N&&i+b<N;i++){
		s[a+i][b+i].pop();
	}
	for(int i=1;a-i>=0&&b-i>=0;i++){
		s[a-i][b-i].pop();
	}
	for(int i=1;a+i<N&&b-i>=0;i++){
		s[a+i][b-i].pop();
	}
	for(int i=1;a-i>=0&&b+i<N;i++){
		s[a-i][b+i].pop();
	}

}

void view(){
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			printf("%c",map[i][j]);
		}
		printf("\n");
	}
}

void rop(int a,int b){
	map[a][b]='Q';
	post(a,b);
	kazu++;
	if(kazu>=8){
		view();
		exit(0);
	}
	for(int i=a+1;i<N;i++){
		for(int j=0;j<N;j++){
			if(s[i][j].empty()) rop(i,j);
		}
	}
		receive(a,b);
		map[a][b]='.';
		kazu--;
}

int main(void){
	int n;
	int a,b;

	kazu=0;
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			map[i][j]='.';
		}
	}

	cin>>n;
	while(n--){
		cin>>a>>b;
		map[a][b]='Q';
		post(a,b);
		kazu++;
	}

	if(kazu==8){
		view();
		exit(0);
	}
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			if(s[i][j].empty()){
				rop(i,j);
			}
		}
	}
	return 0;
}

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

int main() {
    string S;
    cin >> S;
    int L=0;
    for(char x:S){
        if(x == 'x')L++;
    }
    string ans = (L<8)?"YES":"NO";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define strall(v) (v).cbegin(),(v).cend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

int main(){
  int n,ans=0;
  cin >> n;
  char s[n];
  rep(i,n)cin >> s[i];
  for(int i=1;i<n-1;i++){
    int cnt= 0;
    map<char,int> x;
    map<char,int> y;
    for(int l=0;l<i;l++) {x[s[l]];}  
    for(int l=i;l<n;l++) {y[s[l]];}
    for(auto xx:x){
      auto it = y.find(xx.first);
      if(it != y.end()) cnt++;
    }
    chmax(ans,cnt);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
n=int(input())
t=list(map(int,input().split()))
ans=0
a=[]
for i in range(n-2):
    a.append(t[i])
    a.append(t[i+1])
    a.append(t[i+2])
    total=sum(a)
    total=total-min(a)-max(a)
    if total==a[1]:
        ans+=1
    del a[:]
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define llu unsigned long long int
#define fo(i,n) for(int i=0;i<n;i++)
#define eb emplace_back
#define M 1000000007
#define vi vector<int>
#define vlli vector<lli>
#define pi pair<int,int>
#define mp make_pair
#define mapi map<int,int>
int main()
{
  //ios_base::sync_with_stdio(false);
  //cin.tie(NULL);
	int l,r,d;
	cin>>l>>r>>d;
	int cnt=0;
	for(int i=l;i<=r;i++) if(i%d==0) cnt++;
	cout<<cnt<<"\n";
	return 0;
}


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

int main() {
    int n, x;
    while(true) {
        cin >> n >> x;
        if(n == 0) return 0;
        int res = 0;
        for(int i=1; i<=n; ++i) {
            for(int j=i+1; j<=n; ++j) {
                for(int k=j+1; k<=n; ++k) {
                    if(i + j + k == x) ++res;
                }
            }
        }
        cout << res << endl;
    }
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e19;
//const int INF=(1<<30);


int main(){
  int k,n;

  cin >> k >> n;
  VI a(n);

  REP(i,n)cin>>a[i];

  int d=-1;

  REP(i,n-1){
    d = max(d, a[i+1]-a[i]);
  }
  d = max(d, a[0]+(k-a[n-1]));

  cout << k-d << endl;

}



Measured memory_bytes: 1024
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

#最大公約数
def gcd(a,b):
	while b:
		a,b = b, a%b
	return a

#最小公倍数
def lcm(a,b):
	return a*b // gcd(a,b)

N = int(input())
aa = inpl()
ans = aa[0]
for a in aa:
    ans = gcd(a,ans)
print(ans)


Measured memory_bytes: 15452
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()

#define PI acos(-1.0)
#define INF 1000000007

typedef long long ll;

string s;
//char a[100][100];
int c = 0;
int dx[] = { 1, 0, -1, 0 }, dy[] = { 0, 1, 0, -1 };
vector<string> vs;

void dfs(int x, int y){
	vs[x][y] = '0';

	for (int i = 0; i < 4; i++){
		if (x + dx[i] >= 0 && x + dx[i] <= 11 &&
			y + dy[i] >= 0 && y + dy[i] <= 11){
			if (vs[x + dx[i]][y + dy[i]] == '1'){
				dfs(x + dx[i], y + dy[i]);
			}
		}
	}
	return;
}

int main(){
	while (cin >> s){
		vs.push_back(s);
		FOR(i, 1, 12){
			cin >> s;
			vs.push_back(s);
		}
		REP(i, 12){
			REP(j, 12){
				if (vs[i][j] == '1'){
					dfs(i, j);
					c++;
				}
			}
		}
		cout << c << endl;
		c = 0;
		vs.clear();
	}
}

Measured memory_bytes: 1196
#include <stdio.h>
int main(){
	int x,y,a,b,z;
	scanf("%d%d",&x,&y);
	z=y-2*x;
	if(z%2){printf("No\n");return 0;}
	b=z/2;
	a=x-b;
	if(b<0||a<0){printf("No\n");return 0;}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 1636
n = gets.to_i
l = gets.split(" ").map(&:to_i)

count = 0
l.combination(3) do |a,b,c|
    if (a != b) && (b != c) && (a != c)
        if (a+b > c) && (a+c > b) && (b+c > a) 
            count += 1
        end
    end
end

puts count


Measured memory_bytes: 14284
#include "bits/stdc++.h"
typedef long long ll;
using namespace std;
static const int MAX = 200000;

int main() {
    int N, A[MAX], S[MAX];
    cin >> N;
    for (int i = 0; i < N; ++i) {
        int a; cin >> a;
        A[i] = S[i] = a;
    }

    sort(S, S + N, greater<>());

    for (int i = 0; i < N; ++i) {
        if (A[i] != S[0]) {
            cout << S[0] << endl;
        } else if (A[i] == S[0]) {
            cout << S[1] << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3200
#include<bits/stdc++.h>
#define MAXN 1001
const int mod = 1000000007;
typedef long long LL;
using namespace std;
int N;
int DIV[1001];
int primes[MAXN],tot=0;
bool isPrime[MAXN];

void getPrime()
{
    memset(isPrime,true,sizeof(isPrime));
    for(int i=2;i<MAXN;i++)
    {
        if(isPrime[i])
            primes[++tot]=i;
        for(int j=1;j<=tot;j++)
        {
            if(i*primes[j]>=MAXN) break;
            isPrime[i*primes[j]]=false;
            if(i%primes[j]==0) break;
        }
    }
}
int main()
{
    getPrime();
    scanf("%d", &N);
    LL ans = 1;
    for(int i=2;i<=N;i++)
    {
        for(int t=1;primes[t]<=i&&t<=tot;t++)
        {
            int x = i;
            while(x%primes[t]==0&&x) DIV[primes[t]] ++, x/=primes[t];
        }
    }
    for(int i=2;i<=N;i++) 
    {
        //cout <<i << " " << DIV[i] << endl;
        if(DIV[i]) ans*=(DIV[i]+1);
        if(ans>mod) ans = ans%(mod);
    }
    printf("%lld\n", ans);
    //system("pause");
}

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

int main() {
    int n,ptr=0,res=0,flg=0;
    cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++)
        cin >> a[i];
    for(int i=0;i<2*n;i++){
        if(a[ptr]==2){
            ++res;
            flg=1;
            break;
        }
        ptr = a[ptr]-1;
        ++res;
    }
    if(flg==1)
        cout << res << endl;
    else 
        cout << -1 << endl;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
int main() {
    using namespace std;
    int n;
    cin>>n;
    long long sy=1000,temp=0;
    int num[n+1];
    int cha[n+1]={};
    for(int i=0;i<n;i++)
    {
        cin>>num[i];
        if(i>=1&&i<=n-1)
        {
            cha[i]=num[i]-num[i-1];
            if(cha[i]>0)
            {
                temp=sy/num[i-1];
                sy=sy+temp*cha[i];
                //	cout<<sy<<endl;       // 剩余的钱数
            }
        }
    }
    cout<<sy<<endl;
    return 0;
}

Measured memory_bytes: 3644
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String t = "CODEFESTIVAL2016";
    int n = 16;
    int cnt = 0;

    for (int i = 0; i < n; i++) {
      if (s.charAt(i) != t.charAt(i)) {
        cnt++;
      }
    }

    System.out.println(cnt);

  }
}

Measured memory_bytes: 35552
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>
#include<iostream>
#define llong long long
using namespace std;

inline int read()
{
	int x=0; bool f=1; char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=0;
	for(; isdigit(c);c=getchar()) x=(x<<3)+(x<<1)+(c^'0');
	if(f) return x;
	return -x;
}

const int N = 500;
llong a[N+3][N+3];
llong s[2][N+3][N+3];
llong dp[N+3][N+3];
int n;

void update(llong &x,llong y) {x = x<y?x:y;}

llong getsum(int typ,int lx,int rx,int ly,int ry)
{
	return s[typ][rx][ry]-s[typ][lx-1][ry]-s[typ][rx][ly-1]+s[typ][lx-1][ly-1];
}

int main()
{
	scanf("%d",&n);
	for(int i=1; i<=n; i++)
	{
		for(int j=1; j<=n; j++)
		{
			if(j==i) continue;
			scanf("%lld",&a[i][j]);
		}
	}
	for(int i=1; i<=n; i++)
	{
		for(int j=1; j<=n; j++)
		{
			if(i<j) {s[0][i][j] = a[i][j];}
			s[0][i][j] += s[0][i][j-1];
		}
		for(int j=1; j<=n; j++) s[0][i][j] += s[0][i-1][j];
	}
	for(int i=1; i<=n; i++)
	{
		for(int j=1; j<=n; j++)
		{
			if(i>j) {s[1][i][j] = a[i][j];}
			s[1][i][j] += s[1][i][j-1];
		}
		for(int j=1; j<=n; j++) s[1][i][j] += s[1][i-1][j];
	}
	memset(dp,42,sizeof(dp)); 
	dp[0][0] = 0ll;
	for(int i=0; i<=n; i++)
	{
		for(int j=0; j<max(i,1); j++)
		{
//			printf("dp[%d][%d]=%lld\n",i,j,dp[i][j]);
			for(int k=i+1; k<=n; k++)
			{
				llong tmp = dp[i][j]+getsum(1,k+1,n,j+1,i)+getsum(0,i+1,k,i+1,k);
				update(dp[k][i],tmp);
//				printf("update dp[%d][%d]=%lld\n",k,i,tmp);
			}
		}
	}
	llong ans = dp[n][1];
	for(int i=1; i<=n; i++) update(ans,dp[n][i]);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 8192
#include <iostream>
#include <algorithm>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;
typedef long long LL;
const int INF=10000000;
int r[110], c[110];
int dp[110][110];

int CalcMin(int L, int R){
  if(L==R) return dp[L][R]=0;
  int res=INF;
  rep(M,R-L){
    int left, right;
    if(dp[L][L+M]!=-1) left=dp[L][L+M];
    else left=CalcMin(L,L+M);
    if(dp[L+M+1][R]!=-1) right=dp[L+M+1][R];
    else right=CalcMin(L+M+1,R);
    res=min(res,left+right+r[L]*c[L+M]*c[R]);
  }
  return dp[L][R]=res;
}

int main(){
  int n;
  cin >> n;
  rep(i,n) cin >> r[i] >> c[i];
  rep(i,n){
    rep(j,n) dp[i][j]=-1;
  }
  cout << CalcMin(0,n-1) << endl;

  return 0;
}



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

void bubbleSort(vector<int> a, int n) {
    bool flag = true;
    int i = 0;
    int count = 0;
    while (flag) {
        flag = false;
        for (int j = n-1; j > i; j--) {
            if (a.at(j) < a.at(j-1)) {
                swap(a.at(j), a.at(j-1));
                flag = true;
                count++;
            }
        }
        i++;
    }
    for (int x = 0; x < n; x++) {
        if (x) cout << " ";
        cout << a.at(x);
    }
    cout << endl;
    cout << count << endl;
}

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int x = 0; x < n; x++) {
        cin >> a.at(x);
    }
    bubbleSort(a, n);

     return 0;
}


Measured memory_bytes: 3164
#include<stdio.h>
int main()
{
	int n,m;
	int i,a,b,c,d;
	scanf("%d %d",&n,&m);
	if(n+m<=2) printf("0\n");
	else{
		b=n*(n-1)/2;
		c=m*(m-1)/2;
		d=b+c;
		printf("%d",d);
	}
	return 0;
}


Measured memory_bytes: 1708
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	int A, B;
	
	cin >> A >> B;

	int max_l = A + B;
	max_l = max(max_l, A-B);
	
	max_l = max(max_l, A*B);
	
	cout << max_l << endl;
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 30;
const int MOD = 1e9 + 7;

const int N = 1e5 + 10;
int a[N];
int n, A, B;

bool check(int64 m) {
  int64 sum = 0;
  for (int i = 0; i < n; ++i) {
    int cur = max(a[i] - m * B, 0LL);
    sum += (cur + A - 1) / A;
  }
  return sum <= m;
}

int main() {
  scanf("%d%d%d", &n, &A, &B);
  A -= B;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  int low = 1, high = 1e9;
  while (low != high) {
    int mid = (low + high) / 2;
    if (check(mid)) {
      high = mid;
    } else {
      low = mid + 1;
    }
  }
  printf("%d\n", high);
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5, mod = 1e9 + 7;

int add(int a, int b){
    a = (a + mod) % mod;
    b = (b + mod) % mod;
    return (a + b) % mod;
}

int mul(int a, int b){
    a = (a + mod) % mod;
    b = (b + mod) % mod;
    return 1ll * a * b % mod;
}

int fp(int b, int p){
    if(!p) return 1;
    ll ret = fp(b, p >> 1);
    ret = ret * ret % mod;
    if(p&1) ret = ret * b % mod;
    return ret;
}

int kam[N];

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n, k;
    cin >> n >> k;
    ll ans = fp(k, n);
    fill(kam, kam + N, 1);
    for(int i = 2; i <= k; i++){
        for(int j = i + i; j <= k; j += i) kam[j] += (i - kam[i]);
    }
    // for(int i = 2; i <= k; i++) cout << i << ' ' << kam[i] << '\n';
    for(int i = 2; i <= k; i++){
        ll x = i - kam[i];
        ans = add(ans, mul(x, fp(k / i, n)));
    }
    cout << ans;

    return 0;

}


Measured memory_bytes: 4404
using System;
using System.Collections.Generic;
using System.Linq;
using CompLib.Util;

public class Program
{

    public void Solve()
    {
        var sc = new Scanner();
        int n = sc.NextInt();
        var hs = new HashSet<string>(StringComparer.Ordinal);
        for (int i = 0; i < n; i++)
        {
            hs.Add(sc.Next());
        }
        Console.WriteLine(hs.Count);
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 50884