akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	vl v(n);
	REP(i, n)cin >> v[i];
	vl a(n + 1);
	REP(i, n)a[i + 1] = a[i] + v[i];
	ll ans = 0;
	vl l(n + 1), r(n + 1);
	REP(i, n) {
		l[i + 1] = l[i] + max(0ll, v[i]);
	}
	RREP(i, n) {
		r[i] = r[i + 1] + max(0ll, v[i]);
	}
	REP(i, n-k+1) {
		chmax(ans, max(0ll, a[i + k] - a[i]) + l[i] + r[i + k]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3456
from collections import Counter

n = int(input())
v = list(map(int, input().split()))

def f(x, y):
  return n - ( x + y )

v0 = Counter(v[::2])
v1 = Counter(v[1::2])
L = v0.most_common(2)
R = v1.most_common(2)

#print(L, R)

if L[0][0] != R[0][0]:
  print(f(L[0][1], R[0][1]))
elif len(L) > len(R):
  print(f(L[1][1], R[0][1]))
elif len(L) < len(R):
  print(f(L[0][1], R[1][1]))
elif len(L) == 2:
  print(min(f(L[1][1], R[0][1]), f(L[0][1], R[1][1])))
else:
  print(n//2)

Measured memory_bytes: 18656
#include<iostream>
#include<queue> 
using namespace std;
long long ans,m,n,k,q,a;
priority_queue<long long> pq;
int main()
{
	cin>>n>>m;
	for(int i=0;i<n;i++)
	{
		cin>>a;
		pq.push(a);
	}	
	while(m!=0)
	{
		int d=pq.top();
		pq.pop();
		if(d==0)
			break;	
		pq.push(d/2);
		m--;	
	}
	while(!pq.empty())
	{
		ans+=pq.top();
		pq.pop();
	}
	cout<<ans<<endl;
} 

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

int main(){
    long long int A, B;
    cin >> A >> B;

    long long int tmp, r, a, b;
    if(A < B){
        a = B;
        b = A;
    }
    else{
        a = A;
        b = B;
    }
    

    r = a % b;
    while(r != 0){
        a = b;
        b = r;
        r = a % b;
    }

    cout << (A / b) * B << endl;
}

Measured memory_bytes: 256
def main():
    sx, sy, tx, ty = map(int,input().split())

    x = tx - sx
    y = ty - sy

    ans = "U" * y + "R"*x + "D"*y + "L"*x + "L" + "U" * (y+1) + "R"*(x+1) + "D"+"R"+ "D"*(y+1) + "L"*(x+1) + "U"
    print(ans)

if __name__ == "__main__":
        main()


Measured memory_bytes: 3060
# -*- coding: utf-8 -*-
import numpy as np
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect
from scipy.special import comb
import copy
sys.setrecursionlimit(10**6)


def zz():
    return list(map(int, sys.stdin.readline().split()))


def z():
    return int(sys.stdin.readline())


def S():
    return sys.stdin.readline()[:-1]


def C(line):
    return [sys.stdin.readline() for _ in range(line)]


N = z()
S = S()
after_lis = [set() for _ in range(N+1)]
i = N-1
for s in reversed(S):
    after_lis[i] = (after_lis[i] | after_lis[i+1])
    after_lis[i].add(int(s))
    i -= 1

left_index = {}
for i, s in enumerate(S):
    if s not in left_index:
        left_index[s] = i

ans_lis = np.zeros([10, 10, 10], dtype=np.int32)

for char in left_index:
    s_100 = int(char)
    for i_10 in range(left_index[char]+1, N-1):
        # print("s_10")
        s_10 = int(S[i_10])
        ans_lis[s_100, s_10, list(after_lis[i_10+1])] = 1

        # sは暗証番号の一番左
# print(ans_lis)
print(np.sum(ans_lis))


Measured memory_bytes: 65884
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
#include <climits>
#include <complex>
#include <numeric>
using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RREP(i,n) for(int i=(int)n-1; i>=0; i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();++i)
#define ALL(c) (c).begin(), (c).end()

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

const int INF = 1e9;
const int MOD = 1e9+7;

typedef ll SegT;
static const SegT defvalue = 0LL;
class SegTree{
	private:
		vector<SegT> val;
		int n;
	public:
		SegTree(int size){
			n=1;
			while(n<size)n<<=1;
			val=vector<SegT>(2*n, defvalue);
		}
		void update(int i,SegT a){
			i+=n-1;
			val[i]=a;
			while(i>0){
				i=(i-1)/2;
				val[i]=max(val[i*2+1],val[i*2+2]);
			}
		}
		SegT query(int a,int b,int k=0,int l=0,int r=-1){
			if(r==-1)r=n;
			if(r<=a||b<=l) return defvalue;
			if(a<=l&&r<=b){
				return val[k];
			}else{
				return max(query(a,b,k*2+1,l,(l+r)/2),query(a,b,k*2+2,(l+r)/2,r));
			}
		}
};

int main(void){
	int n;
	ll c;
	cin >> n >> c;
	vi x(n), v(n), x2(n), v2(n);
	SegTree st_p(n), st_n(n);
	REP(i, n){
		cin >> x[i] >> v[i];
		x2[i] = c - x[i];
		v2[i] = v[i];
	}
	ll res = 0;
	REP(i, n){
		res += v[i];
		st_p.update(i, res - x[i]);
	}
	res = 0;
	RREP(i, n){
		res += v2[i];
		st_n.update(i, res - x2[i]);
	}
	
	REP(i, n-1) v[i+1] += v[i];
	RREP(i, n-1) v2[i] += v2[i+1];
	ll ans = 0;
	ans = max(ans, st_n.query(0, n));
	ans = max(ans, st_p.query(0, n));

	//cout << "positive route" << endl;
	REP(i, n){
		ll res = v[i] - 2 * x[i];
		res += st_n.query(i + 1, n);
		//cout << "i: " << i << " " << res << endl;
		//cout << v[i] - 2 * x[i] << endl;
		//cout << st_n.query(i + 1, n) << endl;
		ans = max(ans, res);
	}
	//cout << "negative route" << endl;
	RREP(i, n){
		ll res = v2[i] - 2 * x2[i];
		res += st_p.query(0, i);
		//cout << "i: " << i << " " << res << endl;
		//cout << v2[i] - 2 * x2[i] << endl;
		//cout << st_n.query(i + 1, n) << endl;
		ans = max(ans, res);
	}
	cout << ans << endl;
}


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

int main(){
  int n;cin>>n;
  int ans=0,cnt=1;
  
  for(int i=0;i<n;i++){
    int a;cin>>a;
    if(a==cnt)cnt++;
    else ans++;
  }
  if(cnt>1)cout<<ans<<endl;
  else cout<<-1<<endl;
} 

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

int main(){
	int n, m, c, ans, tmp;
	int a, b[21];
	cin >> n >> m >> c;
	for (int i = 0; i < m; ++i) cin >> b[i];
	ans = 0;
	for (int i = 0; i < n; ++i){
		tmp = c;
		for (int j = 0; j < m; ++j){
			cin >> a;
			tmp += a*b[j];
		}
		if (tmp > 0) ans++;
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <algorithm>
using namespace std;

int main() {
	int N, C;
	cin >> N >> C;
	vector<vector<int>> Data(N, vector<int>(3));
	for (int i = 0; i < N; i++) cin >> Data[i][0] >> Data[i][1] >> Data[i][2];

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

	using P = pair<int, int>;
	priority_queue<P,vector<P>,greater<P>> Q;
	
	int ans = 1, amari = 0;
	vector<P> unused;
	Q.push({ Data[0][1],Data[0][2] });
	for (int i = 1; i < N; i++) {
		int s = Data[i][0], t = Data[i][1], c = Data[i][2];
		
		while (!Q.empty() && Q.top().first <= s) {
			if (Q.top().second != c && Q.top().first == s) unused.push_back(Q.top());
			else amari++;
			Q.pop();
		}

		if (amari > 0) amari--;
		else ans++;

		for (auto p : unused) Q.push(p);
		unused.clear();

		Q.push({ t,c });
	}
	cout << ans << endl;
}

Measured memory_bytes: 8780
#include <bits/stdc++.h>
using namespace std;
map<char,int> mp;
int main()
{
	string s;
	cin >>s;
	for(int i=0;i<3;i++) mp[s[i]]++;
	if(mp['A']&&mp['B']) cout <<"Yes"<<endl;
	else cout <<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int n;
    cin >> n;
    vector <int> p(n);
    for(int i = 0; i<n; i++){
        cin >> p[i];
    }
    
    int ans = 0;
    for(int i=1; i<n-1;i++){
        if(p[i] != min(min(p[i-1],p[i]),p[i+1]) && p[i] != max(max(p[i-1],p[i]),p[i+1])){
            ans += 1;
        }
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#include <cstdio>
#include <cstdint>
using namespace std;

int_fast8_t d;
uint_fast32_t M = 0;
uint_fast64_t c, sd = 0, sc = 0;
constexpr int cm = 1 << 22;
char buff[cm], *ci;
int main() {
	fread_unlocked(buff, 1, cm, stdin); ci = buff;
    while(*ci>47) M = (M<<1) + (M<<3) + *ci++ - 48;
    while(M--) {
        d = *++ci - 48;
        for(c=0, ci++; *++ci>47;) c = (c<<1) + (c<<3) + *ci - 48;
        sc += c;
        sd += c * d;
    }
    printf("%lld", --sc + --sd / 9);
	return 0;
}


Measured memory_bytes: 4224
#include<iostream>
#include<cmath>
#include<vector>
#include<bitset>
#include<bitset>
#include<string>
#include<utility>
#include<queue>

using namespace std;

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

Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main() {
  char a;
  cin >> a;
  if (a >= 'a') {
    cout << 'a' << "\n";
  }
  else {
    cout << 'A' << "\n";
  }
}


Measured memory_bytes: 3632
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		long[] d = new long[N];
		int[]t = new int[N];
		Data[] v = new Data[N];
		Set<Integer> set = new HashSet<Integer>();
		for(int i = 0; i < N; i++) {
			t[i] = sc.nextInt();
			d[i] = sc.nextLong();
			v[i] = new Data(t[i], d[i]);
			set.add(t[i]);
		}
		sc.close();
		Arrays.sort(v, new MyCompData());
		if(set.size() == N) {
			long ans = 0;
			for(int i = 0; i < K; i++) {
				ans += v[i].c;
			}
			long x = K;
			ans += x * x;
			System.out.println(ans);
			System.exit(0);
		}
		int l1 = set.size();
		int l2 = N - set.size();
		Long[]d1 = new Long[l1];
		Long[]d2 = new Long[l2];
		set.clear();
		int idx1 = 0;
		int idx2 = 0;
		for(int i = 0; i < N; i++) {
			if(!set.contains(v[i].id)) {
				set.add(v[i].id);
				d1[idx1++] = v[i].c;
			}else {
				d2[idx2++] = v[i].c;
			}
		}
		long[] s1 = new long[l1 + 1];
		long[] s2 = new long[l2 + 1];
		s1[0] = 0;
		s2[0] = 0;
		Arrays.sort(d1, Collections.reverseOrder());
		Arrays.sort(d2, Collections.reverseOrder());
		for(int i = 1; i <= l1; i++) {
			s1[i] += s1[i - 1] + d1[i - 1];
		}
		for(int i = 1; i <= l2; i++) {
			s2[i] += s2[i - 1] + d2[i - 1];
		}
		long ans = 0;
		int max = Math.min(K, l1);
		for(int i = max; i >= 1; i--) {
			if(K - i > l2) break;
			long x = i;
			long sum = s1[i] + s2[K - i] + x * x;
			ans = Math.max(ans, sum);
		}
		System.out.println(ans);
	}
	static class Data{
		int id;
		long c;
		public Data(int id, long c) {
			this.id = id;
			this.c = c;
		}
	}
	static class MyCompData implements Comparator<Data>{
		@Override
		public int compare(Data d1, Data d2) {
			if(d1.c < d2.c) {
				return 1;
			}else if(d1.c == d2.c) {
				return 0;
			}else {
				return -1;
			}
		}
	}
}

Measured memory_bytes: 98984
// https://atcoder.jp/contests/abc141/tasks/abc141_b
//
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, [ next / $t:tt ]) => {
        {
            let len = read_value!($iter, usize);
            (0..len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! dvec {
    ($t:expr ; $len:expr) => {
        vec![$t; $len]
    };

    ($t:expr ; $len:expr, $($rest:expr),*) => {
        vec![dvec!($t; $($rest),*); $len]
    };
}

#[allow(unused_macros)]
macro_rules! ifv {
    ($t:expr, $a:expr, $b: expr) => {
        if $t { $a } else { $b }
    }
}

#[allow(unused_macros)]
macro_rules! fill {
    ($t:expr, $v:expr) => {
        for i in 0..$t.len() {
            $t[i] = $v;
        }
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
        s: chars
    };

    let ng = s.iter().zip(0..).filter(|&(c,idx)| {
        if idx % 2 == 0 && *c == 'L' {
            return true;
        }
        if idx % 2 == 1 && *c == 'R' {
            return true;
        }
        false
    }).collect::<Vec<_>>().len() >= 1;
    println!("{}", ifv!(ng, "No", "Yes"));
}


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

typedef long long  ll;

ll MOD = 1000000007;
ll INF = 100000000;
double PI = 3.1415926535;

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

int cost[10][10];
int d[10];
bool done[10];
int V = 10;

void dijksutra(int s){
    fill(done,done+10,false);
    fill(d,d+10,INF);
    d[s] = 0;
    while(true){
        int v = -1;
        for(int i = 0;i < V;i++){
            if(!done[i]){
                if(v == -1){
                    v = i;
                }
                if(!done[i]){
                    if(d[i] < d[v]){
                        v = i;
                    }
                }
            }
        }
        if(v == -1){
            break;
        }
        done[v] = 1;
        for(int i = 0;i < V;i++){
            d[i] = min(d[i],d[v] + cost[v][i]);
        }
    }
    return;
}

int main(){
    int H,W;
    cin >> H >> W;
    for(int i = 0;i < 10;i++){
        for(int j = 0;j < 10;j++){
            cin >> cost[i][j];
        }
    }
    int cnt[10];
    fill(cnt,cnt+10,0);
    for(int i = 0;i < H*W;i++){
       int a;cin >> a;
       if(a != -1){
           cnt[a]++;
       }
    }
    ll ans = 0;
    for(int i = 0;i < 10;i++){
        dijksutra(i);
        ans += d[1] * cnt[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;

int gcd(int a,int b){
    int g=1,c=2;
    while(c<=a&&c<=b){
        if(a%c==0&&b%c==0){
            a=a/c;
            b=b/c;
            g=g*c;
            c=2;
        }
        else c++;
    }
    return g;
}


int main(){
    int a,b,c,d,e,f;
    scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f);
    int y=gcd(c,d);
    int i,j,k,l,water,sugar,ansdis=a*100,anssugar=0;
    double conc,maxconc=0;
    
    
    for(i=0;i<=30/a;i++){
    if(i!=0){
            for(j=0;j<=(30-i*a)/b+1;j++){
            water=i*a+j*b;
            
         for(k=0;k<=d;k++){
                for(l=0;l<=c;l++){
                    sugar=k*c+l*d;
                    conc=(double)sugar/water;
                    if(conc<=e && conc>maxconc && (100*water+sugar<=f))maxconc=conc,ansdis=100*water+sugar,anssugar=sugar;
    
                }
            }
    
            for(k=c*d;k<=f-100*water;k=k+y){
                sugar=k;
                conc=(double)sugar/water;
                if(conc<=e && conc>maxconc && (100*water+sugar<=f))maxconc=conc,ansdis=100*water+sugar,anssugar=sugar;
            }
        }
    }
     
        if(i==0){
            for(j=1;j<=(30-i*a)/b+1;j++){
                water=i*a+j*b;
                
                for(k=0;k<=d;k++){
                    for(l=0;l<=c;l++){
                        sugar=k*c+l*d;
                        conc=(double)sugar/water;
                        if(conc<=e && conc>maxconc && (100*water+sugar<=f))maxconc=conc,ansdis=100*water+sugar,anssugar=sugar;
     
                    }
                }
                
                for(k=c*d;k<=f-100*water;k=k+y){
                    sugar=k;
                    conc=(double)sugar/water;
                    if(conc<=e && conc>maxconc && (100*water+sugar<=f))maxconc=conc,ansdis=100*water+sugar,anssugar=sugar;
                }
            }
        }
        
        
    }
    printf("%d %d\n",ansdis,anssugar);
    
    
    return 0;
}

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

using namespace std;

struct UnionFind
{
  vector< int > data;

  UnionFind(int sz)
  {
    data.assign(sz, -1);
  }

  bool unite(int x, int y)
  {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }

  int find(int k)
  {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  int size(int k)
  {
    return (-data[find(k)]);
  }
};

int main()
{
  string S;
  int N;

  cin >> S;
  cin >> N;
  UnionFind uf(S.size() + 1);
  for(int i = 0; i <= S.size(); i++) {
    uf.unite(i, S.size() - i);
  }
  for(int i = 0; i < N; i++) {
    int L, R;
    cin >> L >> R;
    uf.unite(L - 1, R);
  }

  vector< int > sum(S.size() + 1);

  for(int i = 0; i <= S.size(); i++) {
    int U = (i == 0 ? 0 : S[i - 1] - 'a');
    int V = (i == S.size() ? 0 : S[i] - 'a');
    int dist = (U + 26 - V) % 26;
    (sum[uf.find(i)] += dist) %= 26;
  }


  for(int i = 0; i <= S.size(); i++) {
    if(sum[i] != 0) {
      cout << "NO" << endl;
      return (0);
    }
  }

  cout << "YES" << endl;
}


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

int X;

int main() {
	cin >> X;

	if( X == 3 || X == 5 || X == 7 ) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}


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

    int n;
    cin >>n;
    vector <int> a(n);
    loop(i,n){
        cin>>a[i];
    }
    bool dobar = true;
    loop(i,n){
        if(a[i]%2==1) continue;
        if(a[i]%3 != 0 && a[i]%5 !=0) dobar = false;

    }
if(dobar) cout << "APPROVED"<< endl;
else
{
    cout << "DENIED" << endl;
}
return 0 ;

}

Measured memory_bytes: 256
import java.util.Scanner;

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

        int s = Integer.parseInt(line);
        System.out.printf("%d:%d:%d%n", s / 3600, s % 3600 / 60, s % 3600 % 60);
    }
}


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

int main() {
	ll score[1<<16], n, a[16][16];
	cin >> n;
	memset(score, 0, sizeof(score));
	for (int i=0; i<n; i++) 
		for (int j=0; j<n; j++)
			cin >> a[i][j];
	for (int i=0; i<(1<<n); i++)
		for (int j=0; j<n; j++)
			for (int k=j+1; k<n; k++)
				if (i&(1<<j) && i&(1<<k))
					score[i] += a[j][k];
	for (int i=0; i<(1<<n); i++)
		for (int j=i; j; j=(j-1)&i)
			score[i] = max(score[i], score[j]+score[j^i]);
	
	cout << score[(1<<n)-1] << "\n";
}

Measured memory_bytes: 768
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> have(n);
  for (int i = 0; i < k; i++) {
    int d;
    cin >> d;
    for (int j = 0; j < d; j++) {
      int a;
      cin >> a;
      have[--a]++;
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (have[i] == 0) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3512
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int c[][] = new int[3][3];
        int sum = 0;
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                c[i][j] = scanner.nextInt();
                sum += c[i][j];
            }
        }
        if (sum % 3 == 0 && sum / 3 == c[0][0] + c[1][1] + c[2][2]) {
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }

    }
}


Measured memory_bytes: 35652
// -*- coding:utf-8-unix -*-

use proconio::marker::Usize1;
use proconio::{fastout, input};
use std::collections::HashSet;

#[fastout]
fn main() {
    input! {
        n: usize,
        m: usize,
        result: [(Usize1, String); m],
    }
    let mut ac_set: HashSet<usize> = HashSet::with_capacity(n);
    let mut wa_vec: Vec<u32> = vec![0; n];
    let mut sum_pen = 0;
    for (p, s) in result.iter() {
        if s == "AC" {
            if !ac_set.contains(p) {
                sum_pen += &wa_vec[*p];
            }
            ac_set.insert(*p);
        } else {
            wa_vec[*p] += 1;
        }
    }
    println!("{} {}", ac_set.iter().count(), sum_pen);
}


Measured memory_bytes: 10348
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static int dp[];
	static int N, M;
	static int[] matchsticks = {
		2,
		5,
		5,
		4,
		5,
		6,
		3,
		7,
		6
	};
	static ArrayList<String> possibleAns = new ArrayList<String>();
	static Digit[] digits;

	public static void main(String[] args) {
		N = sc.nextInt();
		M = sc.nextInt();
		digits  = new Digit[M];
		dp = new int[N+1];
		Arrays.fill(dp, -1);
		for(int i = 0; i < M; i++) {
			int curr = sc.nextInt();
			digits[i] = new Digit(curr, matchsticks[curr-1]);
		}

		Arrays.sort(digits);

		// for(Digit d : digits) {
		// 	System.out.println(d.digit + " " + d.matchsticks);
		// }

		int length = dp(N);
		String ans = formDigits(length);

		System.out.println(ans);
	}

	public static String formDigits(int length) {
		StringBuilder sb = new StringBuilder();
		int index = M-1;
		int copyN = N;
		while(length > 0 && index >= 0) {
			if(dp(copyN - digits[index].matchsticks) == dp(copyN)-1) {
				sb.append(digits[index].digit);
				length--;
				copyN -= digits[index].matchsticks;
			}
			else {
				index--;
			}
		}

		return sb.toString();
	}

	public static int dp(int i) {
		if(i == 0) return 0;

		if(i < 0) return Integer.MIN_VALUE;

		if(dp[i] == -1) {
			int ans = Integer.MIN_VALUE;
			for(int j = 0; j < M; j++) {
				ans = Math.max(ans, dp(i-digits[j].matchsticks) + 1);
			}

			dp[i] = ans;
		}

		return dp[i];
	}

	static class Digit implements Comparable<Digit> {
		public int digit, matchsticks;

		public Digit(int d, int m) {
			digit = d;
			matchsticks = m;
		}

		public int compareTo(Digit b) {
			return new Integer(this.digit).compareTo(b.digit);
		}
	}
}

Measured memory_bytes: 23764
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define print(n) cout<<n<<endl
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
const int M=200111;
const int inf=1000000007;
const int MOD=1000000007;
const double PI = 3.1415926535897932384626433;
const long long INF=1e18;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};


struct UnionFind {
	vector<int> par;
	UnionFind(int n) : par(n, -1) { }

	int root(int x) {
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

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

	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y); // merge technique
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x) {
		return -par[root(x)];
	}
};

vvl comb(int n) {
	vvl v(n + 1,vl(n + 1, 0));
	for (int i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int j = 1; j < v.size(); j++) {
		for (int k = 1; k < j; k++) {
			v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
		}
	}
	return v;
}

void sosu(ll x,bool f[]){
	ll y=x;
	for(ll i=2;i<=sqrt(y);i++){
		if(x%i==0){
			x/=i;
			f[i]=true;
			i--;
		}
	}
}

ll __gcd(ll x,ll y){
	if(x<y)swap(x,y);
	while(1){
		ll tmp=x%y;
		x=y;
		y=tmp;
		if(y==0)break;
	}
	return x;
}

int keta(ll a){
	int ke=1;
	while(a/=10)ke++;
	return ke;
}

vector<long long> enum_divisors(long long N) {
	vector<long long> res;
	for (long long i = 1; i * i <= N; ++i) {
		if (N % i == 0) {
			res.push_back(i);
			// 重複しないならば i の相方である N/i も push
			if (N/i != i) res.push_back(N/i);
		}
	}
	// 小さい順に並び替える
	sort(res.begin(), res.end());
	return res;
}

ll zyou(ll x,ll n){
	ll y=1;
	rep(i,0,n){
		y*=x;
	}
	return y;
}

int main() {
	int a,b,k;
	bool f=false;
	cin>>k>>a>>b;
	rep(i,a,b+1){
		if(i%k==0)f=true;
	}
	if(f)print("OK");
	else print("NG");
	

}


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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
using ld = long double;
ll mod = 1000000007;

int main() {
    ll n;
    cin >> n;
    vector<vector<ll>> g(n);
    repd(i, 1, n) {
        ll p;
        cin >> p;
        p--;
        g[p].push_back(i);
    }

    auto dfs = [&](auto self, ll v) -> ll {
        ll ans = 0;
        vector<ll> temp;
        for (auto u : g[v]) {
            temp.push_back(self(self, u));
        }
        sort(temp.begin(), temp.end());
        for (auto t : temp) {
            ans = max(ans, t) + 1;
        }
        return ans;
    };

    cout << dfs(dfs, 0) << endl;
    return 0;
}



Measured memory_bytes: 16268
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

def inp():
    return int(input())
def inps():
    return input().rstrip()
def inpl():
    return list(map(int, input().split()))
def inpls():
    return list(map(str, input().split()))
def _debug(obj):
    print(obj, file=sys.stderr)

# import decimal
# from decimal import Decimal
# decimal.getcontext().prec = 10

# from heapq import heappush, heappop, heapify
# import math
# from math import gcd
# import itertools as it
# import collections
# from collections import deque 

# ---------------------------------------

n = inp()
for i in range(n):
    print("ACL", end="")
print()


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

#define LOOP(i,n) for(int i = 0; i < n; ++i)

int main()
{
  int n, s;
  int v[20], c[20];
  cin >> n;
  LOOP(i,n) cin >> v[i];
  LOOP(i,n) cin >> c[i];
  LOOP(i,n) if(v[i] - c[i] > 0) s += v[i] - c[i];
  cout << s << "\n";
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());
#define vecmin(A) *min_element(A.begin(),A.end());
#define vecmax(A) *max_element(A.begin(),A.end());
typedef long long ll;

ll tmin(ll a,ll b,ll c){
  return min(min(a,b),c);
}

ll tmax(ll a,ll b,ll c){
  return max(max(a,b),c);
}

int main(){
  ll h,w;
  cin >> h >> w;
  ll ans = h*w;
  rep1(i,h-1){//iで分割
    ll s1 = i*w;
    //縦割
    ll s2 = (h-i)*(w/2);
    ll s3 = h*w - s1 - s2;
    ans = min(ans,tmax(s1,s2,s3)-tmin(s1,s2,s3));
    //横割
    ll s4 = ((h-i)/2)*w;
    ll s5 = h*w - s1 - s4;
    ans = min(ans,tmax(s1,s4,s5)-tmin(s1,s4,s5));
  }
  swap(h,w);
  rep1(i,h-1){//iで分割
    ll s1 = i*w;
    //縦割
    ll s2 = (h-i)*(w/2);
    ll s3 = h*w - s1 - s2;
    ans = min(ans,tmax(s1,s2,s3)-tmin(s1,s2,s3));
    //横割
    ll s4 = ((h-i)/2)*w;
    ll s5 = h*w - s1 - s4;
    ans = min(ans,tmax(s1,s4,s5)-tmin(s1,s4,s5));
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#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 all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_v(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << endl; }
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
#define SP << " " <<
#define D1(a) cout<<#a<<":"<<a<<"\n"
#define D2(a,b) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<endl 
#define D3(a,b,c) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c <<endl
#define D4(a,b,c,d) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c<<","<<#d<<":"<<d<<endl 
#define MOD 1000000007

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    int X; cin >>X;
    vector<int> p(X+1, 0);
    p[0] = 1;

    int prices[] = {100, 101, 102, 103, 104, 105 };

    rep(i, p.size()) {
        if (p[i] != 0) {
            rep(j, 6) {
                int price = i + prices[j];
                if (price == X) {
                    cout << 1 << endl;
                    return 0;
                } else if (price < X) {
                    p[price] = 1;
                }
            }
        }
    }

    cout << 0 << endl;
}


Measured memory_bytes: 640
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		 String S = sc.next();
      	
      if(S.charAt(2) == S.charAt(3) && S.charAt(4) == S.charAt(5)){
      System.out.println("Yes");}
      else{
      System.out.println("No");}
	}
}

Measured memory_bytes: 24916
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;

int main(){
    int a,b;
    cin>>a>>b;
    if(a==b){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    
   return 0;
}

Measured memory_bytes: 256
using System;

public class Hello
{
    public static void Main()
    {
        while (true)
        {
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == 0) break;
            var wk = new int[n];
            for (int i = 0; i < n; i++) wk[i] = int.Parse(Console.ReadLine().Trim());
            Array.Sort(wk);
            var wk2 = 0L;
            var ret = 0L;
            for (int i = 0; i < n - 1; i++)
            {
                wk2 += wk[i];
                ret += wk2;
            }
            Console.WriteLine(ret);
        }
    }
}

Measured memory_bytes: 9336
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

const int mod = 1000000007;
int add(int a, int b) { return (a += b) < mod? a : a - mod; }
int sub(int a, int b) { return (a -= b) >=  0? a : a + mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }
void adds(int& a, int b) { a = add(a, b); }
void subs(int& a, int b) { a = sub(a, b); }
void muls(int& a, int b) { a = mul(a, b); }
void maxs(int& a, int b) { a = max(a, b); }
void mins(int& a, int b) { a = min(a, b); }
int pwr(int a, ll p) {
    if (p == 0) return 1;
    if (p & 1) return mul(a, pwr(a, p - 1));
    return pwr(mul(a, a), p / 2);
}
int inv(int a) { return pwr(a, mod - 2); }

int n;
int a[200001];
int dp[200001];
int f[200001];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for (int i = 1; i <= n; ++i)
        cin >> a[i];

    n = unique(a + 1, a + 1 + n) - (a + 1);

    dp[0] = 1;
    for (int i = 1; i <= n; ++i)
    {
        adds(dp[i], add(dp[i - 1], f[a[i]]));
        adds(f[a[i]], dp[i - 1]);
    }
    cout << dp[n];
}


