akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned int ui;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
#define All(v) (v).begin(),(v).end()
#define Rep(i,n) for(int i = 0; i < (int)n; i++)
#define Reps(i,n) for(int i = 1; i <= (int)n; i++)
#define For(i,m,n) for(int i = m; i < n; i++)
#define Fors(i,m,n) for(int i = m; i <= n; i++)
#define Inf 2e9
#define F first
#define S second
#define pb push_back
#define mp make_pair
struct speed{speed(){cin.tie(); ios::sync_with_stdio(false); cout << fixed << setprecision(18);}}speed;

int dy[] = {0,0,1,-1};
int dx[] = {1,-1,0,0};

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*b/gcd(a,b);
}


char li[16] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};

char bin_six(string bin){
    reverse(bin.begin(),bin.end());
    int tmp = 0;
    for(int i = 0; i < 4; i++){
        if(bin[i] == '1'){
            tmp += pow(2,i);
        }
    }
    return li[int(tmp)];
}

int main() {
	int n;
    cin >> n;
    vector<int> x(n,0);
    Rep(i,n){
        cin >> x[i];
    }
    double min = Inf;
    for(int i = 1; i <= 100; i++){
        double sum = 0;
        for(int j = 0; j < n; j++){
            sum += (i-x[j]) * (i-x[j]);
        }
        if(sum < min){
            min = sum;
        }
    }
    cout << (int)min << endl;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)

N=int(input())
L=[0]*(N-1) 
MAP=[-1]*(N+1)
MAP[1]=0
for i in range(N-1):
    L[i]=list(map(int,input().split()))
    t=[L[i][1],L[i][0],L[i][2]]
    L.append(t)

L1=sorted(L,key=lambda x: (x[0],x[1]))
LIST=[[]for i in range(N+1)]

for i in range(len(L)):
    LIST[L1[i][0]].append([L1[i][1],L1[i][2]])

def calc(k):
    global MAP
    for i in range(len(LIST[k])):
        #print(LIST[k],len(LIST[k]))
        if(MAP[LIST[k][i][0]]==-1):
            MAP[LIST[k][i][0]]=(MAP[k]+LIST[k][i][1])%2
            #print(LIST[k][i][0],MAP[LIST[k][i][0]])
            calc(LIST[k][i][0])

calc(1)
for i in range(1,N+1):
    print(MAP[i])


Measured memory_bytes: 109496
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();
	if(N>=M){
	    if(N==M){
		System.out.println("Yes");
	    }else{
		System.out.println("No");
	    }
	}
    }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
int64_t times2(int64_t n) {
	int64_t output = 1;
	for (int64_t i = 0; i < n; ++i) {
		output *= 2;
	}
	return output;
}

int main() {
	//input
	int N, M, X;
	cin >> N >> M >> X;

	vector<int> C(N);
	vector<vector<int>> A(N, vector<int>(M));
	for (int i = 0; i < N; i++) {
		cin >> C[i];
		for (int j = 0; j < M; j++) {
			cin >> A[i][j];
		}
	}

	//calculation
	int cost_min = INT_MAX;
	for (int i = 0; i < times2(N); i++) {
		bitset<12> b(i);
		vector<int> understand(M, 0);
		int cost = 0;
		for (int n = 0; n < N; n++) {
			if (b.test(n)) {
				cost += C[n];
				for (int m = 0; m < M; m++) {
					understand[m] += A[n][m];
				}
			}
		}
		sort(understand.begin(), understand.end());
		if (understand[0] >= X ) {
			if (cost_min > cost ) {
				cost_min = cost;
			}
		}
	}

	//output
	if (cost_min == INT_MAX) {
		cout << -1 << endl;
	} else {
		cout << cost_min << endl;
	}


	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using st=string;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
st abc="abcdefghijklmnopqrstuvwxyz";
st ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};

