akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
template<typename T>
void chmax(T& a, T b) {
	a = max(a, b);
}

template<typename T>
void chmin(T& a, T b) {
	a = min(a, b);
}

template<typename T>
void IN(vector<T> &A,int N=-1) {
	if (N == -1) {
		N = A.size();
	}
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
}

template<typename T>
void SO(vector<T> &A,bool F=false) {
	sort(A.begin(), A.end());
	if (F) {
		reverse(A.begin(), A.end());
	}
}
//////////////

void solve() {
	int N,T;
	cin >> N >> T;
	vector<LL> A(N);
	IN(A);
	
	LL mSA = 0;
	LL MIN = A[0];
	vector<LL> P(N, 0);
	for (int i = 0; i < N; ++i) {
		chmin(MIN, A[i]);
		P[i] = max(P[i],A[i] - MIN);
	}
	SO(P);
	int cnt = lower_bound(P.begin(), P.end(), P[N - 1]) - P.begin();
	int ans = (N - cnt);
	cout << ans << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}

Measured memory_bytes: 1792
#include <iostream>
#include <queue>
#include <vector>
#define MAX 1000

using namespace std;

const int INF = 1000000;

typedef pair<int,int> P;

int n,m;
char cheese[MAX+1][MAX+1];
 
int bfs(int sy,int sx,int gy,int gx){
    
  int dx[4]={1,0,-1,0};
  int dy[4]={0,1,0,-1};
  int d[MAX][MAX];
  queue<P> q;
     
    for( int i = 0 ; i < n ; i++ )
        for( int j = 0 ; j < m ; j++ )
            d[i][j] = INF;
     
    q.push( P(sy , sx) );
    d[sy][sx] = 0;
     
    while( q.size() ){
        P p = q.front(); 
	q.pop();

        if(p.first == gy && p.second == gx) break;
	
        for(int i = 0 ; i < 4 ; i++){
	  int x = p.first + dx[i];
	  int y = p.second + dy[i];
          
	  if( 0 <= x && x < n &&
	      0 <= y && y < m &&
	      d[x][y] == INF &&
	      cheese[x][y]!='X'){
	    q.push( P(x , y) );
	    d[x][y] = d[p.first][p.second] + 1;
	  }
        }
    }
    
    return d[gy][gx];
}

int main(void){

    int num;
 
    cin >> n >> m >> num;
    vector<P> v(num + 1);
     
    for( int i = 0 ; i < n ; i++ ){
        for( int j = 0 ; j < m ; j++ ){
            cin >> cheese[i][j];
            if( cheese[i][j]=='S'){
                v[0].first = i;
                v[0].second = j;
            }
            if('1' <= cheese[i][j] && cheese[i][j] <= '9'){
                v[cheese[i][j]-'0'].first = i;
                v[cheese[i][j]-'0'].second = j;
            }
        }
    }
     
    int sum = 0;
    for(int i = 1 ; i < num+1 ; i++){
        sum += bfs(v[i-1].first,v[i-1].second,v[i].first,v[i].second);
    }
    cout << sum << endl;
     
    return 0;
}

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

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n, m, k;
    cin >> n >> m >> k;
    char s[n + 1][m + 1];
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            cin >> s[i][j];
        }
    }
    int ans = 0;
    for(int i = 0; i <= (1 << n ) - 1; i++){
        for(int j = 0; j <= (1 << m) - 1; j++){
            int sum = 0;
            for(int k = 1; k <= n; k++){
                for(int l = 1; l <= m; l++){
                    if(!((i >> (k - 1)) & 1) && !((j >> (l - 1)) & 1)){
                        if(s[k][l] == '#'){
                            sum++;
                        }
                    }
                }
            }
            if(sum == k){
                ans++;
            }
        }
    }
    cout << ans;
}

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

typedef pair<int, int> P;

vector<P> BubbleSort(vector<P> c, int n) {
  for ( int i = 0; i < n; i++ ) {
    for ( int j = n-1; j >= i+1; j-- ) {
      if ( c[j].first < c[j-1].first ) {
	swap(c[j], c[j-1]);
      }
    }
  }

  return c;
}

vector<P> SelectionSort(vector<P> c, int n) {
  for ( int i = 0; i < n; i++ ) {
    int minj = i;
    for ( int j = i; j < n; j++ ) {
      if ( c[j].first < c[minj].first ) {
	minj = j;
      }
    }
    swap(c[i], c[minj]);
  }

  return c;
}

signed main() {
  int n;
  cin >> n;
  
  vector<P> a(n);
  vector<string> ori(n);
  for ( int i = 0; i < n; i++ ) {
    string s;   
    cin >> s;
    ori[i] = s;
    a[i] = P(s[1]-'0', i);    
  }

  vector<P> bs = BubbleSort(a, n);
  vector<P> ss = SelectionSort(a, n);
  sort(a.begin(), a.end());

  for ( int i = 0; i < n; i++ ) {
    if ( i ) cout << " ";
    cout << ori[bs[i].second];
  }
  cout << endl;

  if ( a == bs ) cout << "Stable" << endl;
  else cout << "Not stable" << endl;

  for ( int i = 0; i < n; i++ ) {
    if ( i ) cout << " ";
    cout << ori[ss[i].second];
  }
  cout << endl;

  if ( a == ss ) cout << "Stable" << endl;
  else cout << "Not stable" << endl;
  
  return 0;
}