Measured memory_bytes: 2560
char X[999],Y[999],R[999];v;main(x,y,r){for(;~scanf("%*d%s%s"+!!*X*3,X,Y);puts(r>917?R+r:"overflow"))for(x=strlen(X),y=strlen(Y),r=998;x|y|v;v/=10)v+=x?X[--x]:48,v-=y?96-Y[--y]:48,R[--r]=v%10+48;}

Measured memory_bytes: 0
import sys
#input = sys.stdin.readline

# A - Digit Sum 2
def digit_sum(str_num):
	sum = 0	
	
	for i in range(len(str_num)):
		sum += int(str_num[i])
	
	return sum


N = input()
patterns = [N]

for i in range(len(N)-1):
	if N[i] != '0':
		left, right = '', ''  
				
		if i > 0:
			left = N[:i]
		
		n = int(N[i]) - 1
		
		if i < len(N) - 1:
			right = '9' * (len(N)-i-1) 
		
		patterns.append(left + str(n) + right)

ans = 0

for p in patterns:
	ans = max(ans, digit_sum(p))
	
print(ans)

Measured memory_bytes: 3064
import java.util.*;

public class Main {
  public static int N;
  public static int M;
  public static boolean[][] path;
  public static boolean[] visit;

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    N = sc.nextInt();
    M = sc.nextInt();
    int[] a = new int[M];
    int[] b = new int[M];
    for (int i = 0; i < M; i++) {
      a[i] = sc.nextInt() - 1;
      b[i] = sc.nextInt() - 1;
    }
    path = new boolean[N][N];
    visit = new boolean[N];
    int ans = 0;
    for (int i = 0; i < M; i++) {
      for (int j = 0; j < N; j++) {
        Arrays.fill(path[j], false);
      }
      Arrays.fill(visit, false);
      for (int j = 0; j < M; j++) {
        path[a[j]][b[j]] = true;
        path[b[j]][a[j]] = true;
      }
      path[a[i]][b[i]] = false;
      path[b[i]][a[i]] = false;
      dfs(0);
      boolean allVisit = true;
      for (int j = 0; j < N; j++) {
        if (!visit[j]) {
          allVisit = false;
        }
      }
      if (!allVisit) {
        ans++;
      }
    }
    System.out.println(ans);
  }

  public static void dfs(int point) {
    visit[point] = true;
    for (int i = 0; i < N; i++) {
      if (path[point][i] && !visit[i]) {
        dfs(i);
      }
    }
  }
}


