akhauriyash/Code-Regression huggingface dataset:
# ALDS_2_A.
# バブルソート。
from math import sqrt, floor

def intinput():
    a = input().split()
    for i in range(len(a)):
        a[i] = int(a[i])
    return a

def show(a):
    # 配列の中身を出力する。
    _str = ""
    for i in range(len(a) - 1):
        _str += str(a[i]) + " "
    _str += str(a[len(a) - 1])
    print(_str)

def bubble_sort(a):
    # aをバブルソートする(交換回数をreturnする)。
    count = 0
    for i in range(1, len(a)):
        k = i - 1
        while k >= 0:
            # a[i]を前の数と交換していき、前の方が小さかったら止める。
            if a[k] > a[k + 1]:
                a[k], a[k + 1] = a[k + 1], a[k]
                count += 1
            else: break
            k -= 1
    return count

def main():
    N = int(input())
    A = intinput()
    count = bubble_sort(A)
    show(A); print(count)

if __name__ == "__main__":
    main()


Measured memory_bytes: 5668
//B - Card Game for Two
#include <bits/stdc++.h>
using namespace std;

vector<int> card(100);
int N;
int solve();
void quickSort(vector<int> &vec, int L, int R);
void swap(vector<int> &v, int x, int y);


int main() {

  cin >> N;
  for(int i =0; i< N; i++){
    cin >> card[i];
  }

  solve();
}

int solve(){
  quickSort(card, 0, N-1);
  int count = 1;
  for(int i =1; i< N; i++){
    if(card.at(i-1) !=card.at(i)){
      count++;
    }
  }
  cout << count<< endl;
  return 0;
}


void quickSort(vector<int> &vec, int L, int R){
  int i, j, mid, piv;
  i = L;
  j = R;
  mid = L+(R-L)/2;
  piv = vec[mid];

  while(i<R || j>L){
    while(vec[i] <piv){
      i++;
    }
    while(vec[j] > piv){
      j--;
    }

    if(i <= j){
      swap(vec, i, j);
      i++;
      j--;
    }else{
      if(i < R){
        quickSort(vec, i, R);
      }
      if(j > L){
        quickSort(vec, L, j);
      }
      return;
    }
  }
}

void swap(vector<int> &v, int x, int y){
  int temp = v[x];
  v[x] = v[y];
  v[y] = temp;
}


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

struct SCC{
    int N;
    vector<bool> used;
    vector<int> vs;
    vector<int> cmp;

    void dfs(int v, const vector<vector<int>>& G){
        used[v] = true;
        for(auto u : G[v]){
            if(!used[u]) dfs(u, G);
        }
        vs.push_back(v);
    }

    void rdfs(int v, int k, const vector<vector<int>>& rG){
        used[v] = true;
        cmp[v] = k;
        for(auto u : rG[v]){
            if(!used[u]) rdfs(u, k, rG);
        }
    }

    SCC(int N, const vector<vector<int>>& G):N(N){
        vector<vector<int>> rG(N);
        for(int i=0; i<N; i++) for(int j : G[i]) rG[j].push_back(i);
        used.resize(N);
        fill(used.begin(), used.end(), false);
        for(int v=0; v<N; v++){
            if(!used[v]) dfs(v, G);
        }

        fill(used.begin(), used.end(), false);
        cmp.resize(N);
        int k = 0;
        for(int i = vs.size()-1; i>=0; i--){
            if(!used[vs[i]]) rdfs(vs[i], k++, rG);
        }
    }

    vector<vector<int>> dump_graph(const vector<vector<int>>& G){
        int sz = *max_element(cmp.begin(), cmp.end()) + 1;
        vector<vector<int>> edges2(sz);
        for(int i=0; i<N; i++){
            for(auto j : G[i]){
                if(cmp[i] != cmp[j]){
                    edges2[cmp[i]].push_back(cmp[j]);
                }
            }
        }
        return edges2;
    }
};

