akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <utility>
#include <bitset>
#include <vector>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;} //&&c<='9'
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_vo(string s){for(char c:s)pcu(c);}
#endif
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

int main() {
	bitset<64> f = 0;
	vector<bitset<64>> M(in());
	for (auto &b: M)
		for (int k = in(); k; k--)
			b.set(in());
	for (int q = in(); q; q--) {
		int o = in(), m = in();
		switch (o) {
		case 0:
			outl((int) f.test(m));
			break;
		case 1:
			f |= M[m];
			break;
		case 2:
			f &= ~M[m];
			break;
		case 3:
			f ^= M[m];
			break;
		case 4:
			outl((int) ((f & M[m] | ~M[m]).all()));
			break;
		case 5:
			outl((int) (f & M[m]).any());
			break;
		case 6:
			outl((int) (f & M[m]).none());
			break;
		case 7:
			outl((f & M[m]).count());
			break;
		case 8:
			outl((f & M[m]).to_ulong());
			break;
		default:
			outl("error");
		}
	}
}


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

int main(){
  string X;
  cin>>X;
  int N,answer=0;
  N=X.size();
  rep(i,N){
    if(X[2*i] == 'L'){
      answer=1;
    }
    if(X[2*i+1]  == 'R'){
      answer =1;
    }
  }
  if(answer==1)
    cout <<"No";
  else
    cout<<"Yes";
}

Measured memory_bytes: 256
n=int(input())
a,b,c=map(int,input().split())
dp=[[a,b,c] for i in range(n)]
for i in range(1,n):
    a,b,c=map(int,input().split())
    dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a
    dp[i][1]=max(dp[i-1][2],dp[i-1][0])+b
    dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c
print(max(dp[n-1]))


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

int main() {
  int a, b, t; //入力する数値の初期化
  
  cin  >> t >> a >> b;
  
  if (t * a > b){
  	cout << b << endl;
  }else if ( t * a < b) {
  	cout << t * a << endl;
  }else{
  	cout << b << endl;
  }
}


Measured memory_bytes: 3580
N = gets.to_i

h = {}
N.times do
  s = gets.strip.chars.sort.join
  h[s] ||= 0
  h[s] += 1
end

ans = 0
h.each do |_, v|
  (v - 1).downto(1) do |i|
    ans += i
  end
end

puts ans



Measured memory_bytes: 17020
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;


public class Main {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    final int n = scanner.nextInt();
    final int m = scanner.nextInt();
//    final List<Submit> submits = new ArrayList<>();
    int correct = 0;
    int penalty = 0;
    boolean[] result = new boolean[n];
    int[] wa = new int[n];

    for (int i = 0; i < m; i++) {
      int sub = scanner.nextInt();
      String res = scanner.next();
      if(res.equals("AC") && !result[sub-1]) {
        result[sub-1] = true;
      }
      if(!result[sub-1]) {
        wa[sub-1]++;
      }
    }

    for (int i = 0; i < n; i++) {
      if(result[i]) {
        penalty += wa[i];
        correct++;
      }
    }
    System.out.println(correct + " " + penalty);
  }
//    for (int i = 0; i < m; i++) {
//      submits.add(new Submit(scanner.nextInt(), scanner.next()));
//    }
//
//    List<Integer> subjects = submits.stream().map(e->e.subject).distinct().collect(Collectors.toList());
//    for (final int i : subjects) {
//      System.out.println(i);
//      List<String> iSubmits = submits.stream()
//          .filter(e -> e.subject == i)
//          .map(e -> e.result)
//          .collect(
//              Collectors.toList());
//      if (iSubmits.contains("AC")) {
//        correct++;
//        penalty += iSubmits.indexOf("AC");
//      }
//    }
//    System.out.println(correct + " " + penalty);
//  }
//
//  private static class Submit {
//
//    private int subject;
//    private String result;
//
//    Submit(int subject, String result) {
//      this.subject = subject;
//      this.result = result;
//    }
//  }
}


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

int main(){
  int a, b;

  cin >> a >> b;
  if (a < b){
    for(int i=0; i<b; i++){
      cout << a;
    }
  } else {
    for(int i=0; i<a; i++){
      cout << b;
    }
  }
  cout << endl;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			if (n == 0)
				break;
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = scanner.nextInt();
			int ans = n;
			for (int i = 0; i < n; i++)
				for (int j = 1; j < 4; j++) {
					if (a[i] == j)
						continue;
					int tmp = a[i];
					a[i] = j;
					int l = i;
					int r = i;
					int cnt = 0;
					while (l >= 0) {
						int cc = a[l];
						while (l > 0 && cc == a[l - 1])
							l--;
						while (r < n - 1 && cc == a[r + 1])
							r++;
						if (r - l - cnt + 1 < 4)
							break;
						cnt += r - l - cnt + 1;
						l--;
					}
					a[i] = tmp;
					ans = Math.min(ans, n - cnt);
				}
			System.out.println(ans);
		}
	}
}

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

