akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
// #define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
 
struct S002 {
  int n;
  S002& operator > (long& x) {
    n = x;
    return *this;
  }
  S002& operator > (long&& x) {
    n = x;
    return *this;
  }
  S002& operator >= (long& x) {
    if( scanf("%ld", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (double& x) {
    if( scanf("%lf", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (std::string& s) {
    if( not (std::cin >> s) ) exit(0);
    return *this;
  }
  template<typename a>
  S002& operator >= (std::vector<a>& v) {
    v.resize(n);
    for(long i = 0; i < n; ++i) {
      *this >= v[i];
    }
    return *this;
  }
  template<typename a, std::size_t s>
  S002& operator >= (std::array<a, s>& x) {
    for(long i = 0; i < (long)s; ++i) {
      *this >= x[i];
    }
    return *this;
  }
};

struct Solver {
  long a, b, c;
  Solver() {
    S002 reader;
    reader >= a >= b >= c;
  }
  void solve() {
    puts(a <= c and b >= c ? "Yes" : "No");
  }
  ~Solver() { fprintf(stderr, "--end--\n"); }
};
 
int main() {
  loop std::unique_ptr<Solver>(new Solver())->solve();
  return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        while(true){
            String line = sc.next();
            if(line.equals("-")) System.exit(0);
            int l = line.length();
            char[] moji = new char[l];
            for(int i=0;i<l;i++){
                moji[i] = line.charAt(i);
            }

            int m = sc.nextInt();
            for(int i=0;i<m;i++){
                char[] moji2 = new char[l];
                int h = sc.nextInt();
                for(int j=0;j<l-h;j++){
                    moji2[j] = moji[h+j];
                }
                for(int j=0;j<h;j++){
                    moji2[l-h+j] = moji[j];
                }
                for(int j=0;j<l;j++){
                    moji[j] = moji2[j];
                }
            }
            for(int k=0;k<l;k++){
                System.out.print(moji[k]);
            }
            System.out.println("");
        }
    }
}


Measured memory_bytes: 26360
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <queue>
#include <math.h>
#include <bits/stdc++.h>
#include <queue>
#include <map>

using namespace std;

#define INF (1ll<<60)
#define INFint (1<<30)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;
// typedef pair<ll,ll> P;

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

template<class T>
bool umax(T &a, const T &b){
    if (a<b) {
        a=b; return true;
    }
    return false;
}

template<class T>
bool umin(T &a, const T &b) {
    if (b<a) {
        a=b; return true;
    }
    return false;
}

// gcd
template<typename T>
T gcd(T a, T b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}

// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);
    return result;
}

template<typename T>
T lcm( T m, T n ){
    // 引数に0がある場合は0を返す
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;
    return ((m/gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}


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

// v.front() = -BOUND;
// v.back() = BOUND;

//struct edge{
//    int cost, to;
//
//    edge(int in_cost, int in_to){
//        cost=in_cost;
//        to=in_to;
//    }
//    bool operator<(const edge &a) const
//    {
//        return cost > a.cost;
//    }
//};
vector<int>G[10010];
vector<int>c(10010,0);
int num[10010];
bool used[10010];
int now_c=0;
int dfs(int s){
    if(used[s]){
        return 0;
    }else{
        used[s]=true;
    }

    num[s]=c[now_c];
    now_c++;

    for(int i=0; i<G[s].size(); i++){
        dfs(G[s][i]);
    }
    return 0;
}

int sum[110];
int main() {
    int N; cin >> N;
    int ans=INFint;

    sum[0]=0;
    rep(i,N){
        int s; cin >> s;
        sum[i+1]=sum[i]+s;
    }

    for(int i=1; i<N; i++){
        ans=min(ans, abs(sum[N]-2*sum[i]));
    }


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


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

int main()
{
	int way = 0;
	string s;
	cin >> s;
	if (s[0] == 'A')
	{
		++way;
	}
	int daiC = 0;
	for (int i = 2; i < s.size()-1; ++i)
	{
		daiC += (s[i] == 'C');
	}
	way += (daiC == 1);
	int ko = 0;
	for (int i = 0; i < s.size(); ++i)
	{
		ko += (s[i] >= 'a' && s[i] <= 'z');
	}
	way += (ko == s.size() - 2);
	cout << ((way == 3)?"AC":"WA") << endl;
	return 0;
}

Measured memory_bytes: 256
import math
import collections

def LI():
  return [int(s) for s in input().split()]

A,B = LI()

prime_factor = []

for i in range(2,int(math.sqrt(A))+1):
  while A%i == 0:
    prime_factor.append(i)
    A/=i

if A > 1:
  prime_factor.append(A)

prime_factor.append(1)
c1 = set(prime_factor)

prime_factor = []

for i in range(2,int(math.sqrt(B))+1):
  while B%i == 0:
    prime_factor.append(i)
    B/=i
    
if B > 1:
  prime_factor.append(B)

prime_factor.append(1)
c2 = set(prime_factor)

N = len(c1 & c2)

print(N)

Measured memory_bytes: 3444
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner in = new Scanner(System.in);
        int x = in.nextInt(), n = in.nextInt(), m = in.nextInt();
        if (x * (m / x) >= n) {
            System.out.println("OK");
        } else {
            System.out.println("NG");
        }
    }

}


Measured memory_bytes: 26988
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>    
#define inf 100000000
#define INF 9223372036854775807
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
long long mod=(long long)1e09+7;

int in(void){
    int i;scanf("%d",&i);
    return i;
}
long long llin(void){
    long long i;scanf("%lld",&i);
    return i;
}
double din(void){
    double i;scanf("%lf",&i);
    return i;
}
void chin(char s[]){
    scanf("%s",s);
}
void print(int a){
    printf("%d\n",a);
}
void llprint(long long a){
    printf("%lld\n",a);
}
void dprint(double a){
    printf("%.10f\n",a);
}
void print2(int a,int b){
    printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
    return a>b?a:b;
}
long long min(long long a,long long b){
    return a<b?a:b;
}
int cmp(const void *a,const void *b){
    return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
    return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
    return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
    return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
    int t=*a;
    *a=*b;
    *b=t;
}
long long gcd(long long x,long long y){
    return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
    return x/gcd(x,y)*y;
}

// write codes below this
// when you use 'sort',
// make sure TYPE macro is correct

int main(void){
    int n=in(),i,t,ans=inf,c;
    rep(i,n+1){
        c=0;
        t=i;
        while(t){
            c+=t%6;
            t/=6;
        }
        t=n-i;
        while(t){
            c+=t%9;
            t/=9;
        }
        ans=min(ans,c);
    }
    print(ans);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define vi vector<int>
#define vl vector<ll>
#define ppi pair<int,int>
#define ppl pair<ll,ll>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define imx INT_MAX
#define imn INT_MIN
#define inf LONG_MAX
#define minf LONG_MIN
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 
#define pre cout<<fixed<<setprecision(10);
#define umap unordered_map
#define uset unordered_set

/*
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int
#define si short int
*/

/*
bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/


int main()
{
    fast

    int n;
    cin>>n;

    vi v(n);

    forn(i,0,n) cin>>v[i];


    vector<ll> dp(n+10);
    dp[0] = 0;
    dp[1] = abs(v[1]-v[0]);

    forn(i,2,n)
    {
        dp[i] = min(dp[i-1]+abs(v[i]-v[i-1]),dp[i-2]+abs(v[i]-v[i-2])); 
    }

/*    forn(i,0,n)
    {
        cout<<dp[i]<<" ";
    }
    cout<<endl;*/

    cout<<dp[n-1];

    return 0;
}

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

using namespace std;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	sort(a.begin(), a.end());
	if (a.back() - a.front() > 1) {
		cout << "No" << endl;
		return 0;
	}
	int cnt[2] = {};
	for (int i = 0; i < n; i++) cnt[a[i] - a[0]]++;
	if (cnt[1] == 0) {
		cout << (a[0] + 1 == n || a[0] * 2 <= n ? "Yes" : "No") << endl;
		return 0;
	}
	int x = cnt[0];
	int y = a.back();
	int z = y - x;
	if (z <= 0) {
		cout << "No" << endl;
	} else {
		cout << (n - x >= z * 2 ? "Yes" : "No") << endl;
	}
	return 0;
}

Measured memory_bytes: 640
import sys


def prime_list(n):
    limit = int(n ** 0.5) + 1
    lis = range(1, n + 1, 2)
    lis[0] = 2
    while True:
        if len(lis) == 0:
            break
        p = lis.pop(0)
        yield p
        if p <= limit:
            lis = [x for x in lis if x % p != 0]


def primes_number(n):
    primes = []
    for p in prime_list(n):
       primes.append(p)
    return primes


ns = map(int, sys.stdin.readlines())
max_n = max(ns)

primes = primes_number(max_n)


for n in ns:
    p = len(filter(lambda x: x <= n, primes))
    print p

Measured memory_bytes: 23992
#include <bits/stdc++.h>
#include <boost/foreach.hpp>
using namespace std;
#define pi 2*asin(1.0)
#define MAX 10000000
#define MOD 1000000007
#define _GLIBCXX_DEBUG
 
vector<long> fac(MAX);
vector<long> finv(MAX);
vector<long> inv(MAX);
vector<long> Primelist;
//template functions
/////////////////////////
void Prinit(){
long PR=10000001;
vector<long> P(PR,0);
for(long i=2;i*i<PR;i++){
    if(P.at(i)==0){
        long j=i;
      j+=i;
        while(j<PR){
            P.at(j)=1;
             j+=i;         
        }
    }
}

for(long i=2;i*i<PR;i++){//Primelist.size()=446
    if(P.at(i)==0){
        Primelist.push_back(i);
    }
}
}

void Cominit(){
  fac.at(0)=fac.at(1)=1;
  finv.at(0)=finv.at(1)=1;
  inv.at(1)=1;
  for(long i=2;i<MAX;i++){
      fac.at(i)=(fac.at(i-1)*i)%MOD;
      inv.at(i)=MOD-inv.at(MOD%i)*(MOD/i)%MOD;
      finv.at(i)=finv.at(i-1)*inv.at(i)%MOD;
  }
}

long facComb(long N,long M){// nCm%
if(N<M) return 0;
if(N<0||M<0) return 0;
return fac.at(N)*(finv.at(M)*finv.at(N-M)%MOD)%MOD;
}

long Comb(long N,long M){// nCm
long ans=1;
for(long i=N;i>N-M;i--){
    ans=ans*i;
}
for(long i=M;i>0;i--){
    ans=ans/i;
}
return ans;
}

long Perm(long N,long M){// nPm
long ans=1;
for(long i=N;i>N-M;i--){
    ans=ans*i;
}
return ans;
}

long GCM(long A,long B){
            long W,r;
    if(A<B){

        W=B;
        B=A;
        A=W;
    }
    while(A%B!=0){
        r=A%B;
        A=B;
        B=r;
    }
    return B;
}
long LCM(long A,long B){
    return (A*B)/GCM(A,B);
}

long upDiv(long a,long b){
  return (a+b-1)/b;
}

long strtolong(string str){
istringstream ss;
ss=istringstream(str);
long num;
ss>>num;
return num;
}

long chartolong(char ch){
long num;
num=ch-'0';
return num;
}

long Max2(long a,long b){
if(a>b){
    return a;
}else{
    return b;
}
}

long Min2(long a,long b){
if(a>b){
    return b;
}else{
    return a;
}
}


string longtostr(long N){
    string str;
    str=to_string(N);
    return str;
}









/////////////////////////


//Answer


int main() {

long N,ans=0;
cin>>N;
for(long i=1;i<N;i++){
    ans+=(N-1)/i;
}
cout<<ans<<endl;

}



Measured memory_bytes: 237504
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    string S; cin >> S;
    if (S.size()==2) {
        cout << S << endl;
    }
    else {
        reverse(S.begin(),S.end());
        cout << S << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#define MAX 500000
#define NIL -1
using namespace std;

int H[MAX];

void print(int n) {
  for (int i = 0; i < n; i++) cout << " " << H[i];
  cout << endl;
}

int left(int i, int size) {
  int x = i + 1;
  if (x * 2 <= size) return x * 2 - 1;
  else return NIL;
}

int right(int i, int size) {
  int x = i + 1;
  if (x * 2 + 1 <= size) return x * 2;
  else return NIL;
}

void maxHeapify(int src, int size) {
  int l, r, largest;
  l = left(src, size);
  r = right(src, size);

  if (l != NIL && H[l] > H[src]) largest = l;
  else largest = src;

  if (r != NIL && H[r] > H[largest]) largest = r;

  if (largest != src) {
    swap(H[src], H[largest]);
    maxHeapify(largest, size);
  }
}

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

  for (i = 0; i < n; i++) cin >> H[i];
  for (i = n / 2; 0 <= i; i--) maxHeapify(i, n);
  print(n);

  return 0;
}



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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define repp(i, n) rep(i, n)
#define reppp(i, n) repp(i, n)
#define rrepp(i, n) rrep(i, n)
#define repss(i, n) reps(i, n)
#define repcc(i, n) repc(i, n)
#define repii(i, a, b) repi(i, a, b)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  string s;
  getline(cin, s);
  int n = s.size();
  for (int i = 0; i < n; i++) {
    if (i + 5 <= n) {
      if (s.substr(i, 5) == "apple") {
        rep(j, 5) s[i + j] = "peach"[j];
      } else if (s.substr(i, 5) == "peach") {
        rep(j, 5) s[i + j] = "apple"[j];
      }
    }
  }
  cout << s << '\n';
}



Measured memory_bytes: 3076
#include <algorithm>
#include <iostream>
#include <vector>
#include <cstdint>

using namespace std;

int main() {
  int H, W;
  cin >> H >> W;
  vector<int64_t> dp(W + 1, 0);
  dp[1] = 1;
  for (int h = 0; h < H; ++h) {
    string row;
    cin >> row;
    for (size_t w = 0; w < W; ++w) {
      if (row[w] == '#') {
        dp[w+1] = 0;
        continue;
      }
      if (dp[w] != 0) {
        if (dp[w+1] != 0) {
          dp[w+1] = (dp[w+1] + dp[w]) % 1000000007;
        } else {
          dp[w+1] = dp[w];
        }
      }
    }
  }
  cout << dp[W] << endl;

  return 0;
}


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

typedef long long ll;
#define forn(i,n) for (int i = 0; i < int(n); i++)

const int N = 1e5 + 10;

int n;
bool odd[N], rev[N], vis[N];
vector<int> adj[N];
vector<pair<int,int>> edge;

void dfs(int u) {
    vis[u] = true;
    for (auto idx : adj[u]) {
        auto &e  = edge[idx];
        int v = e.first + e.second - u;
        if (!vis[v]) {
            dfs(v);
            if (odd[v]) {
                odd[v] = !odd[v];
                odd[u] = !odd[u];
                rev[idx] = true;
            }
        }
    }
}

int main() {
    int m;
    cin >> n >> m;
    if (m%2) {
        cout << -1;
        return 0;
    }
    forn(i,m) {
        int u,v; cin >> u >> v;
        u--; v--;
        edge.emplace_back(u,v);
        adj[u].push_back(i);
        adj[v].push_back(i);
        odd[u] = !odd[u];
    }
    dfs(0);
    forn(i,m) {
        int u,v; tie(u,v) = edge[i];
        if (rev[i]) swap(u,v);
        cout << u+1 << ' ' << v+1 << '\n';
    }

    return 0;
}


Measured memory_bytes: 14196
#include <stdio.h>

int main(void){
    int num[100],i;
    double hvy[100],hight[100];
    for(i=0;scanf("%d,%lf,%lf",&num[i],&hvy[i],&hight[i])!=EOF;i++){
        if(hvy[i]/hight[i]/hight[i]>=25){
            printf("%d\n",num[i]);
        }
        
    }
    
    return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n,m) for(int (i)=(n);(i)<(m);(i)++)
#define esort(s) sort((s).begin(),(s).end())

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

const int INF = 1000000000;
const ll LINF = 1000000000000000000;
const double PI = acos(-1.0);
const double EPS = 1e-10;

void solve(){

    int N;
    string S;

    cin>>N;
    cin>>S;
    if(N%2==1) cout<<"No"<<endl;
    else
    {
        bool check=true;
        int n=N/2;
        rep(i,n){
            if(S[i]!=S[n+i]){
                check=false;
                break;
            }
        }
        if(check) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    return;
}

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

    solve();

    return 0;
}

Measured memory_bytes: 256
//is there any case of -1 or any special corner cases ?
#include<bits/stdc++.h>
using namespace std;
#define int long long int 
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define vi vector<int>
#define pi pair<int,int>
#define all(v) v.begin(),v.end()
#define zeros(arr) memset(arr,0,sizeof(arr));
#define precise(num)  cout<<fixed; cout << std::setprecision(num)
#define nl cout<<"\n";
#define test int t;cin>>t;while(t--) 
const int maxx  = 3*1e6 , limit = 9*1e18 , MOD=1e9+7;
string binary(int n){bitset<60>b(n) ;string p =b.to_string();return p;}
int decimal(string n) { int dec_value = 0;  int base = 1;  for (int i = n.size() - 1; i >= 0; i--) { if (n[i] == '1') 
dec_value += base; base = base * 2; } return dec_value; } 

bool isPrime(int n){if (n <= 1) return false; if (n <= 3) return true;if (n % 2 == 0 || n % 3 == 0) return false;
for (int i = 5; i * i <= n; i = i + 6) if (n % i == 0 || n % (i + 2) == 0) return false; return true; }
int pow (int x, int n,int mod) {if (n == 0) return 1; int res = pow (x, n / 2,mod);res = (res * res) % mod;if (n % 2) res = (res * x ) % mod;return res;}

#define boost  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n';

int32_t main(){
    long double a,b;
    cin>>a>>b;
    
    int res = a*b;
    cout<<res<<endl;
}

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

ll dp[110][2][110]; // 桁、N未満フラグ、出現する0以外の個数

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

    string s;
    int K;
    cin >> s >> K;

    rep(i,110){
        rep(j,2){
            rep(k,110) dp[i][j][k] = 0;
        }
    }
    dp[0][0][0] = 1;
    int n = s.size();
    for(int i = 0; i < n; i++){
        int D = s[i] - '0';
        for(int j = 0; j < 2; j++){
            for(int k = 0; k < 10; k++){
                for(int l = 0; l <= (j ? 9 : D); l++){
                    if(l != 0){
                        dp[i+1][j || (l < D)][k+1] += dp[i][j][k];
                    } else {
                        dp[i+1][j || (l < D)][k] += dp[i][j][k];
                    }
                }
            }
        }
    }
    cout << dp[n][1][K] + dp[n][0][K] << endl;
}



Measured memory_bytes: 512
def phi(n):
	r = n
	i = 2
	while i*i <= n:
		if n%i==0:
			r -= r/i
			while n%i==0:
				n /= i
		i += 1
	if n>1: r-= r/n
	return r

n = int(raw_input())
print phi(n)

Measured memory_bytes: 4208
function Main(input){
	input=input.split(/\s/);
	input.forEach(function(e,i,a){a[i]=Number(a[i]);});
	
	var ans="No";
	if(Math.abs(input[0]-input[2])<=input[3]){ans="Yes";}
	if(Math.abs(input[0]-input[1])<=input[3]&&Math.abs(input[1]-input[2])<=input[3]){ans="Yes";}
	
	console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
typedef long long ll;
typedef pair<ll,ll> P;



int main(){
    ll n;cin>>n;
    string s;cin>>s;
    ll rcn=0,wcn=0,fl=0;
    rep(i,0,n){

        if(s[i]=='R')rcn++;
    }

    ll an=rcn;
    rep(i,0,rcn){
        if(s[i]=='R')an--;
    }
    cout<<an<<endl;
}

    









Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
int main(void) {
    int n, x; cin >> n >> x;
    vector<int> L(n);
    rep(i, n) cin >> L[i];
    int sum = 0;
    int ans = 1;
    for(int i=0;i<n;i++) {
        sum += L[i];
        if(sum <= x)
        ans++;
    }
    cout << ans;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
        int day,q,N;
        cin >>N >> day >> q;
        int counter=0;
        for(int i=0 ; i<N ; i++ ){
                int x;cin >> x;
                counter+=((day-1)/x);
        }
        cout << counter+q+N << endl;
        return 0;
}

Measured memory_bytes: 256
#include <string.h>
#include <iostream>
#include <math.h>
using namespace std;
int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;

	if (A*B > C*D) {
		cout << A*B;
	}
	else {
		cout << C*D;
	}
	return 0;
}

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

int main() {
  int n,m;
  cin >> n >> m;
  vector<int> road(n);
  rep(i,m) {
    int a,b;
    cin >> a >> b;
    road.at(a-1)++;
    road.at(b-1)++;
  }
  rep(i,n)
   cout << road.at(i) << endl;
}


Measured memory_bytes: 256
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<string>
#include<utility>
#include<vector>
using namespace std;
//--------------------

int main() {

	string res = "No";
	long isused[100009] = {};
	string S; cin >> S;
	for (int i = 0; i < 4; i++) isused[int(S[i])]++;
	sort(isused, isused + 1000);

	if (isused[998] == 2 && isused[999] == 2) res = "Yes";

	cout << res << endl;
}

Measured memory_bytes: 1024
n,m = gets.split.map(&:to_i)
k = []
m.times do |i|
  d,*s = gets.split.map{|j|j.to_i - 1}
  k[i] = s
end
p = gets.split.map(&:to_i)
ans = 0

(0..n).each do |j|
  [*0...n].combination(j) do |num|
  ans += 1 if (0...m).all?{ |i| (k[i] & num).size % 2 == p[i] }
  end
end
    
puts ans

Measured memory_bytes: 2044
N = gets.to_i
As = [0] + gets.split.map(&:to_i) + [0]

s = As.each_cons(2).inject(0){|s, (x, y)| s + (y - x).abs}
(1 .. N).each{|i| puts s + (As[i+1] - As[i-1]).abs - (As[i] - As[i-1]).abs - (As[i+1] - As[i]).abs}

Measured memory_bytes: 12164
A, B, C, D = map(int, input().split())

if A<C:
  if B-C < 0:
    print(0)
  else:
    if D-B < 0:
      x = B-D
    else:
      x = 0
    print(B-C-x)
else:
  if D-A < 0:
    print(0)
  else:
    if B-D < 0:
      x = D-B
    else:
      x = 0
    print(D-A-x)


Measured memory_bytes: 38384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds; 
using ll = long long int;
#define INF             1e14
#define dd              double
#define MOD             1000000007
#define my_sizeof(type) ((char *)(&type+1)-(char*)(&type)) 
#define nl              cout<<endl
#define fill(a,val)     memset(a,val,sizeof(a))
#define mp              make_pair
#define endl            "\n"
#define pb              push_back
#define ff              first    
#define ss              second
#define SIZE            200005
#define all(v)          v.begin(),v.end()
#define s(ar,n)         sort(ar,ar+n)
#define rs(ar,n)        sort(ar, ar+n, greater<ll>()) 
#define oa(a,n)         for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n)         for(ll i=0;i<n;i++)cin>>a[i];
#define maxa(ar,N)      *max_element(ar,ar+N)
#define mina(ar,N)      *min_element(ar,ar+N)
#define fastio()        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define printclock      cerr<<"Time : "<<1000*(long double)clock()/(long double)CLOCKS_PER_SEC<<"ms\n";
typedef tree<pair<ll,ll>, null_type, less<pair<ll,ll>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// find_by_order() - 0 indexing
// order_of_key() - number of elements strictly smaller
ll power(ll x, ll y){
    ll res=1;x=x;
    while(y>0){
        if(y&1)
            res = (res*x);
        y = y>>1;
        x = (x*x);
    }
    return res;
}  
ll logtwo(ll n){
    if(n==1)
        return 0;
    return logtwo(n/2)+1;
}
//---------------------------------------GL HF------------------------------------------------------
// -------------------------------------ManavJ07----------------------------------------------------
ll N,K;
long double ar[200005];
bool check(long double mid){
	ll chances=0;
	for(int i=0;i<N;i++){
		long double cuts=ar[i]/mid;
		ll kk=cuts+5;
		while(kk*mid>=ar[i])
			kk--;
		chances+=kk;
	}
	return (chances<=K);
}
signed main()
{
	fastio();   
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
	int t=1;
	//cin>>t;
	while(t--)
	{
		cin>>N>>K;
		cn(ar,N);
		long double ans=1e12;
		long double low=0.0,high=1e12;
		while(low<=high){
			long double mid=(low+high)/2;
			if(check(mid)){
				high=mid-0.00000001;
				ans=mid;
			}
			else{
				low=mid+0.00000001;
			}
		}
		ll fin=max((long double)1,ans-10);
		while(check(fin)==false)
			fin++;
		cout<<fin<<endl;
	}
}

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

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define FORr(i, j, k) for(int i = j; i >= k; --i)
#define repr(i, j) FOR(i, j, 0)
#define INF (1 << 30)

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

const int MOD = 1e9 + 7;
const int dy[]={0, 0, 1, -1};
const int dx[]={1, -1, 0, 0};

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int main() {
	int N;
	scanf("%d", &N);
	int res = 0;
	int ans = 1;
	FOR(i, 1, N + 1) {
		int tmp = i, cnt = 0;
		while(1) {
			if(tmp % 2 == 0) ++cnt;
			else break;
			tmp /= 2;
			if(tmp == 0) break;
		} 
		if(res < cnt) {
			res = cnt;
			ans = i;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<stdio.h>
#include<stdlib.h>
using namespace std;

int main(){
  int x[100]={},top=0;
  char S[100];

  while( scanf("%s", S) != EOF){
    if ( S[0] == '+' ){
        x[top-2]=x[top-1]+x[top-2];
        top--;
    } 
    else if ( S[0] == '-' ){
        x[top-2]=x[top-2]-x[top-1];
        top--;
    } 
    else if ( S[0] == '*' ){
        x[top-2]=x[top-2]*x[top-1];
        top--;
    } 
    else {
        x[top] = atoi(S);
        top++;

    }
  }
    cout<<x[0]<<endl;
  return 0;
}



Measured memory_bytes: 3216
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
vector<int>in(3);
for(int i=0;i<3;i++)cin>>in[i];
sort(in.begin(),in.end());
cout<<in[0]<<" "<<in[1]<<" "<<in[2]<<endl;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    double R;
    const double PI=3.14159265358979323846;
    cin >> R;
    double ans = 2 * PI * R;
    printf("%.20lf\n", ans);
    return 0;
}

Measured memory_bytes: 3788
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

typedef map<int, pair<int, int> > Packet;

int main() {
    while (true) {
        int n, m;
        cin >> n >> m;
        if ((n | m) == 0) {
            break;
        }
        Packet packets;
        for (int i = 0; i < m; i++) {
            int t, s, d;
            cin >> t >> s >> d;
            packets.insert(make_pair(t, make_pair(s, d)));
        }
        vector<bool> isInfected(n + 1);
        fill(isInfected.begin(), isInfected.end(), false);
        isInfected[1] = true;
        int infectedNum = 1;
        for (Packet::iterator it = packets.begin(); it != packets.end(); it++) {
            if (isInfected[it->second.first] == true && isInfected[it->second.second] == false) {
                isInfected[it->second.second] = true;
                infectedNum++;
            }
        }
        cout << infectedNum << endl;
    }
}

Measured memory_bytes: 0
n = int(input())
w_ls = list(map(int, input().split()))

hoge = []

for i in range(n):
    a_sum = 0
    for j in range(i):
        a_sum = a_sum + w_ls[j]
    b_sum = 0
    for k in range(n-i):
        b_sum = b_sum + w_ls[n-k-1]
    hoge.append(abs(a_sum - b_sum))
print(min(hoge))

Measured memory_bytes: 3060
#include<stdio.h>

int main(void)
{
	int i,j,tmp,x[3000],y[3000];

	for(i=0;i<3000;i++){
		x[i] = 0;
		y[i] = 0;
	}

	i=0;
	scanf("%d %d",&x[i],&y[i]);	
	while(1){
		if(x[i] == 0 && y[i] == 0){
			break;
		}
		i++;
		scanf("%d %d",&x[i],&y[i]);
	}
	
	for(j=0;j<i;j++){
		if(x[j] > y[j]){
			printf("%d %d\n",y[j],x[j]);
		}else{
			printf("%d %d\n",x[j],y[j]);
		}
	}
	
	return 0;
}

Measured memory_bytes: 620
#![allow(dead_code,unused_variables)]
use proconio::{fastout, input};
const MOD : usize = 1_000_000_007;
#[fastout]
fn main() {
    input! {
        n: usize,
    }

    let mut add = pow(10,n,MOD) + pow(8,n,MOD);
    let sub = 2 * pow(9,n,MOD);
    while sub > add{
        add += MOD;
    }
    let ans = add - sub;
    println!("{}",ans%MOD);

}

fn pow(x : usize, k:usize ,md: usize) -> usize{
    let mut tmp = 1;
    let mut m = k;
    let mut d = x;
    while m > 0{
        if m&1 == 1{
            tmp = (tmp * d) % md;
        }
        d = (d * d) % md;
        m >>= 1;
    }
    tmp
}

Measured memory_bytes: 2160
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


int pre[11][1005];
int mm[11][1005];
int n,m,k;

signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);  
   
 #ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
 #endif
 
// -------------------------------------Code starts here---------------------------------------------------------------------     

    cin>>n>>m>>k;
    string a[n+1];
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }


    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(a[i][j]=='1')
                pre[i][j+1]=pre[i][j]+1;
            else
                pre[i][j+1]=pre[i][j];
        }
    }
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            mm[i][j]=mm[i-1][j]+pre[i][j];
    
    int lim=(1<<(n-1))-1;
    int ans=1e17;
    // cout<<lim<<" ";
        // cout<<mm[3][3]<<"\n";
    for(int i=0;i<=lim;i++)
    {
        vector<int>v;
        int z=i;
        int cnt=1;
        int lol=0;
        v.push_back(0);
        while (z!=0)
        {
            if(z%2)
            {
                v.push_back(cnt);
                lol++;
            }
            cnt++;
            z=(z>>1);
        }
        v.push_back(n);        
        int sz=v.size();
        int ini=1;
        int l=1;
        cnt=0;
        bool flag=true;

        for(int x=1;x<=m&&flag;x++)
        {
            int mx=0;
            for(int j=1;j<sz;j++)
            {
                mx=max(mx,mm[v[j]][x]-mm[v[j-1]][x]-mm[v[j]][ini-1]+mm[v[j-1]][ini-1]);
            }
            if(mx>k)
            {
               if(ini==x)
               {
                   flag=false;
                   break;
               }
               ini=x;
               x--;
               cnt++;
            }
        }
        if(flag)
        {
            ans=min(ans,cnt+lol);
        }
    }
    cout<<ans;

