akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<int,int> P;
#define fi first
#define se second
#define all(v) (v).begin(),v.end()
set<string> c;
const ll inf=(1e18);
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n,c;
cin>>n>>c;
vector<ll> x(n+2,0),v(n+1,0),getl(n+1,0),getr(n+1,0),getl_used(n+1,0),getr_used(n+1,0);
    for(int i=1;i<=n;i++){
        cin>>x[i]>>v[i];
    }
    x[n+1]=c;
    ll res1=0,res2=0,ever1=0,ever2=0;
    for(int i=1;i<=n;i++){
        res1+=v[i]-(x[i]-x[i-1]);
        res2+=v[i]-2*(x[i]-x[i-1]);
        chmax(ever1,res1);
        chmax(ever2,res2);
        getl[i]=ever1;
        getl_used[i]=ever2;
    }
    res1=0;res2=0;ever1=0;ever2=0;
    for(int i=n;i>=1;i--){
        res1+=v[i]-(x[i+1]-x[i]);
        res2+=v[i]-2*(x[i+1]-x[i]);
       chmax(ever1,res1);
        chmax(ever2,res2);
        getr[i-1]=ever1;
        getr_used[i-1]=ever2;
    }
    ll resl=0,resr=0,ans=0;
    ll used=c;
    for(int i=0;i<=n;i++){
        resl=getl[i]+getr_used[i];
        resr=getr[i]+getl_used[i];
        ans=max({ans,resl,resr});
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
    using namespace std;
     
    int main(){
        int n;
        cin>>n;
        vector<int> k;
        int a;
        while(n--){
            cin>>a;
            k.push_back(a);
        }
        int sum=0;
        for(int i=0;i<k.size();i++){
            for(int j=i+1;j<k.size();j++){
                sum+=k[i]*k[j];
            }
        }
        cout<<sum;
     
        return 0;
    }

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <time.h>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) (min(a,b) <= (x) && (x) <= max(a,b)) //hei
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007LL
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
	std::fill((T*)array, (T*)(array + N), val);
}
pll Dir[4] = {
	{ -1 ,0 },{ 0 , 1 },{ 1 ,0 },{ 0 ,-1 }
};

//[a, b)
#define Getsum(ar, a,b) (ar[b] - ar[a])
#define INF 10000000000000000LL
#define chmax(a,b) a = max(a,b)
#define chmin(a,b) a = min(a,b)

struct Edge {
	int from, to;
	ll w;
	bool operator<(const Edge& rhs) const {
		return MP(w, MP(from, to)) < MP(rhs.w, MP(rhs.from, rhs.to));
	}

};
ll dp[110][63300] = {};

signed main(void) {
	int n, k;
	cin >> n >> k;

	vector<int> cand;
	int sq = sqrt(n);
	cand.reserve(63300);

	rep(i,1, sq + 1) {
		cand.push_back(i);
		cand.push_back(n / i);
	}

	sort(ALL(cand));
	cand.erase(unique(ALL(cand)), cand.end());

	int bef = 0;
	REP(i, cand.size()) {
		dp[0][i + 1] = dp[0][i] + cand[i] - bef;
		dp[0][i + 1] %= MODU;
		bef = cand[i];
	}


	rep(i,1, k) {
		rep(j, 1, cand.size() + 1) {
			dp[i][j] = dp[i][j-1] + (dp[0][j] - dp[0][j-1]) * dp[i - 1][cand.size() - j + 1];
			dp[i][j] %= MODU;
		}
	}

	printf("%lld\n",( dp[k - 1][cand.size()] + MODU) % MODU);

	return 0;
}


Measured memory_bytes: 51712
N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))
X_Y = []
sum = 0

for i in range(N):
    X_Y.append(int(V[i] - C[i]))
    if(X_Y[i] > 0):
        sum += X_Y[i]
# print(V)
# print(C)
# print(X_Y)
print(sum)


Measured memory_bytes: 3064
/**
 * @author torith
 * @date 2018-11-04
 */

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    int X,Y;
    cin >> X >> Y;
    cout << X + Y/2 << "\n";

    return 0;
}



Measured memory_bytes: 256
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def print_and_exit(X, eated_P):
    if X == 0:
        print eated_P
        exit()

table = {}

def get_burger_size(L):
    global table
    if L in table:
        return table[L]
    if L == 0:
        table[0] = (1L, 1L)
        return (1L, 1L)

    l_1_burger = get_burger_size(L - 1)
    table[L - 1] = l_1_burger
    return  (3L + 2L * l_1_burger[0], 1L + 2L * l_1_burger[1])

g_eated = 0
g_eated_P = 0

def calc_eated(X, L, eated_P):
    X -= 1
    print_and_exit(X, eated_P)

    (eated_f, eated_P_f) = get_burger_size(L - 1)
    if X < eated_f:
        calc_eated(X, L - 1, eated_P)
    X -= eated_f
    eated_P += eated_P_f
    print_and_exit(X, eated_P)

    eated_P += 1
    X -= 1
    print_and_exit(X, eated_P)

    (eated_f, eated_P_f) = get_burger_size(L - 1)
    if X < eated_f:
        calc_eated(X, L - 1, eated_P)
    X -= eated_f
    eated_P += eated_P_f
    print_and_exit(X, eated_P)

    X -= 1
    print_and_exit(X, eated_P)



def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, X] = [long(input_raw[0]), long(input_raw[1])]
    calc_eated(X, N, 0)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2968
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;


