akhauriyash/Code-Regression huggingface dataset:
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	n := getNextInt(scanner)
	k := getNextInt(scanner)

	// ぐー
	r := getNextInt(scanner)
	// ちょき
	s := getNextInt(scanner)
	// ぱー
	p := getNextInt(scanner)
	t := getNextString(scanner)

	ans := 0
	win := make([]bool, n)
	for i := 0; i < n; i++ {
		win[i] = true
	}

	for i := n - 1; i >= k; i-- {
		if win[i] && t[i] == t[i-k] {
			win[i-k] = false
		}
	}
	for i := 0; i < n; i++ {
		if win[i] == false {
			continue
		}
		if t[i] == 'r' {
			ans += p
		}
		if t[i] == 's' {
			ans += r
		}
		if t[i] == 'p' {
			ans += s
		}
	}

	fmt.Println(ans)
	writer.Flush()
}


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

#define ll long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rep(i,n) for(int i = 0; i < int(n); i++)

#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a < b ? a : b)
const int MOD = 1000000007;

int D;
string K;
ll DP[10001][2][100];
int l;

ll fun(int pos, int f, int sum) {
    if(pos == l) {
        return sum % D == 0;
    }

    if(DP[pos][f][sum] != -1) return DP[pos][f][sum];

    int LMT = 9;
    if(f == 0) LMT = K[pos] - '0';
    ll ans = 0;

    for(int i = 0; i <= LMT; i++) {
        int tempf = f;
        if(i < LMT) tempf = 1;
        ans = (ans + fun(pos + 1, tempf, (sum + i) % D)) % MOD;
    }
    return DP[pos][f][sum] = ans;
}

int main() {
    IOS;
    memset(DP, -1, sizeof(DP));
    cin >> K >> D;
    l = K.length();
    ll ans = fun(0, 0, 0) - 1;
    if (ans < 0) ans = MOD - 1;
    cout << ans;
    return 0;
}

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

int main()
{
    int a[6];
    char c[100];
    scanf("%d %d %d %d %d %d", &a[0], &a[1], &a[2], &a[3], &a[4], &a[5], &a[6]);
    scanf("%s", c);
    roll(&a, c);
    printf("%d\n", a[0]);
    return 0;
}

void roll(int *a, char s[]) {
    int i, key, temp;
    for(i = 0; i < strlen(s); i++) {
        temp = a[0];
        switch(s[i]) {
            case 'N': key = 1; break;
            case 'W': key = 2; break;
            case 'E': key = 3; break;
            case 'S': key = 4; break;
        }
        a[0] = a[key];
        a[key] = a[5];
        a[5] = a[5-key];
        a[5-key] = temp;
    }
}



Measured memory_bytes: 2104
#include <iostream>
#include <vector>
#include <map> 
#include <algorithm>
#include <string.h>

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

typedef long long int ll;



void pre_process(string p, int *back_table){
    int i = 0, j = -1, length = p.length();
    back_table[0] = -1;

    while(i <= length) { 
        while(j != -1 && p[i] != p[j]) j = back_table[j];
        i++; j++;
        back_table[i] = j;
    }

}

void _search(string p, string t, int *back_table){
    int i = 0, j = 0, length = t.length(), m = p.length();

    while(i <= length){
        while(j != 0 && t[i] != p[j]) j = back_table[j];
        i++; j++;
        if(j == m) { cout << "Pattern at: " << i - j << endl; j = back_table[j]; }
    }
}

int func(int arr[],int n,int m) {
    int maxsum;
    int incl[n];
    int excl[n];
    incl[0] = arr[0];
    excl [0] = 0;
    for(int i=1;i<n;i++) {
        if(i-m-1 >=0) {
            incl[i] = max(incl[i-m-1],excl[i-m-1]) + arr[i];
        }
        else
            incl[i] = arr[i];
        
        excl[i] = max(excl[i-1],incl[i-1]);
        maxsum = max(maxsum,max(incl[i],excl[i]));
    }

    return maxsum;
}

int show(int x, float y){
    return x + y;
}


int show(int x){ return x; }

float fn_(int x = show(2, 3.3)){
    return x;
}

int fn(int x = show(2)){
    return x;
}

int solve(){
    int n, k; 
    cin >> n >> k;
    int a[n];
    for(int i = 0; i < n; i++)
        cin >> a[i];
    sort(a, a + n, greater<int>());
    int ans = 0;
    for(int i = 0; i < k; i++)
        ans += a[i];
    cout << ans;
}


int main() {
    solve();
}



// akasakaakas 
// akasakaakas


// akasakaakasaka

// kesav696@sbi
// kesav1096@sbi








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

using namespace std;

int main() {

	int n;
	cin >> n;

	int a = n % 10;
	if (a == 2 || a == 4 || a == 5 || a == 7 | a == 9)
		cout << "hon";
	else if (a == 0 || a == 1 || a == 6 || a == 8) {
		cout << "pon";
	}
	else {
		cout << "bon";
	}
		
	return 0;
}


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

