akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
const int hx[][6] = {{0, 0, 1, -1, -1, -1}, {1, 1, 1, -1, 0, 0}};
const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
const int MOD = 1000000000 + 0;
const int INF = 1 << 29;

#define TT_ template<typename T>inline
TT_ T sq(T x){return x*x;}
TT_ void sort(T&v){sort(begin(v),end(v));}
TT_ void revs(T&v){reverse(begin(v),end(v));}
TT_ void uniq(T&v){sort(v);v.erase(unique(begin(v),end(v)),end(v));}
TT_ int ubnd(T&v,typename T::value_type x){return upper_bound(begin(v),end(v),x)-begin(v);}
TT_ int lbnd(T&v,typename T::value_type x){return lower_bound(begin(v),end(v),x)-begin(v);}
#undef TT_
inline int in(){int x;scanf("%d",&x);return x;}
inline ll pow_mod(ll a,ll k,ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;}
inline ll mod_inv(ll a,ll p){return pow_mod(a,p-2,p);}
//}}} priority_queue stringstream sync_with_stdio


#include <vector>
#include <queue>

struct MaxFlow {
  struct Edge {
    int to;
    int cap;
    int rev;
    Edge(int to, int cap, int rev) : to(to), cap(cap), rev(rev) {}
  };

  std::vector<std::vector<Edge>> G;
  std::vector<int> level, iter;

  MaxFlow(int V) : G(V), level(V), iter(V) {}

  void addEdge(int from, int to, int cap) {
    G[from].emplace_back(to, cap, G[to].size());
    G[to].emplace_back(from, 0, G[from].size() - 1);
  }
  
  void bfs(int s) {
    std::fill(level.begin(), level.end(), -1);
    std::queue<int> Q;
    level[s] = 0;
    for (Q.push(s); !Q.empty(); Q.pop()){
      auto v = Q.front();
      for (const auto& e : G[v]){
        if (e.cap <= 0) continue;
        if (level[e.to] >= 0) continue;
        level[e.to] = level[v] + 1;
        Q.push(e.to);
      }
    }
  }

  int dfs(int v, int t, int f) {
    if (v == t) return f;
    for (int& i = iter[v]; i < G[v].size(); i++){
      auto& e = G[v][i];
      if (e.cap <= 0) continue;
      if (level[v] >= level[e.to]) continue;
      int d = dfs(e.to, t, std::min(f, e.cap));
      if (d <= 0) continue;
      e.cap -= d;
      G[e.to][e.rev].cap += d;
      return d;
    }
    return 0;
  }

  int getFlow(int s, int t) {
    int flow = 0;
    while (1) {
      bfs(s);
      if (level[t] < 0) return flow;
      std::fill(iter.begin(), iter.end(), 0);
      for (int f; f = dfs(s, t, 1 << 29), f > 0; flow += f);
    }
  }
};

int main()
{
  int V = in(), E = in();
  MaxFlow mf(V);

  for (int i = 0; i < E; i++){
    int u = in(), v = in(), c = in();
    mf.addEdge(u, v, c);
  }
  cout << mf.getFlow(0, V - 1) << endl;
  return 0;
}

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

int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    
    ll X;
    cin >> X;

    ll m = 100;
    ll i = 0;
    for (i = 0; m < X; i++) {
        m = m + m / 100;
    }

    cout << i << endl;

    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define ll long long
#define sf scanf
#define pf printf
using namespace std;

int main(){
    int cnta=0,cntb=0,cntc=0,cntd=0,cnte=0,
        cntf=0,cntg=0,cnth=0,cnti=0,cntj=0,cntk=0,
        cntl=0,cntm=0,cntn=0,cnto=0,cntp=0,cntq=0,cntr=0,
        cnts=0,cntt=0,cntu=0,cntv=0,cntw=0,cntx=0,
        cnty=0,cntz=0;

    while(1){
    string s;
    getline(cin,s);
    if(s=="")break;


        int len=s.size();
        for(int i=0; i<len; i++){
            if(s[i]=='a' || s[i]=='A') cnta++;
            if(s[i]=='b' || s[i]=='B') cntb++;
            if(s[i]=='c' || s[i]=='C') cntc++;
            if(s[i]=='d' || s[i]=='D') cntd++;
            if(s[i]=='e' || s[i]=='E') cnte++;
            if(s[i]=='f' || s[i]=='F') cntf++;
            if(s[i]=='g' || s[i]=='G') cntg++;
            if(s[i]=='h' || s[i]=='H') cnth++;
            if(s[i]=='i' || s[i]=='I') cnti++;
            if(s[i]=='j' || s[i]=='J') cntj++;
            if(s[i]=='k' || s[i]=='K') cntk++;
            if(s[i]=='l' || s[i]=='L') cntl++;
            if(s[i]=='m' || s[i]=='M') cntm++;
            if(s[i]=='n' || s[i]=='N') cntn++;
            if(s[i]=='o' || s[i]=='O') cnto++;
            if(s[i]=='p' || s[i]=='P') cntp++;
            if(s[i]=='q' || s[i]=='Q') cntq++;
            if(s[i]=='r' || s[i]=='R') cntr++;
            if(s[i]=='s' || s[i]=='S') cnts++;
            if(s[i]=='t' || s[i]=='T') cntt++;
            if(s[i]=='u' || s[i]=='U') cntu++;
            if(s[i]=='v' || s[i]=='V') cntv++;
            if(s[i]=='w' || s[i]=='W') cntw++;
            if(s[i]=='x' || s[i]=='X') cntx++;
            if(s[i]=='y' || s[i]=='Y') cnty++;
            if(s[i]=='z' || s[i]=='Z') cntz++;
        }
    }

        cout<<"a : "<<cnta<<endl;
        cout<<"b : "<<cntb<<endl;
        cout<<"c : "<<cntc<<endl;
        cout<<"d : "<<cntd<<endl;
        cout<<"e : "<<cnte<<endl;
        cout<<"f : "<<cntf<<endl;
        cout<<"g : "<<cntg<<endl;
        cout<<"h : "<<cnth<<endl;
        cout<<"i : "<<cnti<<endl;
        cout<<"j : "<<cntj<<endl;
        cout<<"k : "<<cntk<<endl;
        cout<<"l : "<<cntl<<endl;
        cout<<"m : "<<cntm<<endl;
        cout<<"n : "<<cntn<<endl;
        cout<<"o : "<<cnto<<endl;
        cout<<"p : "<<cntp<<endl;
        cout<<"q : "<<cntq<<endl;
        cout<<"r : "<<cntr<<endl;
        cout<<"s : "<<cnts<<endl;
        cout<<"t : "<<cntt<<endl;
        cout<<"u : "<<cntu<<endl;
        cout<<"v : "<<cntv<<endl;
        cout<<"w : "<<cntw<<endl;
        cout<<"x : "<<cntx<<endl;
        cout<<"y : "<<cnty<<endl;
        cout<<"z : "<<cntz<<endl;
    return 0;
}



