akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <functional>
#include <vector>
using namespace std;

void recursive_comb(int* indexes, int s, int rest, std::function<void(int*)> f) {
	if (rest == 0) {
		f(indexes);
	}
	else {
		if (s < 0) return;
		recursive_comb(indexes, s - 1, rest, f);
		indexes[rest - 1] = s;
		recursive_comb(indexes, s - 1, rest - 1, f);
	}
}

void foreach_comb(int n, int k, std::function<void(int*)> f) {
	vector<int> indexes(k);
	recursive_comb(&(indexes[0]), n - 1, k, f);
}

int main()
{
	auto& in = cin;

    int N;
    in >> N;
	if (N < 3) {
		cout << 0;
		return 0;
	}
    vector<int> Ls(N);
    for (int i = 0; i < N; ++i)
        in >> Ls[i];

	int count = 0;
	foreach_comb(N, 3, [&](int* indexes) {
		int L0 = Ls[indexes[0]];
		int L1 = Ls[indexes[1]];
		int L2 = Ls[indexes[2]];
		if (L0 == L1 || L0 == L2 || L1 == L2)
			return;
		if ((L0 < (L1 + L2)) && (L1 < (L2 + L0)) && (L2 < (L0 + L1))) {
			++count;
		}
	});
	cout << count;

	return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n-1; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const ll INF = 1000000000;

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> p(n), v;
    REP(i,n) {
        cin >> p[i];
        if(i+1==p[i]) {
            v.push_back(i);
        }
    }
    int l = v.size();
    ll ans = 0;
    REP(i,l) {
        if(i<l-1 && v[i+1]-v[i]==1) {
            ++ ans;
            ++ i;
        }
        else ++ans;
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
    /*
    Vil 1, 2, 3, 4, ... N
    Road 1, 2, 3, 4, ... M
    */
    
    int N, M; cin >> N >> M;
    vector< vector<int> > Area(N, vector<int>(N,0));
    
    for(int i = 0; i < M; i++){
        int a, b; cin >> a >> b;
        a = a-1;
        b = b-1;
        Area[a][b] += 1;
        Area[b][a] += 1;
    }
    
    for(auto &fd : Area){
        int count = 0;
        for(int i = 0; i < fd.size(); i++){
            count += fd[i];
        }
        cout << count << endl;
    }
    
    
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

#define M_PI 3.14159265358979323846

double dtor(int d){
	return d / 180.0 * M_PI;
}

int main(void){
	double x = 0.0, y = 0.0;
	int d = 0,a = 0, an = 90;

	while(true){
		scanf("%d,%d", &d, &a);
		if(d == 0 && a == 0){ break; }
		x += d * cos(dtor(an));
		y += d * sin(dtor(an));
		an -= a;
	}
	printf("%d\n%d\n", (int)x, (int)y);
	return 0;
}

Measured memory_bytes: 0
#pragma GCC optimize ("O3")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

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


	string S;
	cin >> S;

	rep(i, S.size()) {
		if (S[i] == '?') S[i] = 'D';
	}
	co(S);

	Would you please return 0;
}

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

int main()
{
	int A, B;
	cin >> A >> B;
	if (B > A) {
		cout << "0" << endl;
		return 0;
	}

	if (A - 2 * B > 0) {
		cout << A - 2 * B << endl;
	}
	else
	{
		cout << "0" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define all(vec) vec.begin(),vec.end()
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
const ll INF=1LL<<30;
const ll LINF=1LL<<60;
const double eps=1e-9;
const ll MOD=1000000007LL;
template<typename T>void chmin(T &a,T b){a=min(a,b);};
template<typename T>void chmax(T &a,T b){a=max(a,b);};
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V>typename enable_if<is_class<T>::value==0>::type fill_v(T& t,const V& v){t=v;}
template<typename T,typename V>typename enable_if<is_class<T>::value!=0>::type fill_v(T& t,const V& v){for(auto &e:t)fill_v(e,v);};
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
    int n;cin>>n;
    string s;cin>>s;
    vector<ll> co(26);
    for(int i=0;i<n;i++){
        co[s[i]-'a']++;
    }
    ll res=1;
    for(int i=0;i<26;i++){
        res*=co[i]+1LL;
        res%=MOD;
    }
    cout<<res-1LL<<endl;
}

Measured memory_bytes: 512
s = gets.chomp.split('')
odd = []
even = []
(0..s.length-1).each do |n|
    if n%2 ==0
        odd << s[n]
    else
        even << s[n]
    end
end

if odd.include?('L') || even.include?('R')
    puts 'No'
else 
    puts 'Yes'
end

Measured memory_bytes: 1916
#include<bits/stdc++.h>
using namespace std;
#define ll long long
string s;
ll num,t=1,ans;
ll cnt[2200];
int main()
{
	cnt[0]=1;
	cin>>s;
	for(int i=s.size()-1;i>=0;i--)
	{
		num=(num+(s[i]-'0')*t)%2019;
		ans+=cnt[num];
		cnt[num]++;
		t=t*10%2019;
	}
	cout<<ans;
    return 0;
}

Measured memory_bytes: 3776
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	x, y := intScanner(), intScanner()
	fmt.Println(x + y/2)
}


Measured memory_bytes: 1772
#include<bits/stdc++.h>
using namespace std;
long long int n,k,res=10000000000;
int main(){
	cin>>n>>k;
	vector<long long  int> arb(n-1);
	for(long long int i=0; i<n; i++){
		cin>>arb[i];
	}
	sort(arb.begin(),arb.begin()+n);
	for(long long int i=0;i<(n-k+1);i++){
	   long long int sum=arb[i+k-1]-arb[i];
		if(sum<=res)
			res=arb[i+k-1]-arb[i];
	}
	cout<<res<<'\n';
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
int main(void){   // Your code here!       
    double r,a,b;   
    scanf("%lf %lf %if",&r, &a, &b);       
    a=3.141592653589*r*r;   
    b=3.141592653589*2*r;   
    printf("%.6lf %.6lf\n", a, b);   
    return 0; }


Measured memory_bytes: 2136
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		//データ入力の準備
		Scanner sc = new Scanner(System.in);
		
		while (true){
			int h = sc.nextInt();
			int w = sc.nextInt();
			
			if (h == 0 && w == 0){
				break;
			}
			
			//結果を出力
			print(h, w);
		}
	}
	
	
	private static void print(int h, int w){
		for (int i = 0; i < h; i++){
			for (int j = 0; j < w; j++){
				if ((i + j) % 2 == 0){
					System.out.print("#");
				}else{
					System.out.print(".");
				}
			}
			System.out.print("\n");
		}
		System.out.print("\n");
	}
}