int main() {
	int n, m; cin >> n >> m;
	cout << n*(n - 1) / 2 + m*(m - 1) / 2 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long n,m,jawaban,hasil,sisa;
	cin>>n>>m;	
	hasil=m/2; sisa=m%2;
	if (hasil>=n) {
		jawaban=n+(hasil-n)/2;
		cout<<jawaban<<endl;
	}
	else{
		cout<<hasil<<endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n; cin >> n;
	int l[11];
	int lmax = 0;
	int sum = 0;
	for(int i=0;i<n;i++){
		cin >> l[i];
		sum += l[i];
		lmax = max(lmax, l[i]);
	}
	if(lmax<sum-lmax){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
//
// Created by moono on 2018/10/27.
//

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



int main() {
    int H, W;
    cin >> H >> W;

    //
    vector<string> strs(H);
    for (int i = 0; i < H; ++i) {
        cin >> strs[i];
    }

    //
    for (int i = 0; i < H; ++i) {
        cout << strs[i] << endl << strs[i] << endl;
    }


    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		int m = stdIn.nextInt();
		int[] money = new int[10];
		int[] ans = new int[n];
		int min = 10000;
		int minNumber = -1;

		for(int i=0; i<10; i++){
			money[i] = stdIn.nextInt();
			if(money[i] < min){
				min = money[i];
				minNumber = i;
			}
		}

		Arrays.fill(ans,minNumber);

		if((m -= money[minNumber] * n) < 0){
			System.out.println("NA");
			return;
		}

/*		for(int i=0; i<n; i++){
			System.out.print(ans[i]);
		}
		System.out.println();
*/
		for(int i=0; i<10; i++){
			for(int j=0; j<n; j++){
				if( ((m - money[i] + money[ans[j]]) >= 0) && (i < ans[j])){
					m = m - money[i] + money[ans[j]];
					ans[j] = i;
				}
			}
		}

		Arrays.sort(ans);

		for(int i=0; i<n; i++){
			System.out.print(ans[i]);
		}
		System.out.println();
	}
}


Measured memory_bytes: 17368
N = input().split()
N = [int(i) for i in N]

judge = False
for i in range(0, N[0]+1):
    for j in range(0, N[0]+1-i):
        k = N[0]-i-j
        if(10000*i + 5000*j + 1000*k == N[1]):
            judge = True
            break
    else:
        continue
    break

if(judge):
    print(i, j, k)
else:
    print(-1, -1, -1)
        


Measured memory_bytes: 3188
import java.io.*;
import java.util.*;
public class Main {
    
    public static void main(String[] args) throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(br.readLine());
        int[] x=new int[n+1];
       int[] prime=new int[n+1];
        Arrays.fill(prime,1);
        prime[0]=prime[1]=0;
        for(int i=2;i*i<=n;i++){
            if(prime[i]>0){
                for(int j=2;i*j<=n;j++){ prime[i*j]=0; }
            }
        }
        
        for(int i=2;i<n+1;i++){
            if(prime[i]>0){
                prime[i]=0;
                for(int j=i;j<=n;j*=i){
                    prime[i]+=n/j;
                }
            }
        }for(int i=0;i<n+1;i++){ prime[i]++; }
        
        long sum=1;
        
        for(int i=0;i<n+1;i++){
            sum=(sum%1000000007)*(prime[i]%1000000007);
        }System.out.println(sum%1000000007);
        
        
    }
}

Measured memory_bytes: 8148
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int a = N/1000;
  int b = N/100%10;
  int c = N/10%10;
  int d = N%10;
  if(b==c&&(a==b||c==d)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3612
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
	"strconv"
	"strings"
)

var scan *bufio.Scanner
var writer io.Writer

func init() {
	scan = bufio.NewScanner(os.Stdin)
	writer = os.Stdout
	scan.Split(bufio.ScanWords)
}

func main() {
	solve()
}

func solve() {
	c := 0
	n := nextInt()
	var s []string
	sx := make([][]string, n)
	sm := make(map[string]int, n)
	for i := 0; i < n; i++ {
		s = append(s, nextWord())
		sx[i] = strings.Split(s[i], "")
		sort.Strings(sx[i])
		c += sm[strings.Join(sx[i], "")]
		sm[strings.Join(sx[i], "")]++
	}
	fmt.Fprint(writer, c)
}

func nextWord() string {
	scan.Scan()
	str := scan.Text()
	return str
}

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


Measured memory_bytes: 36224
import           Data.Maybe
import qualified Data.Vector     as V
import qualified Data.ByteString.Lazy.Char8    as BC

main = do
    n  <- readLn
    as <-
        V.fromList
        .   map (pred . fst . fromJust . BC.readInt)
        .   BC.lines
        <$> BC.getContents
    print $ fromMaybe (-1) $ V.elemIndex 1 $ V.iterateN (n+1) (as V.!) 0

Measured memory_bytes: 19068
#include<iostream>
#include<string>
using namespace std;
int main(){
    string s;
    cin>>s;
    if((s[0]==s[1]&&s[1]==s[2])||(s[1]==s[2]&&s[2]==s[3])){
        cout<<"Yes"<<endl;
        
    }else{
        cout<<"No"<<endl;
    }
    
    
    
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int cnt=0;
  cin>>n;
  vector<int> mt(n);
  for(int i=0;i<n;i++){
    cin>>mt.at(i);
  }
  int sun=mt.at(0);
  for(int i=0;i<n;i++){
    if(sun<=mt.at(i)){
      cnt++;
      sun=mt.at(i);
    }
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.awt.geom.*;

import static java.lang.Math.*;
public class Main {
	final Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		new Main().init();
	}
	void init(){
		new AOJ1174();
	}
	class AOJ1174{
		AOJ1174(){
			while(sc.hasNext()){
				H=sc.nextInt(); W=sc.nextInt(); C=sc.nextInt();
				if((H|(W|C))==0)	break;
				solve();
			}
		}
		int H,W,C;
		int[][][] b;
		final int[] vx={0,-1,0,1},vy={-1,0,1,0};
		void solve(){
			b=new int[6][W][H];
			for(int h=0; h<H; ++h)for(int w=0; w<W; ++w)	b[0][w][h]=sc.nextInt();
			System.out.println(backtracking(b,0));
		}
		int backtracking(int[][][] b,int depth){
			if(depth>=4)	return cnt(chg(depth, C));
			int ret=0;
			for(int c=1; c<=6; ++c){
				if(c==b[depth][0][0])	continue;
				chg(depth, c);
				ret=max(ret, backtracking(b, depth+1));
			}
			return ret;
		}
		int[][] chg(int d,int target){
			for(int w=0; w<W; ++w)for(int h=0; h<H; ++h)	b[d+1][w][h]=b[d][w][h];
			b[d+1][0][0]=target;
			chg(d,0,0,target);
			return b[d+1];
		}
		void chg(int d,int x,int y,int target){
			for(int v=0; v<4; ++v){
				int nx=x+vx[v],ny=y+vy[v];
				if(!(0<=nx&&nx<W && 0<=ny&&ny<H))	continue;
				if(b[d][nx][ny]!=b[d][0][0])	continue;
				if(b[d+1][nx][ny]==target)	continue;
				b[d+1][nx][ny]=target;
				chg(d,nx,ny,target);
			}
		}
		int cnt(int[][] a){
			return cnt(a,0,0,a[0][0]);
		}
		int cnt(int[][] a,int x,int y,int c){
			int ret=1;
			a[x][y]=-1;
			for(int v=0; v<4; ++v){
				int nx=x+vx[v],ny=y+vy[v];
				if(!(0<=nx&&nx<W && 0<=ny&&ny<H))	continue;
				if(a[nx][ny]!=c)	continue;
				ret+=cnt(a, nx, ny, c);
			}
			return ret;
		}
	}
}

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

int main(){
    string s;
    cin>>s;
    for(int i=0;i<4-1;++i){
        if(s[i]==s[i+1]){
            cout<<"Bad\n";
            return 0;
        }
    }
    cout<<"Good\n";
  	return 0;
}

Measured memory_bytes: 256
fun main() {
    val (n, k) = nextIntList()
    val v = nextIntList().toSet().let {
        (0..9).filterNot { v -> v in it }
    }
    v.forEach {
        if (it >= n) {
            println(it)
            return
        }
    }
    var s = v.filterNot { it == 0 }.toSet()
    repeat(4) {
        val ns = mutableSetOf<Int>()
        s.forEach { a ->
            v.forEach { b ->
                val c = a.times(10) + b
                if (c >= n) {
                    println(c)
                    return
                }
                ns.add(c)
            }
        }
        s = ns
    }
}

// # Utils
// ## Input
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = next().split(" ").map(String::toInt)
fun nextLongList() = next().split(" ").map(String::toLong)
fun nextDoubleList() = next().split(" ").map(String::toDouble)

// ## Array
inline fun <reified T> sizedArray(size: Int, default: T) = Array(size) { default }
inline fun <reified T> sized2DArray(row: Int, column: Int, default: T) = Array(row) { Array(column) { default } }

// ## mod^-1
//    [NOTE] CANNOT use this for 0, mod, 2mod, 3mod ...(return wrong value)
fun modinv(num: Long, mod: Long): Long {
    var a = num
    var b = mod
    var u = 1L
    var v = 0L
    while (b > 0) {
        val t = a.div(b)
        a -= t * b
        a = b.also { b = a } // swap a and b
        u -= t * v
        u = v.also { v = u } // swap u and v
    }
    u %= mod
    if (u < 0) u += mod
    return u
}

fun gcd(x: Int, y: Int): Int {
    fun innerGcd(x: Int, y: Int): Int {
        return if (x % y == 0) y else innerGcd(y, x % y)
    }
    return if (x >= y) innerGcd(x, y) else innerGcd(y, x)
}

fun gcd(x: Long, y: Long): Long {
    fun innerGcd(x: Long, y: Long): Long {
        return if (x % y == 0L) y else innerGcd(y, x % y)
    }
    return if (x >= y) innerGcd(x, y) else innerGcd(y, x)
}

// classes
class UnionFindTree(val size: Int) {
    private val r = sizedArray(size, -1)
    fun root(x: Int): Int {
        if (r[x] < 0) return x
        return root(r[x])
    }

    fun unite(x: Int, y: Int) {
        var rx = root(x)
        var ry = root(y)
        if (rx == ry) return
        if (r[rx] > r[ry]) {
            rx = ry.also { ry = rx }
        }
        r[rx] += r[ry]
        r[ry] = rx
    }

    fun size(x: Int) = -r[root(x)]

    override fun toString(): String {
        return r.joinToString(separator = ", ")
    }
}

Measured memory_bytes: 38464
#include<bits/stdc++.h>
#define LL long long
using namespace std;
int h,w; LL ans=(1LL<<60);
void solve(int h,int w)
{
	int i; LL S1,S2,S3;
	for(i=1;i<=h/2;i++){
		S1=1LL*i*w;
		S2=1LL*(w/2)*(h-i);
		S3=1LL*(w-w/2)*(h-i);
		if(S1<S2) swap(S1,S2);
		if(S1<S3) swap(S1,S3);
		if(S2<S3) swap(S2,S3);
		ans=min(ans,S1-S3);
	  }
}
int main()
{
	cin>>h>>w;
	if(h%3==0||w%3==0) ans=0;
	else ans=min(h,w);
	solve(h,w);
	solve(w,h);
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define EPS 1e-10
#define setNil(x) memset((x),0,sizeof(x))
#define setINF(x) memset((x),63,sizeof(x))
#define setNegINF(x) memset((x),192,sizeof(x)) //NegINF=-INF-1
#define setNeg1(x) memset((x),255,sizeof(x))
#define D first
#define ID second
using namespace std;
typedef long long ll;
typedef pair<ll,int> pii;
const int N=100005;
int n,f[N],sz[N];
ll d[N],tot;
pii p[N];
map<ll,int> mp;
vector<int> g[N];
void dfs(int x,int p,int dep){
	tot+=dep;
	for(int i=0;i<g[x].size();i++){
		int u=g[x][i];
		if(u==p)continue;
		dfs(u,x,dep+1);
	}
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>d[i];
		p[i]=pii(d[i],i);
		sz[i]=1;
		mp[d[i]]=i;
	}
	sort(p+1,p+n+1);
	for(int i=n;i>1;i--){
		ll fs=p[i].D-n+2*sz[p[i].ID];
		if(!mp[fs] || fs>=p[i].D){
			cout<<"-1\n";
			return 0;
		}
		sz[f[p[i].ID]=mp[fs]]+=sz[p[i].ID];
		g[p[i].ID].push_back(f[p[i].ID]);
		g[f[p[i].ID]].push_back(p[i].ID);
	}
	dfs(p[1].ID,0,0);
	if(tot!=p[1].D)cout<<"-1\n";
	else for(int i=n;i>1;i--)cout<<f[p[i].ID]<<' '<<p[i].ID<<endl;
	return 0;
}

Measured memory_bytes: 19432
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i = 0; i < (ll) n; i++)
#define xrep(i,x,n) for(ll i = (ll) x; i < (ll) n; i++)
#define vl vector<long long>
#define vs vector<string>
#define all(A) A.begin(), A.end()

int main() {
    ll N; cin >> N;
    vl h(N);
    rep(i, N) cin >> h[i];

    vl dp(N);
    dp[1] = abs(h[0] - h[1]);

    rep(i,N - 2){
        dp[i + 2] = min(dp[i + 1] + abs(h[i + 1] - h[i + 2]), dp[i] + abs(h[i] - h[i + 2]));
    }

    cout << dp[N - 1] << endl;
}

Measured memory_bytes: 4836
#include<bits/stdc++.h>
using namespace std;
const int N=1e7;
long long arr[N];
int main()
{
    int n,z=0;cin>>n;
   for(int i=0;i<n;i++)
   {
       cin>>arr[i];
       if(arr[i]==0)z++;
   }
if(z){cout<<0<<endl;
    return 0;}
long long res=1;
for(int i=0;i<n;i++)
{
    if(arr[i]<=1000000000000000000/res)
    {
        res*=(long long)arr[i];
    }
    else
    {
        cout<<-1<<endl;
        return 0;
    }

}
cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 4412
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <algorithm>
using namespace std;

typedef long long int ll;


ll gcd(ll a, ll b) {
    return b != 0 ? gcd(b, a % b) : a;
}
int main () {
    ll k; cin >> k;
    ll ans = 0;
    for (int i = 1; i <= k; i++) {
        for (int j = 1; j <= k; j++) {
            for (int t = 1; t <= k; t++) {
                ans += gcd(gcd(i, j), t);
            }
        }
    }

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

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

int main() {
  map<string, int> dict;
  int n;
  cin >> n;
  int max_cnt = 0;
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    dict[s]++;
    max_cnt = max(max_cnt, dict[s]);
  }
  for (auto& item : dict) {
    if (item.second == max_cnt) {
      cout << item.first << endl;
    }
  }
}


Measured memory_bytes: 25856
n = int(input())
S = [int(input()) for i in range(n)]
Sum = sum(S)
if Sum%10 != 0:
    print(Sum)
    exit()
else:
    S.sort()
    for s in S:
        if s%10 != 0:
            Sum -= s
            print(Sum)
            exit()
print(0)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
    using namespace std;
    int main() {
      int n,a=0,b=0 ;
      string str;
      cin >> n;
      cin >>str;
      
      for(int i=0;i<n;i++){
        if(str.at(i) == 'R')
          a++;
        else
          b++;
      }
      if(a>b)
        cout << "Yes" <<endl;
      else
        cout << "No" << endl;
    }

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

using namespace std;

#define fcout(d) cout << fixed << setprecision(d)
#define rep(i,n) for(int (i)=0; (i)<n; ++(i))
#define rep1(i,n) for(int (i)=1; (i)<=n; ++(i))
#define repU(i,bottom,ceiling) for(int (i) = (bottom); (i) <= (ceiling); ++(i))
#define repD(i,ceiling,bottom) for(int (i) = (ceiling); (i) >= (bottom); --(i))
#define pub push_back
#define pob pop_back
#define prf printf
#define scf scanf
#define mkp make_pair
#define fir first
#define sec second
#define clr(a) memset((a),0,sizeof(a))

typedef long long ll;
typedef double db;
typedef pair<int,int> pii;

const vector<pair<int,int>> DIR = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const int INF = (int)2e9 + 1e8;
const int MOD = (int)1e9 + 7;

template<typename T,typename U>
inline pair<T,U> operator+(const pair<T,U> & l,const pair<T,U> & r) {
    return {l.fir+r.fir,l.sec+r.sec};
}

template<typename T,typename U>
inline pair<T,U> operator-(const pair<T,U> & l,const pair<T,U> & r) {
    return {l.fir-r.fir,l.sec-r.sec};
}

template<typename T,typename U>
inline pair<T,U> operator*(const pair<T,U> & l,const pair<T,U> & r) {
    return {l.fir*r.fir,l.sec*r.sec};
}

template<typename T> inline T gcd(T a,T b){ if(a % b){ return gcd(b,a % b); }else{ return b; } }

template<typename T> inline T lcm(T a,T b){ return a / gcd(a,b) * b; }

inline int Pow(const long long n,long long m,const int mod = MOD){
	long long res = 1,pow = n;
	while(m) {
		if(m & 1) res = (res * pow) % mod;
		pow = (pow * pow) % mod;
		m >>= 1;
	}
	return res;
}

inline vector<int> Frac(const int range,const int mod = MOD){
	vector<int> frac;
	frac.push_back(1);
	for(int i = 1; i <= range; ++i) frac.push_back((long long)frac.back() * i % mod);
	return frac;
}

inline int Comb(const int n,const int m,const int mod = MOD){
	if(n < m || m < 0) return 0;
	vector<int> frac(Frac(n,mod));
	long long rev = Pow((long long)frac[m] * frac[n-m] % mod,mod-2,mod);
	return rev * frac[n] % mod;
}

template<typename T> inline bool v_find(const vector<T> v,const T obj){
	auto itr = find(v.begin(), v.end(), obj);
	size_t index = distance(v.begin(),itr);
	if (index != v.size()) { return true; }
	return false;
}

template<typename T> inline bool v_erase(vector<T> &v,const T obj){
	auto itr = find(v.begin(), v.end(), obj);
	size_t index = distance(v.begin(),itr);
	if (index != v.size()) {
		v.erase(itr);
		return true;
	}
	return false;
}

template<class T,class U> inline auto LB(const T v,const U in){ return lower_bound(v.begin(),v.end(),in); }

template<class T,class U> inline auto UB(const T v,const U in){ return upper_bound(v.begin(),v.end(),in); }


inline void solve(){
  int x,a,b;
  cin>>x>>a>>b;
  if(a+x<b) cout<<"dangerous";
  else if(a<b) cout<<"safe";
  else cout<<"delicious";
  return;
}

inline void input(){
  return;
}

int main(){
  cin.tie(0);
	ios::sync_with_stdio(false);
	input();
	solve();
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int N;
        public long MOD = 1000000007;

        public void Run()
        {

            N = Input.ReadInt();
            for (int n = 2; n < 1000; n++)
            {
                if (n * (n - 1) != N * 2) continue;
                Console.WriteLine("Yes");
                Console.WriteLine(n);

                int c = N * 2 / n;
                // var ret = new int[n, c];
                var ret = new List<int>[n];
                for (int i = 0; i < n; i++)
                {
                    ret[i] = new List<int>();
                }

                int a = 1;
                for (int i = 0; i < n; i++)
                for (int j = 0; j < n; j++)
                {
                    if (i >= j) continue;
                    ret[i].Add(a);
                    ret[j].Add(a);
                    a++;
                }

                for (int i = 0; i < n; i++)
                {
                    Console.WriteLine(c + " " + string.Join(" ", ret[i]));
                }
                return;
            }

            Console.WriteLine("No");
        }
    }

    // libs ----------
    

    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 18384
fn main() {
    let n: u8 = input();
    koch(n, 0.0, 0.0, 100.0, 0.0);
    println!("100.00000000 0.00000000");
}

fn input() -> u8 {
    let mut buf = String::new();
    let stdin = std::io::stdin();
    stdin.read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

fn koch(n: u8, x1: f64, y1: f64, x2: f64, y2: f64) {
    if n == 0 {
        println!("{:.8} {:.8}", x1, y1);
        return
    }

    let sx = (2. * x1 + 1. * x2) / 3.;
    let sy = (2. * y1 + 1. * y2) / 3.;

    let tx = (x1 + 2. * x2) / 3.;
    let ty = (y1 + 2. * y2) / 3.;

    let f = std::f64::consts::FRAC_PI_3;
    let ux = (tx - sx) * f.cos() - (ty - sy) * f.sin() + sx;
    let uy = (tx - sx) * f.sin() + (ty - sy) * f.cos() + sy;

    koch(n - 1, x1, y1, sx, sy);
    koch(n - 1, sx, sy, ux, uy);
    koch(n - 1, ux, uy, tx, ty);
    koch(n - 1, tx, ty, x2, y2);
}



Measured memory_bytes: 5044
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pll;
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define pb push_back
#define yes(a) printf(a ? "yes\n" : "no\n")
#define Yes(a) printf(a ? "Yes\n" : "No\n")
#define YES(a) printf(a ? "YES\n" : "NO\n") 
const long double PI = acos(-1);
const long long INF = (1 << 30);
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}


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

  ll n;
  cin >> n;
  vector<ll> a(n);
  ll x[n][15], y[n][15];
  for(ll i = 0; i < n; i++){
    cin >> a[i];
    for(ll j = 0; j < a[i]; j++){
      cin >> x[i][j] >> y[i][j];
      x[i][j]--;
    }
  }

  ll ans = 0;
  for(ll bit = 0; bit < (1 << n); bit++){
    ll cnt = 0;
    bool ok = true;
    for(ll i = 0; i < n; i++){
      if(bit & (1 << i)){
        cnt++;
        for(ll j = 0; j < a[i]; j++){
          if(bit & (1 << x[i][j])){
            if(y[i][j] == 0) {
              ok = false;
            }
          }else{
            if(y[i][j] == 1){
              ok = false;
            }
          }
        }
      }
    }
    if(ok) ans = max(ans, cnt);
  }
  cout << ans << endl;
  return 0;
}

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

#define W_MAX 10
#define T_MAX 1000

int main(void) {
  char W[W_MAX];
  char T[T_MAX];
  char END[12] = "END_OF_TEXT";
  int cnt = 0;

  scanf("%s", W);

  for(int i=0; W[i] != '\0'; ++i) {
    W[i] = toupper(W[i]);
  }

  scanf("%s", T);

  while(1) {

    if(strcmp(T, END) == 0) {
      break;
    }

    for(int i=0; T[i] != '\0'; ++i) {
      T[i] = toupper(T[i]);
    }

    if(strcmp(T, W) == 0) {
      cnt++;
    }

    scanf("%s", T);
  }

  printf("%d\n", cnt);

  return 0;
}



Measured memory_bytes: 2116
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef pair<int, int> P;

char change(char c, int n){
    int tmp = 0;
    if('a' <= c && c <= 'z'){
        tmp = c - 'a';
    }else{
        tmp = 26 + c - 'A'; 
    }
    tmp = (tmp - n + 52) % 52;
    if(0 <= tmp && tmp < 26) return 'a' + tmp;
    return 'A' + tmp - 26;
}

signed main(){
    int n;
    while(1){
        cin >> n;
        if(n == 0) break;
        vector<int> k(n);
        rep(i, 0, n) cin >> k[i];
        string s, t = "";
        cin >> s;
        rep(i, 0, s.size()){
            int id = i % n;
            t += change(s[i], k[id]);
        }
        cout << t << endl;
    }
}

Measured memory_bytes: 3192
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
	int n;
	scanf("%d",&n);
	int r,sum=0,x;
	x=n;
	if((n>=100)&&(n<=999)){
		while(n){
			r=n%10;
			n=n/10;
			sum=sum*10+r;
		}
		if(x==sum)
		printf("Yes");
		else 
		printf("No");
	}
	
}