Measured memory_bytes: 3180
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
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; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main() {
  string s,ss,sss,ssss;
  cin >> s;
  rep(i, s.size()) {
    if (i <= 4) {
      ss += s[i];
    }
    if (i >= 6 && i <= 12) {
      sss += s[i];
    }
    if (i >= 14) {
      ssss += s[i];
    }
  }
  cout << ss << " " << sss << " " << ssss << "\n";
}


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

using namespace std;

typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldbl;
typedef pair<int, int> pii;
typedef pair<uint, uint> puu;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<uint> vu;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pii> vpii;
typedef vector<puu> vpuu;
typedef vector<pll> vpll;
typedef vector<pull> vpull;
typedef vector<string> vstr;
typedef vector<double> vdbl;
typedef vector<ldbl> vldbl;
#define pb push_back
#define ppb pop_back
#define pfr push_front
#define ppfr pop_front
#define emp emplace
#define empb emplace_back
#define be begin
#define rbe rbegin
#define all(x) (x).be(), (x).end()
#define rall(x) (x).rbe(), (x).rend()
#define fir first
#define sec second
#define mkp make_pair
#define brif(cond) if (cond) break
#define ctif(cond) if (cond) continue
#define retif(cond) if (cond) return
void canhazfast() {ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);}
template<typename T> T gcd(T a, T b) {return b ? gcd(b, a%b) : a;}
template<typename T> T extgcd(T a, T b, T &x, T &y)
{
    T x0 = 1, y0 = 0, x1 = 0, y1 = 1;
    while (b) {
        T q = a/b; a %= b; swap(a, b);
        x0 -= q*x1; swap(x0, x1);
        y0 -= q*y1; swap(y0, y1);
    }
    x = x0; y = y0; return a;
}
int ctz(uint x) {return __builtin_ctz(x);}
int ctzll(ull x) {return __builtin_ctzll(x);}
int clz(uint x) {return __builtin_clz(x);}
int clzll(ull x) {return __builtin_clzll(x);}
int popcnt(uint x) {return __builtin_popcount(x);}
int popcntll(ull x) {return __builtin_popcountll(x);}
int bsr(uint x) {return 31^clz(x);}
int bsrll(ull x) {return 63^clzll(x);}

int x[16][16];

bool is_square(int x)
{
    int r = (int)sqrt(x);
    return r*r == x;
}

int main()
{
    canhazfast();

    int n, d, ans = 0;

    cin >> n >> d;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < d; ++j) cin >> x[i][j];
        for (int j = 0; j < i; ++j) {
            int ss = 0;
            for (int k = 0; k < d; ++k) {
                int v = x[i][k]-x[j][k];
                ss += v*v;
            }
            if (is_square(ss)) ++ ans;
        }
    }
    cout << ans << '\n';

    return 0;
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = (int)(n); i >= 0; i--)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define repmr(i, m, n) for(int i = (int)(n); i >= (int)(m); i--)
#define all(x) (x).begin(),(x).end()
#define inf 2e9

using namespace std;
typedef long long int lli;
typedef long long ll;

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

    s[3] = '8';
    cout << s << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority_queue
#include<deque>//double_ended queue
using namespace std;
typedef pair<int,int> P;//Pでpair<-,->を表す。
typedef long long LL; 
LL MOD=1000000007;

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

Measured memory_bytes: 256
def gcd(a, b):
    while(b > 0):
        a = a%b
        c = b
        b = a
        a = c
    return a

n = int(input())
s = input()

s = s.split(" ")
# for i s:
#     x = int(input())
#     arr.append(x)

l = int(s[0])

for i in range(1, n):
    l = (l*int(s[i]))//gcd(l, int(s[i]))

ans = 0
for x in s:
    x = int(x)
    ans += l//x

print(ans%1000000007)




Measured memory_bytes: 3700
#include "bits/stdc++.h"
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP0(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define RREP0(i,n) for(int i=n-1; i>=0; --i)
#define RREP1(i,n) for(int i=n; i>=1; --i)
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define FILL(c, v) fill((c).begin(),(c).end(), v)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define CLR(a) memset((a), 0 ,sizeof(a))

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long LL;
typedef unsigned long long ULL;

const int INTINF = 2147483647;
const LL LLINF = 9223372036854775807;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int cities[9][2];

double dist(int i, int j)
{
    double dx2 = pow(cities[i][0] - cities[j][0], 2);
    double dy2 = pow(cities[i][1] - cities[j][1], 2);
    double dist = sqrt(dx2 + dy2);
    return dist;
}


void solve()
{
  int N; cin >> N;
  int fact_N = 1;
  vector<int> indices(N);
  double sum = 0.0;

  REP1(i, N)
  {
      fact_N *= i;
      cin >> cities[i][0] >> cities[i][1];
      indices[i-1] = i;
  }
  
  do {
      REP0(i, N-1) sum += dist( indices[i], indices[i+1] );
  } while (next_permutation(indices.begin(), indices.end()));
  
  cout << (sum / fact_N) << endl;
}

int main(int argc, char const *argv[])
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  std::cout<<std::fixed<<std::setprecision(10);
  solve();
  return 0;
}

