akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int gcd(int a,int b) {
    while(b^=a^=b^=a%=b);
    return a;
}
bool cmp(ll x,ll y){
	return x>y;
}
int main(){
	ll n;cin>>n;ll sum=0;int anx=0;int sb[3];int b,c;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
		for(int z=1;z<=n;z++){
		b=gcd(i,j);c=gcd(i,z);anx+=gcd(b,c);
		}
		}
	}

cout<<anx<<'\n';
}

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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

template<typename T1,typename T2>ostream& operator<<(ostream& os,const pair<T1,T2>& a) {os << "(" << a.first << ", " << a.second << ")";return os;}

const char newl = '\n';

int main() {
    ll n;
    cin >> n;
    ll ans = 0;
    for (int i = 1;i < n;++i) {
        ans += n/i;
        if (n%i == 0) ans--;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>

using namespace std;

#define N 511111
#define A 1111111
#define block 800

struct node{
    int L,R,i;
}q[N];

int v[N],cnt[A],ans[N],answer=0;

bool _compare(node x, node y) {

    if(x.L/block!=y.L/block)
        return x.L<y.L;
    return x.R<y.R;
}

void _add(int pos){

    cnt[v[pos]]++;
    if(cnt[v[pos]]==1)
        ++answer;
}
void _remove(int pos){

    cnt[v[pos]]--;
    if(cnt[v[pos]]==0)
        --answer;
}
int main()
{
   int n,Q;
   scanf("%d%d", &n,&Q);
   for(int i=0;i<n;i++)
   {
       scanf("%d", &v[i]);
   }
   for(int i=0;i<Q;i++)
   {
       int l,r;
       scanf("%d%d", &l, &r);
       --l,--r;
       q[i].L=l;
       q[i].R=r;
       q[i].i=i;

   }
   sort(q,q+Q,_compare);
   int curr_L=0,curr_R=0;
   for(int i=0;i<Q;i++)
   {
      int L=q[i].L, R=q[i].R;

      while(curr_L<L)
      {
        _remove(curr_L);
         curr_L++;
      }
      while(curr_L>L){
        _add(curr_L-1);
        curr_L--;
      }
      while(curr_R<=R)
      {
          _add(curr_R);
          curr_R++;
      }
      while(curr_R>R+1)
      {
          _remove(curr_R-1);
           curr_R--;
      }
      ans[q[i].i]=answer;
   }
   for(int i=0;i<Q;i++)
   {
       printf("%d\n", ans[i]);
   }
return 0;
}


Measured memory_bytes: 15424
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <sstream>
#include <string>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <limits>
#include <unordered_map>
#include <unordered_set>
#include <math.h>
#include <fstream>
#include <iterator>
#include <random>
#include <chrono>

 
#define forr(i,start,count) for (int i = (start); i < (start)+(count); ++i)
#define set_map_includes(set, elt) (set.find((elt)) != set.end())
#define readint(i) int i; cin >> i
#define readll(i) ll i; cin >> i
#define readdouble(i) double i; cin >> i
#define readstring(s) string s; cin >> s
 
typedef long long ll;
 
using namespace std;

ll modd = 1000*1000*1000+7;


int main()   {

    ios_base::sync_with_stdio(false);

    cout.precision(17);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    uniform_int_distribution<int> rand_gen(0, modd);   // rand_gen(rng) gets the rand no

//    auto start = chrono::steady_clock::now();
  
//    readint(test_cases);
    int test_cases = 1;
    forr(t, 1, test_cases) {
        readint(m);
        readstring(s);
        int ret = 0;
        int i_l = 0, i_r = s.size()-1;
        while (true) {
            while (s[i_l]=='R') { i_l++; if (i_l==s.size()) {break;} }
            if (i_l==s.size()) {break;}
            while (s[i_r]=='W') {  i_r--; if (i_r==-1) {break;}  }
            if (i_r==-1) {break;}
            if (i_l>i_r) {break;}
            swap(s[i_l], s[i_r]);
            ret++;
        }
        cout << ret << endl;

//        cout << "Case #" << t << ": " << endl;
    }
 
//    auto end = chrono::steady_clock::now();
//    cout << chrono::duration_cast<chrono::milliseconds>(end - start).count() << endl;

    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()

const ll mod = 1000000000 + 7;
const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const ll INF = 1<<30;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;
const ull BASE = 1e9 + 7;

struct RollingHash {

    ull base1, base2;
    ull mod1, mod2;
    vector<ull> hash1, hash2;
    vector<ull> pow1, pow2;

    RollingHash() : base1(9973), base2(1000000000 + 7), mod1(999999937), mod2(1000000000 + 7) {}

    void construct(const string &s) {
        int n = s.size();

        hash1.assign(n + 1, 0);
        hash2.assign(n + 1, 0);
        pow1.assign(n + 1, 1);
        pow2.assign(n + 1, 1);

        for (int i = 0; i < n;i++) {
            hash1[i + 1] = (hash1[i] + s[i]) * base1;
            hash2[i + 1] = (hash2[i] + s[i]) * base2;
            pow1[i + 1] = pow1[i] * base1;
            pow2[i + 1] = pow2[i] * base2;
        }
    }
    //[l, r)
    pullull get(int l, int r) {
        ull t1 = hash1[r] - hash1[l] * pow1[r - l];
        ull t2 = hash2[r] - hash2[l] * pow2[r - l];
        return make_pair(t1, t2);
    }

    bool match(int l1, int r1, int l2, int r2) {
        return get(l1, r1) == get(l2, r2) ? true : false;
    }
};

int h, w, r, c;
string t[1005], p[1005];

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> h >> w;
    rep(i, h) cin >> t[i];
    cin >> r >> c;
    rep(i, r) cin >> p[i];
    if (h < r || w < c) exit(0);

    RollingHash t_yoko[1005], p_yoko[1005];
    vector<vector<ull>> t_tate(1005, vector<ull>(1005, 0));
    ull p_hs = 0;
    rep(i, h) t_yoko[i].construct(t[i]);
    rep(i, r) p_yoko[i].construct(p[i]);
    rep(i, r) p_hs = (p_hs + p_yoko[i].hash1[c]) * (1000000000 + 7);
    rep(j, w - c + 1) {
        rep(i, h) {
            pair<ull, ull> pt_hs = t_yoko[i].get(j, j + c);
            t_tate[i + 1][j] = (t_tate[i][j] + pt_hs.fi) * (1000000000 + 7);
        }
    }
    ull pw[1005];
    pw[0] = 1;
    rep2(i, 1, 1005) pw[i] = pw[i - 1] * (1000000000 + 7);
    rep(i, h - r + 1)rep(j, w - c + 1) {
        ull t_hs = t_tate[i + r][j] - t_tate[i][j] * pw[r];
        if (t_hs == p_hs) cout << i << " " << j << endl;
    }
}

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

#define show(x) cerr << #x << " = " << x << endl ;
#define input_from_file freopen("input.txt","r",stdin)
#define output_to_file freopen("output.txt" , "w",stdout)
#define fastio ios_base::sync_with_stdio(0)
#define endl '\n'


int main()
{
	 #ifdef LOCAL
        input_from_file;
        output_to_file;
    #endif
	fastio;cin.tie(0);cout.tie(0);
	int n ; cin >> n  ;
	int even = n/2 , odd = (n+1)/2;
	cout << fixed << setprecision(10) <<odd/(double)n;



	return 0;
}

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

using namespace std;
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

const int maxn = 1e6;
const int MOD = 1e9 + 7;

vector<long long> fact(maxn + 1, 1);
vector<long long> inv(maxn + 1, 1);

long long mod_pow(long long a, long long b, long long p = MOD) { // = (a^b) % p //((a^-1) % p) = (a^(p-2)) % p;
	long long res = 1;
	a %= p;

	while (b > 0) {
		if ((b & 1) == 1) res = ((res % p) * (a % p)) % p;
		a = ((a % p) * (a % p)) % p;
		b >>= 1;
	}
	return res;
}

void preC() {
	for (long long i = 1; i <= maxn; i++) {
		fact[i] = (i * fact[i - 1]) % MOD;
		inv[i] = (mod_pow(i, MOD - 2) * inv[i - 1]) % MOD;
	}
}

long long C(long long n, long long r) { // nCr % MOD
	return (fact[n] * ((inv[r] * inv[n - r]) % MOD)) % MOD;
}


int main() {
	preC();

	int x, y; cin >> x >> y;

	if ((x + y) % 3 != 0) {
		cout << 0;
		return 0;
	}

	int n = (2 * y - x) / 3, m = (2 * x - y) / 3;

	if (n < 0 or m < 0) {
		cout << 0;
		return 0;
	}

	cout << C(n + m, n);

	return 0;
}

Measured memory_bytes: 18656
N = int(input())
S = input()
ans = 0
for i in range(1000):
    pw = str(i).zfill(3)
    ok1 = False
    ok2 = False
    ok3 = False
    for j in range(N):
        if S[j] == pw[0] and not ok1:
            ok1 = True
            continue
        if ok1 and not ok2:
            if S[j] == pw[1]:
                ok2 = True
                continue
        if ok2:
            if S[j] == pw[2]:
                ok3 = True
                # print(pw)
                break
    if ok3:
        ans += 1

print(ans)


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

using namespace std;

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

  long N; cin>>N;
  long ans = 0;
  if (N%2==0) {
    long div = 10;
    while (N >= div) {
      ans += N/div;
      div *= 5;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <bitset>
#include <complex>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for(int i = a; i < (int)b; i++)
#define pb push_back
#define mp make_pair
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef long long ll;
typedef unsigned long long ull;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
const int INF = 1 << 27;
const int MAX_V = 101;
//////////////////////////////
// ????°?????????¨?????¨
void visit(int V, int G[MAX_V][MAX_V], int v, int s, int r,
    vector<int> &no, vector< vector<int> > &comp,
    vector<int> &prev, vector< vector<int> > &next,
    vector<int> &mcost, vector<int> &mark,
    int &cost, bool &found) {
  if (mark[v]) {
    vector<int> temp = no;
    found = true;
    do {
      cost += mcost[v];
      v = prev[v];
      if (v != s) {
        while (comp[v].size() > 0) {
          no[comp[v].back()] = s;
          comp[s].push_back(comp[v].back());
          comp[v].pop_back();
        }
      }
    } while (v != s);
    REP(i, V){
      if(i != r && no[i] == s)
        REP(j, V){
          if (no[j] != s && G[j][i] < INF) G[j][i] -= mcost[temp[i]];
        }
    }
  }
  mark[v] = true;
  REP(i, next[v].size())
    if(no[next[v][i]] != no[v] && prev[no[next[v][i]]] == v)
      if (!mark[no[next[v][i]]] || next[v][i] == s)
        visit(V, G, next[v][i], s, r, no, comp, prev, next, mcost, mark, cost, found);
}
int minimumSpanningArborescence(int V, int E, int G[MAX_V][MAX_V], int r) {
  vector<int> no(V);
  vector< vector<int> > comp(V);
  REP(i, V) comp[i].push_back(no[i] = i);

  for(int cost = 0; ;) {
    vector<int> prev(V, -1);
    vector<int> mcost(V, INF);
    REP(i, V){
      REP(j, V){
        if(j == r || G[i][j] == INF || no[i] == no[j] || G[i][j] > mcost[no[j]]) continue;
        mcost[no[j]] = G[i][j];
        prev[no[j]] = no[i];
      }
    }
    vector< vector<int> > next(V);
    REP(i, V)
      if(prev[i] >= 0)
        next[prev[i]].push_back(i);
    bool stop = true;
    vector<int> mark(V, false);
    REP(i, V)
      if(i != r && !mark[i] && !comp[i].empty()) {
        bool found = false;
        visit(V, G, i, i, r, no, comp, prev, next, mcost, mark, cost, found);
        if (found) stop = false;
      }
    if (stop) {
      REP(i, V) if (prev[i] >= 0) cost += mcost[i];
      return cost;
    }
  }
}
int main() {
  int V, E, r;
  cin >>V >>E >>r;
  int G[MAX_V][MAX_V];
  REP(i, V) REP(j, V) G[i][j] = (i == j ? 0 : INF);
  REP(i, E){
    int f, t, c; cin >>f >>t >>c;
    G[f][t] = c;
  }
  cout <<minimumSpanningArborescence(V, E, G, r) <<endl;
  return 0;
}

Measured memory_bytes: 3184
using System;


public class hello
{
    public static void Main()
    {

        var n = int.Parse(Console.ReadLine().Trim());
        for (int i = 0; i < n; i++)
        {
            string[] s = Console.ReadLine().Trim().Split(' ');
            var x1 = decimal.Parse(s[0]);
            var y1 = decimal.Parse(s[1]);
            var x2 = decimal.Parse(s[2]);
            var y2 = decimal.Parse(s[3]);
            var x3 = decimal.Parse(s[4]);
            var y3 = decimal.Parse(s[5]);
            var x4 = decimal.Parse(s[6]);
            var y4 = decimal.Parse(s[7]);
            var a = (y2 - y1)* (x4 - x3);
            var b = (y4 - y3)* (x2 - x1);
            if (a==b) Console.WriteLine("YES");
            else Console.WriteLine("NO");
        }
    }
}

Measured memory_bytes: 9236
#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;
void chmax(LL& a, LL b) {
	a = max(a, b);
}
//////////////

void solve() {
	int N, M;
	cin >> N >> M;
	int time = (N - M) * 100 + M * 1900;
	int E = 1 << M;

	cout << time * E << 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: 256
#include<algorithm>
#include<cstdio>
#include<vector>
#define ll long long
#define MaxN 200500
using namespace std;
inline int read()
{
  int X=0;char ch=0;
  while(ch<48||ch>57)ch=getchar();
  while(ch>=48&&ch<=57)X=X*10+(ch^48),ch=getchar();
  return X;
}
vector<int> g[MaxN],l[MaxN];
int w[MaxN],c[MaxN];
#define Pr pair<ll,int>
#define mp make_pair
#define fir first
#define sec second
struct Data
{
  Pr x,x2;int c;
  bool chk(const Data &t){
    if (t.c==c){
      x=min(x,t.x);
      x2=min(x2,t.x2);
    }else {
      if (t.x<=x){
        x2=min(x,t.x2);
        c=t.c;x=t.x;
      }else x2=min(x2,t.x);
    }
  }
  Pr get(int tc){
    if (tc==c)return x2;
    return x;
  }
}f[MaxN];
void dfs1(int u,int fa)
{
  f[u].x=mp(w[u],u);
  f[u].c=c[u];
  for (int i=0,v;i<g[u].size();i++)
    if ((v=g[u][i])!=fa){
   	  dfs1(v,u);
   	  f[v].x.fir+=l[u][i];
   	  f[v].x2.fir+=l[u][i];
   	  f[u].chk(f[v]);
   	  f[v].x.fir-=l[u][i];
      f[v].x2.fir-=l[u][i];
   	}
}
void dfs2(int u,int fa)
{
  for (int i=0,v;i<g[u].size();i++)
    if ((v=g[u][i])!=fa){
      f[u].x.fir+=l[u][i];
      f[u].x2.fir+=l[u][i];
      f[v].chk(f[u]);
   	  dfs2(v,u);
   	  f[u].x.fir-=l[u][i];
      f[u].x2.fir-=l[u][i];
    }
}
int n,cnt;
int findf(int u)
{return c[u]==u ? u : c[u]=findf(c[u]);}
bool merge(int x,int y)
{
  x=findf(x);y=findf(y);
  if (x==y)return 0;
  c[x]=y;return 1;
}
#define INF (1ll<<60)
Pr p[MaxN];
int main()
{
  n=read();
  for (int i=1;i<=n;i++)w[i]=read();
  for (int i=1,fr,to,len;i<n;i++){
    fr=read();to=read();len=read();
    g[fr].push_back(to);
    l[fr].push_back(len);
    g[to].push_back(fr);
    l[to].push_back(len);
  }for (int i=1;i<=n;i++)c[i]=i;
  ll ans=0;
  while(cnt<n-1){
    for (int i=1;i<=n;i++){
      p[i].fir=f[i].x.fir=f[i].x2.fir=INF;
      f[i].x.sec=f[i].x2.sec=f[i].c=0;
    }dfs1(1,0);dfs2(1,0);
    for (int i=1;i<=n;i++){
      Pr sav=f[i].get(c[i]);
      sav.fir+=w[i];
      p[c[i]]=min(p[c[i]],sav);
    }for (int i=1;i<=n;i++)
      if (p[i].fir<INF&&merge(i,p[i].sec))
        {ans+=p[i].fir;cnt++;}
    for (int i=1;i<=n;i++)findf(i);
  }printf("%lld",ans);
}

Measured memory_bytes: 53376
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
long long inf=(long long)1E17;
using namespace std;
int main(){
  int x,t;
  cin>>x>>t;
  cout<<max(0,x-t)<<endl;
  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++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;

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

  if(a+w < b) cout << b-(a+w) << endl;
  else if(b+w < a) cout << a-(b+w) << endl;
  else cout << 0 << endl;

  return 0;
}


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

#define ll long long
const int mx = 2e5;


int main(void){
  ll N, K;
  cin >> N >> K;
  ll pre=N+1;
  ll prepre=N+1;
  int flag=1;
  N= N%K + K;
  while(N = abs(N-K)){
    if(N==pre || N==prepre){
      if(pre<prepre){
        N=pre;
      }else{
        N=prepre;
      }
      break;
    }else{
      prepre = pre;
      pre = N;
    }
    //cout << N<<"a\n";
  }
  
  cout << N;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <sstream> 

using namespace std; 

#define MP make_pair

long gcd(long a, long b){ 

  if(a%b==0) return b; 
  else return gcd(b,a%b); 

} 

long lcm(long a, long b){ 
  return a*b/gcd(a,b); 
} 

int main(){

	int h;
	while(cin>>h, h){

		vector< vector<int> > map(h , vector<int>(5));

		for(int i=0;i<h;i++){
			for(int j=0;j<5;j++){
				cin>>map[i][j];
			}
		}


		int res=0;
		while(true){

			bool flag=true;

			for(int i=0;i<h;i++){
				int num=map[i][0],len=1,pos=0;
				for(int j=1;j<5;j++){
					if(map[i][j]==num) len++;
					else if(len>=3) break;
					else{ num=map[i][j]; pos=j; len=1;}
				}

				if(len>=3 && num!=0){
					flag=false;
					res+=num*len;
					for(int j=0;j<len;j++) map[i][pos+j]=0;
				}

			}

			for(int i=h-2;i>=0;i--){
				for(int j=0;j<5;j++){
					int pos=i;
					while(pos+1<h && map[pos+1][j]==0) pos++;
					swap(map[i][j],map[pos][j]);
				}
			}


			if(flag) break;
		}

		cout<<res<<endl;

	}

	return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int n, k;
    cin >> n >> k;
    vector<int> l(n);
    rep(i, n) cin >> l[i];
    sort(whole(l), std::greater<int>());
    //reverse(whole(l));
    
    int ans = 0;
    rep(i, k) ans += l[i];
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3584
# -*- coding: utf-8 -*-
import sys

S = input()
S = list(S)

first_S = S.pop()
for i in range(len(S)):
    if S[i] == first_S:
        S.remove(first_S)
        break
else:
    print('No')
    sys.exit()

second_S = S.pop()
for i in range(len(S)):
    if S[i] == second_S:
        break
else:
    print('No')
    sys.exit()

if first_S == second_S:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
#define int long long
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279; //円周率
/*---------------------便利な関数--------------------------------------*/
int fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}

int gcd(int a, int b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}

int lcm(int a, int b) {      //最小公倍数
    return a * b / gcd(a, b);
}

int keta(int n) {        //桁数を求める
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}

int ketasum(int n) {    //各桁の和
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/*-------------ここまで---------------------------------------------*/

//C++(GCC9.2.1)

signed main() {
    //宣言
    int x;
    cin >> x;
    int sum = 0;
    while (x >= 500) {
        x -= 500;
        sum += 1000;
    }
    while (x >= 5) {
        x -= 5;
        sum += 5;
    }
    cout << sum << endl;
    return 0;
}

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

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

  map<int,int> S;

  for (int i = 0; i < N; i++) {
    int K;
    cin >> K;
    
    for (int j = 0; j < K; j++) {
      int A;
      cin >> A;
      S[A]++;
    }
  }
  int itti;
  for (auto x : S) {
    if (x.second == N) {
      itti++;
    }
  }
  cout << itti << endl;
} 

Measured memory_bytes: 256
use std::io::Read;

fn solve(n: usize, s: Vec<Vec<i32>>, p: Vec<i32>) -> i32 {
    (0..(1 << n))
        .filter(|&sw_mask| {
            let is_turned_on = |sw| (sw_mask >> sw) & 1 != 0;
            s.iter().zip(p.iter()).all(|(switches, &parity)| {
                switches.iter().filter(|&sw| is_turned_on(sw - 1)).count() as i32 % 2 == parity
            })
        })
        .count() as i32
}

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let m: usize = iter.next().unwrap().parse().unwrap();
    let s: Vec<Vec<i32>> = (0..m)
        .map(|_| {
            let k = iter.next().unwrap().parse().unwrap();
            (0..k)
                .map(|_| iter.next().unwrap().parse().unwrap())
                .collect()
        })
        .collect();
    let p: Vec<i32> = (0..m)
        .map(|_| iter.next().unwrap().parse().unwrap())
        .collect();
    let r = solve(n, s, p);
    println!("{}", r);
}


Measured memory_bytes: 4352
N = int(input())
ans = 0
if N == 2 :
    print(1)
    exit(0)
if (N - 1 ) % 2 == 0:
    ans = (1 + N -1) * (N // 2)
else:
    #print(N // 2)
    ans = (1 + N -1) * ((N // 2) -1) + N // 2
print(ans)


Measured memory_bytes: 2940
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

int N, M, A[1<<20];

int main() {
  //freopen("input.in","r",stdin);
  //freopen("output.out","w",stdout);

  cin >> N >> M;
  for(int i = 1;i <= N;i++) {
    cin >> A[i];
    A[i] += A[i-1];
    A[i] %= M;
  }

  N++;
  sort(A, A+N);

  long long ans = 0, counter = 1;
  for(int i = 1;i < N;i++) {
    if(A[i] == A[i-1]) counter++;
    else {
      ans += counter * (counter - 1) / 2;
      counter = 1;
    }
  }

  ans += counter * (counter - 1) / 2;
  cout << ans << endl;

  return 0;
}


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

using namespace std;
vector<int> v;
int n,m,x,ans;
int main(){
    ios_base::sync_with_stdio(0);cin.tie(nullptr);
    cin>>n>>m;
    for(int i=1; i<=n; i++){
        cin>>x;
        v.push_back(x);
    }
    sort(v.begin(),v.end());
    for(int i=0; i<v.size(); i++){
        ans+=v[i];
        if(!--m) break;
    }
    cout<<ans<<'\n';
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
vector<P> res;
int dp[2200][2200];
int n;
int dfs(int l,int r){
    //左にl個,右にr個詰めたときの最大値
    if(l == 0 && r == 0)return 0;
    if(l < 0 || r < 0)return -1001001001ll;
    if(dp[l][r] != -1)return dp[l][r];
    int ret = 0;
    auto  now = res[l+r-1];
    //trace(now,n-r,l-1);
    //右
    if(r-1 >= 0)ret = max(ret,dfs(l,r-1) + now.first*abs(now.second - (n-r)));
    //左
    if(l-1 >= 0)ret = max(ret,dfs(l-1,r) + now.first*abs(now.second - (l-1)));
    return dp[l][r] =  ret;

}
signed main(){
    cin >> n;
    vector<int> a(n);
    rep(i,2200)rep(j,2200)dp[i][j] = -1;
    rep(i,n){
        cin >> a[i];
        res.emplace_back(a[i],i);
    }
    sort(res.rbegin(),res.rend());
    int ret = 0;
    rep(i,n+1){
        //trace(dfs(i,n-i),i,n-i);
        ret = max(ret,dfs(i,n-i));
    }
    // trace(p);
    // trace(res);
    cout << ret << endl;
    
    return 0;
}

Measured memory_bytes: 41668
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  int N, A, B;
  string S;
  cin >> N >> A >> B >> S;
  rep(i, N)
  {
    if (S[i] == 'c')
      cout << "No" << endl;
    if (S[i] == 'a')
    {
      if (A > 0)
      {
        cout << "Yes" << endl;
        A--;
      }
      else if (B > 0)
      {
        cout << "Yes" << endl;
        B--;
      }
      else
      {
        cout << "No" << endl;
      }
    }
    else if (S[i] == 'b')
    {
      if (B > 0)
      {
        cout << "Yes" << endl;
        B--;
      }
      else
      {
        cout << "No" << endl;
      }
    }
  }
  return 0;
}

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

int main(){
  int n;cin>>n;
  map<int,int> m;
  vector<int> a(n+1);
  for(int i=1;i<=n;i++){cin>>a[i];m[i+a[i]]++;}
  long long ans=0;
  for(int i=1;i<=n;i++)ans+=m[i-a[i]];
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 21072
#include<stdio.h>

int main(void){
	int n, x;
	
	scanf("%d", &n);
	
	if(n/100 < (n%100)/10)
		x = (n/100+1)*100 + (n/100+1)*10 + (n/100+1);
	else if(n/100 == (n%100)/10){
		if(n/100 >= n%100%10)
			x = (n/100)*100 + (n/100)*10 + (n/100);
		else
			x = (n/100+1)*100 + (n/100+1)*10 + (n/100+1);
	}
	else
		x = (n/100)*100 + (n/100)*10 + (n/100);
	
	printf("%d\n", x);
		
	return 0;
}

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

int main() {
  string x;
  int a;
  cin >> x;
a=x.size();
  if(x.at(a-1) != 's') {
    cout << x << "s" << endl;
  }

  if(x.at(a-1) == 's') {
    cout << x << "es" << endl;
  }
}


Measured memory_bytes: 3624
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

/**
 * Lesson7A あなたの課題は、あるクラスの数学の成績を付けるプログラムを作成することです。
 *
 * プログラムは複数の学生のテストの点数を読み込みます。
 *
 * テストの点数は、中間試験の点数 m、期末試験の点数 f、再試験の点数 r で構成されています。
 *
 * 中間試験と期末試験は 50 点満点（m, f ? 50）、再試験は 100 点満点 （r ? 100）です。
 *
 * 試験を受けていない場合は点数を -1 とします。
 *
 * 以下の手順で成績が付けられます： ?中間試験、期末試験のいずれかを欠席した場合成績は F。 ?中間試験と期末試験の合計点数が 80 以上ならば成績は A
 * 。 ?中間試験と期末試験の合計点数が 65 以上 80 未満ならば成績は B。 ?中間試験と期末試験の合計点数が 50 以上 65 未満ならば成績は C。
 * ?中間試験と期末試験の合計点数が 30 以上 50 未満ならば成績は D。 ただし、再試験の点数が 50 以上ならば成績は C。
 * ?中間試験と期末試験の合計点数が 30 未満ならば成績は F。
 *
 * @author Internship
 *
 */
public class Main{

	/**
	 * プログラムのエントリポイント
	 *
	 * @param args
	 */
	public static void main(String[] args) {

		// 答え
		ArrayList<Character> chaAnswer = new ArrayList<Character>();

		//答えがいくつあるかカウント
		int intAnwer = 0;

		// 1列づつ読み込む
		try {
			BufferedReader insBR = new BufferedReader(
					new InputStreamReader(System.in));


			while (true) {
				String strLine = insBR.readLine();

				//終了条件
				if(strLine.equals("-1 -1 -1")) {
					break;
				}

				// ばらけさせる
				String[] strAryLine = strLine.split(" ");

				// int型にキャスト
				// 中間テスト
				int IntermediateTest = Integer.parseInt(strAryLine[0]);

				// 期末テスト
				int intYearEndTest = Integer.parseInt(strAryLine[1]);

				// 追試
				int intAdditionalTest = Integer.parseInt(strAryLine[2]);

				// 答えのストック　A?F以外で初期化
				char chaAnswerStock = 'G';

				//-1は受けてないので中間テストと期末テストは0点とする
				if(IntermediateTest == -1) {
					intYearEndTest = 0;
				}

				if(intYearEndTest == -1) {
					IntermediateTest = 0;
				}

				// 成績の判断
				if (80 <= (IntermediateTest + intYearEndTest)) {
					chaAnswerStock = 'A';
				} else if (65 <= (IntermediateTest + intYearEndTest)) {
					chaAnswerStock = 'B';
				} else if (50 <= (IntermediateTest + intYearEndTest)) {
					chaAnswerStock = 'C';
				} else if (30 <= (IntermediateTest + intYearEndTest)) {
					chaAnswerStock = 'D';

					if (50 <= intAdditionalTest) {
						chaAnswerStock = 'C';
					}
				} else {
					chaAnswerStock = 'F';
				}
				chaAnswer.add(chaAnswerStock);
				intAnwer++;
			}

			// 出力
			for(int i = 0; i < intAnwer; i++) {
				System.out.println(chaAnswer.get(i));
			}

		} catch (IOException e) {
			System.out.println(e);
		} catch (NumberFormatException e) {
			System.out.println("数字で入力して下さい");
		}
	}
}

Measured memory_bytes: 16944
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;
const ld PI = 3.14159265358979323846;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//



int main() {


    int N; cin >> N;
    int cnt[N+1];
    rep(i, N+1) cnt[i] = 0;
    for (int x = 1; x*x <= N; ++x) {
        for (int y = 1; y*y <= N; ++y) {
            for (int z = 1; z*z <= N; ++z) {
                int f = x*x + y*y + z*z + x*y + y*z + z*x;
                if (f <= N) {
                    ++cnt[f];
                }
            }
        }
    }

    for (int i = 1; i <= N; ++i) {
        out(cnt[i]);
    }

    return 0;
}









Measured memory_bytes: 3556
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

// const int dx[4] = { 1, 0, -1, 0 };
// const int dy[4] = { 0, 1, 0, -1 };

// const int dx[8] = {1, 1, 0,-1,-1,-1, 0, 1};
// const int dy[8] = {0, 1, 1, 1, 0,-1,-1,-1};

#define SUM(vec) accumulate(all(vec),0LL) // 配列の中身を全部足す
template<typename T>void print(T&& x){cout<<x<<endl;}// 改行付き出力
ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int ctoi(char c){return c-'0';}


struct UnionFind {

    UnionFind(int N) : par(N),siz(N,1) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        if(siz[rx] < siz[ry])swap(rx,ry);
        siz[rx] += siz[ry];
        par[ry] = rx; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    int size(int x){
      return siz[root(x)];
    }
  private:
    vector<int> siz;
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
  
};

// TODO: write
int main() {   
  int n,m,k;cin>>n>>m>>k;
  
  auto tree = UnionFind(n);
  vector<vector<int> > a(n),c(n);
  rep(i,m){
    int a1,b1;
    cin>>a1>>b1;
    a1--;b1--;
    tree.unite(a1,b1);
    a[a1].emplace_back(b1);
    a[b1].emplace_back(a1);
  }

  rep(i,k){
    int c1,d1;cin>>c1>>d1;
    c1--;d1--;
    if(tree.same(c1,d1)){
      c[d1].emplace_back(d1);
      c[c1].emplace_back(c1);
    }
  }

  rep(i,n){
    int ans = 0;
    ans += tree.size(i)-1;
    ans -= a[i].size() + c[i].size();
    cout<<ans<<" ";
  }
  cout<<endl;
  return 0;
}



Measured memory_bytes: 12664
#include <stdio.h>

int main(void) {

  int i,j;
  int h[11];

  for(i=0;i< 10;i++)
    scanf("%d",&h[i]);

  for(i=0;i< 3;i++) {
    for(j=i+1;j< 10;j++)
      if(h[i]< h[j]) {
	h[10]=h[i];
	h[i]=h[j];
	h[j]=h[10];
      }
    printf("%d\n",h[i]);
  }

  return 0;

}

Measured memory_bytes: 0
<?php
  list($n,$k) = explode(" ", trim(fgets(STDIN)));
  $p = array_map('intval', explode(" ", trim(fgets(STDIN))));
  $c = array_map('intval', explode(" ", trim(fgets(STDIN))));

  $ans = $c[0];
  for($i=0;$i<$n;$i++){
    $next = $i+1;
    $pointMax=[PHP_INT_MIN];
    $pointAll=0;
    $j=1;
    while(1){
      $next=$p[$next-1];
      $pointAll+=$c[$next-1];
      $pointMax[$j]=max($pointAll, $pointMax[$j-1]);
      if($next === $i+1) break;
      $j++;
    }
    if($k <= $j){
      $ans = max($ans, $pointMax[$k]);
    }else if($pointAll <= 0){
      $ans = max($ans, $pointMax[$j]);
    }else{
      $sum = $pointAll*(intdiv($k, $j)-1);
      $mod = $k % $j;
      $sum += max($pointMax[$j], $pointAll+$pointMax[$mod]);
      $ans = max($ans, $sum);
    }
  }

  echo $ans;

Measured memory_bytes: 17256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll counti[200001];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        counti[a[i]]++;
    }
    ll ans =0;
    for(int i=1;i<=200000;i++)
    {
        ans += (counti[i]*(counti[i]-1LL))/2LL;
    }
    for(int i=0;i<n;i++)
    {
        ll tmp;
        tmp = ans - (counti[a[i]])*(counti[a[i]]-1LL)/2LL;
        ll r = counti[a[i]]-1;
        tmp += (r*(r-1LL))/2LL;
        cout<<tmp<<"\n";
    }
}


Measured memory_bytes: 3968
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) x.begin(),x.end()
#define dmp(x) cerr<<#x<<":"<<x<<endl
typedef pair<int,int> P;
typedef pair<int,P> PP; 
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
const int MOD = 1e9+7;

int mod_pow(int x,int n){
    if(n==0)return 1;
    int res=mod_pow( x*x%MOD , n/2 );
    if( n & 1 )res = res*x%MOD;
    return res;
}

signed main(){
  int n,k;
  cin>>n>>k;
  vector<int> a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  for(int i=0;i<n;i++){
    a.pb(a[i]);
  }
  int ans=0;
  for(int i=0;i<n;i++){
    int fs=0;
    for(int j=0;j<i;j++){
      if(a[j]>a[i])fs++;
    }
    int t=0;
    for(int j=0;j<n;j++){
      if(a[i+j]>a[i])t++;
    }
    ans+=(2*fs+(k-1)*t%MOD)%MOD*k%MOD*mod_pow(2,MOD-2);
    ans%=MOD;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
/*****************************************************

*****************************************************/

#include<bits/stdc++.h>
#define MAX 9223372036854775807
#define endl "\n"
#define ll long long
#define int long long
#define pb push_back
#define pf push_front
#define ppf pop_front
#define mp make_pair
#define ip pair<int, int>

#define loop(i,n) for(int i=0;i<n;i++)
#define fast ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL)
using namespace std;

const ll MOD = 1e9+7;
const ll SZ = 107;
const ll N = 2e5+7;
const ll inf = 1e17;

int pwr(int x, int y)
{
    ll r = 1LL;
    while(y)
    {
        if(y&1)
            r = (r * x) % MOD;
        y >>= 1;
        x = (x * x) % MOD;
    }
    return r % MOD;
}

int inv(int x)
{
    return pow(x, MOD-2);
}

void solve()
{
    int x, a; cin>>x>>a;
    if(x<a)
        cout<<0;
    else
        cout<<10;
}

signed main()
{

    int t=1;
    // cin >>t;
    while(t--){
        solve();
    }
    return 0;
}

/*****************************


****************************/

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

#define int long long
#define ll long long
#define f1(i,a,b) for(i=a;i<b;i++)
#define f2(i,a,b) for(i=a;i>=b;i--)
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair

const int mod=1000000007;
int i,j;
ll temp;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // #ifndef ONLINE_JUDGE
    //     freopen("in.txt","r",stdin);
    //     freopen("out.txt","w",stdout);
    // #endif
    int a,p;
    cin>>a>>p;
    cout<<(3*a+p)/2;
    return 0;
}

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

#define EPS 1e-6
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define llinf 0x3f3f3f3f3f3f3f3f

#define fi first
#define se second
#define pb push_back
#define ende '\n'

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mset(x, y) memset(&x, (y), sizeof(x))

using namespace std; 

using ll = long long;
using ii = pair<int,int>;

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

  string s; cin >> s;
  ll n = s.size();
  ll k; cin >> k;

  bool vai = false;
  if (s[0] == s[n-1]) {
    string t = s;
    s[0] = '-';
    for (int i = 1; i < n && t[i] == t[i-1]; ++i) s[i] = '-';
    s[n-1] = '-';
    for (int i = n-2; i < n && t[i+1] == t[i]; --i) s[i] = '-';
    vai = true;
  }

  ll ans = 0;
  for (int i = 0, j = 1; i < n; i = j) {
    ll rep = 1;
    j = i + 1;
    if (s[i] == '-') continue;
    while (j < n && s[i] == s[j]) {
      j++;
      rep++;
    }
    ans += rep / 2;
  }
  ans = ans * k;

  if (vai) {
    int beg = n - 1;
    while (beg - 1 >= 0 && s[beg-1] == '-') beg--;
    if (beg == 0) {
      if (n % 2) {
        ans += (n/2) * (((k-1)/2)+1);
        ans += ((n-1)/2+1) * (k/2);
      } else
        ans += (n/2)*k;
    } else {
      ll num = 0;
      for (int i = beg; s[i] == '-'; i = (i + 1) % n) num++;
      ans += num/2 * (k - 1);

      int bb = 0, ee = 0;
      for (int i = 0; s[i] == '-'; ++i) bb++;
      ans += bb/2;
      for (int i = n-1; s[i] == '-'; --i) ee++;
      ans += ee/2;
    }
  }

  cout << ans << ende;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char const *argv[]) {
  int N;
  cin >> N;
  vector<int> V(N);
  vector<int> C(N);

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

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

  int bound = 1 << N;
  int max = 0;
  for (int bit = 0; bit < bound; bit++) {
    int cost = 0;
    for (int i = 0; i < N; i++) {
      if (bit & (1 << i)) {
        cost += (V[i] - C[i]);
      }
    }
    if (max < cost) {
      max = cost;
    }
  }

  cout << max << "\n";
  return 0;
}


Measured memory_bytes: 256
def solve():
    S = input()
    flag_c = False
    flag_f = False
    ans = ''
    for s in S:
        if s == 'C':
            flag_c = True
        if flag_c and s == 'F':
            flag_f = True
    if flag_c and flag_f:
        print('Yes')
    else:
        print('No')


if __name__ == "__main__":
    solve()

Measured memory_bytes: 61816
/// d.cpp

# include <stdio.h>
# include <bits/stdc++.h>
using namespace std;
const pair < int , int > DD[] = {{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define IOS ios_base :: sync_with_stdio(0);cin.tie(0)
# define p(v) cerr << #v << " = " << v << '\n'
# define p2(v) cerr << #v << " = " << (complex < __typeof(v.x) > (v.x,v.y)) << '\n'
# define vi vector < int >
# define vl vector < ll >
# define pll pair < ll , ll >
# define pii pair < int , int >
# define mp make_pair
# define db long double
# define fail puts("-1")
# define yes puts("YES")
# define no puts("NO")
# define PP puts("Possible")
# define II puts("Impossible")
# define vii vector < pii >
# define vll vector < ll >
# define pb push_back
# define pdd pair < db , db >
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
int main(void)
{
    #ifdef CF
    freopen("input","r",stdin);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    int n;
    fi>>n;
    static char s[1 << 20];
    fi>>(s + 1);
    static int ans[1 << 20];
    for (int a = 0;a < 2;++a)
        for (int b = 0;b < 2;++b)
        {
            ans[1] = a;
            ans[2] = b;
            for (int i = 3;i <= n;++i)
            {
                int how = s[i - 1] == 'o' ? 0 : 1;
                ans[i] = ans[i - 2] ^ ans[i - 1] ^ how;
            }
            int ok = 1;
            int prev = n;
            int next = 2;
            for (int i = 1;i <= n;++i)
            {
                ok &= (ans[i] ^ (s[i] == 'o')) == (ans[prev] == ans[next]);
                ++prev;
                ++next;
                if (prev > n)
                    prev -= n;
                if (next > n)
                    next -= n;
            }
            if (ok)
            {
                for (int i = 1;i <= n;++i)
                    fo << (ans[i] ? 'W':'S');
                fo << '\n';
                exit(0);
            }
        }
    fail;
    cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <assert.h>
#include <numeric>

using namespace std;

const bool TEST = false;

int
gcd ( int a, int b )
{
    int c;
    while ( a != 0 ) {
        c = a; a = b%a;  b = c;
    }
    return b;
}

int solve() {
    string str;
    cin >> str;
    
    set<char> s;
    for (int i = 0; i < str.length(); i++) {
        s.insert(str[i]);
    }
    
    if (s.size() == 3) {
        cout << "Yes" << endl;
    }else {
        cout << "No" << endl;
    }
    return 0;
}

int main() {
    solve();
    while (TEST) {
        solve();
    }
}


Measured memory_bytes: 256