int main() {
	int N, K;
	cin >> N >> K;
	int A[K], B[K];
	for (int i = 0; i < K; i++) cin >> A[i] >> B[i];
	int dp[N][9];
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 9; j++) {
			dp[i][j] = 0;
		}
	}
	bool jud[N][9];
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 9; j++) {
			jud[i][j] = true;
		}
	}
	for (int i = 0; i < K; i++) {
		int x = A[i], y = B[i];
		if (y == 1) {
			jud[x - 1][1] = false;
			jud[x - 1][2] = false;
			jud[x - 1][4] = false;
			jud[x - 1][5] = false;
			jud[x - 1][7] = false;
			jud[x - 1][8] = false;
		}
		else if (y == 2) {
			jud[x - 1][0] = false;
			jud[x - 1][2] = false;
			jud[x - 1][3] = false;
			jud[x - 1][5] = false;
			jud[x - 1][6] = false;
			jud[x - 1][8] = false;
		}
		else {
			jud[x - 1][0] = false;
			jud[x - 1][1] = false;
			jud[x - 1][3] = false;
			jud[x - 1][4] = false;
			jud[x - 1][6] = false;
			jud[x - 1][7] = false;
		}
	}

	for (int i = 0; i < 9; i++) {
		if (jud[1][i]) {
			if (0 <= i && i <= 2) {
				if (jud[0][0] || jud[0][3] || jud[0][6]) {
					dp[1][i] = 1;
				}
			}
			else if (3 <= i && i <= 5) {
				if (jud[0][1] || jud[0][4] || jud[0][7]) {
					dp[1][i] = 1;
				}
			}
			else {
				if (jud[0][2] || jud[0][5] || jud[0][8]) {
					dp[1][i] = 1;
				}
			}
		}
	}

	for (int i = 2; i < N; i++) {
		for (int j = 0; j < 9; j++) {
			if (jud[i][j]) {
				if (j == 0) {
					dp[i][j] = dp[i - 1][3] + dp[i - 1][6];
				}
				else if (j == 1 || j == 2) {
					dp[i][j] = dp[i - 1][0] + dp[i - 1][3] + dp[i - 1][6];
				}
				else if (j == 3 || j == 5) {
					dp[i][j] = dp[i - 1][1] + dp[i - 1][4] + dp[i - 1][7];
				}
				else if (j == 4) {
					dp[i][j] = dp[i - 1][1] + dp[i - 1][7];
				}
				else if (j == 6 || j == 7) {
					dp[i][j] = dp[i - 1][2] + dp[i - 1][5] + dp[i - 1][8];
				}
				else {
					dp[i][j] = dp[i - 1][2] + dp[i - 1][5];
				}
				dp[i][j] %= 10000;
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < 9; i++) {
		ans += dp[N - 1][i];
		ans %= 10000;
	}
	cout << ans << endl;
}


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

int getPrimeNumbers(int max, int prime[]){
	prime[0] = 2;
	int counter = 0;
	bool isPrime;
	for(int i = 3; prime[counter] * prime[counter] < max ; i += 2){
		isPrime = true;
		for(int j = 0; j <= counter; j++){
			if(i % prime[j] == 0) isPrime = false;
		}
		if(isPrime){
			prime[++counter] = i;
		}
	}
	return counter;
}

int main(){

	int max, num = 0;
	int element[10000];
	int prime[10000];
	int numOfPrime = 1;

	cin >> num;

	for(int i = 0; i < num; i++){
		cin >> element[i];
		if(max <= element[i]){
			max = element[i];
		}
	}

	numOfPrime = getPrimeNumbers(max, prime);

	int primeCounter = 0;
	for(int i = 0; i < num; i++){
		for(int j = 0; j <=numOfPrime; j++){
			if(prime[j] == element[i]){
				primeCounter ++;
				break;
			}
			if(element[i] % prime[j] == 0){
				break;
			}
			if(element[i] < prime[j] * prime[j]){
				primeCounter ++;
				break;
			}
		}
	}

	cout << primeCounter << endl;



	return 0;
}

Measured memory_bytes: 1208
from itertools import accumulate
from bisect import bisect
n,m,k=map(int,input().split())
A=list(map(int,input().split()))
A=list(accumulate(A,initial=0))
B=list(map(int,input().split()))
B=list(accumulate(B))

ans = 0
for i,a in enumerate(A):
  if a > k: break
  ans = max(ans,i + bisect(B,k-a))
print(ans)

Measured memory_bytes: 45332
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;
typedef vector<long long int> vll;

int main() {
	int a, b;
	cin >> a >> b;
	if (a + b == 15) cout << "+" << endl;
	else if (a*b == 15) cout << "*" << endl;
	else cout << "x" << endl;
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    map<string, int> m;
    int n;
    string s;
    cin >> n;
    for (int i = 0; i < n; ++i) cin >> s, ++m[s];
    vector<string> v = {"AC", "WA", "TLE", "RE"};
    for (string i : v) cout << i << " x " << m[i] << endl;
    return 0;
}


Measured memory_bytes: 3656
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func solve() {
	k, s := getInt(), getInt()
	m := min(k, s)

	ans := 0
	for x := 0; x <= m; x++ {
		for y := 0; (y <= k) && (x+y <= s); y++ {
			z := s - (x + y)
			if (z >= 0) && (z <= k) {
				ans++
			}
		}
	}

	fmt.Fprintln(wr, ans)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

// -----------------------------------------

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}

func getRunes() []rune {
	return []rune(getString())
}


Measured memory_bytes: 640
#include <stdio.h>
#include <ctype.h>

int main(){
    char c;
    int cnt[26];
    int i;
    for(i=0;i<26;i++)cnt[i]=0;
    while ((c = getchar()) != EOF) {
        if(isalpha(c)){
            c = tolower(c);
            cnt[c-'a']++;
        }
    }
    for(i=0;i<26;i++)printf("%c : %d\n",'a'+i,cnt[i]);
}

Measured memory_bytes: 940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int tmp;
    cin >> tmp;
    int A = tmp/1000;
    int B = (tmp%1000)/100;
    int C = (tmp%100)/10;
    int D = (tmp%10);
    bool fin = 0;
    REP(i,2){
        int result = (i == 0 ? A+B : A-B);
        REP(l,2){
            int resu2 = (l == 0 ? result + C : result - C);
            REP(j,2){
                int resu3 = (j == 0 ? resu2 + D : resu2 - D);
                if(resu3 == 7){
                    cout <<A<< (i == 0 ? '+' : '-')<<B<< (l == 0 ? '+' : '-')<<C<< (j == 0 ? '+' : '-') <<D<<'='<<7<< "\n";
                    fin = 1;
                }
                if(fin)break;
            }
            if(fin)break;
        }
        if(fin)break;
    }
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
 
#include <bits/stdc++.h> 
 
using namespace std;
 
#define len(x) (int)((x).size())
#define endl '\n'
#define x first
#define y second
#define int long long
#define double long double
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define vi vector<int> 
#define vvi vector<vector<int>>
#define pb push_back
#define pii pair<int, int>
#define beg begin
 
#ifdef LOCAL
    #define dbg(x) cout << #x << " = " << x << endl;
#else 
    #define dbg(x)
#endif 
 
void solve(); signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);                                       
    freopen("output.txt", "w", stdout);