Measured memory_bytes: 256
a,b = map(int,input().split())
count1 = 0
count2 = 0

for i in range(a):
  for j in range(a-1):
    count1 = count1 + 1
for l in range(b):
  for m in range(b-1):
    count2 = count2 + 1
print((count1+count2)//2)

Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	char n;
	cin >> n;
	if ('a' <= n && n <= 'z') {
		cout << 'a' << endl;
	}
	else {
		cout << 'A' << endl;
	}
}

Measured memory_bytes: 3592
import java.util.Scanner;

/**
 * Main<br/>
 *
 * @author Tomo
 * @see <http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_D&lang=ja>
 */
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int n = Integer.parseInt(sc.next());

    int r0 = Integer.parseInt(sc.next());
    int r1 = Integer.parseInt(sc.next());

    int max = r1 - r0;
    int min = Math.min(r0, r1);

    for (int i = 2; i < n; i++) {
      int r = Integer.parseInt(sc.next());
      max = Math.max(max, r - min);
      min = Math.min(min, r);
    }

    System.out.println(max);
  }
}



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

vector<int>adj[200001];
int vis[200001];
int mx = 0,cnt=0;

void dfs(int s){
	cnt++;
    vis[s]=1;
    //cout<<s<<" ";
    for(auto it = adj[s].begin();it!=adj[s].end();++it){
        if(vis[*it]==0){
            vis[*it]=1;
            dfs(*it);
        }
    }
    mx=max(mx,cnt);
}

int32_t main(){
    #ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m,u,v;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    for(int i=1;i<=n;i++){
    	if(vis[i]==0){
    		dfs(i);
    		cnt=0;
    	}
    }
    cout<<mx;
    return 0;
}


Measured memory_bytes: 22300
#include <bits/stdc++.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
//int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
//int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//const ll MOD = 1000000007;
const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'


signed main() {
    fio();
    string s;
    cin >> s;
    rep (i, s.size()) {
        if (s[i] == '?') {
            cout << 'D';
        }
        else {
            cout << s[i];
        }
    }   
    cout << endl;
}

Measured memory_bytes: 3748
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();

    if ((a < 0 && 0 < b) || (a == 0 || b == 0)) {
      System.out.println("Zero");
    } else if (a < 0 && b < 0 && (Math.abs(a - b) % 2 == 0)) {
      System.out.println("Negative");
    } else {
      System.out.println("Positive");
    }

  }
}

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

