akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vi;

bool isValid(vi xs, vi ys, vi hs, int x, int y, int H)
{
    ll count = xs.size();
    for(int i = 0; i < count; i++)
    {
        if(max(H - abs(xs[i] - x) - abs(ys[i] - y), 0) != hs[i])
            return false;
    }
    return true;
}

int main() {
    int N;
    cin >> N;
    vi xs(N), ys(N), hs(N);
    int x, y, h, idx = 0;
    while (cin >> x >> y >> h) {
        xs[idx] = x;
        ys[idx] = y;
        hs[idx] = h;
        idx++;
    }
    
    int h_min = 0, h_max = 0;
    h_min = *std::min_element(hs.begin(), hs.end());
    h_max = *std::max_element(hs.begin(), hs.end());
    
    vi h_c(h_max - h_min + 250);
    for(int i = 0; i < h_c.size(); i++)
        h_c[i] = h_min + i;
    
    for (int x = 0; x <= 100; x++) {
        for (int y = 0; y <= 100; y++) {
//            auto p =  partition_point(h_c.begin(), h_c.end(), [&, x, y](int H){return isValid(xs, ys, hs, x, y, H);});
//            if (p != h_c.begin() && p != h_c.end()) {
//                cout << x << " " << y << " " << *p - 1 << endl;
//                break;
//            }
            for(auto& h : h_c){
                if(isValid(xs, ys, hs, x, y, h)){
                    cout << x << " " << y << " " << h << endl;
                    break;
                }
            }
        }
    }
    return 0;
}



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

int main(){
    int n,k;
    string s;
    cin >> n >> k >> s;
    if(s[k-1]=='A')s[k-1]='a';
    if(s[k-1]=='B')s[k-1]='b';
    if(s[k-1]=='C')s[k-1]='c';
    cout << s << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 10000


int main(){
  int n;
  int k,d;
  bool f[10] = {};

  scanf("%d%d",&n,&k);

  for(int i=0;i<k;i++){
    scanf("%d",&d);
    f[d] = true;
  }

  for(int i=n;;i++){
    int y = i;
    bool flag = true;
    
    while(y>0){
      if(f[y%10]){
        flag = false;
        break;
      }
      y/=10;
    }

    if(flag){
      printf("%d\n",i);
      return 0;
    }
  }
  
  
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void) {
	int A=0, B=0, C;
	scanf("%d", &A);
	scanf("%d", &B);
	if (A > B) {
		C = A - B;
	}
	else if (A < B) {
		C = B - A;
	}
	else {
		C = 0;
	}
	printf("%d\n", C);
	return 0;
}


Measured memory_bytes: 2756
/*  Name: Abu Hurayra
    Handle: HurayraIIT
    Institute: IIT_JU   */

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

typedef long long LL;
typedef string S;
typedef double D;
typedef vector<int> vi;
typedef queue<int> qi;
typedef stack<int> si;

#define pi acos(-1.0)
#define endl '\n'
#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define Fin freopen("input.txt","r",stdin)
#define Fout freopen("output.txt","w",stdout)

int main()
{
	off;
    int n,d,s=0;
    cin >> n >> d;
    if(d>=n/2)
    {
        cout << 1 << endl;
        return 0;
    }
    s = n / (2*d+1) ;
    if(n%(2*d+1)==0) cout << s << endl;
    else cout << s + 1 << endl;
    

    


	return 0;

}



Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <deque>
using namespace std;

int main() {
	int n, a;
	deque<int> B;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a);
		if (i & 0x1)
			B.push_front(a);
		else
			B.push_back(a);
	}
	if (n & 0x1) {
		printf("%d", B[n - 1]);
		for (int i = n - 2; 0 <= i; i--)
			printf(" %d", B[i]);
		printf("\n");
	} else {
		printf("%d", B[0]);
		for (int i = 1; i < n; i++)
			printf(" %d", B[i]);
		printf("\n");
	}
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<string>> vvs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define vrep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
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; }

const int mod = 1000000007;
const int inf = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};

class UnionFind{
public:
    vector<ll> par;
    vector<ll> siz;

    UnionFind(ll k):par(k), siz(k, 1LL){
        rep(i,k) par[i] = i;
    }

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

    void unite(ll x, ll y){
        x = root(x);
        y = root(y);
        if(x==y) return;

        if(siz[x]<siz[y]) swap(x, y);
        par[y] = x;
        siz[x] += siz[y];
        return;
    }

    bool same(ll x, ll y){
        return root(x) == root(y);
    }

    ll size(ll x){
        return siz[root(x)];
    }
};

int main(){
    int n, q;
    cin >> n >> q;
    UnionFind uf(n);
    while(q--){
        int c, x, y;
        cin >> c >> x >> y;
        if(c==0){
            uf.unite(x, y);
        }
        if(c==1){
            if(uf.same(x, y)) cout << 1 << endl;
            else cout << 0 << endl;
        }
    }
}


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

using namespace std;
bool isint(float distance){
    if(distance==(int)distance){
        return true;
    }
    else{
        return false;
    }
}
int main()
{
int array[10][10],n,d,i,j,t=0,counter=0,k=1,operation;
float distance=0;
scanf("%d %d",&n,&d);
operation=n-1;
for(i=0;i<n;++i){
    for(j=0;j<d;++j){
        scanf("%d",&array[i][j]);
    }
}
while(t!=n-1){
    distance=0;
    for(j=0;j<d;++j){
        distance=distance+(array[t][j]-array[k][j])*(array[t][j]-array[k][j]);
    }
    distance=sqrt(distance);
    if(isint(distance)){
        counter++;
    }
    operation--;
    k++;
    if(operation==0){
            t++;
            k=t+1;
            operation=n-(t+1);

    }
}
printf("%d",counter);
    return 0;
}