Measured memory_bytes: 23764
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
namespace mp = boost::multiprecision;

int main(){
    int a, b, c;
	cin >> a >> b >> c;

    int tmp = c - (a - b);
    cout << ((tmp < 0) ? 0 : tmp);
	return 0;
}

Measured memory_bytes: 888
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(a<=b&&c<=d){
        cout << a+c << endl;
    }
    else if(a<=b&&c>=d){
        cout << a+d << endl;
    }
    else if(a>=b&&c<=d){
        cout << b+c << endl;
    }
    else if(a>=b&&c>=d){
        cout << b+d << endl; 
    }
    return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize "trapv"
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define S 1000001
#define M 1000000007
#define nl cout<<"\n";
#define er  cout<<"\n***********\n";
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define test lli t;  cin>>t; while(t--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define Y cout<<"YES\n";
#define N cout<<"NO\n";
#define print(x)                 cout<<#x<<": "<<x<<endl;
#define print2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl;
#define print3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define print4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define print5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl;
#define print6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl;
int main()
{
    fast
    lli n,q,sum=0;
    cin>>n;
    map<lli,lli> mpp;
    vector<lli> v(n);
    for(lli i=0;i<n;i++)
    {
        cin>>v[i];
        mpp[v[i]]++;
        sum=sum+v[i];
    }
    cin>>q;
    while(q--)
    {
        lli b,c;
        cin>>b>>c;
        sum=sum-mpp[b]*(b)+mpp[b]*c;
        mpp[c]=mpp[c]+mpp[b];
        mpp[b]=0;
        cout<<sum;
        nl
    }
}
//a+b=a?b+2?(a&b)
//a+b==(a&b)+(a|b)
//__builtin_popcount(number)
//cout<<fixed<<setprecision(8)<<output<<"\n";



Measured memory_bytes: 9948
import java.util.HashSet;
import java.util.Scanner;

/**
 *
 * @author lenovo
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        HashSet<Integer> set = new HashSet();
        
        for(int i=0;i<N;i++){
            int s = sc.nextInt();
            if( set.contains(s) ){
                set.remove(s);
            }else{
                set.add(s);
            }
        }
        System.out.println(set.size());
    }
    
}


Measured memory_bytes: 61064
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
#include <memory>
#include <stack>
#include <set>
#include <map>

#define INF 1000000000
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

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

  double T,X; cin>>T>>X;
  double ans = T / X;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
using namespace std;
int max(int a, int b) {
    if (a > b) return a;
    return b;
}
typedef long long ll;
map<string, int> m1, m2;
int main() {
    int N, M;
    cin >> N;
    string str;
    for (int i = 0; i < N; ++i) {
        cin >> str;
        m1[str] += 1;
    }
    cin >> M;
    for (int i = 0; i < M; ++i) {
        cin >> str;
        m2[str] += 1;
    }
    int res = 0;

    for (auto it = m1.begin(); it != m1.end(); ++it) {
        str = (*it).first;
        if (m1[str] > m2[str]) {
            res = max((m1[str] - m2[str]), res);
        }
    }

    cout << res;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <tr1/unordered_map>
//#include "Bignum/bignum.h"
//#define big bignum
#define lowbit(x) (x & -x)
#define debug(x) (cout << "#x = " << (x) << endl)
#define Set(x, i) memset (x, i, sizeof(x))
#define re register
#define For(i, j, k) for(re int i = (j); i <= (int) (k); ++i)
#define Rep(i, j, k) for(re int i = (j); i >= (int) (k); --i)
#define Cross(i, j, k) for(re int i = (j); i; i = (k))
using namespace std;
typedef long long ll;
const ll N = 100011;
const ll INF = 5e16;

namespace IO {

	inline char gc() {
		static char buf[100000], *p1 = buf, *p2 = buf;
		return (p1 == p2) && (p2 = (p1 = buf) +
			fread(buf, 1, 100000, stdin), p1 == p2)? EOF: *p1++;
	}

	#define dd ch = getchar()
	inline ll read() {
		ll x = 0; int f = 0; char dd;
		for (; !isdigit(ch); dd) f ^= (ch == '-');
		for (; isdigit(ch); dd)  x = x * 10 + (ch ^ 48);
		return f? -x: x;
	}
	#undef dd

	inline void write ( ll x ) {
		if (x < 0) x = -x, putchar('-');
		if (x > 9) write(x / 10); putchar(x % 10 | 48);
	}

	inline void wrn ( ll x ) { write(x), putchar(' '); }

	inline void wln ( ll x ) { write(x), putchar('\n'); }

	inline void wlnn ( ll x, ll y ) { wrn(x), wln(y); }

}

using IO::wln;
using IO::read;

namespace Cesare {
	
	ll n, k, Ans, fa[N], dep[N];
	
	struct Edge {
		ll To, Next;
	} e[N << 1];
	
	ll cnt = 0, head[N];
	
	inline void add (int u, int v) {
		e[++cnt] = (Edge) {v, head[u]}, head[u] = cnt;
	}
	
	inline void dfs ( ll u ) {
		dep[u] = 1;
		Cross ( i, head[u], e[i].Next ) {
			ll v = e[i].To;
			if (v == fa[u]) continue;
			dfs(v), dep[u] = max(dep[u], dep[v] + 1);
		}
		if (dep[u] == k && fa[u] > 1) dep[u] = 0, ++Ans;
	}
	
	int main() {
		n = read(), k = read();
		For ( i, 1, n ) fa[i] = read();
		if (fa[1] != 1) ++Ans, fa[1] = 1;
		For ( i, 2, n ) add(fa[i], i);
		dfs(1); return wln(Ans), 0;
	}
	
}

int main()
{
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);

	return Cesare :: main();
}

/*

*/




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

using namespace std;

int main()
{

    string a,b;
    cin >> a>>b;
    int c=0;
    for(int i=0;i<a.size();i++)
    {
        if(a[i] != b[i])
        {
            c++;
        }
    }
    cout << c;
    return 0;
}


Measured memory_bytes: 3860
S = input()

# アルファベットに対応するからのbucketを作成する
bucket = [False for _ in range(26)]

for i in S:
    bucket[ord(i)-ord('a')] = True

false_idx = -1

for i in range(26):
    if bucket[i] == False:
        false_idx = i
        break

#すべてFalseだった場合
if false_idx == -1:
    print('None')
else:
    print(chr(ord('a')+i))

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

int main(){
    int n,l[1000000],k;
    cin>>n>>k;
    int DP[1000000];
    const int INF=1e9+10;
    for (int i=0;i<n;i++){
        cin>>l[i];
        DP[i]=INF;
        // cout<<l[i];
    }
    for (int i=0;i<n;i++){
        DP[0]=0;
        for (int j=0;j<=k;j++){
            if(i-j>=0){
                DP[i]= min(DP[i],DP[i-j]+abs(abs(l[i]-l[i-j])));
                //cout<<"DP"<<i<<" "<<DP[i]<<endl;
            } 
            
        }
    }
    cout<<DP[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 4608
n = int(input())
A = list(map(int,input().split()))
A.sort()
B = list(map(int,input().split()))
C = list(map(int,input().split()))
C.sort()

total = 0
tmp_a_t = 0
tmp_c_t = 0
from bisect import bisect_left,bisect_right
for i,b in enumerate(B):
    tmp_a = bisect_left(A,b)
    tmp_c = len(C)-bisect_right(C,b)
    #print(tmp_a,tmp_c)
    total += tmp_a*tmp_c
# print(tmp_a,tmp_c_t)
# total += tmp_a*tmp_c_t
print(total)



Measured memory_bytes: 105572
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <cmath>

using ll = long long;
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) < (b)) ? (b) : (a))