Measured memory_bytes: 256
# n
# a1 a2 ... an

n = gets.to_i
array_a_temp = gets.split
array_a = []

array_a_temp.each do |a|
  array_a << a.to_i
end
array_a.sort!
array_a.reverse!

alice = 0
bob = 0
array_a.each_with_index do |a, i|
  if i.even?
    alice += a
  else
    bob += a
  end
end

puts alice - bob



Measured memory_bytes: 14216
import java.io.*;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Twinkle little = new Twinkle();
        little.star(1, in, out);
        out.close();


    }
static class Twinkle {
        public void star(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int polygon [] = new int[n];
            int max =Integer.MIN_VALUE;
            int sum=0;
            for (int i = 0; i <n ; i++) {
                polygon[i] = in.nextInt();
                sum+=polygon[i];
                if(max<polygon[i]) max =polygon[i];
            }


            if(sum-max>max )
                System.out.println("Yes");
            else
                System.out.println("No");
}
}
  


    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
      public   String nextLine()
        {
            String str = "";
            try
            {
                str = reader.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public boolean hasNext() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    String line = reader.readLine();
                    if (line == null) {
                        return false;
                    }
                    tokenizer = new StringTokenizer(line);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return true;
        }
    }
}


Measured memory_bytes: 23508
#include <bits/stdc++.h>
using namespace std;
char s[1010][1010];
struct node{
    int h,w,v;
};
int dh[4]={0,0,1,-1};
int dw[4]={1,-1,0,0};
int vis[1010][1010];
int main()
{
    int h,w,ch,cw,eh,ew;
    cin>>h>>w>>ch>>cw>>eh>>ew;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            cin>>s[i][j];
            if(s[i][j]=='#')vis[i][j]=1;
        }
    }
    deque<node>dq;
    dq.push_front(node{ch,cw,0});
    vis[ch][cw]=1;
    int ans=1e9;
    while(!dq.empty()){
        node te=dq.front();dq.pop_front();
        //cout<<te.h<<" "<<te.w<<" "<<te.v<<endl;
        if(te.h==eh&&te.w==ew){
            ans=te.v;
            break;
        }
        vis[te.h][te.w]=1;
        for(int i=0;i<4;i++){
            int _h=dh[i]+te.h;
            int _w=dw[i]+te.w;
            if(_h>=1&&_h<=h&&_w>=1&&_w<=w&&!vis[_h][_w]){
                //vis[_h][_w]=1;
                //cout<<"  "<<_h<<" "<<_w<<endl;
                dq.push_front(node{_h,_w,te.v});
            }
        }
        for(int i=-2;i<=2;i++){
            for(int j=-2;j<=2;j++){
                int _h=te.h+i;
                int _w=te.w+j;
                if(i!=0||j!=0){
                    if(_h>=1&&_h<=h&&_w>=1&&_w<=w&&!vis[_h][_w]){
                        //vis[_h][_w]=1;
                        dq.push_back(node{_h,_w,te.v+1});
                    }
                }
            }
        }
    }
    if(ans==1e9)cout<<-1;
    else cout<<ans;
    return 0;
}