Measured memory_bytes: 256
//by tzupengwang™
#include<algorithm>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;

int n ;
int p[ 100005 ] ;

void init() {
  scanf( "%d" , &n ) ;
  for ( int i = 1 ; i <= n ; i ++ ) {
    scanf( "%d" , &p[ i ] ) ;
  }
}

int a[ 100005 ] , b[ 100005 ] ;

void process() {
  for ( int i = 1 ; i <= n ; i ++ ) {
    a[ i ] = i * 25000 ;
    b[ n - i + 1 ] = i * 25000 ;
  }
  for ( int i = 1 ; i <= n ; i ++ ) {
    a[ p[ i ] ] += i - 1 ;
  }
  for ( int i = 1 ; i <= n ; i ++ ) {
    printf( "%d%c" , a[ i ] , " \n"[ i == n ] ) ;
  }
  for ( int i = 1 ; i <= n ; i ++ ) {
    printf( "%d%c" , b[ i ] , " \n"[ i == n ] ) ;
  }
}

int main() {
  init() ;
  process() ;
  return 0 ;
}


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

using ll = long long int;
using P = pair<ll, ll>;
using P3 = pair<double,P>;
using PP = pair<P, P>;
constexpr int INF = 1 << 30;
constexpr ll MOD = ll(1e9+7);
constexpr int di[] = {0, 1, 0, -1};
constexpr int dj[] = {1, 0, -1, 0};
constexpr double EPS = 1e-9;


int main(){
    ll a, b, c;
    cin >> a >> b >> c;
    if(4*a*b < (c-a-b)*(c-a-b) && c > a+b){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#pragma region include
#include <stdio.h>
#include <string>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <bitset>
#include <cmath>
#include <tuple>
#pragma endregion
using namespace std;

#pragma region 定数
#define INF_VAL (2147483647 - 1)
#define INF_VAL_MINUS -INFVAL
#pragma endregion

#pragma region マクロ
// 型
#define ll long long

// 配列の長さを取得する(ただし関数内ではポインタサイズに注意)
#define SIZE_OF_ARRAY(array) sizeof(array) / sizeof(*array)

// for文
#define forn(i, size) for (long long(i) = 0; (i) < (size); (i)++)
#define for0(size) for (long(i) = 0; (i) < (size); (i)++)

// ソート
#define Sort(array, length) sort(array, array + length)
#define SortDESC(array, length, type_name) sort(array, array + length, std::greater<type_name>())

// 配列の最大値、最小値取得
#define MAX_OF_ARRAY(array, length) *max_element(array, array + length)
#define MIN_OF_ARRAY(array, length) *min_element(array, array + length)

// 結果出力系
#define YES                    \
    {                          \
        cout << "YES" << endl; \
        return 0;              \
    }
#define NO                    \
    {                         \
        cout << "NO" << endl; \
        return 0;             \
    }
#define Yes                    \
    {                          \
        cout << "Yes" << endl; \
        return 0;              \
    }
#define No                    \
    {                         \
        cout << "No" << endl; \
        return 0;             \
    }
#define println(str) cout << str << endl;

#pragma endregion

#pragma region Utility
#pragma region 最大公約数
ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return (b);
    }
    else
    {
        return (gcd(b, a % b));
    }
}
#pragma endregion

#pragma region 最小公倍数
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
#pragma endregion

#pragma region 配列要素の合計値を取得
template <typename T>
T getSum(T array[], int length)
{
    T sum = 0;
    for (int i = 0; i < length; i++)
    {
        sum += array[i];
    }
    return sum;
}
#pragma endregion

#pragma region ToString(int)
string ToString(int i)
{
    char buffer[1000];
    sprintf(buffer, "%d", i);
    return string(buffer);
}
#pragma endregion

#pragma region 10進数からN進数(<= 10) へ変換
string convertToN(long n, int base)
{
    string ans = "";
    while (n != 0)
    {
        int temp = n % base; // 1桁取得
        ans = ToString(temp) + ans;
        n /= base;
    }
    return ans;
}
#pragma endregion

#pragma region 連想配列のkeyが存在するか
template <typename T>
bool containsKey(map<string, T> map, string key)
{
    if (map.count(key) == 0)
    {
        return false;
    }
    return true;
}
#pragma endregion
#pragma endregion

int main()
{
    // 標準入力から値を取得
    int N, A;
    cin >> N >> A;

    if (N % A == 0)
    {
        printf("%d\n", N / A);
    }
    else
    {
        printf("%d\n", (N / A) + 1);
    }
}


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

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int h1, s1, h2, s2; cin >> h1 >> s1 >> h2 >> s2;
    bool f = true;

    while(h1 > 0 && h2 > 0) {
        if(f) {
            h2 -= s1;
        } else {
            h1 -= s2;
        }
        f = !f;
    }


    cout << (h1 <= 0 ? "No" : "Yes");
    return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