int main() {
  string S,T;
  int N,answer,i,now=0;
  cin >> N;
  int *A = new int[N];
  int *B = new int[N];
  int *C = new int[N-1];

  for ( i = 0; i < N; i++)
  {
    cin >> A[i];
  }
  for ( i = 0; i < N; i++)
  {
    cin >> B[i];
  }
  for ( i = 0; i < N-1; i++)
  {
    cin >> C[i];
  }

  for ( i = 0; i < N; i++)
  {
    answer+=B[A[i]-1];
    if (i==0)
    {
      continue;
    }
    if (A[i]==A[i-1]+1)
    {
      answer+=C[A[i-1]-1];
    }
  }
  
  cout << answer << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] h = new int[N];
    int count =0;
    for (int i =0; i<N; i++) {
      h[i] = sc.nextInt();
    }
    
    int a =0; int b=0;
    L:while (a<= N-1 && b<= N-1) {
      if (h[a] ==0) {
        a++;
        continue;
      }
      //aを決定
      b = a;
      while (b <= N-1) {
        if (h[b] !=0 && b != N -1) {
          b++;
          continue;
        } else {
          for (int i =a; i<=b; i++) {
            h[i]--;
            if (h[i] <0) {
              h[i] =0;
            }
          }
        }
        count++;
        continue L;
      }
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 36000
#include<iostream>
using namespace std;
const int N=2e5 + 10;
int a[N];
int main(){
	int n ;
	cin >> n ;
	for(int i = 1;i<n;i++)
	{
	    int t ;
	    cin >> t;
	    a[t]++;
	}
	for(int i = 1;i <= n;i++)	 cout<<a[i]<<endl;
	return 0 ;
}

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

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

int main() {
    int n, k, q;
    cin >> n >> k >> q;
    V<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    V<int> a_buf = a;
    V<int> idx(n);
    iota(begin(idx), end(idx), 0);
    sort(begin(idx), end(idx), [&](int x, int y){
        return a[x] < a[y];
    });
    
    int ans = TEN(9)+TEN(7);
    V<bool> vis(n, true);
    for (int s: idx) {
        a = a_buf;
        int l = 0;
        V<int> v;        
        while (l < n) {
            if (!vis[l]) {
                l++;
                continue;
            }
            int r = l+1;
            while (r < n && vis[r]) r++;
            sort(begin(a)+l, begin(a)+r);
            for (int i = 0; i < r-l-(k-1); i++) {
                v.push_back(a[l+i]);
            }
            l = r;
        }
        vis[s] = false;
        sort(begin(v), end(v));
        if (int(v.size()) < q) continue;
        ans = min(ans, v[q-1] - a_buf[s]);
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
	int  n;
	cin >> n;
	vector<int> a(n);
	rep(i,n) cin >> a[i];
	int counts = 0;
	int sa = 0;
	rep(i,n){
		a[i] += sa;
		if(a[i] == i+1) continue;
		else{
			counts++;
			sa++;
		}
	}
	if(counts == n) cout << -1 << endl;
	else cout << counts << endl;
}

Measured memory_bytes: 4024
#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn main() {
    let n: usize =  {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let s = s.trim_right().to_owned();
        s.parse().unwrap()
    };

    let mut v: Vec<usize> = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let s = s.trim_right().to_owned();
        s.split_whitespace().map(|x| x.parse().unwrap()).collect()
    };

    v.sort();

    let mut count = 0;
    for a_i in 0..n {
        let mut right = a_i + 1;
        for left in a_i+1..n {
            while right + 1 < n && v[right + 1] < v[a_i] + v[left] {
                right += 1;
            }
            count += right - left;
            if right == left {
                right += 1;
            }
        }
    }

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


Measured memory_bytes: 4352
@a, @b, @c = gets.split.map(&:to_i)

@flg = true

def t
  if @flg
    if @a % 2 != 0
      @a = @a - 1
    end
    @a = @a / 2
    @b = @b + @a
  else
    if @b % 2 != 0
      @b = @b - 1
    end
    @b = @b / 2
    @a = @a + @b
  end
end

while @c > 0
  @c = @c - 1
  t
  @flg = !@flg
end

puts "#{@a} #{@b}"

Measured memory_bytes: 1788
import java.util.Arrays;
import java.util.*;
public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int i,m;
      int count = 0;
      int total = 0;
      for(i=1;i<=n;i+=2,count=0){
        for(m=1;m<=i;m++){
          if(i%m==0){
            count++;
          }
        }
        if(count==8){
          total++;
        }
      }
      
      System.out.println(total);
  }
}