// -------------------------------------Code ends here------------------------------------------------------------------
     clock_t clk;
 	clk = clock();
 
    clk = clock() - clk;
 	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
 	return 0;
 }
 

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

n,k = na()
mod = 10**9+7

ans = 0

for i in range(k,n+2):
    a = (i*(i+1)//2)%mod
    b = (i*(2*n+3-i)//2)%mod
    ans = (ans+b-a+1)%mod

print(ans%mod)

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

using ll = long long;
const ll MOD = 1e9 + 7;

ll gcd(ll x, ll y) {
    if (y == 0) return x;
    return gcd(y, x % y);
}

int main() {
    ll A, B;
    cin >> A >> B;
    ll G = gcd(A, B);
    int ans = 1;
    for (ll i = 2; i * i <= G; i++) {
        if (G % i == 0) {
            ans++;
            while (G % i == 0) G /= i;
        }
    }
    if (G > 1) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 256
def resolve():
    n=int(input())
    x = [0] * n
    y = [0] * n
    ans=0
    t=1
    for i in range(1,n):
        t*=i
    for i in range(n):
        x[i], y[i] = map(int, input().split())
    for i in range(n):
        for j in range(i+1,n):
            ans+=((x[i]-x[j])**2+(y[i]-y[j])**2)**0.5
    print(2*ans/n)
resolve()

Measured memory_bytes: 38384
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
//Function
lli combi(lli n, lli r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
lli sigma1(lli n){return n*(n+1)/2;}
lli sigma2(lli s, lli n){return sigma1(n) - sigma1(s -1);}
using namespace std;
// }}} End Header

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	lli n, c, k;
	cin >> n >> c >> k;
	vector<lli> t(n);
	rep(i,n) cin >> t[i];
	sort(all(t));
	int cnt=1;
	lli ans=1;
	lli memo = t[0];
	loop(i, 1, n){
		if(t[i] <= memo+k && cnt<c){
			cnt++;
		}else{
			memo = t[i];
			cnt = 1;
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
package main

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

var nextString func() string

func init() {
	nextString = newReadString(os.Stdin)
}

func main() {
	s := nextString()
	dic := map[rune]bool{}

	for _, c := range s {
		if dic[c] {
			fmt.Println("no")
			return
		}
		dic[c] = true
	}
	fmt.Println("yes")
}

func nextInt() (result int) {
	result, _ = strconv.Atoi(nextString())
	return
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
		}
		return r.Text()
	}
}


Measured memory_bytes: 640
def main():
    n,m = map(int, input().split())
    h = list(map(int, input().split()))
    g = [0] * n
    for i in range(m):
        a,b =  map(int, input().split())
        if h[a-1] >= h[b-1]:
            g[b-1] += 1
        if h[b-1] >= h[a-1]:
            g[a-1] += 1
    ans = g.count(0)
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 85016
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    ll n;
    string s;
    cin>>n>>s;
    if(n%2==0){
        for(ll i=0;i<n/2;i++){
            if(s[i]!=s[i+n/2]) break;
            if(i==n/2-1){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<set>
using namespace std;
int main()
{
    long long hp,n,sum=0,a;
    cin>>hp>>n;
    for(long long i=0;i<n;i++)
    {
        cin>>a;
        sum=sum+a;
    }
    if(sum>=hp)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    int N, W;
    int i,j;
    int w,v;

    cin >> N >> W;
    long long dp[101][100001] = {};
    for(i = 1; i <= N; i++){
        cin >> w >> v;
        for(j = 0; j <= W; j++){
            dp[i][j] = dp[i-1][j];
            if(j >= w){
                dp[i][j] = max(dp[i][j], dp[i-1][j-w]+v); 
            }
        }
    }
    cout << dp[N][W] << endl;
}

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

int main() {

  long long N, M;
  cin >> N >> M;

  vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  sort(A.begin(), A.end());

  // --- M 通り以上の握手ができる最小の x を求める ---

  long long x = 0;
  long long ng = 100000 * N + 1;

  while (1 < ng - x) {

    long long mid = (x + ng) / 2;
    long long num = 0;

    for (int i = N - 1; 0 <= i; i--) {
      // Aの最後の要素番号 - （mid - A[i] 以上の要素のうちの最小の要素番号）
      num += A.end() - lower_bound(A.begin(), A.end(), mid - A[i]);
    }

    // num が M 以上の場合は、X を詰める
    // その逆の場合は、NG を詰める
    if (M <= num) {
      x = mid;
    } else {
      ng = mid;
    }

  }

  // --- 幸福度の計算 ---

  // 累積和であらかじめ集計しておく
  vector<long long> SUM(N + 1);
  for (int i = 0; i < N; i++) {
    SUM[i + 1] = SUM[i] + A[i];
  }

  long long answer = 0;
  long long count = 0;

  // x を超える幸福度を計算する
  // 左手で握手する人を A[i] とする
  for (int i = 0; i < N; i++) {

    // x - A[i] を超える要素のうち最小の要素を返す
    long long v = upper_bound(A.begin(), A.end(), x - A[i]) - A.begin();
    
    // 握手をする回数
    count += N - v;
    
    // 左手の幸福度は回数 * A[i] を掛ける、右手の幸福度は累積和から計算
    answer += A[i] * (N - v) + SUM[N] - SUM[v];
    
  }

  // M - count で残りがあれば、それはすべて x となるパターン 
  answer += x * (M - count);

  cout << answer << endl;

}

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

int main() {
  int n;
  cin >> n;
  vector<int> x(n);
  vector<int> y(n);
  vector<int> h(n);
  for (int i=0; i<n; i++){
    cin >> x.at(i) >> y.at(i) >> h.at(i);
  }
  
  int H;
  
  bool finished = false;
  
  for (int X=0; X<=100; X++){
    for (int Y=0; Y<=100; Y++){
      bool ans = true;
      for (int i=0; i<n; i++){
        if (h.at(i)>0){
          H = h.at(i) + abs(x.at(i)-X) + abs(y.at(i)-Y);
          break;
        }
      }
      
      for (int i=0; i<n; i++){
        if (h.at(i) != max(H-abs(x.at(i)-X)-abs(y.at(i)-Y), 0)){
          ans = false;
          break;
        }
      }
 
    if(ans){
      cout << X << " " << Y << " " << H <<endl;
      finished = true;
      break;
    }
    }  
  if(finished){
    break;
  }
  }
  return 0;
}

Measured memory_bytes: 256
from operator import itemgetter


N, M = [int(v) for v in input().split()]
pairs = []
for i in range(N):
    pairs.append([int(v) for v in input().split()])
pairs.sort(key=itemgetter(0))

ans = 0
cnt = 0
for a, b in pairs:
    if cnt + b <= M:
        ans += a * b
        cnt += b
    else:
        ans += a * (M - cnt)
        cnt += M - cnt

    if cnt >= M:
        break

print(ans)


Measured memory_bytes: 22824
#include<iostream>
#include<utility>
#include<algorithm>
#define INF 1000000000
using namespace std;

typedef pair<int, int> point;
point pinf = point(INF, INF);
int win[100][100], pic[50][50], n, m;

point match(int sx, int sy)
{
  bool b[] = {true, true, true, true};
  int p[4][2] = {{-1, -1}, {-1, -1}, {-1, -1}, {-1, -1}};
  for(int y = 0; y < m; y++)
  {
    for(int x = 0; x < m; x++)
    {
      int t[] = {pic[y][x], pic[x][m - y - 1], pic[m - x - 1][y], pic[m - y - 1][m - x - 1]};
      for(int i = 0; i < 4; i++)
      {
        if(t[i] == -1)
          continue;
        if(p[i][0] == -1)
        {
          p[i][0] = sx + x;
          p[i][1] = sy + y;
        }
        if(win[sy + y][sx + x] != t[i])
          b[i] = false;
      }
    }
  }
  point mp = pinf;
  for(int i = 0; i < 4; i++)
    if(b[i])
      mp = min(mp, point(p[i][1], p[i][0]));
  return mp;
}

int main()
{
loop:
  cin >> n >> m;
  if(!n)
    return 0;
  int tmp;
  for(int y = 0; y < n; y++)
  {
    for(int x = 0; x < n; x++)
    {
      cin >> tmp;
      win[y][x] = tmp;
    }
  }
  for(int y = 0; y < m; y++)
  {
    for(int x = 0; x < m; x++)
    {
      cin >> tmp;
      pic[y][x] = tmp;
    }
  }
  point p = pinf;
  for(int y = 0; y <= n - m; y++)
    for(int x = 0; x <= n - m; x++)
      p = min(p, match(x, y));
  if(p == pinf)
    cout << "NA" << endl;
  else
    cout << p.second + 1 << " " << p.first + 1 << endl;
  goto loop;
}

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

int main()
{
  string s; cin >> s;
  string ans = "";
  for (auto &&c : s)
  {
    if (c == '1')
    {
      ans.push_back('1');
    }
    if (c == '0')
    {
      ans.push_back('0');
    }
    if (c == 'B' && !ans.empty())
    {
      ans.pop_back();
    }
    
  }
  cout << ans << endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>

#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define pii pair<int,int>
#define pll pair<ll, ll>
#define vec vector<int>
#define vecll vector<ll>

using namespace std;
///////////////////////////////////////////////////////////



int main() {
    int a, b, n;
    cin >> a >> b;

    if (a >= b) {
        n = a;
        rep(i,n)
            cout << b;
    } else {
        n = b;
        rep(i,n)
            cout << a;
    }
    cout << endl;


    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int m,f,r,i,j;
  while(scanf("%d %d %d",&m,&f,&r)){
    if(m==-1 && f==-1){
      if(r==-1)break;
    }
    if(m==-1 || f==-1)printf("F\n");
    else if(m+f>=80)printf("A\n");
    else if(m+f>=65 && m+f<80)printf("B\n");
    else if(m+f>=50 && m+f<65)printf("C\n");
    else if(m+f>=30 && m+f<50){
      if(r>=50)printf("C\n");
      else printf("D\n");
    }
    else if(m+f<30)printf("F\n");
  }
  return 0;
}

Measured memory_bytes: 584
#include<stdio.h>
int main()
{
    long long w1,w2,h,N,n,count;
    count=0;
    scanf("%lld",&N);
    for (h=1; h<=3500; h++)
    {
        for (n=1; n<=3500; n++)
        {
            w1=N*h*n;
            w2=4*n*h-h*N-N*n;
            if(w1>0&&w2>0&&w1%w2==0)
            {
                printf("%lld %lld %lld",h,n,w1/w2);
                count++;
                break;
            }
        }
        if (count!=0)
            break;
    }
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define bitsz(x) int(__builtin_popcount(x))
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
#define mod 1000000007
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
typedef long long ll;
typedef pair<int, int> P;
const int di[4] = {1,0,-1,0};
const int dj[4] = {0,1,0,-1};


int main() {
    int n; cin >> n;
    int ans = n/2;
    if (n%2==1) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 3628
N = int(input())
A_lis = [int(input()) for i in range(N)]
A_lis_sort = sorted(enumerate(A_lis),key = lambda x:x[1])
max_index = A_lis_sort[-1][0] 
for i in range(N):
  if i == max_index:
    print(A_lis_sort[-2][1])
  else:
    print(A_lis_sort[-1][1])

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;

template<typename A,typename B> inline void chmin(A &a,B b){if(a>b) a=b;}
template<typename A,typename B> inline void chmax(A &a,B b){if(a<b) a=b;}
//-----------------------------------------------------------------------

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

    int m; cin>>m;
    while(m--)
    {
        string s; cin>>s;
        set<string> st;
        for(int i=1;i<s.size();i++){
            string L1,R1,L2,R2;
            L1=L2=s.substr(0,i);
            R1=R2=s.substr(i);
            reverse(ALL(L2)); reverse(ALL(R2));
            st.insert(L1+R1); st.insert(R1+L1);
            st.insert(L1+R2); st.insert(R2+L1);
            st.insert(L2+R1); st.insert(R1+L2);
            st.insert(L2+R2); st.insert(R2+L2);
        }
        cout<<st.size()<<endl;
    }
}

Measured memory_bytes: 3196