#endif
    srand(time(0));
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(10);
    solve();    
}
 
const int INF = 1e18, MAXN = 1500 + 10, MOD = 1e9 + 7, CNT = 41;
int c[MAXN];
int ans = 0, n, k, part = 0;

void tr(int num) {
	for (int i = 0; i < CNT; ++i) {
		if ((num >> i) & 1) {
			c[i]++;
		}
	}
}

void upd(vi &b, vi &cost, int id) {
	int tmp = 0, p = 1;
	for (int i = 0; i < id; ++i) {
		p *= 2;
	}

	int cur = 0;
	for (int i = id; i >= 0; --i) {
		// if (b[i] == 0) {
		// 	cur += cost[i];
		// 	p /= 2;
		// 	continue;
		// }

		if (b[i] == 0) {
			cur += cost[i];
			p /= 2;
			continue;
		}

		if (p + tmp > k) {
			cur += p * c[i];
			p /= 2;
			continue;
		}

		int sum = 0;
		int tt = p;
		tt /= 2;
		for (int j = i - 1; j >= 0; --j) {
			sum += cost[j];
		}

		ans = max(ans, sum);

		tmp += p; cur += cost[i];
		ans = max(ans, cur);
		p /= 2;
	}

	ans = max(ans, cur);
}

void solve() {
	cin >> n >> k;

	int id = 0, t = 1; 
	while (t <= k) {
		t *= 2;
		id++;
	}
	id--;

	// for (int i = id + 1; i < CNT; ++i) {
	// 	c[i] = n;
	// }

	int summ = 0;
	for (int i = 0; i < n; ++i) {
		int num;
		cin >> num;
		summ += num;
		tr(num);
	}

	int pp = 1;
	for (int i = 0; i < id + 1; ++i) {
		pp *= 2;
	}
	for (int i = id + 1; i < CNT; ++i) {
		part += c[i] * pp;
		pp *= 2;
	}

	if (k == 0) {
		cout << summ << endl;
		return;
	}

	vi cost;
	int cur = 0, p = 1;
	for (int i = 0; i < CNT; ++i) {
		if (c[i] * 2 < n) {
			cur += p;
			cost.pb(p * (n - c[i]));
		}
		else {
			cost.pb(p * c[i]);
		}
		p *= 2;
	}

	// for (int i = 0; i <= id; ++i) {
	// 	cout << cost[i] << " ";
	// }
	// cout << endl;

	dbg(cur)

	vi b;
	for (int i = 0; i < CNT; ++i) {
		if ((cur >> i) & 1) {
			b.pb(1);
		}
		else {
			b.pb(0);
		}
	}	

	// for (int i = 0; i <= id; ++i) {
	// 	upd(b, cost, i);
	// }

	upd(b, cost, id);

	cout << part + ans << endl;
}


Measured memory_bytes: 256
//Date and time of submission: 
 
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=1e5+5;
ll n;
int main() {
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	cin>>n;
	cout<<"ABC"<<n;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
using ll = long long;
#define pi 3.1415926


int main(){
    string s;
    cin >> s;
    int br=0;
    sort(s.begin(), s.end());
    for(int i = 0; i < 4; i++){
        if(s[i] != s[i+1])
            br++;
    }
    if(br == 2)
        cout << "Yes";
    else    
        cout << "No";
}

    

	


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define deb(x) cout<< #x << " " << x << "\n";
#define INF 9223372036854775807
const ll mod=998244353;

 
int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    ll n;
    cin>>n;
    if(n%1000==0) cout<<0;
    else
        cout<<1000-n%1000;





    return 0;
}

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