int main(){
    int N, M;
    cin >> N >> M;
    vector<vector<int>> edges(N);
    for(int i=0; i<M; i++){
        int a, b;
        scanf("%d %d", &a, &b);
        edges[a].push_back(b);
    }
    SCC scc(N, edges);
    int sz = *max_element(scc.cmp.begin(), scc.cmp.end()) + 1;
    vector<vector<int>> ans(sz);
    for(int i=0; i<N; i++) ans[scc.cmp[i]].push_back(i);
    cout << sz << endl;
    for(auto& v : ans){
        printf("%d", int(v.size()));
        for(int a : v) printf(" %d", a);
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 57908
'''
    Auther: ghoshashis545 Ashis Ghosh
    College: jalpaiguri Govt Enggineering College

'''
from os import path
import sys
from functools import cmp_to_key as ctk
from collections import deque,defaultdict as dd 
from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right
from itertools import permutations
from datetime import datetime
from math import ceil,sqrt,log,gcd
def ii():return int(input())
def si():return input()
def mi():return map(int,input().split())
def li():return list(mi())
abc='abcdefghijklmnopqrstuvwxyz'
mod=1000000007
#mod=998244353
inf = float("inf")
vow=['a','e','i','o','u']
dx,dy=[-1,1,0,0],[0,0,1,-1]

def bo(i):
    return ord(i)-ord('a')



def solve():
    
    # for _ in range(ii()):

    s=1
    n=ii()
    a=[2]*(n+1)
    for j in range(2,n+1):
        for k in range(2*j,n+1,j):
            a[k]+=1
    for i in range(2,n+1):
        s+=i*a[i]
    print(s)
    










        
if __name__ =="__main__":

    if path.exists('input.txt'):
        sys.stdin=open('input.txt', 'r')
        sys.stdout=open('output.txt','w')
    else:
        input=sys.stdin.readline
    solve()


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

using namespace std;

int main()
{
    int s[10],i;
    for(i=1;i<6;i++)
    {
        cin >> s[i];
        if(s[i]==0)
        {
            cout << i << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 3636
import bisect
import collections
import itertools


def getint(): return int(input())
def getints(): return list(map(int, input().split()))
def getint2d(rows): return [getints() for _ in range(rows)]
def getgrid(rows): return [input() for _ in range(rows)]
def array1d(n, value): return [value for _ in range(n)]
def array2d(n, m, value): return [array1d(m, value) for _ in range(n)]

class Graph:
    def __init__(self, node_count, edge_count):
        self.node_count = node_count
        self.lst = [-1 for _ in range(node_count)]
        self.nxt = [0 for _ in range(edge_count)]
        self.to = [0 for _ in range(edge_count)]
        self.m = 0

    def add_edge(self, u, v, w):  # bidirection weight
        m = self.m
        self.nxt[m], self.lst[u], self.to[m] = self.lst[u], m, (v, w)
        self.m += 1

    def traverse(self, u):
        m = self.lst[u]
        while m != -1:
            yield self.to[m]
            m = self.nxt[m]


n,q=getints()
values = [0]*n
gr = Graph(n,2*n)

for _ in range(n-1):
    a,b=getints()
    a,b=a-1,b-1
    gr.add_edge(a,b,1)
    gr.add_edge(b,a,1)

for _ in range(q):
    u, p=getints()
    values[u-1] += p

def distribute(u, par, prev):
    stk = []
    stk.append((u, par, 0))
    while stk:
        u,par,prev=stk[-1]
        stk.pop()
        values[u] += prev
        for v, _ in gr.traverse(u):
            if v == par: continue
            stk.append((v,u,values[u]))

distribute(0, -1, 0)
print(" ".join(map(str, values)))

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

using namespace std;

using ull = unsigned long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    ull x;
    cin >> n >> x;
    vector<ull> v(n), sumv(n + 1, 0);
    ull ans = x * n;
    for (int i = 0; i < n; i++) {
        cin >> v[i];
        ans += v[i] * 5;
        sumv[i + 1] = sumv[i] + v[i];
    }

    ull hoge = x * ((n + 1) / 2);
    for (int i = 1; i <= (n + 1) / 2; i++) {
        int num = 0;
        ull sum = x * i;
        for (int j = n - 1 - i; j >= 0; j -= i) {
            sum += (sumv[j + 1] - sumv[max(j + 1 - i, 0)]) * num * 2;
            num++;
        }
        hoge = min(hoge, sum);
    }
    ans += hoge;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3456
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{
  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    String s;
    String sl[];

    s = r.readLine();
    sl = s.split(" ");

    boolean a[] = new boolean[100001];
    int x[] = new int[100001];
    a[0] = true;

    int n = Integer.parseInt(sl[0]);
    int m = Integer.parseInt(sl[1]);

    s = r.readLine();
    sl = s.split(" ");

    for(int i = 0; i < n; i++)
    {
      x[i + 1] = Integer.parseInt(sl[i]);
    }

    for(int i = 0; i < m; i++)
    {
      s = r.readLine();
      sl = s.split(" ");
      int v1 = Integer.parseInt(sl[0]);
      int v2 = Integer.parseInt(sl[1]);
      if(x[v1] >= x[v2])
      {
        a[v2] = true;
      }
      if(x[v2] >= x[v1])
      {
        a[v1] = true;
      }
    }

    int ss = 0;
    for(int i = 1; i <= n; i++)
    {
      if(!a[i]) ss++;
    }
    System.out.println(ss);
  }

}

class RemRing
{
  long module;

  public RemRing(long module)
  {
    this.module = module;
  }

  public long sum(long a, long b)
  {
    return (a + b + module) % module;
  }

  public long sub(long a, long b)
  {
    return (a - b + module) % module;
  }

  public long prod(long a, long b)
  {
    return (a * b) % module;
  }

  public long div(long a, long b)
  {
    return (a * inv(b)) % module;
  }

  public long inv(long a)
  {
    long b = this.module;
    long u = 1;
    long v = 0;
    while (b > 0)
    {
      long t = a / b;
      a -= t * b;
      u -= t * v;
      long z = a;
      a = b;
      b = z;
      z = u;
      u = v;
      v = z;
    }
    u %= this.module;
    if (u < 0)
      u += this.module;
    return u;
  }
}

Measured memory_bytes: 60620
package main

import "fmt"

func scanStrs(h int) (strs [][]rune) {
	strs = make([][]rune, h)
	var s string
	for i := range strs {
		fmt.Scan(&s)
		strs[i] = []rune(s)
	}
	return
}

func drawable(strs [][]rune, i, j int) bool {
	if strs[i][j] == '.' {
		return true
	}

	result := false
	if i-1 >= 0 {
		if strs[i-1][j] == '#' {
			result = true
		}
	}

	if j-1 >= 0 {
		if strs[i][j-1] == '#' {
			result = true
		}
	}

	if j+1 < len(strs[0]) {
		if strs[i][j+1] == '#' {
			result = true
		}
	}

	if i+1 < len(strs) {
		if strs[i+1][j] == '#' {
			result = true
		}
	}

	return result
}

func main() {
	var h, w int
	fmt.Scan(&h, &w)
	strs := scanStrs(h)

	is_complete := true
	for i := 0; i < h; i++ {
		if !is_complete {
			break
		}
		for j := 0; j < w; j++ {
			if !is_complete {
				break
			}
			is_complete = drawable(strs, i, j)
		}
	}

	if is_complete {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
using LP=pair<ll,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;

ll absa(ll a,ll b=0){
    if(a>b)return a-b;
    return b-a;
}

int main() {
    int A,B,Q;
    cin>>A>>B>>Q;
    vector<ll> s(A+2),t(B+2);
    
    s.at(0)=-1e12;
    s.at(A+1)=1e12;
    t.at(0)=-1e12;
    t.at(B+1)=1e12;
    rep(i,A){
        cin>>s.at(i+1);
    }
    rep(i,B){
        cin>>t.at(i+1);
    }
    
    rep(query,Q){
        ll x;
        cin>>x;
        ll bs,ns,bt,nt;
        int p=lower_bound(s.begin(),s.end(),x)-s.begin();
        bs=s.at(p-1);
        ns=s.at(p);
        int q=lower_bound(t.begin(),t.end(),x)-t.begin();
        bt=t.at(q-1);
        nt=t.at(q);
        ll ans=1e12;
        vector<vector<ll>> list(3,vector<ll>(2));
        list.at(0).at(0)=bs;
        list.at(0).at(1)=ns;
        list.at(1).at(0)=bt;
        list.at(1).at(1)=nt;
        list.at(2).at(0)=bs;
        list.at(2).at(1)=ns;
        
        rep(i,2)rep(j,2)rep(k,2){
            ll now=absa(x,list.at(i).at(j))+absa(list.at(i).at(j),list.at(i+1).at(k));
        //cout<<now<<endl;
            chmin(ans,now);
        }
        //cout<<bs<<" "<<ns<<" "<<bt<<" "<<nt<<endl;
        cout<<ans<<endl;
    }
}

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

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

	int N, M;

	cin >> N >> M;

	int K;
	vector<vector<int>> S(M);

	for (int m = 0; m < M; m++)
	{
		cin >> K;
		S[m].resize(K);
		for (int k = 0; k < K; k++)
		{
			cin >> S[m][k];
			S[m][k]--;
		}
	}

	vector<int> P(M);

	for (int m = 0; m < M; m++)
	{
		cin >> P[m];
	}

	int ans = 0;

	for (int i = 0; i < (1 << N); i++)
	{
		// i をN bitの２値ベクトルととらえる！
		// 各電球mについて状態iで点灯するかどうか見る
		bool is_fire = true;
		for (int m = 0; m < M; m++)
		{
			int pushed_switch_num = 0;
			for (int idx : S[m])
			{
				if (i & (1 << idx))
				{
					pushed_switch_num++;
				}
			}

			if (pushed_switch_num % 2 != P[m])
			{
				is_fire = false;
			}
		}

		if (is_fire)
		{
			ans++;
		}
	}

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


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

int main()
{
    int N;
    cin>>N;
    if (N<9){
        cout<<N<<endl;
        return 0;
    }else if (N<100){
        cout<<9<<endl;
        return 0;
    }else if(N<999){
        cout<<N-99+9<<endl;
        return 0;
    }else if(N<10000){
        cout<<9+900<<endl;
        return 0;
    }else if (N<99999){
        cout<<N-9999+909<<endl;
        return 0;
    }else{
        cout<<90909<<endl;
        return 0;
    }
}

Measured memory_bytes: 256
#include<stdio.h>



struct Card {
	char suit;
	int value;
};


Card L[50000], R[50000];

void merge(Card A[], int left, int mid, int right)
{
	int n1, n2, i, j;
	n1 = mid - left;
	n2 = right - mid;
	for (i = 0; i < n1; i++)
	{
		L[i] = A[i + left];
	}

	for (i = 0; i < n2; i++)
	{
		R[i] = A[i + mid];
	}
	L[n1].value = 2000000000;
	R[n2].value = 2000000000;
	i = j = 0;
	for (int k = left; k < right; k++)
	{
		if (L[i].value <= R[j].value)
			A[k] = L[i++];
		else
			A[k] = R[j++];
	}
}

void mergeSort(Card A[], int left, int right)
{
	int mid;
	if (left + 1 < right)
	{
		mid = (left + right) / 2;
		mergeSort(A, left, mid);
		mergeSort(A, mid, right);
		merge(A, left, mid, right);
	}
}
int partition(Card A[],int p, int r)
{
	int i;
	Card x = A[r],t;
	i = p - 1;

	for (int j = p; j < r; j++)
	{
		if (A[j].value <= x.value)
		{
			i++;
			t = A[j];
			A[j] = A[i];
			A[i] = t;
		}
	}
	t = A[r];
	A[r] = A[i+1];
	A[i+1] = t;

	return i + 1;

}
void quickSort(Card A[], int p, int r)
{
	int q;
	if (p >= r)
		return;
	q = partition(A, p, r);
	quickSort(A, p, q - 1);
	quickSort(A, q+1, r);
}
int main()
{
	bool stable = true;
	Card A[100005], B[100005];
	int n,i;

	scanf("%d",&n);

	for (i = 0; i < n; i++)
	{
		scanf(" %c %d", &A[i].suit, &A[i].value);
		B[i] = A[i];
	}
	quickSort(A,0,n-1);
	mergeSort(B, 0, n);
	i = 0;
	while (i<n&&stable)
	{
		if (B[i].suit != A[i].suit)
			stable = false;
		i++;
	}
	if (stable)
		printf("Stable\n");
	else
		printf("Not stable\n");
	for (i = 0; i < n; i++)
	{
		printf("%c %d\n", A[i].suit, A[i].value);
	}

	return 0;
}


Measured memory_bytes: 5004
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using boost::multiprecision::cpp_int;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll,pair<ll, ll>> lpll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;

#define deg_to_rad(deg) (((deg)/360)*2*PI)

const ll LINF = LLONG_MAX;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;

const ld PI = (acos(-1));
const ld EPS = 0.0000000001;
// cout << fixed << setprecision(10) << middle << endl;

int main() {
    // input, ready
    int N,K;
    string S;
    cin >> N >> K >> S;

    //resolve
    int zero_cnt = 0;
    int one_cnt = 0;
    vector<int> zero_list;
    vector<int> one_list;
    for (auto c:S) {
        if (c=='0') {
            zero_cnt++;
            if (one_cnt >0) one_list.push_back(one_cnt);
            one_cnt = 0;
        } else {
            one_cnt++;
            if (zero_cnt >0) zero_list.push_back(zero_cnt);
            zero_cnt = 0;            
        }
    }
    if (zero_cnt >0) zero_list.push_back(zero_cnt);
    if (one_cnt >0) one_list.push_back(one_cnt);

    if (zero_list.size() <= K) {
        cout << N << endl;
        return 0;
    }

    int ans = 0;
    int ret1 = 0;
    int ret = 0;
    int size = min(K,(int)zero_list.size());
    if (S[0] == '0') {
        int r=0;
        int l=0;
        for (int i=0; i<size; i++) {
            ans += zero_list[i];
            if (i<one_list.size()) ans += one_list[i];
            r=i;
        }
        r++;
        ret = ans;
        while (r<zero_list.size()) {
            ans += zero_list[r];
            if (r<one_list.size()) ans += one_list[r];
            if (l > 0) ans -= one_list[l-1];
            ans -= zero_list[l];
            ret = max(ans,ret);
            r++;
            l++;
        }
    } else {
        int r=0;
        int l=0;
        ans += one_list[0];
        for (int i=0; i<size; i++) {
            ans += zero_list[i];
            if ((i+1)<one_list.size()) ans += one_list[i+1];
            r=i;
        }
        r++;
        ret = ans;
        while (r<zero_list.size()) {
            ans += zero_list[r];
            if (r+1<one_list.size()) ans += one_list[r+1];
            ans -= one_list[l];
            ans -= zero_list[l];
            ret = max(ans,ret);
            r++;
            l++;
        }        
    }

    // output
    cout << ret << endl;

    return 0;
}


Measured memory_bytes: 1020
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>	
using namespace std;
#define all(v)			((v).begin()), ((v).end())
#define sz(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
typedef long long         ll;
const double EPS = (1e-7);
int dcmp(double x, double y) { return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1; }
#define pb					push_back
#define P(x)				cout<<#x<<" = { "<<x<<" }\n"
clock_t T;
#define ctime cerr << "Time : " << double(clock() - T) / CLOCKS_PER_SEC << endl
void GOAT()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("output.txt", "w	", stdout);
#else
#endif

}
string a, b, ans = "";
int mem[3001][3001];
int lcs(int i, int j)
{
	if (i >= sz(a) || j >= sz(b))return 0;
	int& ret = mem[i][j];
	if (~ret)return ret;
	ret = -1;
	if (a[i] == b[j]) {
		// += a[i];
		return  ret=lcs(i + 1, j + 1)+1;
	}
	int ch1 = lcs(i, j + 1);
	int ch2 = lcs(i + 1, j);
	return ret = max(ch1, ch2);

}
void solve(int i, int j)
{
	if (i >= sz(a) || j >= sz(b))return;
	if (a[i] == b[j]) {
		ans += a[i];
		solve(i + 1, j + 1);
	}
	else
	{
		if (mem[i + 1][j] >= mem[i][j+1])
			solve(i + 1, j);
		else solve(i, j + 1);
	}


}
int main()
{
	//GOAT();
	clr(mem, -1);
	cin >> a >> b;
	lcs(0, 0);
	solve(0, 0);
	cout << ans << endl;


}


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

ll ceil(ll n, ll m) {
    return n % m == 0 ? n / m : n / m + 1;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll h, w, n;
    cin >> h >> w >> n;
    cout << ceil(n, max(h, w));
    return 0;
}

Measured memory_bytes: 256
#pragma warning(disable: 4996)
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <sstream>
#include <fstream>

using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); i++)

int main() {
    int n,ans = 0;
    int a[100];
    cin >> n;
    rep(i, n) cin >> a[i];

    rep(i, n) {
        if ((i + 1) % 2 == 1 && a[i] % 2 == 1) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3176
N, M, Q = map(int, input().split())

mat = [[0 for _ in range(N + 1)] for _ in range(N + 1)]
sum = [[0 for _ in range(N + 1)] for _ in range(N + 1)]

for i in range(M):
    L, R = map(int, input().split())
    mat[L][R] += 1

for i in range(1, N + 1):
    for j in range(1, N + 1):
        sum[i][j] = mat[i][j]
        sum[i][j] += sum[i - 1][j]
        sum[i][j] += sum[i][j - 1]
        sum[i][j] -= sum[i - 1][j - 1]

for i in range(Q):
    L, R = map(int, input().split())
    ans = sum[R][R]
    ans -= sum[R][L - 1]
    ans -= sum[L - 1][R]
    ans += sum[L - 1][L - 1]
    print(ans)


Measured memory_bytes: 15528
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

const int LIM=1000010;
bool sosu[LIM];

int main() {
	int i,j;
	for(i=0;i<LIM;i++){
		sosu[i]=true;
	}
	sosu[0]=sosu[1]=false;
	for(i=0;i<LIM;i++){
		if(sosu[i]){
			for(j=i*2;j<LIM;j+=i){
				sosu[j]=false;
			}
		}
	}
	int n;
	while(n=in()){
		int res=0;
		for(i=0;i<=n/2;i++){
			if(sosu[i]&&sosu[n-i])res++;
		}
		cout<<res<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-11;

int main() {
    while (1) {
        int w, d;
        cin >> w >> d;
        if (w == 0) {
            break;
        }
        int hw[w];
        for (int i = 0; i < w; i++) {
            cin >> hw[i];
        }
        int hd[d];
        for (int i = 0; i < d; i++) {
            cin >> hd[i];
        }
        sort(hw, hw + w);
        reverse(hw, hw + w);
        sort(hd, hd + d);
        reverse(hd, hd + d);
        int ans = 0;
        for (int i = 0; i < w; i++) {
            bool ok = false;
            for (int j = 0; j < d; j++) {
                if (hw[i] == hd[j]) {
                    hd[j] = -1;
                    ans += hw[i];
                    ok = true;
                    break;
                }
            }
            if (!ok) {
                ans += hw[i];
            }
        }
        for (int i = 0; i < d; i++) {
            if (hd[i] != -1) {
                ans += hd[i];
            }
        }
        cout << ans << endl;
    }
}



Measured memory_bytes: 3008
#include<stdio.h>
main()
{
  int a,b,c,d,e,f,X,Y,sum1,sum2,sum;
  scanf("%d%d",&X,&Y);
  a=(X==3);
  b=(X==2);
  c=(X==1);
  sum1=100000*a+200000*b+300000*c;
  d=(Y==3);
  e=(Y==2);
  f=(Y==1);
  sum2=100000*d+200000*e+300000*f;
  sum=sum1+sum2;
  if(sum==600000){
    sum=1000000;
  }
  printf("%d",sum);
}


Measured memory_bytes: 128
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""abc080_a"""


import sys


def main():
    """Main function."""
    n, a, b = list(map(int, input().split(' ')))

    if n * a < b:
        print(n * a)
    else:
        print(b)


if __name__ == '__main__':
    sys.exit(main())

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

using namespace std;

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

    long long a;
    long double b;
    cin >> a >> b;
    cout << (long long)((a * (long long)(b * 100 + 0.01)) / 100);

    return 0;
}


Measured memory_bytes: 3692
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int H,W,N;
int dp[1024][1024];
int g[1024][1024];

int main(){
  while(scanf("%d%d%d",&H,&W,&N) && H||W||N){
    memset(dp, 0, sizeof dp);
    for(int i=0;i<H;i++) for(int j=0;j<W;j++) scanf("%d", &g[i][j]);

    dp[0][0] = N-1;
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
	dp[i][j+1] += (dp[i][j]+(g[i][j]==1))/2;
	dp[i+1][j] += (dp[i][j]+(g[i][j]!=1))/2;
      }
    }
    int y = 0, x = 0;
    while(y < H && x < W){
      if(g[y][x]^(dp[y][x]%2)) x++;
      else y++;
    }
    printf("%d %d\n", y+1, x+1);
  }
  return 0;
}

Measured memory_bytes: 9224
#include <iostream>
using namespace std;
int main(void){
	int w,h;
	cin >>h>>w;
	string arr[h];
	for (int i=0;i<h;i++)cin>>arr[i];
	for (int i=0;i<h;i++){
		cout << arr[i] << endl;
		cout << arr[i] << endl;
	}
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
using namespace std;
/*ll power(ll x,ll y)
{
    ll res=1;
    while(y>0)
    {
        if(y%2==1)
            res=(res*x)%mod;
        x=(x*x)%mod;
        y=y/2;
    }
    return res;
}*/

int main()
{
   ll n,d;
   cin>>n>>d;
   d=2*d+1;
   if(n%d!=0)
    cout<<(n/d)+1<<endl;
   else
    cout<<n/d<<endl;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	sum := 0
	for i := a; i <= b; i++ {
		if i/10000 == i%10 && i/1000%10 == i/10%10 {
			sum++
		}
	}
	fmt.Println(sum)
}


Measured memory_bytes: 512
import sys
input = lambda: sys.stdin.readline().rstrip() 

def resolve():
    N, W = map(int, input().split())
    w = [0] * N
    v = [0] * N
    for i in range(N):
        w[i], v[i] = map(int, input().split()) 

    sum_v = sum(v)

    # dp[i][j]: 0〜(i-1)まで使ったときの価値jのときの重みの総和の最小値
    dp = [[sum(w)]*(sum_v+1) for i in range(N+1)]
    dp[0][0] = 0

    for i in range(1, N+1):
        for j in range(sum_v+1):
            if j-v[i-1] >= 0:
                dp[i][j] = min(dp[i-1][j-v[i-1]] + w[i-1], dp[i-1][j])
            else:
                dp[i][j] = dp[i-1][j]

    print(max([i for i, w in enumerate(dp[N]) if w<=W]))

if __name__ == '__main__':
    resolve()


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

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

    string s = "";
    while (n > 0) {
        int a = n % 26;
        if (a == 0) a = 26, n--;
        s = char('a' - 1 + a) + s;
        n /= 26;
    }

    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3628
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int a = in.nextInt();
		int b = in.nextInt();
		System.out.println(solve(a, b));
		in.close();
	}

	private static int solve(int a, int b) {
		int r = 0;
		for (int i = 1; i <= 9; i++)
			for (int j = 0; j <= 9; j++)
				for (int k = 0; k <= 9; k++) {
					int x = (i * 10001 + j * 1010 + k * 100);
					if (x >= a && x <= b)
						r++;
				}
		return r;
	}
}

Measured memory_bytes: 21844
#include<stdio.h>
int main(void)
{
  int a,b;
  scanf("%d%d",&a,&b);
  char s[15];
  scanf("%s",s);
  for(int i=0;i<a;i++){
    if(s[i]<'0'||s[i]>'9'){
      puts("No");
      return 0;
    }
  }
  if(s[a]!='-'){
    puts("No");
    return 0;
  }

  for(int i=a+1;i<a+b+1;i++){
    if(s[i]<'0'||s[i]>'9'){
      puts("No");
      return 0;
    }
  }


  puts("Yes");
  return 0;
}


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

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	print_tuple<Cdr...>(os,t);
	os<<(sizeof...(Cdr)?",":"")<<get<sizeof...(Cdr)>(t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

struct FenwickTree{
	vector<ll> data;
	FenwickTree(int n):data(n+1){}
	void AddRange(int i,int x){
		for(;i;i-=i&-i)
			data[i]+=x;
	}
	void AddRange(int i,int j,int x){
		AddRange(i,-x);
		AddRange(j,x);
	}
	int Get(int i){
		ll res=0;
		for(i++;i<data.size();i+=i&-i)
			res+=data[i];
		return res;
	}
};

int main()
{
	for(int n,m;cin>>n>>m&&n|m;){
		vi ls(n),rs(n);
		rep(i,n) cin>>ls[i]>>rs[i];

		map<int,vi> f;
		rep(i,n) f[rs[i]-ls[i]+1].push_back(i);

		vi sum(m+1);
		rep(i,m+1) sum[i]=f[i].size();
	 	per(i,m) sum[i]+=sum[i+1];

		FenwickTree ft(m+1);
		repi(d,1,m+1){
			int res=sum[d];
			for(int i=d;i<=m;i+=d)
				res+=ft.Get(i);
			cout<<res<<endl;
			for(int i:f[d])
				ft.AddRange(ls[i],rs[i]+1,1);
		}
	}
}


Measured memory_bytes: 15360
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using ll=long long;
using namespace std;
int main(){
 int n,m,x;
  cin>>n>>m>>x;
  ll c[n];
  ll a[n][m];
  ll ans=10000000;
  rep(i,n){
  cin>>c[i];//i;参考書 各々の金額を格納
    rep(j,m){
    cin>>a[i][j];
    }
  }
 /* rep(i,n){
    cin>>c[i];
  }
  rep(i,n) rep(j,m){
    cin>>a[i][j];
    }*/
  
 // int und[m];//各々のアルゴリズムの理解度をカウント
  int mon;//金額をカウント
  rep(mi,1<<n){
     mon=0;//金額カウントを初期化
    int und[m]={0};//理解度を初期化
   rep(i,n){//ある参考書パターンに対し
    
    if(mi>>i&1){//i番目は買ってる
    rep(j,m){
    und[j]+=a[i][j];//i番目の参考書に対する各々の理解度を足す
    }
      mon+=c[i];
      
    }
   //  cout<<mon<<endl;
    //買ってなかったら足さない
  }
    //理解度が超えているか判定
    int jud=0;
    rep(j,m){
    if(und[j]>=x){
    ++jud;
    }
   // cout<<und[j]<<endl;
    }
  //cout<<jud<<endl;
    if(jud==m){//全部習得できていたら 金額を更新するかも？
    if(ans>=mon){
      ans=mon;
      
    }
    }
    //cout<<ans<<endl;
  //  cout<<mon<<endl;
  }
  if(ans==10000000){
  cout<<"-1"<<endl;
  }
  else{
  cout<<ans<<endl;
  }
}
  

Measured memory_bytes: 3604
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;
import java.util.StringJoiner;

public class Main {

    private static boolean isLessThan(String[] a, String[] b) {
        for (int i = 0; i < Math.min(a.length, b.length); i++) {
            if (a[i].compareTo(b[i]) < 0) {
                return true;
            } else if (a[i].compareTo(b[i]) > 0) {
                return false;
            }
        }
        return a.length < b.length;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        String[] sa = s.split("");
        String[] ta = t.split("");
        Arrays.sort(sa);
        Arrays.sort(ta, Collections.reverseOrder());
        StringJoiner sjs = new StringJoiner("");
        for (int i = 0; i < sa.length; i++) {
            sjs.add(sa[i]);
        }
        StringJoiner sjt = new StringJoiner("");
        for (int i = 0; i < ta.length; i++) {
            sjt.add(ta[i]);
        }
        if (isLessThan(sa, ta)) {
            System.out.println("Yes");
            return;
        }
        System.out.println("No");
    }

}


Measured memory_bytes: 21972
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(void) {
	int i;
	int a, b, h;
	char buf[128], *ch;

	fgets(buf, sizeof(buf), stdin);
	ch = strtok(buf, " ");
	a = atoi(ch);
	fgets(buf, sizeof(buf), stdin);
	ch = strtok(buf, " ");
	b = atoi(ch);
	fgets(buf, sizeof(buf), stdin);
	ch = strtok(buf, " ");
	h = atoi(ch);

	printf("%d\n", ((a + b)*h)/2);
	return 0;
}


Measured memory_bytes: 2088
#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++){
		 	cout << "#";
		 }
		 cout << "\n";
		}
		cout << endl;
	  }
	  return 0;

	}

Measured memory_bytes: 3048
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	int L;
	vector<int> A;
	vector<vector<int>> dp;
	
	cin>>L;
	
	A.resize(L);
	
	dp.resize(5, vector<int>(L+1, INF));
	
	for(int i = 0; i < L; i++){
		cin>>A[i];
	}
	
	dp[0][0] = 0;
	
	for(int i = 0; i < L; i++){
		dp[0][i+1] = min(dp[0][i+1], dp[0][i] + A[i]);
		
		dp[1][i] = min(dp[1][i], dp[0][i]);
		
		if(A[i]) dp[1][i+1] = min(dp[1][i+1], dp[1][i] + A[i]%2);
		else  dp[1][i+1] = min(dp[1][i+1], dp[1][i] + 2);
		
		dp[2][i] = min(dp[2][i], dp[1][i]);
		
		dp[2][i+1] = min(dp[2][i+1], dp[2][i] + (A[i]+1)%2);
		
		dp[3][i] = min(dp[3][i], dp[2][i]);
		
		if(A[i]) dp[3][i+1] = min(dp[3][i+1], dp[3][i] + A[i]%2);
		else  dp[3][i+1] = min(dp[3][i+1], dp[3][i] + 2);
		
		dp[4][i] = min(dp[4][i], dp[3][i]);
		
		dp[4][i+1] = min(dp[4][i+1], dp[4][i] + A[i]);
		
		// for(int j = 0; j< 5; j++){
			// cout<<dp[j][i+1]<<" ";
		// }
		// cout<<endl;
	}
	
	int ans = INF;
	
	for(int i = 0; i < 5; i++){
		ans = min(ans, dp[i][L]);
	}
	
	cout<<ans<<endl;
	
	
	return 0;
}

Measured memory_bytes: 11264
class Solution:
    def solve(self, N: int, A: int, B: int) -> int:

        return (N // (A+B)) * A + min(N % (A+B), A)


if __name__ == '__main__':

    # standard input
    N, A, B = map(int, input().split())

    # solve
    solution = Solution()
    print(solution.solve(N, A, B))


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

int main(void){
  int i,j,H,W;
  cin >> H >> W;
  vector<vector<char> >v(H,vector<char>(W));
  vector<bool> erase_W(W,true);
  vector<bool> erase_H(H,true);
  REP(i,H){
    REP(j,W){
      cin >> v[i][j];
      if(v[i][j] == '#'){
        erase_W[j] = false;
        erase_H[i] = false;
      }
    }
  }
  for(i=H-1;i>=0;i--){
    if(erase_H[i]) v.erase(v.begin()+i);
  }
  for(j=W-1;j>=0;j--){
    if(erase_W[j]){
      REP(i,v.size()){
        v[i].erase(v[i].begin()+j);
      }
    }
  }
  REP(i,v.size()){
    REP(j,v[i].size()) cout << v[i][j];
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import scala.collection.immutable.List
import scala.io.StdIn

object Main extends App {

  val n = StdIn.readLine().toInt
  //val M = Array.fill[ArrayBuffer[(Int, Int)]](n)(ArrayBuffer.empty[(Int, Int)])
  val M = Array.fill[List[(Int, Int)]](n)(List.empty[(Int, Int)])

  (0 until n).foreach { _ =>
    val a = StdIn.readLine().split(' ').map(_.toInt)
    M(a(0)) = (0 until a(1)).map { k =>
      (a(2 + k * 2), a(2 + k * 2 + 1))
    }.reverse.toList
  }

  //(0 until n).foreach { i => println(M(i).mkString("")) }
  private val WHITE = 0
  private val GRAY = 1
  private val BLACK = 9

  val color = Array.fill[Int](n)(WHITE)
  val distance = Array.fill(n)(Int.MaxValue)
  val parent = Array.fill(n)(-1)

  val pq = scala.collection.mutable.PriorityQueue.empty[(Int, Int)]

  def dijkstra(s: Int): Unit = {
    distance(s) = 0
    pq.enqueue((0, 0))
    //color(s) = GRAY

    while (pq.nonEmpty) {
      
      val f = pq.dequeue() // (cost, index)
      val u = f._2 // index
      
      //color(u) = BLACK
      if (distance(u) >= -1 * f._1) { 
        M(u).foreach{ v =>
          //if (color(v._1) != BLACK) {
            if (distance(u) + v._2 < distance(v._1)) {
              distance(v._1) = distance(u) + v._2
              //color(v._1) = GRAY
              pq.enqueue((-1 * v._2, v._1)) // (cost , index)
            }
         // }
        }
      }
    }
  }

  dijkstra(0)

  (0 until n).foreach(i => println(i + " " + distance(i)))

}




Measured memory_bytes: 220208
package main

import (
	"fmt"
)

func main(){
	abc95c()
}
//var a, b string
//fmt.Scan(&a, &b)
//fmt.Println(a, b)

func abc95c(){
	var a, b, c, x, y int
	fmt.Scan(&a, &b, &c, &x, &y)

	sum := map[int]int{}
	sum[0] = a*x + b*y
	if x > y {
		sum[1] = 2*c*x
		sum[2] = 2*c*y + a*(x-y)
	}else if y > x {
		sum[1] = 2*c*y
		sum[2] = 2*c*x + b*(y-x)
	}else{
		sum[1] = 2*c*x
	}

	ans := sum[0]
	for _, v := range sum {
		if ans > v {
			ans = v
		}
	}

	fmt.Print(ans)
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<cmath>
#include<iomanip>
#include<bits/stdc++.h>
using namespace std;
int main(){
    cout << fixed << setprecision(12);
    double r1,r2,c;
    double PI = acos(-1.0);
    cin >> r1 >> r2 >> c;
    c = c/180.0*PI;
    double s = 0.5*(r1*r2*sin(c));
    double r3 = sqrt(pow(r1,2) + pow(r2,2) - 2*r1*r2*cos(c));
    double l = r1 + r2 + r3;
    double h = r2*sin(c);
    cout << s << " " << l << " " << h << endl;
}


Measured memory_bytes: 3580
# include <bits/stdc++.h>
# define rep(i, n) for(ll i = 0; i < (n); ++i)
# define reps(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(ll i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(ll i=((int)(n)); i>0; --i)
# define ll long long
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define P pair<int, int>
using namespace std;
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; }
ll lmax(ll a, ll b){if(a>= b) return a;return b;}
ll lmin(ll a, ll b){if(a>= b) return b;return a;}


int main() {
  int n, k; cin >> n >> k;
  vector<ll> h(n);
  rep(i, n) cin >> h[i];

  sort(ALL(h)); reverse(ALL(h));
  ll sum = 0;
  rep(i, n){
    if(k > 0){
      --k;
      continue;
    }
    sum += h[i];
  }

  cout << sum << endl;
}


Measured memory_bytes: 4764
N = int(input())
a = list(map(int, input().split()))
flag = True
if max(a) == 0:   # 全て0の時は必ず成り立つ
    flag = True
else:
    if N % 3 != 0:   # 全て0でなくて，Nが3の倍数出ない時は成り立たない
        flag = False
    else:
        n = N // 3
        a_set = set(a)
        if len(a_set) == 2:
            count = [] 
            value = []
            for number in a_set:
                count.append(a.count(number))
                value.append(number)
            if value[0] == 0 and count[0] == n and count[1] == n * 2:
                flag = True
            else:
                flag = False
        elif len(a_set) == 3:
            count = []
            value = []
            for number in a_set:
                count.append(a.count(number))
                value.append(number)
            if count[0] == count[1] == count[2]:
                if value[0] ^ value[1] ^ value[2] == 0:
                    flag = True
                else:
                    flag = False
            else:
                flag = False
        else:
            flag = False
if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 14212
#include <stdio.h>

void selectionSort(int A[],int n){
  int i,temp,count=0,j;
  int minj;
  
  for(i=0;i<=n-1;i++){
    minj=i;
    for(j=i;j<=n-1;j++){
      if(A[j]<A[minj]){
	minj=j;
      }
    }
    temp=A[i];
    A[i]=A[minj];
    A[minj]=temp;
    if(i!=minj)count++;
  }
  
  for(i=0;i<n;i++){
    printf("%d",A[i]);
    if(i!=n-1)printf(" ");
  }
  printf("\n");
  printf("%d\n",count);
}

 
int main(){

  int n,i=0;
  int A[100];

  scanf("%d",&n);
  if(n>=1 && n<=100){
    for(i=0;i<n;i++){
      scanf("%d",&A[i]);
    }
    //printf("a\n");
    selectionSort(A,n);
    
  }	  
  return 0;
}



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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

template<typename T1,typename T2>ostream& operator<<(ostream& os,const pair<T1,T2>& a) {os << "(" << a.first << ", " << a.second << ")";return os;}

const char newl = '\n';

int main() {
    int n;
    cin >> n;
    vector<vector<int>> cnt(21,vector<int>(21,0));
    ll ans = 0;
    for (int i = 0;i < n;++i) {
        double s;
        cin >> s;
        ll x = round(s*1e9);
        int t = -9,f = -9;
        while (x%2 == 0) x /= 2,t++;
        while (x%5 == 0) x /= 5,f++;
        t = min(t,10);
        f = min(f,10);
        for (int j = -t+10;j < 21;++j) for (int k = -f+10;k < 21;++k) ans += cnt[j][k];
        cnt[t+10][f+10]++;
    }
    cout << ans << endl;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}


int main(void) {
    vector<int> a(3);
    for (auto &x: a) cin >> x;
    sort(all(a));
    if (a[0]+a[1] == a[2]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

}


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

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

	if(N/1000 == N/100%10 && N/1000 == N/10%100%10){
	cout << "Yes" << endl; //1000の位と100の位が一致、かつ1000の位と10の位が一致
	}

	else if(N/100%10 == N%1000%100%10 && N/100%10 == N/10%100%10){
	cout << "Yes" << endl; //100の位と1の位が一致、かつ100の位と10の位が一致
	}

	else{
	cout << "No" << endl;
	}
}


Measured memory_bytes: 3576
N,M,X=map(int,input().split())
book=[[] for i in range(N)]
for i in range(N):
    book[i]=list(map(int,input().split()))

ans=float("inf")
def dfs(num,table,cost):
    global ans
    if num==N:
        for i in range(M):
            if X>table[i]:
                break
        else:
            ans=min(ans,cost)
    else:
        table2=[table[i]+book[num][i+1] for i in range(M)]
        dfs(num+1,table2,cost+book[num][0])
        dfs(num+1,table,cost)

dfs(0,[0]*M,0)
if ans==float("inf"):
    print(-1)
else:
    print(ans)


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

int main(){
    int A, B;
    cin >> A >> B;
    if (A != 1 && B != 1){
        cout << 1 << endl;
    }
    else if (A != 2 && B != 2){
        cout << 2 << endl;
    }
    else if (A != 3 && B != 3){
        cout << 3 << endl;
    }
    return 0;
}

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

using namespace std;
using ll = long long;

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	ll x;
	cin >> n >> x;
	vector<ll> a(n);
	for(int i = 0; i < n; ++i){ cin >> a[i]; }
	vector<ll> b(a);
	ll answer = 1000000000000000000ll;
	for(int i = 0; i < n; ++i){
		ll local = x * i;
		for(int j = 0; j < n; ++j){ local += b[j]; }
		answer = min(answer, local);
		vector<ll> c(n);
		for(int j = 0; j < n; ++j){
			c[j] = min(b[j], b[(j + n - 1) % n]);
		}
		c.swap(b);
	}
	cout << answer << endl;
	return 0;
}



Measured memory_bytes: 256
K = int(input())

nana = 7
count = 1

mod = 7 % K 

past = {mod}

while mod != 0:
  mod = (mod * 10 + 7) % K
  if mod in past:
    break
  past.add(mod)
  count += 1
  
if mod == 0:
  print(count)
else:
  print(-1)
  
 

Measured memory_bytes: 156672
#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
#define itn int
#define all(c) c.begin(),c.end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
#define ll long long
#define ull unsigned long long
#define pll pair<ll, ll>
#define pii pair<int, int>
#define mp(x, y) make_pair(x, y)
using namespace std;
 
const ll MAX_N = 2e5 + 5, inf = 1e18, mod = 1000000007;
const double PI = 3.1415926536;
int days[13] = {0, 31, 28, 31, 30, 31,30, 31, 31, 30, 31, 30, 31};
 
template<typename T>
ostream& operator <<(ostream& out, const vector<T>& mas) {
    for (const auto& x : mas) {
        out << x << ' ';
    }
    return out;
}
 
void ok() {
    cout << "YES" << '\n';
}
 
void no() {
    cout << "NO" << '\n';
}
 
inline ll nxt() {
    ll x;
    cin >> x;
    return x;
} 
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    ll a = nxt();
  	double t;
 	cin >> t;
  	ll b = t * 1000000;
    cout << a * b / 1000000;
    return 0;
}

Measured memory_bytes: 3648
s = int(input())
import sys
tmp = s
A = [tmp]
flag = 0
while flag==0:
    if tmp%2 == 0:
        tmp//=2
        A.append(tmp)
    else:
        tmp = 3*tmp+1
        A.append(tmp)
    if tmp==1:
        flag = 1
A += [4,2,1]
N = len(A)
flag = 0

for i in range(N):
    tmp = A[i]
    for j in range(i+1,N):
        if A[j]==tmp:
            print(j+1)
            sys.exit()

Measured memory_bytes: 38384
/*OJ:atcoder
  ProblemID:61c
  Date:2018.4.1
*/

 #include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <complex>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cwchar>
#include <cwctype>
#include <exception>
#include <locale>
#include <numeric>
#include <new>
#include <stdexcept>
#include <limits>
#include <valarray>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <list>
#include <utility>
#include <bitset>
#include <algorithm>
#include <functional>
#define mp make_pair
#define pb push_back
#define all(n) (n).begin,(n).end
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pair<int,int>,int> piii;
typedef vector<int> vi;
const int INF=1e9+7;
/*_____main part_____*/
ll ans;
string s;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>s;
	int len=s.size() ;
	for(int k=0;k<(1<<(len-1));k++)
	{
		ll num=s[0]-'0';
		for(int i=0;i<len-1;i++)
		{
			if(k&(1<<i))
			{
				ans+=num;
				num=0;
			 } 
			 num=num*10+s[i+1]-'0';
		}
		ans+=num;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int n,k,q,i,l;
    cin>>n>>k>>q;
    int cnt[n];
    for(i=0;i<n;i++){
        cnt[i]=k;
    }
    int pre;
    for(i=0;i<q;i++){
        cin >> pre;
        cnt[pre-1]++;
    }
    for(i=0;i<n;i++){
        if(cnt[i]-q>0){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1024