Measured memory_bytes: 14084
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

ll fact[200000], invFact[200000]; 

long long power(long long x, long long c) {
    if(c==0) return 1;
    if(c==1) return x;
    if (c%2==1) return (power( (x*x)%MOD, c/2)*x)%MOD;
    else return power( (x*x)%MOD, c/2)%MOD;
}

void make_combT(ll n){
    fact[0]=1;
    rep1(i,n) fact[i]= fact[i-1]*i%MOD;
    
    invFact[n] = power(fact[n],MOD-2);
    rrep(i,n-1) invFact[i] = invFact[i+1] * (i+1) %MOD;
}

ll comb(ll n, ll m){
    if(n<m||n<0||m<0) return 0;
    return (fact[n] * invFact[m] %MOD) * invFact[n-m] %MOD;
}

ll hcomb(ll n, ll m){
    if(n==0&&m==0) return 1;
    return comb(n+m-1,m);
}

int visit[100009];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;
    cin>>N;
    N++;
    int l,r;
    rep1(i,N){
        int x; cin>>x;
        if(visit[x]){
            l = visit[x];
            r = i;
        }else{
            visit[x]=i;
        }
    }
    
    make_combT(100009);
    int len = N - (r-l+1);
    rep1(k,N){
        ll c = comb(N,k);
        ll a = comb(len,k-1);
        c = (MOD+c-a)%MOD;
        cout1(c);
    }
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;