int main() {
    int a;
    int b;
    int c;
    int escape = 0;
    cin >> a >> b >> c;
    
    if(a > b){
        escape = a;
        a = b;
        b = escape;
        escape = 0;
    }

    if(b > c){
        escape = b;
        b = c;
        c = escape;
    }

    if(a > b){
        escape = a;
        a = b;
        b = escape;
        escape = 0;
    }

    cout << a << " " << b << " " << c << endl;
}


Measured memory_bytes: 3100
N, L = gets.split.map(&:to_i)

a = Array.new(N)
b = Array.new(N)

(1..(N)).each do |i|
  a[i - 1] = L + i - 1
  b[i - 1] = (L + i - 1).abs
end

puts a.inject(&:+) - a[b.index(b.min)]


Measured memory_bytes: 1788
#include <vector>
#include <iostream>
using namespace std;
int main() {
	vector<double> vv;
	int n;
	cin >> n;
	while(n--) {
		int x;
		cin >> x;
		vv.push_back(x);
	}

	double s;
	for (auto v : vv) {
		s += 1 / v;
	}
	cout << 1 / s << endl;
}

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

using namespace std;
mt19937_64 rng(58);

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int n;
    cin >> n;
    string ans[10] = {
        "pon",
        "pon",
        "hon",
        "bon",
        "hon",
        "hon",
        "pon",
        "hon",
        "pon",
        "hon"
    };
    cout << ans[n % 10] << endl;
}

Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

long long pow(long long m, long long n);

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

	k = pow(m, n);

	cout << k << endl;

}

long long pow(long long m, long long n) {
	long long answer = 1;
	int r = 1000000007;
	while (n > 0) {
		if (n & 1) {
			answer *= m;
			answer %= r;
		}
		m *= m;
		m %= r;
		n >>= 1;
	}
	return answer;
}


Measured memory_bytes: 3096
package main

import "fmt"

func main() {
	var A, B, m, out int
	fmt.Scanf("%d %d", &A, &B)
	out = 0
	m = 1
	for m < B {
		out++
		if out == 1 {
			m = A
		} else {
			m = (A-1)*out + 1
		}
	}
	fmt.Println(out)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
double len(double, double, double, double);

int main() {
  double x, y, lx, ly, s = 0.0, sx, sy;
  char c;
  cin >> lx >> c >> ly;
  sx = lx;
  sy = ly;
  while(cin >> x >> c >> y) {
    double a = len(sy, sx, ly, lx);
    double b = len(sy, sx, y, x);
    double c = len(ly, lx, y, x);
    double z = (a + b + c) / 2.0;
    double bu = z * (z - a) * (z - b) * (z - c);
    s += pow(bu, 1.0 / 2.0);
    lx = x;
    ly = y;
  }
  cout << s << endl;
  return 0;
}

double len(double sy, double sx, double ey, double ex) {
  double y = ey - sy;
  double x = ex - sx;
  return pow(pow(y, 2) + pow(x, 2), 1.0 / 2.0);
}

Measured memory_bytes: 1344
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
#define PI  acos(-1)
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fi first
#define se second
#define pb push_back
#define re return
#define br break

//----***入出力***---
void print() { std::cout << "\n"; }
template <class T>void print(const T &x) {std::cout << x<<"\n";}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

signed main(){
  int H,W,K;cin>>H>>W>>K;
  int n_st=0;
  vector<string> G(H);
  REP(i,0,H)cin>>G[i];
  vector<int> existRow{0};
  vector<vector<int>> ans(H,vector<int>(W,0));
  REP(i,0,H){
    REP(j,0,W){
      if(G[i][j]=='#'){
        existRow.push_back(i+1);
        br;
      }
    }
  }
  existRow[existRow.size()-1]=H;

  REP(i,0,existRow.size()-1){
    int cake=0;
    n_st++;
    REP(j,0,W){
      REP(k,existRow[i],existRow[i+1]){
        // debug(ans);
        if(G[k][j]=='#'&&!cake){
          cake=1;
          ans[k][j]=n_st;
        }
        else if(G[k][j]=='#'&&cake){
          cake=0;
          n_st++;
          j--;
          br;
        }
        else{
          ans[k][j]=n_st;
        }
      }
    }
  }
  view(ans);

  
  
}


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

int main(){
  int n,m,x;
  cin>>n>>m>>x;
  vector<int> A(m);
  for(int i=0;i<m;i++) cin>>A[i];
  int c=0,i=0;
  while(x>A[i]){
    c++;
    i++;
  }
  cout<<min(c,m-c)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
#define ll long long int
int main()
{
	int t = 1;
//	cin>>t;
	
	while(t--)
	{
		int n;
		cin>>n;
		bool pos = true;
		int curr;
		REP(i,n)
		{
			cin>>curr;
			if(curr%2 ==0 && curr%3!=0 && curr%5!=0)
				pos = false;
		}
		if(pos)
			cout<<"APPROVED\n";
		else
			cout<<"DENIED\n";
	}
}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

int main(){
	cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
	ll a, b, c;cin >> a >> b >> c;
	cout << a + b + c - max({a, b, c}) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	int n = 0; string s, t; cin >> s >> t;
	if (s[0] == t[0]) {
		n++;
	}
	if (s[1] == t[1]) {
		n++;
	}
	if (s[2] == t[2]) {
		n++;
	}
	cout << n << endl;
	cin >> n;
}

Measured memory_bytes: 256
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define ALL(a) (a).begin(), (a).end()
string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";

/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}


int main(void){
  int N, A, B, W, H;
  cin >> N >> A;
  if (N%500<=A) cout <<"Yes" << endl;
  else cout <<"No" << endl;

}


Measured memory_bytes: 256
//Robs Code

/***********HEADER***************/
#include <iostream>
#include <bitset>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#include <list>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <iomanip>

/***********MACROS***************/
#define int long long int
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define pii pair<int,int>

using namespace std;

const int N = 1e5 + 1;
int n,m,i,j,k,l,x,y,z,cnt[3],sum[3];

/***********MAIN**************/
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	cin>>n>>m;
	cout<<(n*(n-1)/2 + m*(m-1)/2);
}
//.........

