akhauriyash/Code-Regression huggingface dataset:
Class Program
    Shared Sub Main(args As String())
        Dim s As String = Console.ReadLine()
        Dim t As String = Console.ReadLine()
        Dim arrS As Char() = s.ToCharArray()
        Dim arrT As Char() = t.ToCharArray()
        Dim cnt As Integer = arrS.Length
        Dim diff As Integer = 0
        For i As Integer = 0 To cnt - 1
            If Not arrS(i).Equals(arrT(i)) Then diff += 1
        Next
        Console.WriteLine(diff)
    End Sub
End Class

Measured memory_bytes: 28144
import java.util.*;

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

		String s = sc.nextLine();
		boolean b = true;
		
		//奇数文字がRUDのいずれかかを調べる
		for(int i = 0; i < s.length(); i += 2) {
			if(!(isRUD(s.charAt(i)))) {
				b = false;
				break;
			}
		}
		
		//偶数文字がRUDのいずれかかを調べる
		for(int i = 1; i < s.length(); i+= 2) {
			if(!(isLUD(s.charAt(i)))) {
				b = false;
				break;
			}
		}
		
		if(b) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
		
	static boolean isRUD(char c) {
		if(c == 'R') {
			return true;
		} else if(c == 'U') {
			return true;
		} else if(c == 'D') {
			return true;
		} else {
			return false;
		}
	}
	
	static boolean isLUD(char c) {
		if(c == 'L') {
			return true;
		} else if(c == 'U') {
		return true;
		} else if(c == 'D') {
			return true;
		} else {
			return false;
		}
	}
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
typedef long long ll;
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod を計算する
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

ll pow2(ll n){
  ll ans=1;
  rep(i,n){
    ans=(ans*2)%MOD;
  }
  return ans;
}

ll COM(ll n, ll k){
  ll ans=1;
  rep(i,k){
    ans=ans*(n-i)%MOD;
    ans=ans*modinv(i+1,MOD)%MOD; 
  }
  return ans;
}

