akhauriyash/Code-Regression huggingface dataset:
import scala.math._

object Main extends App {

  val YES = "YES"
  val Yes = "Yes"
  val NO = "NO"
  val No = "No"

  val input: Array[Array[Int]] = Array.ofDim(6, 6000000)
  ///////////////////////////////////////////

  val sc = new java.util.Scanner(System.in)
  val n, k = sc.nextInt
  val t = List.fill(n)(sc.nextInt)

  val ans = t.foldLeft(0){ case (acc, i) => if (k <= i) acc + 1 else acc}
  println(ans)

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

  def bigIterator(start: BigInt, end: BigInt, step: BigInt = 1) =
    Iterator.iterate(start)(_ + step).takeWhile(_ <= end)

  def lcm(a :Int, b :Int): Int =
    a / gcd(a, b) * b

  def lcm(a :Long, b :Long): Long =
    a / gcd(a, b) * b

  def gcd(a: Int, b: Int): Int =
    if (b == 0) a else gcd(b, a % b)

  def gcd(a: Long, b: Long): Long =
    if (b == 0) a else gcd(b, a % b)

  def setOrUpdated[A, B](a: Map[A, B], key: A, value: B, f: (B, B) => B) =
    a.get(key) match {
      case Some(v) => a.updated(key, f(value, v))
      case _ => a + (key -> value)
    }
}

Measured memory_bytes: 194304
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#define endl "\n"
using namespace std;

int main()
{
    int n;
    int i, j;

    cin >> n;
    vector <int> v(n);

    for(i = 0; i < n; i ++)
    	cin >> v[i];

    int ans = 0;
    for(i = 0; i < n - 1; i ++)
    {
    	for(j = i + 1; j < n; j ++)
    		ans = ans + v[i]*v[j];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
while True:
    n=int(input())
    if n==0:
        break
    a=[]
    for i in range(n):
        x=int(input())
        a.append(x)
    
    count=[0]*10
    for j in a:
        count[j]+=1
    for k in range(10):
        if count[k]==0:
            print('-')
        else:
            print('*'*count[k])



Measured memory_bytes: 5712
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    string s;
    cin>>n>>s;
    ll dp[n+1][n+1];
    memset(dp,0,sizeof(dp));
    for(int i=n-1;i>=0;i--){
        for(int j=n-1;j>=0;j--){
            if(s[i]==s[j]){
                dp[i][j]+=dp[i+1][j+1]+1;
            }
        }
    }
    ll ans=0;
    for(ll i=0;i<n;i++){
        for(ll j=i+1;j<n;j++){
            ans=max(ans,(min(dp[i][j],j-i)));
        }
    }
    cout << ans<<endl;
    return 0;
}


Measured memory_bytes: 195712
import math
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

a, b, h, m = map(int, readline().split())

r = h*30+m*0.5 - m*6
r = min(r, 360-r)
ans = (a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(r))) ** 0.5
print(ans)

Measured memory_bytes: 9528
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define ll long long
#define P pair<int, int>

using namespace std;
int mod = 1000000007;

int N;