int main()
{
    int a,b,c; cin >> a >> b >> c;
    int ans = 0;
    ans = (c - (a-b));

    if(ans <= 0) cout << 0 << endl;
    else cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
///
// File:  alds1_11_a.cpp
// Author: ymiyamoto
//
// Created on Wed Oct 18 00:12:34 2017
//

#include <cstdint>
#include <iostream>

using namespace std;

static uint32_t graph[100][100];

int32_t main()
{
  uint32_t n;
  cin >> n;

  for (uint32_t i = 0; i < n; i++) {
    uint32_t id, k;
    cin >> id >> k;
    for (uint32_t j = 0; j < k; j++) {
      uint32_t v;
      cin >> v;
      graph[id - 1][v - 1] = 1;
    }
  }

  for (uint32_t i = 0; i < n; i++) {
    for (uint32_t j = 0; j < n; j++) {
      if (j != 0) cout << " ";
      cout << graph[i][j];
    }
    cout << endl;
  }

  return 0;
}

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

#define rr(i, b)    for (int i = 0; i < int(b); i++)
#define vi(n, a) vector <int> a(n); rr(i, n) cin >> a[i]
#define pvec(a) rr(i, a.size()) cout << a[i] << " "; cout << endl
#define bug(x) cout << #x << " " << x << endl
#define ll long long
#define vii vector <int>

using namespace std;

bool check(string s) {

    int l = 0;
    int r = s.size()/2;

    while(r != s.size()) {
        if(s[l] != s[r]) {
            return false;
        }
        l++;
        r++;
    }

    return true;
}

void solve() {
    int n;
    cin >> n;
    string s;
    cin >> s;

    if(n % 2 != 0) {
        cout << "No" << endl;
    }
    else {
        if(check(s)) cout << "Yes" << endl;
        else cout << "No" << endl;
    } 

    //cout << a[0]<< b[1] << c[2] << endl;
}
 
int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 3640
import java.util.*;
public class Main{
	public static void unite(Node x, Node y){
		leader(y).parent = leader(x);
	}
	public static Node leader(Node x){
		if(x.parent == x)
			return x;
		else
			return x.parent = leader(x.parent);
	}
	public static int same(Node x, Node y){
		if(leader(x) == leader(y))
			return 1;
		else
			return 0;
	}
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int q = sc.nextInt();
		Node[] nodes = new Node[n];
		for(int i = 0 ; i < n ; i++)
			nodes[i] = new Node(i,true);
		for(int i = 0 ; i < q ; i++){
			int com = sc.nextInt();
			int x = sc.nextInt();
			int y = sc.nextInt();
			switch(com){
				case 0: unite(nodes[x],nodes[y]); break;
				case 1: System.out.println(same(nodes[x],nodes[y])); break;
			}
		}
	}
}
class Node{
	int isRoot;
	int data;
	Node parent = this;
	Node(int data, boolean isroot){
		this.data = data;
		if(isroot)
			isRoot = 1;
		else
			isRoot = 0;
	}
}


Measured memory_bytes: 101676
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
#include <stack>
using namespace std;

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