int main() {
  ll n,a,b;
  cin >> n >> a >> b;
  ll ans= (((modpow(2,n,MOD)-1)%MOD-COM(n,a))%MOD-COM(n,b))%MOD;
  if(ans<0){
    ans+=MOD; 
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		char map[][] = {
			{'a','b','c','d','e',},
			{'f','g','h','i','j',},
			{'k','l','m','n','o',},
			{'p','q','r','s','t',},
			{'u','v','w','x','y',},
			{'z','.','?','!',' ',},
		};
		LOOP1: while (sc.hasNext())
		{
			String str = sc.next();
			int length = str.length();
			if (length % 2 != 0)
			{
				System.out.println("NA");
				continue;
			}
			StringBuffer result = new StringBuffer();
			for (int i = 0; i < length; i += 2)
			{
				int a = str.charAt(i) - '1';
				int b = str.charAt(i+1) - '1';
				try
				{
					result.append(map[a][b]);
				}
				catch (ArrayIndexOutOfBoundsException e)
				{
					System.out.println("NA");
					continue LOOP1;
				}
			}
			System.out.println(result.toString());
		}
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#include <stdlib.h>
#include <fstream>
#include <iostream>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

ll mod(ll a, ll b){
  ll ret=a%b;
  if(ret<0) ret+=b;
  return ret;
}

ll modpow(ll a,ll b,ll c){
  ll res=1;
  while(b>0){
    if(b&1) res=mod(res*a,c);
    a=mod(a*a,c);
    b>>=1;
  }
  return res;
}

int main() {
  int n,m;
  cin>>n>>m;
  vector<vector<int>> G(n);
  vector<int> par(n,-1),dis(n,0);
  vector<int> cnt(n,0);
  for(int i=0;i<n-1+m;i++){
    int a,b;
    cin>>a>>b;
    a--;b--;
    G[a].push_back(b);
    cnt[b]++;
  }
  queue<int> memo;
  for(int i=0;i<n;i++){
    if(cnt[i]==0){
      memo.push(i);
    }
  }
  while(!memo.empty()){
    int v=memo.front();
    memo.pop();
    for(auto nv:G[v]){
      dis[nv]=max(dis[v]+1,dis[nv]);
      if(dis[nv]==dis[v]+1) par[nv]=v;
      cnt[nv]--;
      if(cnt[nv]==0){
        memo.push(nv);
      }
    }
  }
  for(int i=0;i<n;i++){
    cout<<par[i]+1<<endl;
  }
  return 0;
}


Measured memory_bytes: 9752
S = input()
count = 0
max = 0
for i in range(len(S)):
  if S[i] == 'A' or S[i] == 'C' or S[i] == 'G' or S[i] == 'T':
    count += 1
    if max < count:
      max = count
  else:
    count = 0
print(max)

Measured memory_bytes: 9104
#include <iostream>
#include <vector>
#include <map>

using namespace std;
typedef long long lli;

int main() {
  int n; cin >> n;
  vector<lli> as(n, 0);
  vector<lli> sums(n, 0);
  map<lli, lli> memo;
  lli ans = 0;
  memo[0] = 1;
  for (int i = 0; i < n; i++) {
    cin >> as[i];
    if ( i != 0 ) {
      sums[i] = as[i] + sums[i - 1];
    } else {
      sums[i] = as[i];
    }

    if (memo.find(sums[i]) == memo.end()) {
      memo[sums[i]] = 1;
    } else {
      memo[sums[i]] += 1;
    }
  }
  for (auto i = memo.begin(); i != memo.end(); i++) {
    if (i->second == 1) continue;
    //cout << i->first << "," << i->second << endl;
    ans += i->second * (i->second - 1) / 2;
  }
  cout << ans << endl;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(NAME, NUM) for (int NAME = 0; NAME < (NUM); ++NAME)
#define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; --NAME)
#define ALL(NAME) (NAME).begin(), (NAME).end()

#define cMOD 1000000007ULL
#define cINF ((1ull<<62)-1)
#define cINFINT ((1<<30)-1)


int main()
{
	ll w,h,x,y;cin>>w>>h>>x>>y;
	double s = double(w)*double(h)*0.5;
	cout << s << endl;

	bool b = x*2==w && y*2==h;
	cout << (b ? '1' : '0') << endl;
	
	return 0;
}

Measured memory_bytes: 256
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
import math
import queue
#import numpy as np
#import sympy as syp(素因数分解とか)
Mod = 1000000007
import sys

sys.setrecursionlimit(100000) 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

def factorial(i):
    if i == 1:
        return 1
    else:
        return i*factorial(i-1)
 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)




def main(): #startline-------------------------------------------- 
    n = int(input())
    a = list(map(int,input().split()))
    keep = 1
    cnt = 0
    for i in range(n):
        if a[i] == keep:
            cnt += 1
            keep += 1
    print(n - cnt if cnt != 0 else -1)
            



if __name__ == "__main__":
    main() #endline===============================================
    

Measured memory_bytes: 27192
#include <bits/stdc++.h>
using namespace std;
int main () {
  int n;
  cin >> n;

  int count = 0;
  int keta =0;
  int tmp;
  if( n < 9){
    cout << n << endl;
    return 0;
  }else{
    for ( int i = 1; i <= 6; i ++ ){
      tmp = pow(10,i);
      if( tmp > n) {
        keta = i;
        //      cout << keta << endl;
        break;
      }
    }    
  }
  for (int i = 1; i <= keta; i++) { // i 桁目について
    if( i%2 == 1){ // i 桁目が奇数
      if ( i==1 ){
        for(int j = 1; j< 10; j++){ // 1--9
          count++;
          //  cout << j <<endl;
        }
      }else if( i >= 2){
        if( i < keta){
          for( int j = pow(10,i-1); j < pow(10,i); j++){ // 100--999
            count++;
            //cout << j << endl;
          }          
        }else if( i == keta){
          for( int j = pow(10,(i-1)); j<= n; j++){ // 100--
            count++;
            //cout << j << endl;
          } 
        }
      }
    }
  }
  
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define MOD (ll)(1e9+7)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
int gcd(int A,int B) {if(!B)return A;return gcd(B,A%B);}

int main()
{
	int x,y,z;
	cin>>x>>y>>z;
	cout<<z<<" "<<x<<" "<<y;

}


Measured memory_bytes: 256
#include<stdio.h>
void qsort(int list1[],int list2[], int left, int right) {
    int l = left;
    int r = right;
    int pivot = list1[(left + right) / 2]; // 中央からピボットを選択
    int temp;

    while (1) {
        while (list1[l] < pivot) l++;
        while (list1[r] > pivot) r--;

        if (l > r) break;

        // pivotより小さい値を左、大きい値を右に入れ替え
        temp = list1[l];
        list1[l] = list1[r];
        list1[r] = temp;
        
        temp = list2[l];
        list2[l] = list2[r];
        list2[r] = temp;


        l++, r--;
    };

    // pivotより小さい領域と大きい領域をそれぞれ再帰的にソート
    if (left < r)  qsort(list1,list2 ,left, r);
    if (l < right) qsort(list1,list2, l, right);
}

int main(void){
    int N;
    scanf("%d",&N);
    int A[N],B[N];
    for(int i=0;i<N;i++){
        scanf("%d %d",&A[i],&B[i]);
    }
    qsort(B,A,0,N-1);
    int sum = 0;
    for(int i=0;i<N;i++){
        sum += A[i];
        if(sum>B[i]){
            printf("No");
            return 0;
        }

    }
    printf("Yes");
    return 0;
}

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

#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define mod(x) ((x)%MOD)
#define o(X) (1<<(X))
#define oL(X) (1LL<<(X))
#define LL long long
#define ppt(x) __builtin_popcount(x)
using namespace std;
const int INF=0x3f3f3f3f,N=1e6+5,MOD=1e9+7;
const LL INF_LL=0x3f3f3f3f3f3f3f3fLL;

template<typename T>
inline int getplc(T x,int y) { return (x>>y)&1; }
template<typename T>
T square(T x) {return x*x;}

LL qpow(LL a,LL b=MOD-2,LL _MOD=MOD){
	LL res=1;
	for(;b;b>>=1,a=a*a%_MOD){
		if(b&1)res=res*a%_MOD;
	}
	return res;
}

template <typename T>
T Smax(T x) { return x; }
template<typename T, typename... Args>
T Smax(T a, Args... args) {
	return max(a, Smax(args...));
}
template <typename T>
T Smin(T x) { return x; }
template<typename T, typename... Args>
T Smin(T a, Args... args) {
	return min(a, Smin(args...));
}

template <typename T>
#define errorl(args...) {  \
	string _s = #args;   \
	replace(_s.begin(), _s.end(), ',', ' ');  \
    stringstream _ss(_s);  \
    istream_iterator<string> _it(_ss);  \
    errl(_it, args);  \
}
void errl(istream_iterator<string> it) {}
template<typename T, typename... Args>
void errl(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	errl(++it, args...);
}
#define error(args...) {  \
    string _s = #args;  \
    replace(_s.begin(), _s.end(), ',', ' ');  \
    stringstream _ss(_s);  \
    istream_iterator<string> _it(_ss);  \
    err(_it, args);  \
    cerr<<endl; \
}
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << "=" << a << " # ";
	err(++it, args...);
}


string s, t;
void Solve() {
	int len, same = 0;
	cin >> len >> s >> t;
	for (int i = 1; i <= len; i++) {
		if (s.substr(len - i) == t.substr(0, i)) {
			same = i;
		}
	}


	cout << 2 * len - same << endl;
}