int main() {
  cin >> N;
  int tmp = N;
  int sum = 0;
  while (tmp > 0) {
    sum += tmp%10;
    tmp /= 10;
  }
  cout << ((N%sum == 0) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
//Solution By SlavicG
#include "bits/stdc++.h"
using namespace std;
 
#define ll                          long long
 
#define forn(i,n)                   for(int i=0;i<n;i++)
#define all(v)                      v.begin(), v.end()
#define rall(v)                     v.rbegin(),v.rend()
	
#define pb                          push_back
#define sz(a)                       (int)a.size()
 
#define fastio                      ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define   endl                      "\n"

int main()
{
	ll n;
	cin >> n;
	ll cnt = 0;
	for(int i = 1;i <= n;i++)
	{
		ll b = n / i;
		if(i*b>=n)b--;
		cnt += max(0LL,b);
	}
	cout << cnt << endl;
}

Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {

	
	public static void main(String[] args) {
		// TODO Auto-generated method stub

		int[] dp=new int[45];
		dp[0]=1;
		dp[1]=1;
		Scanner scanner=new Scanner(System.in);
		int n=scanner.nextInt();
		for(int i=2;i<=n;i++)
			dp[i]=dp[i-1]+dp[i-2];
		System.out.println(dp[n]);
	}

}



Measured memory_bytes: 26236
#include <stdio.h>

int main(){
  int k,a[32]={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};
  scanf("%d",&k);
  printf("%d",a[k-1]);
  return(0);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using ll = int_fast64_t;
#define rep(i,b,e) for(ll i=b;i<e;i++)

int main(){
        int n, a, b, c;
        scanf("%d %d %d %d", &n, &a, &b, &c);
        std::vector<ll> l(n);
        rep(i, 0, n) scanf("%ld", &l[i]);

        ll ans = 1e18;
        rep(i, 0, (1<<n)*(1<<n)){
                ll A=0, B=0, C=0, tmp=-30;
                for(ll x=i, j=0; x; x/=4, j++){
                        if(x%4==3) A += l[j], tmp += 10;
                        if(x%4==2) B += l[j], tmp += 10;
                        if(x%4==1) C += l[j], tmp += 10;
                }
                if(!(A and B and C)) continue;
                ans = std::min(ans, (ll)(tmp+llabs(A-a)+llabs(B-b)+llabs(C-c)));
        }
        printf("%ld\n", ans);
        return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        int lcm[][] = new int[s.length() + 1][t.length() + 1];
        int move[][] = new int[s.length() + 1][t.length() + 1];
        for (int i = 1; i < s.length() + 1; i++) {
            char ss = s.charAt(i - 1);
            for (int j = 1; j < t.length() + 1; j++) {
                char tt = t.charAt(j - 1);
                if (ss == tt) {

                    lcm[i][j] = lcm[i - 1][j - 1] + 1;
                    // 左上
                    move[i][j] = 3;
                } else if (lcm[i - 1][j] > lcm[i][j - 1]) {
                    lcm[i][j] = lcm[i - 1][j];
                    // 上
                    move[i][j] = 2;
                } else {
                    lcm[i][j] = lcm[i][j - 1];
                    // 左
                    move[i][j] = 1;
                }
            }
        }
        // 経路復元
        String ans = "";
        int spos = s.length();
        int tpos = t.length();
        while (spos >= 0 && tpos >= 0) {
            if (move[spos][tpos] == 3) {
                ans = s.charAt(spos - 1) + ans;
                spos--;
                tpos--;
            } else if (move[spos][tpos] == 2) {
                spos--;
            } else {
                tpos--;
            }
        }
        System.out.println(ans);
        sc.close();
    }
}

Measured memory_bytes: 130380
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int main(void){
    cin.sync_with_stdio(false);
    char c; int a[26];
    for(int i = 0; i < 26; i++){
        a[i] = 0;
    }
    while((c = getchar()) != '\n'){
        a[c-'a']++;
    }
    for(int i = 0; i < 26; i++){
        if(a[i]==0){
            printf("%c\n", i+'a');
            return 0;
        }
    }
    printf("None\n");
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<stdlib.h>
#include<malloc.h>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<string.h>
#include<sstream>
#include<math.h>
#include<cctype>
#include<stdlib.h>
#include <cstring>
#include<cstdlib>
#include<cstdio>
#include<functional>
using namespace std;
int main()
{
	int x, a, b;
	while (cin >> x >> a >> b)
	{
		char c = abs(x - a) < abs(x - b) ? 'A' : 'B';
		cout << c << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for (int i=(n)-1;i>=0;i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define REPS(i,f,n) for (int i=(f)-1;i>=(n);i--)
int dx[4] = {1, 0, 0, -1};
int dy[4] = {0, 1, -1, 0};

// ???????????????????????¨???
int main(void){
	int n;
	cin >> n;
	vector<ll> r(n);
	rep(i, n)
		scanf("%lld", &r[i]);

	ll max_num = r[n - 1];
	ll ans = -100000000000000;

	REPS(i, n, 1){
		ans = max(ans, max_num - r[i - 1]);
		if (max_num < r[i - 1])
			max_num = r[i - 1];
	}

	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 4384
use proconio::input;

fn main() {
    input! {
        n: usize,
        a: [i64; n],
    };
    let magic = 1e9 as i64 + 7;
    let magic2 = 5e8 as i64 + 4;
    let mut s1 = 0;
    let mut s2 = 0;
    for i in 0..n {
        s1 = (s1 + a[i]) % magic;
    }
    for i in 0..n {
        let x = (a[i] * a[i]) % magic;
        s2 = (s2 + x) % magic;
    }
    let s = (( ((s1 * s1) % magic) + (magic - s2) ) * magic2) % magic;
    println!("{}", s);
}


Measured memory_bytes: 5568
#include<iostream>
using namespace std;
int main()
{
    int n, m;
    cin >> n >> m;
  
    int l = 1;
    int r = n;
    int tmpl, tmpr;
    for (int i = 0; i < m; i++) {
      cin >> tmpl >> tmpr;
      if (l < tmpl) l = tmpl;
      if (r > tmpr) r = tmpr;
    }
    
    int result = r - l + 1;
    if (result < 0) result = 0;
  
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FI first
#define SE second
#define INF 10000000

    int main(){
    ll n, m, a[100000], b[100000], c[100000];
    pll d[200000];
    cin >> n >> m;
    REP(i, n) {
        cin >> a[i];
        d[i].FI = a[i];
        d[i].SE = 1;
    }
    REP(i, m){
        cin >> b[i] >> c[i];
        d[i + n].FI = c[i];
        d[i + n].SE = b[i];
    }
    sort(d, d + n + m, greater<pll>());
    ll currn = n,ans=0;
    //cout << d[0].FI << d[1].FI << d[2].FI << d[3].FI << endl;
    REP(i, n + m)
    {
        if (currn <= d[i].SE){
            ans += currn * d[i].FI;
            break;
        }else{
            ans += d[i].FI * d[i].SE;
            currn -= d[i].SE;
        }
    }
    cout << ans << endl;
    }

Measured memory_bytes: 5760
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class B
{
	public static void Main() => (new Solver()).Solve();
}

public class Solver
{
	public void Solve()
	{
		int A = GetInt();
		int B = GetInt();
		int M = GetInt();
		var a = GetInts(A);
		var b = GetInts(B);

		int min = a.Min() + b.Min();
		for(int i = 0; i < M; i++)
			chmin(ref min, a[GetInt() - 1] + b[GetInt() - 1] - GetInt());

		WriteLine(min);
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => Enumerable.Range(0, (int)N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(long N) => Enumerable.Range(0, (int)N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDouble()).ToArray();
	public static decimal[] GetDecimals(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDecimal()).ToArray();
	public static string[] GetStrings(long N) => Enumerable.Range(0, (int)N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}

Measured memory_bytes: 37724
import java.util.*;
import java.io.*;
public class Main{
  public static void main(String [] args){

	Scanner sc=new Scanner(System.in);
	int ah=sc.nextInt();
	int as=sc.nextInt();

	int bh=sc.nextInt();
	int bs=sc.nextInt();

	int ahamla=((bh+as-1)/as);
	int bhamla=((ah+bs-1)/bs);

	if(ahamla<=bhamla){
		System.out.println("Yes");
	}
	else{
		System.out.println("No");
	}
  }

}

Measured memory_bytes: 27008
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const long long infll = (long long) 1.01e18;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

#ifdef DEBUG
mt19937 mrand(300); 
#else
mt19937 mrand(chrono::steady_clock::now().time_since_epoch().count()); 
#endif

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int maxn = 505;
int n;
int p[maxn * maxn];

bool read() {
  if (scanf("%d", &n) < 1) {
    return false;
  }
  for (int i = 0; i < n * n; i++) {
    scanf("%d", &p[i]);
    p[i]--;
  }
  return true;
}

const int gox[] = {1, 0, -1, 0};
const int goy[] = {0, 1, 0, -1};

bool inside(int x, int y) {
  return 0 <= x && x < n && 0 <= y && y < n;
}

int d[maxn][maxn];
int alive[maxn][maxn];
deque<pair<int, int>> q;

void bfs() {
  while (!q.empty()) {
    int x = q.front().first, y = q.front().second;
    q.pop_front();
    for (int dir = 0; dir < 4; dir++) {
      int nx = x + gox[dir], ny = y + goy[dir];
      if (!inside(nx, ny)) {
        continue;
      }
      int nd = d[x][y] + (alive[x][y] ? 1 : 0);
      if (nd < d[nx][ny]) {
        d[nx][ny] = nd;
        if (alive[x][y]) {
          q.push_back(make_pair(nx, ny));
        } else {
          q.push_front(make_pair(nx, ny));
        }
      }
    }
  }
}

void solve() {
  q.clear();
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      d[i][j] = inf;
      alive[i][j] = true;
      if (i == 0 || i == n - 1 || j == 0 || j == n - 1) {
        d[i][j] = 0;
        q.push_back(make_pair(i, j));
      }
    }
  }
  bfs();
  int res = 0;
  for (int i = 0; i < n * n; i++) {
    int id = p[i];
    int x = id / n, y = id % n;
    res += d[x][y];
    alive[x][y] = false;
    q.clear();
    q.push_back(make_pair(x, y));
    bfs();
  }
  printf("%d\n", res);
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 7680
#include<bits/stdc++.h>
using namespace std;
//#include<boost/multiprecision/cpp_int.hpp>
//using boost::multiprecision::cpp_int;

#define int long long
#define cint cpp_int
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) (((a)+(b)-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/2
#define PI acos(-1.0)

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

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;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vvout(VVi &v){for(int i=0;i<(v).size();i++) vout(v[i]);}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
int mypow(int x, int n, int m){if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}
int digit(int k,int i){string s = to_string(k);return s[s.size()-i]-'0';}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
Vi accum(Vi v){Vi ret((v).size());ret[0]=v[0];REP(i,1,(v).size()) ret[i]=ret[i-1]+v[i];return ret;}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}



signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(12);
    int x,y;
    cin>>x>>y;
    if(x==1 && y==1){
        cout<<1000000<<endl;
        return 0;
    }

    int ans=0;
    if(x==1) ans += 300000;
    if(x==2) ans += 200000;
    if(x==3) ans += 100000;
    if(y==1) ans += 300000;
    if(y==2) ans += 200000;
    if(y==3) ans += 100000;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
const int MAXN=205;
int n,ans=0;
int prime[MAXN],tot=0;
int minp[MAXN],minq[MAXN],divcnt[MAXN];
bool flag[MAXN];
void getready(){
	flag[1]=true;divcnt[1]=1;
	for(int i=2;i<MAXN;++i){
		if(flag[i]==false){
			prime[++tot]=i;
			divcnt[i]=2;minp[i]=i;minq[i]=i;
		}
		for(int j=1;j<=tot&&prime[j]*i<MAXN;++j){
			int temp=prime[j]*i;
			flag[temp]=true;
			minp[temp]=prime[j];
			if(i%prime[j]==0){
				minq[temp]=minq[i]+1;
				divcnt[temp]=divcnt[i]/(minq[i]+1)*(minq[temp]+1);
				break;
			}
			minq[temp]=1;
			divcnt[temp]=divcnt[i]*divcnt[prime[j]];
		}
	}
}
int main(){
	getready();
	scanf("%d",&n);
	for(int i=1;i<=n;i+=2)
		if(divcnt[i]==8) ++ans;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 105, mo =1e9+7;
int n,s[N],f[N][N][N],a[N],b[N];
void add(int &x, int y){x=x+y<mo?x+y:x+y-mo;}
int main() {
	read(n);rep(i,1,n*2-1)read(s[i]);
	sort(s+1,s+n*2);
	rep(i,1,n-1)a[i]=s[i]!=s[i+1],b[i]=s[2*n-i]!=s[2*n-i-1];
	f[n][0][0]=1;
	per(i,n,2)rep(j,0,n*2)rep(k,0,n*2)if(f[i][j][k]){
		add(f[i-1][j+a[i-1]][k+b[i-1]],f[i][j][k]);
		rep(c,0,j-1+a[i-1])add(f[i-1][c][k+1+b[i-1]],f[i][j][k]);
		rep(c,0,k-1+b[i-1])add(f[i-1][j+1+a[i-1]][c],f[i][j][k]);
	}
	int res=0;rep(i,0,n*2)rep(j,0,n*2)add(res,f[1][i][j]);
	cout<<res;
	return 0;
}


Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rrep(i, n) for(int i=((int)(n)-1); i>=0; i--)
#define REP(i, k, n) for(int i=(int)(k); i<(int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define PQ(T) priority_queue<T>
#define PQS(T) priority_queue<T, vector<T>, greater<T> >
#define deci cout << fixed << setprecision(15);
typedef long long ll;
const int INF = INT_MAX;
const ll inf = 1e18;
const ll mod = 1e9 + 7;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T> bool chmin(T&x,T y){if(x>y){x=y;return true;}return false;}
template<class T> bool chmax(T&x,T y){if(x<y){x=y;return true;}return false;}
ll gcd(ll x, ll y){ if(x>y) swap(x, y);while(x!=0){ y%=x; swap(x, y); }return y; }
ll mpow(ll x, ll r){if(r==0) return 1;if(r%2==1){ return x*mpow(x, r-1)%mod; }else{ ll aa = mpow(x, r/2); return aa*aa%mod; }}

int main(){
	int k, q; cin >> k >> q;
	int d[k];
	rep(i, k) cin >> d[i];
	rep(i, q){
		ll n, x, m; cin >> n >> x >> m;
		ll sum = 0, cnt = 0;
		n--;
		rep(j, k){
			if(d[j] % m != 0) cnt++;
			sum += d[j] % m;
		}
		sum *= n/k;
		cnt *= n/k;
		rep(j, n % k){
			if(d[j] % m != 0) cnt++;
			sum += d[j] % m;
		}
		sum += x % m;
		cout << cnt - sum/m << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)
#define INF 100000000
#define ll long long

int dp1[1000001];
int dp2[1000001];
int main()
{
	vector<ll> poloc;
	
	int i = 1;
	while (i*(i + 1)*(i + 2) / 6 <= 1000000) {
		poloc.push_back(i*(i + 1)*(i + 2) / 6);
		i++;
	}

	REP(i, 1, 1000001) dp1[i] = dp2[i] = INF;
	dp1[0] = dp2[0] = 0;
	REP(i, 0, poloc.size()) {
		REP(j, 0, 1000001) {
			if (j + poloc[i] > 1000000) break;
			dp1[j + poloc[i]] = min(dp1[j + poloc[i]], dp1[j] + 1);
		}

		if (poloc[i] % 2 == 1) {
			REP(j, 0, 1000001) {
				if (j + poloc[i] > 1000000) break;
				dp2[j + poloc[i]] = min(dp2[j + poloc[i]], dp2[j] + 1);
			}
		}
	}

	int n;
	while (cin >> n, n) {
		cout << dp1[n] << " " << dp2[n] << endl;
	}
	return 0;
}

Measured memory_bytes: 10968
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long S =sc.nextLong(), a=1;
    for(int i=1; i<=S; i++){
      a =a * i % 1000000007;
    }
    System.out.println(a);
  }
}

Measured memory_bytes: 35496
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(int i =(a);i<(n);i++)
#define urep(i,a,n) for(int i = (a);i>(n);i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;

ll N, M;
ll x[3][1000];
ll ans;
ll sumnum[1000];
int main() {
	cin >> N >> M;
	int xsum = 0, ysum = 0, zsum = 0;
	bool flg[3];
	rep(i,0,N){
		cin >> x[0][i]>>x[1][i]>>x[2][i];
	}
	rep(i, 0, 2) {
		rep(j, 0, 2) {
			rep(k, 0, 2) {
				rep(l, 0, N)sumnum[l] = 0;
				rep(l, 0, N) {
					if (i)sumnum[l] += x[0][l];
					else sumnum[l] -= x[0][l];
					
					if (j)sumnum[l] += x[1][l];
					else sumnum[l] -= x[1][l];

					if (k)sumnum[l] += x[2][l];
					else sumnum[l] -= x[2][l];
				}
				sort(sumnum, sumnum + N);
				ll num=0;
				rep(l,0, M) {
					num += sumnum[N-l-1];
				}
				ans = max(ans, num);
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;


int main(void){
  int n,i,p[100005],ans=0;
  
  cin >> n;
  for (i=0;i<n;i++) cin >> p[i];
  
  for (i=0;i<n-1;i++){
    if (p[i]==i+1){
      swap(p[i],p[i+1]);
      ans++;
    }
  }
  
  if (p[n-1]==n) ans++;
  
  cout << ans << endl;
  
  return 0;
}

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

int N, l, ans = 0;

int main() {
  scanf("%d", &N);
  vector<int> v(N);
  for (int i = 0; i < N; i++) {
    scanf("%d", &l);
    v.at(i) = l;
  }
  sort(v.begin(), v.end());

  for (int b = 0; b < N; b++) {
    int r = b + 1;
    for (int a = 0; a < b; a++) {
      int ab = v.at(a) + v.at(b);
      while (r < N && v.at(r) < ab) ++r;
      int l = b + 1;
      ans += max(0, r - l);
    }
  }

  printf("%d\n", ans);
  return 0;
}

// 4 3 4 2 1 1
// 3 1 1000 1 0
// 7 218 786 704 233 645 728 389 23

Measured memory_bytes: 256
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn is753(n: i32) -> bool {
    let mut has3 = false;
    let mut has5 = false;
    let mut has7 = false;
    let mut m = n;
    while m > 0 {
        match m % 10 {
            3 => has3 = true,
            5 => has5 = true,
            7 => has7 = true,
            _ => return false,
        }
        m /= 10;
    }
    has3 && has5 && has7
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: i32 = read(&mut stdin_lock, &mut buf, b'\n');

    let mut v = vec![0];
    let mut ans = 0;
    let mut m = n;
    while m > 0 {
        v = v
            .clone()
            .into_iter()
            .flat_map(|i| {
                vec![3, 5, 7]
                    .iter()
                    .map(|&j| i * 10 + j)
                    .collect::<Vec<i32>>()
            })
            .collect();
        ans += v.iter().filter(|&&i| i <= n && is753(i)).count();
        m /= 10;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
//本番では解けなかった

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

//整数の計算の場合、19桁を超えると計算は概算にしかならないので注意
//pow(a,b)%10のような計算はできない(powは単体でしか使えない)

//mod計算の本質は余り部分だけに注目すること
//→ｎ乗する時は余り部分をn乗で求めることが出来る
//→n回余り部分を掛け合わせるループをする

//関数自体の型を定義するのを忘れない
long long int powmod(long long int a,long long int b){
    long long res=1;
    for(int i=0;i<b;i++){
        res=res*a%1000000007;
    }
    return res;
}

int main(){
    int n;
    cin>>n;
    int mod=1000000007;

    long long int ans;
    ans=powmod(10,n)-powmod(9,n)-powmod(9,n)+powmod(8,n);
    //①元の計算が正だとしても、余り同士の計算が正になるわけではないことに注意
    //②また余り同士の計算が正だとしても、割る数を大きく超えてくる可能性があることにも注意

    //②の対策をしつつ、①の対策としてあと一回割る数を足せば正になるところまでもってくる
    ans%=mod;
    //①の対策の継続として、割る数を一回足して余りを出す
    ans=(ans+mod)%mod;

    cout<<ans<<endl;
}

Measured memory_bytes: 3624
//
//  header_useful.h
//  c++_acm
//
//  Created by 李弘辰 on 2019/7/23.
//  Copyright  2019 李弘辰. All rights reserved.
//

#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <vector>
#include <list>
#include <set>
#include <unordered_set>
#include <utility> // pair
#include <map>
#include <unordered_map>
#include <iostream>
#include <sstream>
#include <algorithm> // sort
#include <string>
#include <stack>
#include <queue>
#include <fstream>
#include <bitset>


using namespace std;

#define ll long long
#define lll __int128
#define uchar unsigned char
#define ushort unsigned short
#define uint unsigned int
#define ulong unsigned long
#define ull unsigned long long

#define INT_INF 0x7fffffff

#define pi acos(-1)

#define mx(a,b) (a) > (b) ? (a) : (b)
#define mn(a,b) (a) < (b) ? (a) : (b)
#define mem(a,b) memset(a,b,sizeof(a))
#define fre(a) freopen(a,"r",stdin)

#define cio ios::sync_with_stdio(false); // Do not use it with "scanf" and other c input!
#define pb push_back
#define rep(i,a,b) for (int i = a;i <= b;i ++)
#define pre(i,a,b) for (int i = a;i >= b;i --)
#define REP(i,a,b) for (int i = a;i < b;i ++)

#define read(a,s,n) rep(i,s,n) scanf("%d",a + i);
#define READ(a,s,n) REP(i,s,n) scanf("%d",a + i);

#define read_ll(a,s,n) rep(i,s,n) scanf("%lld",a + i);
#define READ_ll(a,s,n) REP(i,s,n) scanf("%lld",a + i);

#define _T_(T) int T;scanf("%d",&T);while (T --)
#define __T _T_(TTESTCASES)
#define _E_(T) while (~T)

#define Tprint(a,s,e) {int f=1;REP(i,s,e){if(f)f=0;else printf(" ");printf("%d",a[i]);}}


#define endl '\n'

#define itn int
#define iny int
#define nit int
#define inr int
#define mian main
#define iman main
#define mina main
#define mian main
#define ednl endl
#define fro for
#define fir for
#define reutrn return
#define retunr return
#define reutnr return


/* header_useful_h */


int main() {
    int k;
    scanf("%d", &k);
    ll n = 7;
    int ans = 1;
    if(k % 2 ==0 || k % 5 == 0){
        puts("-1");
        return 0;
    }
    while (1) {
        if(n % k == 0) {
            printf("%d\n", ans);
            return 0;
        }
        ans ++;
        n *= 10;
        n += 7;
        n %= k;
    }
    return 0;
}


Measured memory_bytes: 3228
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

struct Info {
	int a, b, c;
	Info(int a, int b, int c) : a(a), b(b), c(c) {};
};

signed main() {
	int N, Ma, Mb;
	cin >> N >> Ma >> Mb;

	vector<Info> infos;

	rep(i, N) {
		int a, b, c;
		cin >> a >> b >> c;
		infos.push_back(Info(a, b, c));
	}

	if (N == 1) {
		if (infos[0].a * Mb == infos[0].b * Ma) {
			cout << infos[0].c << endl;
		} else {
			cout << -1 << endl;
		}
		return 0;
	}

	vector<Info> v[2];
	map<pair<int, int>, int> m[2];
	rep(i, N) {
		v[i % 2].push_back(infos[i]);
	}

	rep(i, 2) {
		int len = v[i].size();
		REP(j, 1, (1 << len) - 1) {
			int a = 0;
			int b = 0;
			int c = 0;
			rep(k, len) {
				if ((j & (1 << k)) == 0) continue;
				a += v[i][k].a;
				b += v[i][k].b;
				c += v[i][k].c;
			}
			if (i == 0) {
				int tmp = min(a / Ma, b / Mb);
				a -= tmp * Ma;
				b -= tmp * Mb;
			} else {
				int tmp = max((a + Ma - 1) / Ma, (b + Mb - 1) / Mb);
				a = tmp * Ma - a;
				b = tmp * Mb - b;
			}
			auto pr = mp(a, b);
			if (m[i].count(pr)) {
				m[i][pr] = min(m[i][pr], c);
			} else {
				m[i][pr] = c;
			}
		}
		//cerr << "m[" << i << "]:" << endl;
		//for (auto &pr : m[i]) {
		//	cerr << " (" << pr.first.first << ", " << pr.first.second << ") -> " << pr.second << endl;
		//}
	}

	int ret = INT_MAX;
	rep(i, 2) {
		if (m[i].count(mp(0, 0))) {
			ret = min(ret, m[i][mp(0, 0)]);
		}
	}
	for (auto &pr : m[0]) {
		if (m[1].count(pr.first)) {
			ret = min(ret, pr.second + m[1][pr.first]);
		}
	}

	if (ret == INT_MAX) cout << -1 << endl;
	else cout << ret << endl;

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())
#define ENDL cout<<endl

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};
int main(){
    I vec;
    CIN(N);CIN(K);
    REP(a,N){
        CIN(b);
        vec.push_back(b);
    }
    sort(ALL(vec));
    LL ans = LINF;
    for(int a = 0;a < N-K+1;a++){
   //     cout<<vec.at(a+K-1)<<" "<<vec.at(a)<<endl;
        ans = min(ans,(LL)vec.at(a+K-1)-vec.at(a));
    }
    COUT(ans);
    return 0;
}


Measured memory_bytes: 892
// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

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

//for loop関係
#define rep(i,a,n) for(int i=(a);i<(n);++i)
#define repe(i,a,n) for(int i=(a);i<=(n);++i)
#define rrep(i,n,a) for(int i=(n);n>(a);--i)
#define rrepe(i,n,a) for(int i=(n);n>=(a);--i)

//略記
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define ENDL << "\n"

using ll = long long;
using P = pair<int,int>;
using itn = int;

//定数
const int INF = 1<<30;
const ll MOD = 1000000007;
const long double PI =(acos(-1));

//Degree <-> Radian
double toRad(double d){ double rad; rad=d*PI/180; return rad; }
double toDegree(double rad){ double d; d=rad*180/PI; return d; }
//The least common multiple : lcm
ll lcm(int a,int b){ return a*b/__gcd(a,b); }
//素数判定
bool isPrime(int n){
    int i; 
    if(n<2) return 0;
    else if(n==2) return 1;
    if(n%2==0) return 0;
    for(i=3;i*i<=n;i+=2) if(n%i==0) return 0;
    return 1;
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    cin >> s;
    if(s[2]==s[3] && s[4]==s[5])cout << "Yes" ENDL;
    else cout << "No" ENDL;
    
    return 0;
}

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


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while(true){
			String str = br.readLine();
			
			if(str == null){
				break;
			}
			
			String[] strArray = str.split(" ");
			int a = Integer.parseInt(strArray[0]);
			int b = Integer.parseInt(strArray[1]);
			int n = Integer.parseInt(strArray[2]);
			
			Decimal dc = new Decimal(a, b);
			
			System.out.println(dc.sumOfDecimal(n));
		}
	}

}

class Decimal{
	private int numerator;
	private int denominator;
	private int[] dplace = new int[101];
	
	public Decimal(int a, int b){
		numerator = a;
		denominator = b;
		
		initDplace();
	}
	
	private void initDplace(){
		int a = numerator;
		int b = denominator;
		for(int i = 1; i < dplace.length ; i++){
			dplace[i] = (a*10/b)%10;
			a = a*10%b;
		}
	}
	
	public int sumOfDecimal(int n){
		int result = 0;
		for(int i = 1; i <= n ; i++){
			result += dplace[i];
		}
		
		return result;
	}
	
	public void print(){
		for(int i = 1; i < dplace.length ; i++){
			System.out.print(dplace[i]);
		}
		System.out.println();
	}
}

Measured memory_bytes: 24284
#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <set>
#include <numeric>
#include <bitset>
#include <map>
#include <limits.h>

using namespace std;

/// 各桁の和
int sumdigit(int x){
   int sum = 0;
    while(x != 0){
        sum += x % 10;
        x /= 10;    
    }
    return sum;
}
/// 最小公倍数 
int gcd(int x, int y){
      if(x<y){
          int temp = x;
          x = y;
          y = temp;
      }
      int r = x % y;
       while(r!=0){
           x = y;
           y = r;
           r = x % y;
       }
      return y;
   }



int main(){
string S ;
cin >> S;
if(S[5] == '1'){
    cout << "TBD" << endl;
    return 0;
}


   else if(S[6] == '5' || S[6] == '6'|| S[6] == '7' || S[6] == '8' || S[6] == '9' ){
        cout << "TBD" << endl;
        return 0 ;
    }
    else{
        cout << "Heisei" << endl;
    return 0 ;
    }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    char x,y;
    cin>>x>>y;
    if(x>y)
        cout<<">"<<endl;
   else if(y>x)
    cout<<"<"<<endl;
   else
    cout<<"="<<endl;
    return 0;
}


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


int main(){
  string A,B,C;
  int a(0),b(0),c(0);
  cin>>A>>B>>C;
  char now('a');
  while (true){
    if (now=='a'){
      if (a==A.size()){
        cout << 'A'<<endl;
        return 0;
      }
      now=A[a];
      a+=1;
    }else if(now=='b'){
      if (b==B.size()){
        cout << 'B'<<endl;
        return 0;
      }
      now=B[b];
      b+=1;
    }else{
      if (c==C.size()){
        cout << 'C'<<endl;
        return 0;
      }
      now=C[c];
      c+=1;
    }
  }
}


Measured memory_bytes: 256
<?php

while (fscanf(STDIN, '%f', $w)) {
    if ($w <= 48.0) {
        echo 'light fly' . PHP_EOL;
    } elseif ($w <= 51.0) {
        echo 'fly' . PHP_EOL;
    } elseif ($w <= 54.0) {
        echo 'bantam' . PHP_EOL;
    } elseif ($w <= 57.0) {
        echo 'feather' . PHP_EOL;
    } elseif ($w <= 60.0) {
        echo 'light' . PHP_EOL;
    } elseif ($w <= 64.0) {
        echo 'light welter' . PHP_EOL;
    } elseif ($w <= 69.0) {
        echo 'welter' . PHP_EOL;
    } elseif ($w <= 75.0) {
        echo 'light middle' . PHP_EOL;
    } elseif ($w <= 81.0) {
        echo 'middle' . PHP_EOL;
    } elseif ($w <= 91.0) {
        echo 'light heavy' . PHP_EOL;
    } else {
        echo 'heavy' . PHP_EOL;
    }
}



Measured memory_bytes: 9188
#include <bits/stdc++.h>
#define N 2005

using namespace std;

const long long mod = 1e9+7;
long long n, k;
long long c[N];

long long a[N], b[N];
long long num[N];
long long ans;

long long calc(int x) {
	long long res = 0;
	for (int i = n; i > x; --i)
		if (a[i] < a[x]) ++res;
	return res;
}

int main() {
	ios::sync_with_stdio(false);

	cin >> n >> k;
	for (int i = 1; i <= n; ++i)
		cin >> a[i], b[i] = a[i];

	sort(b + 1, b + n + 1);
	for (int i = 1; i <= n; ++i)
		num[i] = lower_bound(b + 1, b + n + 1, a[i]) - b - 1;

	for (int i = n; i; --i) {
		(ans += calc(i) * k % mod) %= mod;
		(ans += k * (k - 1) / 2 % mod * num[i] % mod) %= mod;
	}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  map<string,int>ans;
  ans["SSS"] = 0;
  ans["SSR"] = 1;
  ans["SRS"] = 1;
  ans["SRR"] = 2;
  ans["RSS"] = 1;
  ans["RSR"] = 1;
  ans["RRS"] = 2;
  ans["RRR"] = 3;
  string s;
  cin >> s;
  cout << ans[s] << endl;
}
  

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

using namespace std;

int main(void)
{
    string s;
    cin >> s;
    int counter = 0;
    bool flag = true;
    for (auto it = s.begin(); it != s.end(); ++it)
    {
        if(counter%2 == 0)
        {
            if(!(*it == 'R' || *it == 'U' || *it == 'D')){
                flag = false;
                break;
            }
        }
        else
        {
            if(!(*it == 'L' || *it == 'U' || *it == 'D')){
                flag = false;
                break;
            }
        }
        counter++;
    }
    if(flag){ cout << "Yes" << endl;}
    else{ cout << "No" << endl;}
}

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

using namespace std;
typedef long long ll;
const int MAXN = 1e5 + 5;

bool isprime(ll x)
{
    if(x<=1)
      return 0;
      for(ll i = 2 ; i * i <= x ; i++)
          if(x % i == 0)
              return 0;
    return 1;
}

int main() {
    
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll x;
    cin >> x;
    for(ll j = x ; j; j++)
    {
        if(isprime(j))
         {
              cout << j;
              return 0;
         }
    }
    
    
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+7;
int a[N];
map<int,int>mp;
int main()
{
	 int n;
	 cin>>n;
	 for(int i=1;i<=n;i++)
	 {
	 	cin>>a[i];
	 }
	 int ans=0;
	 for(int i=1;i<=n;i++)
	 {
	 	if(a[i]==i)
	 	{
	 		ans++;
	 		int temp=a[i];
	 		a[i+1]=a[i];
	 		a[i+1]=temp;
		}	
	 }
	 cout<<ans<<endl;
}

Measured memory_bytes: 640
local function str2tbl(s)
    local t = {string.byte(s, 1, #s)}
    for i=1, #t do
        t[i] = string.char(t[i])
    end
    return t
end

local function str2numtbl(s, offset)
    local t = {string.byte(s, 1, #s)}
    if offset then
        for i=1, #t do
            t[i] = t[i] - offset
        end
    end
    return t
end

--local function each_char2(s)
--    return ipairs(str2tbl(s))
--end

local function each_char(s)
    local f = function(_, i)
        i = i + 1
        if i <= #s then
            return i, string.sub(s, i, i)
        end
    end
    return f, nil, 0
end

function string.at(s, i)
    return string.sub(s, i, i)
end

--
local N,_,S,K = io.read("n", "l", "l", "n")
local c = S:at(K)
local ans = string.gsub(S, "[^"..c.."]", "*")
print(ans)

Measured memory_bytes: 888
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;

int main(){
  string S;
  cin>>S;
  int abc[30]={0};
  for(int i=0;i<S.size();i++){
    abc[S[i]-'a']++;
  }
  int last=-1;
  for(int i=0;i<26;i++){
    if(abc[i]==0) {
      last=i;
      break;
    }
  }
  int hantei=0;
  if(last!=-1){
    S+=('a'+last);
    hantei=1;
  }else{
    int flag[30]={0};
    for(int i=S.size()-1;i>=0 && hantei==0;i--){
      int temp=S[i]-'a';
      flag[temp]++;
      for(int j=temp+1;j<26 && hantei==0;j++){
        if(flag[j]==1){
          S[i]='a'+j;
          hantei=1;
          S=S.substr(0,i+1);
        }
      }
    }
    
  }
  if(hantei)cout<<S<<endl;
  else cout<<-1<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll ;
#define rep(i, a, b) for (int i = a; i <= b; ++ i) 
using namespace std ;

long double solve(int n, long double a, long double p) {
	double res = (2.0 * n * a + p * n * (2.0 * n + 1)) / (2.0 * n) ;
	if (n == 1) return res ;
	return res + solve(n - 1, a + a / n + 3.0 * p / 2.0 / n, p + 2.0 * p / n) ;
}

int main() {
	int n ; long double x, y ;
	scanf("%d%Lf%Lf", &n, &x, &y) ;
	printf("%.10Lf\n", solve(n, x - y, y)) ;
	return 0 ; 
}

Measured memory_bytes: 12800
// ALDS1_4_A: Linear Search

fn scan<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let n = s.trim().parse().ok().unwrap();
    n
}

fn scan_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let a = s.split_whitespace().map(|n| n.parse().ok().unwrap()).collect();
    a
}

fn main() {
    let n: usize = scan();
    let a: Vec<i64> = scan_vec();
    let m: usize = scan();
    let b: Vec<i64> = scan_vec();

    let ans = b.iter().filter(|&b| a.contains(b)).count();

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


Measured memory_bytes: 5032
#include <algorithm>
#include <array>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <stack>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define MOD ((ll)1000000007)


int main(int argc, char const *argv[])
{
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);

	int a, b;
	cin >> a >> b;

	if ((a * b) % 2 == 0)
	{
		cout << "Even" << endl;
	} else {
		cout << "Odd" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const int N = 1001000;
bool prime[N];

const ll mod = 1e9+7;

int main(){
    fill(prime,prime+N,true);
    prime[0] = prime[1] = false;
    for(int i=2; i<N; ++i){
        if(prime[i]) for(int j=2*i; j<N; j+=i) prime[j] = false;
    }

    int n;
    cin >>n;
    vector<int> q(n);
    rep(i,n) cin >>q[i];
    q.pb(1000999);

    vector<ll> dp(n+1);
    dp[0] = 1;
    rep(i,n)if(prime[q[i]]){
        // 1個
        if(i+1<=n && prime[q[i+1]] && q[i]<q[i+1]) (dp[i+1] += dp[i]) %= mod;

        // 2個
        if(i+2<=n && prime[q[i+2]] && q[i]<q[i+2]) (dp[i+2] += dp[i]) %= mod;
    }
    cout << dp[n] << endl;

    return 0;
}



Measured memory_bytes: 5016
#include<iostream>
 
using namespace std;
 
typedef long long ll;

const int start[] = {1,4,1,4,1,2,1,2};
int now[] = {1,4,1,4,1,2,1,2};
int ans[8];
int out;
int in[8];


bool isunder(){

  for(int i = 0; i < 8; i++){
    if(ans[i] < now[i]) return false;
    if(ans[i] > now[i]) return true;
  }
  return false;
}

void move(){

  int end = now[7];

  for(int i = 6; i >= 0; i--)
    now[i+1] = now[i];

  now[0] = end;
}

void check(){

  int sum = 0;

  for(int i = 0; i < 8; i++)
    sum += max(0,in[i]-now[i]);
  

  if(sum < out || (sum==out && isunder())){
    for(int i = 0; i < 8; i++)
      ans[i] = now[i];
    out = sum;
  }
}

bool fin(){
  for(int i = 0; i < 8; i++)
    if(now[i] != start[i]) return false;

  return true;
}
void solve(){

  while(1){
    check();
    move();
    if(fin()) break;
  }

  for(int i = 0; i < 8; i++){
    if(i) cout << " ";
    cout << ans[i];
  }
  cout << endl;
}

void init(){
  ans[0] = -1;
  out = (1<<30);
}

bool input(){
  init();
  for(int i = 0; i < 8; i++)
    if(!(cin >> in[i])) return false;

  return true;
}
int main(){
  
  while(input()) solve();
  
  return 0;
}

Measured memory_bytes: 1160
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

from collections import defaultdict, deque
from sys import exit
import math
import copy
from bisect import bisect_left, bisect_right
from heapq import *
import sys
# sys.setrecursionlimit(1000000)
INF = 10 ** 17
MOD = 1000000007

from fractions import *
def inverse(f):
    # return Fraction(f.denominator,f.numerator)
    return 1/f


def combmod(n, k, mod=MOD):
    ret = 1
    for i in range(n - k + 1, n + 1):
        ret *= i
        ret %= mod

    for i in range(1, k + 1):
        ret *= pow(i, mod - 2, mod)
        ret %= mod

    return ret
def bunsu(n):
    ret = []
    for i in range(2, int(math.sqrt(n)) + 1):
        if n % i == 0:
            tmp = 0
            while(True):
                if n % i == 0:
                    tmp += 1
                    n //= i
                else:
                    break
            ret.append((i, tmp))

    ret.append((n, 1))
    return ret

def solve():
    a, b = input().split()
    a = int(a)
    b = int(b[:-3]) * 100 + int(b[-2:])
    ans = (a * b) // 100
    print(ans)
    # print(str(ans)[:-2])
def main():
    # n = getN()
    # for _ in range(n):
    solve()
if __name__ == "__main__":
    solve()


Measured memory_bytes: 72560