akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int main() {
  string s;
  int n, q, ans = 0;;
  cin >> n >> q >> s;
  vector<int> l(q), r(q), c(n, 0);
  for(int i = 0; i < q; i++) {
    cin >> l.at(i) >> r.at(i);
  }
  for(int i = 1; i < n; i++) {
    if(s[i] == 'C' && s[i-1] == 'A') ans++;
    c.at(i) = ans;
  }
  for(int i = 0; i < q; i++) {
    cout << c.at(r.at(i)-1) - c.at(l.at(i)-1) << endl;
  }
}

Measured memory_bytes: 2176
fn solve() {
    let (n, m): (usize, usize) = (read::<usize>(), read::<usize>());
    let mut x: Vec<i64> = vec![];
    for i in 0..m {
        x.push(read());
    }
    x.sort();
    let mut int = vec![0; m - 1];
    //n-1個の区間を無視できる
    for i in 1..m {
        int[i - 1] = x[i] - x[i - 1];
    }
    int.sort();
    if n >= m {
        println!("{}", 0);
    } else {
        let mut res = 0;
        for i in 0..m - n {
            res += int[i];
        }
        println!("{}", res);
    }
}

fn main() {
    let stack_size = 104_857_600;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min, Reverse};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========


Measured memory_bytes: 2936
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    long x;
    cin >> x;
    long ans=0;
    ans = (x/11)*2;
    long r = x%11;
    if(r>6){
        ans+=2;
    }else if(r==0){
        ans;
    }else{
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = input()
b = input()
c = input()
ans = 0

for i in range(n):
    x = a[i]
    y = b[i]
    z = c[i]

    if x == y == z:
        continue
    elif x != y and y != z and z != x:
        ans += 2
    else:
        ans += 1

print(ans)

Measured memory_bytes: 3060
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}

#define int ll
void solve(){
	while (true) {
		string s;
		cin >> s;
		if (s == "#") return;
		if (s.length() == 1) {
			cout << 0 << endl;
			continue;
		}
		int cnt[10] = { 0,0,1,2,0,1,2,0,1,2 };
		int ans = 1000000;
		REP(teas, 2) {
			pair<int, int> now = mp(s[0] - '0', s[1] - '0');
			swap(s[0], s[1]);
			if (cnt[now.first] > cnt[now.second]) continue;
			int atcoder = teas;
			for (int t = 2; t < s.length(); ++t) {
				if (atcoder % 2 == 0) {
					if (cnt[s[t] - '0'] <= cnt[now.second]) {
						now.first = s[t] - '0';
						atcoder++;
					}
					else {
						now.second = s[t] - '0';
					}
				}
				else {
					if (cnt[now.first] <= cnt[s[t] - '0']) {
						now.second = s[t] - '0';
						atcoder++;
					}
					else {
						now.first = s[t] - '0';
					}
				}
			}
			ans = min(ans, (long long)s.length() - 2LL - atcoder + teas);
		}
		cout << ans << endl;
	}
}

#undef int
int main() {
	init();
	solve();
}


Measured memory_bytes: 3216
package main

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