Measured memory_bytes: 256
# 整数の入力
N = int(input())
# 整数の入力
Mountain_list = map(int, input().split() )

Max_hight  = 0
Ocean_view = 0
## Ocean_flag = True

for i, Mountain in enumerate(Mountain_list):
	if i == 0:
		Ocean_view += 1
		Max_hight = Mountain
		continue

##	Ocean_flag = True

	if Max_hight <= Mountain:
		Max_hight = Mountain
		Ocean_view += 1

## 	for Comparison_mountain in Mountain_list[:i-1]:
## 		if Mountain < Comparison_mountain:
## 			Ocean_flag = False
## 			break:
	
##	if Ocean_flag:
##		Ocean_view += 1
##		Max_hight = Mountain

print(str(Ocean_view))

Measured memory_bytes: 3060
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
using namespace std;

typedef long long ll;

int main()
{
    int N,A,B;
    cin >> N >> A >> B;
    cout << min(N*A, B);

    


    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
using namespace std;
#define int long long
#define fr(i,n) for (int i = 0; i < n; i++)
#define fro(i,m,n) for (int i = m; i < n; i++)
#define pb push_back
#define iter ::iterator
#define fi first
#define se second


void io(){
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  #endif
}

void solve(){
  //io();
  int n,W;
  cin>>n>>W;
  int v[n],w[n];
  fr(i,n){
    cin>>w[i]>>v[i];
  }

  int dp[n+1][W+1];
  for(int i=0;i<=n;i++){
    for(int j=0;j<=W;j++){
      if(i==0||w==0){
        dp[i][j]=0;
        continue;
      }
      dp[i][j]=dp[i-1][j];
      if(w[i-1]<=j){
        dp[i][j]=max(dp[i][j],v[i-1]+dp[i-1][j-w[i-1]]);
      }
    }
  }
  std::cout << dp[n][W] << '\n';
}



int32_t main(){
  std::ios::sync_with_stdio(false);
  solve();
  return 0;
}


Measured memory_bytes: 82424
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

int n,k,v[60],ans;
vector <int> os;

int main()
{
	cin>>n>>k;
	rep(i,n) cin>>v[i];
	rep(i,n+1)
	{
		rep(j,n+1)
		{
			if(i+j>n||i+j>k) break;
			os.clear();
			int sum=0;
			rep(p,i) os.pb(v[p]),sum+=v[p];
			for(int p=n-1;p>=n-j;p--) os.pb(v[p]),sum+=v[p];
			sort(os.begin(),os.end());
			for(int p=0;p<os.size()&&p+1<=k-i-j&&os[p]<0;p++) sum-=os[p];
			ans=max(ans,sum);  
		}
	}
	cout<<ans<<endl;
	rt0;
}

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

int main(){

 int n;
 cin >> n;

 vector <vector<int> > arr;
    for(int i=1;i<=n;i++){
        vector<int> t;
        int num;
        cin >> num; t.push_back(num);
        cin >> num; t.push_back(num);
        cin >> num; t.push_back(num);
      arr.push_back(t);  
    }

    int dp[n][3];

    dp[0][0] = arr[0][0];
    dp[0][1] = arr[0][1];
    dp[0][2] = arr[0][2];

    for(int i=1;i<n;i++){
        dp[i][0] = arr[i][0] + max(dp[i-1][1],dp[i-1][2]);
        dp[i][1] = arr[i][1] + max(dp[i-1][0],dp[i-1][2]);
        dp[i][2] = arr[i][2] + max(dp[i-1][0],dp[i-1][1]);
    }
    cout << max(dp[n-1][0], max(dp[n-1][1],dp[n-1][2])) << endl;
  return 0;  
}

Measured memory_bytes: 9832
N,M = map(int,input().split(' '))

s = []
for i in [0]*M:
	s.append(list(map(int,input().split(' ')))[1:])

p = list(map(int,input().split(' ')))

bs = []
for t in s:
	rep = 0
	for i in t:
		rep += (1 << (i-1))
	bs.append(rep)

ans = 0
for i in range(0,2**N):
	f = True
	for j,cp in zip(bs,p):
		ch = i & j
		if (bin(ch).count("1") - cp) % 2:
			f = False
			break
	if f:
		ans += 1
print(ans)









Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
const int maxn=1e5+10;
const int maxm=110;
long long int dp[maxm][maxn];
int n;
int k;
int a[maxm];
int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
     cin>>n>>k;
     for(int i=1;i<=n;i++){
     	cin>>a[i];
	 }
	 dp[0][0]=1;
	 for(int i=1;i<=k;i++){
	 	dp[0][i]+=dp[0][i-1];
	 }
	 for(int i=1;i<=n;i++){
	 	for(int j=0;j<=k;j++){
	 		if(a[i]>=j){
	 			dp[i][j]=dp[i-1][j];
			 }
			 else{
	 		dp[i][j]=((dp[i-1][j]-dp[i-1][j-a[i]-1])+mod)%mod;
	 	}
	 	if(j>0&&i!=n){
	 	dp[i][j]+=dp[i][j-1];
	 dp[i][j]%=mod;
	 }
		 }

	 }
	 cout<<dp[n][k];
	 }

