akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using loop = int;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(loop (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(loop (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(loop (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(loop (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n, k; cin >> n >> k;
    int a = 1;
    FOR(i, 0, n) {
        if (a < k)a <<= 1;
        else a += k;
    }
    cout << a << "\n";
}

Measured memory_bytes: 256
from collections import deque

times = int(input())
stack = deque()
for i in range(times):
    op = input().split()
    if op[0] == "insert":
        stack.appendleft(op[1])
    if op[0] == "delete":
        if op[1] in stack:
            stack.remove(op[1])
    if op[0] == "deleteFirst":
        stack.popleft()
    if op[0] == "deleteLast":
        stack.pop()
print(*stack)


Measured memory_bytes: 69732
using System;
using static System.Console;

namespace abc178
{
    class Program
    {
        static void Main()
        {
            var n = int.Parse(ReadLine());
            var points = new int[n][];
            for (var i = 0; i < n; ++i)
            {
                var xy = ReadLine().Split(' ');
                points[i] = new int[] { int.Parse(xy[0]), int.Parse(xy[1]) };
            }
            WriteLine(DistMax(points));
        }
        static int DistMax(int[][] points)
        {
            var sMin = int.MaxValue;
            var sMax = 0;
            var bsMin = int.MaxValue;
            var bsMax = 0;
            foreach (var point in points)
            {
                sMin = Math.Min(sMin, point[0] + point[1]);
                sMax = Math.Max(sMax, point[0] + point[1]);
                bsMin = Math.Min(bsMin, point[1] - point[0]);
                bsMax = Math.Max(bsMax, point[1] - point[0]);
            }
            return Math.Max(sMax - sMin, bsMax - bsMin);
        }
    }
}


Measured memory_bytes: 51536
#include<cstdio>
#include<cstring>
#define int long long
const int mod=1000000007;
inline int sqr_mod(int a,int m){return a*a%m;}
int pow_mod(int a,int n,int m)
{
	if(!n)return 1;
	if(n&1)return sqr_mod(pow_mod(a,n>>1,m),m)*a%m;
	return sqr_mod(pow_mod(a,n>>1,m),m);
}
int inverse(int n){return pow_mod(n,mod-2,mod);}
int n,a,b[200000],d,fac[200000],inv[200000];
inline int C(int n,int m){return fac[n]*inv[m]%mod*inv[n-m]%mod;}
signed main()
{
	scanf("%lld",&n);
	memset(b,-1,sizeof b);
	for(int i=0;i<=n;i++)
	{
		scanf("%lld",&a);
		if(b[a]==-1)b[a]=i;
		else d=i-b[a];
	}
	fac[0]=inv[0]=1;
	for(int i=1;i<=n+1;i++)fac[i]=fac[i-1]*i%mod,inv[i]=inverse(fac[i]);
	for(int k=1;k<=n+1;k++)
	{
		int ans=C(n+1,k);
		if(n-d>=k-1)ans-=C(n-d,k-1);
		printf("%lld\n",(ans+mod)%mod);
	}
	return 0;
}


Measured memory_bytes: 5248
#include <stdio.h>

int main(void)
{
	int h, w;
	int i, j;

	while(scanf("%d %d", &h, &w)!=EOF && !(h==0 && w==0)){
		for(i=0;i<h;i++){
			for(j=0;j<w;j++)
				printf("#");
			printf("\n");
		}
		printf("\n");
	}

	return 0;
}

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

using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n); i > 0; i--)
#define all(n) n.begin(), n.end()
#define print(n) cout << n << endl

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    ll x;
    cin >> x;

    ll a=0,b,temp=0,ma=0,mb;
    while(ma - temp < 1000000000){
        mb=0;
        b=0;
        while(mb < abs(ma+x)){
            if(mb==abs(ma-x)){
                print(a << " " << ((ma-x>0)*2-1)*b);
                goto END;
            }
            if(mb==abs(ma+x)){
                print(-a << " " << ((ma+x>0)*2-1)*b);
                goto END;
            }
            b++;
            mb=b*b*b*b*b;
        }
        temp = ma;
        a++;
        ma=a*a*a*a*a;
    }
    END:
    return 0;
}

Measured memory_bytes: 3648
import java.util.Scanner;

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

		if(D / S <= T){System.out.println("Yes");} else {System.out.println("No");}
	}
}

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

using namespace std;

typedef long long llint;

const int MAXN = 200005;
const llint INF = 1000000000000000000LL;

llint n, q, a, b, ofs = 1, sol = INF;
llint val[MAXN], dp[MAXN];

struct node {
    llint mn, prop;
    node () {}
    node (llint _mn, llint _prop) {
        mn = _mn; prop = _prop;
    }
} t[2][4*MAXN];

node spoji (node x, node y) {
    return node(min(x.mn, y.mn), 0);
}

void build () {
    while (ofs < n+1) ofs *= 2;
    for (int i=1; i<2*ofs; i++) {
        t[0][i].mn = t[1][i].mn = INF;
    }
}

void propagate (int x, int ind) {
    if (t[ind][x].prop == 0) return;
    t[ind][x].mn += t[ind][x].prop;
    if (x < ofs) {
        t[ind][2*x].prop += t[ind][x].prop;
        t[ind][2*x+1].prop += t[ind][x].prop;
    }
    t[ind][x].prop = 0;
}

void update (int x, int from, int to, int low, int high, int ind, llint d) {
    propagate(x, ind);
    if (from <= low && high <= to) {
        t[ind][x].prop += d;
        propagate(x, ind);
        return;
    }
    if (to < low || high < from) return;
    update(2*x, from, to, low, (low + high)/2, ind, d);
    update(2*x+1, from, to, (low + high)/2+1, high, ind, d);
    t[ind][x] = spoji(t[ind][2*x], t[ind][2*x+1]);
}

llint upit (int x, int from, int to, int low, int high, int ind) {
    propagate(x, ind);
    if (from <= low && high <= to) return t[ind][x].mn;
    if (to < low || high < from) return 2*INF;
    llint v1 = upit(2*x, from, to, low, (low + high)/2, ind);
    llint v2 = upit(2*x+1, from, to, (low + high)/2+1, high, ind);
    return min(v1, v2);
}

void calc () {
    val[0] = b;
    update(1, a, a, 0, ofs-1, 0, -INF - a);
    update(1, a, a, 0, ofs-1, 1, -INF + a);
    for (int i=1; i<=q; i++) {
        llint mn1 = upit(1, 1, val[i], 0, ofs-1, 0) + val[i];
        llint mn2 = upit(1, val[i], n, 0, ofs-1, 1) - val[i];
        dp[i] = min(mn1, mn2);
        update(1, 1, n, 0, ofs-1, 0, abs(val[i] - val[i-1]));
        update(1, 1, n, 0, ofs-1, 1, abs(val[i] - val[i-1]));
        llint t1 = upit(1, val[i-1], val[i-1], 0, ofs-1, 0);
        llint t2 = upit(1, val[i-1], val[i-1], 0, ofs-1, 1);
        if (dp[i] - val[i-1] < t1) update(1, val[i-1], val[i-1], 0, ofs-1, 0, -t1 + dp[i] - val[i-1]);
        if (dp[i] + val[i-1] < t2) update(1, val[i-1], val[i-1], 0, ofs-1, 1, -t2 + dp[i] + val[i-1]);
    }
    llint d = 0;
    for (int i=q; i>=1; i--) {
        sol = min(sol, dp[i] + d);
        d += abs(val[i] - val[i-1]);
    }
    sol = min(sol, d);
}

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> q >> a >> b;
    for (int i=1; i<=q; i++) {
        cin >> val[i];
    }
    build();
    calc();
    cout << sol;
    return 0;
}


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

int main(){
    string s;
    long long ans=0;
    cin>>s;
    for(long long i=0;i<s.size();i++){
        ans+=s[i]-'0';
    }
    if(ans%9==0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3716
#include <iostream>
#include <algorithm>
#include <iomanip>
#include"stdio.h"
#include <cstring>
#include<math.h>
#include<map>
#include<queue>
#include<stack>
#include"time.h"
#define MAX_INT  ((unsigned)(-1)>>1)
#define MIN_INT  (~MAX_INT)
#define db printf("where!\n");
#define pb push_back
using namespace std;
#define ll long long
ll gcd(ll x,ll y){return y ? gcd(y,x%y) : x;}
template<class T>inline void read(T &res){
char c;T flag=1;
while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;res=c-'0';
while((c=getchar())>='0'&&c<='9')res=res*10+c-'0';res*=flag;
}

int main()
{
    ll n;cin>>n;
    int ans=0;
    ll a=100;
    while(a<n){
        ans++;
        a*=1.01;
    }
    cout<<ans;
	return 0;
}

Measured memory_bytes: 3168
use v5.18; # strict say state
use warnings;
use List::Util qw(reduce first max min sum0);

chomp (my $x = <STDIN>);

my $ans = length $x;
my ($sc, $tc);
for my $i (0..length($x)) {
  if ($i == length($x)) {
    if ($sc > 0 && $tc > 0) {
      $ans -= 2 * min($sc, $tc);
    }
  } elsif (substr($x, $i, 1) eq 'S') {
    if ($sc > 0 && $tc > 0) {
      $ans -= 2 * min($sc, $tc);
      $sc = ($sc-$tc>0)?($sc-$tc):0;
      $tc = 0;
    }
    $sc++;
  } else {
    $tc++ if $sc > 0;
  }
}
say $ans;

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

using namespace std;

int main(){
    int h,w;
    cin>>h>>w;
    vector<string> hoge(h);
    
    for(int i=0;i<h;i++) cin>>hoge.at(i);
    
    string ans="Yes";
    
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            bool flag=true;
            if(hoge.at(i).at(j)=='.') flag=false;
            if(i>0 && hoge.at(i).at(j)=='#' && hoge.at(i-1).at(j)=='#') flag=false;
            if(i<h-1 && hoge.at(i).at(j)=='#' && hoge.at(i+1).at(j)=='#') flag=false;
            if(j>0 && hoge.at(i).at(j)=='#' && hoge.at(i).at(j-1)=='#') flag=false;
            if(j<w-1 && hoge.at(i).at(j)=='#' && hoge.at(i).at(j+1)=='#') flag=false;
            
            if(flag){
                ans="No";
                goto skip;
            }
        }
    }
    
    skip:
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <cassert>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <list>
#include <forward_list>
#include <array>
#include <cstring>
#include <cmath>
#include <tuple>
#include <complex>
#include <bitset>
#include <climits>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using LD = long double;
using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pld = pair<LD, LD>;
int N, M, Q;
int max_score = 0;
vector<int> A;
vector<array<int, 4>> quadruples;


void solve(const int beg_nr, const int n, const int k)
{
    if (k == 0)
    {
        int cur_score = 0;
        for (const array<int, 4> &quadruple : quadruples)
        {
            const int &a = quadruple[0] - 1, &b = quadruple[1] - 1, &c = quadruple[2], &d = quadruple[3];

            if (A[b] - A[a] == c)
            {
                cur_score += d;
            }
        }

        max_score = max(max_score, cur_score);
        
        /*cerr << "A: ";
        for (auto &z : A)
        {
            cerr << z << " ";
        }
        cerr << endl;*/
        return;
    }

    for (int j = beg_nr; j <= M; ++j)
    {
        A.emplace_back(j);
        solve(j, n, k - 1);
        A.pop_back();
    }
}


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

    cin >> N >> M >> Q;
    quadruples.resize(Q);
    for (array<int, 4> &quadruple : quadruples)
    {
        for (int i = 0; i < 4; ++i)
        {
            cin >> quadruple[i];
        }
    }

    solve(1, N + M - 1, N);

    cout << max_score;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
#define endl '\n'
#define ld long double
#define all(a) a.begin(),a.end()
#define int long long
#define pb push_back
#define pii pair <int, int>
#define ff first
#define ss second
#define sz(v) (int)v.size()
#define UB upper_bound
#define LB lower_bound
#define BP(x) __builtin_popcountll(x)
#define PQS priority_queue <int, vector<int>, greater<int> >
#define OST tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int getRand(int l, int r) {
  uniform_int_distribution<int> uid(l, r);
  return uid(rng);
}

const ll INF = 1e18 + 0;
const ll mod = 1e9 + 7;
//const int mod = 998244353;

ll mul(ll a, ll b) {
  a += mod; b += mod;
  a %= mod; b %= mod; return ((a * b) % mod);
}
void solve(){
    ll n,k;
    cin>>n>>k;
    ll K=k;
    vector<ll>pos,neg,zero;
    for(ll i=0;i<n;i++){
        ll d;
        cin>>d;
        if(d>0)pos.push_back(d);
        else if(d<0)neg.push_back(abs(d));
        else zero.push_back(d);
    }
    sort(pos.begin(),pos.end(),greater<ll>());sort(neg.begin(),neg.end(),greater<ll>());
    ll ans=1;
    ll pcur=0,ncur=0;
    if(k%2){
        if(pos.size()){
            ans=mul(ans,pos[pcur]);
            pcur++;
            k--;
        }
    }
    while(k && (pcur+1<(ll)pos.size() || ncur+1<(ll)neg.size())){
        ll val1=-INF,val2=-INF;
        if(pcur+1<(ll)pos.size()){
            val1=pos[pcur] * pos[pcur+1];
        }
        if(ncur+1<(ll)neg.size()){
            val2=neg[ncur] * neg[ncur+1];
        }
        if(val1>val2){
            ans=mul(ans,val1);
            pcur+=2;
        }
        else{
            ans=mul(ans,val2);
            ncur+=2;
        }
        k-=2;
    }
    if(k){
        if(!zero.empty()){
            ans=0;
            cout<<ans<<endl;
            return;
        }
        ans=1;
        vector<pair<ll,ll>>v;
        for(auto i:pos)v.push_back({i,1});
        for(auto i:neg)v.push_back({i,-1});
        for(auto i:zero)v.push_back({i,1});
        sort(v.begin(),v.end());
        for(ll i=0;i<K;i++){
            ans=mul(ans,v[i].first * v[i].second);
        }
    }
    cout<<ans<<endl;
    return;
}
signed main() {
  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
   int t = 1;  //cin >> t;
   for(int i = 1; i <= t; i++) {
     solve();
  }
}



Measured memory_bytes: 8876
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <climits>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string.h>
#include <iomanip>
#include <ctype.h>

#define ll          long long int
#define ull         unsigned long long int
#define pb          push_back
#define pii         pair<int,int>
#define F         first
#define S          second
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define M_PI        3.14159265358979323846
#define mp          make_pair
#define sz(x)       (int)x.size()
#define hell        1000000007
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define eps 1e9
#define all(a)      (a).begin(),(a).end()
const long long INF = (long long) 1e9+1;


using namespace std;
void solve();

void fastIO() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}