int main() {
	int n;
	cin >> n;
	int T[n+1];
	int X[n+1];
	int Y[n+1];
	T[0] = 0;
	X[0] = 0;
	Y[0] = 0;
	for (int i=1; i<=n; i++) {
		cin >> T[i] >> X[i] >> Y[i];
	}

	for (int i=0; i<n; i++) {
		int dt = T[i+1] - T[i];
		int ds = abs(X[i+1] - X[i]) + abs(Y[i+1] - Y[i]);
		if (ds > dt or dt%2!=ds%2) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 1408
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
using namespace std;
typedef long long LL;
const int MaxN = 1e5;
const int Inf = 1 << 30;

int main()
{
	int a[3];
	while(~scanf("%d %d %d",a,a + 1,a + 2)){
		sort(a,a + 3);
		if(a[0] == 5 && a[1] == 5 && a[2] == 7) printf("YES\n");
		else printf("NO\n");
	}
    return 0;
}

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

string solve() {
    ll N;
    string S;
    cin >> N >> S;
    ll l = 0, p = 0;
    for ( char c : S ) {
        if ( c == '(' ) p++;
        else p--;
        l = min(l, p);
    }
    l = -l;
    string ans = "";
    for ( int i = 0; i < l; i++ ) {
        ans.append("(");
    }
    ans.append(S);
    for ( int i = 0; i < l + p; i++ ) {
        ans.append(")");
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#define first f
#define second s
#define ll long long
#define mp make_pair
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#include <bits/stdc++.h>
#define pii pair<int,int>
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
const int maxn=2e5+5;
const double PI=acos(-1);
const double e=2.718281828459;

map<string,int>MP;
string s[maxn];
set<string>S;

int main()
{
    int n,mx=-1;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        cin>>s[i];
        MP[s[i]]++;
        S.insert(s[i]);
        mx=max(mx,MP[s[i]]);
    }
    for(auto it=S.begin();it!=S.end();it++){
        if(MP[*it]==mx){
            cout<<*it<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 36992
#include<iostream>

using namespace std;

int main(void){
    int i, j;
    cin >> i >> j;
    if (abs(i - j) >= 2){
        cout << (i < j ? j*2 - 1 : i*2 - 1) << endl;
    }
    else{
        cout << i + j <<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int w,h,i,j;
	char a;
	char hata[30][30];
	
	cin>>w>>h>>a;
	
	for(i=1;i<w-1;i++){
		for(j=1;j<h-1;j++){
			hata[j][i]='.';
		}
	}
	for(i=0;i<w;i++){
		hata[0][i]='-';
		hata[h-1][i]='-';
	}
	for(i=0;i<h;i++){
		hata[i][0]='|';
		hata[i][w-1]='|';
	}
	hata[0][0]='+';
	hata[0][w-1]='+';
	hata[h-1][0]='+';
	hata[h-1][w-1]='+';
	hata[h/2][w/2]=a;
	
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			cout<<hata[i][j];
		}
		cout<<endl;
	}
	
		
	return 0;
}


Measured memory_bytes: 3132
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#define int  long long int
	#define pb push_back
	#define fe first
    #define lb lower_bound 
    #define ub upper_bound
    #define pii pair<pair<int,int>,pair<int,int> >
	#define se second
	#define endl "\n"
	#define pi pair<int, int>
	#define vi vector<int> 
	#define vvi vector<vi>
    #define bs   binary_search
	#define rep(i,a,b) for(int i=a;i<b;i++)
	#define rep1(i,a,b) for(int i=a;i<=b;i++)	
    #define all(c) (c).begin(),(c).end()
    #define sz(x)       (int)x.size() 
	#define PI 3.14159265358979323846
    
	 const int N =3e5+5;
    
     int mod= 1e9+7,INF=1e17;
     
     int dx[4]={0,0,+1,-1};
     int dy[4]={+1,-1,0,0};
     
     
     vi v[N];
     int d[N],vis[N];
     int l,r;
     
     void bfs(int x){
		 queue<int >q;
		 q.push(x);
		 vis[x]=1;
		 
		 while(!q.empty()){
			   int nv=q.front();
			   q.pop();
			   
			   for(auto to:v[nv]){
				   
				   if(!vis[to]){
					   
					   d[to]=d[nv]+1;
					   vis[to]=1;
					   q.push(to);
				   }
			   }		
			}		 
	 }
    
     
     void solve(){
	   int n,m;
	   cin>>n>>m;
	   
	   rep(i,0,m){
		   
		   int x,y;
		   cin>>x>>y;
		   
		   v[x].pb(y+n);
		   v[x+n].pb(y+2*n);
		   v[x+2*n].pb(y);
	   }
	   

	   cin>>l>>r;
	   
	   bfs(l);   
	   
	   if(d[r]!=0 && d[r]%3==0)
	     cout<<d[r]/3<<endl;
	  else
	    cout<<-1;   
	 
	 }
	
      int32_t main() {
	    cool;
	    int t=1;
        //cin>>t;
	    while(t--)
	       solve();
	       
	       
	       return 0;	   
	   }


Measured memory_bytes: 21376
module Main where

import Control.Applicative
import Control.Monad
import Data.List

main :: IO ()
main = do
    n <- readLn
    ws <- replicateM n getLine
    let f (as, bss) =
            if (last as == (head $ head bss)) && as `notElem` bss
            then True
            else False
    let p = all f (zip ws (init . tail $ tails ws))
    if p
        then putStrLn "Yes"
        else putStrLn "No"

Measured memory_bytes: 636
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

int main(){
  int N;
  vector<pair<int, int> > v;
  cin >> N;
  for (int i = 1; i <= N; i++){
    int num;
    cin >> num;
    v.push_back(make_pair(num, i));
  }

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

  for (int i = 0; i < N; i++){
    printf("%d ", v[i].second);
  }
  printf("\n");
  
}


Measured memory_bytes: 4232
import sys

# sys.stdin = open('a1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    x, t = read_int_list()
    res = x - t
    if res > 0:
        print(res)
    else:
        print('0')


main()


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <stack>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <map>

using namespace std;

typedef pair<int,int> pii;

main(){
    int extra = 0;
    int arr[8];
    for(int i=0;i<8;++i) arr[i] = 0;
    int numbers; cin >> numbers;
    int num;
    while(numbers--){
       cin >> num;
       if(num<=399) arr[0] += 1;
       else if(num<=799) arr[1] += 1;
       else if(num<=1199) arr[2] += 1;
       else if(num<=1599) arr[3] += 1;
       else if(num<=1999) arr[4] += 1;
       else if(num<=2399) arr[5] += 1;
       else if(num<=2799) arr[6] += 1;
       else if(num<=3199) arr[7] += 1;
       else extra++;
    }
    int total = 0;
    bool totalC = true;
    for(int i=0;i<8;++i){
        if(arr[i]!=0) {total++;totalC=false;}
    }
    if(totalC) cout << 1 << " " << extra << endl;
    else cout << total << " " << total+extra << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int N;
  cin >> N;
  ll a[N];
  for(int i=0;i<N;i++) cin >> a[i];
  sort(a,a+N);

  if(N % 2 == 0){
    ll ans = 0LL;
    int l = 0;
    int r = N - 1;
    while(l < N / 2 - 1){
      ans += a[r] - a[l];
      ans += a[r - 1] - a[l];
      l++;
      r--;
    }
    ans += a[N - 1] - a[N / 2 - 1];
    cout << ans << endl;
  }
  else{
    ll ans = 0LL;
    for(int i=0;i<N/2;i++){
      ans += 2 * (i + 1) * (a[i+1] - a[i]);
      ans += 2 * (i + 1) * (a[N-1-i] - a[N-1-i-1]);
    }

    int b = min(a[N/2] - a[N/2-1] , a[N/2+1] - a[N/2]);
    ans -= b;

    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

const int N = 1e4 + 10;
vector<int> a[N];
int c[N], deg[N];
int ret[N];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i < n; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    --x; --y;
    a[x].push_back(y);
    a[y].push_back(x);
    deg[x]++;
    deg[y]++;
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", &c[i]);
  }
  sort(c, c + n);
  queue<int> Q;
  for (int i = 0; i < n; ++i) {
    if (deg[i] == 1) Q.push(i);
  }
  int sum = 0, k = 0;
  fill(ret, ret + n, -1);
  while (!Q.empty()) {
    int u = Q.front();
    Q.pop();
    ret[u] = c[k++];
    if (deg[u] < 1) continue;
    sum += ret[u];
    for (auto& v : a[u]) {
      if (ret[v] < 0) {
        --deg[v];
        if (deg[v] == 1) Q.push(v);
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    if (ret[i] < 0) ret[i] = c[k];
  }
  printf("%d\n", sum);
  for (int i = 0; i < n; ++i) {
    printf("%d%c", ret[i], " \n"[i + 1 == n]);
  }
  return 0;
}


Measured memory_bytes: 1024
A = [int(input()) for i in range(5)]

ans = 0
remain = 10
for a in A:
  if a%10 == 0:
    ans += a//10
    #print(a,a//10)
  else:
    ans += (a+10)//10
    #print(a,(a+10)//10)
    remain = min(remain, a%10)
    
print(ans * 10 + remain -10)



Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using T = tuple<ll,ll,ll>;
using Map = map<char,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;

ll INF=2000000000000000;

int main(){
    ll n;
    cin >> n;
    ll m;
    cin >> m;
    ll s;
    cin >> s;
    ll g;
    cin >> g;
    vector<ll> u(m,0);
    vector<ll> v(m,0);
    vector<ll> a(m,0);
    vector<ll> b(m,0);
    for(ll i=0;i<m;i++){
        cin>>u[i]>>v[i]>>a[i]>>b[i]
    ;}
    vector<vector<P>> ylist(n+1, vector<P>(0));
    vector<vector<P>> slist(n+1, vector<P>(0));
    for(ll i=0;i<m;i++){
        ylist[u[i]].emplace_back(P(a[i],v[i]));
        ylist[v[i]].emplace_back(P(a[i],u[i]));
        slist[u[i]].emplace_back(P(b[i],v[i]));
        slist[v[i]].emplace_back(P(b[i],u[i]));
    ;}
    vector<ll> dyfroms(n+1,INF);
    vector<ll> dstog(n+1,INF);
    dyfroms[s]=0;
    dstog[g]=0;
    priority_queue<P, vector<P>, greater<P>> pqy;
    priority_queue<P, vector<P>, greater<P>> pqs;
    pqy.push(P(0,s));
    pqs.push(P(0,g));
    while(!pqy.empty()){
        P x=pqy.top();
        pqy.pop();
        ll t=x.second;
        if(x.first>dyfroms[t]){continue;}
        for(ll i=0;i<ylist[t].size();i++){
            if(dyfroms[ylist[t][i].second]>dyfroms[t]+ylist[t][i].first){
                dyfroms[ylist[t][i].second]=dyfroms[t]+ylist[t][i].first;
                pqy.push(P(dyfroms[ylist[t][i].second],ylist[t][i].second));
            }
        ;}
    }
    while(!pqs.empty()){
        P x=pqs.top();
        pqs.pop();
        ll t=x.second;
        if(x.first>dstog[t]){continue;}
        for(ll i=0;i<slist[t].size();i++){
            if(dstog[slist[t][i].second]>dstog[t]+slist[t][i].first){
                dstog[slist[t][i].second]=dstog[t]+slist[t][i].first;
                pqs.push(P(dstog[slist[t][i].second],slist[t][i].second));
            }
        ;}
    }
    priority_queue<P, vector<P>, greater<P>> way;
    for(ll i=1;i<=n;i++){
        way.push(P(dyfroms[i]+dstog[i],i));
    ;}
    ll ans=way.top().first,mark=way.top().second;
    way.pop();
    for(ll i=0;i<n;i++){
        if(i==mark){
            while(1){
                if(way.top().second>mark){
                    mark=way.top().second;
                    ans=way.top().first;
                    break;
                }
                way.pop();
            }
        }
        cout<<1000000000000000-ans<<endl;
    ;}


    
return 0;
}


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

int main() { 
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    cout << abs(a[n-1] - a[0]) << endl ;
}


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

#define int long long
typedef vector<int> vint;
typedef pair<int, int> pint;
const double PI = 3.141592653589793238462643383279;
const int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
template<typename T, typename U> inline bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> inline bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
struct Init {
    Init() {
        cout << fixed << setprecision(20);
    };
} init;

int N;
int P[330000];
int idx[330000];
set<int> set_hi, set_lo;
signed main() {
    cin >> N;
    for (int i = 1; i <= N; i++) { cin >> P[i], idx[P[i]] = i; }
    int ans = 0;
    for (int i = N; i >= 1; i--) {
        int cur = idx[i];
        int r1, r2;
        auto it = set_hi.upper_bound(cur);
        if (it == set_hi.end()) {
            r1 = N + 1, r2 = N + 1;
        } else {
            r1 = *it;
            auto it2 = set_hi.upper_bound(r1);
            if (it2 == set_hi.end()) { r2 = N + 1; }
            else { r2 = *it2; }
        }

        int l1, l2;
        it = set_lo.upper_bound(-cur);
        if (it == set_lo.end()) {
            l1 = 0, l2 = 0;
        } else {
            l1 = -*it;
            auto it2 = set_lo.upper_bound(-l1);
            if (it2 == set_lo.end()) { l2 = 0; }
            else { l2 = -*it2; }
        }
        ans += (cur - l1) * (r2 - r1) * i;
        ans += (r1 - cur) * (l1 - l2) *i;
        set_hi.insert(cur), set_lo.insert(-cur);
    }
    cout << ans << endl;
}


Measured memory_bytes: 12416
// Created by Sharat Sachin
#include <bits/stdc++.h>
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,n) for(ll i=0;i<(n);++i)
#define repA(i,a,n) for(ll i=a;i<=(n);++i)
#define repD(i,a,n) for(ll i=a;i>=(n);--i)
using namespace std;
using ll = long long;

int main()
{   ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    ll n,v[105],f[100005],w[105],W;
    cin>>n>>W;
    repA(i,1,100000)f[i]=1e18;
    repA(i,1,n) {
        cin>>w[i]>>v[i];
        repD(j,100000,v[i])f[j]=min(f[j],f[j-v[i]]+w[i]);
    }
    repD(i,100000,0)if(f[i]<=W) {
        cout<<i;
        return 0;
    }
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {

    /* チェックリスト
     * intの範囲を超えていないか
     * TLEしそうな処理の有無
     */
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        String[] ins = sc.nextLine().split(" ");
        int n = Integer.parseInt(ins[0]);
        int k = Integer.parseInt(ins[1]);
        String[] humans = sc.nextLine().split(" ");
        int r = 0;
        for(int i = 0;i < n;i++){
            if(Integer.parseInt(humans[i]) >= k){
                r++;
            }
        }
        System.out.println(r);
    }
}

Measured memory_bytes: 36100
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

struct Segmenttree{
    int n;
    vector<long long> node;

    Segmenttree(vector<long long> v){
        n = (int)(v.size());
        node.resize(2*n);
        for(int i=0;i<n;i++) node[i+n] = v[i];
        for(int i=n-1;i>=0;i--) node[i] = max(node[i<<1],node[i<<1|1]);
    }
    //i番目の要素をxに変更する
    void update(int i,long long x){
        i += n;
        node[i] = x;
        while(i>1){
            i >>= 1;
            node[i] = max(node[i<<1],node[i<<1|1]);
        }
    }
    //[l,r)の要素のmaxを求める
    long long query(int l,int r){
        long long res = 0;
        l += n; r += n;
        while(l<r){
            if(l&1) res = max(res,node[l++]);
            if(r&1) res = max(res,node[--r]);
            l >>= 1; r >>= 1;
        }
        return res;
    }
    //i番目の要素にアクセス
    long long getval(int i){
        return node[i+n];
    }
};

int mx = 300005;

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    Segmenttree seg(vector<ll>(mx,0));

    rep(i,n){
        int now = seg.query(max(a[i]-k,0),min(a[i]+k+1,mx));
        seg.update(a[i],now+1);
    }
    cout << seg.query(0,mx) << endl;

    return 0;
}

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

int serch(string s,char a){
  int cnt = 0;
  for(int i = 0; i < s.size(); i++){
    if(s[i] == a){
      cnt++;
    }
  }
  return cnt;
}
int main() {
  string s;
  cin >> s;
  int ans = min(serch(s,'0'),serch(s,'1'));
  ans *= 2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int n,q,m;
int A[2000];
bool tansaku(int m,int s){
    bool x=false;
    for(int i=s;i<n;i++){
        if(A[i]==m) return true;
    }
    for(int i=s;i<n;i++){
        if(m-A[i]>0){
           if(tansaku(m-A[i],i+1)) x=true;
        }
    }
    return x;;
}
int main(){
    cin>>n;
    for(int i=0;i<n;i++) cin>>A[i];
    cin>>q;
    for(int i=0;i<q;i++){
        cin>>m;
        if(tansaku(m,0)) cout<<"yes"<<endl;
        else cout<<"no"<<endl;
    }
}


Measured memory_bytes: 3072
#include<stdio.h>
int main(void)
{
	int seisuu[3];
	int x;
	scanf("%d %d %d",&seisuu[0],&seisuu[1],&seisuu[2]);
	if(seisuu[0]>seisuu[1]){
	x=seisuu[0];
	seisuu[0]=seisuu[1];
	seisuu[1]=x;
	}
	if(seisuu[0]>seisuu[2]){
	x=seisuu[0];
	seisuu[0]=seisuu[2];
	seisuu[2]=x;
	}
	if(seisuu[1]>seisuu[2]){
	x=seisuu[1];
	seisuu[1]=seisuu[2];
	seisuu[2]=x;
	}
	printf("%d %d %d\n",seisuu[0],seisuu[1],seisuu[2]);
	return 0;
}



Measured memory_bytes: 1948
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <unordered_map>
#include <cassert>
#include <time.h>
#include <cmath>
#include <random>
        
#define hash akasd
#define prev aaaasds
#define rank asdfdsf

using namespace std;

typedef long long ll;
typedef long double dbl;

template<class T>
void print(vector<T> s){
  for (T i : s)
		  cout << i << " ";
	cout << endl;
}

const int maxn = 1e5 + 7;

int prev[maxn], rank[maxn];

int getPrev(int v){
    if (v == prev[v])
        return v;
    prev[v] = getPrev(prev[v]);
    return prev[v];
}

ll summa[maxn];

void join(int a, int b){
    a = getPrev(a);
    b = getPrev(b);
    if (a == b)
        return;
    if (rank[a] < rank[b])
        swap(a, b);
    prev[b] = a;
    summa[a] += summa[b];
    if (rank[a] == rank[b])
        rank[a]++;
}

ll kek[maxn];

vector<pair<int, int> > g[maxn];
bool ok[maxn];

void dfs(int v, ll x){
    ok[v] = 1;
    for (pair<int, int> u : g[v]){
        if (!ok[u.second] && u.first <= x)
            dfs(u.second, x);
    }
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    // freopen("test.in", "r", stdin);
    int n, m;
    cin >> n >> m;
    vector<int> s(n);
    for (int i = 0; i < n; i++)
        cin >> s[i];
    vector<pair<int, pair<int, int> > > lst(m);
    for (int i = 0; i < m; i++){
        int a, b, x;
        cin >> a >> b >> x;
        lst[i] = {x, {a - 1, b - 1}};
        g[a - 1].push_back({x, b - 1});
        g[b - 1].push_back({x, a - 1});
    }
    sort(lst.begin(), lst.end());
    for (int i = 0; i < n; i++){
        prev[i] = i;
        summa[i] = s[i];
    }
    for (int i = 0; i < m; i++){
        join(lst[i].second.first, lst[i].second.second);
        kek[i] = summa[getPrev(lst[i].second.first)];
    }
    // for (int i = 0; i < m; i++)
    //     cout << kek[i] << " ";
    // cout << endl;
    int answer = 0;
    for (int i = m - 1; i >= 0; i--){
        int a = lst[i].second.first, b = lst[i].second.second;
        if (ok[a] && ok[b]){
            answer++;
            continue;
        }
        if (lst[i].first <= kek[i]){
            answer++;
            dfs(a, kek[i]);
        }
    }
    cout << m - answer << endl;
    return 0;
}

Measured memory_bytes: 12544
n = int(input())
W = list(map(int, input().split()))
sum_num = sum(W)
S1 = 0
min = 101
for w in W:
    S1 = S1 + w
    S2 = sum_num - S1
    if min > abs(S1 - S2):
        min = abs(S1 - S2)

print(min)


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

using namespace std;

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vpi = vector<pii>;

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

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

	return 0;
}

Measured memory_bytes: 3644
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/
 
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x
 
using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;
 
const ll MODBASE = 1000000007LL;
const int MAXN = 110;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int n, cnt0;
ll prod0, k;
vector<ll> pos, neg;

ll cntNeg(ll u) {
    ll res = 0;
    FOR(i,0,SZ(pos)-1) {
        ll e = u / pos[i] + (u % pos[i] > 0);
        int dau = 0, cuoi = SZ(neg)-1;
        while (dau <= cuoi) {
            int mid = (dau + cuoi) >> 1;
            if (neg[mid] >= e) cuoi = mid-1;
            else dau = mid+1;
        }
        res += SZ(neg) - dau;
    }
    return res;
}

ll cnt(vector<ll> &a, ll u) {
    ll res = 0;
    FOR(i,0,SZ(a)-1) {
        ll e = u / a[i];
        int dau = 0, cuoi = i-1;
        while (dau <= cuoi) {
            int mid = (dau + cuoi) >> 1;
            if (a[mid] <= e) dau = mid+1;
            else cuoi = mid-1;
        }
        res += cuoi + 1;
    }
    return res;
}

ll cntPos(ll u) {
    return cnt(pos, u) + cnt(neg, u);
}

ll solve(ll u) {
    ll res = 0;
    if (u >= 0) {
        res = prod0 + cntNeg(1);
        if (u) res += cntPos(u);
        return res;
    }
    else {
        res += cntNeg(-u);
    }
    return res;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n >> k;
    FOR(i,1,n) {
        ll x;
        cin >> x;
        if (x == 0) cnt0++;
        else if (x > 0) pos.emplace_back(x);
        else neg.emplace_back(-x);
    }
    sort(ALL(neg));
    sort(ALL(pos));

    FORE(i,n-1,n-cnt0) prod0 += i;

    ll dau = -1000000000000000000LL, cuoi = 1000000000000000000LL;
    while (dau <= cuoi) {
        ll mid = (dau + cuoi) / 2;
        if (solve(mid) < k) dau = mid+1;
        else cuoi = mid-1;
    }
    cout << dau;
    return 0;
}


Measured memory_bytes: 2420
N = int(input())
arr = sorted([6**x for x in range(1, 9) if 6**x <= N] + [9**x for x in range(1, 9) if 9**x <= N])
dp = [i for i in range(0,N+1)]
for i in range(2, N+1):
    dp[i] = 1+dp[i-1]
    for c in arr:
        if i - c >= 0:
            dp[i] = min([dp[i], 1+dp[i-c]])
print(dp[-1])

Measured memory_bytes: 7064
#include <cstdio>
#include <cassert>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <array>

using namespace std;

#define all(c) begin(c), end(c)
#define dump(c) cerr << "> " << #c << " = " << (c) << endl
#define REP(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

const int INF = 1001001001;
const double EPS = 1e-10;


template<typename T1,typename T2>
ostream& operator<<(ostream& os, const pair<T1,T2>& p){
  return os << '(' << p.first <<',' << p.second << ')';
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& a){
  os << '[';
  rep(i,a.size()) os << (i ? " " : "") << a[i];
  return os << ']';
}

int main() {
  int N; cin >> N;
  while(N--) {
    string O, M; cin >> O >> M;
    reverse(all(O));
    for(char o : O) {
      if(o == 'J') {
        M = M.substr(M.size() - 1) + M.substr(0, M.size() - 1);
      }
      if(o == 'C') {
        M = M.substr(1) + M.substr(0, 1);
      }
      if(o == 'E') {
        int h = M.size() / 2;
        M = M.substr(M.size() - h) + M.substr(h, M.size() & 1) + M.substr(0, h);
      }
      if(o == 'A') {
        reverse(all(M));
      }
      if(o == 'P') {
        for(char &c : M) if(isdigit(c)) c = (c - '0' - 1 + 10) % 10 + '0';
      }
      if(o == 'M') {
        for(char &c : M) if(isdigit(c)) c = (c - '0' + 1) % 10 + '0';
      }
    }

    cout << M << endl;
  }
  
  
  return 0;
}

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

int main(){
 int a, b,k;cin>>a>>b>>k;
 deque<int>d;
  for(int i=1;i<=min(a,b);i++){
 if(a%i==0&&b%i==0) d.push_back(i);
 }
  cout<<d.at(d.size()-k)<<endl;

}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from itertools import accumulate

n = int(input())
S = input().rstrip()
q = int(input())
K = tuple(map(int, input().split()))
L = [0]*q
M = [0]*n
C = [0]*n
cnt_M = [0]*n
cnt = 0
for i in range(n-1, -1, -1):
  s = S[i]
  if s == "M":
    M[i] = cnt
    cnt_M[i] = 1
  elif s == "C":
    C[i] = 1
    cnt += 1
M = tuple(accumulate(M))
C = list(accumulate(C[::-1]))[::-1]
cnt_M = tuple(accumulate(cnt_M))
for i, s in enumerate(S):
  if s == "D":
    for j, k in enumerate(K):
      temp = M[min(i+k-1, n-1)] - M[i]
      if i+k < n:
        temp -= C[i+k] * (cnt_M[i+k-1]-cnt_M[i])
      L[j] += temp
print(*L, sep="\n")

Measured memory_bytes: 235324
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define mid ((l+r)>>1)
#define lowbit(x) (x&(-x))
#define INF 0x3f3f3f3f
using namespace std;
template<class T>il read(T &x){
	int f=1;char k=getchar();x=0;
	for(;k>'9'||k<'0';k=getchar()) if(k=='-') f=-1;
	for(;k>='0'&&k<='9';k=getchar()) x=(x<<3)+(x<<1)+k-'0';
	x*=f;
}
template<class T>il _print(T x){
	if(x/10) _print(x/10);
	putchar(x%10+'0');
}
template<class T>il print(T x){
	if(x<0) putchar('-'),x=-x;
	_print(x);
}
ll mul(ll a,ll b,ll mod){long double c=1.;return (a*b-(ll)(c*a*b/mod)*mod)%mod;}
it qpow(int x,int m,int mod){
	int res=1,bas=x;
	while(m){
		if(m&1) res=(1ll*res*bas)%mod;
		bas=(1ll*bas*bas)%mod,m>>=1;
	}
	return res;
}
const int MAXN = 3e4+5;
int n,ans;
char s[MAXN],vis[1005][3];
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	read(n),scanf("%s",s+1);
	for(ri i=1;i<=n;++i){
		for(ri j=0;j<100;++j)
			vis[j*10+s[i]-'0'][2]|=vis[j][1];
		for(ri j=0;j<10;++j)
			vis[j*10+s[i]-'0'][1]|=vis[j][0];
		vis[s[i]-'0'][0]=1;
	}
	for(ri i=0;i<1000;++i)
		ans+=vis[i][2];
	print(ans);
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  int M = N;
  
  vector<int> a(N);
  for (int i=0; i<N; i++)
    cin >> a.at(i);
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  for (int i=0; i<N-1 ; i++) {
    if (a.at(i) == a.at(i+1))
      M--;
  }
  
  cout << M << endl;

}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void){
  int n;
  ll t;
  cin >> n >> t;
  vector<ll> ts(n);
  REP(i, 0, n) {
    cin >> ts[i];
  }
  ll tot = 0;
  REP(i, 0, n - 1) {
    tot += min(t, ts[i + 1]- ts[i]);
  }
  tot += t;
  cout << tot << endl;
}


Measured memory_bytes: 1792
<?php
while (true) {
    list($a, $operator, $b) = getSpacesByExplodeTrimInput();

    switch ($operator) {
        case '+':
            $result = addingTwoNum($a, $b);
            break;
        case '-':
            $result = subTractTwoNum($a, $b);
            break;
        case '*':
            $result = multiplyTwoNum($a, $b);
            break;
        case '/':
            $result = divideTwoNumByFloorPoint($a, $b);
            break;
        case '?':
            exit;
    }

    echo $result, PHP_EOL;
}

function getSpacesByExplodeTrimInput()
{
    return explode(' ', trim(fgets(STDIN)));
}

function addingTwoNum($a, $b)
{
    return $a + $b;
}

function subTractTwoNum($a, $b)
{
    return $a - $b;
}
  
function multiplyTwoNum($a, $b)
{
    return $a * $b;
}

function divideTwoNumByFloorPoint($a, $b)
{
    return floor($a / $b);
}

Measured memory_bytes: 15444
import std.algorithm;
import std.bigint;
import std.concurrency;
import std.container;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.meta;
import std.numeric;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;


auto solve(string S) {
    auto groups = S.array.group.map!"a[1]".array;
    long moves;

    foreach (i; 0 .. groups.length - 1) {
        if (groups[i] < groups[i + 1]) {
            moves += groups[i];
            groups[i + 1] -= groups[i];
        } else {
            moves += groups[i + 1];
            if (i + 2 < groups.length) {
                groups[i + 2] += groups[i] - groups[i + 1];
                groups[i + 1] = 0;
            }
        }
    }

    return moves * 2;
}


void main() {
    auto input = stdin.byLine.map!split.joiner;

    string S;
    S = input.front.to!string;
    input.popFront;

    static if (is(ReturnType!solve == void))
        solve(S);
    else
        solve(S).writeln;
}


Measured memory_bytes: 2840
package main

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

var n int
var a, b, c []int
var dp [][]int

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 main() {

	sc.Split(bufio.ScanWords)

	n = nextInt()

	a = make([]int, n)
	b = make([]int, n)
	c = make([]int, n)

	for i := 0; i < n; i++ {
		a[i] = nextInt()
		b[i] = nextInt()
		c[i] = nextInt()
	}

	dp = make([][]int, n)
	for i := 0; i < n; i++ {
		dp[i] = make([]int, 3)
		dp[i][0] = -1
		dp[i][1] = -1
		dp[i][2] = -1
	}

	ans := int(math.Max(float64(dfs(0, 0)), float64(dfs(0, 1))))
	fmt.Println(ans)
}

func dfs(day int, preChoice int) int {
	// 最終日であればそれ以上幸福度は得られないので0
	if day == n {
		return 0
	}
	// 計算済みであればそれを返す
	if dp[day][preChoice] != -1 {
		return dp[day][preChoice]
	}
	chooseA := -9999999
	chooseB := -9999999
	chooseC := -9999999
	if preChoice != 0 {
		chooseA = a[day] + dfs(day+1, 0)
	}
	if preChoice != 1 {
		chooseB = b[day] + dfs(day+1, 1)
	}
	if preChoice != 2 {
		chooseC = c[day] + dfs(day+1, 2)
	}
	// 最も幸福度が高かったものをdpに保存
	maxValue := int(math.Max(float64(chooseA), float64(chooseB)))
	maxValue = int(math.Max(float64(maxValue), float64(chooseC)))
	dp[day][preChoice] = maxValue
	return maxValue
}


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long
#define mod 1000000007
#define IINF INT_MAX
#define INF 1LL << 30


int main() {
    int n; cin >> n;
    string s, t; cin >> s >> t;
    for(int i = 0; i < n; i++){
        cout << s[i];
        cout << t[i];
    }
    cout << "\n";

    return 0;
}


Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc  = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int wa = a + b;
		int sa = a - (b);
		int seki = a * b;
		int[] list = new int[] {sa, seki};
		int max = wa;
		for(int i =0; i < list.length; i++) {
			if(max < list[i]) {
				max = list[i];
			}
		}
		System.out.println(max);
	}
}

Measured memory_bytes: 22868
import sys

field = [[0 for i in range(10)] for j in range(10)]


def ink(x, y, s):
    for dx, dy in ((0, 0), (0, 1), (1, 0), (-1, 0), (0, -1)):
        plot(x + dx, y + dy)
    if s == 1:
        return
    for dx, dy in ((1, 1), (-1, -1), (-1, 1), (1, -1)):
        plot(x + dx, y + dy)
    if s == 2:
        return
    for dx, dy in ((2, 0), (0, 2), (-2, 0), (0, -2)):
        plot(x + dx, y + dy)


def plot(x, y):
    if 0 <= x < 10 and 0 <= y < 10:
        field[x][y] += 1

for line in sys.stdin:
    x, y, s = map(int, line.split(','))
    ink(x, y, s)
print(sum(field, []).count(0))
print(max(sum(field, [])))

Measured memory_bytes: 7664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define all(x) (x).begin(),(x).end()
#define INF 1e18

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

void Main(){
  int N; cin >> N;
  vector<ll> cusum(N);
  ll sum = 0;
  rep(i, 0, N){
    int a; cin >> a;
    sum += a;
    cusum[i] = sum;
  }
  ll res = INF;
  for(int i = 0; i < N - 1; i++){
    if(res > abs(sum - 2 * cusum[i])) res = abs(sum - 2 * cusum[i]);
  }
  cout << res << endl;
}

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

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  //cout << std::fixed << std::setprecision(15);

  Main();
}


