akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <climits>
#include <iomanip>
#define endl "\n"
#define debug(x) cout << #x << " : " << x << endl;
#define debug2(x, y) cout << #x << " : " << x  << ", " << #y << " : " << y << endl;
#define FASTIO ios_base::sync_with_stdio(false),cin.tie(0);
typedef long long ll;
using namespace std;

int main()
{
	FASTIO

	ll x, k, d;
	cin >> x >> k >> d;

	ll moves_req = abs(x) / d;
	// debug(moves_req)
	ll pos;
	if(moves_req >= k)
		pos = abs(x) - k * d;
	else
	{
		pos = abs(x) - moves_req * d;
		ll moves_left = k - moves_req;
		if(moves_left % 2 == 1)
			pos = abs(pos - d);
	}

	cout << pos << endl;
}

Measured memory_bytes: 3652
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>/*toupperとかが入っている*/
#include<vector>/*可変長配列vectorのインクルード*/
 
const int MOD=1000000007;/* 1,000,000,007 で割った余りを出力する　のとき使う*/
using namespace std;/*標準名前空間を利用する。cinやcoutはこれによって利用可能になる*/
 
string S;
string T;
 
int main(void) {
  cin >> S;
  cin >> T;
  
  int S_size = S.length();
  int T_size = T.length();
  
  int ans = T_size;
  
  for(int i = 0; i <= S_size - T_size; i++){
    int count = 0;
    for(int j = 0; j < T_size; j++){
      if(S[i+j] != T[j]){
        count++;
      }
    }
    ans = min(count, ans);
  }
  
  cout << ans << endl;
 
  return 0;
}


Measured memory_bytes: 3596
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <cmath>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;

int n;
vector<P> vec;
ll dp[5001][5001];

bool comp(const P &a, const P &b){
  return a.first + a.second < b.first + b.second;
}