Measured memory_bytes: 80128
#include <stdio.h>
void insertionSort(int A[1000], int N);
void Print(int Ar[1000], int M);

int main(void)
{
    int n;
    scanf("%d", &n);
    int array[n];
    for(int i = 0; i < n; i++)
    {
        scanf("%d", &array[i]);
    }
    Print(array, n);
    insertionSort(array, n);
    return 0;
}

void Print(int Ar[1000], int M)
{
    for(int i = 0; i < M-1; i++)
    {
        printf("%d ", Ar[i]);
    }
    printf("%d", Ar[M-1]);
    printf("\n");
}

void insertionSort(int A[1000], int N)
{
    int v = 0;
    for(int j = 1; j < N; j++)
    {
        v = A[j];
        int k = j - 1;
        while(j >= 0 && A[k] > v)
        {
            A[k+1] = A[k];
            k--;
            A[k+1] = v;
        }
        Print(A, N);
    }
}


Measured memory_bytes: 2140
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif 
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
//typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};



int n,t;

int ans;
P ab[3333];
int dp[3333][3333];
signed main(){
    
    cin>>n>>t;
    rep(i,n){
        int a,b;
        cin>>a>>b;
        ab[i]={a,b};
    }
    sort(ab,ab+n);
    rep(i,n){
        rep(j,t){
            if(j+ab[i].first<t){
                dp[i+1][j+ab[i].first]=max(dp[i][j]+ab[i].second,dp[i+1][j+ab[i].first]);
            }
            dp[i+1][j]=max(dp[i][j],dp[i+1][j]);
        }
    }
    rep(i,n)rep(j,t)ans=max(ans,dp[i][j]+ab[i].second);
    cout<<ans<<endl;
}

Measured memory_bytes: 80128
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

const int MAX_N = 200000;
ll n, t;
ll a[MAX_N];

int main() {
    fastio();

    cin >> n >> t;
    forn(i, n) cin >> a[i];

    ll ans = 0;
    forn(i, n - 1) {
        ans += min(t, a[i + 1] - a[i]);
    }
    ans += t;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
///Bismillahir Rahmanir Rahim
#define ll long long
#define scf1(a)  scanf("%lld",&a);
#define scf2(a,b)  scanf("%lld %lld",&a,&b)
#define pf    printf
#define pb    push_back
#define rsrt(v) reverse(v.begin(),v.end())
#define srt(v) sort(v.begin(),v.end())
#define ff first
#define ss second
#define spd ios_base::sync_with_stdio(false)
#include<bits/stdc++.h>
using namespace std;
ll mark[200];
int main()
{
     ll a,b,i,j;

  for(i=1;i<=9;i++)
  {
      for(j=1;j<=9;j++)
      {
          mark[i*j]=1;
      }
  }
    cin>>a;
   if(mark[a])
      cout<<"Yes"<<endl;
   else
    cout<<"No"<<endl;

}


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

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vpii;

ll INF = (1ll << 32);
double EPS = 1e-4;

int f(ll n) {
  for (ll i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      return 0;
    }
  }
  return 1;
}

int main() {
  vi v1(100001);
  for (ll i = 3; i <= 100000; i += 2) {
    if (f(i) && f((i + 1) / 2)) {
      v1[i] = 1;
    }
  }

  vi v2(100001);
  for (ll i = 1; i <= 100000; i++) {
    v2[i] = v2[i - 1] + v1[i];
  }

  ll Q;
  cin >> Q;
  for (ll i = 0; i < Q; i++) {
    ll l, r;
    cin >> l >> r;
    cout << v2[r] - v2[l - 1] << endl;
  }
}

Measured memory_bytes: 2176
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <map>
#include <vector>
#include <stack>
#include <queue>

using namespace std;

#define inf                  1e9   // this is double value
#define ms(a,b)              memset(a,b,sizeof a)
#define CLR(a)               memset(a,0,sizeof a)
#define input_file           freopen("in.txt","r",stdin)
#define output_file          freopen("out.txt","w",stdout)
#define N                    100000008
#define LL                   long long
#define nl                   printf("\n")
#define spc                  printf(" ")
#define isValid(x,y,dx,dy)   ((0<=dx&&dx<x) && (0<=dy&&dy<y)) 