int const nmax = 300;
int mat[2][1 + 2 * nmax][1 + 2 * nmax];

std::vector<std::pair<int,int>> mv[2];
int lim;

bool valid(int x, int y) {
  return 0 <= x && x < lim && 0 <= y && y < lim;
}

void dfs(int x, int y, int color, int p) {
  if(mat[p][x][y] == 0) {
    mat[p][x][y] = color;
    for(int h = 0; h < mv[p].size(); h++) {
      int newx = x + mv[p][h].first;
      int newy = y + mv[p][h].second;
      if(valid(newx, newy))
        dfs(newx, newy, 3 - color, p);
    }
  }
}
int frec[3][3];

int main() {
  int n, d1, d2;
  std::cin >> n;
  std::cin >> d1 >> d2;
  lim = 2 * n;
  for(int i = -lim; i <= lim; i++)
    for(int j = -lim; j <= lim; j++) {
      if(i * i + j * j == d1)
        mv[0].push_back({i, j});
      if(i * i + j  * j == d2)
        mv[1].push_back({i, j});
    }
  for(int i = 0; i < lim; i++)
    for(int j = 0; j < lim; j++) {
      dfs(i, j, 1, 0);
      dfs(i, j, 1, 1);
      frec[mat[0][i][j]][mat[1][i][j]]++;
    }
  for(int h = 1; h <= 2; h++)
    for(int h2 = 1; h2 <= 2; h2++)
      if(n * n <= frec[h][h2]) {
        int lft = n * n;
        for(int i = 0; i < lim; i++)
          for(int j = 0; j < lim; j++)
            if(0 < lft && mat[0][i][j] == h && mat[1][i][j] == h2) {
              std::cout << i << " " << j << '\n';
              lft--;
            }
        return 0;
      }
  return 0;
}


