akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

int main(void) {
	int n;
	char w[100][11];
	int flag = 1;
	
	scanf("%d", &n);
	
	for (int i = 0; i < n; i++) {
		scanf("%s", w[i]);
		if (i >= 1) {
			if (w[i-1][strlen(w[i-1])-1] != w[i][0])
				flag = 0;
		}
	}
	
	for (int i = 0; i < n && flag; i++) {
		for (int j = i+1; j < n && flag; j++) {
			if (strcmp(w[i], w[j]) == 0) flag = 0;
		}
	}
	
	printf(flag ? "Yes" : "No");
	
	return 0;
}

Measured memory_bytes: 128
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;

void solve()
{
    int64_t N, K;
	std::cin >> N >> K;
	std::vector<int64_t> H(N);
	for (int64_t i = 0; i < N; i++)
	{
		std::cin >> H[i];
	}

	if (N <= K)
	{
		std::cout << 0 << std::endl;
		return;
	}

	std::sort(H.begin(), H.end(), std::greater<int64_t>());

	int64_t ans = 0;
	for (int64_t i = K; i < N; i++)
	{
		ans += H[i];
	}

	std::cout << ans << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	solve();
}


Measured memory_bytes: 4708
from collections import Counter

N = int(input())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n /= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

c = Counter(prime_factorize(N))
n = 0
for prime in c:
    wa = 1
    count = 1
    length = c[prime]
    while True:
        if c[prime] >= wa:
            n += 1
            count += 1
            wa += count
        else:
            break
print(n)


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

char a, b;