int main(int argc, char const* argv[])
{
  cin >> n;
  for(int i = 0; i < n; i++){
    int h, p;
    cin >> h >> p;
    vec.pb(mk(h, p));
  }
  sort(vec.begin(), vec.end(), comp);
  for(int i = 0; i < n + 1; i++){
    for(int j = 0; j < n + 1; j++){
      dp[i][j] = linf;
    }
  }
  dp[0][0] = 0;
  for(int i = 0; i < n; i++){
    for(int j = 0; j <= n; j++){
      dp[i + 1][j] = dp[i][j];
      if(j > 0 && dp[i][j-1] <= vec[i].first)dp[i+1][j] = min(dp[i+1][j], dp[i][j-1] + vec[i].second);
    }
  }
  for(int i = n; i > 0; i--){
    if(dp[n][i] < linf / 2){
      cout << i << endl;
      return 0;
    }
  }
	return 0;
}


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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> cnt(n+1, 0);
    for(int i=0;i<n;i++){
        int a;
        cin >> a;
        cnt[a]++;
    }
    sort(cnt.rbegin(), cnt.rend());
    int ans = n;
    for(int i=0;i<k;i++){
        ans -= cnt[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

int n;
double x, dp[3001][3001];
vector <double> a;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout << fixed << setprecision(12);
    a.push_back(0);
    cin >> n;
    for(int i = 0 ; i < n && cin >> x ; i++)
        a.push_back(x);
    dp[1][1] = a[1];
    dp[1][0] = (1 - a[1]);
    for(int i = 2 ; i <= n ; i++){
        dp[i][0] = dp[i - 1][0] * (1 - a[i]);
        for(int j = 1 ; j <= i ; j++)
            dp[i][j] = dp[i - 1][j] * (1 - a[i]) + dp[i - 1][j - 1] * a[i];
    }
    double ans = 0;
    for(int i = (n + 1) / 2 ; i <= n ; i++)
        ans += dp[n][i];
    cout << ans << endl;
}


Measured memory_bytes: 68992
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
typedef long long i64;
int main(){
  while(true){
    int n;
    vector<int> a;
    cin >> n;
    if(n==0) break;
    rep(i,n){
      int b;
      cin >> b;
      a.push_back(b);
    }
    sort(a.begin(),a.end());
    int total=0;
    repi(i,1,n-1){
      total+=a[i];
    }
    cout << total/(n-2) << endl;;
  }
  return 0;
}

Measured memory_bytes: 3008
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;

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

	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (a + b == c + d) {
		cout << "Balanced" << endl;
	}
	else if (a + b > c + d) {
		cout << "Left" << endl;
	}
	else {
		cout << "Right" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
import sys
#import numpy as np
#from collections import defaultdict
import math
#from collections import deque

input = sys.stdin.readline



def main():


    n = int(input())

    dp = [0]*n
    dp[0] = list(map(int,input().split()))

    for i in range(1,n):
        dp[i] = list(map(int,input().split()))
        dp[i][0] += max(dp[i-1][1],dp[i-1][2])
        dp[i][1] += max(dp[i - 1][0], dp[i - 1][2])
        dp[i][2] += max(dp[i - 1][0], dp[i - 1][1])
    print(max(dp[n-1]))


if __name__ == "__main__":
    main()

Measured memory_bytes: 85212
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  int h, w;
  cin >> h >> w;
  vector<vector<int>> a(h);
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      char c;
      cin >> c;
      if (c == 'B') a[i].push_back(j);
    }
  }
  vector<pair<int, int>> candi;
  for (int i = 0; i < h; i++) {
    if (a[i].empty()) continue;
    candi.emplace_back(i, a[i][0]);
    candi.emplace_back(i, a[i].back());
  }
  int ans = 0;
  for (int i = 0; i < (int) candi.size(); i++) {
    for (int j = 0; j < (int) candi.size(); j++) {
      ans = max(ans, abs(candi[i].first - candi[j].first) + abs(candi[i].second - candi[j].second));
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6456
#include <bits/stdc++.h>
using namespace std;
typedef long long       ll;
const ll  big =1e5+5;
ll freq[big];

int main()
{ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
ll n,k,a[big],sum=0;
cin>>n;
pair <int,int> q[big];
for(int i=0;i<n;++i){
    cin>>a[i];
    sum+=a[i];
    freq[a[i]]++;
}
cin>>k;
for(int i=0;i<k;++i){
    cin>>q[i].first>>q[i].second;
     if(freq[q[i].first]==0){cout<<sum<<endl;}
     else{
        sum-=freq[q[i].first]*q[i].first;
        sum+=freq[q[i].first]*q[i].second;
        freq[q[i].second]+=freq[q[i].first];
        freq[q[i].first]=0;
        cout<<sum<<endl;
     }

}

    return 0;
}

Measured memory_bytes: 5968
import java.util.*;
import java.io.*;

public class Main{
	public static void solve(String str){
		StringBuilder temp = new StringBuilder();
		for(int i = 0; i < str.length(); i++){
			switch( str.charAt(i) ){
				case ' ' : temp.append("101"); break;
				case '\'' : temp.append("000000"); break;
				case ',' : temp.append("000011"); break;
				case '-' : temp.append("10010001"); break;
				case '.' : temp.append("010001"); break;
				case '?' : temp.append("000001"); break;
				case 'A' : temp.append("100101"); break;
				case 'B' : temp.append("10011010"); break;
				case 'C' : temp.append("0101"); break;
				case 'D' : temp.append("0001"); break;
				case 'E' : temp.append("110"); break;
				case 'F' : temp.append("01001"); break;
				case 'G' : temp.append("10011011"); break;
				case 'H' : temp.append("010000"); break;
				case 'I' : temp.append("0111"); break;
				case 'J' : temp.append("10011000"); break;
				case 'K' : temp.append("0110"); break;
				case 'L' : temp.append("00100"); break;
				case 'M' : temp.append("10011001"); break;
				case 'N' : temp.append("10011110"); break;
				case 'O' : temp.append("00101"); break;
				case 'P' : temp.append("111"); break;
				case 'Q' : temp.append("10011111"); break;
				case 'R' : temp.append("1000"); break;
				case 'S' : temp.append("00110"); break;
				case 'T' : temp.append("00111"); break;
				case 'U' : temp.append("10011100"); break;
				case 'V' : temp.append("10011101"); break;
				case 'W' : temp.append("000010"); break;
				case 'X' : temp.append("10010010"); break;
				case 'Y' : temp.append("10010011"); break;
				case 'Z' : temp.append("10010000"); break;
			}
		}
		while( temp.length()%5 != 0 ){
			temp.append("0");
		}
		String s = new String(temp);
		
		StringBuilder ans = new StringBuilder();
		for(int i = 0; i < s.length()/5; i++){
			int x = Integer.parseInt(s.substring(i*5, i*5+5),2);
			if( x < 26 ){
				ans.append(Character.toString((char)('A'+x)));
			} else {
				switch( x ){
					case 26: ans.append(" "); break;
					case 27: ans.append("."); break;
					case 28: ans.append(","); break;
					case 29: ans.append("-"); break;
					case 30: ans.append("'"); break;
					case 31: ans.append("?"); break;
				}
			}
		}
		System.out.println(ans);
	}
			
	public static void main(String[] args){
		Scanner stdIn = null;
		
		try{
			stdIn = new Scanner(new BufferedReader(new InputStreamReader(System.in)));		
			while( stdIn.hasNext() ){
				String str = stdIn.nextLine();
				solve(str);		
			}
		} finally {
			if( stdIn != null ){
				stdIn.close();
			}
		}
	}
}

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

#define ll long long
#define ull unsigned long long 
#define endl '\n'
#define pii pair<int, int>
#define all(a) a.begin(),a.end()

int main(){
    int n;
    cin >> n;
    vector<pair<ll, ll> > a(n);
    ll ans=0;

    for(int i=0; i<n; ++i){
        cin >> a[i].first >> a[i].second;
    }

    for(int i=n-1; i>=0; --i){
        a[i].first = a[i].first+ans;

        if(a[i].first % a[i].second == 0)
            continue;

        if(a[i].first > a[i].second){
            ll z = a[i].first/a[i].second + 1;
            ans += a[i].second * z - a[i].first;
        }
        else{
            ans += a[i].second - a[i].first;
        }
    }
    cout << ans;
}


Measured memory_bytes: 4800
#include <bits/stdc++.h>
#define inf 100000000000000LL
#define ll long long
#define mx 1000007
using namespace std;

vector< vector<ll> > tree( 4LL*mx, {0LL,inf} );

ll f(vector<ll> line, int x){
	return line[0] * x + line[1];
}

void insert(vector<ll> line, int lo = 1, int hi = mx, int i = 1){
	int m = (lo + hi) / 2;
	bool left = f(line, lo) < f(tree[i], lo);
	bool mid = f(line, m) < f(tree[i], m);

	if(mid) swap(tree[i], line);

	if(hi - lo == 1) return;
	else if(left != mid) insert(line, lo, m, 2*i);
	else insert(line, m, hi, 2*i+1);
}

ll query(int x, int lo = 1, int hi = mx, int i = 1){
	int m = (lo+hi)/2;
	ll curr = f(tree[i], x);
	if(hi-lo==1) return curr;
	if(x<m) return min(curr, query(x, lo, m, 2*i));
	else return min(curr, query(x, m, hi, 2*i+1));
}

ll dp[mx];

int main()
{
	ll n,c;
	cin>>n>>c;

	ll h[n+5];

	for( int i=1;i<=n;i++ )
	{
		cin>> h[i];

		if(i>1)
			dp[i]= h[i]*h[i]+c+query( h[i] );

		insert( { -2*h[i], h[i]*h[i]+dp[i] } );
	}

	cout<< dp[n] <<"\n";
}


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

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

using namespace std;

int main(){
    int A,B,C,D;
    cin>>A>>B>>C>>D;
    int s,f;
    s=A<C?C:A;
    f=B<D?B:D;
    if(f-s<0){
        cout<<"0"<<endl;
        return 0;
    }else{
        cout<<f-s<<endl;
        return 0;
    }
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    A, B, C = [int(x) for x in input().split()]


    if A % 2 == 0 or B % 2 == 0 or C % 2 ==0:
        print(0)
    else:
        print(min(A * B, B * C, C * A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
K, N = map(int, input().split())
A = list(map(int, input().split()))

dif_max = 0

for i in range(N):
    if i == 0:
        dif = A[0] + (K - A[-1])
    else:
        dif = abs(A[i] - A[i-1])
    if dif > dif_max:
        dif_max = dif

print(K - dif_max)

Measured memory_bytes: 26444
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
std::vector< pair<long long, long long> > coordinate;
long long n,d,tmp,ct=0;
void solve(){
    rep(i,n){
        if((pow(coordinate.at(i).first,2)+pow(coordinate.at(i).second,2))<=pow(d,2)) {
            ct++;
        }
    }
    cout<<ct<<endl;
}

int main(){
    cin>>n>>d;
    rep(i,n){
        pair<long long, long long> tpair;
        cin>>tmp;
        tpair.first=tmp;
        cin>>tmp;
        tpair.second=tmp;

        coordinate.emplace_back();
        coordinate.at(i)=tpair;
    }

    solve();
    return 0;
}


Measured memory_bytes: 7428
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  int n;
  cin>>n;
  if(n==1){
    cout<<3;
    return 0;
  }
  if(n==2){
    cout<<6;
    return 0;
  }
  char m,s;
  vector<int> a;
  cin>>s;
  m=s;
  int j=1;
  for(int i=1;i<n;i++){
    cin>>s;
    if(m==s) j++;
    else{
      a.push_back(j);
      m=s;
      j=1;
    }
  }
  a.push_back(j);
  ll c=a[0]*3;
  for(int i=1;i<a.size();i++){
    if(a[i]==1){
      if(a[i-1]==1){
        c*=2;
      }
    }else{
      if(a[i-1]==1){
        c*=2;
      }else{
        c*=3;
      }
    }
    c%=1000000007;
  }
  cout<<c;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <bitset>
#include <fstream>
#include <iomanip>

#define ll long long
#define scani(x) scanf("%i", &x)
#define scanll(x) scanf("%I64d", &x)
#define scanfl(x) scanf("%f", &x)
#define scanch(x) scanf("%c", &x)
#define scans(x) scanf("%s", x);
#define printi(x) printf("%i", x);
#define printll(x) printf("%I64d", x);
#define printfl(x) printf("%f", x);
#define printch(x) printf("%c", x);
#define prints(x) printf("%s", x);
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define INFI (1 << 29)
#define INFL (1LL << 62)
#define sz(x) int(x.size())
#define fi first
#define se second
#define forn(i, n) for(ll i = 0; i < n; i++)
#define for1(i, n) for(ll i = 1; i <= n; i++)
#define ford(i, n) for(ll i = (n - 1); i >= 0; i--)
#define fori(i, n) for(ll i = n; i >= 1; i--)
#define fore(i, l, r) for(ll i = l; i <= r; i++)
#define get_bit(mask, x) (bool)(mask & (1LL << x))
#define set_bit(mask, x) (mask |= (1LL << x))
#define reset_bit(mask, x) (mask &= ~(1LL << x))
#define toggle_bit(mask, x) (mask ^= (1LL << x))

using namespace std;

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

    ll n;
    long double r = 0.0;

    cin >> n;

    vector < long double > v(n);

    forn(i, n)
        cin >> v[i];

    sort(all(v));

    r = ((v[0] + v[1]) / 2);

    fore(i, 2, (n - 1))
        r = ((v[i] + r) / 2);

    cout << fixed << setprecision(10) << r << "\n";

    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n, q int
	fmt.Scan(&n, &q)

	var s string
	fmt.Scan(&s)

	ss := make([]int, n)
	cnt := 0
	for i := 1; i < n; i++ {
		if s[i] == 'C' && s[i-1] == 'A' {
			cnt++
		}
		ss[i] = cnt
	}

	var l, r int
	for i := 0; i < q; i++ {
		fmt.Scan(&l, &r)
		result := ss[r-1] - ss[l-1]
		fmt.Println(result)
	}

}


Measured memory_bytes: 6912
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <string>
#include <queue>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

using namespace std;

int main()
{
    long long m, n;
    cin >> m >> n;
    if (m == 1 && n == 1) {
        cout << 1 << endl;
    }
    else if (m == 1) {
        cout << n - 2 << endl;
    }
    else if (n == 1) {
        cout << m - 2 << endl;
    }
    else {
        cout << m * n - (m + n) * 2 + 4 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int n=0,m=0,a=0,b=0,count=0;
    int H[100000]={},flag[100000]={};
    scanf("%d %d",&n,&m);
    for(int i=0;i<n;i++){
        scanf("%d",&H[i]);
        flag[i]=1;
    }
    for(int i=0;i<m;i++){
        scanf("%d %d",&a,&b);
        if(H[a-1]>=H[b-1]){
            flag[b-1]=0;
        }
        if(H[b-1]>=H[a-1]){
            flag[a-1]=0;
        }
    }
    for(int i=0;i<n;i++){
        if(flag[i]==1) count+=1;
    }

    printf("%d\n",count);
    return 0;
}


Measured memory_bytes: 2508
import java.util.*;
import static java.lang.System.*;

public class Main {
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int a = cin.nextInt();
        int b = cin.nextInt();
        int c = cin.nextInt();
        int x = cin.nextInt();
        int y = cin.nextInt();
        int ans = 1000000000;
        for (int i = 0; i <= 2 * 100000; i += 2) {
            int nowx = x - i / 2;
            int nowy = y - i / 2;
            int cost = c * i;
            if (nowx > 0) cost += a * nowx;
            if (nowy > 0) cost += b * nowy;
            ans = Math.min(ans, cost);
        }
        out.println(ans);
    }
}


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

#define long long long int
using namespace std;

// @author: pashka

struct point {
    double x, y;
};

double dist(point a, point b) {
    return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
}

int n, k;
vector<point> p;
vector<double> c;

bool good(double t) {
    if (k == 1)
        return true;
    vector<double> r(n);
    for (int i = 0; i < n; i++) {
        r[i] = t / c[i];
    }
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (dist(p[i], p[j]) > r[i] + r[j]) continue;
            if (dist(p[i], p[j]) < abs(r[i] - r[j])) continue;
            double aa = -2 * (p[i].x - p[j].x);
            double bb = -2 * (p[i].y - p[j].y);
            double cc = p[i].x * p[i].x - p[j].x * p[j].x +
                    p[i].y * p[i].y - p[j].y * p[j].y - r[i] * r[i] +
                    r[j] * r[j];
            // aa * x + bb * y + cc = 0
            double dd = dist({0, 0}, {aa, bb});
            aa /= dd;
            bb /= dd;
            cc /= dd;

            dd = aa * p[i].x + bb * p[i].y + cc;
            point perp = {p[i].x - aa * dd, p[i].y - bb * dd};
            double qq = sqrt(r[i] * r[i] - dd * dd);

            vector<point> oo = {
                    {perp.x + bb * qq, perp.y - aa * qq},
                    {perp.x - bb * qq, perp.y + aa * qq}
            };

            for (point o : oo) {
                int s = 0;
                for (int q = 0; q < n; q++) {
                    if (dist(p[q], o) <= r[q] || q == i || q == j) s++;
                }
                if (s >= k) return true;
            }
        }
    }
    for (point o : p) {
        int s = 0;
        for (int q = 0; q < n; q++) {
            if (dist(p[q], o) <= r[q]) s++;
        }
        if (s >= k) return true;
    }
    return false;
}

int main() {
    ios::sync_with_stdio(false);

    cin >> n >> k;
    p.resize(n);
    c.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i].x >> p[i].y >> c[i];
    }

    double l = 0;
    double r = 1e10;
    for (int tt = 0; tt < 100; tt++) {
        double m = (l + r) / 2;
        if (good(m)) {
            r = m;
        } else {
            l = m;
        }
    }
    cout << setprecision(20) << r << "\n";

    return 0;
}

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