int main() {
#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
//  freopen("o1.txt","w",stdout);
#endif
	ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
	Solve();
	return 0;
}


Measured memory_bytes: 3616
N,K = map(int,input().split())
AB = [tuple(map(int,input().split())) for i in range(N-1)]
es = [[] for i in range(N)]
for a,b in AB:
    a,b = a-1,b-1
    es[a].append(b)
    es[b].append(a)

MOD = 10**9+7

fac = [1,1] + [0]*K
finv = [1,1] + [0]*K
inv = [0,1] + [0]*K
for i in range(2,K+2):
    fac[i] = fac[i-1] * i % MOD
    inv[i] = -inv[MOD%i] * (MOD // i) % MOD
    finv[i] = finv[i-1] * inv[i] % MOD

def npr(n,r):
    if n<r: return 0
    return fac[n] * finv[n-r]

ans = K * npr(K-1,len(es[0]))
ans %= MOD

visited = [0]*N
visited[0] = 1
stack = []
for v in es[0]:
    stack.append(v)

while stack:
    v = stack.pop()
    visited[v] = 1
    ans *= npr(K-2, len(es[v])-1)
    ans %= MOD
    for to in es[v]:
        if visited[to]: continue
        stack.append(to)
print(ans%MOD)

Measured memory_bytes: 49624
//#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f_(i,a,b) for (int i=a;i>=b;i--)
#define f(i,a,b) for (int i=a;i<=b;i++)

int n,a,b,c,d;
string s;
int main() {
//	freopen("","r",stdin);
//	freopen("","w",stdout);
//	scanf("%d %d %d %d %d", &n, &a, &b, &c, &d);
	cin>>n>>a>>b>>c>>d>>s;
	for (int i=a;i<max(c,d)-1;i++) {
		if (s[i]==s[i-1]&&s[i]=='#') {
			printf("No");
			return 0;
		}
	}
	if (s[c-1]=='#'||s[d-1]=='#') {
		printf("No");
		return 0;
	}
	if (c<d) {
		printf("Yes");
		return 0;
	}
	for (int i=b-1;i<min(c,d);i++) {
		if (s[i]=='.'&&s[i]==s[i-1]&&s[i]==s[i+1]) {
			printf("Yes");
			return 0;
		}
	}
	printf("No");
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vec> mat;
int main(){
    double h,w,n;
    cin>>h>>w>>n;
    cout<<ceil(n/max(h,w));
}

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

using namespace std;




int main(){
  int a;
  int p;
  
  cin>>a>>p;
  
  int cullet=a*3;
  
  int applepie=(p+cullet)/2;
  cout<<applepie<<endl;
  return 0;
  }

Measured memory_bytes: 256
n,m = map(int,input().split())
city = []
num = [0] * n
for i in range(m):
    city.append(list(map(int,input().split())))
for i in range(m):
    for j in range(2):
            num[city[i][j] - 1] += 1
for i in num:
    print(i)

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

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

sort(a.begin(),a.end());
  vector<int> v(1000005,0);
  for(ll x:a){
    if(v[x]!=0){
      v[x]=2;
  //    cout<<x<<"x"<<endl;
      continue;
    }
    else{
      for(ll i=x;i<1000005;i+=x){
        v[i]++;
  //      cout<<i<<"i"<<endl;
      }
    }
  }
  ll ans=0;
  for(ll x:a){
    if(v[x]==1) {
      ans++;
  //  cout<<x<<endl;
  }
  }
  cout<<ans;
}


Measured memory_bytes: 7996
n = int(input())
h = list(map(int, input().split()))

cnt = [float('inf')] * n
cnt[0], cnt[1] = 0, abs(h[0] - h[1])
for i in range(2, n):
    cnt[i] = min(abs(h[i - 1] - h[i]) + cnt[i - 1], abs(h[i - 2] - h[i]) + cnt[i - 2])

print(cnt[n - 1])


Measured memory_bytes: 84756
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextFloat64() float64 {
	sc.Scan()
	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

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

func abs(x int) int {
	if x < 0 {
		return -1 * x
	} else {
		return x
	}
}

func max(x, y int) int {
	if x > y {
		return x
	} else {
		return y
	}
}

func main() {
	sc.Split(bufio.ScanWords)
	r, c, k := nextInt(), nextInt(), nextInt()

	point := make(map[int]map[int]int)

	for i := 0; i < k; i++ {
		rs, cs, vs := nextInt(), nextInt(), nextInt()

		rs -= 1
		cs -= 1

		if point[rs] == nil {
			tmp := map[int]int{}
			tmp[cs] = vs
			point[rs] = tmp
		} else {
			point[rs][cs] = vs
		}
	}

	dp := make([][][4]int, r+1)
	for i := 0; i < r+1; i++ {
		dp[i] = make([][4]int, c+1)
	}
	dp[0][0][1] = point[0][0]

	for i := 0; i < r; i++ {
		for j := 0; j < c; j++ {
			for p := 0; p < 4; p++ {
				dp[i][j+1][p] = max(dp[i][j+1][p], dp[i][j][p])
				dp[i+1][j][0] = max(dp[i+1][j][0], dp[i][j][p])
				dp[i+1][j][1] = max(dp[i+1][j][1], dp[i][j][p]+point[i+1][j])
				if p+1 < 4 {
					dp[i][j+1][p+1] = max(dp[i][j+1][p+1], dp[i][j][p]+point[i][j+1])
				}
			}
		}
	}

	ans := 0
	for k := 0; k < 4; k++ {
		ans = max(ans, dp[r-1][c-1][k])
	}
	fmt.Println(ans)
}


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


int main() {
	long long k;
	cin >> k;
	vector<long long> a;
	queue<long long> que;
	long long count=0;
	for(long long i=1;i<=9;i++){
		a.push_back(i);
		que.push(i);
		count++;
	}
	while(count<=k){
		long long v=que.front();
		que.pop();
		if(v%10!=0){
			a.push_back(v*10+v%10-1);
		    que.push(v*10+v%10-1);
		    count++;
		}
		a.push_back(v*10+v%10);
	    que.push(v*10+v%10);
		count++;
		if(v%10!=9){
			a.push_back(v*10+v%10+1);
		    que.push(v*10+v%10+1);
		    count++;
		}
	}
	sort(a.begin(),a.end());
	cout << a[k-1] << endl;
}


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

using namespace std;

using ll = long long;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

template<typename T>
struct edge {
    int src, to;
    T cost;

    // to, costで初期化
    edge (int to, T cost) : src(-1), to(to), cost(cost) {}

    // src, to, costで初期化
    edge (int src, int to, T cost) : src(src), to(to), cost(cost) {}

    // toにxを代入？
    edge &operator=(const int &x) {
        to = x;
        return *this;
    }
    
    // edge()でtoを返す？
    operator int() const {return to;}
};

// templates
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<Edges<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

bool nega = false;

template< typename T >
vector< T > bellman_ford(Edges< T > &edges, int V, int s) {
  const auto INF = numeric_limits< T >::max();
  vector< T > dist(V, INF);
  dist[s] = 0;
  for(int i = 0; i < V - 1; i++) {
    for(auto &e : edges) {
      if(dist[e.src] == INF) continue;
      dist[e.to] = min(dist[e.to], dist[e.src] + e.cost);
    }
  }
  vector<bool> negative(V, false);
  for(int i=0;i<V;++i) {
    for(auto &e : edges) {
      if(dist[e.src] == INF) continue;
      if(dist[e.src] + e.cost < dist[e.to] || negative[e.src]) negative[e.to] = true;
    }
  }
  nega = negative[V-1];
  return dist;
}

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);

  int n, m; cin >> n >> m;
  Edges<ll> edges;
  for(int i=0;i<m;++i) {
    ll a, b, c; cin >> a >> b >> c;
    a--; b--;
    edges.push_back(edge<ll>(a, b, -c));
  }

  vector<ll> dist = bellman_ford<ll>(edges, n, 0);
  
  if(nega) {
    cout << "inf" << endl;
  } else {
    cout << -dist[n-1] << endl;
  }

}


Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        n:usize,
        s:usize,
        a:[u64;n],
    }
    let modulus = 998244353u64;
    let mut dp = vec![vec![0u64; s + 1]; n + 1];
    dp[0][0] = 1;
    for i in 0..n {
        for j in 0..=s {
            dp[i + 1][j] += 2 * dp[i][j];
            dp[i + 1][j] %= modulus;
            if j + a[i] as usize <= s {
                dp[i + 1][j + a[i] as usize] += dp[i][j];
                dp[i + 1][j + a[i] as usize] %= modulus;
            }
        }
    }

    println!("{}", dp[n][s])
}