void solve(){
    string sa = "";
    for(int i = 1; i <= b - '0'; ++i){
        sa += a;
    }
    string sb = "";
    for(int i = 1; i <= a - '0'; ++i){
        sb += b;
    }
    if(sa < sb) cout << sa;
    else cout << sb;
}
int main(){
    cin >> a >> b;
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main()
{
    string S, T, ans = "No";
    int len, count;

    cin >> S >> T;
    len = S.size();
    for (int i = 0; i < len; i++) {
        if (S == T) {
            ans = "Yes";
            break;
        }
        S = S.back() + S.substr(0, len-1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
int main(){
    int s;
    std::cin >> s;
    int hour = s/3600;//１ｈ＝３６００秒
    int sub_hour = s%3600;
    int minute = sub_hour/60;
    int sub_minute = sub_hour%60;
    std::cout << hour << ':' << minute << ':' << sub_minute << std::endl;
}


Measured memory_bytes: 3100
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long
#define ll long long
#define mod  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<int,int>
#define ps push_back
double pi = 3.141592653589793;
using namespace std;
int z=0;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
//ここから始めよう
int gcd(int a,int b){
    return b == 0 ? a : gcd(b,a%b);
}
int lcm(int a,int b){
    return a / gcd(a,b) * b;
}
signed main(){
    int a,b;cin>>a>>b;
    string s,t;cin>>s>>t;
    int k=gcd(a,b);
    rep(i,0,k){
        if(s[i*(a/k)]!=t[i*(b/k)]){
            cout<<-1<<endl;return 0;
        }
    }
    cout<<lcm(a,b)<<endl;return 0;
}

Measured memory_bytes: 512
W, a, b = map(int, input().split())
A = [a, a + W]
B = [b, b + W]
if A[1] < B[0]:
    print(B[0] - A[1])
elif B[1] < A[0]:
    print(A[0] - B[1])
else:
    print(0)

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

const vector<int> match = {0,2,5,5,4,5,6,3,7,6};

void chmax(string &a, string b){
    if(a == "-") a = b;
    else if(a.size() < b.size()) a = b;
    else if(a.size() == b.size()){
        if(a < b) a = b;
    }
}

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

    vector<int> a(m);
    for(int i=0; i<m; i++){
        cin >> a[i];
    }

    vector<string> dp(20000, "-");// dp[0] = "-", dp[1] = "-", dp[2] = "-", ...
    dp[0] = "";

    for(int i=0; i<=n; i++){
        if(dp[i] == "-") continue;
        for(auto num : a){
            chmax(dp[i + match[num]], 
                  dp[i] + (char)('0' + num)// joining : string + char
            );
        }
    }
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 43776
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long A,B,N;
  cin>>N>>A>>B;
  if ((B-A)%2==0){
    cout<<setprecision(20)<<(B-A)/2<<endl;
    return 0;
  }
  cout<<setprecision(20)<<min(N-B,A-1)+1+(B-A-1)/2<<endl;
  return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;

int main() {
    int n, ans = 0;
    string s;
    cin >> n >> s;
    for (int i = 0; i < n - 2; i++) {
        if (s.at(i) == 'A' && s.at(i + 1) == 'B' && s.at(i + 2) == 'C') {
            ans++;
        }
    }
    cout << ans << endl;
}

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

int main(void){
    char X,Y;
    cin >> X >> Y;
    if(X > Y){
        cout << ">" << endl;
    }
  	else if(X < Y){
        cout << "<" << endl;
    }
  	else {
        cout << "=" << endl;
    }
    
}


Measured memory_bytes: 256
N,X,Y = map(int,input().split())

D = [0 for _ in range(N+1)]
#D[i]:距離がiである頂点(a,b)(a!=b)の組の個数

def dist(i,j):
    return min(j-i,abs(X-i)+abs(j-Y)+1)

for i in range(1,N):
    for j in range(i+1,N+1):
        D[dist(i,j)] += 1

for k in range(1,N):
    print(D[k])


Measured memory_bytes: 3444
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dunk(n) cout << n << endl
#define all(v) v.begin(), v.end()
typedef long long ll;



int main() {
    int n;
    cin >> n;
    n %= 10;
    switch(n){
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            dunk("hon");
            break;
            
        case 0:
        case 1:
        case 6:
        case 8:
            dunk("pon");
            break;
        
        case 3:
            dunk("bon");
            break;
    }
    
    return 0;
}



Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
 
struct UnionFindSet {
  vector<int> f;
  int n;
  UnionFindSet(int n) : f(n) { clear(n); }
  void clear(int n) {
    this->n = n;
    for (int i = 0; i < n; i++) {
      f[i] = i;
    }
  }
  int find(int x) { return f[x] == x ? x : f[x] = find(f[x]); }
  void Union (int x, int y) { f[find(y)] = find(x); }
};
 
int main() {
  int n, m;
  cin >> n >> m;
  UnionFindSet s(n + 1);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    s.Union(a, b);
  }
  int cnt = 0;
  for (int i = 1; i <= n; i++)
    if (s.find(i) == i) cnt++;
  cout << cnt - 1;
}

Measured memory_bytes: 3744
#include <math.h>
#include <ctype.h>
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, n) for (int i = a; i < n; i++)
#define REP(i, n) for(int i = 0; i < n; i++)

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

    unordered_map<int, int> mp;
    int A[n];
    REP(i, n){
        cin >> A[i];
        mp[A[i]]++;
    }

    vector<int> V;
    for(auto x : mp) V.push_back(x.second);

    int t = 0;
    if(V.size() > k){
        sort(V.begin(), V.end());
        REP(i, V.size() - k){
            t += V[i];
        }
    }
    cout << t << endl;

    return 0;
}

Measured memory_bytes: 11080
n,t = map(int, input().split())
a = input().split()
a = [int(m) for m in a]
X = 0

for i in range(n):
    if i == 0:
        u = a[0]
        if n == 1:
            X += t
            break
        else:
            v = a[1]
    if u + t < v:
        X += t
    else:
        X += v - u
    u = v
    if i + 1 < n:
        v = a[i + 1]
    if i == n - 1:
        X += t
print(X)

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

char c[200];

int main()
{
    string s;
    cin >> s;
    
    for(int i = 0; i < s.size(); i++) {
        c[s[i]]++;
    }    
    
    for(char j = 'a'; j <= 'z'; j++) {
        if(c[j] % 2) {
            cout << "No";
            exit(0);
        }
    }
    cout << "Yes";
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static MyUtil;

class MyUtil
{
    public static int Gcd(int a, int b)
    {
	if (a < b){ return Gcd(b, a); }
	while (b != 0)
	{
	    var r = a % b;
	    a = b;
	    b = r;
	}
	return a;
    }

    public static void Swap<T>(ref T a, ref T b)
    {
	var t = a;
	a = b;
	b = t;
    }

    public static int[] ReadIntArray()
    {
	return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }

    public static long[] ReadLongArray()
    {
	return ReadLine().Split().Select(x => long.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
	int n = int.Parse(ReadLine());
	var v = ReadIntArray();
	var c = ReadIntArray();

	int ans = 0;

	for (int i = 0; i < n; i++)
	{
	    ans += Math.Max(0, v[i] - c[i]);
	}

	WriteLine(ans);
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll Q=1000000007;
  
ll fact(ll x){
  ll prod=1;
  for(ll i=1;i<=x;i++){
    prod *= i;
    prod %= Q;
  }
  return prod;
}

int main(){
  ll N,M;
  cin >> N >> M;
  if(abs(N-M)>1){
    cout << 0 << endl;
    return 0;
  }else if(abs(N-M)==1){
    ll ans = fact(N);
    ans = ans*fact(M)%Q;
    cout << ans << endl;
    return 0;
  }else{
    ll ans = fact(N);
    ans = ans*fact(M)%Q;
    ans = ans * 2 % Q;
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<cmath>
using namespace std;
const int maxn=1e5+5;
typedef long long ll;
int main(){
    ll n;
    cin>>n;
    if(n%2==0){
        cout<<n/2<<endl;
    }
    else{
        cout<<n/2+1<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 888
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = Integer.parseInt(sc.next());
		int w = Integer.parseInt(sc.next());
		int n = Integer.parseInt(sc.next());
		int[][] s = new int[h][w];
		int indexH = 0;
		int indexW = -1;
		boolean odd = true;
		for (int i = 1; i <= n; i++) {
			int a = Integer.parseInt(sc.next());
			for (int j = 0; j < a; j++) {
				if (odd) {
					indexW++;
					if (indexW == w) {
						indexW--;
						indexH++;
						odd = false;
					}
				}
				else {
					indexW--;
					if (indexW < 0) {
						indexW++;
						indexH++;
						odd = true;
					}
				}
				s[indexH][indexW] = i;
			}
		}
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w - 1; j++) {
				System.out.print(s[i][j] + " ");
			}
			System.out.println(s[i][w - 1]);
		}
	}
}

Measured memory_bytes: 28048
use std::cmp;

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let mut seg = vec![];
    for _ in 0..n {
        let l = sc.read::<i64>();
        let r = sc.read::<i64>() + 1;
        seg.push((l, r));
    }

    let max_l = seg.iter().map(|&(l, _)| l).max().unwrap();
    let min_r = seg.iter().map(|&(_, r)| r).min().unwrap();
    let max_seg = seg.iter().map(|&(l, r)| r - l).max().unwrap();
    let ans1 = max_seg + cmp::max(min_r - max_l, 0);

    let mut seg = seg
        .into_iter()
        .map(|(l, r)| {
            (
                cmp::max(r - max_l, 0),
                -cmp::max(min_r - l, 0),
                cmp::max(min_r - l, 0),
            )
        })
        .collect::<Vec<_>>();
    seg.sort();

    let (_, _, mut min_b) = seg[0];
    let (mut min_a, _, _) = seg[1];
    let mut ans2 = min_a + min_b;
    for i in 1..(n - 1) {
        let (_, _, b) = seg[i];
        min_b = cmp::min(min_b, b);
        let (a, _, _) = seg[i + 1];
        min_a = a;
        ans2 = cmp::max(ans2, min_a + min_b);
    }

    println!("{}", cmp::max(ans1, ans2));
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 10492
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  vector<char> ans(s.size(),'A');
  int X=0;
  for(int i=0;i<s.size();i++){
    if(s.at(i)=='0'||s.at(i)=='1'){
      ans.at(X)=s.at(i);
      X++;
    }
    else if(s.at(i)=='B'&&X!=0){
      ans.at(X-1)='A';
      X--;
      if(X<0) X=0;
    }
  }
  for(int i=0;i<s.size();i++){
    if(ans.at(i)!='A'){
      cout<<ans.at(i);
    }
  }
    cout<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main()
{
    int k,x;
    int s,e;
    cin>>k>>x;
    s=x-k+1;
    e=x+k-1;
    for (int i = s; i <= e; i++)cout<<i<<" ";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <set>
#include <cmath>
#include <vector>

typedef long long ll;
#define LL_MAX (1<<30)

using namespace std;

int main()
{
    ll n, m;
    vector<ll> r;
    vector<ll> l;

    cin >> n >> m;

    ll tmp;
    for (ll i=0; i<m; i++)
    {
        cin >> tmp, l.push_back(--tmp);
        cin >> tmp, r.push_back(--tmp);
    }

    vector<ll> gate(n, 0);

    ll _min(-LL_MAX), _max(LL_MAX);
    for(ll i=0; i<m; i++)    
        _min=max(_min, l[i]), _max=min(_max, r[i]);

    ll ans(0);
    if (_max>=_min)
        ans = _max-_min+1;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2796
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <limits>
#include <utility>
#include <algorithm>
#include <tuple>
#include <limits>

int main(int argc, char *argv[])
{
    int ans = 0;
    int x, n;
    bool pList[102];

    std::cin >> x >> n;

    for (int i = 0; i < 102; i++) {
        pList[i] = false;
    }

    for (int i = 0; i < n; i++) {
        int p;
        std::cin >> p;
        pList[p] = true;
    }

    for (int i = 0; i < 102; i++) {
        if (abs(x - i) < abs(x - ans) && !pList[i]) {
            ans = i;
        }
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 3620
S = input()

if S == 'SAT':
  print(1)
  
elif S == 'FRI':
  print(2)
  
elif S == 'THU':
  print(3)
  
elif S == 'WED':
  print(4)
  
elif S == 'TUE':
  print(5)
  
elif S == 'MON':
  print(6)
  
elif S == 'SUN':
  print(7)

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstring>
#include<string>
using namespace std;
int main(){
	string x,y;
	cin>>x>>y;
	cout<<y<<x<<endl; 
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main { 
  public static void main(String[] args) {

    Scanner scanner = new Scanner(System.in);
    int N = Integer.parseInt(scanner.next());
    scanner.close();
    int count = 0;
    int A = 1;
    boolean flag = false;

    for (int C = 1; C < N; C++){
      for (int B = 1; B <= (N - C) / B; B++){
        if ((N - C) % B == 0){
          if (B == (N - C) / B){
            count++;
            break;
          }
          count += 2;
        }
      }
    }

    System.out.println(count);
  }
}

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

int main() {
  int N,K,j = 0;
  int P = 1;
  cin >> N >> K;
  while(j<N){
    if(P*2 < (P+K)){
      P *= 2;
    }
    else{
      P += K;
    }
    j++;
  }
  
    cout << P << endl;
}

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

typedef long long ll;
typedef pair<int, int> pi;

int N;
vector<pi> P;

void input_init(void) {
	cin >> N;
	P.resize(N);
	for (int i = 0; i < N; ++i)
		cin >> P[i].first >> P[i].second;
	sort(P.begin(), P.end());
	P.erase(unique(P.begin(), P.end()), P.end());
	N = P.size();
}

ll det(pi a, pi b) {
	ll x = (ll)a.first * b.second;
	ll y = (ll)-a.second * b.first;
	return x + y;
}

vector<pi> convex_hull(vector<pi> &ps, int n) {
	int k = 0;
	vector<pi> qs(n * 2);
	for (int i = 0; i < n; ++i) {
		while (k > 1) {
			pi a = make_pair(qs[k - 1].first - qs[k - 2].first, qs[k - 1].second - qs[k - 2].second);
			pi b = make_pair(ps[i].first - qs[k - 1].first, ps[i].second - qs[k - 1].second);
			if (det(a, b) <= (ll)0)
				k--;
			else
				break;
		}
		qs[k++] = ps[i];
	}
	for (int i = n - 2, t = k; i >= 0; --i) {
		while (k > t) {
			pi a = make_pair(qs[k - 1].first - qs[k - 2].first, qs[k - 1].second - qs[k - 2].second);
			pi b = make_pair(ps[i].first - qs[k - 1].first, ps[i].second - qs[k - 1].second);
			if (det(a, b) <= (ll)0)
				k--;
			else
				break;
		}
		qs[k++] = ps[i];
	}
	qs.resize(k - 1);
	return qs;
}

ll calcu_dist(pi a, pi b) {
	ll x = (ll)abs(a.first - b.first);
	ll y = (ll)abs(a.second - b.second);
	return x + y;
}

int main(void) {
	input_init();
	vector<pi> qs = convex_hull(P, N);
	ll ans = (ll)0;
	for (int i = 0; i < (int)qs.size(); ++i) {
		for (int j = 0; j < i; ++j) {
			ll d = calcu_dist(qs[i], qs[j]);
			ans = max(d, ans);
		}
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 7944
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
typedef pair<int, int> P;
int A[200010];
int B[200010];
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];
    priority_queue<P> pq;
    rep(i, N) {
        int L = (i + N - 1) % N;
        int M = (i + N) % N;
        int R = (i + N + 1) % N;
        pq.push({B[M] - B[L] - B[R], i});
    }
    int cnt = 0;
    while(pq.size()) {
        P num = pq.top();
        pq.pop();
        //cout << num.first << endl;
        if(num.first < 0) break;
        int i = num.second;
        int L = (i + N - 1) % N;
        int M = (i + N) % N;
        int R = (i + N + 1) % N;
        if (B[L] + B[R] < B[M] && B[M] > A[M]) {
            int times = (B[M] - A[M])/ (B[L] + B[R]);
            if (times <= 0) break;
            B[M] -= (B[L] + B[R]) * times;
            cnt += times;
            // rep(i, N) cout << B[i] << " ";
            // cout << endl;   
            REP(j, -1, 1) {
                int i2 = num.second + j + N*2;
                int L1 = (i2 + N - 1) % N;
                int M1 = (i2 + N) % N;
                int R1 = (i2 + N + 1) % N;
                pq.push({B[M1] - B[L1] - B[R1], M1});
            }
        }
    }
    rep(i, N) {
        if (B[i] != A[i]) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 71040
def selectionSort(A, N):
    count = 0
    for i in range(0, N):
        minj = i
        for j in range(i, N):
            if A[j]<A[minj]:
                minj = j
        if minj != i:
            (A[i], A[minj]) = (A[minj], A[i])
            count += 1
    print(" ".join(map(str, A)))
    print(count)

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

selectionSort(a, n)


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

    //long long
    using ll = long long;

    // pair<int, int>
    using PII = pair<int, int>;

    //最大値、mod
    const int MOD = 1000000007;
    const int INF = 1000000000;
    const long long LINF = 1e18;

    //出力系
    #define print(x) cout << x << endl
    #define prints(x) cout << fixed << setprecision(10) << x << endl
    #define printc(x) cout << setw(2) << setfill('0') << x << endl;
    #define yes cout << "Yes" << endl
    #define YES cout << "YES" << endl
    #define no cout << "No" << endl
    #define NO cout << "NO" << endl
    
    // begin() end()
    #define all(x) (x).begin(),(x).end()

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

    //最大公約数 
    unsigned gcd(unsigned a, unsigned b) {
      if(a < b) return gcd(b, a);
      unsigned r;
      while ((r=a%b)) {
        a = b;
        b = r;
      }
      return b;
    }

    // 最小公倍数
    unsigned lcm(unsigned a, unsigned b){
        return a / gcd(a, b) * b; 
    }

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

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









int main(){
  int A, B;
  cin >> A >> B;
  int aans = (A * 100) / 8;
  int bans = (B * 100) / 10;
  int ma = max(aans,bans);
  int mi = min(aans,bans);
  int ans = mi;
  while(ans <= 10000){
    if((ans * 8) / 100 == A && (ans * 10) / 100 == B) {
      print(ans);
      return 0;
    }
    ans++;
  }
  print(-1);
  return 0;
}

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

int main() {
	string w;
	cin >> w;
	char a[26]={0};
	for (int i=0; i<w.length();i++){
	    a[w[i]-96]++;
	}
	for (int i=0; i<26; i++){
	    if (a[i]%2==1){
	        cout << "No" << endl;
	        return 0;
	    }
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
using namespace std;
 
 
int main()
{
	long long int N, res = 0;
 
	cin >> N;
 
	for(int i=1; i<=N; i++){
		if(i%3 != 0 && i%5 != 0){
			res += i;
		}
	}
 
	cout << res;
 
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d,e;
  cin>>a>>b>>c>>d>>e;

    if (a==0){
      cout<<"1"<<endl;}
     if (b==0){
      cout<<"2"<<endl;}
     if (c==0){
      cout<<"3"<<endl;}
     if (d==0){
      cout<<"4"<<endl;}
     if (e==0){
      cout<<"5"<<endl;}
}

Measured memory_bytes: 3588
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#define MOD 1000000007
using namespace std;
typedef long long ll;

template <typename Tp> inline void getint(Tp &num){
	register int ch, neg = 0;
	while(!isdigit(ch = getchar())) if(ch == '-') neg = 1;
	num = ch & 15;
	while(isdigit(ch = getchar())) num = num * 10 + (ch & 15);
	if(neg) num = -num;
}

inline ll fastpow(ll bas, ll ex){
	register ll res = 1; bas %= MOD;
	for(; ex; ex >>= 1, bas = bas * bas % MOD) if(ex & 1) res = res * bas % MOD;
	return res;
}

inline int kazu(int a, const int &b) {return (a += b) >= MOD ? a - MOD : a;}
inline int hiku(int a, const int &b) {return (a -= b) < 0 ? a + MOD : a;}

int N, H, D, fac[1000005] = {1}, sumfac = 0, isumfac, f[1000005], sumf;

int main(){
	getint(N), getint(H), getint(D);
	for(register int i = 1; i <= N; i++) fac[i] = fac[i - 1] * (ll)i % MOD;
	for(register int i = 1; i <= N; i++) sumfac = kazu(sumfac, fac[i]);
	isumfac = fastpow(sumfac, MOD - 2), sumf = f[0] = 1;
	for(register int i = 1; i <= H; i++){
		if(i > D) sumf = hiku(sumf, f[i - D - 1]);
		f[i] = sumf * (ll)sumfac % MOD, sumf = kazu(sumf, f[i]);
	}
	return printf("%d\n", f[H] * (ll)fac[N] % MOD * isumfac % MOD), 0;
}


Measured memory_bytes: 8064
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second > b.second; }

int main(){
   string day[]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
   string s;cin>>s;
   rep(i,7){
       if(day[i]==s)cout<<7-i<<endl;
   }
}

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

int main(){
    int n;
    cin >> n;
    int a[n],b[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
        b[i]=a[i]; //コピー
    }
    sort(b,b+n);

    int d(0);
    for(int i=0;i<n;i++){
        if(a[i]!=b[i])  d++;
    }

    if(d==0){   //sortしなくてもよかった時
        cout << 0 << endl;
        return 0;
    }

    int q; 
    cin >> q;

    for(int i=1;i<=q;i++){
        int x,y;
        cin >> x >> y;
        
        //交換前
        if(a[x-1]!=b[x-1])  d--;
        if(a[y-1]!=b[y-1])  d--;

        swap(a[x-1],a[y-1]);

        //交換後
        if(a[x-1]!=b[x-1])  d++;
        if(a[y-1]!=b[y-1])  d++;

        if(d==0){
            cout << i << endl;
            return 0;
        }
    }

    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 5476
#include <bits/stdc++.h>
using namespace std;
 
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define lli long long int
#define li long int
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define mem(arr,x) memset(arr,x,sizeof(arr))
#define F first
#define S second
#define MOD 1000000007
 
lli mod(lli base,lli exp){
	lli res = 1;
	while(exp>0){
		if(exp&1) res = (res*base)%MOD;
		base = (base*base)%MOD;
		exp = exp>>1;
	}
	return res;
}
void solve(){
string s,t;
cin>>s;
cin>>t;
lli a=s.size();
lli b=t.size(),i,f=0;
if(b-a!=1)cout<<"No";
else{
	for(i=0;i<a;i++){
		if(s[i]!=t[i]){
			f=1;
			break;
		}
	}
	if(f) cout<<"No";
	else cout<<"Yes";
}
}
int main() {
        fast();
	int t;
	t=1;
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 3660
X, K , D = gets.split.map(&:to_i)

a = X.abs / D
if K < a
    if X > 0
        puts (X - (D * K)).abs
    else
        puts (X + (D * K)).abs
    end
    exit
end

k = K - a
x = X > 0 ? X - (D * a) : X + (D * a)

if k % 2 == 0
    puts x.abs
else
    if x > 0
        puts (x - D).abs
    else
        puts (x + D).abs
    end
end

Measured memory_bytes: 14328
#include <bits/stdc++.h>
#define int long long 
using namespace std;
using Graph = vector<vector<int>>;
const int MOD = 998244353;

//AのN乗(mod M)を高速に計算する(O(logN))
//Aの逆元を取る場合、modpow(A, MOD-2, MOD)で求まる
long long modpow(long long a, long long n, long long mod) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


signed main() {
  COMinit();
  
  int N, M, K;
  cin >> N >> M >> K;
  int all = modpow(M, N, MOD);
  for( int i = K+1; i < N; i++ ){
    int hiku = COM(N-1, i);
    hiku *= (M * modpow(M - 1, N - i - 1, MOD)) % MOD;
    hiku %= MOD;
    all = (all-hiku)%MOD;
    if( all < 0 ) all += MOD;
  }
  cout << all%MOD << endl;
}


Measured memory_bytes: 15592
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws Exception{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(br.readLine());
    // w = x - y
    int max_w = Integer.MIN_VALUE;
    int min_w = Integer.MAX_VALUE;
    // v = x + y
    int max_v = Integer.MIN_VALUE;
    int min_v = Integer.MAX_VALUE;
    for(int i = 0; i < n; i++){
      String[] data = br.readLine().split(" ");
      int x = Integer.parseInt(data[0]);
      int y = Integer.parseInt(data[1]);
      max_w = Math.max(max_w, x - y);
      min_w = Math.min(min_w, x - y);
      max_v = Math.max(max_v, x + y);
      min_v = Math.min(min_v, x + y);
    }
    br.close();
    System.out.println(Math.max(Math.abs(max_w - min_w), Math.abs(max_v - min_v)));
  }
}

Measured memory_bytes: 55188
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

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

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

    vector<int> a(n), b(n);
    rep(i, n) cin >> a[i] >> b[i];

    int ans = 0;
    rep(i, n){
        if((k | a[i]) == k){
            ans += b[i];
        }
    }

    rep(i, 30){
        if((k >> i) == 0){
            break;
        }
        if((k >> i) % 2 == 0){
            continue;
        }

        int tmp = 0;
        int limit = (1LL << (i)) - 1;
        limit |= k;
        limit ^= 1LL << (i);
        rep(i, n){
            if((limit | a[i]) == limit){
                tmp += b[i];
            }
        }
        if(tmp > ans){
            ans = tmp;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)

int main() {
    ll N;
    cin >> N;

    priority_queue<ll, vector<ll>, greater<ll>> v;
    REP(i, N) {
        ll tmp;
        cin >> tmp;
        v.push(tmp);
    }

    long double sum = 0;
    sum += (long double)v.top() / pow(2, N - 1);
    v.pop();
    sum += (long double)v.top() / pow(2, N - 1);
    v.pop();
    REP(i, N - 2) {
        sum += (long double)v.top() / pow(2, N - (i + 2));
        v.pop();
    }
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 4120
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N, M;
  cin >> N >> M;
  vector<int> P(M);
  vector<string> S(M);
  for(int i=0; i<M; i++){
    cin >> P.at(i) >> S.at(i);
  }
  vector<bool> Q(N,false);
  vector<int>  R(N);
  int a = 0;
  int b = 0;
  for(int i=0; i<M; i++){
    if(S.at(i) == "WA" && Q.at(P.at(i)-1) == false){
      R.at(P.at(i)-1)++;
    }
    else if(S.at(i) == "AC" && Q.at(P.at(i)-1) == false){
      a++;
      Q.at(P.at(i)-1) = true;
    }
  }
  for(int i=0; i<N; i++){
    if(Q.at(i)){
      b += R.at(i);
    }
  }
  cout << a << " " << b << endl;
}

Measured memory_bytes: 6528
using System;

class Program
{
	static void Main(string[] args)
	{
		int n = int.Parse(Console.ReadLine());
		
		string[] str0 = Console.ReadLine().Split(' ');
		int[] s = new int[n];
		for (int i = 0; i < n; i++)
		{
			s[i] = int.Parse(str0[i]);
		}

		int q = int.Parse(Console.ReadLine());
		
		string[] str1 = Console.ReadLine().Split(' ');
		int[] t = new int[n];
		for (int i = 0; i < q; i++)
		{
			t[i] = int.Parse(str1[i]);
		}

		int count = 0;
		for (int i = 0; i < q; i++)
		{
			for (int j = 0; j < n; j++)
			{
				if (t[i] == s[j])
				{
					count ++;
					break;
				}
			}
		}

		Console.WriteLine(count);
	}
}


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

int main(){
 string s;
  cin>>s;
  int n=s.size();
  int count=0;
 for(int i=0;i<s.size();i++){
   if(s[i]!=s[n-1-i])count++;
 }
  
  cout<<count/2<<endl;
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define ll long long
#define mp make_pair
#define pii pair<int,int>
#define mod 1000000007
#define M 1000000
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    long t;
    cin>>t;
    ll a,b;
    cin>>a>>b;
    ll flag=0;
    for(int i=a;i<=b;i++)
    {
        if(i%t==0)
        {
            flag=1;
            break;
            
        }
    }
    if(flag==0)
    cout<<"NG";
    else
    cout<<"OK";
}

Measured memory_bytes: 3652
def ok(last4):
    for i in range(4):
        t = list(last4)
        if i >= 1:
            t[i - 1], t[i] = t[i], t[i - 1]
        if 'AGC' in ''.join(t):
            return False
    return True


def main():
    MOD = 10**9 + 7
    N = int(input())
    memo = [{} for _ in range(N + 1)]

    def dfs(cur, last3):
        if last3 in memo[cur]:
            return memo[cur][last3]
        if cur == N:
            return 1
        ret = 0
        for c in 'ACGT':
            if ok(last3 + c):
                ret = (ret + dfs(cur + 1, last3[1:] + c)) % MOD
        memo[cur][last3] = ret
        return ret

    print(dfs(0, 'TTT'))


if __name__ == '__main__':
    main()

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

using namespace std;
int N;
vector<int> edges[205];
bool vis[205];
bool state[205];
int dist[205][205];
int INF = 0x3f3f3f3f;

bool bipartite(int v) {
    bool works = true;
    for (int e: edges[v]) {
        if (!vis[e]) {
            vis[e] = true;
            state[e] = !state[v];
            works = bipartite(e) && works;
        } else {
            if (state[v] == state[e]) works = false;
        }
    }
    return works;
}

int main() {
    cin >> N;
    string a;
    for (int i = 1; i <= N; i++) {
        cin >> a;
        for (int j = 0; j < N; j++) {
            if (a[j] - '0' == 1) edges[i].push_back(j + 1);
        }
    }
    state[1] = true;
    vis[1] = true;
    if (bipartite(1)) {
        memset(dist, INF, sizeof(dist));
        for (int i = 1; i <= N; i++) {
            dist[i][i] = 0;
            for (int e: edges[i]) dist[i][e] = 1;
        }
        for (int k = 1; k <= N; k++) {
            for (int i = 1; i <= N; i++) {
                for (int j = 1; j <= N; j++) {
                    if (dist[i][k] + dist[k][j] < dist[i][j]) {
                        dist[i][j] = dist[i][k] + dist[k][j];
                    }
                }
            }
        }
        int ans = 0;
        for (int i = 1; i <= N; i++) {
            for (int j = 1; j <= N; j++) {
                ans = max(ans, dist[i][j]);
            }
        }
        printf("%d\n", ans+1);
    } else {
        printf("-1\n");
    }
    return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(15);

  int n, m;
  cin >> n >> m;
  vector<vector<bool>> p(n, vector<bool>(n, false));
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    p[a][b] = true;
    p[b][a] = true;
  }

  vector<int> g(n);
  for (int i = 0; i < n; ++i) {
    g[i] = i;
  }

  int ans = 0;
  do {
    if (g[0] != 0) break;
    bool ok = true;
    for (int i = 1; i < n; ++i) {
      if (!p[g[i - 1]][g[i]]) {
        ok = false;
        break;
      }
    }
    if (ok) ++ans;
  } while (next_permutation(g.begin(), g.end()));

  cout << ans << '\n';

  return 0;
}


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

#define filein freopen ("in.txt", "r", stdin)
#define fileout freopen ("out.txt", "w", stdout)
#define dbg(x) cerr << #x << ": " << x << endl

using namespace std;
typedef long long ll;

const int maxn = 3003;

ll a[maxn];
ll dp[maxn][maxn];
ll n;

ll go (ll L, ll R){
    if (L > R) return 0;
    ll &ret = dp[L][R];
    if (ret != -1) return ret;
    ret = max (a[L] - go (L + 1, R), a[R] - go (L, R - 1));
    return ret;
}

int main(){
    memset (dp, -1, sizeof dp);
    scanf ("%lld", &n);
    for (ll i = 0; i < n; i++)
        scanf ("%lld", &a[i]);
    cout << go (0, n - 1) << endl;
	return 0;
}


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

char s[200010];
int n,cnt=0;
long long ans=0;

int main()
{
    scanf("%s",s+1);
    n=strlen(s+1);
    for(int i=1;i<=n;i++)
        s[i]=='W'?ans+=cnt:cnt++;
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

int main() {
    ll x, k, d;    cin >> x >> k >> d;
    if (x < 0)
        x = -x;
    if (x >= 0) {
        ll a = x/d;
        if (a >= k) {
            cout << x-k*d << endl;
            return 0;
        }
        if ((k-a) % 2 == 0) {
            cout << x - d*a << endl;
            return 0;
        }
        cout << abs(x- d*(a+1)) << endl;
        return 0;
    }

    return 0;
}

Measured memory_bytes: 3632
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
ans=0
tb=-1
for i in range(n):
    t=a[i]
    ans+=b[t-1]
    if t==tb+1:
        ans+=c[tb-1]
    tb=t
print(ans)

Measured memory_bytes: 3064
import sys
import copy
import math
import itertools
import numpy as np
S = input()
#010101...との比較
cnt = [0,0]
for i in range(len(S)):
    if i%2==0 and int(S[i]) == 1:
        cnt[0]+=1
    elif i%2 == 1 and int(S[i]) == 0:
        cnt[0]+=1
    
    if i%2==0 and int(S[i]) == 0:
        cnt[1]+=1
    elif i%2 == 1 and int(S[i]) == 1:
        cnt[1]+=1
    
if cnt[0]<=cnt[1]:
    print(cnt[0])
else:
    print(cnt[1])

Measured memory_bytes: 27196
n = int(input())
a = list(map(int, input().split()))
ansa,ansb,t=0,0,0
for i in range(n):#偶数正
    t+=a[i]
    if i%2==1:
        if t>=0:
            ansa+=abs(t+1)
            t=-1
    else:
        if t<=0:
            ansa+=abs(t-1)
            t=1
t=0
for i in range(n):#奇数正
    t+=a[i]
    if i%2==1:
        if t<=0:
            ansb+=abs(t-1)
            t=1
    else:
        if t>=0:
            ansb+=abs(t+1)
            t=-1
print(min(ansa, ansb))


Measured memory_bytes: 14332
#include <stdio.h>

int main(){
  int N,M,C,ans=0,A,B[30];
  scanf("%d %d %d",&N,&M,&C);
  for(int j=1;j<=M;j++)
    scanf("%d",B+j);
  int S=0;
  for(int i=1;i<=N;i++){
    S=C;
    for(int j=1;j<=M;j++){
      scanf("%d",&A);
      S+=A*B[j];
    }
    if(S>0) ans++;
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 1736
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<algorithm>
#include<climits>
#define MOD (1000000007)

using namespace std;

typedef long long int Int;

int N;
vector<Int> a(1001);
vector<Int> dp(1001);
vector<int> pre(1001);

int main(void) {
    cin>>N;
    for(int i = 1;i <= N;i++) {
        cin>>a[i];
        dp[i] = a[i];
    }

    for(int i = 1;i <= N;i++) {
        for(int j = i-2;j >= 1;j -=2) {
            if(dp[j]+a[i] > dp[i]) {
                dp[i] = dp[j] + a[i];
                pre[i] = j;
            }
        }
    }

    Int ans = -INT_MAX;
    int index = -1;
    for(int i = 1;i <= N;i++) {
        if(dp[i] > ans) {
            ans = dp[i];
            index = i;
        }
    }

    cout<<ans<<endl;
    vector<int> method;
    for(int i = N;i > index;i--)
        method.push_back(i);
    N = index;

    while(pre[index]) {
        int mid = (index + pre[index]) / 2;
        int c = index - mid;
        while(c--)
        {
            method.push_back(mid);
            mid--;
        }
        index = pre[index];
    }
    for(int i = 1;i < index;i++) {
        method.push_back(1);
    }
    cout<<method.size()<<endl;
    for(auto &&t: method) {
        cout<<t<<endl;
    }

    return 0;
}


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

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

    vector<int> d(N);
    int total= 0;

    for (size_t i = 0; i < N; i++)
    {
        cin >> d.at(i);
    }

    for (size_t i = 0; i < N; i++)
    {
        for (size_t j = i + 1 ; j < N; j++)
        {
            total += d.at(i) * d.at(j);
        }
        
    }

    cout << total << endl;
    
    

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

int main(void)
{
  string S;
  cin >> S;

  long long count0 = 0;
  long long count1 = 0;
  for (auto itr = S.begin(); itr != S.end(); ++itr) {
    if (*itr == '0') {
      count0 ++;
    }
    else {
      count1 ++;
    }
  }

  cout << min(count0, count1)*2 << endl;

  return 0;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, s, n) for (i64 i = (s); i <= (n); ++i)
#define VAR(Type, ...) Type __VA_ARGS__; IN(__VA_ARGS__)

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template <class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template <class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

// IN
void IN() {}
template <class Head, class... Tail>
void IN(Head&& head, Tail&&... tail) {
  cin >> head;
  IN(forward<Tail>(tail)...);
}

// OUTS
void OUTS() {}
template <class Head, class... Tail>
void OUTS(Head&& head, Tail&&... tail) {
  cout << head << " \n"[sizeof...(tail)==0];
  OUTS(forward<Tail>(tail)...);
}

template <class T>
void OUTS(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e==&vec.back()]; }

template <class T>
void OUTS(vector<vector<T>> &df) { for (auto &vec : df) OUTS(vec); }

// OUTL
void OUTL() {}
template <class Head, class... Tail>
void OUTL(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  OUTL(forward<Tail>(tail)...);
}

template <class T>
void OUTL(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

// OUTN
void OUTN() {}
template <class Head, class... Tail>
void OUTN(Head&& head, Tail&&... tail) {
  cout << head;
  OUTN(forward<Tail>(tail)...);
}

template <class T>
void OUTN(vector<T> &vec) { for (auto &e : vec) cout << e; }
// }}} End

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  VAR(int, N, Y);

  for (int i = 0; i <= N; ++i) {
    for (int j = 0; j <= N; ++j) {
      int k = N - (i + j);
      int norm = 10000 * i + 5000 * j + 1000 * k;
      if (0 <= k && k <= N && norm == Y) {
        OUTS(i, j, k);
        return 0;
      }
    }
  }

  OUTS(-1, -1, -1);
  return 0;
}


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

int main() {
    int N;
    cin >> N;
    int amari;
    amari = N%10;
    if (amari == 2 || amari == 4 || amari == 5 || amari == 7 || amari == 9)
    {
	cout << "hon" << endl;
    }else if (amari == 0 || amari == 1 || amari == 6 || amari == 8)
    {
	cout << "pon" << endl;
    }else {
	cout << "bon" << endl;
    }
    return 0;
}


Measured memory_bytes: 3636
import pprint
N = int(input())
S = {}
for i in range(N):
    tmp = input()
    if tmp in S.keys():
        S[tmp] = S[tmp] + 1
    else:
        S[tmp] = 1
    #pprint.pprint(S)

num = 0
v = []
for key,value in S.items():
    if value > num:
        num = value
        v = [key]
    elif value == num:
        v.append(key)

v.sort()

for i in v:
    print(i)

Measured memory_bytes: 32732
d=int(input())
C=list(map(int,input().split()))
S=[list(map(int,input().split())) for i in range(d)]
A=[0]*26
for i in range(d):
    cnt=[0]*26
    for j in range(26):
        A[j]+=C[j]
        cnt[j]=S[i][j]+A[j]
    now=cnt.index(max(cnt))
    print(now+1)
    A[now]=0

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

#define int long long
using namespace std;

const int mod = 1e9 + 7;
int fpow(int a, int b){
	int ans = 1;
  	while(b) {
      if (b&1) ans = (ans * a) % mod;
      a = (a*a) % mod;
      b >>= 1;
    }
  	return ans;
}
int32_t main() {
 	int n;
  	cin >> n;
  	cout << (fpow(10,n) - 2 * fpow(9,n) + fpow(8,n) + 2 * mod) % mod;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<ll>())
#define ll long long
#define rep(i, s, g) for (ll i = (s); i < (g); i++)
#define MOD 1000000007
#define vfind(v, target) find(v.begin(), v.end(), target)
#define notFound(v, target) (vfind(v, target) == v.end())

using namespace std;

int main()
{
  ll N; cin >> N;
  vector<ll> A(N);
  rep(i, 0, N) cin >> A[i];
  vsort(A);
  ll color = 1, sum = A[0];
  rep(i, 0, N - 1) {
  	if (sum * 2 >= A[i + 1]) color++;
    else color = 1;
    sum += A[i + 1];
  }
  cout << color << endl;
}

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

int main(){
	int H , W ;

	while(1){
		cin >> H >> W;
		if ( H == 0 && W == 0 ) break;

		for ( int i = 0; i < H; i++ ) {
			for ( int j = 0; j < W; j++ ){
				if( ( i + j) % 2 == 0 ) {
					cout << "#";
				} else { 
					cout << ".";
				}

			}
			cout << endl;
		}
		cout << endl;
	}

	return 0;
}

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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()
#define vprint(v) for(auto e:v){cout<<e<<" ";};cout<<endl;
#define vvprint(vv) for(auto v:vv){vprint(v)};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20);

    string S;
    cin >> S;

    if(S[S.length()-1]=='s') cout << S+"es" << endl;
    else cout << S+"s" << endl;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
int main()
{
    string s;
    long long int i,j,k,x;
    cin>>x;
    i=x/500;
    k=i*1000;
    x=x-i*500;
    j=x/5;
    j=j*5;
    k+=j;
    cout<<k<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>

int main(void) {
  int N;
  
  std::cin >> N;
  std::vector<int> a(N);
  for (int i = 0; i < N; ++i) {
    std::cin >> a[i];
  }
  
  std::sort(a.begin(), a.end());

  std::cout << a.back() - a.front() << std::endl;
  
  return 0;
}

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

int main() {
  int n,m,l;
  cin >> n >> m >> l;
  vector<vector<int> > A(n,vector<int>(m));
  vector<vector<int> > B(m,vector<int>(l));
  vector<vector<int64_t> > C(n,vector<int64_t>(l));
  for (int i=0; i<n; i++) {
      for (int j=0; j<m; j++) {
          cin >> A.at(i).at(j);
      }
  }
  
  for (int i=0; i<m; i++) {
      for (int j=0; j<l; j++) {
          cin >> B.at(i).at(j);
      }
  }
  
  for (int i=0; i<n; i++) {
      for (int j=0; j<l; j++) {
          C.at(i).at(j)=0;
          for (int k=0; k<m; k++) {
              C.at(i).at(j)+=A.at(i).at(k)*B.at(k).at(j);
          }
      }
  }
  
  for (int i=0; i<n; i++) {
      for (int j=0; j<l; j++) {
          cout << C.at(i).at(j);
          if (j!=l-1) cout << " ";
      }
      cout << endl;
  }
}


Measured memory_bytes: 3288