#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair
 
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
 
const int mod=1e9+7;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int mul(int a,int b)
{
	return ((a)*1ll*(b))%mod;
}
 
void add(int &a,int b)
{
	a+=b;
	if(a>=mod)a-=mod;
}
 
int sub(int a,int b){
	a-=b;
	if(a<0){
		a+=mod;
	}
	return a;
}
 
int powz(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1){
			res=mul(res,a);
		}
		b/=2;
		a=mul(a,a);
	}
	return res;
}
 
template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
	input>>x.F>>x.S;
	return input;
}
 
template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
	for(auto& i:x)
		input>>i;
	return input;
}
 
template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
	for(auto& i:x)
		output<<i<<' ';
	return output;
}
 
const int N=1000002;

void solve(){
	int n,k;
	cin>>n>>k;
	vi a(n);
	cin>>a;
	sort(all(a));
	ll ans=0;
	for(int i=0;i<n-k;i++){
		ans+=a[i];
	}
	cout<<ans;
}
 
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int tc=1;
	//~cin>>tc;
	for(int _=0;_<tc;_++){
		//~ cout<<"Case #"<<_+1<<": ";
		solve();
		if(_!=tc-1)
		cout<<"\n";
	}
}


Measured memory_bytes: 1024
#include <fstream>
#include <vector>
#include <set>
#include <iostream>