Measured memory_bytes: 72456
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long;
//#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<V<T>>;
#define fi first
#define se second
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1), EPS = 1e-10;
const ll MOD = 1e9+7;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,m;
  cin >> n >> m;
  if(n>=13) cout << m;
  else if(n >=6) cout << m/2;
  else cout << 0;
  cout << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;

int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);

    vector<pair<int,int> > z;
    int i;
    int lmax=-INF;
    int r_lmax=0;
    for(i=0; i<n; i++) {
        int l,r;
        scanf("%d%d", &l, &r);
        if(lmax<l) {
            lmax=l;
            r_lmax=r;
        }
        z.push_back(make_pair(r,l));
    }
    sort(z.begin(), z.end());

    int anstmp=0;
    {
        vector<int> slmax0(n),slmax1(n),srmin0(n),srmin1(n);
        for(i=0; i<n; i++) {
            if(i==0) slmax0[i]=z[i].second;
            else slmax0[i]=MAX(slmax0[i-1],z[i].second);

            if(i==0) srmin0[i]=z[i].first;
            else srmin0[i]=MIN(srmin0[i-1],z[i].first);
        }
        for(i=n-1; i>=0; i--) {
            if(i==n-1) slmax1[i]=z[i].second;
            else slmax1[i]=MAX(slmax1[i+1],z[i].second);

            if(i==n-1) srmin1[i]=z[i].first;
            else srmin1[i]=MIN(srmin1[i+1],z[i].first);
        }
        for(i=0; i<n; i++) {
            int anss=MAX(0, z[i].first-z[i].second+1);
            int slmax=-INF, srmin=INF;
            if(i>0) {
                slmax=MAX(slmax,slmax0[i-1]);
                srmin=MIN(srmin,srmin0[i-1]);
            }
            if(i<n-1) {
                slmax=MAX(slmax,slmax1[i+1]);
                srmin=MIN(srmin,srmin1[i+1]);
            }
            anss += MAX(0, srmin-slmax+1);
            //printf("%d\n", anss);
            anstmp=MAX(anstmp,anss);
        }
    }

    int ans=0;
    int lmax0=-INF;
    int rmin0=INF;
    for(i=0; i<n-1; i++) {
        int r=z[i].first;
        int l=z[i].second;
        if(r==r_lmax) break;

        lmax0=MAX(lmax0,l);
        rmin0=MIN(rmin0,r);
        if(lmax0>rmin0) {
            break;
        }
        int ans0=(rmin0-lmax0+1);
        int rnext=z[i+1].first;
        int ans1=(rnext-lmax+1);
        ans=MAX(ans, ans0+ans1);
    }
    printf("%d\n", MAX(anstmp,ans));

    return 0;
}



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