Measured memory_bytes: 37884
dataset = input().split(" ")

n = int(dataset[0])
m = int(dataset[1])
l = int(dataset[2])

A = []
for i in range(n):
    buf = input().split(" ")
    tmp = []
    for j in range(m):
        tmp.append(int(buf[j]))
    A.append(tmp)

B = []
for i in range(m):
    buf = input().split(" ")
    tmp = []
    for j in range(l):
        tmp.append(int(buf[j]))
    B.append(tmp)


C = []
for i in range(n):
    for j in range(l):
        sum = 0
        for k in range(m):
            sum += A[i][k] * B[k][j]
        C.append(sum)


for i in range(n):
    for j in range(l):
        print("%d" % (C[i*l + j]), end="")
        if j < l-1:
            print(" ", end="")
    print()



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

int main()
{
    int n,i,j,k;
    cin>>n>>k;
    int cost[n+1];
    int dp[n+1];;
    //cout<<dp[0];
    for(i = 0; i < n ; i++)
        cin>>cost[i];

    dp[0]=0;
    for(i = 1; i <= n; i++)dp[i]=INT_MAX;

    for(i = 1; i < n; i++)
    {
        for(j = 1; j <= k; j++)
        {
            if(i-j < 0)
                break;
            dp[i] = min(dp[i],abs(cost[i]-cost[i-j])+dp[i-j]);
            //finding the minimum cost between positions i to (i-1) to (i-k)
        }

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


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
typedef long long ll;
ll mod_pow(ll, ll, ll);
ll mod_fact(ll, ll);
ll mod_inv(ll, ll);
//
int main(){
    int d, g;
    cin >> d >> g;
    int p[d], b[d];
    for(int i = 0; i < d; i++){
        cin >> p[i] >> b[i];
    }
    int mn = INT_MAX;
    for(int i = 0; i < (1 << d); i++){
        int sum = 0;
        int num = 0;
        for(int j = 0; j < d; j++){
            if(i >> j & 1){
                sum += p[j] * 100 * (j + 1) + b[j];
                num += p[j];
            }
        }
        if(sum >= g) mn = min(mn, num);
        {
            int mx = -1;
            for(int j = 0; j < d; j++){
                if(!(i >> j & 1)) mx = j;
            }
            for(int j = 0; j < p[mx]; j++){
                sum += 100 * (mx + 1);
                num++;
                if(sum >= g){
                    mn = min(mn, num);
                }
            }
        }
    }
    cout << mn;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let mut a: Vec<i64> = (0..n).map(|_| read()).collect();
    a.sort();

    let mut x = a[n-1];
    let mut y = a[0];
    for i in 1..n-1 {
        if a[i] <= 0 {
            x -= a[i];
        } else {
            y -= a[i];
        }
    }
    println!("{}", x-y);
    x = a[n-1];
    y = a[0];
    for i in 1..n-1 {
        if a[i] <= 0 {
            println!("{} {}", x, a[i]);
            x -= a[i];
        } else {
            println!("{} {}", y, a[i]);
            y -= a[i];
        }
    }
    println!("{} {}", x, y);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 6012
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner input=new Scanner(System.in);
		 int x=input.nextInt();
		 if(x>=0 && x<=1) {
			 if(x==0)
				 System.out.println(1);
			 if(x==1)
				 System.out.println(0);
		 }

  }
}


Measured memory_bytes: 35616
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AISing2020C
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] ans = new int[N];
            for (int x = 1; x <= 100; x++)
            {
                for (int y = 1; y <= 100; y++)
                {
                    for (int z = 1; z <= 100; z++)
                    {
                        int n = x * x + y * y + z * z + x * y + y * z + z * x;
                        if (n <= N)
                        {
                            ans[n - 1] += 1;
                        }
                    }
                }
            }
            for (int i = 0; i < N; i++)
            {
                Console.WriteLine(ans[i]);
            }
        }
    }
}


Measured memory_bytes: 27484
import java.util.*;