Measured memory_bytes: 3176
import java.io.PrintWriter
import java.util.*
import java.math.*
import java.lang.*
import kotlin.comparisons.*

val pw = PrintWriter(System.out)
val MOD: Long = (1e+9 + 7).toLong()

fun main(args: Array<String>) {
    val (n, m) = readListOfLong().sorted()
    val oddNum = if(n == 1L) {
        if(m == 1L) 1L
        else n * (m-2L)
    } else (n - 2L) * (m - 2L)
    println(oddNum)
    pw.flush()
}

/****** Declared Functions and Data Structures ******/
// IO
fun read() = readLine()!!
fun readInt() = read().toInt()
fun readLong() = read().toLong()
fun readDouble() = read().toDouble()
fun readListOfString() = read().split(" ")
fun readListOfInt() = readListOfString().map { it.toInt() }
fun readListOfLong() = readListOfString().map { it.toLong() }
fun readListOfDouble() = readListOfString().map { it.toDouble() }

fun Double.format(digits: Int) = String.format("%.${digits}f", this)
fun Float.format(digits: Int) = String.format("%.${digits}f", this)

fun print(value: Any) { pw.print(value) }
fun println(value : Any) { pw.println(value) }


// Extensions
fun<T> List<T>.toBuckets(bucketKeys: List<T>): Map<T, Int> {
    val buckets = bucketKeys.associate { t -> Pair(t, 0) }.toMutableMap()
    this.forEach { t ->
        buckets[t] = buckets[t]!! + 1
    }
    return buckets
}

fun <K, V> Map<K, V>.toMutableMap(): MutableMap<K, V> = HashMap(this)

// Util Functions
fun<T> permutations(src: List<T>): List<List<T>> {
    if(src.size == 1) return listOf(src)
    val perms = mutableListOf<List<T>>()
    val insertElement = src[0]
    permutations(src.drop(1)).forEach { perm ->
        for(i in 0..perm.size) {
            val newPerm = perm.toMutableList()
            newPerm.add(i, insertElement)
            perms.add(newPerm.toList())
        }
    }
    return perms
}