#define rep(i, a, b) for(auto i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define PB push_back

struct edge{int to;};
using graph = vector<vector<edge>>;

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

  int k, a, b;
  cin >> k >> a >> b;
  if (a % k == 0 or b % k == 0) {
    cout << "OK" << '\n';
  } else if (a / k != b / k) {
    cout << "OK" << '\n';
  } else {
    cout << "NG" << '\n';
  }
}


Measured memory_bytes: 3652
import sys
sys.setrecursionlimit(200000)

H,W = map(int,input().split(' '))
S = []
for i in [0]*H:
	l = input()
	S.append([1 if x == '#' else -1 for x in l])

bk = 0
wh = 0
def check(S,x,y):
	global bk
	global wh
	if S[y][x] == 0:
		return
	if S[y][x] == 1:
		bk += 1
		S[y][x]=0
		if 0 < y and S[y-1][x] == -1:
			check(S,x,y-1)
		if 0 < x and S[y][x-1] == -1:
			check(S,x-1,y)
		if y < H-1 and S[y+1][x] == -1:
			check(S,x,y+1)
		if x < W-1 and S[y][x+1] == -1:
			check(S,x+1,y)
		return
	if S[y][x] == -1:
		wh += 1
		S[y][x]=0
		if 0 < y and S[y-1][x] == 1:
			check(S,x,y-1)
		if 0 < x and S[y][x-1] == 1:
			check(S,x-1,y)
		if y < H-1 and S[y+1][x] == 1:
			check(S,x,y+1)
		if x < W-1 and S[y][x+1] == 1:
			check(S,x+1,y)
		return