public class Main {
    public void main(Scanner sc) {
        int n = sc.nextInt();
        String s1 = sc.next();
        String s2 = sc.next();

        long mod = 1000000007L;

        long ans;
        boolean beforeTate;
        int start;
        if (s1.charAt(0) == s2.charAt(0)) {
            ans = 3;
            beforeTate = true;
            start = 1;
        } else {
            ans = 6;
            beforeTate = false;
            start = 2;
        }

        for (int i = start; i < n; i++) {
            if (s1.charAt(i) == s2.charAt(i)) {
                ans *= (beforeTate ? 2 : 1);
                beforeTate = true;
            } else {
                ans *= (beforeTate ? 2 : 3);
                beforeTate = false;
                i++;
            }
            ans %= mod;
        }

        System.out.println(ans);
    }

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


Measured memory_bytes: 23764
x,y,a,b,c = map(int, input().split())
A = list(map(int, input().split())) 
B = list(map(int, input().split())) 
C = list(map(int, input().split())) 

A.sort()
B.sort()
C.sort(reverse=True)

X = A[len(A)-x:]
Y = B[len(B)-y:]

#print(X,Y,C)

xi = 0
yi = 0
ci = 0
for ci in range(c):
    #print(ci,xi,yi)
    if xi < len(X) and yi < len(Y):
        if C[ci] <= X[xi] and C[ci] <= Y[yi]:
            break
        
        if X[xi] < Y[yi]:
            if C[ci] > X[xi]:
                X[xi] = C[ci]
                xi = xi + 1
        else:
            if C[ci] > Y[yi]:
                Y[yi] = C[ci]
                yi = yi + 1
                
    elif xi < len(X):
        if C[ci] <= X[xi]:
            break
        
        if C[ci] > X[xi]:
            X[xi] = C[ci]
            xi = xi + 1
        
    elif yi < len(Y):
        if C[ci] <= Y[yi]:
            break
        
        if C[ci] > Y[yi]:
            Y[yi] = C[ci]
            yi = yi + 1
            
    else:
        break

print(sum(X)+sum(Y))

Measured memory_bytes: 23328
#include<stdio.h>

int main(){
/*	unsigned long long int l;
	unsigned long long int lsan;
	scanf("%lld", &lsan);
	l = lsan*lsan*lsan;
	double L = (double)(l/27);
//	L = L/3;
*/
	int l;
	scanf("%d", &l);
	double lper3=l*1.0/3;
	
	printf("%.12lf\n", lper3*lper3*lper3);
	return 0;
}

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    string s;cin>>s;
    int x,y;
    x=0;y=s.size()-1;
    for (int i=0;i<s.size();i++){
        if (s[i]=='A'){
            x=i;break;
        }
    }for (int i=s.size()-1;i>=0;i--){
        if (s[i]=='Z'){
            y=i;break;
        }
    }cout<<y-x+1;
    return 0;
}

Measured memory_bytes: 720
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]

n, m = MAP()
a = LIST()
s = sum(a)
a.sort(reverse=True)
t = s / 4 / m
if a[m - 1] >= t:
    print('Yes')
else:
    print('No')

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

#define ll long long 

int main(){
	int n;
	cin>>n;
	int arr[n];
	for(int i = 0; i<n; i++)
		cin>>arr[i];
	int dp[n+1]={};
	dp[1] = abs(arr[1] - arr[0]);
	for(int i = 2; i<n; i++){
		dp[i] = min(dp[i-1] + abs(arr[i] - arr[i-1]), dp[i-2] + abs(arr[i] -arr[i-2]));
		}
	cout<<dp[n-1]<<endl;
	return 0;
	}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main()
{
    int n;

    while (cin >> n, n) {
        int a, b;

        a = b = 0;
        for (int i = 0; i < n; i++) {
            int t1, t2;

            cin >> t1 >> t2;
            if (t1 > t2)
                a += t1 + t2;
            else if (t1 < t2)
                b += t1 + t2;
            else {
                a += t1;
                b += t2;
            }
        }
        cout << a << " " << b << endl;
    }

    return 0;
}

Measured memory_bytes: 1160
n = (int)(input())

x = []
y = []
h = []

for _ in range(n):
    a, b, c = map(int, input().split())
    x.append(a)
    y.append(b)
    h.append(c)

f = False
for i in range(0, 100+1):
    for j in range(0, 100+1):
        for k in range(n):
            if h[k] != 0:
                ch = h[k] + abs(i-x[k]) + abs(j-y[k])
                break
        if all(max(ch-abs(i-x[k]) - abs(j-y[k]), 0) == h[k] for k in range(n)):
            print(i, j, ch)
            exit()


Measured memory_bytes: 3064
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


n, m, k = li()
MOD = 10**9 + 7

ans = 0