// BE CAREFUL WITH HASH TABLE & UNORDERED MAP
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
using namespace std;

#define MOD 998244353
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = (b-1); i >= (a); i--)
#define RF0(i,b) RFO(i,0,b)
#define ll long long
#define pii pair<int,int>
#define ppp pair<pair<pii,pii>,int>
#define add(a,b) ((int) (((ll) (a) + (b))%MOD))
#define mul(a,b) ((int) (((ll) (a) * (b))%MOD))
#define PB emplace_back
#define MP make_pair
#define F first
#define S second

// ifstream cin ("cinput.in");
// ofstream cout ("coutput.out");

int H, W, K, x1, y1, x2, y2;
int moves [4][2] = {{-1,0},{1,0},{0,-1},{0,1}};
char a;
vector<vector<int>> grid;
set<ppp> queue; // ((priority, cost), (r,c))

bool valid(int r, int c) {
    return (0 <= r && r < H && 0 <= c && c < W);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> H >> W >> K;
    cin >> x1 >> y1 >> x2 >> y2;
    x1--; y1--; x2--; y2--;
    F0R(i,H) {
        grid.PB(vector<int>());
        F0R(j,W) grid[i].PB(2000000);
    }
    F0R(i,H) F0R(j,W) {
        cin >> a;
        if (a == '@') grid[i][j] = -1;
    }

    // Dijkstra's
    grid[x1][y1] = 0;
    queue.emplace(MP(MP(MP(4,0),MP(x1,y1)),0));
    while (!queue.empty()) {
        ppp cur = *queue.begin(); queue.erase(queue.begin());
        if (cur.F.F.F != 4 && cur.S >= 0 ) queue.emplace(MP(MP(MP(4,cur.F.F.S), MP(cur.F.S.F, cur.F.S.S)),0));
        cur.S = abs(cur.S);
        F0R(i,4) {
            int nr = cur.F.S.F + moves[i][0], nc = cur.F.S.S + moves[i][1], nm = cur.F.F.S + (cur.F.F.F == 4), ns = cur.S+1;
            if ((cur.F.F.F != 4 && i != cur.F.F.F)
                || !valid(nr, nc)
                || grid[nr][nc] == -1
                || cur.S == K
                || grid[nr][nc] <= nm-1
                ) continue;
            if (grid[nr][nc] > nm) grid[nr][nc] = nm;
            else ns *= -1;
            queue.emplace(MP(MP(MP(i,nm), MP(nr,nc)), ns));
        }
    }
    if (grid[x2][y2] == 2000000) cout << "-1\n";
    else cout << grid[x2][y2] << '\n';
}