cnt = 0
for y in range(H):
	for x in range(W):
		if S[y][x] == 1:
			check(S,x,y)
			cnt += wh*bk
			wh = 0
			bk = 0
print(cnt)




Measured memory_bytes: 138596
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using db = double;
using pll = pair < ll, ll >;
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
    cerr << name << " : " << arg1 << std :: 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...);
}
#else
#define trace(...)
#endif
 
#define pb push_back
#define mp make_pair
#define fastIo() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)
 
const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;
 
int main(){   
    ll n; cin >> n;
    ll a[n];
    ll comfort = 0;
    map<ll,ll>cnt;
    ll cur = 0;
    for(ll i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a, a + n, greater<ll>());
    comfort += a[cur++];
    for(ll i = 2; i < n; i++) {
        if(cnt[cur] < 2) {
            cnt[cur]++;
            comfort += a[cur];
        } else {
            cur++;
            comfort += a[cur];
            cnt[cur]++;
        }
    }
    cout << comfort << endl;
}


Measured memory_bytes: 11408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
/*--------------------------------------------*/

int main(){
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N;
    cin >> N;

    vector<ll> a(N);
    ll tmp = 1;
    ll ans = 0;
    rep(i,N){
        cin >> a[i];
        if(a[i] == tmp){
            tmp++;
        }else{
            ans++;
        }
    }

    if(tmp == 1){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }


    
}

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