int main(){
   fastIO();
    solve();
}
//void sieve();
ll pw(ll k,ll x);
ll gcd(ll x,ll y);

void solve(){

  int n,w;
  cin>>n>>w;
  int wt[n];
  ll val[n];

  forn(i,0,n){
    cin>>wt[i]>>val[i];
  }
  int v=100001;
  ll dp[n+1][v];
  forn(i,0,n+1){
    forn(j,0,v)
    dp[i][j]=INF;
  }
  for(int i=0;i<=n;i++)
  dp[i][0]=0;

  for(int i=1;i<=n;i++){
    for(int j=1;j<v;j++){
      dp[i][j]=dp[i-1][j];
      dp[i][j]=min(dp[i][j],dp[i-1][j-val[i-1]]+wt[i-1]);
    }
  }

  int ans=0;
  for(int i=1;i<=n;i++){
    for(int j=1;j<v;j++){
      if(dp[i][j]<=w){
        ans=max(ans,j);
      }
    }
  }
  cout<<ans;
}


///Before submit=>
///    *check for integer overflow,array bounds
///    *check for n=1

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


ll pw(ll k,ll x){
  if(x==0)
  return 1;
  if(x&1)
  return ((pw(k,x-1)%hell)*k%hell)%hell;
  else
  return ((pw(k,x/2)%hell)*(pw(k,x/2)%hell))%hell;
}