# nの逆元のリスト
def inv_mod(n: int, mod: int) -> list:
    inv = [0, 1]
    for i in range(2, n + 1):
        inv.append(mod - ((mod // i) * inv[mod % i]) % mod)
    return inv


# nの階乗のリスト
def fact(n: int, mod: int) -> list:
    fac = [1, 1]
    res = 1
    for i in range(2, n + 1):
        res = res * i % mod
        fac.append(res)
    return fac


# nの階乗の逆元のリスト
def fact_inv(n: int, inv: list, mod: int) -> list:
    facInv = [1, 1]
    for i in range(2, n + 1):
        facInv.append(facInv[i - 1] * inv[i] % mod)
    return facInv


# 二項係数
def nCr(n: int, r: int, mod: int, fac: list, facInv: list) -> int:
    if not (0 <= r and r <= n):
        return 0

    return ((fac[n] * facInv[r]) % mod) * facInv[n - r] % mod


def onedim(width: int, depth: int, mod: int):
    ret = 0
    for d in range(width):
        ret += depth**2 * (width - d) * d * nCr(m*n-2, k-2, mod, fac, facInv)
        ret %= mod

    return ret

fac = fact(n*m+1, MOD)
facInv = fact_inv(n*m, inv_mod(m*n+1, MOD), MOD)

print((onedim(n, m, MOD) + onedim(m, n, MOD)) % MOD)

Measured memory_bytes: 26828
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

vector<pii> v[10005];
int c[10005];

int main()
{ios_base::sync_with_stdio(false);
int n,m,r;
cin>>n>>m>>r;
rep(i,1,n)c[i]=-1;
rep(i,1,r)
{
	int x;
	cin>>x;
	c[x]=i-1;
}
while(m--)
{
	int a,b,c;
	cin>>a>>b>>c;
	v[a].pb(mp(b,c));
	v[b].pb(mp(a,c));
}
int ans=1e9+7;
rep(i,1,n)
{
	if(c[i]==-1)continue;
	priority_queue<pair<int,pii> > q;
	q.push(mp(0,mp(i,(1<<c[i]))));
	int d[205][1<<9];
	rep(ii,1,n)rep(j,0,(1<<9)-1)d[ii][j]=1e9+7;
	d[i][(1<<c[i])]=0;
	while(!q.empty())
	{
		pair<ll,pii> p=q.top();
		q.pop();
		int at=p.ss.ff,msk=p.ss.ss;
		ll dd=-p.ff;
		if(dd>d[at][msk])continue;
		tr(v[at],it)
		{
			int to=it->ff;
			ll len=it->ss;
			int msk1=msk;
			if(c[to]>-1)msk1|=(1<<c[to]);
			if(d[at][msk]+len<d[to][msk1])
			{
				d[to][msk1]=d[at][msk]+len;
				q.push(mp(-d[to][msk1],mp(to,msk1)));
			}
		}
	}
	rep(ii,1,n)ans=min(ans,d[ii][(1<<r)-1]);
}
ol(ans);
return 0;
}



Measured memory_bytes: 3812
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ll long long int
#define MOD 1e9+7
#define start int t;cin>>t;while(t--)
#define debug(x) cout<<"#"<<x<<"\n"
#define en "\n"
#define vi vector<int>
#define vli vector<long long int>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define print_all(x) for(auto t:x) cout<<t<<" "; cout<<en
#define F first
#define S second
using namespace std;

vector<ll> printDivisors(ll n) 
{ 
    vector<ll> v;
    for (ll i=1; i<=sqrt(n); i++) 
    { 
        if (n%i == 0) 
        { 
            if (n/i == i) 
                v.pb(i);
  
            else {
                v.pb(i);
                v.pb(n/i);
            } 
        }
    }
    return v;
} 

bool isEven(string s){
    int len=s.size();
    for(int i=0;i<len/2;i++){
        if(s[i]!=s[i+len/2]){
            return false;
        }
    }
    return true;
}
void solve(){
   int a,b,c;
   cin>>a>>b>>c;
   int maxi=max(a,max(b,c));
   //int mini=min(a,b,c);
   
   cout<<a+b+c-maxi;
}


int main(){
    fast;
    //start{
        solve();
    //}
    return 0;

}



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

int main(){
	long n;cin >> n;
  	vector<long> a(n+1);
  	for(int i=0;i<n;i++){
      	long b;
      	cin >> b;
    	a[b]=i+1;
    }
  	for(int i=1;i<=n;i++){
    	cout << a[i] << " " ;
    }
  	return 0;
}

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

int main()
{
	int k, x;
	cin >> k >> x;

	set<int> st;

	for (int i = x - k + 1; i <= x; i++)
	{
		st.insert(i);
	}

	for (int i = x; i < x + k; i++)
	{
		st.insert(i);
	}

	for (auto &&i : st)
	{
		cout << i << ' ';
	}
	cout << endl;

	return 0;
}

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

using namespace std;

int64_t updateLucusNumber(vector<int64_t> &L, int i) {
    // ベースケース 1
    if (i == 0) {
        L.at(0) = 2;
        return 2;
    }

    // ベースケース 2
    if (i == 1) {
        L.at(1) = 1;
        return 1;
    }

    // 再帰ステップ
    if (L.at(i) == -1) {
        L.at(i) = updateLucusNumber(L, i - 2) + updateLucusNumber(L, i - 1);
    }

    return L.at(i);
}

int main() {
    // input
    int N;
    cin >> N;

    // lucus number
    vector<int64_t> L(N + 1, -1);

    updateLucusNumber(L, N);

    // output
    cout << L.at(N) << endl;
}


Measured memory_bytes: 256
N=int(input())
f=[0]*10000
for i in range(100):
  for j in range(100):
    for k in range(100):
      n=(i+1)**2+(j+1)**2+(k+1)**2+(i+1)*(j+1)+(j+1)*(k+1)+(k+1)*(i+1)  
      if n<=10000:
        f[n-1]+=1
for i in range(N):
  print(f[i])


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

int x=0;
long long int a[150000];
long long int y=9,z=0;
 
void shori(long long int keta,long long int ima,long long int mae,int hantei){
  long long int i,kari,k;
  if(hantei==1){
    for(i=max(mae-1,z);i<=min(mae+1,y);i++){
      kari=ima+pow(10,keta)*i;
      if(keta==0){
        a[x]=kari;
        x++;
      }else{
        shori(keta-1,kari,i,1);
      }
    }
  }else{
    if(keta>=1){
      shori(keta-1,0,0,0);
    }
    if(keta==9){
      k=3;
    }else{
      k=9;
    }
    for(i=1;i<=k;i++){
      kari=pow(10,keta)*i;
      if(keta==0){
        a[x]=kari;
        x++;
      }else{
        shori(keta-1,kari,i,1);
      }
    }
  }
}


int main(){
  int k,ima=0,i;
  cin>>k;
  for(i=0;i<150000;i++){
    a[i]=3234566668;
  }
  shori(9,0,0,0);
  sort(a,a+150000);
  cout<<a[k-1];
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct edge{
    ll to, cost;
};


ll gcd(ll a,ll b){
    if(b == 0){
        return a;
    }else{
        return gcd(b, a%b);
    }
}

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

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

    ll dp[n+1];
    dp[0] = r[1] - r[0];
    ll ans = dp[0];
    for(ll i=1;i<n-1;++i){
        dp[i] = max(dp[i-1] + (r[i+1] - r[i]), r[i+1] - r[i]);
        ans = max(ans, dp[i]);
        //cout<<dp[i]<<endl;
    }
    cout<<ans<<endl;

    return 0;
}


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

int main() {
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n){
        int ai; cin >> ai; ai--;
        a[i] = ai;
    }
    vector<int> b(n);
    rep(i,n){
        b[a[i]]++;
    }

    int64_t cntall = 0;
    rep(i,n){
        int64_t bi = b[i];
        cntall += bi*(bi-1)/2;
    }

    rep(i,n){
        int64_t ansi = cntall;
        ansi -= b[a[i]]-1;
        cout << ansi << endl;
    }
}


Measured memory_bytes: 4096
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n;i++)
using ll = long long;
using namespace std;
int main(){
    ll n; cin>>n;
    for(ll m=1;;m<<=1)
        if((n&m)==0){cout<<m<<endl; return 0;}
}

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

int main(){

  char c[50][51];
  int h, w, cnt[50][50]={};

  cin>>h>>w;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>c[i][j];
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      for(int k=-1;k<=1;k++){
        for(int l=-1;l<=1;l++){
          if(k==0&&l==0) continue;
          if(0<=i+k&&i+k<h&&0<=j+l&&j+l<w){
            if(c[i+k][j+l]=='#') cnt[i][j]++;
          }
        }
      }
    }
  }

  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(c[i][j]=='#') cout<<c[i][j];
      else cout<<cnt[i][j];
    }
    cout<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