int main()
{
	int n,k,i,arr[100005],sum;
	while(cin>>n>>k)
	{
		for(i=0; i<n; i++)
		{
			cin>>arr[i];
		}
		sort(arr,arr+n);
		i=n-1;
		sum=0;
		while(k--)
		{
			sum+=arr[i--];
		}
		cout<<sum<<endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

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

    vector<int> s(m), c(m);
    REP(i, m) cin >> s[i] >> c[i];

    REP(i, 1000) {
        int x = i / 10;
        vector<int> d(1, i % 10);
        while (x) {
            d.push_back(x % 10);
            x /= 10;
        }
        reverse(d.begin(), d.end());
        if (d.size() != n) continue ;

        bool ok = true;
        REP(i, m) if (d[s[i] - 1] != c[i]) ok = false;
        if (ok) {
            cout << i << '\n';
            return 0;
        }
    }

    cout << -1 << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii; // (cst, to)
const int INF = 100000000;
const int MAX_V = 10010;

int V;
vector<pii> G[MAX_V];
bool used[MAX_V];

int prim() {
    priority_queue<pii, vector<pii>, greater<pii> > que;
    memset(used, 0, sizeof(used));
    que.push(pii(0,0));
    int ret = 0;
    while(!que.empty()) {
        int cst = que.top().first, v = que.top().second;
        que.pop();
        if(used[v]) continue;
        used[v] = 1;
        ret += cst;
        for(int i = 0; i < G[v].size(); i++)
            que.push(pii(G[v][i].first, G[v][i].second));
    }
    return ret;
}

int main(){
    int E;
    cin >> V >> E;

    for(int i = 0;i < E;i++){
        int a,b,c;
        cin >> a >> b >> c;
        G[a].push_back(make_pair(c,b));
        G[b].push_back(make_pair(c,a));
    }

    cout << prim() << endl;



}


Measured memory_bytes: 7880
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;

int n, tab[100010], ans;
int main()
{
	ios_base::sync_with_stdio( 0 );
	cin.tie( 0 );
	cin>>n;
	for( int a = 1; a <= n; a++ )
	{
		cin>>tab[a];	
	}
	for( int a = 1; a <= n; a++ )
	{
		if( tab[a] == a )
		{
			if( a == 1 )
			{
				swap( tab[a], tab[a+1] );
				ans++;	
			}
			else if( a == n )
			{
				swap( tab[a], tab[a-1] );
				ans++;
			}
			else
			{
				if( tab[a+1] == a+1 )swap( tab[a], tab[a+1] ), ans++;
				else swap( tab[a], tab[a-1] ), ans++;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}	

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

int main() {
  int N;
  cin >> N;
  bool flg = false;
  for(int i = 1;i <= 9;i++) {
    for(int j = 1;j <= 9;j++) {
      if(i * j == N) {
        flg = true;
      }
    }
  }
  if(flg) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3608
use std::str::FromStr;
use std::fmt::Debug;
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}


fn get_num(table: &Vec<u32>, n: u32) -> usize{
    (*table).iter().filter(|x| **x > n-2).collect::<Vec<&u32>>().len()
}

fn main(){
    let n: u32 = read_as_vec()[0];

    let mut table = vec![0;(n+1) as usize];

    
    for i in 2..n+1{
        let mut target = i;
        for j in 2..i+1{
            while target % j == 0{
                target /= j;
                table[j as usize] += 1;
            }
        }
    }
    
    let ans = get_num(&table, 75)
        + get_num(&table, 15) * (get_num(&table, 5) -1)
        + get_num(&table, 25) * (get_num(&table, 3) -1)
        + get_num(&table, 5) * (get_num(&table, 5) -1)* (get_num(&table, 3)-2)/2;
    println!("{}", ans);
        
}


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

int main(){
    int n;
    cin >> n;
    if(n >= 1000){
        cout << "ABD" << endl;
    }else if(n < 1000){
        cout << "ABC" << endl;
    }
}
  

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <list>
#include <cstdint>
#include <bits/stdc++.h>
#include <queue>
#include <set>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for (int i = n - 1; i >= 0; i--)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

#define INF bit(60)
#define pb push_back
#define mod 1000000007

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;
}

using namespace std;
using uif = uint_fast64_t;
using ll = long long int;

int qp(int a, ll b)
{
  int ans = 1;
  do
  {
    if (b & 1)
      ans = 1ll * ans * a % mod;
    a = 1ll * a * a % mod;
  } while (b >>= 1);
  return ans;
}
int qp(int a, ll b, int mo)
{
  int ans = 1;
  do
  {
    if (b & 1)
      ans = 1ll * ans * a % mo;
    a = 1ll * a * a % mo;
  } while (b >>= 1);
  return ans;
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

#define FACSIZE 200002

ll invfac[FACSIZE];
ll fac[FACSIZE];

ll mod_pow(ll, ll);
ll mod_add(ll, ll);
ll mod_mul(ll, ll);
ll mod_div(ll, ll);
void make_fact(ll);
void make_invfact(ll);

int main(void)
{

  ll n, m, k;
  cin >> n >> m >> k;

  make_fact(200003);
  make_invfact(200002);

  ll ans = 0;
  ll comb = mod_mul(fac[n * m - 2], mod_mul(invfac[k - 2], invfac[(n * m - 2) - (k - 2)]));

  for (ll d = 1; d < n; d++)
  {

    ll tmp = 0;
    tmp = mod_mul(d, comb);
    tmp = mod_mul(tmp, n - d);
    tmp = mod_mul(tmp, m);
    tmp = mod_mul(tmp, m);

    ans = mod_add(ans, tmp);
  }
  for (ll d = 1; d < m; d++)
  {

    ll tmp = 0;
    tmp = mod_mul(d, comb);
    tmp = mod_mul(tmp, m - d);
    tmp = mod_mul(tmp, n);
    tmp = mod_mul(tmp, n);

    ans = mod_add(ans, tmp);
  }

  cout << ans << endl;

  return 0;
}

ll mod_pow(ll x, ll r)
{
  if (r == 0)
    return 1;
  else if (r == 1)
    return x % mod;
  else if (r % 2 == 0)
  {
    ll t = mod_pow(x, r / 2) % mod;
    return t * t % mod;
  }
  else
  {
    ll t = mod_pow(x, r / 2) % mod;
    ll k = t * t % mod;
    return k * x % mod;
  }
}
ll mod_add(ll a, ll b)
{
  return (a + b) % mod;
}

ll mod_mul(ll a, ll b)
{
  return (a * b) % mod;
}

ll mod_div(ll a, ll b)
{
  return mod_mul(a, mod_pow(b, mod - 2));
}

void make_fact(ll n)
{
  fac[0] = 1;
  rep(i, n)
  {
    fac[i + 1] = mod_mul(fac[i], i + 1);
  }
}

void make_invfact(ll n)
{
  invfac[n] = mod_pow(fac[n], mod - 2);
  for (int i = n - 1; i >= 0; i--)
  {
    invfac[i] = mod_mul(invfac[i + 1], i + 1);
  }
}


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

int main(){
    ll N;cin>>N;
    ll ans=1e13;
    for(ll i=1;i<=sqrt(N);i++){
        if(N%i==0){
            ll p=i,q=N/i;
            ans=min(ans,p+q-2);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using o_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define M 1000010


int main(){
	IOS;
	
	ll n;cin>>n;
	ld ans = (ld)n/(ld)(3.00);
	ans=(ans*(ans*ans));
	cout<<setprecision(10)<<ans;
	return 0;
}



Measured memory_bytes: 256
#[allow(unused_imports)]
use proconio::{fastout, input, marker::*};

#[fastout]
fn main() {
    input! {
        n: usize,
        k: usize,
    }
    let mut ans = 0f64;

    for i in 1..n+1 {
        let mut point = i;
        let mut cnt = 0;
        while point < k {
            point *= 2;
            cnt += 1;
        }
        ans += (1f64 / (n as f64)) * (1f64 / 2f64).powf(cnt as f64);
    }

    println!("{:.9}", ans);
}


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

using namespace std;

typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli>> mat;
typedef vector<unordered_map<lli,lli>> graph;

lli k;
lli n;
vll a;

int main(){
  cin >> k;
  n = 50;
  a = vll(n);
  for(lli i = 0;i < n;i++) a[i] = i;
  for(lli i = 0;i < n;i++){
    a[i] += k/n;
  }
  k %= n;
  for(lli i = 0;k > 0;k--,i++){
    a[i] += n;
    for(lli j = 0;j < n;j++){
      if(j != i) a[j]--;
    }
  }
  cout << n << endl;
  for(lli i = 0;i < n-1;i++){
    cout << a[i] << " ";
  }
  cout << a[n-1] << endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
   using ll = long long;
   using namespace std;

   void solve() {
      int n;
      cin >> n;
      ll ans = 0, x;
      for(int i = 0; i < n; i++) {
         cin >> x;
         ans += x - 1;
      }
      cout << ans << endl;
   }

   int main() {
      cin.tie(0);
      cin.sync_with_stdio(0);
      int testcase = 1;
      // cin >> testcase;
   
      for(int i = 0; i < testcase; i++) {
         solve();
      } 
      return 0;
   }


Measured memory_bytes: 3640
from sys import stdin
import math
def input():
	return stdin.readline()[:-1]

def intput():
	return int(input().rstrip())

def sinput():
	return input().rstrip().split()

def intsput():
	return map(int, sinput())

def main():
	wt = [0]*120
	pref = [0]*120
	n = intput()
	ls = list(intsput())
	for i in range(0, n):
		wt[i+1] = ls[i]
		pref[i+1] = pref[i] + ls[i]
	mdf = 1e10
	for i in range(1, n+1):
		a = pref[i]
		b = pref[n]-pref[i]
		mdf = min(mdf, abs(a-b))
	print(mdf)


if __name__ == '__main__':
	main()

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

int main() {
  while (true) {
    int n, k, m;
    cin >> n >> k >> m;
    if (n == 0 && k == 0 && m == 0) break;
    vector <int> stones;
    for (int i = 1; i <= n; i++) stones.push_back(i);
    int p = m-1;
    while (stones.size() >= 2) {
      stones.erase(stones.begin()+(p=(p%stones.size())));
      p += k-1;
    }
    cout << stones[0] << endl;
  }
}

Measured memory_bytes: 1324