int main() {
  ll N;
  cin >> N;
  vl a(N);
  rep(i,N){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  ll sum=a[0];
  ll p=0;
  FOR(i,1,N){
    if(sum*2>=a[i]){
      sum+=a[i];
    }
    else{
      sum+=a[i];
      p=i;
    }
  }
  cout << N-p << endl;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    int n,a,b,c,d;
    cin >> n >> a >> b >> c >> d >> s;
    s = "#" + s + "#";
    auto can_reach = [&](int start, int end) {
        for (int i = start; i + 1 <= end; i++) {
            if (s[i] == '#' && s[i + 1] == '#') return false;
        }
        return true;
    };
    if(!can_reach(a,c)||!can_reach(b,d)){
         cout << "No" << endl;
         return 0;
    }
    if(d<c){
        int flag = 0;
        for(int i=b;i<=d;i++){
            if(s[i-1]==s[i]&&s[i]==s[i+1]&&s[i]=='.'){
                flag = 1;
            }
        }
        if(!flag){
        cout << "No" << endl;
        return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 772
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
// vector<vector<vector<double>>> dp(300+1, vector<vector<double>>(300+1, vector<double>(300+1, -1.0)));
int n1, n2, n3;
int n;
// double getexp(int i, int j, int k) {
//     if (i==0 && j==0 && k==0) return 0.0;
//     // if (i>n1 || j>n2 || k>n3) return 0.0;
//     if (dp[i][j][k]>(-0.5)) return dp[i][j][k];
//     int N = i+j+k;
//     double temp = 1.0*n/N;
//     dp[i][j][k] = temp;
//     if (i) dp[i][j][k] += 1.0*i/N * getexp(i-1, j, k);
//     if (j) dp[i][j][k] += 1.0*j/N * getexp(i+1, j-1, k);
//     if (k) dp[i][j][k] += 1.0*k/N * getexp(i, j+1, k-1);
//     // printf("returning dp[%d][%d][%d] = %.12lf\n", i, j, k, dp[i][j][k]);
//     return dp[i][j][k];
// }
double dp[305][305][305];
int main() {
    scanf("%d", &n);
    vector<int> a(n);
    n1 = 0, n2 = 0, n3 = 0;
    for (int &i: a) {
        scanf("%d", &i);
        if (i==1) n1++;
        else if (i==2) n2++;
        else n3++;
    }
    // vector<vector<vector<double>>> dp(n+5, vector<vector<double>>(n+5, vector<double>(n+5)));
    dp[0][0][0] = 0.0;
    // int i = 1, j = 0 , k = 0;
    for (int k=0; k<=n; k++) {
        for (int j=0; j<=n; j++) {
            for (int i=0; i<=n; i++) {
                int N = i+j+k;
                if (N==0) continue;
                double temp1 = 1.0*n/N;
                dp[i][j][k] = temp1;
                if (i) dp[i][j][k] += 1.0*i/N * dp[i-1][j][k];
                if (j) dp[i][j][k] += 1.0*j/N * dp[i+1][j-1][k];
                if (k) dp[i][j][k] += 1.0*k/N * dp[i][j+1][k-1];
            }
        }
    }

    printf("%.15lf\n", dp[n1][n2][n3]);
}

Measured memory_bytes: 219392
N = int(input())
S = sorted([sorted(input()) for _ in range(N)])
ans = [1]
for i in range(N - 1):
    if S[i] == S[i + 1]:
        ans[-1] += 1
    elif ans[-1] > 1:
        ans += [1]
ret = 0
for a in ans:
    ret += a * (a - 1) // 2
print(ret)


Measured memory_bytes: 25420
import java.util.*;
import java.math.*;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int k = in.nextInt();
		int a = in.nextInt();
		int b = in.nextInt();
		int i;
		for(i = a; i <= b; i++) {
			if(i % k == 0) {
				System.out.println("OK");
				break;
			}
		}
		if(i > b) System.out.println("NG");
	}
} 


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

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(v) reverse((v).begin(),(v).end())
#define ANS(ans) cout<<(ans)<<endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for (int i = 0; i < (n); ++i)


int main() {
	int n;
	cin >> n;

	int sum = 0;
	int temp = 1;
	while (sum < n) {
		sum += temp;
		temp++;
	}
	int diff = sum - n;
	FOR(i, 1, temp-1) {
		if (i != diff) {
			cout << i << endl;
		}
	}
	

	return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;
using namespace std;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
template <typename TL, typename TR>
inline void print(const std::vector<std::pair<TR,TL>>& rhs){
    std::cout<<" = [";
    uint i=0;
    for(; i<rhs.size()-1; ++i){ std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"], "; }
    std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"]]" << endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int N; cin >> N;
    vector<unordered_map<string,int>> ht(5);
    
    for(int i=0; i<N; ++i){
        string s; cin >> s;
        if(s[0]=='M'){ ht[0][s]+=1; continue; }
        if(s[0]=='A'){ ht[1][s]+=1; continue; }
        if(s[0]=='R'){ ht[2][s]+=1; continue; }
        if(s[0]=='C'){ ht[3][s]+=1; continue; }
        if(s[0]=='H'){ ht[4][s]+=1; continue; }
    }
    
    int64 sum=0ll;
    for(uint i=0; i<(uint)1<<ht.size(); ++i){
        uint bit=i;
        if(__builtin_popcount(bit)!=3){ continue; }
        
        int64 mul=1ll;
        for(uint i=0; i<ht.size(); ++i, bit>>=1){
            if(bit & 1){ mul*=ht[i].size(); }
        }
        sum+=mul;
    }
    
    cout << sum << endl;
    
    return 0;
}

Measured memory_bytes: 10880
#define _USE_MATH_DEFINES
#pragma region include

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
#pragma endregion //#include
/////////

#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
//////////////

void solve() {
	
	string A, B;
	cin >> A >> B;
	int N = A.size();
	vector<int> TAB(26, -1);
	vector<int> TBA(26, -1);
	for (int i = 0; i < N; ++i) {
		int terA = A[i] - 'a';
		int terB = B[i] - 'a';
		if (TAB[terA] == -1 && TBA[terB] == -1 ) {
			TAB[terA] = terB;
			TBA[terB] = terA;
		}
		else {
			if (TAB[terA] != terB || TBA[terB] != terA) {
				cout << "No" << endl;
				return;
			}
		}
	}
	cout << "Yes" << endl;
}

#pragma region main
signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


Measured memory_bytes: 916
#include<bits/stdc++.h>
using namespace std;
#define MAX 100005
struct Node
{
    char name[100];
    int t;
};
Node p[MAX];

int main()
{
    int n,k,rest,sum = 0;
    queue<Node> q;
    scanf("%d%d",&n,&k);
    for(int i = 0;i < n;i++)
    {
        scanf("%s%d",p[i].name,&p[i].t);
        q.push(p[i]);
    }
    while(!q.empty())
    {
        Node s = q.front();
        q.pop();
        sum += min(s.t,k);
        rest = s.t - k;
        if(rest <= 0) cout << s.name << " " << sum << endl;
        else
        {
            s.t = rest;
            q.push(s);
        }
    }
    return 0;
}



Measured memory_bytes: 13448
use std::io::Read;

pub fn read_stdin() -> String {
    let mut s = String::new();
    ::std::io::stdin().read_to_string(&mut s).unwrap();
    s
}

pub trait Parse {
    fn to<T>(&mut self) -> T
    where
        T: std::str::FromStr;
}

impl<'a> Parse for std::str::SplitWhitespace<'a> {
    fn to<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let word = self.next().unwrap();
        word.parse().ok().unwrap()
    }
}

fn main() {
    let source = read_stdin();
    let mut iter = source.split_whitespace();
    let v: Vec<i32> = (0..4).map(|_| iter.to()).collect();
    let ab = (v[2] - v[0], v[3] - v[1]);
    let rot_ab = (-ab.1, ab.0);
    let p2 = (v[2] + rot_ab.0, v[3] + rot_ab.1);
    let p3 = (p2.0 - ab.0, p2.1 - ab.1);
    println!("{} {} {} {}", p2.0, p2.1, p3.0, p3.1);
}

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

int main() {
  int n,k;
  cin >> n >> k;
  int ans = ceil((n-1)*1.00/(k-1)*1.00)*1LL;
  cout << ans << endl;
  vector<int> a(n);
  for(int& i : a)
    cin >> i;
  return 0;
}


Measured memory_bytes: 640
s = gets.chop
gets.to_i.times{
  m, a, b, c = gets.split
  an = a.to_i
  bn = b.to_i
  case m
  when 'print'
    puts s[an..bn]
  when 'reverse'
    s = s[0...an] << s[an..bn].reverse << s[bn+1..-1]
  else
    s = s[0...an] << c << s[bn+1..-1]
  end
}

Measured memory_bytes: 8912
unittest
{
	assert( [ "1 5 2" ].parse.expand.solve == 53 );
	assert( [ "9 9 9" ].parse.expand.solve == 108 );
	assert( [ "6 6 7" ].parse.expand.solve == 82 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto abc = input.front.split.to!( long[] );
	return tuple( abc );
}

auto solve( long[] abc )
{
	auto m = abc.reduce!max;
	if( m == abc[ 0 ] ) return abc[ 0 ] * 10 + abc[ 1 ] + abc[ 2 ];
	if( m == abc[ 1 ] ) return abc[ 0 ] + abc[ 1 ] * 10 + abc[ 2 ];
	if( m == abc[ 2 ] ) return abc[ 0 ] + abc[ 1 ] + abc[ 2 ] * 10;
	
	assert( false );
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include <bits/stdc++.h>

using namespace std;

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

  int A = 0;
  int B = 0;
  int input;
  while (cin >> input) {
    A += input;
    B += input * input;
  }

  auto f = [&](int p) {
    return N * p * p - 2 * A * p + B;
  };

  int ans = min(f(floor((double) A / N)), f(ceil((double) A / N)));

  cout << ans << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i > (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld EPS = 1.0e-14;//-9
const ld PI = 3.141592653589;
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl lcm(intl a,intl b){
    return a / gcd(a, b) * b;
}
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl a1,a2,b1,b2;
    cin >> a1 >> a2 >> b1 >> b2;
    string s = "";
    char r,l,u,d;
    r = 'R'; l = 'L'; u = 'U'; d = 'D';
    intl x = b1 - a1;
    intl y = b2 - a2;
    rep(i,x)s += r;
    rep(i,y)s += u;
    rep(i,x)s += l;
    rep(i,y)s += d;
    s += d;
    rep(i,x + 1)s += r;
    rep(i,y + 1)s += u;
    s += l;
    s += u;
    rep(i,x + 1)s += l;
    rep(i,y + 1)s += d;
    s += r;
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
   long long int n,z=0,i,j,y,arr[100001],s=0;
   cin>>n;
   for(i=0;i<n;i++)
   {
       cin>>arr[i];
   }
   for(j=0,i=1;i<n;j++,i=j+1)
   {
       if(arr[j]>=arr[i])
        s++;
       else
       {
           s=0;
       }
       if(s>=z)
        z=s;
   }
   cout<<z;
    return 0;
}


Measured memory_bytes: 1024
import Control.Monad
import Data.List
import Data.Ord
import Data.Maybe
import qualified Data.ByteString.Char8 as B

main = do
 [n,k] <- map read . words <$> getLine
 ab <- map (map (fst . fromJust . B.readInt) . B.words) <$> replicateM n B.getLine
 print (bigArray k (sortBy (comparing head) ab))

bigArray k ([a,b]:ab)
 | k <= b = a
 | otherwise = bigArray (k-b) ab

Measured memory_bytes: 65916
#include <stdio.h>
int main(void)
{
  int x, y, r;
  
  scanf("%d %d", &x, &y);
  
  if (x < y){
    r = x;
    x = y;
    y = r;
  }
  while (y > 0){
    r = y;
    y = x % y;
    x = r;
  }
  printf("%d\n",r);
  return 0;
}

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

// TYPEDEF
// ----------------------------------------
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pair;
typedef vector<ll> vll;
typedef vector<vector<ll>> Graph;
typedef vector<string> vs;
typedef vector<pair<ll, ll>> Pll;
typedef queue<ll> qll;

// REPEAT
// ----------------------------------------
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REPA(i,a) for(ll i=0;i<(ll)(a.size());i++);
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define COUT(a) cout << (a) << endl;
#define ENDL(a) cout << endl;
#define COUTA(i,a) for(ll i=0;i<(ll)(a.size());i++) {cout << (a)[i] << " ";} cout << endl;

// UTIL
// ----------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())

// DEBUG
// ----------------------------------------
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

// BIT FLAG
// ----------------------------------------
const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000
const unsigned int BIT_FLAG_8 = (1 << 8); // 0000 0001 0000 0000
const unsigned int BIT_FLAG_9 = (1 << 9); // 0000 0010 0000 0000
const unsigned int BIT_FLAG_10 = (1 << 10); // 0000 0100 0000 0000
const unsigned int BIT_FLAG_11 = (1 << 11); // 0000 1000 0000 0000

// CONST
// ----------------------------------------
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI=3.14159265358979323846; // or M_PI
constexpr int MOD = 1000000007;


void Main() {
  ll n, m;
  cin >> n >> m;
  vll dp(n + 1, -1);

  REP(i, m) {
    ll a_in;
    cin >> a_in;
    dp[a_in] = 0;
  }

  dp[0] = 1; //start
  FOR(i, 1, n) {
    if (i > 1) {
      if (dp[i] != 0) {
        dp[i] = (dp[i - 1] + dp[i - 2]) % MOD;
      }
    }
    else {
      if (dp[i] != 0) {
        dp[i] = dp[i - 1];
      }
    }
  }

  COUT(dp[n]);

}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}

/*
5 2
3 1 2 5
2 2 3
1 0
*/


Measured memory_bytes: 3968
N,L = map(int, input().split())
A=list(map(int, input().split()))
choose = -1
for i in range(1, N):
    if A[i - 1] + A[i] >= L:
        choose = i - 1
        break
if choose == -1:
    print('Impossible')
else:
    print('Possible')
    for i in range(0, choose):
        print(i + 1)
    for i in range(N - 1, choose + 1, -1):
        print(i)
    print(choose + 1)

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

int main() {
    int N; 
    cin >> N;
    vector <double> v(N);
    for (int i=0; i<N; i++) {
        cin >> v.at(i);
    }
    sort(v.begin(), v.end());
    for (int i=0; i<N-1; i++) {
        v.at(i+1) = (v.at(i)+v.at(i+1))/2.0;
    }
    cout << v.at(N-1);
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int n,i,j;
  scanf("%d",&n);
  char s[n];
  for(i=0;i<n;i++){scanf("%s",&s[i]);
  }
  j=0;
  for(i=0;i<n-2;i++){if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')
      j=j+1;}
  printf("%d",j);
  return 0;
}


Measured memory_bytes: 2124
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    int su = 0;
    int mi = 1001, ans = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        su += a[i];
        if(a[i] % 10 != 0) mi = min(mi, a[i]);
    }
    if(mi > 1000) mi = 0;
    if(su % 10 == 0 && mi == 0) ans = 0;
    else if(su % 10 == 0) ans = su - mi;
    else ans= su;
    cout << ans;
}


Measured memory_bytes: 256
package main

import (
  "fmt"
)

func main() {
  var a, b int
  fmt.Scan(&a, &b)
  var fee int
  if a > 12 {
    fee = b
  } else if a > 5 {
    fee = b / 2
  } else {
    fee = 0
  }
  fmt.Println(fee)
}

Measured memory_bytes: 512
#include <algorithm>
#include <functional>
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

int main(int argc, const char *argv[]) {
  using ll = long long;
  int n, m;
  cin >> n >> m;

  priority_queue<ll, vector<ll>, less<ll>> q;
  for (int i = 0; i < n; i++) {
    ll a;
    cin >> a;
    q.push(a);
  }

  while (m > 0) {
    ll top = q.top();
    if (top <= 0) {
      break;
    }

    q.pop();
    q.push(top / 2);
    m--;
  }

  ll ans = 0;
  while (!q.empty()) {
    ans += q.top();
    q.pop();
  }
  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 1400
import sys
input = sys.stdin.readline

N = int(input())
P = [list(map(str, input().split())) for _ in range(N)]
S = input().rstrip()

ind = -1
for a, b in P:
    if a == S:
        ind = 0
    elif ind != -1:
        ind += int(b)

print(ind)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <string.h>
#include <stack>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
typedef long long ll;
typedef pair<int,int> P;
int main() {
    int n;
    cin >> n;
    vector<int>t(n);
    ll sum = 0;
    rep(i, 0, n) {
        cin >> t[i];
        sum += t[i];
    }
    int m;
    cin >> m;
    rep(i, 0, m) {
        int p,x;
        cin >> p >> x;
        if(t[p-1] > x) {
            cout << sum-(t[p-1] - x) << endl;
        } else {
            cout << sum+(x - t[p-1]) << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define forn(i, n) for(int i=0;i<(int)(n);i++)
#define for1(i, n) for(int i=1;i<=(int)(n);i++)
#define fore(i, l, r) for(int i=(int)(l);i<=(int)(r);i++)
#define ford(i, n) for(int i=(int)(n)-1;i>=0;i--)
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define endl "\n"
#define MAX 1000000007
using namespace std;
typedef int64_t ll;
typedef vector<int> vi;
typedef vector<int64_t> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;

int main(int argc, char *argv[]){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.precision(10);
	cout << fixed;
	 long long a,b,c,d;
	cin>>a>>b;
	cin>>c>>d;
	cout<<max(max(a*c,a*d),max(b*c,b*d));
	return 0;
}



Measured memory_bytes: 3620
import itertools
import math

N = int(input())
X = [[0, 0] for i in range(N)]
for i in range(N):
	X[i][0],X[i][1] = map(int, input().split())	

Ns = 1
for i in range(1, N+1):
	Ns = Ns*i

L = [i for i in range(N)]

sum = 0
for V in itertools.permutations(L, N):
	for i in range(N-1):
		sq = (X[V[i]][0] - X[V[i+1]][0])**2 + (X[V[i]][1] - X[V[i+1]][1])**2
		sum += (sq)**0.5

print(sum/Ns)

Measured memory_bytes: 3188
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;
int A,B,C,D,E;
int main() {
	cin>>A>>B>>C>>D>>E;
	if(A<40)A=40;
	if(B<40)B=40;
	if(C<40)C=40;
	if(D<40)D=40;
	if(E<40)E=40;



	cout<<(A+B+C+D+E)/5<<endl;

	return 0;
}

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

#define MAX_N 6
#define MAX_X 100000
#define INF 10000000000

int N = 6;
// int X = 615;
int X;
int dp[MAX_N + 1][MAX_X + 1];
// int w[] = {101, 102, 103, 104, 105, 106};
int w[] = {100, 101, 102, 103, 104, 105};

int main() {
    cin >> X;

    int ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= X; j++) {
            if (j < w[i]) {
                dp[i + 1][j] = dp[i][j];
            } else {
                // if (dp[i][j] == X || dp[i + 1][j - w[i]] + w[i] == X) {
                //     printf("1\n");
                //     return 0;
                // }

                // int t = max(dp[i][j], dp[i + 1][j - w[i]] + w[i]);
                // if (t <= X) {
                //     dp[i + 1][j] = t;
                // }
                dp[i + 1][j] = max(dp[i][j], dp[i + 1][j - w[i]] + w[i]);
            }

            // 答えが見つかった
            if (dp[i + 1][j] == X) {
                printf("1\n");
                return 0;
            }
         }
    }

    printf("%d\n", ans);
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <tuple>
#include <algorithm>
using namespace std;

int main() {
	int N;
	cin >> N;
	vector<tuple<long long, long long, long long>> xyh(N);

	long long h_i_max = 0;
	for (int i = 0; i < N; i++) {
		long long x_i, y_i, h_i;
		cin >> x_i >> y_i >> h_i;
		xyh[i] = make_tuple(x_i, y_i, h_i);
	}


	for (int w = 0; w <= 100; w++) {
		for (int h = 0; h <= 100; h++) {
			long long match = -1;
			long long x_i, y_i, h_i;
			int cnt = 0,tmp_i;
			for (int i = 0; i < xyh.size(); i++) {
				tie(x_i, y_i, h_i) = xyh[i];
				if (h_i != 0) {
					cnt++;
					tmp_i = i;
					if (match == -1) {
						match = h_i + (abs(x_i - w) + abs(y_i - h));
					}
					if (match != h_i + (abs(x_i - w) + abs(y_i - h))) {
						break;
					}
				}

				if (match > 0 && i == xyh.size() - 1) {
					if (cnt == 1) {
						tie(x_i, y_i, h_i) = xyh[tmp_i];
						cout << x_i << " " << y_i << " " << h_i;
						goto L_END;
					}
					else {
						cout << w << " " << h << " " << match;
						goto L_END;
					}
				}
			}
		}
	}

L_END:

	return 0;
}

Measured memory_bytes: 256
use proconio::*;

fn main() {
    input! {
        n: usize,
        a: [i64; n],
    }
    let mut res = 0i64;
    for i in 0..n {
        for j in i + 1..n {
            res += a[i] * a[j];
        }
    }
    println!("{}", res);
}


Measured memory_bytes: 2136
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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;}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    string s;cin>>s;
    rep(i,3)if(s[i]=='7'){
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;
    return 0;
}


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

class card{
public:
	int N;
	vector<int> value;
	vector<char> cha;
	vector<string> init_array;
	vector<string> array;
	vector<string> Barray;
	vector<string> Sarray;


	void set(void){
		cin >> N;
		value.resize(N);
		cha.resize(N);
		init_array.resize(N);
		array.resize(N);
		Barray.resize(N);
		Sarray.resize(N);
		for(int i=0; i<N; i++){
			cin >> init_array[i];
			Barray[i] = init_array[i];
			Sarray[i] = init_array[i];
		}
	}

	void init(void){
		for(int i=0; i<N; i++){
			array[i] = init_array[i];
			value[i] = array[i][1]-'0';
			cha[i] = array[i][0];
		}
	}

	void BubbleSort(void){
		for(int i=0;i<N;i++){
			for(int j=N-1;j>i;j--){
				if(value[j]<value[j-1]){
					swap(value[j],value[j-1]);
					swap(Barray[j],Barray[j-1]);
				}
			}
		}
		for(int i=0; i<N; i++)
			cout << Barray[i] << (i<N-1?" ":"");
		cout << endl;
		cout << "Stable" << endl;
	}

	void SelectionSort(void){
		for(int i=0; i<N; i++){
		bool flag = false;
		int minj = i;
		for(int j=i; j<N; j++){
			if(value[j]<value[minj]){
				minj = j;
				flag=true;
			}
		}
		if(flag==true){
			swap(value[i],value[minj]);
			swap(Sarray[i],Sarray[minj]);
		}
		}
		for(int i=0; i<N; i++)
			cout << Sarray[i] << (i<N-1?" ":"");
		cout << endl;
	}

	void isStable(void){
		for(int i=0;i<N;i++){
			if(Barray[i]!=Sarray[i]){
				cout << "Not stable" << endl;
				return;
			}
		}
		cout << "Stable" << endl;
		return;
	}
};


int main(){
	card c1;
	c1.set();
	c1.init();
	c1.BubbleSort();
	c1.init();
	c1.SelectionSort();
	c1.isStable();
	return 0;
}

Measured memory_bytes: 3184
ip=[int(x) for x in input().split()]
a=ip[0]
b=ip[1]
k=ip[2]
if k>=(b-a+1):
  for i in range(a,b+1):
    print(i)
else:
	lw=list(range(a,a+k))
	hg=list(range(b-k+1,b+1))
	res=list(set(lw+hg))
	res.sort()
	for i in res:
  		print(i)


Measured memory_bytes: 3060
import numpy as np
N,C = map(int,input().split())
D = np.array([list(map(int,input().split())) for _ in range(C)])
c = np.array([list(map(int,input().split())) for _ in range(N)])

strange = np.array([[0]*C for _ in range(3)])
for i in range(N):
    for j in range(N):
        strange[(i+j)%3] += D[c[i][j]-1]

ans = 1000*N**2
for c1 in range(C):
    for c2 in range(C):
        for c3 in range(C):
            if c1 != c2 and c2 != c3 and c3 != c1:
                ans = min(ans,strange[0][c1]+strange[1][c2]+strange[2][c3])
print(ans)

Measured memory_bytes: 16932
def main():
    N = input()
    in_value = [float(i) for i in input().split(' ')]

    sort_value = sorted(in_value)

    if(N != 1):
        while(len(sort_value) != 1):
            min_avg = (sort_value.pop(0) + sort_value.pop(0)) / 2
            sort_value.append(min_avg)
            sort_value = sorted(sort_value)

    print(sort_value[0])


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    string s;cin>>s;
    int cn=0;
    REP(i,s.size())cn+=s[i]-'0';
    cout<<(stoi(s)%cn==0?"Yes":"No")<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

int main(){
    int N;cin>>N;
    vec cost(210,0);
    for(int i=0;i<N;i++){
        int a;cin>>a;
        for(int j=0;j<=200;j++){
            cost[j]+=pow(j-100-a,2);
        }
    }
    int ans=pow(10,9);
    for(int j=0;j<=200;j++)
        ans=min(ans,cost[j]);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
dic = {'AC':0, 'WA':0, 'TLE':0, 'RE':0}
for i in range(n):
	s = input()
	dic[s]+=1
print('AC x',dic['AC'])
print('WA x',dic['WA'])
print('TLE x',dic['TLE'])
print('RE x',dic['RE'])

Measured memory_bytes: 9196
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define vi vector<int>
#define pb push_back
#define INF 999999999
//#define INF (1LL<<59)


//0-index ??????????????°?????????(????????´??°or?????? , ????°????or?????§???or???) verified AOJ DSL_2,DSL_3
template<class T>
class segtree{
private:
	vector<T> dat;
	int _size;  //the number of leaves
	T _init;
	
public:
	segtree(int __size=0 , T init=numeric_limits<T>::max() ):_size(__size) , _init(init) , dat(4*__size,init){
		if(__size==0)return ;
		int x=1;
		while(x<_size)x*=2;
		_size = x;
	}
	
	void update(int m,T x){
		int i = m+_size;
		dat[i] += x;    //addition
		//dat[i] = x;     //initialize
		while(i!=1){
			//dat[i/2] = min(dat[i],dat[i^1]);    //minimum
			//dat[i/2] = max(dat[i],dat[i^1]);    //maximum
			dat[i/2] = dat[i]+dat[i^1];         //sum
			i/=2;
		}
	}
	
	// call find(s,t)
	T find(int s,int t,int num=1,int a=0,int b=-1){
		if(b==-1)b=_size-1; //I couldn't "int b=_size".
		if(b<s||t<a)return _init;
		if(s<=a&&b<=t)return dat[num];
		//return min( find(s,t,num*2,a,(a+b)/2) , find(s,t,num*2+1,(a+b)/2+1,b) );    //minimum
		//return max( find(s,t,num*2,a,(a+b)/2) , find(s,t,num*2+1,(a+b)/2+1,b) );    //maximum
		return find(s,t,num*2,a,(a+b)/2) + find(s,t,num*2+1,(a+b)/2+1,b);           //sum
	}
	int size(){return _size;}
};

/*
 segtree<int> x(100);                                                //100 datas
 segtree<pair<int,int>> x( 100,make_pair( 1<<31-1 , 1<<31-1 ) );     //100 datas
 */

int n;

int main(){
	int q;
	cin>>n>>q;
	segtree<int> st(n,0);
	rep(i,q){
		int a,b,c;
		cin>>a>>b>>c;
		if(a==0)st.update(b-1,c);
		else cout<<st.find(b-1,c-1)<<endl;
	}
}

Measured memory_bytes: 4340
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if(c<a-b) {
			System.out.println(0);
		}else {
			System.out.println(c-(a-b));
		}
	}
}

Measured memory_bytes: 21716
use std::io::{self, BufRead, BufWriter, Write};

fn solve<R, W>(reader: R, mut writer: W)
where
    R: BufRead,
    W: Write,
{
    let mut lines = reader.lines();
    let _ = lines.next().unwrap().unwrap();
    let table: Vec<Vec<bool>> = lines.map(|s| {
        s.unwrap().chars().map(|c| c == '1').collect()
    }).collect();

    let mut ans = -1;
    for i in 0..table.len() {
        let group = max_group(&table, i);
        if group > ans {
            ans = group;
        }
    }

    writeln!(&mut writer, "{}", ans).unwrap();
}

fn max_group(table: &[Vec<bool>], start: usize) -> i32 {
    let mut queue: Vec<usize> = vec![start];
    let mut done: Vec<i32> = vec![0;table.len()];
    done[start] = 1; // group 1
    let mut count: i32 = 1; // start

    let mut gr: i32 = 0;
    while ! queue.is_empty() {
        let x = queue.remove(0);
        gr = done[x];
        for i in 0 .. table.len() {
            if ! table[x][i] {
                continue;
            }

            if done[i] == 0 {
                // new node
                count += 1;
                queue.push(i);
                done[i] = gr + 1;
            } else if done[i] != gr + 1 && done[i] != gr - 1 {
                // failed
                return -1;
            }
        }
    }

    gr
}


fn main() {
    let stdio = io::stdin();
    let input = stdio.lock();

    let stdout = io::stdout();
    let output = BufWriter::new(stdout.lock());

    solve(input, output);
}

#[cfg(test)]
mod tests {
    use super::*;

    const TESTS: &'static [(&'static [u8], &'static [u8])] = &[
        (
            br"2
01
10", br"2
",
        ),
        (
            br"3
011
101
110", br"-1
",
        ),
        (
            br"6
010110
101001
010100
101000
100000
010000", br"4
",
        ),
    ];

    #[test]
    fn test_b() {
        for &(input, expected) in TESTS {
            let mut output = Vec::new();
            solve(input, &mut output);
            let expected_str = String::from_utf8(expected.to_vec()).unwrap();
            let output_str = String::from_utf8(output).unwrap();
            assert_eq!(expected_str, output_str);
        }
    }
}


Measured memory_bytes: 4352
/*
    Author: Alam Khan
    AUST CSE 40th Batch

*/

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef deque<ll> dl;
typedef stack<ll> stl;
typedef set<ll> sl;
typedef map<string, ll> msl;
typedef map<ll,ll> mll;
#define sf(n)     scanf("%lld",&n)
#define sff(n,m)     scanf("%lld %lld",&n,&m)
#define sfff(n,m,r)     scanf("%lld %lld %lld",&n,&m,&r)
#define sfs(n)     scanf("%s",n)
#define pf(n)     printf("%lld\n",n)
#define pff(n,m)     printf("%lld %lld\n",n,m)
#define pfff(n,m,r)     printf("%lld %lld %lld\n",n,m,r)
#define pfs(n)     printf("%s\n",n)
#define pfcs(i,n)     printf("Case %lld: %lld\n",i,n)
#define pb     push_back
#define prf     printf
#define inf     2e18
#define low     -1000000000000
#define PI        acos(-1.0)
#define rep1(i,n) for(i=1;i<n;i++)
#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,a,n) for(i=a;i<n;i++)
#define repe1(i,n) for(i=1;i<=n;i++)
#define repe0(i,n) for(i=0;i<=n;i++)
#define repe(i,a,n) for(i=a;i<=n;i++)
#define endl  "\n"
#define FAST  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fr freopen("input.txt","r",stdin)
#define fw freopen("output.txt","w",stdout)

int main()
{
    ll i,n,t,k,j,x=0,y=0,m;
    string str;
    cin>>str;
    if(str[0]=='7' || str[1]=='7'  || str[2]=='7' )
        cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}



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

mt19937 mt(time(nullptr));
// uniform_int_distribution< int > rand_int(0, 10) // rand[0, 10] inclusive

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  int n;
  cin >> n;
  int ans = 0;
  for (int i=1; i<=n; ++i) {
    if (0 < i && i < 10) ans++;
    if (100 <= i && i < 1000) ans++;
    if (10000 <= i && i< 100000) ans++;
  }
  cout << ans << endl; 
  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
time = 0
def input():
    return sys.stdin.readline()
n = int(input())
G = [[]]
d = [0]*(n+1)
f = [0]*(n+1)
for _ in range(n):
    G.append(list(map(int,input().split()))[2:])
def dfs(e):
    global time
    d[e] = time
    for nexte in G[e]:
        if d[nexte] == 0:
            time += 1
            dfs(nexte)
    time += 1
    f[e] = time

for i in range(1,n+1):
    if d[i] == 0:
        time += 1
        dfs(i)
for i in range(1,n+1):
    print(i,d[i],f[i])



Measured memory_bytes: 5664
#include<iostream>
#include <vector>

using namespace std;

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

  	vector<int> x(n);
  for(int i=0;i<n;i++){
    cin >> x.at(i) ;
  }

  int count = 0 ;
  for(int i=0;i<n;i++){
   if(x.at(i) >= k) count++ ;
  }
    
  cout << count << endl ;
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <sstream>
#include <queue>

#define MAX_V 1000

using namespace std;

int const INT_MAX = 10000000;

bool d2[MAX_V][MAX_V];

struct edge{
	int to;
	int cost;
};

typedef pair<int, int> P; // first??????????????¢???second??????????????????

vector<edge> G[MAX_V];
int d[MAX_V];

// ?????????O(|E|log|V|)

void shortest_path(int s, int V){ // V???????????°
	
	priority_queue<P, vector<P>, greater<P> > que;
	
	for(int i = 0; i < V; i++){
		d[i] = INT_MAX;
	}
	d[s] = 0;
	
	que.push(P(0, s));
	
	while(!que.empty()){
		
		P p = que.top();
		que.pop();
		
		int v = p.second;
		
		if(d[v] < p.first){
			continue;
		}
		
		for(int i = 0; i < G[v].size(); i++){
			edge e = G[v][i];
			if(d[e.to] > e.cost + d[v]){
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		} // ????????????????°???????????????´??°
	}
}

int main(){
	
	while(true){
		
		int n, m;
		
		cin >> n >> m;
		
		if(n == 0 && m == 0){
			break;
		}
		
		for(int i = 0; i <= n; i++){
			for(int j = 0; j <= n; j++){
				d2[i][j] = false;
			}
		}
		
		for(int i = 0; i < MAX_V; i++){
			G[i].erase(G[i].begin(), G[i].end());
		}
		
		for(int i = 0; i < m; i++){
			int index1, index2, cost;
			cin >> index1 >> index2 >> cost;
			
			d2[index1][index2] = true;
			d2[index2][index1] = true;
			
			edge e1, e2;
			e1.to = index2;
			e2.to = index1;
			e1.cost = cost;
			e2.cost = cost;
			G[index1].push_back(e1);
			G[index2].push_back(e2);
			
			index1 += n;
			index2 += n;
			
			e1.to = index2;
			e2.to = index1;
			e1.cost = cost;
			e2.cost = cost;
			G[index1].push_back(e1);
			G[index2].push_back(e2);
			
		}
		
		for(int i = 1; i <= n; i++){
			for(int j = 1; j <= n; j++){
				if(d2[i][j]){
					for(int k = 1; k <= n; k++){
						if(d2[j][k]){
							edge e;
							e.to = k + n;
							e.cost = 0;
							G[i].push_back(e);
						}
					}
				}
			}
		}
		
		shortest_path(1, 2 * n + 1);
		
		cout << d[2 * n] << endl;
		
	}
	return 0;
}

Measured memory_bytes: 3320
/**
 * 
 * @param {String} row 
 */
function Main(row) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	let [input] = row.split("\n");
    //let items = input.split('');

    let val = {
        'SSS': 0,
        'SSR': 1,
        'SRS': 1,
        'SRR': 2,

        'RSS': 1,
        'RSR': 1,
        'RRS': 2,
        'RRR': 3,
    }
    console.log(val[input]);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;
#define int long long
const int MOD = 1000000007;

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int X, Y, A, B, C;
	cin >> X >> Y >> A >> B >> C;
	int Z = 0;
	vector<int> P(A);
	vector<int> Q(B);
	vector<int> R(C);
	for (int i = 0; i < A; i++) {
		cin >> P[i];
	}
	for (int i = 0; i < B; i++) {
		cin >> Q[i];
	}
	for (int i = 0; i < C; i++) {
		cin >> R[i];
	}
	sort(P.rbegin(), P.rend());
	sort(Q.rbegin(), Q.rend());
	sort(R.rbegin(), R.rend());
	int INF = (int)1 << 60;
	while (true) {
		if (Z >= (int)R.size()) break;
		int mn = INF;
		int t = -1;
		if (X > 0) {
			if (mn > P[X - 1]) {
				mn = P[X - 1];
				t = 0;
			}
		}
		if (Y > 0) {
			if (mn > Q[Y - 1]) {
				mn = Q[Y - 1];
				t = 1;
			}
		}
		if (mn < R[Z]) {
			Z++;
			if (t == 0)
				X--;
			else
				Y--;
		} else {
			break;
		}
	}
	int res = 0;
	for (int i = 0; i < X; i++) {
		res += P[i];
	}
	for (int i = 0; i < Y; i++) {
		res += Q[i];
	}
	for (int i = 0; i < Z; i++) {
		res += R[i];
	}
	cout << res << endl;
}

Measured memory_bytes: 2560
R, G, B, N = gets.split.map &:to_i
ans = 0
(0..3000).each{|r|
  rr = r * R
  break if rr > N
  (0..3000).each{|g|
    rrgg = rr + g * G
    break if rrgg > N
    ans += 1 if (N - rrgg) % B == 0
  }
}
p ans

Measured memory_bytes: 1788
#include <iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include <set>
#include <cassert>
#include<cmath>
#include<climits>
#include<iomanip>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
const long long INF = 1LL << 60;


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

class UnionFind {
	vector<int> data;
public:
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int find(vector<long long> &arr, long long obj) {
	if (arr[arr.size() - 1] < obj)return arr.size()-1;
	if (arr[0] > obj)return -1;

	int min = 0; int max = arr.size() - 1;
	for (int i = 0; i < arr.size(); i++) {
		if (arr[min+(max-min) / 2] > obj) {
			max = min + (max - min) / 2;
		}
		else {
			min = min + (max - min) / 2;
		}
		if (max - min == 1) {
			return min;
		}
	}


}

//約数求める //約数
void divisor(ll n,vector<ll> &ret) {
	for (ll i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i * i != n) ret.push_back(n / i);
		}
	}
	sort(ret.begin(), ret.end());
	
}
//階乗
long long factorial(long long n, long long mod) {
	long long ret = 1;
	for (long long i = 1; i <= n; i++) {
		ret = (ret * i) % mod;
	}
	return ret;
}
//モジュラ逆数
long long inv_mod(long long n, long long mod) {
	long long a = n % mod, b = mod - 2, ret = 1;
	while (b > 0) {
		if (b & 1) ret = (ret * a) % mod;
		a = (a * a) % mod;
		b >>= 1;
	}
	return ret;
}