/* Written by Filip Hlasek 2017 */
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <iostream>

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

using namespace std;

#define MOD 998244353
#define MAXN 333
int pow2[MAXN];
int f[MAXN];

int X[MAXN], Y[MAXN];

bool done[MAXN][MAXN];

int main(int argc, char *argv[]) {
  pow2[0] = 1;
  REP(i, MAXN - 1) pow2[i + 1] = (pow2[i] * 2) % MOD;
  REP(i, MAXN) f[i] = (pow2[i] - (long long)i * (i - 1) / 2 - i - 1) % MOD;
  // REP(i, 10) printf("%d\n", f[i]);
  int N;
  scanf("%d", &N);
  REP(i, N) scanf("%d%d", X + i, Y + i);

  int ans = f[N];

  REP(i, N) REP(j, i) if (!done[i][j]) {
    vector<int> line;
    line.push_back(i);
    line.push_back(j);
    FOR(k, i + 1, N - 1) {
      int x1 = X[k] - X[i], x2 = X[k] - X[j], y1 = Y[k] - Y[i], y2 = Y[k] - Y[j];
      if (x1 * y2 == y1 * x2) {
        line.push_back(k);
      }
    }
    REP(a, line.size()) REP(b, line.size()) done[line[a]][line[b]] = true;
    ans = (ans - f[line.size()] + MOD) % MOD;
  }
  printf("%d\n", ans);
  return 0;
}

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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const LL mod = 998244353;
string S;
LL dp[200010][3][3];

int solve(){
	set<string> ans{S};
	queue<string> Q; Q.push(S);
	while(!Q.empty()){
		string x = Q.front(); Q.pop();
		repp(i,1,S.size()) if(x[i-1] != x[i]){
			string y = x;
			if(x[i-1] != 'a' && x[i] != 'a') y[i-1] = y[i] = 'a'; 
			else if(x[i-1] != 'b' && x[i] != 'b') y[i-1] = y[i] = 'b';
			else if(x[i-1] != 'c' && x[i] != 'c') y[i-1] = y[i] = 'c';
			if(ans.find(y) == ans.end()){
				Q.push(y);
				ans.insert(y);
			}
		}
	}
	return ans.size();
}

int main(){
	cin >> S;
	int n = S.size();
	if(n < 4){
		cout << solve() << endl;
		return 0;
	}
	int d = 0 , m = S[0] - 'a';
	repp(i,1,n){
		if(S[i-1] != S[i]) ++d;
		m += S[i] - 'a';
	}
	if(d == 0){
		cout << 1 << endl;
		return 0;
	}
	dp[1][0][0] = dp[1][1][1] = dp[1][2][2] = 1;
	repp(i,1,n) repp(j,0,3) repp(k,0,3) repp(l,0,3) if(k != l)
		(dp[i+1][(j+l)%3][l] += dp[i][j][k]) %= mod;
	LL ans = 1 , ans2 = 3 , t = 1;
	repp(i,1,n) (ans *= 3) %= mod;
	repp(i,2,n) (ans2 *= 2) %= mod;
	repp(j,0,3) repp(k,0,3) if((j+k)%3 == m%3) ans += dp[n-1][j][k];
	cout << (ans - ans2 + mod + (d==n-1?1:0)) % mod << endl;
	return 0;
}


Measured memory_bytes: 14596
n, m = gets.split.map(&:to_i)
cond = m.times.map {
  k, *ss = gets.split.map(&:to_i)
  ss.inject(0) {|acc, s| acc | (1 << (s - 1))}
}.zip(gets.split.map(&:to_i))