func main() {
	n := 0
	k := int64(0)
	fmt.Scan(&n, &k)
	a := make([]int, n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := 0; i < n; i++ {
		sc.Scan()
		a[i], _ = strconv.Atoi(sc.Text())
		a[i]--
	}
	visited := make([]int, n)
	for i := range visited {
		visited[i] = -1
	}
	step := 0
	cycle := 0
	p := 0
	for i := 0; i <= n; i++ {
		if visited[p] != -1 {
			cycle = i
			break
		}
		visited[p] = i
		p = a[p]
	}
	step = visited[p]
	cycle -= step
	p = 0
	if k <= int64(step) {
		for i := int64(0); i < k; i++ {
			p = a[p]
		}
	} else {
		for i := 0; i < step; i++ {
			p = a[p]
		}
		k = (k - int64(step)) % int64(cycle)
		for i := int64(0); i < k; i++ {
			p = a[p]
		}
	}
	fmt.Println(p + 1)
}


Measured memory_bytes: 6528
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
using i=int;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

typedef vector<vector<ll> > mat;
int sz=3;
mat mul(mat A,mat B){
   mat C(sz,vector<ll>(sz));
   rep(i,sz)rep(j,sz)rep(k,sz)C[i][j]=(C[i][j]+A[i][k]*B[k][j])%mod;
   return C;
}

vector<ll> mul(mat A,vector<ll> x){
    vector<ll> ret(sz);
    rep(i,sz)rep(j,sz)(ret[i]+=A[i][j]*x[j])%=mod;
    return ret;
}

mat A[30];


vector<ll> calc(ll n,vector<ll> x){
    vector<ll> ret=x;
    rep(i,30){
        if(n&(1<<i))ret=mul(A[i],ret);
    }
    return ret;
}

vector<ll> add(vector<ll> x,vector<ll> y){
    vector<ll> ret(sz);
    rep(i,sz)ret[i]=(x[i]+y[i])%mod;
    return ret;
}


int main(){
    int n,m;
    cin>>n>>m;
    vector<ll> vec1[m+2],vec2[m+2];
    ll dp[m+2];
    dp[0]=0;
    ll a[m+2];
    rep(i,m)cin>>a[i+1];
    A[0]={{4,mod-2,1},{1,0,0},{0,1,0}};
    rep(i,30)A[i+1]=mul(A[i],A[i]);
    a[0]=0;
    a[m+1]=n;
    vec1[0]={0,0,0};
    vec2[0]={5,1,0};
    rep(i,m+1){
        vec1[i+1]=calc(a[i+1]-a[i],vec1[i]);
        vec2[i+1]=calc(a[i+1]-a[i],vec2[i]);
        dp[i+1]=(mod+vec2[i+1][2]-vec1[i+1][2])%mod;
        vec1[i+1]=add(vec1[i+1],{5*dp[i+1],dp[i+1],0});
    }
    cout<<dp[m+1]<<endl;
}

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

#define ll long long
#define mod 1000000007
#define pll pair<long long,long long>
#define pdd pair<long double,long double>
#define vll vector<ll>
#define rep(i,j,n) for(int i=j;i<n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
#define inf 1e17
#define N 100010
priority_queue<pll,vector<pll>,greater<pll> >pq;
priority_queue<ll,vector<ll>,greater<ll> >pq1;

ll result(ll a, ll b, ll p){
    ll ans=1;
    if(b==(-1))
        b=p-2;
    while(b){
        if(b&1){
            ans=(ans*a)%p;
        }
        a=(a*a)%p;
        b>>=1;
    }
    return ans;
}

ll T = 1,n,m,k;

int main(){
    if(fopen("input.txt", "r"))
    freopen("input.txt", "r", stdin),
    freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    char p;
    cin >> p;
    char d='Z';
    // cout << d+1;
    if(p>=65 && p<=90){
        cout << 'A';
    }
    else
        cout << 'a';

    return 0;
}


Measured memory_bytes: 3640
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
using namespace std;

long double dp[123][123];
int main(void)
{
	int n, t, l, b;
	cout.precision(15);
	cout << fixed;
	for (;;)
	{
		cin >> n >> t >> l >> b;
		if (!n)break;
		vector<int>cell(n + 1);
		for (int i = 0; i < l; ++i)
		{
			int ll; cin >> ll; cell[ll] = 1;//lose
		}
		for (int j = 0; j < b; ++j)
		{
			int bb; cin >> bb; cell[bb] = 2;//back
		}
		memset(dp, 0, sizeof(dp));
		dp[0][0] = 1.;
		long double ans = 0.;
		for (int i = 0; i <= t; ++i)
		{
			for (int j = 0; j <= n; ++j)
			{
				if (cell[j] == 2)
				{
					dp[i][0] += dp[i][j];
					dp[i][j] = 0.;
				}
				ans += dp[i][n];
				dp[i][n] = 0.;
			}
			for (int j = 0; j <= n; ++j)
			{
				if (cell[j] == 2)continue;
				int dif = 1;
				if (cell[j] == 1)dif = 2;
				for (int dic = 1; dic <= 6; ++dic)
				{
					int nxt = j + dic;
					if (nxt > n)
					{
						nxt = n + n - nxt;
					}
					dp[i + dif][nxt] += dp[i][j] / 6.;
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

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

using namespace std;

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

    vector<int> h(n),dp(n);
    for(int i=0; i<n; i++){
        cin>>h[i];
        dp[i]=1e9;
    }

    dp[0]=0;
    for(int i=0; i<n-1; i++){
        for(int j=1; j<=k; j++){
            if(i+j>n){
                break;
            }
            dp[i+j]=min(dp[i+j],abs(h[i]-h[i+j])+dp[i]);
        }
    }

    cout<<dp[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>

using namespace std;

bool sosu(int n){
	if(n == 1) return true;
	if(n == 1) return true;
	if(n%2 == 0) return false;
	for(int i=3;i<=sqrt(n);i+=2){
		if(n % i == 0) return false;
	}
	
	return true;
}

int main(){
	int n;
	while(cin >> n, n){
		int count = 0;
		for(int i=(n%2==0?n+1:n+2);i<=2*n;i+=2){
			if(sosu(i)) count++;
		}
		if(n == 1) count = 1;
		cout << count << endl;
	}

	return 0;
}

Measured memory_bytes: 3084
#include <stdio.h>
int main(){
    int n, i, j, sum, no;
    int a = 0;
    scanf("%d", &n);
    int x[n];
    for(i = 0; i < n; i++){
        scanf("%d", &x[i]);
    }
    for(i = 0; i < n - 1; i++){
        a = a + x[i];
    }
    int min = 0;
    if(x[n - 1] > a){
        min = x[n - 1] - a;
    }else{
        min = a - x[n - 1];
    }
    int t = n - 2;
    while(1){
        int sum1 = 0, sum2 = 0;
        for(i = 0; i <= t; i++){
            sum1 = sum1 + x[i];
        }
        for(i = t + 1; i < n; i++){
            sum2 = sum2 + x[i];
        }
        if(sum1 > sum2){
            no = sum1 - sum2;
        }else{
            no = sum2 - sum1;
        }
        if(min >= no){
            min = no;
        }else{
            break;
        }
        t--;
    }
    printf("%d", min);

    return 0;
}

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

void solve(std::string b)
{
    if (b == "A")
        puts("T");
    else if (b == "T")
        puts("A");
    else if (b == "G")
        puts("C");
    else
        puts("G");
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    std::string b;
    std::cin >> b;
    solve(b);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  string a;
  cin >> a;
  
  
  if (a[0] == a[1] && a[1] == a[2]) {
     cout << "Yes" << endl;
  } else if (a[3] == a[1] && a[1] == a[2]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 256
a = []
count = []
n = gets.chomp.to_i
d,x = gets.chomp.split(" ").map{|x| x.to_i}
for i in 0..n-1 do
  a[i] = gets.chomp.to_i
  count[i] = 1 + (d-1)/a[i]
end

print "#{x + count.inject(:+)}\n"

Measured memory_bytes: 1788
#include <bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>
    #include <ext/pb_ds/detail/standard_policies.hpp>
 
    using namespace std;
    using namespace __gnu_pbds;
 
    #define endl "\n"
    #define fi first
    #define se second
    #define pb push_back
    #define int long long 
    #define ll long long
    #define ld long double
    #define pii pair<ll,ll>
 
    #define read(t) ll t;cin>>t;
    #define all(x) x.begin(),x.end()
    #define f(a,b,c) for(ll a=b;a<c;a++)
    #define For(i,n) for(ll i=0;i<n;i++)
 
    #define what(x) cerr << #x << " is " << x << endl;
    #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) ;
 
    typedef tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> omultiset;
    typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> oset;
    typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> oset1;
 
/*.....................................................................................................................*/
 
    const ll mod=(ll)1e9+ 7;
 
    ll add(ll x,ll y) {return (x+y)%mod;}
    ll mult(ll x, ll y){return ((x%mod )* (y%mod)) % mod;}
 
    long long binpow(long long x, long long p) 
    {
        if (p == 0) {return 1;} 
    	if (p == 2 || (p & 1)) {return mult(x, binpow(x, p - 1));}
    	return binpow(binpow(x, p / 2), 2);
    }
    ll modinv(ll a) {return binpow(a,mod-2);}
 
    //A.erase(unique(A.begin(),A.end()),A.end());
    double pi=3.141592653589793238462641;
    ll dx[4]={1,-1,0,0},dy[4]={0,0,1,-1};
    const ll  man  =   (int)200005   ,  inf   =   1e18;
 
 
/*......................................................................................................................*/



signed main()
{
    fast;
    int n,W;
    cin>>n>>W;
    vector<int>w(n+1),v(n+1);
    for(int i=1;i<=n;i++)
    {
        cin>>w[i]>>v[i];
    }
    vector<vector<int>>dp(n+1,vector<int>(W+1,0));
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=W;j++)
        {
            int in =0;
            if(j-w[i]>=0)
            {
                in=dp[i-1][j-w[i]]+v[i];
            }
            dp[i][j]=max(dp[i-1][j],in);
        }
    }
    cout<<dp[n][W]<<endl;
}   

Measured memory_bytes: 83168
#include <iostream>
#include <vector>
#include <iomanip>
#include <stack>
#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iterator>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <time.h>
#include <complex>
#include <cmath>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n;i>0;i--)
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define SORT(v) sort((v).begin(),(v).end())
#define TEMP(type,x,y) do {temp temp=x,x=y,y=temp}while(0)
const ll INF = (1LL << 50);

/*

274 % 13
4 % 13 = 4
70 % 13 = 5
200 % 13 = 5
*/

int main() {

	string s;
	cin >> s;

	const int N = 13;

	/*
		後ろから解くアルゴリズム
		1?2?3 -> 0 -> 3 -> ?3 -> 2?3 -> ?2?3 -> 1?2?3

	*/

	vector<ll> dp(N);

	int mul = 1;//桁を保持
	ll const mod = 1'000'000'007;
	dp[0] = 1;

	for (int i = s.length() - 1; i >= 0; i--) {
		char c = s[i];

		vector<ll> nextDP(N);

		if (c == '?') {
			for (int k = 0; k < 10; k++) {//1~9を試す
				for (int j = 0; j < N; j++) {
					nextDP[(k * mul + j) % N] += dp[j];
					nextDP[(k * mul + j) % N] %= mod;
				}
			}

		}
		else {
			int k = (int)(s[i] - '0');//文字を数字に変換
			for (int j = 0; j < N; j++) {
				nextDP[(k * mul + j) % N] += dp[j];
				nextDP[(k * mul + j) % N] %= mod;
			}
		}

		mul *= 10;//次の桁を調べる
		mul %= N;

		dp = nextDP;//更新

	}

	cout << dp[5] << endl;

	return 0;

}

Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

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

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int n=0;
        int k=0;
        int x=0;
        int y=0;
        
        
        String str = in.readLine();
        n=Integer.parseInt(str);
 
        str = in.readLine();
        k=Integer.parseInt(str);
  
        str = in.readLine();
        x=Integer.parseInt(str);        

        str = in.readLine();
        y=Integer.parseInt(str);

        
        int anser = 0;
        
        for(int i=1;i<n+1;i++){
            if(i > k){
                anser += y;
            }else{
                anser += x;
            }
        }
        
        System.out.println(anser);
    }
}

Measured memory_bytes: 7892
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
 
using namespace std;
 
#define MAX 15
#define INF 1e9
 
struct Point{
    double x,y;
    Point(){}
    Point(double x,double y) : x(x), y(y) {}
};
 
struct Segment{
    Point s,t;
    Segment(){}
    Segment(Point s,Point t) : s(s), t(t) {}
};
 
int N;
double dp[1<<MAX][MAX][2];
Segment Seg[MAX];
double d[MAX];
 
double getDistance(Point &p1,Point &p2){
    return sqrt(pow(p1.x-p2.x,2)+pow(p1.y-p2.y,2));
}
 
double solve(int S,int now,bool st){
    if((1<<N)-1 == S){
	if(st){
	    return dp[S][now][st] = d[now];
	}else{
	    return dp[S][now][st] = d[now];
	}
    }
    if(dp[S][now][st] != INF){
	return dp[S][now][st];
    }
    double res = INF;
    for(int i = 0 ; i < N ; i++){
	if(S >> i & 1) continue;
	if(st){
	    res = min(res,solve(S|(1<<i),i,true) + d[now] + getDistance(Seg[now].t,Seg[i].s));
	    res = min(res,solve(S|(1<<i),i,false) + d[now] + getDistance(Seg[now].t,Seg[i].t));     
	}else{
	    res = min(res,solve(S|(1<<i),i,true) + d[now] + getDistance(Seg[now].s,Seg[i].s));
	    res = min(res,solve(S|(1<<i),i,false) + d[now] + getDistance(Seg[now].s,Seg[i].t));   
	}
    }
    return dp[S][now][st] = res;
}
 
int main(){
    int Tc = 1;
    while(cin >> N, N){
	for(int i = 0 ; i < N ; i++){
	    cin >> Seg[i].s.x >> Seg[i].s.y >> Seg[i].t.x >> Seg[i].t.y;
	    d[i] = getDistance(Seg[i].s,Seg[i].t);
	}
	for(int i = 0 ; i < (1<<MAX) ; i++){
	    for(int j = 0 ; j < MAX ; j++){
		for(int k = 0 ; k < 2 ; k++){
		    dp[i][j][k] = INF;
		}
	    }
	}
	double res = INF;
	for(int i = 0 ; i < N ; i++){
	    res = min(res,solve(1<<i,i,true));
	    res = min(res,solve(1<<i,i,false));
	}
	printf("Case %d: %.5f\n",Tc++,res);
    }
    return 0;
}

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

// 1s = 10 ^ 8 loop

int main() {
  string n;
  cin >> n;
  for (char c : n) {
    switch (c) {
      case '1':
        cout << 9;
        break;
      case '9':
        cout << 1;
        break;
      default:
        break;
    }
  }
  cout << endl;
}


Measured memory_bytes: 256
/* {{{ Shinobu kawaii */
/*
  ______   __        _                  __                 
.' ____ \ [  |      (_)                [  |                
| (___ \_| | |--.   __   _ .--.   .--.  | |.--.   __   _   
 _.____`.  | .-. | [  | [ `.-. |/ .'`\ \| '/'`\ \[  | | |  
| \____) | | | | |  | |  | | | || \__. ||  \__/ | | \_/ |, 
 \______.'[___]|__][___][___||__]'.__.'[__;.__.'  '.__.'_/ 

*/
/* }}} */

#include <bits/stdc++.h>
using namespace std;

// #define int long long

/* cpp template {{{ */

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()

/* REPmacro */
#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

/* typedef */
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;
typedef double D;
typedef pair<D, D> P;

/* const */
const int INF = 999999999;
const double EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; std::cin >> x; return x;}
template <typename T>
void print(std::vector<T>& v, char c = ' ') {
  REP(i, v.size()) {
    if (i != 0) std::cout << c;
    std::cout << v[i];
  }
  std::cout << '\n';
}
template <typename T>
void print(T x) {
  std::cout << x << '\n';
}

/* }}} */
#define X Fi
#define Y Se
#define sq(x) (x) * (x)

P input() {
  D x, y;
  char c;
  cin >> x >> c >> y;
  return mp(x, y);
}

D area(D a, D b, D c) {
  D z = (a + b + c) / 2;
  return sqrt(z * (z - a) * (z - b) * (z - c));
}

D len(P a, P b) {
  return sqrt(sq(a.X - b.X) + sq(a.Y - b.Y));
}

signed main()
{
  //cin.tie(0);
  //ios::sync_with_stdio(false);
  vector<P> v;
  
  while (v.pb(input()), !cin.eof());
  D s = 0.0;
  REP(i, v.size()) {
    if (i < 2) continue;
    D a = len(v[0], v[i]),
      b = len(v[0], v[i - 1]),
      c = len(v[i], v[i - 1]);
    s += area(a, b, c);
  }
  cout << setprecision(10);
  print(s);

  return 0;
}

Measured memory_bytes: 1292
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

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

	long long ans = 0;
	for (int i = 0; i < N; i++)
	{
		int a;
		cin >> a;

		ans += a - 1;
	}

	cout << ans << endl;

	return 0;
}

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

int main(){
    int m, f, r;
    vector<char> grade;

    while (true)
    {
        
        cin >> m >> f >> r;
        if(m==-1 && f==-1 && r==-1) break;
        else if(m == -1 || f == -1) grade.push_back('F');
        else if (m+f >= 80)
        {
            grade.push_back('A');
        }
        else if (m+f >= 65)
        {
            grade.push_back('B');
        }
        else if (m+f >= 50)
        {
            grade.push_back('C');
        }
        else if (m+f >= 30)
        {
            if (r >= 50)
            {
                grade.push_back('C');
            }
            else
            {
                grade.push_back('D');
            }
            
        }
        else
        {
            grade.push_back('F');
        }
    }
    
     for (int i = 0; i < grade.size(); i++)
        {
            cout << grade.at(i) << endl;
        }
}


Measured memory_bytes: 3152
/*@author Vipen Loka*/
#include <bits/stdc++.h>
#define endl '\n'
#define ff first
#define ss second
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define deb(x) cout << #x << ':' << x << '\n';

using namespace std;

void solve(){
	int i,j;
	int n;
	cin >> n;
	if(n<3){
		puts("0");
		return;
	}
	vector<int> dp(n+1,0);
	dp[3]=1;
	dp[4]=1;
	dp[5]=1;

	for (int i = 6; i < n+1; ++i)
	{
		for (int j = 3; j < i-2; ++j)
		{
			dp[i]+=dp[j];
			dp[i]%=mod;
		}
		dp[i]++;
	}

	printf("%d\n",dp[n]);
}


int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(0);
    
	int T=1;
	// cin >> T;
	while (T--){
		solve();
	}
}


Measured memory_bytes: 3676
import java.util.Scanner;

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

        char[] S = scanner.next().toCharArray();
        if (S[2] == S[3] && S[4] == S[5]) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
   }
}