Measured memory_bytes: 1792
def main():
  N = int(input())
  A = [int(x) for x in input().split()]
  
  B = [0] * N    
  for i in range(N-1):
      B[A[N-i-2]-1] += 1
  
  for i in range(N):
    print(B[i])
    
if __name__ == '__main__':
  main()

Measured memory_bytes: 32204
#include <stdio.h>

int main (void)
{
	char c[1001];
	int i,sum;
	while(1)
	{
		scanf("%s",c);
		sum=0;
		if(c[0]=='0')
		{
			break;
		}
		for(i=0;c[i]!='\0';i++)
		{
			sum+=c[i]-'0';
		}
		printf("%d\n",sum);
	}
	return 0;
}

Measured memory_bytes: 536
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

int main(){
  int st[30] = {0};
  int i;
  for(i = 0; i < 28; i++){
    int	input;
    cin	>> input;
    st[input - 1] = 1;
  }
  for(i = 0; i < 30; i++){
    if(!st[i])
      printf("%d\n",i + 1);
  }




  return 0;
}

Measured memory_bytes: 1144
#include <iostream>
#include <algorithm>
using namespace std;
double arr[1000000];
int main(){
    int a,b,c,i,n;
    cin>>n;
    for(i = 0;i < n;i++){
        cin>>arr[i];
    }
    a = arr[0];
    int flag = 0;
    for(i = 0;i < n;i++){
        if(arr[i]>=a){
            a = arr[i];
        }
        else{
            if(a - arr[i]>=2){
                flag = 1;
            }
        }
    }
    if(flag == 0){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
}


Measured memory_bytes: 1024
using System;

class program
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        long ans = 1;

        for(int i = 2; i <= N; i++)
        {
            ans *= i;
            if (ans > 1000000007)
            {
                ans %= 1000000007;
            }
        }

        Console.WriteLine(ans);

    }
}