puts (2 ** n).times.map {|switches|
  cond.all? {|c, p| (switches & c).to_s(2).count("1") % 2 == p}
}.count(true)

Measured memory_bytes: 3836
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main() {
  int n, a;
  cin >> n >> a;
  cout << n * n - a << endl;

  return 0;
}


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

const int maxn=3005;
const int mdn=1000000007;
const int inv2=(mdn+1)>>1;
int n,q;
int a[maxn];
pair<int,int> c[maxn];
long long dp[maxn][maxn];

int main(){
    ios::sync_with_stdio(0);
    cin>>n>>q;
    for(int i=1;i<=n;i++){cin>>a[i];}
    for(int i=1;i<=q;i++){cin>>c[i].first>>c[i].second;}
    for(int i=1;i<=n;i++){for(int j=1;j<=n;j++){dp[i][j]=(a[i]<a[j]);}} 
    for(int i=1;i<=q;i++){
        int u=c[i].first,v=c[i].second;
        long long mean=(dp[u][v]+dp[v][u])*inv2%mdn;
        dp[u][v]=dp[v][u]=mean;
        for(int j=1;j<=n;j++){
            if(j==u||j==v)continue;
            long long m1=(dp[j][u]+dp[j][v])*inv2%mdn;
            dp[j][v]=m1;
            dp[j][u]=m1;
            long long m2=(dp[u][j]+dp[v][j])*inv2%mdn;
            dp[u][j]=m2;
            dp[v][j]=m2;
        }
    }
    long long ans=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<i;j++){
            ans+=dp[i][j];
        }
    }
    long long tot=1;
    for(int i=1;i<=q;i++){tot=(tot<<1)%mdn;}
    cout<<(ans%mdn*tot)%mdn;
    return 0;
}

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

int main(){
int a,b;
cin>> a >> b;
if(a < b){
	cout<< "a < b" <<endl;
}
if(a > b){
	cout<< "a > b" <<endl;
}
if(a == b){
	cout<< "a == b" <<endl;
}
}

Measured memory_bytes: 3068
class SegmentTree:
    def __init__(self, base_array,n , default_value = 0, segfunc = lambda a, b: a + b): #元配列、大きさ、デフォルト値
        self._num = 2 ** (n - 1).bit_length()
        self._seg = [default_value] * 2 * self._num
        self._segfunc = segfunc
        self._ide_ele = default_value
        for i in range(n):
            self._seg[i + self._num - 1] = base_array[i]
        for i in range(self._num - 2, -1, -1):
            self._seg[i] = segfunc(self._seg[2 * i + 1], self._seg[2 * i + 2])


    def update(self, k, x):
        k += self._num - 1
        self._seg[k] = x
        while k:
            k = (k - 1) // 2
            self._seg[k] = self._segfunc(self._seg[k * 2 + 1], self._seg[k * 2 + 2])


    def query(self, p, q):
        if q <= p:
            return self._ide_ele
        p += self._num - 1
        q += self._num - 2
        res = self._ide_ele
        while q - p > 1:
            if p & 1 == 0:
                res = self._segfunc(res, self._seg[p])
            if q & 1 == 1:
                res = self._segfunc(res, self._seg[q])
                q -= 1
            p = p // 2
            q = (q - 1) // 2
        if p == q:
            res = self._segfunc(res, self._seg[p])
        else:
            res = self._segfunc(self._segfunc(res, self._seg[p]), self._seg[q])
        return res

def main():
    N = int(input())
    S = [c for c in input()]
    M = int(input())

    A = [0 for i in range(N)]

    for i, c in enumerate(S):
        A[i] = 1 << ord(c) - ord('a')

    st = SegmentTree(A, N, 0, lambda a, b: a | b)

    for i in range(M):
        p, a, b = input().split()
        a  = int(a) - 1
        b = int(b) - 1 if p == '2' else b
        if p == '1':
            st.update(a, 1 << ord(b) - ord('a'))

        if p == '2':
            s = st.query(a, b + 1)
            print(bin(s).count('1'))


if __name__ == '__main__':
    main()

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

const int MAXN = 3e5 + 5;
int n, a[MAXN], maxL[MAXN], maxR[MAXN];