Measured memory_bytes: 21716
//
//  main.cpp
//
 
#include <algorithm>
#include <array>
#include <assert.h>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
using namespace std;
 
using ll = long long;
using ull = unsigned long long;
 
template<typename T>
vector<T> make_vec_nd(T init, size_t size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, size_t size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

#define rep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,a,b) for(ll i=(a)-1;i>=(b);i--)

int main() {
	ll ai, ao, at, aj, al, as, az;
	cin >> ai >> ao >> at >> aj >> al >> as >> az;
	ll ans = 0;
	ans += ao;
	if (ai == 0 || aj == 0 || al == 0) {
		ans += 2 * (ai / 2) + 2 * (aj / 2) + 2 * (al / 2);
	} else {
		ans += max(3 + 2 * ((ai-1)/2) + 2 * ((aj-1)/2) + 2 * ((al-1)/2),
				       2 * (ai / 2)   + 2 * (aj / 2)   + 2 * (al / 2));
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
const int INF = 1e9;

struct edge{
    int to, cost;
};

int V, E, r;
vector<edge> G[100010];
int d[100010];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> V >> E >> r;
    for(int i = 0; i < E; i++){
        int a, b, c;
        cin >> a >> b >> c;
        G[a].push_back(edge{b, c});
    }
    fill(d, d + V, INF);
    d[r] = 0;
    priority_queue<P, vector<P>, greater<P> > q;
    q.push(P(d[r], r));
    while(!q.empty()){
        P p = q.top(); q.pop();
        int from = p.second;
        int cost = p.first;
        if(d[from] < cost) continue;
        for(int i = 0; i < G[from].size(); i++){
            edge e = G[from][i];
            int next = e.to;
            int newCost = e.cost + cost;
            if(d[next] > newCost){
                d[next] = newCost;
                q.push(P(newCost, next));
            }
        }
    }
    for(int i = 0; i < V; i++){
        if(d[i] >= INF) cout << "INF" << endl;
        else cout << d[i] << endl;
    }
}

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

int main() {
    int d,g; cin >> d >> g;
    vector<pair<int,int>> p(d);
    long ans = 0;
    for(int i=0; i<d; i++){
        cin >> p[i].first >> p[i].second;
        ans += p[i].first;
    }

    for(int bit=0; bit<(1<<d); bit++){
        long tmp = 0;
        long score = 0;
        for(int i=0; i<d; i++){
            if(bit & (1<<i)){
                tmp += p[i].first;
                score += (i+1) * 100 * p[i].first + p[i].second;
            }
        }

        if(score < g){
            for(int i=d-1; i>=0; i--){
                if(!(bit & (1<<i)) && (i+1) * p[i].first * 100 >= g - score ){
                    tmp += (g-score-1) / ((i+1) * 100) + 1;
                    score += ((g-score-1) / ((i+1) * 100) + 1) * (i+1)*100; 
                    break;
                }
            }
        }
        if(score >= g && tmp < ans){
            ans = tmp;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3612
#pragma GCC optimize ("O3")
#include<bits/stdc++.h>
using namespace std;

/// Info.
///****************************************************************************************************************************************///
/// author                : BAHAA El-DEEN OSAMA .
/// Problem name          : K - Minor Change
/// Method                : brute force
/// Online judge          : vjudge(Contest)
/// Date                  : 8/6/2020
///****************************************************************************************************************************************///



string s1,s2;
int cnt=0;

int main()
{
    cin>>s1>>s2;
    for(int i=0;i<s1.length();++i)
    {
        if(s1[i]!=s2[i])
        {
            ++cnt;
        }
    }
    cout <<cnt<<endl;




return 0;
}


Measured memory_bytes: 3908
#include <iostream>
#include <iomanip>

using namespace std;

int main(){
  int N;
  cin >> N;
  double A[N];
  double ans=0;
  for(int i=0; i<N; i++) cin >> A[i];
  for(int i=0; i<N; i++) ans += 1/A[i];
  ans = 1 / ans;
  cout << fixed;
  cout << setprecision(8) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
	int L;
	string S;
	int a[26];
	int i;
	int ans=0;
	
	cin>>S;
	L=S.size();
	
	for(i=0;i<26;i++){
		a[i]=0;
	}
	
	for(i=0;i<L;i++){
		if(S[i]=='a'){
			a[0]++;
		}
		if(S[i]=='b'){
			a[1]++;
		}
		if(S[i]=='c'){
			a[2]++;
		}
		if(S[i]=='d'){
			a[3]++;
		}	
	       	if(S[i]=='e'){
			a[4]++;
		}
		if(S[i]=='f'){
			a[5]++;
		}
		if(S[i]=='g'){
			a[6]++;
		}
		if(S[i]=='h'){
			a[7]++;
		}
		if(S[i]=='i'){
			a[8]++;
		}
		if(S[i]=='j'){
			a[9]++;
		}
		if(S[i]=='k'){
			a[10]++;
		}
		if(S[i]=='l'){
			a[11]++;
		}	
	       	if(S[i]=='m'){
			a[12]++;
		}
		if(S[i]=='n'){
			a[13]++;
		}
		if(S[i]=='o'){
			a[14]++;
		}
		if(S[i]=='p'){
			a[15]++;
		}	
		if(S[i]=='r'){
			a[16]++;
		}
		if(S[i]=='s'){
			a[17]++;
		}
		if(S[i]=='t'){
			a[18]++;
		}	
	       	if(S[i]=='u'){
			a[19]++;
		}
		if(S[i]=='v'){
			a[20]++;
		}
		if(S[i]=='w'){
			a[21]++;
		}
		if(S[i]=='x'){
			a[22]++;
		}
		if(S[i]=='y'){
			a[23]++;
		}
		if(S[i]=='z'){
			a[24]++;
		}
		if(S[i]=='q'){
			a[25]++;
		}
	}
	for(i=0;i<26;i++){
		if(a[i]>1){
			ans++;
			break;
		}
	}
	if(ans!=0){
		cout<<"no";
	}else{
		cout<<"yes";
	}
}
	
	
	
	

Measured memory_bytes: 256
SA = list(input())
SB = list(input())
SC = list(input())

if len(SA) == 1:
    print("A")
    exit()
else:
    now = SA[0]
    del SA[0]

while True:
    if now == "a":
        if len(SA) == 0:
            print("A")
            exit()
        else:
            now = SA[0]
            del SA[0]
    elif now == "b":
        if len(SB) == 0:
            print("B")
            exit()
        else:
            now = SB[0]
            del SB[0]
    elif now == "c":
        if len(SC) == 0:
            print("C")
            exit()
        else:
            now = SC[0]
            del SC[0]

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

using namespace std;

const int MOD = 1e9 + 7;

int main()
{
  int n, k;
  cin >> n >> k;
  map<int, long long> m;
  long long ans = 0;
  for (int i = 1; i <= n; i++)
    m[i % k]++;
  for (int i = 0; i < k; i++)
    if (2 * i % k == 0)
      ans += m[i] * m[i] * m[(k - i) % k];
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
 
const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

int n;
string s;
ll cnt[30];

int main() {
    cin >> n >> s;
    rep(i,s.size()) cnt[s[i]-'a']++;
    ll ans = 1;
    rep(i,30) ans = ans * (cnt[i]+1) % MOD;
    ans = (ans - 1 + MOD) % MOD;
    cout << ans << endl;
}



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

int main()
{
    int i;
    char cur;
    string s;

    cin >> s;
    cur = s[0];

    for(i=1;i<4;i++){
        if(cur == s[i]){
            cout << "Bad" << endl;
            break;
        }else{
            cur = s[i];
        }
    }

    if(i == 4){
        cout << "Good" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<double> VD;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cout << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 1 << 18;
int n, h, w;
pair<int, PII> cards[N];
int p[N];
int sz[N];
int zan[N];

int find(int x)
{
	if (p[x] == x)
		return x;
	return p[x] = find(p[x]);
}

void unite(int x, int y)
{
	x = find(x);
	y = find(y);
	if (x == y)
		return;
		
	if (sz[x] < sz[y])
		swap(x, y);
	
	sz[x] += sz[y];
	p[y] = x;
	zan[x] += zan[y];
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	//freopen("In.txt", "w", stdout);
	
	cin >> n >> h >> w;
	FOR(i, 0, n)
	{
		cin >> cards[i].Y.X >> cards[i].Y.Y >> cards[i].X;
		cards[i].Y.X--;
		cards[i].Y.Y--;
	}
	
	sort(cards, cards + n);
	reverse(cards, cards + n);
	
	FOR(i, 0, h + w)
		p[i] = i, sz[i] = 1;
	
	LL ans = 0;
	FOR(i, 0, n)
	{
		int r = cards[i].Y.X;
		int c = cards[i].Y.Y;
		
		unite(r, c + h);
		int par = find(r);
		if (sz[par] > zan[par])
		{
			ans += cards[i].X;
			zan[par]++;
		}
	}
	
	cout << ans << endl;
	
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}


Measured memory_bytes: 5504
#include <iostream>
#include <algorithm>
using namespace std;
int main () {

int n;
cin>>n;
unsigned long long int a;
cin>>a;
unsigned long long int b;
for (int i=1; i<n; i++) {
	cin>>b;
	unsigned long long int br1=a,br2=b;
	if (br2>br1) {swap(br1,br2);}
	while (br1!=0) {
		br1=br1%br2;
		if (br1==0) {break;}
		swap(br1,br2);
	}
	a=(a/br2)*(b/br2)*br2;
}
cout<<a;

return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define vll vector<ll>
#define endl "\n"
#define pll pair<ll,ll>
#define all(x) (x).begin() , (x).end()
#define f first
#define s second
#define pr(x) cout<<x<<endl;
#define pr2(x,y) cout<<x<<" "<<y<<endl;
#define pr3(x,y,z) cout<<x<<" "<<y<<endl;
#define prv(v) for(auto x:v) cout<<x<<" ";
#define ffs fflush(stdout);
#define int ll
using namespace std;
 
const ll N =(2e5+5);
const ll MOD = 1e9+7;
const ll INF = LLONG_MAX;
const ll LOG = 29;
#define PI 3.141592653589793238 


long long binpow(long long a, long long b) {
    a%=MOD;    
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res * a)%MOD;
        a = (a * a)%MOD;
 
        
        b >>= 1;
    }
    res%=MOD;
    return res;
}
void solve(){
    ll n,m;
    cin>>n>>m;
    ll h[n+1];
    for(int i =1;i<=n;i++){
        cin>>h[i];
    }
    vll adj[n+1];
    for(int i=1;i<=m;i++){
        ll u,v;
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    ll ans = 0;
    for(int i = 1;i<=n;i++){
        bool poss=true;
        for(auto u:adj[i]){
            poss &= (h[i] > h[u]);
        }
        if(poss)ans++;
    }
    cout<<ans<<endl;
}  

 
 
signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
     
    ll t=1;
    while(t--){
        solve();
    }    
}

Measured memory_bytes: 10208
n=int(input())
a=input()
b=input()
c=input()
ans=0
for i in range(n):
  if a[i]==b[i]==c[i]:
    ans += 0
  elif a[i]!=b[i] and b[i]!=c[i] and a[i]!=c[i]:
    ans += 2
  else:
    ans += 1
print(ans)

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


using namespace std;

#define ll long int
#define ull unsigned long long int

#define I_read()  freopen("input.tex","r",stdin);

#define O_write() freopen("output.txt","w",stdout);

#define fast() ios_base::sync_with_stdio(false); cin.tie(0);


int main(){

//	fast();	
#ifdef _DEBUG

//	  I_read();
//        O_write();

#endif
	
	int n;
		
	cin>>n;

	int temp=n%10;

	if( temp == 2 || temp == 4 || temp == 5 || temp == 7 || temp == 9)
	{
		cout<<"hon"<<endl;
	}
	else if( temp == 0 || temp == 1 || temp == 6 || temp == 8)
	{
		cout<<"pon"<<endl;
	}
	else
	{
		cout<<"bon"<<endl;
	}
	
 return 0;	
}



Measured memory_bytes: 3624
#a
n=int(input())
h=list(map(int,input().split()))

N=100010
dp=[0]*N

for i in range(1,n):
    if i==1:
        dp[i]=dp[i-1]+abs(h[i-1]-h[i])
    else:
        dp[i]=min(dp[i-1]+abs(h[i-1]-h[i]),dp[i-2]+abs(h[i-2]-h[i]))

print(dp[n-1])


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

using namespace std;

using int64 = long long;
const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


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

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
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 V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}


// 競技プログラミングを引退します
// いままでありがとうございました

int main() {
  int N, K;
  cin >> N >> K;
  vector< int > A(N);
  cin >> A;

  // S[r] - S[l] == r - l (mod K)
  // S[r]   -  r == S[l] - l (mod K)

  vector< int64 > S(N + 1);
  for(int i = 0; i < N; i++) {
    S[i + 1] = S[i] + A[i];
    S[i + 1] %= K;
  }


  int64 ret = 0;
  vector< int64 > del[402020];
  map< int64, int > mp;

  for(int i = 0; i <= N; i++) {

    for(auto &t : del[i]) mp[t]--;

    int64 val = (K + (S[i] - i) % K) % K;
    ret += mp[val];

    mp[val]++;
    del[min(N+1,i + K)].emplace_back(val);
  }

  cout << ret << endl;
}



Measured memory_bytes: 26096
import math
import numpy as np

N = int(input())
A = list(map(int, input().split()))



def get_sieve_of_eratosthenes_new(n):
    import math
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]

prime_num = set(get_sieve_of_eratosthenes_new(999984))

def pairwise_coprime():
    gcd = dict()
    for a in A:
        if a in prime_num:
            if not (a in gcd):
                gcd[a] = 1
            else:
                return False
        else:
            tmp = a
            for p in prime_num:
                if tmp == 1:
                    break
                # print(tmp, p)

                if tmp % p == 0:
                    if not(p in gcd):
                        gcd[p] = 1
                    else:
                        return False
                    
                    while tmp % p == 0:
                        tmp //= p
    # print(gcd)
    
    return True
                


def setwise_coprime():
    gcd = A[0]
    for i in range(1, N):
        gcd = math.gcd(gcd, A[i])
        # print(gcd)
        if gcd == 1:
            break
    
    if gcd == 1:
        return True
    else:
        return False

if pairwise_coprime():
    print("pairwise coprime")
elif setwise_coprime():
    print("setwise coprime")
else:
    print("not coprime")


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

const int N = 100005;

multiset<int> s[N];
int cnt;
priority_queue< int, vector<int>, greater<int> > rem;
int n, m, par[N], a[N];
long long ans;

int anc(int p) { return p == par[p] ? p : par[p] = anc(par[p]); }
void join(int p, int q) {
	p = anc(p), q = anc(q);
	assert(p != q);
	if (s[p].size() > s[q].size()) swap(p, q);
	// p->q
	for (auto i : s[p]) s[q].insert(i);
	s[p].clear(); par[p] = q;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n >> m;
	if (n < 2 * (n - m - 1)) return cout << "Impossible\n", 0;
	for (int i = 1; i <= n; ++i) par[i] = i;
	for (int i = 1; i <= n; ++i) cin >> a[i], s[i].insert(a[i]);

	for (int i = 0; i < m; ++i) {
		int u, v; cin >> u >> v; ++u; ++v;
		join(u, v);
	}

	for (int i = 1; i <= n; ++i) if (i == anc(i)) {
		if (++cnt <= 2 * (n - m - 1)) ans += *s[i].begin();
		s[i].erase(s[i].begin());
		for (int j : s[i]) rem.push(j);
	}
	for (int i = 1; i <= 2 * (n - m - 1) - cnt; ++i) {
		ans += rem.top(); rem.pop();
	}

	cout << ans << endl;
}

Measured memory_bytes: 11260
let n = stdin.ReadLine() |> int
let h = stdin.ReadLine().Split() |> Array.map int64

Array.scan (fun (h1,c1,h2,c2) t -> (h2,c2,t,Array.min [|c1+(abs (t-h1));c2+(abs (t-h2))|])) (0L,1000000000L,h.[0],0L) h.[1..n-1]
|> ((fun x -> x.[n-1]) >> (fun (_,_,_,c2) -> c2))
|> stdout.WriteLine


Measured memory_bytes: 50480
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repA(i,a,b) for(int i=a;i<=b;i++)
#define repD(i,b,a) for(int i=b;i>=a;i--)
#define fill(a) memset(a,0,sizeof(a))
#define f first
#define s second
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int main()
{
    double r;
    cin>>r;
    cout<<setprecision(4);
    cout<<fixed;
    cout<<r*6.2831<<endl;
}


Measured memory_bytes: 3748
using System;

namespace ABC152
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = new string[2];
            var n = Console.ReadLine().Split(' ');
            s[0] = new String(n[0][0], int.Parse(n[1]));
            s[1] = new String(n[1][0], int.Parse(n[0]));
            Array.Sort(s);
            Console.WriteLine(s[0]);
        }
    }
}

Measured memory_bytes: 11356
def func_rfindr(str):
    return str.rfind('R')

def func_lfindw(str):
    return str.find('W')

def func_replace(target, pos, str):
    ret = ""
    if pos != 0:
        ret = target[0:pos]
    ret = ret + str
    if len(target) - 1 != pos:
        ret = ret + target[pos + 1:]
    return ret

N = int(input())
C = input()
ans = 0

posrr = func_rfindr(C)
poslw = func_lfindw(C)

while poslw != -1 and posrr != -1 and posrr > poslw:
    #C = func_replace(C, posrr, "W")
    #C = func_replace(C, poslw, "R")
    C = C[poslw + 1:posrr]
    ans = ans + 1
    posrr = func_rfindr(C)
    poslw = func_lfindw(C)

print(ans)

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

int main(){

    ll n,k,x,y;
    cin >> n >> k;
    if(n>=k){
        x = n%k;
        y = min(x,k-x);
    }
    else {
        x = k - n;
        y = min(x,n);
    }
    cout << y << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9;
const int mod = 1e9+7;

signed main(){
    int n, a, b;
    cin >> n >> a >> b;
    int ma = min(a,b);
    int mi = (n - a - b >= 0) ? 0: a+b-n;
    cout << ma<<" "<<mi << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
using namespace std;

int a,d,n;


bool input(){
  cin>>a>>d>>n;
  if(a==0&&d==0&&n==0){
	  return false;
  }
  return true;
}

bool prime(int m){
	int i;

	if(m<2)
		return 0;
	else if(m==2)
		return 1;
	if(m%2==0)
		return 0;

	for(i=3; i*i<=m; i=i+2){
		if(m%i==0)
			return 0;
	}
	return 1;
}
		
int solve(){
	int i=0,count=0;
	bool p;
	while(1){
		p=prime(a);
		if(p==1){
			count++;
		}
		if(n==count){
			break;
		}
		a=a+d;
	}
	return a;
}




int main(){
  while(input()){
    cout<<solve()<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using loop = int;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(loop (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(loop (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(loop (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(loop (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n; cin >> n;
    VI a(n); cin >> a;
    VL cnt(n);
    each(i, a) {
        --i;
        ++cnt[i];
    }

    ll ans = 0;
    FOR(i, 0, n)ans += cnt[i] * (cnt[i] - 1) / 2;

    FOR(i, 0, n) {
        ans -= cnt[a[i]] * (cnt[a[i]] - 1) / 2;
        ans += (cnt[a[i]] - 2) *(cnt[a[i]] - 1) / 2;
        cout << ans << "\n";
        ans -= (cnt[a[i]] - 2) *(cnt[a[i]] - 1) / 2;
        ans += cnt[a[i]] * (cnt[a[i]] - 1) / 2;
    }
}

Measured memory_bytes: 4992