/*void sieve(){

  for(int i=2;i<=1000000;i++){
    if(prime[i]==true){
      for(int j=i*i;j<=1000000;j+=i)
      prime[j]=false;
    }
  }

}*/


Measured memory_bytes: 79232
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  [n, d] <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  let
    p :: (Int, Int) -> Bool
    p (x, y) = x * x + y * y <= d * d
  xys <- sequence . replicate n $ unsafeListToPair . map unsafeTextToInt . T.words <$> T.getLine :: IO [(Int, Int)]
  print . length . filter p $ xys

unsafeListToPair :: [Int] -> (Int, Int)
unsafeListToPair [x, y] = (x, y)
{-# INLINE unsafeListToPair #-}

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n
{-# INLINE unsafeTextToInt #-}


Measured memory_bytes: 66160
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int a=0,b=0;
	string s="",t="";
	char c;

	cin>>  a ;
	cout<< a/3 <<endl;
	
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define MOD (int) (1e9+7)
#define INF (int) 2e9
#define LLINF (ll) 2e18

int main(){
    int n;
    cin >> n;
    ll a[n];
    rep(i, n){
        cin >> a[i];
    }

    ll ans = 0;
    rep(j, 60){
        ll zero = 0, ichi = 0;
        rep(i, n){
            if(a[i]%2==0){
                zero++;
            }else{
                ichi++;
            }
            a[i]/=2;
        }
        ans +=  (zero * ichi)%MOD * ((ll)pow(2, j)%MOD);
        ans %= MOD;
    }

    cout << ans << endl;
    // printf("%d\n", N);
    return 0;
}

Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {
	static final int[] HAIKU = { 5, 7, 5, 7, 7 };
	int n;
	int[] w;

	void run() {
		Scanner scan = new Scanner(System.in);
		while (true) {
			n = scan.nextInt();
			if (n == 0)
				break;
			w = new int[n];
			for (int i = 0; i < n; i++)
				w[i] = scan.next().length();
			solve();
		}
	}

	void solve() {
		int index = 0;
		int sum = 0;
		int count = 0;
		int i = index;
		while (i < n) {
			sum += w[i++];
			if (sum == HAIKU[count]) {
				sum = 0;
				count++;
			} else if (sum > HAIKU[count]) {
				index++;
				i = index;
				sum = 0;
				count = 0;
			}
			if (count == HAIKU.length) {
				System.out.println(index + 1);
				return;
			}
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 32352
package main

import "fmt"

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)

	m := make(map[int]bool)
	m[a], m[b], m[c] = true, true, true
	if len(m) == 2 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

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

    int A[100][100];
    int b[100];
    int c[100];



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

    for (int j = 0; j < m; j++) {
      
        cin >> b[j];
        
    }
        
    
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            c[i] += A[i][j]*b[j];
            
            
        }
    }    

    for (int x = 0; x < n; x++)
        cout << c[x] << endl;
        
        

    
}


Measured memory_bytes: 3120
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<vector>
#include<cstring>
#define SF scanf
#define PF printf
#define MAXN 200010
using namespace std;
int n,m;
int a[MAXN],b[MAXN];
bool check(int x){
	for(int i=1;i<=m;i++)
		b[i]=(a[i]>=x);
	for(int i=0;i<n-1;i++){
		if(b[n+i]==b[n+i+1])
			return b[n+i];
		if(b[n-i]==b[n-i-1])
			return b[n-i];
	}
	return b[1];
}
int main(){
	SF("%d",&n);
	m=2*n-1;
	for(int i=1;i<=m;i++)
		SF("%d",&a[i]);
	int l=1,r=m,ans=m;
	while(l<=r){
		int mid=(l+r)>>1;
		if(check(mid)){
			l=mid+1;
			ans=mid;
		}
		else
			r=mid-1;
	}
	PF("%d",ans);
}

Measured memory_bytes: 1664
#include <iostream>

using namespace std;

typedef pair<int , int> P;

int main()
{
    int n, t; cin >> n >> t;
    int ans = 1001;

    P ct;
    for (int i = 0; i < n; i++) {
        cin >> ct.first >> ct.second;
        if (ct.second <= t && ct.first < ans) {
            ans = ct.first;
        }
    }

    if (ans == 1001) cout << "TLE" << endl;
    else cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
V = [None] + [[] for _ in range(n)]
for i in range(m):
    a, b= map(int,input().split())
    V[a].append(b)
    V[b].append(a)

from collections import deque
q = deque()
reach = [None] + [0] + [-1]*(n-1)
goal  = [None] + [0]*n
for L in V[1]:
    q.append(L)
    reach[L] = reach[1] + 1
    goal[L] = 1
while q:
    p = q.popleft()
    for L in V[p]:
        if reach[L] == -1:
            q.append(L)
            reach[L] = reach[p] + 1
            goal[L] = p
print("Yes")
for i in range(len(goal)-2):
    print(goal[i+2])

Measured memory_bytes: 35596
n,m = gets.split.map &:to_i
red = Array.new(n){ false }
red[0] = true
num = Array.new(n){ 1 }

m.times do
  
  x,y = gets.split.map &:to_i
  x -= 1
  y -= 1
  num[y] += 1
  num[x] -= 1
  
  red[y] ||= red[x]
  red[x] &&= num[x] > 0
end

puts red.select(&:itself).size


Measured memory_bytes: 4092
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;

int main(){
	string s;
	cin>>s;
	if((s[6]=='1'||s[6]=='2'||s[6]=='3'||s[6]=='4')&&s[5]=='0'){
		cout<<"Heisei"<<endl;
	}
	else{
		cout<<"TBD"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;
string str,ans;
char t[8][5];

void write(int x,int num){
  if(num>=5){
    t[0][x]=' ';t[1][x]='*';
  }else{
    t[0][x]='*';t[1][x]=' ';
  }
  t[2][x]='=';
  
  
  for(int i=3;i<8;i++)t[i][x]='*';
  t[3+num%5][x]=' ';
}

int main(){
  int z;
  string str;
  cin>>str;
  while(1){
    z=5-str.size();
    for(int i=0;i<z;i++){
      write(i,0);
    }
    for(int i=0;i<(int)str.size();i++){
      write(i+z,str[i]-'0');
    }
    for(int i=0;i<8;i++){
      for(int j=0;j<5;j++){
	cout<<t[i][j];
      }
      cout<<endl;
    }
    if(cin>>str){}else break;
    cout<<endl;
  }
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    vint a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    --k;

    cout << a[k] << endl;
    return 0;
}

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

using namespace std;

void action()
{
    long long n,m;
    scanf("%lld%lld",&n,&m);
    long long c1 = max(n,m);
    long long c2 = min(n,m);
    if(c2 == 1)
    {
        if(c1==1) printf("1\n");
        else
            printf("%lld\n",c1-2);
    }
    else
        printf("%lld\n",(c2-2)*(c1-2));

}
int main()
{
    action();
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>

#define rep(i, n)for(ll i=0;i<n;i++)
#define ll long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define inf 1000000007
#define double long double
using namespace std;
typedef pair<ll, ll> P;

bool prime(int n) {
    int cnt = 0;
    for (int i = 1; i <= sqrt(n); i++) {
        if (n % i == 0)cnt++;
    }
    if (cnt != 1)return false;
    else return n != 1;
}

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

ll lcm(ll x, ll y) {
    return x * y / gcd(x, y);
}

ll mod_pow(ll x, ll n, ll mod) {
    ll bit = 1;
    while (n) {
        if (n & 1)bit = bit * x % mod;
        x = x * x % mod;
        n /= 2;
    }
    return bit;
}

ll C(ll a, ll b) {
    ll x = 1, y = 1;
    rep(i, b) {
        x = x * (a - i) % inf;
        y = y * (b - i) % inf;
    }
    rep(i, inf) {
        if (x == y * i % inf) {
            return i;
        }
    }
}

P a[3333];
ll dp[3333][6666];

signed main() {
    ll n, w;
    cin >> n >> w;
    rep(i, n)cin >> a[i].first >> a[i].second;
    sort(a, a + n);
    for (int i = 0; i < n; i++) {
        for (ll j = 0; j < 6666; j++) {
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
            if (j <= w - 1)dp[i + 1][j + a[i].first] = max(dp[i][j] + a[i].second, dp[i][j + a[i].first]);
        }
    }
    ll ans, p = -11;
    for (int i = 0; i < 6666; i++) {
        ans = max(p, dp[n][i]);
        if (p < dp[n][i])p = dp[n][i];
    }
    cout << ans << endl;
    ggr
}

Measured memory_bytes: 157952
#include<bits/stdc++.h>
#define lf double
#define ll long long
#define ii pair<int,int>
#define li pair<ll,int>
#define iii pair<ii,int>
#define iiii pair<ii,ii>
#define pll pair<ll,ll>
#define ld long int
#define heap priority_queue
#define mp make_pair
#define st first
#define nd second
#define pb push_back
#define pp pop_back
#define all(x) x.begin(),x.end()
#define len(x) strlen(x)
#define sz(x) (int) x.size()
#define orta ((bas+son)/2)
#define min3(x,y,z) min(min(x,y),z)
#define max3(x,y,z) max(max(x,y),z)
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define MOD 1000000007
#define inf 10000000000009
#define N 100005
#define LOG 33
#define M 10
#define EPS 0.0000001
using namespace std; 

int main() {  

	int n,m;
	scanf("%d %d",&n,&m);
	int tot=(n-m)*100+m*1900;
	for(int i=1;i<=m;i++) tot*=2;
	printf("%d",tot);	

}

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

using namespace std;

const int MAX = 1000;

char c;

int main()
{
  cin >> c;

  if((int)c >= 97 && (int)c <= 122)
  {
    cout << 'a';
  }
  else
  {
    cout << 'A';
  }
  
  return 0;
}

Measured memory_bytes: 3624
#include <iostream>

using namespace std;

long long  dp[11][1001];

void compute(void){

  for( int i = 0 ; i < 11 ; i++ ){
    for( int j = 0 ; j < 1001 ; j++ ){
      dp[i][j] = 0;
    }
  }

  dp[0][0] = 1;

  for( int i = 0 ; i <= 100 ; i++ ){  // 同じ数は１度しか使えないので、for３つ目でi+kををやる必要がある。
      for( int j = 9 ; j >= 0 ; j-- ){// 入力される n は１~9だから最高で９回ループを行う
	for( int k = 0 ; i+k <= 1000 ; k++ ){  //入力される s は最高1000
	dp[j+1][k+i] += dp[j][k];
      }
    }
  }
}

int main(void){

  compute();

  int n,s;
  while( cin >> n >> s, n || s ){
  cout << dp[n][s] << endl;
  }
  return 0;
}

Measured memory_bytes: 1240
from bisect import bisect_left
n = int(input())
S = list(map(int, input().split()))
p = int(input())
T = list(map(int, input().split()))

ans = 0
def sh(num):
    ind = bisect_left(S, num)
    return S[ind] == num

for t in T:
    if sh(t):
        ans += 1
print(ans)


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

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> A(N);
	for (int i = 0; i < N; i++) cin >> A[i];
	if (K >= N) {
		for (int i = 0; i < N; i++) cout << N << (i < N - 1 ? " " : "\n");
		return 0;
	}
	for (int i = 0; i < K; i++) {
		vector<int> B(N);
		for (int i = 0; i < N; i++) {
			B[max(0, i - A[i])]++;
			if (i + A[i] + 1 <= N - 1) B[i + A[i] + 1]--;
		}
		int now = 0;
		bool all = true;
		for (int i = 0; i < N; i++) {
			now += B[i];
			A[i] = now;
			if (A[i] < N) all = false;
		}
		if (all) break;
	}
	for (int i = 0; i < N; i++) cout << A[i] << (i < N - 1 ? " " : "\n");
}

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

using namespace std;

namespace program
{
	const int MAXN = 300, MAXM = 300, INF = 0x3f3f3f3f;
	bool Vis[MAXM + 10];
	int A[MAXN + 10][MAXM + 10];
	int Pos[MAXN + 10];
	vector<int> T[MAXM + 10];

	void work()
	{
		int n, m, ans = INF;
		scanf("%d%d", &n, &m);
		for(int i = 1; i <= n; i++)
		{
			for(int j = 1; j <= m; j++)
				scanf("%d", &A[i][j]);
			T[A[i][1]].push_back(i);
			Pos[i] = 1;
		}
		for(int i = 1; i <= m; i++)
		{
			int mx = 0;
			for(int j = 1; j <= m; j++)
				if(!Vis[j] && T[j].size() > T[mx].size())
					mx = j;
			if(T[mx].size() < ans)
				ans = T[mx].size();
			Vis[mx] = 1;
			for(vector<int>::iterator p = T[mx].begin(); p != T[mx].end(); p++)
			{
				while(Vis[A[*p][Pos[*p]]])
					Pos[*p]++;
				T[A[*p][Pos[*p]]].push_back(*p);
			}
		}
		printf("%d\n", ans);
	}
}

int main()
{
	program::work();
	return 0;
}


Measured memory_bytes: 1280
N, K = map(int, input().split())
H = list(map(int, input().split()))
dp = [0] * N
for i in range(1, N):
    dp[i] = min(dp[i-j] + abs(H[i] - H[i-j]) for j in range(1, min(i, K) + 1))
print(dp[-1])

Measured memory_bytes: 53344
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <queue>
#include<iomanip>
#include <cmath>
#include <set>

#define ABS(x) ((x)>0?(x):-(x))
#define MIN(x,y) ((x)>(y)?(y):(x))

using namespace std;
typedef long long ll;

ll newton(long long int a, long long int  b)
{
	if(a==b)
		return a;
	while(a != 0 && b != 0)
	{
		if(a > b)
		{
			b += a;
			a = b-a;
			b -= a;
		}
		b %= a;
	}
	return a;
}

struct UnionFind {
	vector<int> p;
	UnionFind(int N):p(N)
	{
		for(int i=0; i< N; i++)
		{
			p[i] = i;
		}
	}
	int root(int x)
	{
		if(p[x] == x)
			return x;
		return p[x] = root(p[x]);
	}
	void unite(int x, int y)
	{
		int rx = root(x);
		int ry = root(y);
		if(rx == ry) return;
		p[rx] = ry;
	}
	bool issame(int x, int y)
	{
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

//大きな数に対する割り算をするとき、MODを指定することで掛け算の値に変換できる

ll div2mul_calc(ll a, ll b, ll m)
{
	if (b == 0) {
        return 1;
    } else if (b % 2 == 0) {
        ll d = div2mul_calc(a, b / 2, m);
        return (d * d) % m;
    } else {
        return (a * div2mul_calc(a, b - 1, m)) % m;
    }
}
ll div2mul(ll n, ll mod)
{
	return div2mul_calc(n, mod-2, mod);
}
ll dive10(ll b, ll s, ll n, ll m)
{
	b = div2mul_calc(b, n, m);
	ll i = 1;
	ll c = b;
	ll r = 1;
	ll t = b;
	ll k = 1;
	while(i)
	{
		if(i&s)
		{
			r += c*k;
			r %= m;
			k *= t;
			k %= m;
		}
		c = c + c*t;
		c %= m;
		t = t*t;
		t %= m;
		i <<= 1;
	}
	return r;
}
ll divet10(ll b, ll s, ll n, ll m)
{
	b = div2mul_calc(b, n, m);
	ll i = 1;
	ll c = b;
	ll r = 1;
	ll t = b;
	ll k = 1;
	while(i)
	{
		if(i&s)
		{
			r += c*k;
			r %= m;
			k *= t;
			k %= m;
		}
		c = c + c*t;
		c %= m;
		t = t*t;
		t %= m;
		i <<= 1;
	}
	return r;
}
ll big(int n)
{
	ll ret = 1;
	for(int i=2;i<=n;++i)
	{
		ret*=2;
	}
	return ret;
}
int main()
{
	ll A,B,C,D;
	cin>>A>>B>>C>>D;
	ll c=C,d=D;
	if(c>d)
	{
		d+=c;
		c = d-c;
		d = d-c;
	}
	while(d%c!=0)
	{
		d %=c;
		d+=c;
		c = d-c;
		d = d-c;
	}
	ll E=C/c*D;
	cout << (B-A+1-(ll)(B/C)+(ll)((A-1)/C)-(ll)(B/D)+(ll)((A-1)/D)+(ll)(B/E)-(ll)((A-1)/E)) << endl;

	return 0;
}




































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

#define INF 1e9;
#define mod 1e9+7

//#define max(x,y) (x>y)?x:y
//#define min(x,y) (x<y)?x:y
#define rep(i,j,k) for(int i=j;i<k;i++)
#define repp(i,j,k) for(int i=j;i>=k;i--)
#define mi(n) (int*)malloc(sizeof(int)*n);
#define mc(n) (char*)malloc(sizeof(char)*n);

using namespace std;


int main(){
   int n,m;
   cin>>n>>m;
   vector<vector<char>> v(n,vector<char>(n));
   vector<vector<char>> vv(m,vector<char>(m));
   
   rep(i,0,n) rep(j,0,n) cin>>v[i][j];
   rep(i,0,m) rep(j,0,m) cin>>vv[i][j];
   
   rep(i,0,n-m+1){
       rep(j,0,n-m+1){
           bool judge=true;
           rep(k,i,i+m){
               rep(p,j,j+m){
                   if(v[k][p]!=vv[k-i][p-j]) judge=false;
               }
           }
           if(judge) {
               cout<<"Yes"<<endl;
               return 0;
           }
       }
       
   }
   
   cout<<"No"<<endl;
   
   
   

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

typedef struct {
    char name[6];
    int n;
} DATA;

int main(void)
{
    int n;
    DATA data[1000], t;
    char name[6];
    int num;
    int i, j, k;
    int count;
    
    scanf("%d", &n);

    count = 0;
    for (i = 0; i < n; i++){
        scanf("%s", name);
        scanf("%d", &num);
        for (j = 0; j < count; j++){
            if (strcmp(name, data[j].name) == 0){
                break;
            }
        }
        if (j == count){
            strcpy(data[j].name, name);
            data[j].n = num;
            count++;
        }
        else {
            data[j].n += num;
        }
    }

    for (j = 0; j < count; j++){
        for (k = 0; k < count - 1; k++){
            if (strlen(data[k].name) > strlen(data[k + 1].name)){
                t = data[k];
                data[k] = data[k + 1];
                data[k + 1] = t;
            }
            else if (strlen(data[k].name) == strlen(data[k + 1].name)){
                if (strcmp(data[k].name, data[k + 1].name) > 0){
                    t = data[k];
                    data[k] = data[k + 1];
                    data[k + 1] = t;
                }
            }
        }
    }

    for (j = 0; j < count; j++){
        printf("%s %d\n", data[j].name, data[j].n);
    }
    return (0);
}


    

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

int main()
{
	int month_1 = 0, day_1 = 0, month_2 = 0, day_2 = 0;
	cin >> month_1 >> day_1 >> month_2 >> day_2;
	if (day_1 + 1 == day_2)
		cout << 0;
	else
		cout << 1;
	return 0;
}

Measured memory_bytes: 256
'use strict'

const main = (INPUT) => {
  const N = Number(INPUT.split('\n')[0])
  const W = INPUT.split('\n').slice(1)
  let ans = 'Yes'
  for (let i = 0; i < W.length - 1; i++) {
    for (let j = i + 1; j < W.length; j++) {
      if (W[i] == W[j]) {
        ans = 'No'
      }
    }
  }
  for (var i = 0; i < N - 1; i++) {
    if (W[i].slice(-1) != W[i + 1].slice(0, 1)) {
      ans = 'No'
    }
  }
  console.log(ans)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 7372
var print = console.log;

function read_input(_input) {
    var lines = _input.split("\n");
    return function () {
        return lines.shift();
    };
}



// input?????\??????????????¨????????\???
function Main(_input) {
    var input = read_input(_input); // input = ?????????????????¢??°
    var N = input() - 0;
    for (var i = 0; i < N; i++) {
        var out = 0;
        var runner = 0;
        var pt = 0;
        while (out < 3) {
            var v = input();
            if (v === 'HIT') {
                runner++;
                if (runner === 4) {
                    pt++;
                    runner--;
                }
            } else if (v === 'HOMERUN') {
                pt += runner + 1;
                runner = 0;
            } else {
                out++;
            }
        }
        print(pt);
    }

}

//*???????????\????????¨??????????????§????????????????¨??????\????????????????????????????????????Main????????????????????????
 Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//Main(require("fs").readFileSync("input.txt", "utf8"));

Measured memory_bytes: 15284
import java.util.*;
public class Main {

		static void solve() {
			Scanner sc = new Scanner(System.in);
			String s = sc.next();
			String res = "Yes";
			if(s.equals("BBB")||s.equals("AAA")) {
				res = "No";
			}
			System.out.println(res);
			sc.close();
		}
	public static void main(String[] args) {
		solve();

	}

}


Measured memory_bytes: 23764
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A = sorted(A, reverse=True)
B = sorted(B, reverse=True)
C = sorted(C, reverse=True)

ab = []
for a in A:
  for b in B:
    ab += [a+b]
ab = sorted(ab, reverse=True)
ab = ab[:X+Y+Z+1]

ans = []
for n in ab:
  for c in C:
    ans += [n+c]
ans = sorted(ans, reverse=True)
for i in range(K):
  print(ans[i])


Measured memory_bytes: 146252
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#define rep(i,n) for (int i=0; i<n;++i)
#define rep_down(i,n) for (int i=n-1; i>=0;--i)
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
ll N, K;
ll A[2001];
ll B[2001];
ll C[2001];

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

  cin >> N >> K;
  rep(i, N) cin >> A[i];

  rep(i, N-1){
    for (int j=i+1; j<N;j++){
      if (A[i] > A[j]) B[i]++;
    }
  }
  for (int i=1; i<N;i++){
    rep(j, i){
      if (A[i] > A[j]) C[i]++;
    }
  }

  ll q = ((K+1)*K)/2ll;
  ll q2 = ((K-1)*K)/2ll;
  q%=MOD;
  q2%=MOD;
  ll ans = 0ll;
  rep(i, N){
    B[i]=q*B[i];
    C[i]=q2*C[i];
    ans+=B[i]+C[i];
    ans%=MOD;
  }
  cout << ans << "\n";
  return 0;
}


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

using namespace std;

map<int, int> memo;

bool is_prim(int n) {
  if (n == 1) return false;
  if (n == 2) return true;
  if ((n % 2) == 0) return false;

  // NOTE: Return cached result
  if (memo.find(n) != memo.end()) {
    return memo[n];
  }

  bool isPrime = true;

  for (int i = 3; i * i <= n; ++i) {
    // Check dividability
    if ((n % i) == 0) {
      isPrime = false;
      break;
    }
  }

  // NOTE: Cache result
  memo[n] = isPrime;

  return isPrime;
}

int count_prim(int n) {
  map<int, int> p;
  int r = 0;

  for(int i = 2; i <= n / 2; ++i) {
    // NOTE: only for debug
    // cout << i << ": " << is_prim(i) << endl;
    // cout << n - i << ": " << is_prim(n - i) << endl;
    if (is_prim(i) && is_prim(n - i)) {
      ++r;
    }
  }

  return r;
}

int main(int argc, char** argv) {
  int n;
  // NOTE: only for debug
  // cout << "is_prim(1): " << is_prim(1) << endl;
  // cout << "is_prim(2): " << is_prim(2) << endl;
  // cout << "is_prim(3): " << is_prim(3) << endl;
  // cout << "is_prim(4): " << is_prim(4) << endl;
  // cout << "is_prim(5): " << is_prim(5) << endl;
  // cout << "is_prim(6): " << is_prim(6) << endl;
  // cout << "is_prim(7): " << is_prim(7) << endl;
  // cout << "is_prim(8): " << is_prim(8) << endl;
  // cout << "is_prim(9): " << is_prim(9) << endl;
  // cout << "is_prim(10): " << is_prim(10) << endl;
  // cout << "is_prim(11): " << is_prim(11) << endl;
  // cout << "is_prim(12): " << is_prim(12) << endl;
  // cout << "is_prim(13): " << is_prim(13) << endl;
  // cout << "is_prim(14): " << is_prim(14) << endl;
  // cout << "is_prim(15): " << is_prim(15) << endl;
  // cout << "is_prim(16): " << is_prim(16) << endl;
  // cout << "is_prim(17): " << is_prim(17) << endl;
  // cout << "is_prim(18): " << is_prim(18) << endl;
  // cout << "is_prim(19): " << is_prim(19) << endl;
  // cout << "is_prim(20): " << is_prim(20) << endl;
  cin >> n;
  while (n != 0) {
    // Do here
    // cout << n << endl;
    int r = count_prim(n);
    cout << r << endl;

    cin >> n;
  }
  return 0;
}



Measured memory_bytes: 3720
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt(); 
    
    int c0 = 0;
    int c1 = 0;
    int c2 = 0;
    int c3 = 0;
    
    for(int i=0; i<N; i++){
      String S=sc.next();
      
      if(S.equals("AC")){
        c0++;
      } else if(S.equals("WA")){
        c1++;
      } else if(S.equals("TLE")){
        c2++;
      } else if(S.equals("RE")){
        c3++;
      }
    }
    
    System.out.println("AC x "+ c0);
    System.out.println("WA x "+ c1);
    System.out.println("TLE x "+ c2);
    System.out.println("RE x "+ c3);
      
  }
}
        


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

// data structure
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <vector>

#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  string a, b;
  cin >> a;
  cin >> b;
  if (a.length() != b.length() - 1) {
    std::cout << "No" << std::endl;
    return 0;
  }

  if (a.compare(b.substr(0, b.length() - 1)) == 0)
    std::cout << "Yes" << std::endl;
  else
    std::cout << "No" << std::endl;
  return 0;
}


Measured memory_bytes: 3520
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace cShaprTest
{
    class Program
    {
        public static int N { get; private set; }
        public static int A { get; private set; }
        public static int B { get; private set; }
        public static int C { get; private set; }

        private static int max;
        private static int[] l;

        static void Main(string[] args)
        {
            var NABC = Console.ReadLine().Split().Select(int.Parse).ToArray();
            N = NABC[0];
            A = NABC[1];
            B = NABC[2];
            C = NABC[3];

            max = int.MaxValue;
            l = new int[N];
            for (var i = 0; i < N; i++)
            {
                l[i] = int.Parse(Console.ReadLine());
            }

            var ans = Dfs(0, 0, 0, 0);
            Console.WriteLine(ans);
        }


        public static int Dfs(int index, int a, int b, int c)
        {
           // Console.WriteLine(index);
          //  Console.WriteLine(N);
 //           Console.WriteLine();

            if (index == N)
            {
                if (a == 0 || b == 0 || c == 0)
                {
                    return 100000;
                }
//                Console.WriteLine(Math.Abs(A - a) + Math.Abs(B - b) + Math.Abs(C - c));
                return Math.Abs(A - a) + Math.Abs(B - b) + Math.Abs(C - c) - 30;
            }
            var pattern = new int[4];

            pattern[0] = Dfs(index + 1, a, b, c);

            pattern[1] = Dfs(index + 1, a + l[index], b, c) + 10;
            pattern[2] = Dfs(index + 1, a, b + l[index], c) + 10;
            pattern[3] = Dfs(index + 1, a, b, c + l[index]) + 10;

            return pattern.Min();
        }
    }
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
char p[maxn];
int s[maxn];
int main()
{
    int x,a=0;
    cin>>p;
    int m=strlen(p);
    int sum=0;
    for(int i=0;i<m;i++)
        s[i]=p[i]-'0';
    for(int i=0;i<m;i++)
        if(s[i]!=9)
        {
            x=i;
            break;
        }
    for(int i=0;i<m;i++)
        if(s[i]==9)
            a++;
    if(a==m-1&&s[0]!=9)
    {
        for(int i=0;i<m;i++)
        sum+=s[i];
    }
    else if(a==m)
    {
        for(int i=0;i<m;i++)
        sum+=s[i];
    }
    else
    {
    if(x==0)
    {
        s[x]-=1;
        for(int i=x+1;i<m;i++)
            s[i]=9;
    }
    else
    {
        s[x-1]-=1;
        for(int i=x;i<m;i++)
            s[i]=9;
    }
    for(int i=0;i<m;i++)
        sum+=s[i];
    }
    printf("%d\n",sum);
}

Measured memory_bytes: 256
a,b,c,x,y=map(int,input().split())
ans=0
if x<y:
	if a+b<2*c:
		ans+=(a+b)*x
	else:
		ans+=(2*c)*x
	ans+=(y-x)*min(2*c,b)
else:
	if a+b<2*c:
		ans+=(a+b)*y
	else:
		ans+=(2*c)*y
	ans+=(x-y)*min(2*c,a)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* exchange */
#define CHMIN(a, b) (a) = min((ll)(a), (ll)(b))
#define CHMAX(a, b) (a) = max((ll)(a), (ll)(b))

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll K = 0;
ll t;
ll ret = 0;
string s;
priority_queue<ll> q;

void input() {
  IN(N);
  IN(K);
  REP(i, N) {
    IN(t);
    q.push(t);
  }
}

void solve() {
  ll i = 0;
  while(i < K && !q.empty()) {
    q.pop();
    i++;
  }
  while(!q.empty()) {
    ret += q.top();
    q.pop();
  }
  PRINT(ret);
}

int main(void){
  input();
  solve();
}


Measured memory_bytes: 2420