int main(){
	scanf("%d", &n);
	for(int i = 0; i < n; ++i){
		scanf("%d", &a[i]);
	}
	for(int i = 0; i < n; ++i){
		maxL[i] = a[i];
		if(i)
			maxL[i] = max(maxL[i], maxL[i-1]);
	}
	for(int i = n-1; i >= 0; --i){
		maxR[i] = a[i];
		if(i < n-1){
			maxR[i] = max(maxR[i], maxR[i+1]);
		}
	}
	for(int i = 0; i < n; ++i){
		int ans = (i == 0) ? 0:maxL[i-1];
		ans = (i == n-1) ? ans:max(ans, maxR[i+1]);
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 3968
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = 1e18;


#define PB push_back
#define MP make_pair
#define F first
#define S second

long long POW(long long x, long long n) {
    long long ret = 1;
    while (n > 0) {
        if (n & 1) ret = ret * x % MOD;
        x = x * x % MOD;
        n >>= 1;
    }
    return ret;
}

template<typename T,typename U>
bool chmax(T& max, const U& x){
	if(max<x){
		max = x;
		return true;
	}
	return false;
}

template<typename T,typename U>
bool chmin(T& min, const U& x){
	if(min>x){
		min = x;
		return true;
	}
	return false;
}


int main(){
	ll n;
	map<pair<ll,ll>,ll> ab;
	cin >> n;
	ll corner=0;

	for(ll j=0;j<n;j++){
		ll a,b;
		cin >> a >> b;
		ll d=abs(__gcd(a,b));
		if(a<0){
			a*=-1; b*=-1;
		}
		if(a==b && a==0){
			corner++;
		}else if(a==0 ){
			ab[MP(0,1)]++;
		}else if(b==0){
			ab[MP(1,0)]++;
		}else{
			ab[MP(a/d,b/d)]++;
		}
	}

	vector<ll> ans;
	ans.PB(0);

	map<pair<ll,ll>,bool> used;
	for(auto iter = ab.begin(); iter!=ab.end();iter++){
		if(used[MP(iter->F.F,iter->F.S)]) continue;
		if(iter->S==0) continue;
		if(ab[(MP(iter->F.S,-iter->F.F))]!=0){
			ans.PB( (POW(2,iter->S)+POW(2,ab[MP(iter->F.S,-iter->F.F)])-1)%MOD );
			used[MP(iter->F.S,-iter->F.F)]=true;
		}else if(ab[(MP(-iter->F.S,iter->F.F))]!=0){
			ans.PB( (POW(2,iter->S)+POW(2,ab[MP(-iter->F.S,iter->F.F)])-1)%MOD );
			used[MP(-iter->F.S,iter->F.F)]=true;
		}
		else{
			ans[0] = ans[0] +  iter->S;
		}
	}
	ll fa=1;
	ans[0]=POW(2,ans[0]);
	for(auto e:ans){
		fa = fa*e%MOD;
	}
	fa = fa-1+corner;
	if(fa-1+corner<0){
		fa=fa +MOD;
	}
	cout << fa << endl;
	
}

Measured memory_bytes: 59648
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
const Int INF = 1e18;
const int SHIFT = 20;
const int MASK = (1 << SHIFT) - 1;
array<Int, 4> f(int a, int b, int c) {
    array<Int, 4> res = {-1, -1, -1, -1};
    if (a < 0) return res;
    for (int i = (1 << SHIFT) - 1; i >= 0; i--) {
        if (((((1 << SHIFT) + a - i) ^ (b + i)) & MASK) == c) {
            int t = 0;
            if (a - i < 0) t += 1;
            if (b + i >= 1 << SHIFT) t += 2;
            res[t] = i;
        }
    }
    return res;
}
Int solve(Int a, Int b, Int c) {
    auto res1 = f(a & MASK, b & MASK, c & MASK);
    Int ans = INF;
    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < 2; j++) {
            if ((a >> SHIFT) - i < 0) continue;
            auto res2 = f((a >> SHIFT) - i, (b >> SHIFT) + j, c >> SHIFT);
            if (res2[0] >= 0 && res1[i + 2 * j] >= 0) {
                Int a = res2[0] << SHIFT | res1[i + 2 * j];
                ans = min(ans, a);
            }
        }
    }
    if (ans == INF || ans == a) return -1;
    return ans;
}
int main() {
    int N; cin >> N;
    vector<Int> A(N); for (auto &a : A) cin >> a;
    Int c = 0;
    for (int i = 2; i < N; i++) c ^= A[i];
    cout << solve(A[0], A[1], c) << '\n';
    return 0;
}


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

int main(){
  int a,b;
  int ans[3];

  while(1){
    cin >> a >> b;
    if(!a && !b)break;

    b -= a;
    ans[2] = b/1000;
    b -= ans[2]*1000;

    ans[1] = b/500;
    b -= ans[1]*500;

    ans[0] = b/100;

    cout << ans[0] << " " << ans[1] << " " << ans[2] << endl;
  }
}

Measured memory_bytes: 0
#include<stdio.h>