using namespace std;

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

#define X first
#define Y second

const int N=1e5+10;


int main(){
    int n,m;
    cin>>n>>m;
    if (n%3==0||m%3==0) cout<<0;
    else {
        ll ans=min(n,m);
        for(int len=1;len<=n;len++) {
            ll p1=1LL*len*m,p2=1LL*(n-len)*(m/2),p3=1LL*(n-len)*m-p2;
            ans=min(ans,max(max(abs(p1-p2),abs(p2-p3)),abs(p3-p1)));
        }
        for(int len=1;len<=m;len++) {
            ll p1=1LL*len*n,p2=1LL*(m-len)*(n/2),p3=1LL*(m-len)*n-p2;
            ans=min(ans,max(max(abs(p1-p2),abs(p2-p3)),abs(p3-p1)));
        }
        cout<<ans;
    }
}


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

const ll MAX = 200000;
const ll INF = 1001001001;
const ll MOD = 1000000007;
const double PI=3.1415926535897932;

ll N, ans=0, tmp=1;
vector<ll> A;

signed main(){
    cin >> N;
    for(int i=0;i<N;i++) {
        ll a;
        cin >> a;
        A.push_back(a);
    }
    for(int i=0;i<N;i++) {
        if(A[i]==tmp&&i!=0) {
            tmp++;
            continue;
        }
        ans += (A[i]-1)/tmp;
        if(i==0) tmp++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4264
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
  int a, b, ab; cin >> a >> b >> ab;
  int x, y;     cin >> x >> y;
  int cost = 0;
  int nab = min(x, y);
  if (a + b < 2 * ab)
    cost += nab * (a + b);
  else
    cost += nab * (2 * ab);
  x -= nab; y -= nab;
  if (x != 0)
  {
    if (a < 2*ab)
      cost += a * x;
    else
      cost += 2 * ab * x;
  }
  else
  {
    if (b < 2*ab)
      cost += b * y;
    else
      cost += 2 * ab * y;
  }
  cout << cost << endl;
}

Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <math.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

//INT_MAX	2,147,483,647 = 2*1.0e9

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

  int a[4];
  for(int i= 0; i < 4; i++){
    a[i] = stoi(S.substr(i,1));
  }

  int n = 3;

  bool op[3];
  int mask;
  for(mask = 0; mask < (1<<n); mask++){
    int sum = a[0];
    for(int i = 0; i < n; i++){
      if(mask & (1<<i)){
        sum += a[i+1];
        op[i] = true;
      }
      else{
        sum-= a[i+1];
        op[i] = false;
      }
    }
    if(sum == 7){
      break;
    }
  }

  cout << a[0];
  for(int i = 0 ; i < n; i++){
    cout << (op[i] ? "+" : "-") << a[i+1];
  }
  cout << "=7" << endl;


  return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main()
{

    int a = 0;
    int b = 0;
    int c = 0;
    int d = 0;
    char A[4];
    int n;

    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%s", A);
        if (A[0] == 'A')
            a++;
        else if (A[0] == 'W')
            b++;
        else if (A[0] == 'T')
            c++;
        else if (A[0] == 'R')
            d++;
    }

    printf("AC x %d\n", a);
    printf("WA x %d\n", b);
    printf("TLE x %d\n", c);
    printf("RE x %d\n", d);

  
}

Measured memory_bytes: 2152
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb push_back
#define ld long double
#define f first
#define s second
#define in insert
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e18 + 5;
const int mod = 1e9 + 7;
const int  N = 2e5 + 314;
const long double pi = 3.1415926535897932384626433832795;
void solve(){
	int sx, sy, tx, ty;
	cin>>sx>>sy>>tx>>ty;
	int x = sx, y = sy;
	while(y<ty){
		cout<<'U';
		y++;
	}
	while(x<tx)
	{
		cout<<'R';
		x++;
	}
	while(y>sy){
		cout<<'D';
		y--;
	}
	while(x>=sx)
	{
		cout<<'L';
	 	x--;
	}
	while(y<=ty)
	{
		cout<<'U';
		y++;
	}
	while(x<tx)
	{
		cout<<'R';
		x++;
	}
	y--;
	cout<<'D';
	x++;
	cout<<'R';
	while(y>=sy)
	{
		cout<<'D';
		y--;
	}
	while(x>sx)
	{
		cout<<'L';
		x--;
	}
	cout<<'U';
}
signed main(){
	speed;
	int t=1;
	//cin>>t;
	while(t--)solve();
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
const int mod = 1e9+7;
const int mx = INT_MAX;
const long double pi = 4*atan((long double)1);
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
#define file "orz"
ll pref[1005];
vector<ll> v;
int main()
{
	//freopen(file".inp","r",stdin);
	//freopen(file".out","w",stdout);
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	ll n,k;
	cin>>n>>k;
	for(ll i=1;i<=n;i++)
	{
		cin>>pref[i];
		pref[i] += pref[i-1];
	}
	for(ll i=0;i<=n;i++)
		for(ll j=i+1;j<=n;j++)
			v.eb(pref[j]-pref[i]);
	ll ans = 0;
	for(ll i=40;i>=0;i--)
	{
//		cout<<ans<<endl; 
		ll c = 0;
		for(auto j:v)
		{
			ll x = ans&j;
			if(x == ans)
			{
				if(j & (1LL<<i))
					c++;
			}
		}
		if(c>=k)
		{
//			cout<<c<<" "<<k<<endl;
//			cout<<c<<" "<<k<<endl;		 
			ans = ans^(1LL<<i);
		}	
	}
	cout<<ans;
}


Measured memory_bytes: 5872
import java.util.Scanner;

public class Main {

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

    void compute() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int counst = 0;
        boolean[] exists = new boolean[8];
        for (int i = 0; i < N; i++) {
            int a = sc.nextInt();
            if (a < 3200) {
                exists[a / 400] = true;
            } else {
                counst++;
            }
        }
        int nkinds = 0;
        for (int i = 0; i < 8; i++) {
            if (exists[i]) {
                nkinds++;
            }
        }
        if (counst != 0) {
            System.out.println(Math.max(1, nkinds) + " " + (nkinds + counst));
        } else {
            System.out.println(nkinds + " " + nkinds);
        }
    }
}


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