int main() {
	
	ll a, b, k; cin >> a >> b >> k;
	map<ll, ll> mp;
	for (int i = a; i < min(b, a + k); i++) {
		mp[i] = 1;
	}
	for (int i = max(a, b - k + 1); i <= b; i++) {
		mp[i] = 1;
	}
	for (auto u : mp) {
		cout << u.first << endl;
	}
    return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define N 100010
typedef long long ll;
ll n,m,a[N],f[N],r[N],tp;
void dfs(ll x,ll v){
	ll p=upper_bound(a+1,a+tp+1,x)-a-1;
	if(!p){
		r[1]+=v;
		r[x+1]-=v;
		return;
	}
	f[p]+=v*(x/a[p]);
	dfs(x%a[p],v);
}
int main(){
	cin>>n>>m;
	a[++tp]=n;
	for(int i=1;i<=m;i++){
		ll x;
		cin>>x;
		while(x<=a[tp]&&tp)tp--;
		a[++tp]=x;
	}
	f[tp]=1;
	for(int i=tp-1;i;i--){
		f[i]+=f[i+1]*(a[i+1]/a[i]);
		dfs(a[i+1]%a[i],f[i+1]);
	}
	r[1]+=f[1];
	r[a[1]+1]-=f[1];
	for(int i=1;i<=n;i++)
		r[i]+=r[i-1];
	for(int i=1;i<=n;i++)
		cout<<r[i]<<'\n';
}

Measured memory_bytes: 4096
MOD = 998244353

n, s = map(int, input().split())
As = list(map(int, input().split()))

dp = [0] * (s+2)

dp[0] = 1

for a in As:
    for i in range(s+1, -1, -1):
        if i - a < 0:continue
        dp[i] += dp[i-a] * (MOD+1) // 2
        dp[i] %= MOD

print(dp[s] * pow(2, n, MOD) % MOD)

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

using namespace std;

int main()
{
	int t;
	t=1;
	while(t--)
	{
   string s;
   cin>>s;
   
   int i,j,k,n;
   
   n=s.length();	
	
	j=0;
	k=0;
	for(i=0;i<n;i++)
	{
		
		if(s[i]=='R')
		{
			j++;
			k=max(k,j);
			
		}
		else
		{
			k=max(k,j);
			
			j=0;
			
		}
		
		
	}
	
	
	cout<<k<<endl;
	}



}


Measured memory_bytes: 3624
N, M = map(int, input().split())

price = list()
for _ in range(N):
    a, b = map(int, input().split())
    price.append((a, b))

p = 0
q = 0
for a, b in sorted(price):
    for i in range(b):
        p += a
        q += 1
        if q == M:
            break
    if q == M:
        break

print(p)

Measured memory_bytes: 17676
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <utility>

using namespace std;

struct UF {
    vector<int> data;

    UF(int n) {
        data.resize(n, -1);
    }

    int root(int i) {
        return data[i] < 0 ? i : data[i] = root(data[i]);
    }

    int size(int i) {
        i = root(i);
        return -data[i];
    }

    void unite(int x, int y) {
        x = root(x), y = root(y);
        if (x == y) return;
        if (size(x) < size(y)) swap(x, y);

        data[x] += data[y];
        data[y] = x;
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }
};

int N, K, L;

int main()
{
    cin >> N >> K >> L;

    UF a(N), b(N);

    for (int i=0;i<K;++i) {
        int p, q; cin >> p >> q;
        --p, --q;
        a.unite(p, q);
    }

    for (int i=0;i<L;++i) {
        int p, q; cin >> p >> q;
        --p, --q;
        b.unite(p, q);
    }

    map<pair<int, int>, int> m;

    for (int i=0;i<N;++i) {
        pair<int, int> p(a.root(i), b.root(i));
        m[p] += 1;
    }

    for (int i=0;i<N;++i) {
        if (i) cout << ' ';
        cout << m[make_pair(a.root(i), b.root(i))];
    }
    cout << endl;
}


Measured memory_bytes: 13568
package main

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

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt() int {
  n, _ := strconv.Atoi(NextLine())
  return n
}
func NextIntVec() []int {
  L := strings.Split(NextLine(), " ")
  N := make([]int, len(L))
  for i := range N {
    N[i], _ = strconv.Atoi(L[i])
  }
  return N
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func WriteIntVec(A []int) {
  S := make([]string, len(A))
  for i, a := range A {
    S[i] = strconv.Itoa(a)
  }
  Write(strings.Join(S, " "))
}
func Output() {
  _ = writer.Flush()
}

func Max(x, y int) int {
  if x < y { return y }
  return x
}
func Min(x, y int) int {
  if x < y { return x }
  return y
}
func MinVec(A []int) int {
  min := A[0]
  for _, a := range A {
    min = Min(a, min)
  }
  return min
}

func main() {
  NK := NextIntVec()
  N, K := NK[0], NK[1]
  H := NextIntVec()
  H = append([]int{0}, H...)
  DP := make([][]int, N - K + 1)
  for i := range DP {
    DP[i] = make([]int, N + 1)
    for j := range DP[i] {
      DP[i][j] = int(1e9 + 7) * N
    }
  }
  DP[0][0] = 0
  for i := 1; i <= N - K; i++ {
    for j := 1; j <= K + i; j++ {
      for k := 0; k < j; k++ {
        c := DP[i - 1][k] + Max(H[j] - H[k], 0)
        DP[i][j] = Min(c, DP[i][j])
      }
    }
  }
  Write(MinVec(DP[N - K]))
  Output()
}

Measured memory_bytes: 1536
n=int(input())
a=list(map(int,input().split()))

hu=0
sei=0
ans=0
ahu=[]
asei=[]

for i in range(1,n+1):
  a[i-1]-=i
  ans+=abs(a[i-1])
  if a[i-1]<0:
    hu+=1
    ahu.append(abs(a[i-1]))
  elif a[i-1]>0:
    asei.append(a[i-1])
    sei+=1
zero=n-sei-hu
now=0
#print(ahu)
#print(asei)
asei.sort()
ahu.sort()

if sei < hu and sei+zero <hu:
  sei+=zero
  for i in range((hu-sei)//2+1):
    ans-=(ahu[i]-now)*(hu-sei-2*i)
    now=ahu[i]
    
elif sei > hu and sei > hu+zero:
  hu+=zero
  for i in range((sei-hu)//2+1):
    ans-=(asei[i]-now)*(sei-hu-2*i)
    now=asei[i]

print(ans)



Measured memory_bytes: 30916
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  const Int INF = 1e18;

  Int n;
  cin>>n;
  vector<Int> as(n);
  for(Int i=0;i<n;i++) cin>>as[i];

  vector<map<Int, Int>> dp(2);
  auto touch=[&](auto &m,Int k){if(!m.count(k)) m[k]=-INF;};

  Int len=n;
  dp[0][0]=0;
  for(Int a:as){
    vector<map<Int, Int>> nx(2);
    for(Int u=0;u<2;u++){
      for(auto [k, v]:dp[u]){
        if(k+(len+1)/2<n/2) continue;
        // use
        if(u==0){
          touch(nx[1],k+1);
          chmax(nx[1][k+1],v+a);
        }
        // not
        touch(nx[0],k);
        chmax(nx[0][k],v);
      }
    }
    swap(dp,nx);
    len--;
  }

  touch(dp[0],n/2);
  touch(dp[1],n/2);
  cout<<max(dp[0][n/2],dp[1][n/2])<<endl;
  return 0;
}


Measured memory_bytes: 4780
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

int main(){
  int cnt=0;
  string w, t;
  cin>>w;
  while(1){
    cin>>t;
    if(t=="END_OF_TEXT") break;
    transform(t.begin(), t.end(), t.begin(), ::tolower);
    if(t==w) cnt++;
  }
  cout<<cnt<<endl;

  return 0;
}

Measured memory_bytes: 3164