// return nCr, if you want nCr, please access v[n][r]
fun combinations(n: Long): List<List<Long>> {
    val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()
    for(i in 0 until v.size) {
        v[i][0] = 1L
        v[i][i] = 1L
    }
    for(i in 0 until v.size) {
        for(j in 1 until i) {
            v[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD
        }
    }
    return v.map { it.toList() }.toList()
}

// should be a >= b
fun gcd(a: Long, b: Long): Long = 
    if(b == 0L) a else gcd(b, a % b)

// shoud be a >= b
fun lcm(a: Long, b: Long): Long = 
    a / gcd(a, b) * b

fun sumDigits(num_: Long): Long {
    var num = num_
    var rtn: Long = 0
    while(num != 0.toLong()) {
        val tmp = num % 10
        rtn += tmp
        num /= 10
    }
    return rtn
}

fun isDecimal(v: Double): Boolean = ((v - Math.floor(v)) != 0.0)

// Data Structures
class Stack<T>(private var st: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = st.isEmpty()
    fun top(): T = st.last()
    fun push(e: T) { st.add(e) }
    fun pop() { st = st.dropLast(1).toMutableList() }
}

class Queue<T>(private var que: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = que.isEmpty()
    fun top(): T = que.first()
    fun push(e: T) { que.add(e) }
    fun pop() { que = que.drop(1).toMutableList() }
}


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

int main(){
  int num;
  int sum = 0;
  string str;
  cin >> num >> str;
  for(int i=0; i<10; i++){
    for(int j=0; j<10; j++){
      for(int k=0; k<10; k++){
        bool flag[3];
        bool Found = false;
        for(int x=0; x<3; x++) flag[x] = false;
        for(int n=0; n<num; n++){
          if(!flag[0]){
            if(i == str[n]-'0') flag[0] = true;
          }else if(!flag[1]){
            if(j == str[n]-'0') flag[1] = true;
          }else if(!flag[2]){
            if(k == str[n]-'0'){
              Found = true;
              break;
            }
          }
        }
        if(Found) sum++;
      }
    }
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define size 150

int main()
{
    int sizeA, sizeB;
    char A[size] = {}, B[size] = {};
    scanf("%s",A);
    scanf("%s",B);
    for(int i=0;i<size;i++){
        if(A[i]=='\0'){
            sizeA=i;
            break;
        }
    }
    for(int i=0;i<size;i++){
        if(B[i]=='\0'){
            sizeB=i;
            break;
        }
    }
    if(sizeA>sizeB){
        printf("GREATER\n");
    } else if(sizeA<sizeB) {
        printf("LESS\n");
    } else {
        for(int i=0;i<size;i++){
            if(A[i]!=B[i]){
                if(A[i]>B[i]){
                     printf("GREATER\n");
                     break;
                } else {
                     printf("LESS\n");
                     break;
                }
            }
            if(i==size-1){
                printf("EQUAL\n");
            }
        }
    }
    return 0;
}

Measured memory_bytes: 128
def q_c():
    a = input().split()
    a_1 = int(a[0])
    if "." not in a[1]:
        a_2 = int(a[1]) * 100
    else:
        a_2 = int((a[1] + "00").replace(".","")[0:3])

    a = str(a_1 * a_2)
    if len(a) >= 3:
        print(a[0:-2])
    else:
        print(0)


if __name__ == '__main__':
    q_c()


Measured memory_bytes: 9164
#include<bits/stdc++.h>
using namespace std; 
int main()
{
  int n,k;
  int h[100005];
  int ans;

  cin>>n>>k;

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

  sort(h,h+n);
  ans=h[k-1]-h[0];
  for(int i=1;i<n-k+1;i++){
    if(ans>h[i+k-1]-h[i]){
      ans=h[i+k-1]-h[i];
    }
  }

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


Measured memory_bytes: 640
def main():
    n, k = map(int, input().split())
    lr = [list(map(int, input().split())) for _ in range(k)]
    dp = [0] * (n + 1)
    dp[1] = 1
    dpsum = [0] * (n + 1)
    dpsum[1] = 1
    mod = 998244353

    for i in range(2, n + 1):
        for j in range(k):
            li = i - lr[j][1]
            ri = i - lr[j][0]
            if ri < 0:
                continue
            dp[i] = (dp[i] + dpsum[ri] - dpsum[li - 1]) % mod
        dpsum[i] = dpsum[i - 1] + dp[i]

    print(dp[-1] % mod)


if __name__ == "__main__":
    main()


Measured memory_bytes: 71328
#include<stdio.h>
int main ()
{
    int x, a;
    scanf("%d %d", &x, &a);
    
    if(x<a)
    {
        printf("0\n");
    }
    else if(x>a)
    {
        printf("10\n");
    }
    else
    {
        printf("10\n");
    }
    
     
     return 0;
    
    
}


Measured memory_bytes: 128
// ------------------------------------
// Date:2018/ 4/14
// Problem:/ / / b.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

int N, M, X;
int a[111];

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

  cin >> N >> M >> X;
  fill_n(a, 111, 0);
  REP(i, M) {
    CIN(p);
    a[p]++;
  }
  
  int ucost, dcost;
  ucost = dcost = 0;
  RREP(i, X + 1) {
    dcost += a[i];
  }
  FOR(i, X + 1, N + 1) {
    ucost += a[i];
  }

  int ans = min(dcost, ucost);
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
#define all(n) (n).begin(),(n).end()
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}
#define int long long
struct Edge {
  ll to, cost;  // 辺の接続先頂点, 辺の重み
  Edge(ll to, ll cost) : to(to), cost(cost) {}  // コンストラクタ
};

typedef vector<vector<Edge> > AdjList;  // 隣接リストの型
AdjList graph;  // グラフの辺を格納した構造体
                // graph[v][i]は頂点vから出るi番目の辺Edge

const ll INF = 10000000000000000;

vector<ll> dist,unko; // 最短距離

bool a=1;

// 戻り値がtrueなら負の閉路を含む
bool bellman_ford(int n, int s) { // nは頂点数、sは開始頂点
  dist = vector<int>(n, INF);
  dist[s] = 0; // 開始点の距離は0
  for (int i = 0; i < n*2; i++) {
    for (int v = 0; v < n; v++) {
      for (int k = 0; k < graph[v].size(); k++) {
        Edge e = graph[v][k];
        if (dist[v] != INF && dist[e.to] > dist[v] + e.cost) {
        
          dist[e.to] = dist[v] + e.cost;
          if (i == n - 1){
          	unko=dist;
          } // n回目にも更新があるなら負の閉路が存在
          if(i==2*n-1){
          	return true;
          }
        }
      }
    }
  }
  return false;
}

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

  graph = AdjList(n);
  
  for (int i = 0; i < m; i++) {
    int from, to, cost;
    cin >> from >> to >> cost;
    graph[from-1].push_back(Edge(to-1, p-cost));
  }

  if(bellman_ford(n,0)){
  	if(unko[n-1]==dist[n-1]){
  		cout << max(0ll,-dist[n-1]) << endl;
  	}else{
  		cout << -1 << endl;	
  	}
  	
  	
  	
  }else{
  	cout << max(0ll,-dist[n-1]) << endl;
  }
  
 }

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <tuple>
#include <unordered_map>
#include <map>
#include <cmath>

#define endl "\n"
#define eb emplace_back
#define ll long long

using namespace std;

int main() {

    cin.tie(nullptr); cout.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int n, w;
    cin >> n >> w;

    int values[n];
    ll weights[n];

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

    ll maxVal = 0;
    for (int i = 0; i < n; i++)
        maxVal += values[i];

    ll dp[maxVal+1];
    fill(dp, dp+maxVal+1, 1e9);
    dp[0] = 0;

    for (int i = 0; i < n; i++) {
        for (ll j = maxVal; j >= values[i]; j--) {
            dp[j] = min(dp[j], weights[i] + dp[j-values[i]]);
        }
    }

    ll ans = 0;
    for (int i = 0; i <= maxVal; i++) {
        if (dp[i] <= w)
            ans = i;
    }

    cout << ans;

    return 0;

}

Measured memory_bytes: 4428
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func scanInts(n int) []int {
	sl := make([]int, n)
	for i := range sl {
		sl[i] = scanInt()
	}
	return sl
}

func scanStrings(n int) []string {
	sl := make([]string, n)
	for i := range sl {
		sl[i] = scanString()
	}
	return sl
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	N, M := scanInt(), scanInt()
	min, max := 1, N
	for i := 0; i < M; i++ {
		min_tmp, max_tmp := scanInt(), scanInt()
		if min_tmp > min {
			min = min_tmp
		}
		if max_tmp < max {
			max = max_tmp
		}
	}
	if min <= max {
		fmt.Println(max - min + 1)
	} else {
		fmt.Println(0)
	}
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include <math.h>
#include <algorithm>
#include <functional>
#include<iostream>
#include <string>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define fro(i,j,n) for(int i=j;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)


int main() {
    ll k,ans;
	cin >> k;
  	queue<ll> que;
  	for(int i=1;i<10;i++){
      que.push(i);
    }
    ll i;
    ll j=9;
    while(11<k){
      i=que.front();
      que.pop();
      if(i%10!=0){que.push(i*10+i%10-1);
      j++;
                 }
      if(j==k){
        ans = i*10+i%10-1;
        break;
      }
      que.push(i*10+i%10);
      j++;
      if(j==k){
        ans = i*10+i%10;
        break;
      }
      if(i%10!=9){que.push(i*10+i%10+1);
      j++;
                 }
      if(j==k){
        ans = i*10+i%10+1;
        break;
      }
      
    }
    if(k<13)cout << k << endl;
      else cout << ans << endl;
}


Measured memory_bytes: 768
using System;
using System.Linq;
using System.Collections.Generic;

class Mondai
{
    static void Main()
    {
        var hw = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray(); ;
        var H = hw[0];
        var W = hw[1];
        var isBlack = new bool[H, W];
        var que = new Queue<int[]>();
        for (int i = 0; i < H; ++i)
        {
            var A = Console.ReadLine().ToCharArray();
            for (int j = 0; j < W; ++j)
            {
                if (A[j] == '#')
                {
                    isBlack[i, j] = true;
                    que.Enqueue(new int[3] { i, j, 0 });
                }
                else isBlack[i, j] = false;
            }
        }
        var ans = 0;
        var X = new int[] { -1, 0, 1, 0 };
        var Y = new int[] { 0, -1, 0, 1 };
        while (que.Any())
        {
            var info = que.Dequeue();
            var y = info[0];
            var x = info[1];
            var time = info[2]+1;
            for (int i=0;i<4;++i)
            {
                var nextX = x + X[i];
                var nextY = y + Y[i];
                if (nextX < 0 || W <= nextX || nextY < 0 || H <= nextY || isBlack[nextY,nextX]) continue;
                isBlack[nextY,nextX] = true;
                que.Enqueue(new int[3] { nextY, nextX, time });
                if (ans < time) ans = time;
            }
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 72072
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define maxn 4010
#define ll long long
using namespace std;
const ll modd=924844033;
int n,k;
void file(){
	freopen("C.in","r",stdin);
	freopen("C.out","w",stdout);
}
int vis[maxn][2];
int dp[maxn][maxn][2];
ll f[maxn];
ll ans;
ll fac[maxn];
int tag[maxn];int tot;
int main(){
	//file();
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++){
		for(int j=0;j<=1;j++){
			if(!vis[i][j]){
				int x=i,y=j;int len=0;
				while(x<=n){
					vis[x][y]=1;
					x+=k;y^=1;
					len++;
				}
				tot+=len;
				tag[tot]=1;
			}
		}
	}
	dp[1][0][0]=1;//printf("%d\n",tot);
	for(int i=1;i<=tot;i++){
		for(int j=0;j<=i;j++){
			dp[i+1][j][0]=(dp[i][j][0]+dp[i][j][1])%modd;//if(dp[i+1][j][0]<0)printf("1*\n");
			if(!tag[i]){
				dp[i+1][j+1][1]=dp[i][j][0];//if(dp[i][j][0]<0)printf("*\n");
			}
		}
	}
	for(int i=1;i<=n;i++){
	//	 ll tp=(dp[tot][i][0]+dp[tot][i][1]);
		f[i]=(ll)(dp[tot][i][0]+dp[tot][i][1])%modd;
//		if(f[i]<0)printf("3*\n");
	}
	fac[0]=1;
	for(int i=1;i<=n;i++){
		fac[i]=fac[i-1]*(ll)i%modd;
//		if(fac[i]<0)printf("4*\n");
	}
	ans=fac[n];
	for(int i=1,j=-1;i<=n;i++,j=-j){
		ll tp=f[i]*fac[n-i]%modd;//if(tp<0)printf("5*\n");
		if(j==1)
		ans=(ans+modd+tp)%modd;
		else ans=(ans-tp+modd)%modd;
	}
	printf("%lld\n",ans);
	return 0;
}

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

void main() {
    int n, m;

    scan(n, m);

    auto visited = new bool[](n);
    auto adj = new int[][](n, 0);
    auto rank = new int[](n);

    foreach (i ; 0 .. m) {
        int si, ti;
        scan(si, ti);
        adj[si] ~= ti;
    }

    int num = n - 1;

    void dfs(int v) {
        visited[v] = true;

        foreach (u ; adj[v]) {
            if (!visited[u]) dfs(u);
        }

        rank[num--] = v;
    }

    foreach (i ; 0 .. n) {
        if (!visited[i]) dfs(i);
    }

    writefln("%(%s\n%)", rank);
}


void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

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

int get(int l, int r, int s, int e) {
	int mid = (s + e) / 2;
	cerr << l << '-' << s << ' ' << mid << endl;
	if (r <= s || e <= l)
		return 0;
	if (l <= s && e <= r) {
		cerr << s << ' ' << e << ' ' << "is goood\n";
		return e - s;
	}
	cerr << l << ' ' << s << ' ' << mid << endl;
	int a = get(l, r, s, mid);
	int b = get(l, r, mid, e);
	if (a && b) {
		cerr << '(' << s << '|' << e << '|' << a << '|' << b << ')' << min(2 * a + b, a + e - mid) << endl;
	}
	if (b)
		return min(2 * a + b, a + e - mid);
	else
		return a;
}

int32_t main() {
	int s, e;
	cin >> s >> e;
	cout << get(s, e + 1, 0, (1ll << 60)) << endl;
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  __MAKE_TIME__  Problem: __PROBLEM__ / Link: __CONTEST_URL__  ----- */
/* ------問題------
-----問題ここまで----- */
/* -----解説等-----
----解説ここまで---- */

LL N;

LL ans = 0LL;

//[L,R]のいい感じの分割
PLL f(VL& csum, int L, int R) {
	int LLL = L, RRR = R;
	FOR(i, 0, 10) { // check [L,mid][mid+1,R]
		int mid1 = (2*L + R) / 3;
		int mid2 = (L + 2*R) / 3;
		LL dif1 = LINF, dif2 = LINF;
		{
			LL A = csum[mid1] - csum[LLL - 1];
			LL B = csum[RRR] - csum[mid1];
			dif1 = abs(A - B);
		}
		{
			LL A = csum[mid2] - csum[LLL - 1];
			LL B = csum[RRR] - csum[mid2];
			dif2 = abs(A - B);
		}
		if (dif2 < dif1) {
			L = mid1;
		}
		else {
			R = mid2;
		}
	}
	LL dd = LINF;
	LL M = 0;
	FOR(i, 0, R-L+1) {
		int mid2 = L + i;
		LL A = csum[mid2] - csum[LLL - 1];
		LL B = csum[RRR] - csum[mid2];
		if (abs(A - B) < dd) {
			dd = abs(A - B);
			M = mid2;
		}
	}
	LL A = csum[M] - csum[LLL - 1];
	LL B = csum[RRR] - csum[M];
	return PLL(A, B);
}

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

	cin >> N;
	VL a(N);
	FOR(i, 0, N)cin >> a[i];
	VL csum(N + 1, 0);
	FOR(i, 0, N)csum[i + 1] = csum[i] + a[i];
	// iを決める(a,b||c,d)
	// この中の最適分割は
	// なかをいい感じに分割することである
	ans = LINF;
	FOR(c, 2, N - 1) { // cの位置
		// [A,B]:[1:c]
		PLL ab = f(csum, 1, c);
		// [C,D]:[c+1,N]
		PLL cd = f(csum, c + 1, N);
		LL Max = max({ ab.first,ab.second,cd.first,cd.second });
		LL Min = min({ ab.first,ab.second,cd.first,cd.second });
		ans = min(ans, Max - Min);
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
using ll = int_fast64_t;
#define SELECTOR(_1, _2, _3, SELECT, ...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__, _rep1, _rep0)(__VA_ARGS__)
#define _rep0(i, n) for (ll i = 0; i < n; ++i)
#define _rep1(i, k, n) for (ll i = k; i < n; ++i)

void solve(){
  // main coding
  ll n,m; cin>>n>>m;
  ll INF=1<<15;
  vector<vector<ll>> dist(n,vector<ll>(n,INF)); // adjacency matrix
  vector<vector<ll>> E(n); // adjacency list
  rep(_,m) {
    ll a,b; cin>>a>>b;
    --a; --b; // 0-indexed
    dist[a][b]=1;
    E[a].push_back(b);
  }
  // Warshall-Floyd
  rep(k,n) rep(i,n) rep(j,n) {
    dist[i][j]=min(dist[i][k]+dist[k][j],dist[i][j]);
  }
  // loop detection
  ll len=n+1,v;
  rep(i,n) {
    if(dist[i][i]<len) {
      v=i;
      len=dist[i][i];
    }
  }
  if(len==n+1) {
    cout<<-1<<"\n";
    return;
  }
  const ll vm=v;
  vector<ll> ans;
  while(len){
    ans.push_back(v);
    --len;
    rep(i,n) if(dist[v][i]==1 && dist[i][vm]==len){
      v=i;
      break;
    }
  }
  cout<<ans.size()<<"\n";
  for(ll v:ans) cout<<v+1<<"\n";
}

int main(){
  // ios::sync_with_stdio(false);
  // cout<<fixed<<setprecision(10);
  solve();
  return 0;
}


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

using namespace std ;
typedef long long ll;
typedef string str;
typedef vector<int> vint;
typedef vector<double> vdou ;
typedef vector<ll> vll;
typedef vector<vint> vvint;
typedef vector<str> vstr;
typedef pair<int, int> pii;
typedef vector<pii> vpii ;

#define REP(i, n) for (ll (i) = 0; (i) < (ll)(n); i++) 
#define FOR(i, a, b) for(ll (i) = a; (i) < (ll)b; i++)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define CHI 1000000000000000003
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (ll)x.size()
#define SP(x)  setprecision((ll)x)

const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
const double PI = M_PI;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数

//-------------------------------------------------
// 
void yes(){
  cout <<"Yes"<<endl ;
}
void no(){
  cout <<"No"<<endl ;
}

bool isprime(ll n){
    if(n==2){
        return true ;
    }
    else if(n<2 || n%2==0){
        return false ;
    }
    else{
        ll i = 3 ;
        while(i<=sqrt(n)){
            if(n%i==0){
                return false ;
            }
            i += 2 ;
        }
        return true ;
    }
}

vll yakusuu(ll n){
    vll ret ;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            ret.push_back(i) ;
            if(i*i!=n){
                ret.push_back(n/i) ;
            }
        }
    }
    sort(ALL(ret)) ;
    return ret ;
}


//-------------------------------------------------
// メモ
/*






*/
//-------------------------------------------------


int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a, b ;
  cin >> a >> b ;
  ll c = gcd(a,b) ;
  vll yak = yakusuu(c) ;
  ll ans = 1 ;
  REP(i,SZ(yak)){
    if(isprime(yak[i])){
      ans++ ;
    }
  }
  cout << ans <<endl ;
  
  
  
  return 0 ;
}

Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int h, w, d;
	cin >> h >> w >> d;
	vector<pair<int,int>> v(h*w+1);
	for(int i=1; i<=h; i++){
		for(int j=1; j<=w; j++){
			int a;
			cin >> a;
			v[a]=make_pair(i,j);
		}
	}
	vector<int> u(h*w+1,0);
	for(int i=d+1; i<h*w+1; i++){
		u[i]=u[i-d]+abs(v[i].first-v[i-d].first)+abs(v[i].second-v[i-d].second);
	}
	int q;
	cin >> q;
	for(int i=0; i<q; i++){
		int l, r;
		cin >> l >> r;
		cout << u[r]-u[l] << endl;
	}
	return 0;
}

Measured memory_bytes: 2176
import std.stdio;
import std.ascii;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;

void main() {
    int N, M; scanf("%d %d\n", &N, &M);
    int[] L = new int[M];
    foreach (i; 0 .. M) {
        scanf("%d\n", &L[i]);
    }

    foreach (i; 0 .. M) {
        if (gcd(L[i], N) == 1) {
            writeln("Yes");
            return;
        }
    }
    int G = L[0];
    foreach (i; 1 .. M) {
        G = gcd(G, L[i]);
    }
    writeln(G == 1 ? "Yes" : "No");
}

Measured memory_bytes: 1232
#include<stdio.h>

int main(){
  int i, j, n, x[101][101] = {}, y[3];

  scanf("%d", &n);

  for(i = 1; i <= n; i++){
    scanf("%d %d", &y[0], &y[1]);

    for(j = 1; j <= y[1]; j++){
      scanf("%d", &y[2]);
      x[i][y[2]] = 1;
    }
  }

  for(i = 1; i <= n; i++){
    for(j = 1; j <= n; j++){
      printf("%d", x[i][j]);
      if(j != n) printf(" ");
    }
    printf("\n");
  }

  return 0;
}



Measured memory_bytes: 2104
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;


int main() {
	int h, w;
	cin >> h >> w;

	vector<string> c(h);

	for (int i = 0; i < h; i++)
		cin >> c[i];

	for (int i = 0; i < h + 2; i++) {
		for (int j = 0; j < w + 2; j++) {
			if (i == 0 || j == 0 || i == h + 1 || j == w + 1) {
				printf("#");
			}else {
				printf("%c", c[i - 1][j - 1]);
			}
		}
		cout << endl;
	}

}

Measured memory_bytes: 256
program main
  implicit none
  integer :: a, b, i, ndig, face, ar(10)
  read (*, *) a, b
  if (a <= b) then
    face = a
    ndig = b
  else
    face = b
    ndig = a
  end if
  ar(:) = face
  write (*, "(10(i0))") ar(1:ndig)
end program main


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#include<bits/stdc++.h>
#define ll long long
int main() {
   string s,t;
   cin>>s>>t;
   int n = s.length();
   int l= t.length();

   int maxi= INT_MIN;
   int c=0;
   for(int i=0 ;i<n-l+1;i++)
   {
     c=0;
       for(int j=0;j<l;j++)
       {
           
           if(s[i+j]==t[j])
           {
              c++;
           }
          
       }
        maxi = max(maxi,c);
   }
     maxi = max(maxi,c);
   cout<<l-maxi<<endl;

}


Measured memory_bytes: 3612
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>
using namespace std;

typedef long long lint;

int main(){
    int n;
    cin >> n;
    int res = 2 * n;
    vector<int> L(res);
    for(int i = 0 ; i < res ; i++){
        cin >> L[i];
    }
    sort(L.begin(), L.end());
    int ans = 0;
    for(int i = 0 ; i < res ; i += 2){
        ans += L[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int A = sc.nextInt();
       	int B =sc.nextInt();
       	int K =sc.nextInt();
       	ArrayList<Integer> array = new ArrayList<>();

       	for(int i =1 ;i<=100;i++){
       		if(A %i ==0 & B%i ==0){
       			array.add(i);
       		}
       	}
       	Collections.sort(array, Comparator.reverseOrder());

       	System.out.println(array.get(K-1));

}
}


Measured memory_bytes: 23636
from itertools import permutations
def solve(perm):
  t = 0
  for i in perm:
    t = ((t + 9) // 10) * 10
    t += x[i]
  return t

x = [int(input()) for _ in range(5)]
ans = min([solve(perm) for perm in permutations([i for i in range(len(x))])])
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define SORT(c) sort((c).begin(),(c).end());
#define pb push_back
#define MP make_pair
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define pi 3.141592653589793
#define ll long long
#define ull unsigned long long
#define w(x) int x;cin>>x;while(x--)
#define fast ios_base::sync_with_stdio(0)
#define sz size()
#define cu cout<<
#define en endl
#define sp " "
#define RE(i,n) for(int i=0,_n=(n);i<_n;++i)
#define RI(i,n) for(int i=1,_n=(n);i<=_n;++i)
#include<cstdio>
#include<cstring>
typedef unsigned long long UL;
template<typename T>inline T  S(T a)
{
    return a*a;
}
template<class T>inline string tostring(T a)
{
    ostringstream os("");
    os << a;
    return os.str();
}
template<typename T>inline ll tolong(T a)
{
    ll res;
    istringstream os(a);
    os>>res;
    return res;
}
template<typename T>inline T gcd(T a, T b)
{
    if (b == 0)return a;
    else return gcd(b, a % b);
}
template<typename T>inline T bigmod(T a, T b, T m)
{
    if (b == 0)return 1;
    else if (b % 2 == 0)return S(bigmod(a, b / 2, m)) % m;
    else return (a % m*bigmod(a, b - 1, m)) % m;
}
const int inf = (int)1e9 + 5;
const ll linf = (ll)1e16 + 5;
const ll modd = (ll)1e9 + 7;
const int mod = 10000007;
#define N 20000009
bool prime[N];
vector<ll> prm;
void seive ()
{

    memset(prime, true, sizeof(prime));

    for( ll i=2; i*i<=N; i++)
    {
        if (prime[i] == true)
        {
            for (ll j=i*i; j<=N; j += i)
                prime[j] = false;
        }
    }
}
/*bool isprime(ll n)
{
    if(n<2) return 0;
    if(n==2) return 1;
    else
    {
        for(int i=2; i*i<=n; i++)
            if(n%i==0) return 0;
    }
    return 1;
}*/
void pr (int f)
{
    if(f==1)
        cout<<"YES\n";
    else
        cout<<"NO\n";
}
int cnt[200];
int main()
{
    fast;
   int n;
   cin >>n;
   string s;
   for ( int i=0;i<n;i++)
   {
       cin >> s;
       if(s=="AC") cnt[0]++;
       else if(s=="WA") cnt[1]++;
      else  if(s=="TLE") cnt[2]++;
       else if(s=="RE") cnt[3]++;
   }
   cout <<"AC x "<<cnt[0]<<endl;
   cout <<"WA x "<<cnt[1]<<endl;
   cout <<"TLE x "<<cnt[2]<<endl;
   cout <<"RE x "<<cnt[3]<<endl;
}


Measured memory_bytes: 3656
import fractions

k = int(input())

ans = 0
gcd_table = [[0 for _ in range(k)] for _ in range(k)]
for i in range(k):
    for j in range(k):
        gcd_table[i][j] = fractions.gcd(i+1, j+1)
for i in range(k):
    for j in range(k):
        for l in range(k):
            ans += gcd_table[gcd_table[i][j]-1][l]
print(ans)


Measured memory_bytes: 10944
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <list>
#include <map>
#include <stack>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <numeric>
 
using namespace std;


const int maxn = 1e5+5;
char arr[maxn] = {};

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

    int n; cin >> n;
    string s; cin >> s;

    for (int i = 0; i < n; i++) {
        arr[i] = s[i];
    }

    cout << unique(arr, arr+n) - arr << endl;

}



Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
ll INF=1LL<<60;
ll MOD=1000000007;



int main(){
    double X;
    cin >> X;
    double F=sqrt(sqrt(X/5));
    ll F2=F;
    ll s=F2+1;
    for(ll i=1;i<=s;i++){
     for(ll j=-i;j<i;j++){
         if(pow(i,5)-pow(j,5)==X){
             cout<<i<<" "<<j<<endl;return 0;
         }
     ;}
    ;}
    
    return 0;
}


Measured memory_bytes: 4192
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>


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

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

int main(void)
{
    cin.sync_with_stdio(false);
    int N;
    cin >> N;
    
    vector<int> locs(N + 1);
    REP(n, N) {
        int p;
        cin >> p;
        locs[p] = n + 1;
    }
    
    // 番兵を入れる
    multiset<int> seen;
    seen.insert(0);
    seen.insert(0);
    seen.insert(N + 1);
    seen.insert(N + 1);
    
    // 以下のように並んでいるとき、2番めに大きい値が4となる範囲を考える
    // inf inf 1 5 2 4 3 7 6 inf inf
    //      w    x       y z
    //
    
    ll ans = 0;
    for(int n = N; n >= 1; --n) {
        auto loc = locs[n];
        auto it = seen.lower_bound(loc);
        auto y = *it;
        ++it;
        auto z = *it;
        --it;
        --it;
        auto x = *it;
        --it;
        auto w = *it;
        //cout << "loc of " << n << ": " << loc << endl;
        //cout << "y = " << y << endl;
        //cout << "z = " << z << endl;
        //cout << "x = " << x << endl;
        //cout << "w = " << w << endl;
        
        ll combination = (x - w) * (y - loc);
        combination += (z - y) * (loc - x);
        ans += combination * n;
        
        //cout << "added: " << (x - w) * (y - loc) << endl;
        //cout << "added: " << (z - y) * (loc - x) << endl;
        
        seen.insert(loc);
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 5376
// Copyright (C) 2017 __debug.

// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; version 3

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; If not, see <http://www.gnu.org/licenses/>.


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/priority_queue.hpp>

#define x first
#define y second
#define MP std::make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#ifdef __linux__
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif

using std::pair;
using std::vector;
using std::string;

typedef long long LL;
typedef pair<int, int> Pii;

const int oo = 0x3f3f3f3f;

template<typename T> inline bool chkmax(T &a, T b) { return a < b ? a = b, true : false; }
template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, true : false; }
string procStatus()
{
    std::ifstream t("/proc/self/status");
    return string(std::istreambuf_iterator<char>(t), std::istreambuf_iterator<char>());
}
template<typename T> T read(T &x)
{
    int f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar())
        f = (ch == '-' ? -1 : 1);
    for (x = 0; isdigit(ch); ch = getchar())
        x = 10 * x + ch - '0';
    return x *= f;
}
template<typename T> void write(T x)
{
    if (x == 0) {
        putchar('0');
        return;
    }
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    static char s[20];
    int top = 0;
    for (; x; x /= 10)
        s[++top] = x % 10 + '0';
    while (top)
        putchar(s[top--]);
}
// EOT

const int MAXN = 2e5 + 5;

int N, D, X;

void input()
{
    read(N); read(D); read(X);
}

void solve()
{
    long double d = D, x = X;
    long double ans = 0;
    for (int n = N; n >= 1; --n) {
        ans += (2 * d + (2 * n - 1) * x) / 2;
        long double d0 = ((2 * n + 2) * d + 5 * x) / (2 * n);
        long double x0 = ((2 * n - 2) * (d + x) + 4 * d + 11 * x) / (2 * n) - d0;
        d = d0; x = x0;
    }

    printf("%.15Lf\n", ans);
}

int main()
{
#ifdef __DEBUG
    freopen("C.in", "r", stdin);
    freopen("C.out", "w", stdout);
#endif

    input();
    solve();

    return 0;
}

// 此情可待成追忆？只是当时已惘然。
//     -- 李商隐《锦瑟》


Measured memory_bytes: 256
N, T = map(int, input().split())
ct=[]
for _ in range(N):
    ct.append(tuple(map(int, input().split())))
OK=[tpl for tpl in ct if tpl[1]<=T]
if OK:
    good=min(OK, key=lambda x:x[0])
    print(good[0])
else:
    print('TLE')

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

inline int read()
{
	char c=getchar();
	int x=0,f=1;
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') {x=(x<<3)+(x<<1)+c-'0';c=getchar();}
	return x*f;
}

typedef long long LL;
const int maxn=2e5+5,INF=1e9+5;

int a[maxn];
int n;

LL f(int b)
{
	int i;
	LL ans=0;
	for (i=1;i<=n;i++) ans+=abs(a[i]-(b+i));
	return ans;
}

int main()
{
	int i,l,r,x,y;
	LL f1,f2;
	n=read();
	for (i=1;i<=n;i++) a[i]=read();
	l=-INF,r=INF;
	x=1LL*(r-l)/3+l,y=r-1LL*(r-l)/3;
	while (x<y)
	{
		f1=f(x),f2=f(y);
		if (f1<f2) r=y;else l=x;
		x=1LL*(r-l)/3+l,y=x+1LL*(r-l)/3;
		//printf("%d %d\n",l,r);
	}
	printf("%lld\n",f1);
	return 0;
}

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

int main(){
    int N;
    cin >> N;
    int a[N];
    for(int i=0;i<N;i++) cin >> a[i];
    int ans=0;
    for(int i=1;i<N;i++){
        int cnt=1;
        int j=i;
        while(true){
            if(a[j]!=a[j-1]) break;
            cnt++;
            j++;
            if(j==N) break;
        }
        i=j;
        //cout << cnt << endl;
        ans+=cnt/2;
    }
    cout << ans << endl;
}

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int n;
    int a[100003];
    int k;
    Scd2(n,k);

    Rep(i,n){
        Scd(a[i]);
    }

    sort(a,a+n);

    int dis = INF;

    Rep(i,n){
        dis = min( a[i] , dis );
        if( i == n-1 ) break;
        if( a[i+1] == a[i] ) continue;
        dis = min( dis , a[i+1] - a[i] );
    }

    bool ans = false;
    Rep(i,n){
        if( a[i] >= k ){
            if( (a[i] - k) % dis == 0 ){
                ans = true;
            }
        }
        if( ans ) break;
    }


    printf ("%s\n", ans ? "POSSIBLE" : "IMPOSSIBLE" );


    return 0;
}



Measured memory_bytes: 640
#include<cstdio>
#define F(i,a) for(int i=0;i<a;++i)
int n,N,D1,D2;
int i1[600],j1[600],t1;
int i2[600],j2[600],t2;
bool v1[600][600], v2[600][600];
bool c1[600][600], c2[600][600];
int s[4];
void DFS1(int x,int y,bool c){
	if(x<0||y<0||x>=N||y>=N) return;
	if(v1[x][y]) return;
	v1[x][y]=1, c1[x][y]=c;
	F(k,t1){
		DFS1(x+i1[k],y+j1[k],!c);
		DFS1(x+i1[k],y-j1[k],!c);
		DFS1(x-i1[k],y+j1[k],!c);
		DFS1(x-i1[k],y-j1[k],!c);
	}
}
void DFS2(int x,int y,bool c){
	if(x<0||y<0||x>=N||y>=N) return;
	if(v2[x][y]) return;
	v2[x][y]=1, c2[x][y]=c;
	F(k,t2){
		DFS2(x+i2[k],y+j2[k],!c);
		DFS2(x+i2[k],y-j2[k],!c);
		DFS2(x-i2[k],y+j2[k],!c);
		DFS2(x-i2[k],y-j2[k],!c);
	}
}
int main(){
	scanf("%d%d%d",&n,&D1,&D2); N=n+n;
	F(i,N) if(i*i<=D1)
		F(j,N) if(i*i+j*j==D1)
			i1[t1]=i, j1[t1]=j, t1++;
	F(i,N) if(i*i<=D2)
		F(j,N) if(i*i+j*j==D2)
			i2[t2]=i, j2[t2]=j, t2++;
	F(i,N) F(j,N) DFS1(i,j,0);
	F(i,N) F(j,N) DFS2(i,j,0);
	F(i,N) F(j,N)
		++s[c1[i][j]*2+c2[i][j]];
	F(k,4) if(s[k]>=n*n){
		int cnt=0;
		F(i,N) F(j,N) if(c1[i][j]*2+c2[i][j]==k&&cnt<n*n)
			++cnt, printf("%d %d\n",i,j);
		return 0;
	}
}

Measured memory_bytes: 19072
N = int(input())
 
k = N//4
m = N%4
if(m == 0):
  print("Yes")
elif(m == 1):
  if(k>=5):
    print("Yes")
  else:
    print("No")
elif(m==2):
  if(k>=3):
    print("Yes")
  else:
    print("No")
elif(m==3):
  if(k>=1):
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue> 
#define rg register
using namespace std;
typedef long long LL;
template<typename T> inline void read(T &x){
	x=0; T f=1; char ch=getchar();
	while(ch<'0'||ch>'9') f=ch=='-'?-1:1, ch=getchar();
	while(ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+(ch^'0'), ch=getchar();
	x=x*f;
}
const int N=1e6+10;

int n;

int calc(int x){
	int s=0;
	for(int i=1;i*i<=x;i++){
		if(x%i==0){
			s++;
			if(x/i!=i) s++;
		}
	}
	return s;
}

int main(){
	read(n);
	int res=0;
	for(int i=1;i<n;i++)
		res+=calc(n-i);
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 3764
using System;
using System.Linq;
using System.Collections.Generic;

class Plogram
{
    static void Main()
    {
        var line = Console.ReadLine().Split();
        int N = int.Parse(line[0]);
        int M = int.Parse(line[1]);
        int ans = 0;

        var X = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        X = X.OrderBy(x => x).ToArray();

        var range = new List<int>();
        for (int i = 0; i < M - 1; i++)
        {
            range.Add(X[i + 1] - X[i]);
        }
        range = range.OrderBy(x => x).ToList();

        for (int i = 0; i < M - N; i++)
        {
            ans += range[i];
        }

        Console.WriteLine(ans);

    }
}

Measured memory_bytes: 26464
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int x;
int main()
{
	scanf("%d",&x);
	int a=x/1000,b=x/100%10,c=x/10%10,d=x%10;
	if(a==b||b==c||c==d)
		printf("Bad\n");
	else
		printf("Good\n");
	return 0;
}


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

int main() {

  vector< pair< long long int, pair< long long int, long long int > > > list;

  for ( long long int i = 1; i <= 150; i++ ) {
    for ( long long int j = i+1; j <= 150; j++ ) {
      list.push_back( make_pair( i * i + j * j, make_pair( i, j ) ) );
    }
  }

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

  long long int w, h;

  while( true ) {

    cin >> h >> w;
    if ( w == 0 ) break;

    for ( long long int i = 0; i < list.size(); i++ ) {

      if ( w * w + h * h > list[i].first ) continue;
      if ( w * w + h * h < list[i].first ) {
	cout << list[i].second.first << " " << list[i].second.second << endl;
	break;
      }else {
	if ( h < list[i].second.first ) {
	  cout << list[i].second.first << " " << list[i].second.second << endl;
	  break;
	}
      }

    }

  }

  return 0;

}

Measured memory_bytes: 1540
//  main.cpp
//  CppTest

#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;

int main(int argc, const char * argv[]) {
    
    /////////////////////
    // Write code below /
    /////////////////////
    char c;
    cin >> c;
    const string vowel = "aeiou";
    if (vowel.find(c) == string::npos) {
        cout << "consonant" << endl;
    } else {
        cout << "vowel" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256