int main(){
	int a;
	cin>>a;
	int b,c;
	cin>>b>>c;
	int e=0;
	for(int i=0;i<a;i++){
		int d[100];
		cin>>d[i];
		for(int j=0;j<100;j++){
			if(d[i]*j+1<=b){
				e++;
			}
		}
	}
	cout<<e+c<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#define MAX_NUM 100
using namespace std;

char grid[MAX_NUM][MAX_NUM];

int main() {
    int H, W;
    cin >> H >> W;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) cin >> grid[i][j];
    }
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) cout << grid[i][j];
        cout << endl;
        for (int j = 0; j < W; j++) cout << grid[i][j];
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#include <numeric>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[8]={ 0, 1, 0,-1, 1, 1,-1,-1}; // x軸方向への変位
ll dy[8]={ 1, 0,-1, 0, 1,-1, 1,-1}; // y軸方向への変位

int main(void){
    ll n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    ll ans = 1;
    ll INF = 1e+9+7;
    for(ll i = 0; i < n; i++){
        if(i==0 && s[i]==t[i]) ans*=3;
        else if(i==0 && s[i]!=t[i]) {
            ans*=6; i++;
        }
        else if(s[i]==t[i] && s[i-1]==t[i-1])
            ans *= 2;
        else if(s[i]!=t[i] && s[i-1]!=t[i-1]){
            ans*=3; i++;
        }
        else if(s[i]!=t[i] && s[i-1]==t[i-1]){
            ans*=2; i++;
        }
        ans%=INF;
        //cout << i << " " << ans << endl;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define INF 110000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,int> P;

int main(){
  ll ans=0;
  ll N,minA=INF,temp,count=0;
  cin>>N;

  for(int i=0;i<N;i++){
    cin>>temp;
    if(temp<0){
      count++;
      temp*=-1;
    }
    ans+=temp;
    minA=min(minA,temp);
  }
  if(count%2!=0) ans-=minA*2;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
def main():
    n, m = map(int, input().split())
    sss = []
    ccc = []
    for _ in range(m):
        s, c = map(int, input().split())
        if s in sss:
            idx = sss.index(s)
            if ccc[idx] != c:
                print(-1)
                return
        else:
            sss.append(s)
            ccc.append(c)
        # temp_dubs = []
        # if s in sss:
        #     temp_dubs = [i for i, x in enumerate(sss) if x == s]
        # for td in temp_dubs:
        #     if ccc[td] != c:
        #         print(-1)
        #         return
        # sss.append(s)
        # ccc.append(c)
    if n == 1:
        start = 0
    else:
        start = 10 ** (n-1)

    for i in range(start, 10 ** (n+1)):
        i_list = list(map(int, list(str(i))))
        break_flag = False
        for j, s in enumerate(sss):
            idx = s - 1
            str_i_temp = i_list[idx]
            if str_i_temp != ccc[j]:
                break_flag = True
                break
        if break_flag:
            continue
        else:
            print(i)
            return

    print(-1)


if __name__ == '__main__':
    main()


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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; i++)cin >> v[i];

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

    cout << v[n / 2] - v[n / 2 - 1] << endl;
    return 0;
}

Measured memory_bytes: 768
#include <algorithm>//min/max/sort(rand-access it)/merge
#include <array>
#include <bitset>
// #include <chrono>//std::chrono::/system_clock/steady_clock/high_resolution_clock/duration
#include <climits>//INT_MAX/INT_MIN/ULLONG_MAX
#include <cmath>//fmin/fmax/fabs/sin(h)/cos(h)/tan(h)/exp/log/pow/sqrt/cbrt/ceil/floor/round/trunc
#include <cstdlib>//abs/atof/atoi/atol/atoll/strtod/strtof/..., srand/rand, calloc/malloc, exit, qsort
// #include <fstream>//ifstream/ofstream
#include <iomanip>//setfill/setw/setprecision/fixed/scientific
#include <iostream>//cin/cout/wcin/wcout/left/right/internal/dec/hex/oct/fixed/scientific
#include <iterator>
#include <limits>//numeric_limits<type>::max/min/lowest/epsilon/infinity/quiet_NaN/signaling_NaN
#include <list>
#include <queue>
#include <string>//stoi/stol/stoul/stoll/stoull/stof/stod/stold/to_string/getline
#include <tuple>
#include <utility>//pair
#include <valarray>
#include <vector>
 
#define PRIME_SHORT 10007
#define PRIME 1000000007
 
using namespace std;
 
typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> plli;
typedef pair<ull, int> puli;
typedef pair<double, int> pdi;
typedef pair<ll, ll> pllll;
typedef pair<ull, ull> pulul;
typedef pair<double, double> pdd;
typedef tuple<int, int, int> ti3;
typedef tuple<int, int, int, int> ti4;
 
const bool debug = false;
 
void rar(int n, int* a);
void rar2(int n, int m, int** a);
 
int ipow(int base, int exp);
int left(int current, bool swap);
int right(int current, bool swap);
int griddist(int x, int y, int s, int t);
int griddist(pii one, pii two);
double sqeucldist(double x, double y, double s, double t);
double sqeucldist(pii one, pii two);
ull modadd(ull a, ull b, int mod);
ull modmult(ull a, ull b, int mod);
 
int main(void) {
    size_t m, n, x;
    cin >> m >> x;
    n = 2*m-1;
    if (x != 1 && x != n)
    {
        cout << "Yes\n";
        size_t *row = new size_t[n];
        size_t pos = m-1;
        row[pos] = x;
        //pos+pos = 2*(m-1) = 2*m-2 = n-1
        for (size_t i = 1; i <= pos; ++i)
        {
            size_t next_up = x+i>n ? x+i-n : x+i;
            size_t next_down = i>=x ? n-i+x : x-i;
            row[pos+i] = (i%2 ? next_up : next_down);
            row[pos-i] = (i%2 ? next_down : next_up);
        }
        for (size_t i = 0; i < n; ++i) cout << row[i] << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3072
#include<stdio.h>
int main(){
  int i,j,n,b,num=0;
  scanf("%d",&n);
  if(n<1||n>100)return 0;
  int a[n];
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  if(a[i]<0||a[i]>100)return 0;
  }
  int flag=1;
  while(flag){
    flag=0;
    for(j=n-1;j>0;j--){
      if(a[j]<a[j-1]){
	b=a[j];
	a[j]=a[j-1];
	a[j-1]=b;
	flag=1;
	num++;
      }
    }
  }
  for(i=0;i<n;i++){
    if(i==n-1)printf("%d\n",a[i]);
    else printf("%d ",a[i]);
  }
  printf("%d\n",num);
  return 0;
}



Measured memory_bytes: 2140
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    dead_code
)]
//use permutohedron::LexicalPermutation as _;
use proconio::input;
//use proconio::marker::Chars;
//use proconio::marker::Usize1;
//use std::collections::HashSet;
//use std::collections::HashMap;
//use std::collections::BTreeMap;
//use std::cmp::*;
//use std::num;