Measured memory_bytes: 14708
a, b, c, k = map(int, input().split())



if k <= a:      #aのほうがｋ（カードを引く回数より）大きかった時
    ans = k     #ｋの回数分＝最大値
else:           #aよりｋのほうが大きかった時
    y = k - a   #引く回数 - a = 残りの引ける数
    if y <= b:  #ｂより残り引ける数が小さければ
        ans = a
    else :
        y -= b
        ans = a - y
print(ans)

Measured memory_bytes: 9124
#include<stdio.h>
int main()
{
	int x,r;
	scanf("%d",&x);
	r=x%7;
	switch(r){
	case 1:
		printf("fri\n");
		break;
	case 2:
		printf("sat\n");
		break;
	case 3:
		printf("sun\n");
		break;
	case 4:
		printf("mon\n");
		break;
	case 5:
		printf("tue\n");
		break;
	case 6:
		printf("wed\n");
		break;
	default:
		printf("thu\n");
	}
    return 0;
}

Measured memory_bytes: 2608
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();

    // input
    let h: usize = read(&mut stdin_lock, &mut buf, b' ');

    let mut ans = 1u64;
    let mut x = h;
    let mut b = 1;
    while x > 1 {
        b *= 2;
        x /= 2;
        ans += b;
    }
    println!("{}", ans);
}


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

using namespace std;

typedef long long ll;

const int MOD = 1e9 + 7;
const int N = 1e6 + 34;

int main()
{
    ll c = 1000;
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for (int i = 0; i + 1 < n; i++)
    {
        if (a[i] < a[i + 1])
        {
            ll cnt = c / a[i];
            c -= cnt * a[i];
            c += cnt * a[i + 1];
        }
    }
    cout << c;
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

#define MAX_N 131072
i64 N, N_, K, Q;

/* シンプルな実装 O(N + Q) */
/*
i64 A[MAX_N];


int main() {
  cin >> N >> K >> Q;
  REP(i, N) A[i] = K - Q;

  i64 q;
  REP(i, Q) {
    cin >> q;
    q--;
    A[q] += 1;
  }
  REP(i, N) {
    if (A[i] > 0) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }

  return 0;
}
*/

/* RMQ O(QlogN) */
i64 dat[2 * MAX_N - 1];


void query(i64 a, i64 b, i64 k, i64 l, i64 r) {
  // [a, b)と[l, r)が交差していなければ何もしない
  if (b <= l || r <= a) return;

  // [a, b)が[l, r)を完全に含んでいれば節点kから-1
  if (a <= l && r <= b) dat[k]--;
  else {
    query(a, b, 2 * k + 1, l, (l + r) / 2);
    query(a, b, 2 * k + 2, (l + r) / 2, r);
  }
}


// i番目のスコアを返す
i64 get_result(i64 p) {
  i64 i = N - 1 + p; // 葉
  i64 res = dat[i];
  while (i > 0) {
    i = (i - 1) / 2;
    res += dat[i];
  }
  return res;
}


int main() {
  cin >> N_ >> K >> Q;
  N = 1;
  while (N < N_) {
    N *= 2;
  }

  REP(i, 2 * N - 1) dat[i] = 0;

  // 葉をKに更新
  for (i64 i = N - 1; i < 2 * N - 1; i++) {
    dat[i] = K;
  }

  // クエリを処理
  i64 q;
  REP(i, Q) {
    cin >> q;
    q--;
    query(0, q, 0, 0, N);
    query(min(q + 1, N), N, 0, 0, N);
  }

  REP(i, N_) {
    if (get_result(i) > 0) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 2688
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

void solve() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			for (int k = j + 1; k < n; k++) {
				if (a[i] != a[j] && a[i] != a[k] && a[j] != a[k] && a[i] + a[j] > a[k]) {
					ans++;
				}
			}
		}
	}

	cout << ans;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int q = 1;
	//cin >> q;
	for (; q > 0; q--) {
		solve();
		cout << endl;
	}
}