int n, w[105], v[105];
long long dp[105][100005], W;
int main () {
  scanf("%d %lld", &n, &W);
  for (int i=0; i<n; i++) {
    scanf("%d %d", &w[i], &v[i]);
  }
  for (int i=0; i<=n; i++) for (int j=0; j<=100000; j++) dp[i][j]=999999999999LL;
  dp[0][0]=0;
  for (int i=0; i<n; i++){
    for (int j=0; j<=100000; j++){
      dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
      if (j+v[i]<=100000) dp[i+1][j+v[i]]=min(dp[i+1][j+v[i]], dp[i][j]+w[i]);
    }
  }
  for (int i=100000;i>=0;i--) {
    if (dp[n][i]<=W) {
      printf("%d\n", i);
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const int mod=1000000007,INF=1001001001;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};


//#define int ll

int n,k,l,a,b;
int ans[200020];
vint visit[200020];

struct UF{
    vector<int>par,sz;
    void init(int n){
        par.resize(n);
        sz.resize(n);
        for(int i=0;i<n;i++){
            par[i]=i;
            sz[i]=1;
        }
    }
    int find(int x){
        return x==par[x]?x:par[x]=find(par[x]);
    }
    void unite(int x,int y){
        x=find(x);y=find(y);
        if(x==y)return;
        sz[x]+=sz[y];
        par[y]=x;
    }
    bool same(int x,int y){
        return find(x)==find(y);
    }
    int size(int x){
        return sz[find(x)];
    }
};

signed main(){
    cin>>n>>k>>l;
    UF X,Y;
    X.init(n);Y.init(n);
    rep(i,0,k){
        cin>>a>>b;a--,b--;
        X.unite(a,b);
    }
    rep(i,0,l){
        cin>>a>>b;a--,b--;
        Y.unite(a,b);
    }
    
    rep(i,0,n)visit[X.find(i)].pb(i);
    rep(i,0,n){
        map<int,int>cnt;
        for(auto u:visit[i])cnt[Y.find(u)]++;
        for(auto u:visit[i])ans[u]=cnt[Y.find(u)];
    }
    
    rep(i,0,n){
        cout<<ans[i]<<" ";
    }
    cout<<" "<<endl;
    
    return 0;
}

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

#define N_MAX 100010
#define INF 1000000010

struct Card {
    char suit;
    int value;
};

void merge(struct Card A[], int left, int mid, int right) {
    int n_left = mid - left;
    int n_right = right - mid;

    struct Card L[N_MAX / 2 + 2], R[N_MAX / 2 + 2];
    for (int i = 0; i < n_left; i++) {
        L[i] = A[left + i];
    }
    L[n_left].value = INF;

    for (int i = 0; i < n_right; i++) {
        R[i] = A[mid + i];
    }
    R[n_right].value = INF;

    int idx_L = 0;
    int idx_R = 0;
    for (int k = left; k < right; k++) {
        if (L[idx_L].value <= R[idx_R].value) {
            A[k] = L[idx_L];
            idx_L++;
        }
        else {
            A[k] = R[idx_R];
            idx_R++;
        }
    }
}

void mergeSort(struct Card A[], int left, int right) {
    if (right - left > 1) {
        int mid = (left + right) / 2;
        mergeSort(A, left, mid);
        mergeSort(A, mid, right);
        merge(A, left, mid, right);
    }
}


int partition(struct Card A[], int p, int r) {
    struct Card x = A[r];
    int i = p - 1;
    for (int j = p; j < r; j++) {
        if (A[j].value <= x.value) {
            i++;
            struct Card temp = A[j];
            A[j] = A[i];
            A[i] = temp;
        }
    }
    A[r] = A[i+1];
    A[i+1] = x;
    return i + 1;
}

void quickSort(struct Card A[], int p, int r) {
    int q;
    if (p < r) {
        q = partition(A, p, r);
        quickSort(A, p, q - 1);
        quickSort(A, q, r);
    }
}

int main() {
    int n;
    cin >> n;
    struct Card QS[N_MAX];
    for (int i = 0; i < n; i++) {
        cin >> QS[i].suit >> QS[i].value;
    }
    struct Card MS[N_MAX];
    for (int i = 0; i < n; i++) {
        MS[i] = QS[i];
    }

    quickSort(QS, 0, n - 1);

    mergeSort(MS, 0, n);
    // for (int i = 0; i < n; i++) {
    //     cout << MS[i].suit << " " << MS[i].value << endl;
    // }
    // cout << endl;

    int is_stable = 1;
    for (int i = 0; i < n; i++) {
        if (QS[i].suit != MS[i].suit) {
            is_stable = 0;
        }
    }

    if (is_stable == 1) {
        cout << "Stable" << endl;
    }
    else {
        cout << "Not stable" << endl;
    }

    for (int i = 0; i < n; i++) {
        cout << QS[i].suit << " " << QS[i].value << endl;
    }
}



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

def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

p_list = primes(55555)
p5_list = [i for i in p_list if i%5 == 1]
out = ' '.join(map(str, p5_list[:n]))
print(out)

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#include<algorithm>
#define int long long
using namespace std;
typedef pair<int,int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1000000000000

int MOD=1000000007;
int modpow(int a,int x){
  if(a<0)a+=MOD;
  int ans=1;
  while(x>0){
    if(x&1) ans=ans*a%MOD;
      a=a*a%MOD;
      x>>=1;
  }
  return ans;
}

int gyaku(int n){
    return modpow(n,MOD-2);
}
////////////////////////////////////////////////////////////

signed main() {
  int n;
  cin>>n;
  vector<char>ans(0);
  while(n>0){
    int t=(n-1)%26;
    n=(n-1)/26;
    ans.push_back('a'+t);
  }
  rep(i,ans.size()){
    cout<<ans[ans.size()-1-i];
  }
}


Measured memory_bytes: 3632
n = int(input())
l = list(map(int, input().split()))

scores = [0, 0, 0, 0, 0, 0, 0, 0]
x = 0

def evaluation(list):
    for i in list:
        if 0 <= i <= 399:
            scores[0] = 1
        elif 400 <= i <= 799:
            scores[1] = 1
        elif 800 <= i <= 1199:
            scores[2] = 1
        elif 1200 <= i <= 1599:
            scores[3] = 1
        elif 1600 <= i <= 1999:
            scores[4] = 1
        elif 2000 <= i <= 2399:
            scores[5] = 1
        elif 2400 <= i <= 2799:
            scores[6] = 1
        elif 2800 <= i <= 3199:
            scores[7] = 1

for j in range(n):
    if l[j] >= 3200:
        x += 1

evaluation(l)
y = sum(scores)

if n==1:
    print(1,1)
else:
    print(max(1, y), y + x)

Measured memory_bytes: 3064
import collections
n,k=map(int,input().split())
a=[int(i) for i in input().split()]
cnt=collections.Counter(a)
shu=len(cnt.values())
ans=0
if shu<=k:
    print(ans)
else:
    x=list(cnt.values())
    x.sort()
    for i in range(shu-k):
        ans+=x[i]
    print(ans)

Measured memory_bytes: 32516
using System;
class program{
  static void Main(){
    long[] vals = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
    int ans = 0;
    long a = vals[1]*vals[1];
    for(int i = 0;i < vals[0];i++){
      var xy = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
      if(a >= xy[0]*xy[0]+xy[1]*xy[1]) ans++;
    }
    Console.Write(ans);
  }
}

Measured memory_bytes: 46140
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    from heapq import heapify,heappop,heappush
    n,m=map(int,input().split())
    A=[-a for a in map(int,input().split())]
    heapify(A)
    for _ in range(m):
        x=-heappop(A)
        heappush(A,-(x//2))
    print(-sum(A))
resolve()

Measured memory_bytes: 14380
//By Koios1143
#include<bits/stdc++.h>
#define LL long long
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define pii pair<int,int>
using namespace std;
const int MaxN = 100005;
int n,k,arr[MaxN],dp[MaxN];
int main(){
	IOS
	while(cin>>n>>k){
		for(int i=0 ; i<n ; i++){
			cin>>arr[i];
			dp[i]=INT_MAX;
		}
		dp[0]=0;
		dp[1]=abs(arr[0]-arr[1]);
		for(int i=2 ; i<n ; i++){
			for(int j=1 ; i-j>=0 && j<=k ; j++){
				dp[i]=min(dp[i], dp[i-j] + abs(arr[i]-arr[i-j]));
			}
		}
		cout<<dp[n-1]<<'\n';
	}
	return 0;
}


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

int main(){
	int i;
	int a[3];
	rep(i, 3) cin >> a[i];
	sort(a, a+3);
	if(a[0] == a[1]) cout << a[2] << endl;
	else cout << a[0] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N,K,X,L;
  cin >> N >> K;
X=1;
L=0;
  for( int i=0; i < N; i++){
    cin >> X;
    if(2*X <= K){
      L += 2*X;}
    else{
      L += 2*K-2*X;}  
  }
 cout << L << endl;
}

Measured memory_bytes: 3624
#include<cstdio>
#include<cstring>

using namespace std;

char s[1010],t[1010];

inline int Min(int a,int b){
	return a<b?a:b;
}

int main(){
	scanf("%s",s+1);
	scanf("%s",t+1);
	int ans=1000;
	int len1=strlen(s+1),len2=strlen(t+1);
	for(int i=1;i<=len1-len2+1;i++){
		int res=0;
		for(int j=0;j<len2;j++)
			if(s[i+j]^t[j+1]) res++;
		ans=Min(ans,res);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1672
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
map<pair<ll,ll>,ll>dp;
ll mod = 1e9+7;
ll f(ll x,ll y){
    if(dp.count({x,y})){
        return dp[{x,y}];
    }
    ll res = 0;
    res += f(x/2,y/2);
    if(x>=1 and y>=1)res += f((x-1)/2,(y-1)/2);
    if(x>=2) res += f((x-2)/2,y/2);
    return dp[{x,y}] = res%mod;
}
int main(){
    ll n;
    cin >> n;
    dp[{0,0}] = 1;
    cout << f(n,n) << endl;
}

Measured memory_bytes: 256
def solve():
    s = input()
    k = int(input())
    head_ones = 0
    for c in s:
        if c != "1":
            break
        else:
            head_ones += 1

    return "1" if head_ones >= k else [c for c in s if c != "1"][0]


if __name__ == "__main__":
    print(solve())


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

using namespace std;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())
#define debug(x) cout << #x << ":" << x << endl;
#define debug2(x) for(auto a : x) cout << a << " "; cout << endl;
#define debug3(x) rep(i, sizeof(x)) cout << x[i] << " "; cout << endl;

vector<pii> around = {MP(1, 0), MP(-1, 0), MP(0, 1), MP(0, -1)};

//------------------------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; i += 2) {
        int cnt = 0;
        REP(j, 1, i + 1) if (i % j == 0) cnt++;
        if (cnt == 8) ans++;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    ll h;
    int n;
    cin>>h>>n;
    ll sum=0;
    rep(i,n){
        ll a;
        cin>>a;
        sum+=a;
    }
    if(sum>=h) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>

using namespace std;

int main()
{
    string s;
    string t;
    cin >> s;
    cin >> t;
    
    int ans = 0;
    
    for (int i = 0 ;i < s.size();i++){
        if (s[i] == t[i]){
            ;
        }
        else {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3792
import java.util.*;

public class Main{
	public static void main(String[] args) throws Exception {
		Scanner s = new Scanner(System.in);
		int N = s.nextInt(), r = 0, b = 0;
		String S = s.next();
		for (int i = 0; i < N; i++){
			String SS = S.substring(i,i + 1);
			if(SS.equals("R")) r++;
			else b++;
		}
		if (r > b)System.out.println("Yes");
		else System.out.println("No");
	}
}

Measured memory_bytes: 23380
#define _USE_MATH_DEFINES

#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
using ld = long double;
 
const ll MOD = 1000000007;
 
#ifndef ONLINE_JUDGE
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " (" << x.first << " : " << x.second << ")" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "["; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "]"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "(" << obj.first << ", " << obj.second << ")"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print_sim_py(void) {cout << endl;}
template <class Head> void print_sim_py(Head&& head) {cout << head;print_sim_py();}
template <class Head, class... Tail> void print_sim_py(Head&& head, Tail&&... tail) {cout << head << " ";print_sim_py(forward<Tail>(tail)...);}
 
#define print(...) print_sim_py(__VA_ARGS__);
#else
#define print(...);
#endif


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

    ll n,k;
    ll pt = 1;

    cin >> n >> k;
    vector<ll> b(k);
    
    for(ll i=0;i<k; i++){
        cin >> b[i];
    }

    for(ll i=k;i<n; i++){
        ll t=b[(i-k)%k];
        cin >> b[(i-k)%k];

        string ans = "Yes";

        if(t>=b[(i-k)%k])
            ans = "No";
        print(t,b[(i-k)%k])

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



Measured memory_bytes: 4748
#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	std::string s;
	std::cin >> s;
	int64_t res = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < i; j++) {
			if (s[i] == s[j]) continue;
			for (int k = 0; k < j; k++) if (j - k != i - j && s[k] != s[i] && s[k] != s[j]) res++;
		}
	}
	printf("%" PRId64 "\n", res);
	return 0;
}


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

using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    for(auto &e : a)cin >> e;
    vector<ll> dp(n+1);
    ll sum = a[0]; 
    for(int i = 2 ; i <= n ; i++){
        //3状態の場合分をiの偶奇で行う
        if(i % 2 == 0) {
            dp[i] = max(a[i-1] + dp[i-2], sum);
        } 
        else {

            dp[i] = max(a[i-1] + dp[i-2], dp[i-1]);
            sum += a[i-1];
        }
    }
    cout << dp[n] << endl;
    return 0;
}


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

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

p_sorted = sorted(p_list)
#print(p_sorted)

ans = 0
for i in range(n):
    if p_list[i] != p_sorted[i]:
        ans += 1

if ans == 2 or ans == 0:
    print('YES')
else:
    print('NO')



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

using namespace std;

int main() {

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	int k;
	string s;
	cin >> k >> s;
	if (s.size() <= k) cout << s << '\n';
	else cout << s.substr(0, k) + "..." << '\n';
	return 0;
}

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

int d[323456];//d[i]:i個のグループの数
int dwa[323456];//dwa[i]:sum[0,i) of d
int dkwa[323456];//dkwa[i]:sum[0,i) of k*d[k]
int f[323456];//f[i]:i個列を作るときの最大長さ
//=( sum[0,i)k*d[k] + i*sum[i,INF)*d )/i
//=( dkwa[i]+i*(dwa[INF]-dwa[i]) )/i

signed main(){
  int n;cin>>n;
  map<int,int> m;
  for(int i=0;i<n;i++){
    int a;cin>>a;
    m[a]++;
  }
  for(auto p:m)d[p.second]++;
  for(int i=0;i<323400;i++)dwa[i+1]=dwa[i]+d[i];
  for(int i=0;i<323400;i++)dkwa[i+1]=dkwa[i]+i*d[i];
  for(int i=1;i<323400;i++)f[i]=(dkwa[i]+i*(dwa[323300]-dwa[i]))/i;
  int now=n;
  for(int i=1;i<=n;i++){
    while(now&&f[now]<i)now--;
    cout<<now<<endl;
  }
}


Measured memory_bytes: 18432
// lcmとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1001001001
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
using namespace std;
bool my_compare(pair<ll, ll> a, pair<ll , ll> b) {
    // 基本はfirstで比較
    if(a.first != b.first){
         return a.first < b.first; // 昇順
        //return a.first > b.first; // 降順
    }

    // それ以外はsecondで比較
    if(a.second != b.second){
        return a.second > b.second;
    }else{
        // どちらも同じ
        return true;
    }
}

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

    ll a,b,c,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str;
    cin>>n;
    vector<ll> v(n);
    vector<ll> w(100000+2);
    //rep(i,n)

    rep(i,n) cin>>v[i];
    rep(i,n){
        if(v[i]!=0)w[v[i]-1]++;
        w[v[i]]++;
        w[v[i]+1]++;
    }
    rep(i,100000+2){
        maxi=max(maxi,w[i]);
    }
    cout<<maxi<<endl;

    return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define CANCER ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define mod 1000000007

using namespace std;


int main()
{
	CANCER;
	int n,k;
	cin>>n>>k;
	if(k==1)
		cout<<0;
	else
	{
		for(int y=0;y<k;y++)
			n--;
		cout<<n;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
int n, x, y, ans[2005];
void get(int i, int j) {
	int d1 = j - i;
	int d2 = abs(i - x) + 1 + abs(j - y);
	ans[std::min(d1, d2)]++;
}
int main() {
	std::cin >> n >> x >> y;
	for (int i = 1; i < n; ++i)
		for (int j = i + 1; j <= n; ++j) get(i, j);
	for (int i = 1; i < n; ++i) std::cout << ans[i] << '\n';
	
}


Measured memory_bytes: 256
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

alias Edge = Tuple!(int, "u", int, "v");

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto M = s[1].to!long;
    auto AB = N.iota.map!(_ => readln.split.map!(to!long).array).array;

    AB.sort();
    long cnt = 0;
    long ans = 0;

    foreach (ab; AB) {
        if (cnt == M) break;
        long a = ab[0];
        long b = ab[1];
        b = min(M-cnt, b);
        cnt += b;
        ans += a * b;
    }

    ans.writeln;
}


Measured memory_bytes: 11772
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
 
using namespace std;
typedef long long ll;
 
int main()
{
    ll n, m, k;
    cin >> n >> m >> k;
    vector<ll> a(n), b(m);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for (int i = 0; i < m; i++)
    {
        cin >> b[i];
    }
    vector<ll> acc_a(n + 1);
    vector<ll> acc_b(m + 1);
    for (int i = 0; i < n; i++)
    {
        acc_a[i + 1] = acc_a[i] + a[i];
    }
    for (int i = 0; i < m; i++)
    {
        acc_b[i + 1] = acc_b[i] + b[i];
    }
    ll ans = 0;
    for (int i = 0; i < n + 1; i++)
    {
        ll remain = k - acc_a[i];
        if (remain < 0)
            continue;
 
        auto iter = upper_bound(acc_b.begin(), acc_b.end(), remain);
        ll index = distance(acc_b.begin(), iter);
        ll books = i + index - 1;
        ans = max(ans, books);
    }
    cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 9580
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
	long int a[5], n;
	int i, j;
	long int sum = 4;
	long int min;
	
	scanf("%ld", &n);
	
	for(i = 0; i < 5; i++) {
		scanf("%ld", &a[i]);
	}
	
	min = a[0];
	
	for(i = 1; i < 5; i++) {
		if(a[i] < min) {
			min = a[i];
		}
	}
	
	if(n % min == 0) {
		sum += (n / min);
	} else {
		sum += ((n / min) + 1);
	}
	
	printf("%ld\n", sum);
	return 0;
}

Measured memory_bytes: 128
<?php

fscanf(STDIN, "%d", $num_count);
$target_num = array_map("intval", explode(" ", trim(fgets(STDIN))));

fscanf(STDIN, "%d", $search_count);
$keys = array_map("intval", explode(" ", trim(fgets(STDIN))));

$count = 0;

foreach ($keys as $key) {
    if (binary_search($target_num, $key)) ++$count;
}

echo $count, "\n";


function binary_search ($target_num, $key) {
    $left = 0;
    $right = count($target_num);
    while ($left < $right) {
        $mid = ($left + $right) / 2;
        if ($target_num[$mid] == $key) return true;
        elseif ($target_num[$mid] > $key) $right = $mid;
        else $left = $mid+1;
    }
    
    return false;
}


Measured memory_bytes: 40908
import math

a,b,h,m=map(float,input().split())
pi=math.pi
apos=(h*60+m)/(12*60)*2*pi
bpos=m/60*2*pi

kaku=apos-bpos
#print(kaku,math.degrees(kaku))
if kaku<0:
    kaku=-kaku
if kaku>=pi:
    kaku=2*pi-kaku
#print(kaku,math.degrees(kaku))
print((a**2+b**2-2*a*b*math.cos(kaku))**0.5)

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

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

  vector<int> a(n);
  rep (i, n) cin >> a[i];

  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());

  int alice = 0, bob = 0; //得点
  rep (i, n) {
    if (i % 2 == 0) alice += a[i];
    else bob += a[i];
  }

  cout << alice - bob << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cctype>
#include <utility>
#include <vector>
using namespace std;

const auto gcu = getchar_unlocked;
const auto pcu = putchar_unlocked;
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _sc _il bool scan
_T T in(int c){T n=0;int m=1;while(isspace(c)){c=gcu();}if(c=='-')m=-1,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
_il int in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _ot _il void out
#define _ol _il void outl
_ot(bool b) {pcu('0'+b);}
_ot(const char *s){while(*s)pcu(*s++);}
_ot(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_ot(string s){for(char c:s)pcu(c);}
#endif
_T _ot(T n){static char b[20];char *p=b,m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=n%10*m+'0',n/=10;while(p!=b)pcu(*--p);}
_ol(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _ot(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _ot(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _ol(T&&... t){out(move(t)...);outl();}

struct item {int v, w;};

int main() {
	int N = in(), W = in();
	vector<item> items(N);
	for (item &i : items)
		i = {in(), in()};
	vector<int> dp(W + 1);
	for (int i = 0; i < N; i++)
		for (int w = W; w >= items[i].w; w--)
			dp[w] = max(dp[w - items[i].w] + items[i].v, dp[w]);
	outl(dp[W]);
}


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

using namespace std;

using ll = long long;

int main(){
    int A,B;cin >> A >> B;
    int now = 1;
    int ans = 0;
    while(now < B){
        now--;
        now += A;
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    if(n<=111){
        cout << 111 << endl;
    }
    else if(n<=222){
        cout << 222 << endl;
    }
    else if(n<=333){
        cout << 333 << endl;
    }
    else if(n<=444){
        cout << 444 << endl;
    }
    else if(n<=555){
        cout << 555 << endl;
    }
    else if(n<=666){
        cout << 666 << endl;
    }
    else if(n<=777){
        cout << 777 << endl;
    }
    else if(n<=888){
        cout << 888 << endl;
    }
    else{
        cout << 999 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

ss, st = ins().split()
a, b = inm()
su = ins()


def solve():
    if su == ss:
        return (a - 1), b
    else:
        return a, (b - 1)


print(*solve())


Measured memory_bytes: 9080
#include <iostream>
#include <string>

using namespace std;

int main() {
    while(!cin.eof()) {
        string str;
        getline(cin, str);
        if(str == "") break;
        for(int shift = 0; shift < 26; ++shift) {
            if(str.find("the") != string::npos || str.find("this") != string::npos || str.find("that") != string::npos) break;
            for(int i = 0; i < str.size(); ++i) 
                if(islower(str[i]) && ++str[i] > 'z') str[i] = 'a';
        }
        cout << str << endl;
    }
    return 0;
}

Measured memory_bytes: 0
N=int(input())
A=list(map(int,input().split()))
B=[0 for _ in range(N)]
for i in range(N):
    B[i] = A[i] - (i+1)
B.sort()
b=B[N//2]
ans=sum([abs(x-b) for x in B])
print(ans)

Measured memory_bytes: 27684
#include <stdio.h>
int main() {
	int W;
	int H;
	int x;
	int y;
	int r;
	

	scanf("%d", &W);
	scanf("%d", &H);
	scanf("%d", &x);
	scanf("%d", &y);
	scanf("%d", &r);

int A = (0 <= x - r && x + r <= W);
	int B =( 0 <= y - r && y + r <= H);
	int C = (x - r<0 || x + r>W);
	int D = (y - r<0 || y + r>H);
	if (A&&B){
		printf("Yes\n");
	}

	if(C||D)
	 {
			printf("No\n");
		}

	return 0;
}


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

using namespace std;

typedef long long ll;

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 (a>b) { a=b; return 1; } return 0; }

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

	int n;
	cin >> n;

	int r = (n + 999) / 1000;
	cout << 1000 * r - n << endl;	
}


Measured memory_bytes: 3644
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

long long int power(long long int x, long long int n, long long int M) {
	long long int ret = 1;
	long long int by = x;
	while (n) {
		if (n & 1) {
			ret *= by;
			ret %= M;
		}
		by *= by;
		by %= M;
		n >>= 1;
	}
	return ret;
}

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

	cin >> N >> K;
	vector<int>v(N);
	for (auto &i : v)cin >> i;
	sort(v.begin(), v.end());
	vector<long long int>by(N + 1, 1);
	vector<long long int>rev(N + 1, 1);
	for (int i = 2; i <= N; i++) {
		by[i] = by[i - 1] * i%MOD;
		rev[i] = power(by[i], MOD - 2, MOD);
	}
	long long int ans = 0;
	for (int i = K - 1; i < N; i++) {
		ans += by[i] * rev[K - 1] % MOD*rev[i - K + 1] % MOD*v[i]%MOD;
		ans %= MOD;
	}
	for (int i = 0; i <= N - K; i++) {
		ans += MOD - by[N - i - 1] * rev[K - 1] % MOD*rev[N - i - K] % MOD*v[i] % MOD;
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2176
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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;
}

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

    cout << A * B << endl;
    return 0;
}


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

int main(){
  long long N;
  cin >> N;
  vector<long long> A(N);
  for(long long i = 0; i < N; i++) cin >> A[i];
  vector<long long> N2(61);
  N2[0] = 2;
  for(int i = 1; i < 61; i++) N2[i] = N2[i-1]*2;
  vector<long long> numN2(61);
  for(long long i = 0; i < N; i++){
    for(int j = 0; j < 61; j++){
      if((A[i]%N2[j] / (N2[j]/2)) == 1) numN2[j]++;
    }
  }
  long long ans = 0;
  for(int i = 0; i < 61; i++){
    if(numN2[i]*(N-numN2[i]) == 0) continue;
    long long tmp = numN2[i]*(N-numN2[i]);
    tmp %= 1000000007;
    long long tmp2 = N2[i]/2;
    tmp2 %= 1000000007;
    ans += tmp2*tmp;
    // cout << "ans = " << ans << endl;
    ans %= 1000000007;
  }
  cout << fixed;
  cout << setprecision(12) << ans << endl;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,a,b) for(int i=a;i<=b;i++)
inline ll r() {
	ll x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9')c=getchar();
	if(c=='-')f=-1,c=getchar();
	while(isdigit(c))x=x*10+c-'0',c=getchar();
	return x*f;
}
#define d r()
ll n,ans;
double dd;
double dis(double x1,double y1,double x2,double y2){
	return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}
int main(){
	n=d;
	cin>>dd;
	f(i,1,n){
		double x,y;
		cin>>x>>y;
		if(dis(x,y,0,0)<=dd)ans++;
	}
	cout<<ans;
	return 0;
}


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

typedef struct restraunt {
  char city[10];
  int point;
  int number;
} RESTRAUNT;

int compare(const void *a, const void *b) {
  RESTRAUNT ra = *(RESTRAUNT *)a, rb = *(RESTRAUNT *)b;
  int cmp = strcmp(ra.city, rb.city);
  if (cmp == 0) {
    return rb.point - ra.point;
  } else {
    return cmp;
  }
}

int main() {
  int n;
  scanf("%d\n", &n);
  RESTRAUNT a[n];
  for (int i = 0; i < n; i++) {
    scanf("%s%d", a[i].city, &(a[i].point));
    a[i].number = i+1;
  }
  qsort(a, n, sizeof(RESTRAUNT), compare);
  for (size_t i = 0; i < n; i++) {
    printf("%d\n", a[i].number);
  }
  return 0;
}


Measured memory_bytes: 128
#include <iostream>

using namespace std;


int main() {
	int n;
	long long int prev = 2;
	cin >> n;
	long long int total=1;
	for (int i = 1; i < n; i++) {
		long long int tmp = total;
		total += prev;
		prev = tmp;
	}

	cout << total << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
const int INF = 1LL<<30;

int main(){
    string sa,sb,sc;
    cin>>sa>>sb>>sc;
    int na=sa.size(),nb=sb.size(),nc=sc.size();

    int a=0,b=0,c=0;
    char t='a';
    while(1){
        if(t=='a'){
            if(a==na){
                cout<<"A"<<endl;
                return 0;
            }
            t=sa[a];
            a++;
        }
        else if(t=='b'){
            if(b==nb){
                cout<<"B"<<endl;
                return 0;
            }
            t=sb[b];
            b++;
        }
        else if(t=='c'){
            if(c==nc){
                cout<<"C"<<endl;
                return 0;
            }
            t=sc[c];
            c++;
        }
    }
}

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

namespace HABIT{
    #define f(a,b,c,d) for(register int a=b,c=d;a<=c;a++)
    #define g(a,b,c,d) for(register int a=b,c=d;a>=c;a--)
    #define LOCAL
    typedef int i32;
    typedef unsigned int u32;
    typedef long long int i64;
    typedef unsigned long long int u64;
    typedef pair<i32,i32> pii;
    const i32 MAXN=1024;
    typedef i32 ar[MAXN];
    
    template<typename T> inline T Max(T a) { return a; }
    template<typename T,typename... Args> inline T Max(T a,Args... args){
        T b=Max(args...);
        return (a>b)?a:b;
    }
    template<typename T> inline T Min(T a) { return a; }
    template<typename T,typename... Args> inline T Min(T a,Args... args){
        T b=Min(args...);
        return (a<b)?a:b;
    }

    #ifdef LOCAL
        inline char gc() { return getchar(); }
    #else
        inline char gc() {
            static char s[1<<20|1]={0},*p1=s,*p2=s;
            return (p1==p2)&&(p2=(p1=s)+fread(s,1,1<<20,stdin),p1==p2)?EOF:*(p1++);
        }
    #endif
    inline i64 read(){
        register i64 ans=0;register char c=gc();register bool neg=0;
        while(c<48||c>57) neg^=!(c^'-'),c=gc();
        while(c>=48&&c<=57) ans=(ans<<3)+(ans<<1)+(c^48),c=gc();
        return neg?-ans:ans;
    }

    char Output_Ans[1<<20|1],*Output_Cur=Output_Ans;
    inline void output() { Output_Cur-=fwrite(Output_Ans,1,Output_Cur-Output_Ans,stdout); }
    inline void print(char c){
        if(Output_Cur-Output_Ans+1>>20) output();
        *(Output_Cur++)=c;
    }
    inline void print(char *s) { while(*s) print( *(s++) ); }
    inline void print(u64 x){
        if(!x) { print('0'); return ; }
        char buf[30]={0},*p=buf+28;
        while(x) *(p--)=x%10+48,x/=10;
        print(p+1);
    }
    inline void print(u32 x) { print( (u64)x ); }
    inline void print(i64 x){
        if(x<0) print('-'),x=-x;
        print( (u64)x );
    }
    inline void print(i32 x){
        if(x<0) print('-'),x=-x;
        print( (u64)x );
    }
}
using namespace HABIT;

int main(){
    i32 K=read(),A=read(),B=read();
    A=A/K+(A%K!=0);
    B=B/K;
    if(A<=B) print("OK");
    else print("NG");
    output();
    return 0;
}

Measured memory_bytes: 3636
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

	public static final int MAX = 200000;

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int highest =0;
		int middle =0;
		int lowest =0;

		for(int i =0 ; i<10; i++){

			int now = Integer.parseInt(br.readLine());
			if(highest <= now){
				lowest = middle;
				middle = highest;
				highest= now;
			/*	System.out.println("h");*/
			}else if (middle <= now) {
				lowest = middle;
				middle = now;
				/*System.out.println("m");*/
			}else if (lowest <= now) {
				lowest = now;
				/*System.out.println("l");*/

			}
			/*System.out.println(highest+"\n"+middle+"\n"+lowest);*/

		}

		System.out.println(highest+"\n"+middle+"\n"+lowest);

	}

}

Measured memory_bytes: 24240
#include<bits/stdc++.h>
using namespace std;
typedef complex<double> P;
 
P calc(P a,P b,P c,P d){
  a-=d;b-=d;c-=d;
  return d+a+(b-a)*imag(a/c)/imag(a/c-b/c);
}
 
int main(){
  int n;
  double ax,ay,bx,by,cx,cy,dx,dy;
  scanf("%d",&n);
  while(n--){
    scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&ax,&ay,&bx,&by,&cx,&cy,&dx,&dy);
    P ans=calc(P(ax,ay),P(bx,by),P(cx,cy),P(dx,dy));
    printf("%.8f %.8f\n",ans.real(),ans.imag());
  }
  return 0;
}

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

using namespace std;

int main()
{
    string s;

    int n;
    scanf("%d",&n);
    cin>>s;
    int start = 0,end=s.size()/2;
    if(s.size()%2==1)puts("No");
    else{
        bool flag = true;
        while(start!=s.size()/2){
            if(s[start++]!=s[end++]){
                flag=false;
                break;
            }
        }
        if(!flag)puts("No");
        else puts("Yes");
    }

    return 0;
}


Measured memory_bytes: 256