fn main() {
    input! {
        A:i32,B:i32
    }
    for x in 10..=11000 {
        if x * 8 / 100 == A && x / 10 == B {
            println!("{}", x);
            return;
        }
    }
    println!("-1");
}


Measured memory_bytes: 2136
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <bitset>

using namespace std;
typedef long long int ll;



int main() {
	ll n,a,b,c,d,e;
	vector<ll> X(5);
	cin>>n>>X.at(0)>>X.at(1)>>X.at(2)>>X.at(3)>>X.at(4);
	ll m = *min_element(X.begin(),X.end());
	
	cout << (n-1)/m + 5 << endl;
}


Measured memory_bytes: 256
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
a=[[] for i in range(n)]
for i in range(n):
    a[i]=list(map(int,input().split()))
#print(a,b,c)
def judge(x,y,z):
    rt=0
    for i in range(len(x)):
        rt+=x[i]*y[i]
    return rt+z
ans=0
for i in range(n):
    jj=judge(a[i],b,c)
    #print(jj)
    if jj>0:
        ans+=1
print(ans)

Measured memory_bytes: 3192
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int n;
    int sum=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        sum+=800;
        if(i%15==0)sum-=200;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<string.h>
#include<queue>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<cstdlib>
#include<math.h>
#include<set>
#include<array>
using namespace std;

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; }



#define rep(n) for(int i=0;i<n;i++)
typedef pair<int, int> pii;

typedef long long ll;
typedef pair<ll, ll>pll;
const int MOD = 1000000007;
const int INF = 1 << 29;
const long long INFl = 1LL << 60;




int main() {
	long long h[110000];



    long long dp[110000];
	int n, k; 
	
	cin >> n >> k;
	for (int i = 0; i < n; ++i) cin >> h[i];

	
	for (int i = 0; i < 110000; ++i) dp[i] = INFl;

	
	dp[0] = 0;

	
	for (int i = 0; i < n; ++i) {
		for (int j = 1; j <= k; ++j) {
			chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
		}
	}

	
	cout << dp[n - 1] << endl;
	return 0;
}