long long nPr(long long n, long long r, long long mod) {
	long long ret = 1;
	for (long long i = n; i >= n - r + 1; i--) {
		ret = ret * (i % mod) % mod;
	}
	return ret;
}

long long nCr(long long n, long long r, long long mod) {
	return nPr(n, r, mod) * inv_mod(factorial(r, mod), mod) % mod;
}

ll gcd(ll m, ll n){
	if (n == 0)return m;
	return gcd(n, m%n);
}//gcd



ll dp[3010][3010];
int main() {
	string s;
	cin >> s;
	ll k;
	cin >> k;
	rep(i, k) {
		if (s[i] != '1') {
			cout << s[i];
			return 0;
		}			   
	}

	cout << 1;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<62;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n,k;
	ll ans=INFLL;
	cin >>n>>k;
	V px ,nx;
	ll bef;
	ll cnt;
	rep(i,n){
		cin>>bef;
		if(bef <0){
			nx.push_back(-1LL*bef);
		}else{
			px.push_back(bef);
		}

	}
//	clog<<'a';
	if(nx.size()!=0){
	sort(all(nx));
	}
	if(px.size()!=0){
	sort(all(px));
	}
//	clog<<'b';
	for(int i=0;i<=k;i++){
	//	clog<<'i';
		if((nx.size()<i and i!=0) or (px.size()<(k-i) and i!=k)){
			//clog<<"pass"<<endl;
			continue;
		}else{
			if(i==0){
				cnt=px[k-1];
			}else if(i==k){
				cnt=nx[k-1];
			}else{
				cnt = nx[i - 1] + px[k - i - 1] + min(nx[i - 1], px[k - i - 1]);
			}
		//	clog/*<<nx[i-1]<<" "<<px[k-i-1]<<" "*/<<cnt<<endl;
			chmin(ans,cnt);
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1656