int main()
{
	int	H, W;
	
	while(1){
		scanf("%d %d", &H, &W);
		if(H == 0 && W == 0)break;
		int i, j;
		for(i = 0; i < H; ++i){
			for(j = 0; j < W; ++j){
				if(i == 0 || i == H - 1 || j ==0 || j == W - 1){
					printf("#");
				}else{
					printf(".");
				}
				
			}
			printf("\n");
		}
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 572
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
using namespace std;

int main() {

	int N;
	cin >> N;

	int ans = 0;
	for (int j = 1; j <= N; j++) {
		int num = 0;
		int i = 6;
		while (num == 0) {
			i--;
			num = j / pow(10, i);
		}

		if (0 == i % 2) {
			ans += 1;
		}
	}

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

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define rep(i,a) for(int i=0;i<(a);++i)

int x, y, s;

int tax( int r, int x )
{ return x*(100+r)/100; }

int main()
{
  while( scanf( "%d%d%d", &x, &y, &s ), x|y|s )
  {
    int ans = 0;

    rep( i, s-1 ) rep( j, s-1 ) if( tax(x,i+1)+tax(x,j+1) == s )
      ans = std::max( ans, tax(y,i+1)+tax(y,j+1) );
      
    printf( "%d\n", ans );
  }
  
  return 0;
}

Measured memory_bytes: 2668
#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }

// vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  return s;
}

class BinarySearch {
public:
  vector<int> data;
  BinarySearch(const vector<int> &data) : data(data) {}

  // index が条件を満たすかどうか
  bool is_ok(int index, int key) {
    if (data[index]*2 >= key) return true;
    else return false;
  }

  // 汎用的な二分探索のテンプレ
  int search(int key) {
    int ng = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    int ok = (int)data.size(); // 「index = data.size()-1」が条件を満たさないこともあるので、初期値は a.size()

    /* ok と ng のどちらが大きいかわからないことを考慮 */
    while (abs(ok - ng) > 1) {
      int mid = (ok + ng) / 2;
      if (is_ok(mid, key)) ok = mid;
      else ng = mid;
    }
    return ok;
  }

  int best(int key, int ok) {
    int best_value = 2*key;
    int best_id = -1;
    for (int i = -1; i <= 1; ++i) {
      int id = ok+i;
      if (id < 0 || id >= data.size()) continue;
      int v = abs(data[id]*2-key);
      if (v < best_value) {
        best_value = v;
        best_id = id;
      }
    }
    assert(best_id != -1);
    return data[best_id];
  }

};


int main() {
  int n;
  cin >> n;
  vector<int> la(n);
  int best = -1;
  for (int i = 0; i < n; ++i) {
    cin >> la[i];
    chmax(best, la[i]);
  }
  int best2 = best*2;
  int best3 = -1;
  for (int a : la) {
    if (a == best) continue;
    int v = abs(a*2-best);
    if (best2 > v) {
      best2 = v;
      best3 = a;
    }
  }
  assert(best3 != -1);
  cout << best << " " << best3 << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
//typedef pair<int,int> P;
//priority_queue<int> pque;
//priority_queue<int, vector<int>, greater<int>> pque;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2000000000;//10^9
ll MOD  = 1000000007;

string s,t;
int dp[3010][3010];


int main(void){
    cin >> s >> t;
    
    int sl = s.size(), tl = t.size();
    
    for(int i = 0; i < sl; i++){
        for(int j = 0; j < tl; j++){
            if(s.at(i) == t.at(j)){
                dp[i+1][j+1] = dp[i][j] + 1;
            }
            else{
                if(dp[i+1][j] >= dp[i][j+1]){
                    dp[i+1][j+1] = dp[i+1][j];
                }
                else{
                    dp[i+1][j+1] = dp[i][j+1];
                }
            }
        }
    }
    
    string ans;
    
    int x = sl,y = tl;
    
    while(x > 0 && y > 0){
        if(dp[x][y] == dp[x-1][y]){
            x--;
        }else if(dp[x][y] == dp[x][y-1]){
            y--;
        }else{
            x--,y--;
            ans += s.at(x);
        }
    }
    for(int i = dp[sl][tl]; i > 0; i--){
        cout << ans.at(i-1);
    }
    
    cout << endl;
}


Measured memory_bytes: 35584
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
typedef long long int lli;
typedef long long int ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<pll> vop;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define REP(i,a,b) for( long long i=a;i<b;i++)
#define REPR(i,a,b) for(long long i=a;i>=b;i--)
#define adb(a) for(auto ii:a) cout << ii << " "; cout << endl
#define adp(a) for(auto ii:a) cout << ii.F << " " << ii.S << endl;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define endl "\n"
#define mem(a,b) memset(a,b,sizeof(a))
#define mod 1000000007
#define PI 3.14159265358979323846
const ll MAXN = 100007;
const ll p = 1000000007;
#define N 200003
#define INF INTMAX_MAX

struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1> {}(p.first);
        auto hash2 = hash<T2> {}(p.second);
        return hash1 ^ hash2;
    }
};

ll dx[] = {1, -1, 0, 0};
ll dy[] = {0, 0, 1, -1};
vl g[N];
bool vis[N];
ll cnt = 0;

ll power(ll a, ll b, ll m) { ll ans = 1; a = a % m; while (b) { if (b & 1) ans = (ans * a) % m; b /= 2; a = (a * a) % m; } return ans; }

ll lcm(ll a, ll b) { return (a * b) / __gcd(a, b); }

ll modInverse(ll a, ll m) { ll g = __gcd(a, m); return power(a, m - 2, m); }

bool cmp(const pll &a, const pll &b)
{
    if (a.F != b.F) {
        return a.F > b.F;
    }
    else
        return a.S < b.S;
}

// bool check(ll i, ll j)
// {
//     if (i >= 0 && i < n && j >= 0 && j < m && a[i][j] != '#')
//         return true;
//     return false;
// }

void dfs(ll v)
{
    vis[v] = true;
    cnt++;
    for (auto u : g[v]) {
        if (!vis[u]) dfs(u);
    }
}

int main()
{


    fastIO;
    int test = 1, num = 1;
    //cin >> test;
    while (test--)
    {
        ll n, m;
        cin >> n >> m;
        REP(i, 0, m)
        {
            ll u, v;
            cin >> u >> v;
            g[u].PB(v);
            g[v].PB(u);
        }
        mem(vis, false);
        ll ans = 0;
        REP(i, 1, n + 1)
        {
            if (!vis[i]) {
                cnt = 0;
                dfs(i);
                ans = max(ans, cnt);
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 20924
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def main():
    N = I()
    ans = N - 1
    max_sq = int(math.sqrt(N)) + 1
    for i in range(1, max_sq):
        if N % i != 0:
            continue
        j = N // i
        ans = min(ans, i+j-2)
    print(ans)
main()




Measured memory_bytes: 6092
N=int(input())
A=[0]+[int(x) for x in input().split()]+[0]
X=sum(abs(A[i]-A[i-1]) for i in range(1,N+2))
for i in range(1,N+1):
  print(X-abs(A[i]-A[i-1])-abs(A[i+1]-A[i])+abs(A[i+1]-A[i-1]))
  

Measured memory_bytes: 14048
import itertools
def main():
    N = int(input())
    P = input()
    Q = input()
    per = [ "".join(map(str, p)) for p in itertools.permutations(range(1, N+1))]
    print(abs(per.index(P.replace(" ", "")) - per.index(Q.replace(" ", ""))))
if __name__ == "__main__":
    main()

Measured memory_bytes: 6040