Measured memory_bytes: 1920
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;i<=n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
#define prique priority_queue<ll>
#define ALL(a)  (a).begin(),(a).end()
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int n, int r) {
	int ans = 1;
	for (ll i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
int per(int n, int r) {
	r = n - r;
	int sum = 1;
	int i;
	for (i = n; i >= r + 1; i--)sum *= i;
	return sum;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};

int ctoi(const char c) {
	return c - '0';
}
int keta(int a) {
	return to_string(a).size();
}
double a[200010],b[200010];
signed main() {
	int n, m;
	cin >> n >> m;
	Rep(i, n) {
		cin >> a[i];
	}
	double ans = 0.0;
	b[0] = 0.0;
	Rep(i, n) {
		b[i]=b[i-1]+(a[i] * (a[i] + (double)1.0)) / ((double)2.0 * a[i]);
	}
	Rep(i, n) {
		if (i - m >= 0 && b[i] - b[i - m] > ans) {
			ans = b[i] - b[i - m];
		}
	}
	cout << fixed << setprecision(10) << ans << endl;
}


Measured memory_bytes: 6528
#include <iostream>
#include <algorithm>
#include <cmath>
#include <climits>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <unordered_map>
using namespace std;

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


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

int main() {
  long N;
  cin>>N;
  vector<long> a(N);

  for(int i=0;i<N;i++) cin>>a[i];
  //sort(a.begin(),a.end());
  //reverse(a.begin(),a.end());
  long ans=0;
  for(int i=0;i<N;i++){
    if(i%2==0&&a[i]%2==1) ans++;
  }
  cout<<ans<<endl;
  }


Measured memory_bytes: 3592
L, R = map(int, input().split(' '))

if R - L >= 2018:
    print(0)
else:
    min_value = 2018
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            min_value = min(min_value, i * j % 2019)
    print(min_value)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main() {
  int a[5];
  rep(i,5)cin>>a[i];
  int b;cin>>b;
  rep(i,4){
    for(int o=i+1;o<5;o++){
      int c=fabs(a[i]-a[o]);
      if(c>b){
        cout<<":(";
        return 0;
      }
    }
  }
  cout<<"Yay!";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define PI 3.141592653589
#define ll long long
using namespace std;

int N, M;
vector<int> s,c;

bool ok(string str){
  if(str.size() != N) return false;
  for(int i=0; i<M; ++i) if(str[s[i]] != (char)(c[i] + '0')) return false;
  return true;
}

string solve(){
  for(int i=0; i <= 999; ++i){
    stringstream iss; iss<< i;
    string str = iss.str();
    if(ok(str)) return str;
  }
  return "-1";
}


int main(){
  cin >> N >> M;
  s.resize(M); c.resize(M);
  for(int i=0; i<M; ++i) cin >> s[i] >> c[i], --s[i];
  cout << solve() << endl;
}
 

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#define reg register
using namespace std;
typedef long long ll;
const int MN=1e5+5;
int n,x[MN],y[MN];
char ch[MN];
int main(){
	scanf("%s",ch+1);n=strlen(ch+1);
	if((ch[n]^48)||!(ch[1]^48))return 0*puts("-1");
	for(reg int i=1;i<=(n>>1);i++)if(ch[i]^ch[n-i])return 0*puts("-1");
	reg int pre=1;
	for(reg int i=2;i<=n;i++)if(ch[i]^48)for(;pre<i;pre++)printf("%d %d\n",pre,i);
	printf("%d %d\n",n-1,n);
	return 0;
}

Measured memory_bytes: 1408
#include <bits//stdc++.h>
using namespace std;
#define int long long
#define rep(i,n,k) for(int i=n;i<k;i++)
#define P make_pair
#define F first
#define S second
#define M LLONG_MAX
signed main(void){
    int n,m,ans,w,p,q;
    ans=0;
    string s,s1,s2;
    vector<int> v;
   cin>>n;
   int a[n];
   map<int,int> num;
   rep(i,0,n){
       cin>>p;
       a[i]=p;
       if(num.find(p)==num.end()){
           num[p]=1;
           v.push_back(p);
       }
       else
       num[p]++;
   }
   rep(i,0,v.size()){
       ans+=num[v[i]]*(num[v[i]]-1)/2;
   }
   rep(i,0,n){
       if(num[a[i]]!=1){
           q=num[a[i]];
           cout<<ans-q*(q-1)/2+(q-1)*(q-2)/2<<endl;
       }
       else
       cout<<ans<<endl;
   }
  
}


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

using namespace std;
using ll = long long;
#define int ll

void init();
void solve();

#define rep(i, a) for (int i = 0; i < (int) (a); i++)
#define reps(i, a, b) for (int i = (int) (a); i < (int) (b); i++)
#define rrep(i, a) for (int i = (int) a-1; i >= 0; i--)
#define rreps(i, a, b) for (int i = (int) (a)-1; i >= (int) (b); i--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
#define lcout(a) cout << a
#define lcoutln(a) cout << a << endl
#define lcerr(a) cerr << a
#define lcerrln(a) cerr << a << endl
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif
#define MOD 1000000007
#define PI 3.141592653589793238462643383

signed main()
{
	init();
	solve();
}

int H, W;
vector<vector<int> > v;
vector<pair<int, int> > p;

void init()
{
	cin >> H >> W;
	v.resize(H);
	rep(i, H) {
		vector<int> t(W);
		rep(j, W) {
			cin >> t[j];
		}
		v[i] = t;
	}
	rep(i, H) {
		rep(j, W) {
			p.PB(MP(i, j));
		}
		if (++i >= H) break;
		rrep(j, W) {
			p.PB(MP(i, j));
		}
	}
}

void solve()
{
	vector<pair<int, int> > res;
	rep(i, p.size()-1) {
		if (v[p[i].first][p[i].second] % 2) {
			v[p[i+1].first][p[i+1].second]++;
			res.PB(MP(p[i].first+1, p[i].second+1));
			res.PB(MP(p[i+1].first+1, p[i+1].second+1));
		}
	}
	cout << res.size() / 2 << endl;
	int pos = 0;
	rep(i, res.size() / 2) {
		cout << res[pos].first << " " << res[pos].second << " ";
		pos++;
		cout << res[pos].first << " " << res[pos].second << endl;
		pos++;
	}

}


Measured memory_bytes: 14316
#include <iostream>
using namespace std;
typedef long long ll;
#define MAX_N 100010
const ll R = 1e9 + 7;
 
int n, m, j = 0;
ll dp[MAX_N];

int main() {
    cin >> n >> m;
    int a[m + 1];
    for (int i = 0; i < m; i++) cin >> a[i];
    
    dp[1] = 1, dp[2] = 2;
    for (int i = 1; i <= n; i++) {
        if (i <= 2) dp[i] = dp[i - 1] + 1;
        else dp[i] = (dp[i - 1] + dp[i - 2]) % R;
        if (i == a[j]) { dp[i] = 0; j++;}
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> Pii;

ll A, B, N;

int main() {
    cin >> A >> B >> N;

    ll left = 0, right = N+1;
    while (right - left > 1) {
        ll mid = (left + right) / 2;
        if (mid / B > 0) {
            right = mid;
        }
        else left = mid;
    }

    cout << (left * A)/B - A * (left / B) << endl;
    
    
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
using namespace std;
int main(){
    int N, K;
    cin >> N >> K;
    
    int cnt = 0;
    for(int i = 0; i < N; i++){
       int h;
       cin >> h;
       if(h >= K){
           cnt++;

       }
    }
    cout << cnt << endl;
    return 0;
    }

Measured memory_bytes: 256