Measured memory_bytes: 3584
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
using namespace std;


#define INF (1ll<<60)

int main(int argc, char const *argv[]) {
	int n,k;cin>>n>>k;
	vector<long long> a(n);
	for(int i=0;i<n;++i)cin>>a[i];
	sort(a.begin(),a.end());
	int l=-1,r=n;
	// int res=0;
	// for(int m=0;m<n;++m){
	while(r>l+1){
		int m=(l+r)/2;
		vector<bool> dp(k);
		dp[0]=true;
		bool needed = false;
		if(0>=k-a[m])needed=true;
		for(int i=0;i<n;i++){
			if(i==m)continue;
			for(int j=k-1;j>-1;--j){
				if(j-a[i]>-1&&dp[j-a[i]]){
					dp[j] = true;
					if(j>=k-a[m])needed=true;
				}
			}
		}
		// if(!needed)res++;
		if(needed)r=m;
		else l=m;
	}
	// cout<<l+1<<endl;
	cout<<l+1<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

int d[3];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int n,m;
    cin >> n >> m;
    d[0] = d[1] = d[2] = -1;
    REP(i, m) {
        int s, c;
        cin >> s >> c;
        if(s > n) {
            cout << -1 << endl;
            exit(0);
        }
        s--;
        if(d[s] != -1 && c != d[s]) {
            cout << - 1 << endl;
            exit(0);
        }
        else if(n > 1 && s == 0 && c == 0) {
            cout << -1 << endl;
            exit(0);
        } else {
            d[s] = c;
        }
    }


    for(int i=0; i<n; i++) {
        if(n > 1 && i == 0 && d[i] == -1) {
            cout << 1;
        } else {
            cout << (d[i] == -1? 0:d[i]);
        }
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main{
	
	//最大公約数・最小公倍数（セットで使う）
	public static long gcm(long a, long b) {
		long result = a;
		long k = 0;
		long n = b;
		do {
			k = result % n;
			result = n;
			n = k;
		} while(k != 0);
		return result;
	}
	
	public static long lcm(long a, long b) {
		long g;
		g = gcm(a, b);
		return a/g*b;
	}
	
	static long gcd (long a, long b) {
		long temp;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return b;
	}



	//素数判定
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2) if(n%i==0){return false;}
		return true;
	}


	//倍数判定（10進数以外のときに有用）
	static boolean isMultiple (String s, int base, int m) {
		int temp = 0;
		for (int i=0; i<s.length(); i++) {
			temp = (temp*base+Character.getNumericValue(s.charAt(i)))%m;
		}
		if (temp==0) {return true;}
		return false;
	}


	//階乗
	static long factorial (int i) {
		if (i==1) {return 1;}
		else {return i*factorial(i-1);}
	}


	//進数変換
	static String toNbase (String sm, int m, int n) {
		return Long.toString(Long.parseLong(sm,m),n);
	}
	
	public static final long gcd_n(long[] param) {
	    final int len = param.length;
	    long g = gcd(param[0], param[1]);    //gcd(a, b) は以前作ったもの
	    for (int i = 1; i < len - 1; i++) {
	        g = gcd(g, param[i + 1]);       //gcd(a, b) は以前作ったもの
	    }
	    return g;
	}
	
	public static long lcm_n(long[] numbers) {
		long l;
		l = numbers[0];
		for (int i = 1; i < numbers.length; i++) {
			l = lcm(l, numbers[i]);
		}
		return l;
	}
	
	
 public static void main(String[] args) {
	 Scanner sc=new Scanner(System.in);
	 int N=sc.nextInt();
	 int[] A=new int[N];
	 int[] B=new int[N];
	 for(int i=0;i<N;i++){
		 A[i]=sc.nextInt();
		 B[i]=A[i];
	 }
	 Arrays.sort(B);
	 for(int i=0;i<N;i++){
		 if(A[i]==B[N-1]) {
			 System.out.println(B[N-2]);
		 }else {
			 System.out.println(B[N-1]);
		 }
	 }
	
	 
	 
	 
 }
	


}


Measured memory_bytes: 91652
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <algorithm>
#include <climits>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <ctime>
#include <cstdlib>
#include <iterator>
using namespace std;