Measured memory_bytes: 34532
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        int x=in.nextInt();
        Integer []ar=new Integer[n];
        for(int i=0;i<n;i++) {
            ar[i] = in.nextInt();
        }
        long res=0;
        for(int i=0;i<n-1;i++){
            if(ar[i+1]!=0&&ar[i]+ar[i+1]>x){
                res+=((ar[i]+ar[i+1])-x);
                ar[i+1]-=((ar[i]+ar[i+1])-x);
                if(ar[i+1]<0){
                    ar[i]-=Math.abs(ar[i+1]);
                    ar[i+1]=0;
                }
            }
        }
        System.out.println(res);
    }
}


Measured memory_bytes: 63236
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			execute(scanner);
		}
	}

	private static void execute(Scanner scanner) {
		String[] array = scanner.nextLine().split(" ");
		int x = array[0].charAt(0);
		int y = array[1].charAt(0);
		if (x < y) {
			System.out.println("<");
			return;
		}
		if (x > y) {
			System.out.println(">");
			return;
		}
		System.out.println("=");
	}
}


Measured memory_bytes: 24020
import java.util.*;

public class Main {
    public static void main(String args[]){
        Scanner stdIn = new Scanner(System.in);
        int a = stdIn.nextInt();
        int b = stdIn.nextInt();
        
        if(a >= 1 && a <= 9 && b >= 1 && b <= 9){
            System.out.println(a * b);
        }else{
            System.out.println(-1);
        }
        
        
    }
}


Measured memory_bytes: 22100
#include<bits/stdc++.h>
 
using namespace std;
#define taskname "A"
#define pb	push_back
#define mp 	make_pair
#define rep(i, l, r) for (int i = (l); i <= (r); ++i)
 
#ifndef LOCAL
#define cerr if(0)cout
#endif
 
typedef long double ld;
typedef long long ll;
typedef pair<int,int> ii;
const int maxn = 2e5 + 6;
 
int n , a[maxn];
int res = 1;
int l[maxn] , r[maxn];
 
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen(taskname".INP","r")){
		freopen(taskname".INP", "r",stdin);
		freopen(taskname".OUT", "w",stdout);
    }
    cin >> n;
    for(int i = 1 ; i <= n ; ++i)cin >> a[i];
    for(int i = 1 ; i <= n ; ++i){
        l[i] = __gcd(l[i - 1] , a[i]);
    }
    for(int i = n ; i >= 1 ; --i){
        r[i] = __gcd(r[i + 1] , a[i]);
    }
    for(int i = 1 ; i <= n ; ++i){
        res = max(res , __gcd(l[i - 1] , r[i + 1]));
    }
    cout << res;
    cerr << __gcd(0,0);
}

Measured memory_bytes: 1408