Measured memory_bytes: 11092
#include <stdio.h>
#include <vector>
#include <map>
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <iomanip>
#include <numeric>
using namespace std;

const long long M = 1e9 + 7;

int main(void) {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> a(n, vector<int>(m));
  vector<int> used(m, 1);
  vector<int> pnt(n, 0);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      cin >> a[i][j];
      --a[i][j];
    }
  }
  int ans = 1e9;
  int used_num = m;
  while (used_num--) {
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < m; ++j) {
        if (used[a[i][j]]) {
          pnt[i] = j;
          break;
        }
      }
    }
    vector<int> count(m);
    for (int i = 0; i < n; ++i) {
      count[a[i][pnt[i]]]++;
    }
    int maxi = -1;
    int ind = -1;
    for (int i = 0; i < m; ++i) {
      if (count[i] > maxi) {
        maxi = count[i];
        ind = i;
      }
    }
    ans = min(ans, maxi);
    used[ind] = 0;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<vector>
#include<string>
#define int long long
using namespace std;

int w[100000], d[100000];
signed main() {
	int n, k; cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> w[i] >> d[i];
	}
	int l = 0, r = LLONG_MAX / 3;
	while (r - l > 1) {
		int t = (l + r) / 2;
		int sum = 0;
		for (int i = 0; i < n; i++) {
			if (t >= w[i]) {
				sum += 1 + (t - w[i]) / d[i];
			}
		}
		if (sum >= k)r = t;
		else l = t;
	}
	cout << r << endl;
}

Measured memory_bytes: 1792