//#define TEST
int main()
{
#ifdef TEST
	freopen("data.in", "r", stdin);
	freopen("data.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	int x, a, b;
	while(cin >> x >> a >> b) {
		if(abs(a - x) < abs(b - x)) cout << "A" <<endl;
		else cout << "B" << endl;
	} 

	return 0;
}


Measured memory_bytes: 256
"""
- https://atcoder.jp/contests/abc136/tasks/abc136_a
- 容器１：now B, max A
- 容器２：now C
- reg:
    - 1≤B≤A≤20
    - 1≤C≤20
"""

a, b, c = map(int, input().split())
cap = a-b
use = min(a-b, c)
ans = c - use
print(ans)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
typedef long long LL;
typedef unsigned long long ULL;
const LL LINF = 0x3f3f3f3f3f3f3f3f; 
const int INF = 0x3f3f3f3f;
const double eps = 1e-6;
const int mod = 1e9+7;
const ULL P = 131;
const int N = 2e5+7;

int a[N];

int main()
{
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	int ans=0;
	if(a<=k) ans+=a,k-=a;
	else if(a>k) ans=k,k=0;
	if(k>0) k-=b;
	if(k>0) ans-=k;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define pf push_front
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define SZ(x) (int)(x).size()
#define endl '\n'
#define FOR(a, b, c) for (auto(a) = (b); (a) < (c); ++(a))
#define ROF(a, b, c) for (auto(a) = (b); (a) > (c); --(a))
#define F0R(a, b) FOR ((a), 0, (b))
#define R0F(a, b) ROF ((a), (b), -1)
#define CEIL(a, b) ((a) + (b)-1) / (b)
#define SET(a, b) memset((a), (b), sizeof(a))
template <class t>
bool ckmin(t& a, const t& b) {
    return a > b ? a = b, true : false;
}
template <class t>
bool ckmax(t& a, const t& b) {
    return a < b ? a = b, true : false;
}
#ifndef DEBUG
#define DEBUG 0
#endif
#define dout \
    if (DEBUG) std::cerr
#define dvar(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
template <class a, class b>
ostream& operator<<(ostream& o, const pair<a, b>& p);
template <class T>
struct IsC {
    template <class C>
    static char test(typename C::const_iterator*);
    template <class C>
    static int test(...);
    static const bool value = sizeof(test<T>(0)) == sizeof(char);
};
template <>
struct IsC<string> {
    static const bool value = false;
};
template <class C>
typename enable_if<IsC<C>::value, ostream&>::type operator<<(ostream& o,
                                                             const C& c) {
    o << '[';
    for (auto it = c.begin(); it != c.end();)
        o << *it << (++it != c.end() ? ", " : "");
    return o << ']';
}
template <class a, class b>
ostream& operator<<(ostream& o, const pair<a, b>& p) {
    return o << '(' << p.fi << ", " << p.se << ')';
}

void solve() {
    int n;
    cin >> n;
    vi as(n), bs(n);
    F0R (i, n) cin >> as[i] >> bs[i];
    sort(ALL(as)); sort(ALL(bs));
    if (n & 1) {
	cout << bs[n / 2] - as[n / 2] + 1 << endl;
    } else {
        cout << bs[n / 2 - 1] + bs[n / 2] - as[n / 2 - 1] - as[n / 2] + 1 << endl;
    }
}

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

    int tt = 1;
    FOR (t, 1, tt + 1) {
	// cout << "Case #" << t << ": ";
	solve();
    }

    return 0;
}


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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

const lli e5 = 100009;

lli euclid(lli a,lli b){
	while(a != 0){
		b %= a;
		swap(a,b);
	}
	return b;
}

lli n;
lli t;
lli ans = 1;


int main(){
	cin >> n;
	for(lli i = 0;i < n;i++){
		cin >> t;
		ans = ans*(t/euclid(ans, t));
	}
	cout << ans << endl;

}


Measured memory_bytes: 256
import sys
import string

def count_char_v2():
    alphabet = string.ascii_lowercase
    lst = [0 for _ in range(len(alphabet))]

    for line in sys.stdin:
        for char in line:
            if char.isalpha():
                index = alphabet.index(char.lower())
                lst[index] += 1

    for i in range(len(alphabet)):
        print(f"{alphabet[i]} : {lst[i]}")


if __name__ == "__main__":
    count_char_v2()


Measured memory_bytes: 6692
#include<stdio.h>

int ttos(int h,int m,int s){
  int a=3600*h+60*m+s;
  return a;
}

void stot(int s){
  int h=s/3600;
  int s1=s%3600;
  int m=s1/60;
  int s2=s1%60;
  printf("%d %d %d\n",h,m,s2);
}

void doit(){
  int h1,m1,s1,h2,m2,s2;
  while(scanf("%d %d %d %d %d %d",&h1,&m1,&s1,&h2,&m2,&s2)!=EOF){
    int s3=ttos(h1,m1,s1);
    int s4=ttos(h2,m2,s2);
    stot(s4-s3);
  }
}

int main(){
  doit();
  return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
int N,M;

long long int ans;

bool compare_by_a(pair<int, int> a, pair<int, int> b)
{
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}

int main(void)
{
    cin >> N >> M;

    vector<pair<long long int,long long int>> AB(N);

    for(int i=0;i<N;i++)cin >> AB[i].first >> AB[i].second;

    sort(AB.begin(),AB.end(),compare_by_a);

    int cnt=0;

    int i=0;

    while(cnt<M)
    {
        if(M-cnt<AB[i].second)
        {
            ans+=AB[i].first*(M-cnt);
            break;
        }
        else
        {
            ans+=AB[i].first*AB[i].second;
            cnt+=AB[i].second;
            // printf("%lld\n",ans);

        }

        i++;
    }

    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 1792
import std.stdio;
import std.string;
import std.conv;

void main(){
	int n, m;
	string s;
	readf("%d\n", &n);
	for (int i = 1; i <= n; i++) {
		writeln("Case ", i, ":");
		readf("%d\n", &m);
		foreach (j; 0..10) {
			s = format("%08d", m*m);
			m = to!int(s[2..6]);
			writeln(m);
		}
	}
}

Measured memory_bytes: 1000
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main(){
    int N;
    cin >> N;
    int a[11000];
    for(ll i = 0;i < N;i++){
        cin >> a[i];
    }
    
    int ans = 0;
    for(int i = 0;i < 30;i++){
        for(int i = 0;i < N;i++){
            if(a[i] % 2 == 0){a[i]/=2;ans++;}
        }
    }
    cout << ans;
    
}




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

int main(){
  int a,b;
  char op[2];

  scanf("%d %s %d", &a, op, &b);

  if(op[0] == '+') printf("%d", a + b);

  else printf("%d", a - b);

  return 0;
}


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

int main()
{
  int k;

  cin >> k;

  int ans = 0;

  for (int i = 1; i <= k; i++){
    for (int j = 1; j <= k; j++){
      if(i%2 == 0 && j%2==1)
        ans++;
    }
  }

  cout << ans;
}


Measured memory_bytes: 3608
#include <stdio.h>

int main() {
	int n, y;

	scanf("%d", &n);
	scanf("%d", &y);
	y = y/1000;

	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n; j++) {
			if (y == 5*n + 5*i - 4*j) {
				if(n - i - j >= 0) {
					printf("%d %d %d\n",i , n - i - j, j);
					return 0;
				}
			}
		}
	}
	printf("-1 -1 -1\n");
	return 0;
}



Measured memory_bytes: 128
import Control.Applicative ((<$>), (<*>))
import qualified Control.Monad as Monad (replicateM)
import qualified Data.List as List (transpose)
import qualified Data.List.Split as Split (chunksOf)

type Row = [Int]
type Matrix = [Row]

main = do
    [n,m,l] <- getLine'
    a <- Monad.replicateM n getLine'
    b <- Monad.replicateM m getLine'
    let result = toMatrix l $ dotProduct <$> a <*> List.transpose b
    mapM_ (putStrLn . printFormat) result

getLine' :: IO [Int]
getLine' = map (read :: String -> Int) . words <$> getLine

printFormat :: Row -> String
printFormat xs = unwords $ show <$> xs

toMatrix :: Int -> [Int] -> Matrix
toMatrix n xs = Split.chunksOf n xs

dotProduct :: Row -> Row -> Int
dotProduct xs ys = sum $ zipWith (*) xs ys

Measured memory_bytes: 12396
//保留所有权利。
#include<iostream>
#include<stdio.h>//printするよ
#include<vector>
#include<algorithm>//辞書順はnext_permutationだよ
#include<set>
#include<string>
#include<sstream>
#include<string.h>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<utility>//swapで数値交換するよ
//END OF LIBRARIES.
#define rt "\n"//改行を最速化させるよ
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define vcin(v) for (int i = 0; i < (v).size(); i++) { cin >> (v)[i]; }
#define sort(s) sort(s.begin(),s.end())
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define cncn int cnt=0
#define smsm int sum=0
#define str srting
#define v vector
#define please return
#define AC 0//おまじないだよ
#define Rapid cin.tie(0);ios::sync_with_stdio(false)
//END OF DEFINE.
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vcha;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
//printf("%02d:%02d:%02d\n", h, m, s);・・・2文字は埋める・h、m、ｓ
//END OF TYPEDEF.

//最大公約数（GCD）を求めるよ
//最小公倍数（LCM）は＜＜　A × B ÷ GCD　 ＞＞で求まるよ

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}
int x = 0, y = 0, z = 0, n = 0;
string s = "";
asas;
cncn;
//BEGIN OF CODE.
int main(void) {
	cin >> n;
	vint a(n);
	rep(i, n)cin >> a[i];
	sort(a);
	cnt = 1;
	rep(i, n) {
		if (i % 2 == 0) {//Aliceのターン
			x += a[i];
		}
		else {
			y += a[i];
		}
	}
	cout << abs(x-y) << rt;
	please AC;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
const int MAXN = 1e7 + 5;
const int MAXD = 1e4 + 5;
const int MOD = 1e9 + 7;
const long double EPS = 1e-4;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline ll rand(ll a, ll b) {ll c = rng(); return a+((ll)abs(c))%(b-a+1);}

ll d[MAXN];

int main(){

        ios::sync_with_stdio(0);
        cin.tie(0);
         ll Ans = 0;
        int n;
        cin >> n;
        for(int i = 1 ; i <= n ; i++)
        {
          for(int j = i; j <= n ; j+=i)
          {
             d[j]++;
          }
        }

        for(ll i = 1 ; i <= n ; i++)
            Ans+=i * d[i];
         
     cout << Ans << '\n';      

       
}

Measured memory_bytes: 81776