Measured memory_bytes: 21588
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def main():
	#a = int(input())
	n, k = tin()
	#s = input()
	al = lin()
	cl=lin()
	dd=[0]*n
	for i in range(n):
		if dd[i]!=0:
			continue
		cc=set()
		pos = i
		point=0
		n_node=0
		while pos not in cc:
			cc.add(pos)
			pos=al[pos]-1
			point+=cl[pos]
			n_node+=1
			
		for p in cc:
			dd[p] = (point, n_node)
	
	ret=-mod*mod
	for i in range(n):
		pi, ni = dd[i]
		if pi < 0:
			point=0
			pmax=-mod*mod
			pos=i
			for _ in range(ni):
				cc.add(pos)
				pos=al[pos]-1
				point+=cl[pos]
				pmax = max(pmax, point)
			ret = max(ret, pmax)
		elif k < ni*2:
			point=0
			pmax=-mod*mod
			pos=i
			for _ in range(k):
				cc.add(pos)
				pos=al[pos]-1
				point+=cl[pos]
				pmax = max(pmax, point)
			ret = max(ret, pmax)
		else:
			point = pi*((k//ni)-1)
			nk=k%(ni) + ni
			pos = i
			pmax = point
			for _ in range(nk):
				cc.add(pos)
				pos=al[pos]-1
				point+=cl[pos]
				pmax = max(point, pmax)
			ret = max(ret, pmax)
	return ret
		
		
			
	
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 69300
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
using namespace std;

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

template <typename T>
T lcm(T a, T b) {
    T g = gcd(a, b);
    return a / g * b;
}

int main(){

    int H, W;
    cin >> H >> W;
    vector<vector<char>> a(H + 2, vector<char>(W + 2, '#'));
    for(int i = 1; i <= H; i++){
        for(int j = 1; j <= W; j++){
            cin >> a[i][j];
        }
    }

    for(int i = 0; i < a.size(); i++){
        for(int j = 0; j < a[i].size(); j++){
            cout << a[i][j];
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int> A(N);
  for(int i=0;i<N;i++) {
    cin>>A.at(i);
  }
  sort(A.begin(),A.end());
  string ans="YES";
  for(int i=0;i<N-1;i++) {
    if(A.at(i)==A.at(i+1)){
      ans="NO";
      break;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    string S;
    cin >> S;
    rep(i,S.size())cout << "x" ;
    cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int INF = 100000;
int dp[100005];
int f(int n){
	//cout<<n<<'\n';
	int&ret = dp[n];
	if(~ret) return ret;
	ret = INF;
	for(int i=6; i<=n; i*=6) ret = min(ret,f(n-i)+1);
	for(int i=9; i<=n; i*=9) ret = min(ret,f(n-i)+1);
	ret = min(ret,f(n-1)+1);
	return ret;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	memset(dp,-1,sizeof(dp));
	dp[1] = 1;
	dp[0] = 0;
	for(int i=6; i<=INF; i*=6) dp[i] = 1;
	for(int i=9; i<=INF; i*=9) dp[i] = 1;
	int n;
	cin>>n;
	cout<<f(n);
}

Measured memory_bytes: 4724
import itertools

n,k=map(int,input().split())
d=list(input())
x=[]
ans=float('inf')

for i in range(10):
  if str(i) not in d:
    x.append(str(i))
    
for i in range(1,6):
  for lst in itertools.product(x,repeat=i):
    if int(''.join(lst))>=n:
      ans=min(ans,int(''.join(lst)))
      

print(ans)

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

using namespace std;

#define eb emplace_back
#define ii pair<int, int>
#define OK (cerr << "OK" << endl)
#define debug(x) cerr << #x " = " << (x) << endl
#define ff first
#define ss second
#define int long long
#define tt tuple<int, int, int>
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vii vector<pair<int, int>>
#define vvi vector<vector<int>>
#define vvii vector<vector<pair<int, int>>>
#define Mat(n, m, v) vector<vector<int>>(n, vector<int>(m, v))
#define endl '\n'

// constexpr int INF = 2e18;
constexpr int MOD = 1e9 + 7;
constexpr int MAXN = 1E6 + 3;

int dp[MAXN][2][2];

int f(int idx, int z, int n) {
  if (idx == 0) {
    return (z && n);
  }

  int &ret = dp[idx][z][n];
  if (~ret)
    return ret;

  ret = 0;
  ret += f(idx - 1, 1, n);
  ret %= MOD;
  ret += f(idx - 1, z, 1);
  ret %= MOD;
  ret += 8 * f(idx - 1, z, n);
  ret %= MOD;
  return ret;
}

// #define MULTIPLE_TEST_CASES
void solve() {
  memset(dp, -1, sizeof dp);
  int n;
  cin >> n;

  cout << f(n, 0, 0) << endl;
}

signed main() {
  // freopen(".in", "r", stdin);
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr), cout.tie(nullptr);

  int t = 1;
#ifdef MULTIPLE_TEST_CASES
  cin >> t;
#endif
  while (t--)
    solve();
}

Measured memory_bytes: 97212
def main():
    N = int(input())
    A = [int(x) for x in input().split()]
    B = [int(x) for x in input().split()]
    C = [int(x) for x in input().split()]
    ans = sum(B)
    k = -1
    for i in A:
        if i == k + 1:
            ans += C[k-1]
        k = i
    print(ans)


if __name__ == "__main__":
    main()


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

int main() {
    int X;
    cin >> X;
    X--;
    while (true){
        X++;
      	bool A=true;
        for (int i=2 ; i<X ; i++){
            if (X%i==0)
                A=false;
        }
    if (A)
    break;
    }
    cout << X << endl; 
}

Measured memory_bytes: 256
def main():
    """"ここに今までのコード"""
    import sys
    read = sys.stdin.buffer.read
    readline = sys.stdin.buffer.readline
    readlines = sys.stdin.buffer.readlines

    n = int(readline())
    data = tuple(map(int,read().split()))
    m1 = data[0]
    ab = data[1:1+2*m1]
    m2 = data[1+2*m1]
    cd = data[2+2*m1:2+2*(m1+m2)]
    m3 = data[2+2*(m1+m2)]
    ef = data[3+2*(m1+m2):]

    mod = 998244353
    mods = [1] * (n+10)
    base = pow(10,18,mod)
    for i in range(1,n+1):
        mods[i] = (mods[i-1] * base)%mod

    def calc_node(xy):
        links = [[] for _ in range(n+1)]
        it = iter(xy)
        for x,y in zip(it,it):
            if(x < y):
                x,y = y,x
            links[y].append(x)

        group = [-1] * (n+1)
        g_bit = [0] * (n+1)
        group[-1] = 0
        g_bit[-1] = 1
        num_max = 1
        for i in range(n,0,-1):
            tmp = 0
            for j in links[i]:
                tmp |= g_bit[j]
            cnt = 0
            while(tmp&1):
                tmp = tmp>>1
                cnt+=1
            group[i] = cnt
            g_bit[i] = 1 << cnt
            num_max = max(num_max,cnt)

        res = [0] * (num_max+1)
        for i,num in enumerate(group[1:],1):
            res[num] += mods[i]
            res[num] %= mod

        return res

    x = calc_node(ab)
    y = calc_node(cd)
    z = calc_node(ef)

    if(len(x) < len(y)):
        x,y = y,x
    if(len(y) < len(z)):
        y,z = z,y
    if(len(x) < len(y)):
        x,y = y,x


    len_2 = 2**(len(y)-1).bit_length()
    yz = [0] * (len_2)
    for j in range(len(y)):
        for k in range(len(z)):
            yz[j^k] += y[j]*z[k]
            yz[j^k] %= mod

    ans = 0
    for i,j in zip(x,yz):
        ans += i*j
        ans %= mod

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 123248
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define MOD 1000000007

vector<vector<ll>> dp(3010, vector<ll>(3010));
int main() {
	int N;
	string s;
	cin >> N >> s;
	rep(i,N) {
		dp[0][i] = 1;
	}
	ll acc[N];
	rep(i,N) {
		if(i==0) acc[i] = dp[0][i];
		else acc[i] = dp[0][i] + acc[i-1];
	}
	for(int i=1; i<N; i++) {
		if(s[i-1] == '<') {
			rep(j,N-i) {
				dp[i][j] = (acc[N-i] - acc[j] + MOD) % MOD;
				/*for(int k=j+1; k<=N-i+1; k++) {
					dp[i][j] = (dp[i][j]+dp[i-1][k]) % MOD;
				}*/
			}
		}
		else {
			rep(j,N-i) {
				dp[i][j] = acc[j];
				/*rep(k,j+1) {
					dp[i][j] = (dp[i][j] + dp[i-1][k]) % MOD;
				}*/
			}
		}
		rep(j,N-i) {
			if(j == 0) acc[j] = dp[i][j];
			else acc[j] = (acc[j-1] + dp[i][j]) % MOD;
		}
	}
	/*rep(i,N) {
		rep(j,N) cout << setw(3) << dp[i][j];
		cout << endl;
	}*/
	ll ans = dp[N-1][0];
	cout << ans << endl;

  return 0;
}


Measured memory_bytes: 71168
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

int main() {
  int n, a, b, c;
  scanf("%d%d%d%d", &n, &a, &b, &c);
  int l[n], m = (1<<(2*n)), ah, bh, ch, p[m], ans = INT_MAX;
  for (int i=0; i<n; i++) scanf("%d", l+i);
  for (int i=0; i<m; i++) p[i] = 0;
  for (int i=0; i<m; i++) {
    ah = 0; bh = 0; ch = 0;
    for (int j=0; j<n; j++) {
      int k = (3 & (i>>(2*j)));
      if (k == 1) {
        if (ah != 0) p[i] += 10;
        ah += l[j];
      } else if (k == 2) {
        if (bh != 0) p[i] += 10;
        bh += l[j];
      } else if (k == 3) {
        if (ch != 0) p[i] += 10;
        ch += l[j];
      }
    }
    if (ah == 0 || bh == 0 || ch == 0) {
      p[i] = INT_MAX;
      continue;
    }
    p[i] += abs(ah - a) + abs(bh - b) + abs(ch - c);
    ans = (ans > p[i]) ? p[i] : ans;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>
using namespace std;
const int Q=1<<19;
#define db double
db qt[Q];
int qv[Q];
int hd=1,tl=0;
const db eps=1e-9;
int main()
{
	int n;
	int L;
	db als=0;
	scanf("%d%d",&n,&L);
	while(n--){
		int v;
		db t;
		scanf("%lf%d",&t,&v);
		int qaq=L*(hd<=tl)+v;
		while(qaq>L){
			int now=min(qaq-L,qv[hd]);
			qaq-=now;
			als-=qt[hd]*now;
			qv[hd]-=now;
			if(!qv[hd])++hd;
		}
		als+=t*v;
		printf("%.8lf\n",als/L);
		while(hd<=tl&&t-qt[tl]<eps){
			t=(db)(t*v+qt[tl]*qv[tl])/(v+qv[tl]);
			v+=qv[tl];
			--tl;
		}
		qv[++tl]=v;
		qt[tl]=t;
	}
	return 0;
}

Measured memory_bytes: 15616
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define MOD (1e10+7)

int main(void){
	int n,a[123][2],i,j,ans=0,s[123][2];
	cin >> n;
	for(j=0; j<2; j++){
		for(i=0; i<n; i++){
			cin >> a[i][j];
		}
	}
	s[0][0]=0;
	s[0][1]=0;
	for(i=0; i<n; i++){
		s[i+1][0] = s[i][0] + a[i][0];
		s[i+1][1] = s[i][1] + a[i][1];
	}
	for(i=0; i<n; i++){
		ans = max(ans,s[i+1][0]+s[n][1]-s[i][1]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main (){
    int N,ans=0,sum=0,ssum=0;
    cin >> N;
    string s;
    cin >> s;
    
    for(int i=1;i<N;i++){
        if(s.at(i)== 'E'){
            ans++;
            sum++;
        }
    }

    for(int j=1;j<N;j++){
        if(s.at(j-1)== 'W'){
            sum++;
        }
        if(s.at(j)=='E'){
            sum--;
        }
        ans = min(ans,sum);
    }
    cout << ans << endl;
}

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

int cnt[15];
vector<int> times = {0};

int helper(int hour){

    if(hour == 13){

        int low = 30;

        for(int i = 0; i < times.size(); ++i){
            for(int j = i + 1; j < times.size(); ++j){
                int d = abs(times[i] - times[j]);
                low = min(low, min(d, 24 - d));
            }
        }

        return low;

    }

    if(cnt[hour] == 0) return helper(hour + 1);


    for(int i = 0; i < cnt[hour]; ++i)
        times.push_back((i & 1) == 0 ? 24 - hour : hour);

    int best = helper(hour + 1);

    for(int i = 0; i < cnt[hour]; ++i) times.pop_back();
    for(int i = 0; i < cnt[hour]; ++i)
        times.push_back((i & 1) == 1 ? 24 - hour : hour);

    best = max(best, helper(hour + 1));

    for(int i = 0; i < cnt[hour]; ++i) times.pop_back();

    return best;

}

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int n; cin >> n;

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

    cout << helper(0);

    return 0;

}


Measured memory_bytes: 256
from math import *
def modpow(a,n,m):
  res=1
  while n>0:
    if n&1:res=res*a%m
    a=a*a%m
    n//=2
  return res
n,a,b=map(int,input().split())
mod=10**9+7
ans=modpow(2,n,mod)-1
na=1
nb=1
for i in range(a):
  na*=(n-i)%mod
  na%=mod
fa=1
for i in range(1,a+1):
  fa*=i
  fa%=mod
na*=modpow(fa,mod-2,mod)
for i in range(b):
  nb*=(n-i)%mod
  nb%=mod
fb=1
for i in range(1,b+1):
  fb*=i
  fb%=mod
nb*=modpow(fb,mod-2,mod)
print((ans-nb-na)%mod)

Measured memory_bytes: 65832
#include <iostream>
#include <iomanip>
#include <cassert>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <sstream>
#include <istream>
#include <cmath>
#include <cstdio>

using namespace std;

#define vci vector<int>
#define vcs vector<string>
#define pb push_back
#define sz size()
#define mapii map<int, int>
#define mapci map<char, int>
#define mapsi map<string, int>
#define all(x) x.begin(), x.end()
#define minit(a, i) memset(a, i, sizeof(a));

#define for_(i, a, b) for (int i=(int)a; i<(int)b; i++)
#define for_d(i, a, b) for (int i=(int)a-1; i>=b; i--)
#define for_r(i, a, b, c) for (int i=(int)a; i<(int)b; i += c)
#define for_dr(i, a, b, c) for (int i=(int)a-1; i>=b; i -= c)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

typedef long long ll;

const int iINF = 2147483647;
const ll lINF = 9223372036854775807;

template <class T> inline void dbg(T t) { cout << t << endl; }



int ans[15][100];

void dfs(int nuse, int nsum, int len) {
	ans[len][nsum]++;
	
	for_(i, nuse+1, 10) {
		dfs(i, nsum+i, len+1);
	}
}

int main() {
	int n, sum;
	minit(ans, 0);
	
	dfs(-1, 0, 0);
	
	while (cin >> n >> sum) {
		if (n == 0 && sum == 0) break;
		cout << ans[n][sum] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1164
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
	int N;
	cin>>N;
	vector<string>S;
	string tmps;
	for(int i=0;i<N;++i){
		cin>>tmps;
		sort(tmps.begin(),tmps.end());
		S.push_back(tmps);
	}
	sort(S.begin(),S.end());
	/*
	for(int i=0;i<N;++i){
		cout<<S[i]<<endl;
	}
	*/
	long ans=0;
	long tmp=0;
	int n=0;
	for(int i=0;i<N-1;++i){
		if(S[i]==S[i+1]){
			if(tmp==0){
				tmp=1;
				n=2;
			}
			else{
				tmp=tmp*(n+1)/(n-1);
				n++;
			}
		}
		else{
			ans+=tmp;
			tmp=0;
			n=0;
		}
	}
	ans+=tmp;
	cout<<ans<<endl;
}


Measured memory_bytes: 5748
N, M = [int(x) for x in input().strip().split(" ")]

def dfs(v):
    pvs = set([v])
    path = [v]
    def _dfs(v, path):
        for u in d[v]:
            if u in pvs:
                for i, c in enumerate(path):
                    if c == u:
                        break
                return path[i+1:]  + [u]
            if u in vs:
                continue
            pvs.add(u)
            vs.add(u)
            loop = _dfs(u, path + [u])
            pvs.remove(u)
            if loop:
                return loop
        return False
    return _dfs(v, path)

vs = set()
def dfs_w(v, d):
    # dfs while版 
    pvs = set([])
    stack = [v]
    path = []
    while True:
        if len(stack) == 0:
            break
        v = stack.pop()
        if v < 0:
            pvs.remove(path[-1])
            path.pop()
        else:
            path.append(v)
            pvs.add(v)
            vs.add(v)
            for u in d[v]:
                if u in pvs:
                    for i, c in enumerate(path):
                        if c == u:
                            break
                    return path[i+1:]  + [u]
                if u in vs:
                    continue
                stack += [-v, u]
    return False

d = [set() for _ in range(N+1)]
for _ in range(M):
    a, b = [int(x) for x in input().strip().split(" ")]
    d[a].add(b)

for i in range(N):
    i += 1
    if i in vs:
        continue
    loop = dfs_w(i, d)
    if loop:
        break

if not loop:
    print(-1)
    import sys
    sys.exit()

v2i = [-1 for _ in range(N+1)]
for i, v in enumerate(loop):
    v2i[v] = i

nloop, pvs = [], set()
v = loop[0]
f = False
while True:
    nloop.append(v)
    pvs.add(v)
    max_i = max_i_l = -1
    for u in d[v]:
        if v2i[u] == -1:
            continue
        if v2i[v] > v2i[u] and u in pvs:
            f = True
            max_i_l = max(max_i_l, v2i[u])
        if v2i[u] > v2i[v]:
            max_i = max(max_i, v2i[u])
    if f:
        nloop.append(loop[max_i_l])
        break
    v = loop[max_i]

for i, x in enumerate(nloop):
    if x == nloop[-1]:
        break
nloop = nloop[i+1:]
print(len(nloop))
for v in nloop:
    print(v)


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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int n = s.size();
  int res = 0;
  for (int i = 0; i < n / 2; ++i) {
    res += s[i] != s[n - 1 - i];
  }
  cout << res << '\n';
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 62;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n, l; cin >> n >> l;
  vector<string> s(n);
  rep(i, n) cin >> s[i];
  sort(ALL(s));
  string ans = "";
  rep(i, n) ans += s[i];
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<string>
#include<cstdio>
#include<queue>
#include<functional>
#include <tuple>
#include<iomanip>
#include<stack>
#include<cmath>
#define ll long long
#define N 1000000007
using namespace std;
int main() {
	int a, b, c; cin >> a >> b >> c;
	if (a + b + c >= 22) cout << "bust" << endl;
	else cout << "win" << endl;
	return 0;
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



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

  int n, k;
  cin >> n >> k;
  vi x(n);
  rep(i,n) cin >> x[i];
  ll ans = inf;
  for(int i = 0; i+k-1 < n; i++) {
    ll tmp = 0;
    int l = i;
    int r = i+k-1;
    tmp += x[r] - x[l];
    tmp += min(abs(x[r]), abs(x[l]));
    chmin(ans, tmp);
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
N=int(input())
H=list(map( int,input().split() ))
ans=0

while any(H) != 0:
  for i in range(N):
    if H[i]!=0:
      for j in range(i,N):
        if H[j]==0:
          break
        elif j==N-1:
          j+=1
      break
  for k in range(i,j):
    H[k]-=1
  ans+=1
print(ans)  

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

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N, A, B; cin >> N >> A >> B;
  ll v1 = min(A, B);
  ll v2 = max(0LL, A + B - N);
  cout << v1 << " " << v2 << endl;

  return 0;
}



Measured memory_bytes: 3568
s = gets.chomp
result = true
s.length.times do |i|
    case s[i]
    when "U", "D"
        next
    when "R"
        if !((i + 1).odd?)
            result = false
            break
        end
    when "L"
        if !((i + 1).even?)
            result = false
            break
        end
    end
end
puts result ? "Yes" : "No"

Measured memory_bytes: 1788
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int POW[4];

int get_len(int num){

	if(num == 0)return 1;

	int ret = 0;

	while(num > 0){

		ret++;
		num /= 10;
	}

	return ret;
}

int main(){

	POW[0] = 1;
	for(int i = 1; i <= 3; i++){

		POW[i] = POW[i-1]*10;
	}

	int a,b;

	scanf("%d %d",&a,&b);

	int num = a*POW[get_len(b)]+b;

	bool FLG = false;

	for(int i = 1; i*i <= num; i++){

		if(i*i == num){

			FLG = true;
			break;
		}
	}

	if(FLG){

		printf("Yes\n");

	}else{

		printf("No\n");
	}

	return 0;
}


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

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998_244_353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(T)(ref T x, T y) { y.modpow(mod - 2); x.modm(y); }

void main()
{
	auto N = RD;
	auto K = RD;
	auto A = RDA;

	foreach (i; 0..N-K)
	{
		writeln(A[i] < A[i+K] ? "Yes" : "No");
	}

	stdout.flush;
	debug readln;
}


Measured memory_bytes: 11708
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>

std::vector<size_t> make_vector(size_t n, size_t x) {
  return std::vector<size_t>(n, x);
}

template <class Tp>
std::vector<Tp> make_vector(size_t n, const Tp& x) {
  return std::vector<Tp>(n, x);
}

template <class... Ts>
auto make_vector(size_t n, size_t m, const Ts&... x) {
  return std::vector<decltype(make_vector(m, x...))>(n, make_vector(m, x...));
}

int main() {
  size_t N;
  scanf("%zu", &N);

  std::vector<intmax_t> a(N);
  for (auto& ai: a) scanf("%jd", &ai);

  auto dp = make_vector(N, N, intmax_t(-1e13));

  for (size_t i = 0; i < N; ++i)
    dp[i][i] = a[i];

  for (size_t w = 1; w < N; ++w)
    for (size_t i = 0; i+w < N; ++i)
      dp[i][i+w] = std::max(a[i]-dp[i+1][i+w], a[i+w]-dp[i][i+w-1]);

  printf("%jd\n", dp[0][N-1]);
}


Measured memory_bytes: 70656