akhauriyash/Code-Regression huggingface dataset:
package main

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

func main() {
        var h, w, k int
        fmt.Scanf("%d %d %d", &h, &w, &k)

        sc := bufio.NewScanner(os.Stdin)
        sh := make([][]int, h)
        var count int
        for sc.Scan() {
                sw := make([]int, w)
                for i, s := range strings.Split(sc.Text(), "") {
                        if s == "." {
                                sw[i] = 0
                        } else {
                                sw[i] = 1
                        }
                }
                sh[count] = sw
                count++
                if count == h {
                        break
                }
        }

        var before string
        initCount := 1
        berryCount := 1
        for _, l := range sh {
                if !checkLine(l) {
                        if before == "" {
                                initCount++
                        } else {
                                fmt.Println(before)
                        }
                        continue
                }

                var l2 []int
                berryCount, l2 = splitLine(berryCount, l)
                if before == "" {
                        before = stringLine(l2)
                        for i := 0; i < initCount; i++ {
                                fmt.Println(before)
                        }
                } else {
                        before = stringLine(l2)
                        fmt.Println(before)
                }
        }
}

func printLine(l []int) {
        fmt.Println(stringLine(l))
}

func stringLine(l []int) string {
        var str string
        for _, s := range l {
                str += strconv.Itoa(s) + " "
        }
        str = strings.TrimRight(str, " ")
        return str
}

func splitLine(start int, l []int) (int, []int) {
        l2 := make([]int, len(l))
        end := start
        init := true
        for i, s := range l {
                if s == 1 {
                        if init {
                                init = false
                        } else {
                                end++
                        }
                }
                l2[i] = end
        }

        end++

        return end, l2
}

func checkLine(l []int) bool {
        for _, s := range l {
                if s == 1 {
                        return true
                }
        }
        return false
}

Measured memory_bytes: 6528
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <bitset>
#include <numeric>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <numeric>
#include <cstdlib>
#include <random>
#include <bits/stdc++.h>


using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll mod=1000000007ll;
const ll inf=1000000000000000ll;

const ll MAX_N=100000;

string N;

int main(){
  cin>>N;
  ll ans=0;
  for(ll i=0;i<4;i++){
    if(N[i]=='2')ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
main()
{
    int w, h;
    cin >> h >> w;
    string mat[h], ans[h];
    for(int i = 0; i < h; i++)
    {
        cin >> mat[i];
        ans[i] = mat[i];
    }
    for(int i = 0; i < h; i++)
    {
        int cnt = 0;
        for(int j = 0; j < w; j++)
        {
            if(mat[i][j] == '.')
                cnt++;
        }
        if(cnt == w)
        {
            fill(ans[i].begin(), ans[i].end(), 'x');
        }
    }
    for(int i = 0; i < w; i++)
    {
        int cnt = 0;
        for(int j = 0; j < h; j++)
        {
            if(mat[j][i] == '.')
                cnt++;
        }
        if(cnt == h)
        {
            for(int j = 0; j < h; j++)
                ans[j][i] = 'x';
        }
    }
    for(int i = 0; i < h; i++)
    {
        bool flag = false;
        for(int j = 0; j < w; j++)
        {
            if(ans[i][j] != 'x')
            {
                cout << ans[i][j];
                flag = true;
            }
        }
        if(flag)
            cout << endl;
    }
//    main();
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace ABC085_B_Kagami_Mochi
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			List<int> dList = new List<int>();
			for (int i = 0; i < n; i++)
				dList.Add(int.Parse(Console.ReadLine()));
			
			dList.Sort();
			dList.Reverse();

			int count = 1;
			for (int i = 1; i < n; i++)
				if (dList[i] != dList[i - 1]) count++;
			
			Console.WriteLine(count);
		}
	}
}

Measured memory_bytes: 11220
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,ans;
	cin>>a>>b>>c;
	ans=3;
	if(a==b)ans--;
	if(a==c)ans--;
	if(b==c)ans--;
	if(a==b&&a==c)ans=1;
     cout<<ans;
     return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

const double eps = 0.00000001;

double fcr(const vector<pair<int, int>> &xy, const pair<double, double> &p){
  double res = 0;
  for(auto q : xy){
    double hy = hypot(q.first-p.first, q.second-p.second);
    res = max(res, hy);
  }
  return res;
}

double xf(const vector<pair<int, int>> &xy, double x){
  double l = 0, r = 1000;
  rep(__x, 100){
    double m1 = (l*2+r)/3, m2 = (l+r*2)/3;
    pair<double, double> pm1(x, m1), pm2(x, m2);
    double r1 = fcr(xy, pm1), r2 = fcr(xy, pm2);
    if(r1 < r2){
      r = m2;
    }else{
      l = m1;
    }
  }
  return (l+r)/2;
}

int main(){
  int n;
  cin >> n;
  vector<pair<int, int>> xy(n);
  pair<double, double> pos(0, 0);
  rep(i, n){
    int x, y;
    cin >> x >> y;
    xy.at(i) = {x, y};
  }
  double l = 0, r = 1000;
  rep(_i, 100){
    double m1 = (l*2+r)/3, m2 = (l+r*2)/3;
    double y1 = xf(xy, m1), y2 = xf(xy, m2);
    pair<double, double> p1(m1, y1), p2(m2, y2);
    double r1 = fcr(xy, p1), r2 = fcr(xy, p2);
    if(r1 < r2){
      r = m2;
    }else{
      l = m1;
    }
  }
  pos.first = (l+r)/2;
  pos.second = xf(xy, pos.first);
  double ans = fcr(xy, pos);
  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}

Measured memory_bytes: 3860
#include <iostream>
#include <algorithm>

using namespace std;

int main(int, char**)
{
	unsigned int n;
	std::cin >> n;
	bool ans = false;
	for (unsigned int i = 0; i < n; i++) {
		unsigned int a;
		cin >> a;
		if (a % 2 == 1)
			ans = true;
	}

	if (ans)
		cout << "first" << endl;
	else
		cout << "second" << endl;
	return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
using namespace std;

int main(){
  int N,ans=0;
  cin>>N;
  int P[N];
  for(int i=0; i<N; ++i) cin>>P[i];
  for(int i=1; i<N-1; ++i){
    if((P[i-1]<P[i]) && P[i]<P[i+1]) ans++;
    else if((P[i-1]>P[i]) && P[i]>P[i+1]) ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

int M;
ll c[200000];
ll d[200000];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> M;
    ll sum = 0;
    ll tmp = 0;
    for(int i = 0; i < M; i++){
        cin >> d[i] >> c[i];
        sum += c[i];
        tmp += c[i]*d[i];
    }
    ll prev = tmp;
    tmp += tmp/10;
    while(tmp != prev){
        ll dif = tmp/10-prev/10;
        prev = tmp;
        tmp += dif;
    }
    cout << sum-1+tmp/10 << endl;
}

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

int main(){
    int N, T, E;
    vector<int> x;

    cin >> N >> T >> E;
    for(int i=0; i < N; i++){
        int input;
        cin >> input;
        x.push_back(input);
    }
    bool isPossible = false;
    for(int i=E*(-1); i <= E && !isPossible; i++){
        for(int j=0; j < N && !isPossible; j++){
            if((i+T)%x[j] == 0){
                cout << j+1 << endl;
                isPossible = true;
            }
        }
    }
    if(!isPossible) cout << -1 << endl;
}

Measured memory_bytes: 1220
from sys import stdin, setrecursionlimit
from collections import Counter, deque, defaultdict
from math import floor, ceil
from bisect import bisect_left
from itertools import combinations
setrecursionlimit(100000)

INF = int(1e10)
MOD = int(1e9 + 7)

def main():
    from builtins import int, map
    N = int(input())
    flags = []
    for _ in range(N):
        ai, bi = map(int, input().split())
        flags.append(ai == bi)

    for i in range(N - 2):
        if flags[i] and flags[i + 1] and flags[i + 2]:
            print("Yes")
            exit()

    print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 9416
#include <bits/stdc++.h>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define popcount __builtin_popcount
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;


template <class T>
inline bool chmin(T &a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}

ll gcd(ll n, ll m)
{
	ll tmp;
	while (m != 0)
	{
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m)
{
	return abs(n) / gcd(n, m) * abs(m); //gl=xy
}

using namespace std;

using P=pair<int,int>;
set<P>st;
ll h,w;
vector<ll>ans;
set<P>used;

void check(int x,int y,int xx,int yy){
	if(used.count(P{x,y}))return;
	used.emplace(x,y);
	int cnt=0;
	if(x>=0&&xx<=h&&y>=0&&yy<=w);
	else return;
	REP(i,x,xx){
		REP(j,y,yy){
			if(st.count(P{i,j}))++cnt;
		}
	}
	ans[cnt]++;
}
void solve(){
	int n;
	cin>>h>>w>>n;
	vector<P>p(n);
	rep(i,n){
		cin>>p[i].first>>p[i].second;
		p[i].first--;p[i].second--;
		st.emplace(p[i].first,p[i].second);
	}
	ans.resize(10);
	rep(i,n){
		int x=p[i].first,y=p[i].second;
		check(x,y,x+3,y+3);
		check(x-1,y-1,x+2,y+2);
		check(x-2,y-2,x+1,y+1);
		check(x,y-1,x+3,y+2);
		check(x,y-2,x+3,y+1);
		check(x-1,y,x+2,y+3);
		check(x-1,y-2,x+2,y+1);
		check(x-2,y,x+1,y+3);
		check(x-2,y-1,x+1,y+2);
	}
	ans[0]=(h-2)*(w-2)-accumulate(ans.begin()+1,ans.end(),0LL);
	rep(i,10){
		cout<<ans[i]<<"\n";
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 50976
use std::cmp::*;

#[derive(PartialEq, PartialOrd, Copy, Clone)]
pub struct Total<T>(pub T);

impl<T: PartialEq> Eq for Total<T> {}

impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

fn main() {
    let mut n = read::<i64>();
    let v = read_vec::<i64>();
    let (ga, sa, ba) = (v[0], v[1], v[2]);
    let v = read_vec::<i64>();
    let (gb, sb, bb) = (v[0], v[1], v[2]);
    let mut ans = 0;
    for gi in 0..n + 1 {
        if gi * ga > n {
            break;
        }
        for si in 0..n + 1 {
            if gi * ga + si * sa > n {
                break;
            }
            let mut residual = n - (gi * ga + si * sa);
            if bb > ba {
                residual = (residual / ba) * bb + (residual - (residual / ba) * ba);
            }
            ans = max(ans, gb * gi + sb * si + residual);
        }
    }
    n = ans;

    let order = argsort(&vec![ga / gb, sa / sb, ba / bb]);
    let rates = vec![(gb, ga), (sb, sa), (bb, ba)];
    let (gb, ga) = rates[order[2]];
    let (sb, sa) = rates[order[1]];
    let (bb, ba) = rates[order[0]];

    let max_enable = (n / gb) as i64;

    let mut ans = n;
    if n <= 5000 {
        for gi in 0..max_enable + 1 {
            for si in 0..n {
                if gi * gb + si * sb > n {
                    break;
                }
                let mut residual = n - (gi * gb + si * sb);
                if ba > bb {
                    residual = (residual / bb) * ba + (residual - (residual / bb) * bb);
                }
                ans = max(ans, residual + gi * ga + si * sa);
            }
        }
    } else {
        for gi in 0..max_enable + 1 {
            let si = (n - gi * gb) / sb;
            let residual = n - (gi * gb + si * sb);
            ans = max(ans, residual + gi * ga + si * sa);
        }
    }
    println!("{:?}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn argsort<T: std::cmp::Ord + std::marker::Copy>(v: &Vec<T>) -> Vec<usize> {
    let mut sort_v = Vec::new();
    for i in 0..v.len() {
        sort_v.push((v[i], i));
    }
    sort_v.sort();
    sort_v.iter().map(|x| x.1).collect::<Vec<usize>>()
}


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

using namespace std;

bool rec(vector<int> v)
{
	if (v.size() == 0) { return true; }

	vector<int> count_(10, 0);

	for (int i = 0; i < v.size(); i++)
	{
		count_[v[i]] += 1;
	}

	for (int i = 1; i <= 9; i++)
	{
		if (count_[i] >= 3)
		{
			vector<int> v2;

			for (int j = 0; j < v.size(); j++)
			{
				if (v[j] != i)
				{
					v2.push_back(v[j]);
				}
			}

			if (rec(v2) == true)
			{
				return true;
			}
		}
	}

	for (int i = 1; i <= 7; i++)
	{
		if (count_[i] >= 1 && count_[i + 1] >= 1 && count_[i + 2] >= 1)
		{
			int ca = 0, cb = 0, cc = 0;

			vector<int> v2;

			for (int j = 0; j < v.size(); j++)
			{
				if ((v[j] != i || ca++ != 0) && (v[j] != i + 1 || cb++ != 0) && (v[j] != i + 2 || cc++ != 0))
				{
					v2.push_back(v[j]);
				}
			}

			if (rec(v2) == true)
			{
				return true;
			}
		}
	}

	return false;
}

bool check(vector<int> v)
{
	for (int i = 1; i <= 9; i++)
	{
		int count_ = 0;

		for (int j = 0; j < v.size(); j++)
		{
			if (v[j] == i)
			{
				count_++;
			}
		}

		if (count_ >= 2)
		{
			vector<int> v2;

			int cc = 0;

			for (int j = 0; j < v.size(); j++)
			{
				if (v[j] != i || cc++ >= 2)
				{
					v2.push_back(v[j]);
				}
			}

			if (rec(v2) == true)
			{
				return true;
			}
		}
	}

	return false;
}

int main()
{
	string S; vector<int> v(13);

	while (cin >> S)
	{
		for (int i = 0; i < 13; i++)
		{
			v[i] = S[i] - 48;
		}

		int count_ = 0;
		
		for (int i = 1; i <= 9; i++)
		{
			vector<int> v2 = v;

			v2.push_back(i);

			vector<int> countDiv2(10);

			for (int j = 0; j < v2.size(); j++)
			{
				countDiv2[v2[j]]++;
			}

			for (int j = 1; j <= 9; j++)
			{
				if (countDiv2[v[j]] > 4)
				{
					goto Exit;
				}
			}

			if (check(v2))
			{
				if (count_++)
				{
					cout << ' ';
				}

				cout << i;
			}

		Exit:;
		}

		if (count_ == 0)
		{
			cout << 0;
		}

		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 3176
using System;
using System.Linq;

namespace caddi2018_a
{
    class Program
    {
        static bool[] isprime = new bool[1000010];
        static void prime()
        {
            for (int i = 2; i < 1000010; i++) isprime[i] = true;
            for (int i = 2; i < 1000010; i++)
            {
                if (isprime[i])
                {
                    for (long j = (long)i * i; j < 1000010; j += i) isprime[j] = false;
                }
            }
        }
        static void Main(string[] args)
        {
            long[] x = Console.ReadLine().Split().Select(long.Parse).ToArray();
            if (x[0] == 1) Console.WriteLine(x[1]);
            else
            {
                prime();
                long ret = 1; long a = x[1];
                for (int i = 2; i <= Math.Sqrt(x[1] + 10); i++)
                {
                    if (isprime[i])
                    {
                        int count = 0;
                        while (a % i == 0) { a /= i; count++; }
                        ret *= (long)Math.Pow(i, count / x[0]);
                    }
                }
                Console.WriteLine(ret);
            }
        }
    }
}

Measured memory_bytes: 14292
#include"bits/stdc++.h"
using namespace std;


void Main() {
  long long n;
  cin >> n;
  if (n % 2) {
    cout << 0 << endl;
    return;
  }
  long long waru = 5;
  long long ans = 0;
  while (waru <= n) {
    ans += n / 2 / waru;
    waru *= 5;
  }
  cout << ans << endl;
}

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


Measured memory_bytes: 256
while True:
    (n, x) = [int(i) for i in input().split()]
    if n == x == 0:
        break
    cnt = 0
    for i in range(1, n+1):
        for j in range(i+1, n+1):
            for k in range(j+1, n+1):
                if (i + j + k) == x:
                    cnt += 1
                elif (i + j + k) > x:
                    break
    print(cnt)

Measured memory_bytes: 6724
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"YES"<<endl
#define cno cout<<"NO"<<endl
#define sp <<" "<<
#define CST(x) cout<<fixed<<setprecision(x)
#define PI 3.14159265359
#define MOD 1000000007
using namespace std;
using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;
using que_a = priority_queue<int, vector<int>, greater<int> >;
using que_d = priority_queue<int>;
using pint = pair<int,int>;

int main(){

    int m,f,r;
    while(true){
        cin >> m >> f >> r;
        if(m == -1 && f == -1 && r == -1) return 0;
        int sum = m + f;
        if(m == -1 || f == -1) cout << 'F' << endl;
        else if(sum >= 80) cout << 'A' << endl;
        else if(sum >= 65) cout << 'B' << endl;
        else if(sum >= 50) cout << 'C' << endl;
        else if(sum >= 30){
            if(r >= 50) cout << 'C' << endl;
            else cout << 'D' << endl;
        }
        else cout << 'F' << endl;
    }
    return 0;
}


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

vector <long long> task;
signed main(){
  long long n, a , b , ta , tb ;
  bool f=true;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a>>b;
    task.push_back(1000000001*b+a);
   }
  sort(task.begin(),task.end());
  ta=0,tb=0;
  for(int i=0;i<n;i++){
    ta+=task[i]%1000000001 , tb=task[i]/1000000001;
    if(tb < ta){
      f=false;
    }
  }
  if(f){
    cout<<"Yes\n";
  } else {
    cout<<"No\n";
  }
  return(0);
}
  

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
#define big 1000000007
#define PI 3.14159265
int main(){
    double a,b,x;
    cin >> a >> b >> x;
    double h ;
    double cita;
    //x = a*(b+上底)*a/2;
    //場合分け；水が半分より多い⇒台形、半分より少ない⇒三角形
    if(2*x>a*a*b){
    h = (2*x-a*a*b)/(a*a);
    double naname = sqrt(a*a+(b-h)*(b-h));
    cita = 180*acos(a/naname)/PI;
    }
    else{
        h=2*x/(a*b);
        cita = 90 - 180*atan(h/b)/PI;
    }
    cout << fixed << setprecision(10);
    cout << cita <<endl;

}

Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#include <map>
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
using ll = long long;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) {
        cin >> a[i];
    }

    vector<int> ans(n);

    rep(i,n){
        ans[a[i]-1] = i+1;
    }
    rep(i,n){
        if(i <= n-1) cout << ans[i] << ' ';
        else cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 1536
#include<iostream>
#include<algorithm>


using namespace std;

int main(void){
    int N;
    int Y;
    int a,b,c;  a=b=c=-1;
    bool flag=false;

    cin>>N>>Y;

    int i,j,k;
    
    
    for(i=0;i<=N;i++){
        if(flag==true)break;
        for(j=0;j<=N;j++){
            if(flag==true)break;
            for(k=0;k<=N;k++){
                if(flag==true)break;
                if((i+j+k)>N)break;
                int result=10000*i+5000*j+1000*k;
                if((Y==result)&&(N==(i+j+k))){
                    flag=true;
                    a=i;
                    b=j;
                    c=k;
                    break;
                }
            }
    
        }
    }
    cout<<a<<" "<<b<<" "<<c<<endl;

    return 0;
    
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
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 (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

ll A[2][105] = {};

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

    ll N;
    cin >> N;
    REP(i, N){
    	cin >> A[0][i];
    }
    REP(i, N){
    	cin >> A[1][i];
    }

    ll res = 0;
    REP(i, N){
    	ll tmp = 0;
    	REP(j, N){
    		if(j<=i) tmp += A[0][j];
    		else tmp += A[1][j];
    	}
    	tmp += A[1][i];
    	chmax(res, tmp);
    }
    cout << res << endl;
    return 0;
}

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

int main(){
  // 奇数の数: a, 4の倍数の数: b
  // 偶数で４の倍数でない: c
  int N;
  cin >> N;
  int a=0, b=0, c=0;
  for(int i = 0; i < N; i++){
    int tmp;
    cin >> tmp;
    if(tmp % 4 == 0){
      b++;
    } else if(tmp % 4 == 2){
      c++;
    } else {
      a++;
    }
  }
  
  string ans;
  if(b == 0){
    if(a == 0 && c >= 2){
      ans = "Yes";
    } else { 
      ans = "No";
    }
  } else {
    if(a <= b){
      ans = "Yes";
    } else if( a == b+1 && c == 0) { 
      ans = "Yes";
    } else { 
      ans = "No";
    }
  }
  
  cout << ans << endl;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<stdio.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;


#define ll                  long long
#define scl(n)              scanf("%lld",&n)
#define scll(n, m)          scanf("%lld%lld",&n, &m)
#define scc(c)	            scanf("%c",&c)
#define fr(i,n)             for (ll i=0;i<n;i++)
#define fr1(i,n)            for(ll i=1;i<=n;i++)
#define pfl(x)              printf("%lld\n",x)
#define pb                  push_back
#define debug               cout<<"I am here"<<endl;
#define pno                 cout<<"NO"<<endl
#define pys                 cout<<"YES"<<endl
#define tcas(i,t)           for(ll i=1;i<=t;i++)
#define all(x) 	            (x).begin(), (x).end()
#define allrev(x)           (x).rbegin(),(x).rend()
#define pr                  pair<ll, ll>
#define ff                  first
#define ss                  second
#define pn                  printf("\n")

#define N 200005

ll m,n,k, a[N],cut=0;

bool is_posi(ll x)
{
    cut=0;
    fr(i, n)
    {
        cut += a[i] / x;
        if (a[i] == x )cut--;
    }

    //return cut<=k;

    if(cut<=k)return 1;
    else return 0;
}

int main()
{
    ll t;
    t=1;
    tcas(cs, t)
    {
        cin>>n>>k;
        ll cnt=0,cn=0,ans,sum=0, mx=-1 ;
        fr(i, n)cin>>a[i];

        ll l=1 , r=1e9, mid;
        ans=mx;

        while(l<=r)
        {
            mid=(l+r)/2;
            if(is_posi(mid ) )r=mid-1  , ans=mid;
            else l=mid+1;
        }

        cout<<ans<<endl;
    }

return 0;
}

/// **************************Before submit****************************

///    ****Please check all base case output  and printing " YES or NO " ***
///    *check for integer overflow,array bounds
///    *check for n=1


Measured memory_bytes: 5120
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    print(n*(n-1)>>1)
    return

#Solve
if __name__ == "__main__":
    solve()


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

#define ll long long
#define pb push_back
#define fi first
#define se second
#define vi vector<int>
#define vii vector<int,int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define umii unordered_map<int,int>
#define mii map<int,int>
#define pii pair<int,int>
#define rep(i,a,b) for(int i=a ; i<b ; i++)

const long long MOD = 1e9+7;

void solve() {
	ll n,k;
	cin >> n >> k;
	int p[n], c[n];
	for(int i=0; i<n; i++)
		cin >> p[i];
	for(int i=0; i<n; i++)
		cin >> c[i];
	vector<vector<long long>> cycle, pre;
	for(int i=0; i<n; i++) {
		vector<long long> temp1;
		// temp.pb(p[i]);
		ll s=p[p[i]-1];
		ll score=c[p[i]-1];
		temp1.pb(score);
		while(p[i] != s) {
			// temp.pb(s);
			score+=c[s-1];
			temp1.pb(score);
			s=p[s-1];
		}
		// cycle.pb(temp);
		pre.pb(temp1);
	}
	ll mx=INT_MIN;
	for(auto it:pre) {
		ll score=INT_MIN;
		if(it.size()>=k) {
			for(int i=0; i<k ; i++) {
				score = max(score, it[i]);
			}
		}
		else {
			if(*(it.rbegin()) < 0) {
				for(auto itr:it)
					score = max(score,itr);
			}
			else {
				ll q=k/it.size();
				ll r=k%it.size();
				ll t1 = *(it.rbegin())*q;
				ll t2 = *(it.rbegin())*(q-1);
				ll m = INT_MIN;
				for(int i=0; i<r; i++)
					m = max(m, it[i]);
				t1+=m;
				m=INT_MIN;
				for(int i=0; i<it.size(); i++) {
					m = max(m, it[i]);
				}
				t2+=m;
				score = max(t1, t2);
			}
		}
		mx=max(mx, score);
	}
	cout << mx << endl;
}

signed main() 
{
	int t=1;
	// cin>>t;
	for(int i=1; i<=t; i++) {
		solve();
	}
}

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

int main() {
	int H, W;
  cin >> H >> W;
  vector<string> data(H);
  for(int i=0;i<H; i++){
    cin >> data.at(i);
  }
  
  // 除去するべき行を抜く
  vector<string> data1;
  for(int i=0; i<H; i++){
    int dotCount = 0;
    for(int j=0;j<data.at(i).size();j++){
      if (data.at(i).at(j) == '.') { dotCount++; }
    }
    if (dotCount == W) {
      continue;
    }
    data1.push_back(data.at(i));
  }

  // 縦の除去するべき文字をxでマーク
  for(int j=0;j<W;j++){
    int dotCount = 0;
    for(int i=0; i<data1.size(); i++) {
      if(data1.at(i).at(j) == '.') { dotCount++; }
    }
    if (dotCount == data1.size()) {
      for(int i=0; i<data1.size(); i++) {
        data1.at(i).at(j) = 'x';
      }
    }
  }
  
  for(int i=0;i<data1.size(); i++){
    string nl;
    for(int j=0; j<W; j++){
      if(data1.at(i).at(j) != 'x') {
        nl.push_back(data1.at(i).at(j));
      }
    }
    data1.at(i) = nl;
  }
  
  for(int i=0;i<data1.size();i++){
    cout << data1.at(i) << endl;
  }
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>; 
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


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

     rep(i, min(2000, k)){
         vector<int> imos(n+1);
         rep(j, n){
             int s = max(0, j - A[j]), g = min(n, j + A[j] + 1);
             imos[s]++;
             imos[g]--;
         }
         rep(j, n){
             if(j)A[j] = A[j-1]; else A[j] = 0;
             A[j] += imos[j];
         }
     }
     rep(i, n)cout << A[i] << " ";
     cout << ln;
}
    

 


Measured memory_bytes: 4836
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;++i)
#define ocut cout
#define ouct cout
#define itn int

struct Union{
  vector<ll> par;
  Union(ll a){
  par=vector<ll>(a,-1);
  }
  ll find(ll a){
    if(par[a]<0){
      return a;
    }
    else{
      return par[a]=find(par[a]);
    }
  }
  bool same(ll a,ll b){
    return (find(a)==find(b));
  }
  ll size(ll a){
    return -par[find(a)];
  }
  void unite(ll a,ll b){
    ll c=find(a),d=find(b);
    if(c==d)
      return;
    if(size(c)<size(d)){
      swap(c,d);
    }
    par[c]+=par[d];
    par[d]=c;
  }
};
ll euclidean_gcd(ll a, ll b) {
  if(a < b) return euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
ll euclidean_lcm(ll a, ll b) {
  return a/euclidean_gcd(a,b)*b;
}

ll binary(ll bina){
    ll ans = 0;
    for (ll i = 0; bina>0 ; i++)
    {
        ans += bina%2;
        bina = bina/2;
    }
    return ans;
}
void revStr(char* str){
	int size = strlen(str);
	int i,j;
	char tmp = {0};
	
	for(i = 0, j = size - 1; i < size / 2; i++, j--){
		tmp = str[i];
		str[i] = str[j];
		str[j] = tmp;
	}
	return;	
}

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(void){
  string s;
  cin >> s;
  if(s[s.size()-1]=='s')cout << s << "es";
  else cout << s << "s";
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll n;
  R n;
  ll t[n];
  rep(i,n) R t[i];
  ll sum=0;
  rep(i,n) sum+=t[i];
  ll m;
  R m;
  while(m--) {
    int x,y;
    cin >> x >> y;
    x--;
    pr(sum-t[x]+y);
  }
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
using namespace std;

int main() {
  int n, a;
  vector<int> v;
  v.push_back(0);
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a);
    if (a == v.back() + 1) {
      v.push_back(a);
    }
  }
  if (v.back()) {
    printf("%d\n", n - v.back());
  } else {
    printf("-1\n");
  }
}

Measured memory_bytes: 1400
import Control.Applicative
import Data.List

frame :: Int -> Int -> String
frame h w = (recUpper w) ++ (recInner w (h-2)) ++ (recUpper w)

recUpper :: Int -> String
recUpper w = (replicate w '#') ++ "\n"

recInner :: Int -> Int -> String
recInner w 0 = ""
recInner w h = "#" ++ (replicate (w-2) '.') ++ "#\n" ++ (recInner w (h-1))

main = do
{
    l <- map (map (read::String->Int) . words) . init . lines <$> getContents;
    let{
        sqs = [ frame (x!!0) (x!!1)  | x<-l ];
    };
    mapM_ putStrLn $ sqs;
}

Measured memory_bytes: 4740
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Scanner;
import java.util.HashSet;
import java.util.Iterator;

class Main {

    static final int MOD = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        int[] c = new int[n];
        long ans = 0;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt() - 1;
        }
        for (int i = 0; i < n; i++) {
            b[i] = sc.nextInt();
        }
        for (int i = 0; i < n - 1; i++) {
            c[i] = sc.nextInt();
        }
        c[n - 1] = 0;
        int prev = n - 1;
        for (int i = 0; i < n; i++) {
            ans += b[a[i]];
            if (prev == a[i] - 1)
                ans += c[prev];
            prev = a[i];
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int n;
	cin >> n;
	vector<int>a(n),b(n),c(n);
	for (int i = 0; i < n; i++)cin >> a.at(i);
	for (int i = 0; i < n; i++) cin >> b.at(i);
	for (int i = 0; i < n; i++)cin >> c.at(i);
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	sort(c.begin(), c.end());
	long long ans = 0;
	for (int i = 0; i < n; i++) {
		long long as = lower_bound(a.begin(), a.end(), b.at(i)) - a.begin();
		long long cs = c.end() - upper_bound(c.begin(), c.end(), b.at(i));
		ans += as * cs;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
 
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;i<n;i++)
#define ll long long
 
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end() 

#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
 
#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
 
using namespace std;

/**************************************************************************/
int main()
{
	fastIO;
	ll n,i;
    cin>>n;
    string a  = to_string(n);
    fo(i,a.size())
    {
        if(a[i]=='1') a[i]='9';
        else if(a[i]=='9') a[i]='1';
    }

    cout<<a<<endl;
}
/*************************************************************************/ 

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
#define N 2001
#define INF 0x3f3f3f3f
int f[N][N],w[N],b[N],B[N<<1][N],W[N<<1][N];char s[N];
int main()
{
//	freopen("magolor.in","r",stdin);
//	freopen("magolor.out","w",stdout);
	int n,a,ans=0;
	scanf("%d",&n);
	for (int i=1;i<=n<<1;++i) 
	{
		scanf("%s%d",s,&a);
		if (s[0]=='W') w[a]=i;else b[a]=i;
		for (int j=0;j<=n;++j)
		{
			B[i][j]=B[i-1][j]+(a>j&&s[0]=='B');
			W[i][j]=W[i-1][j]+(a>j&&s[0]=='W');
		}
	}
	for (int i=1;i<=n;++i)
		for (int j=i+1;j<=n;++j)
			ans+=(w[j]<w[i])+(b[j]<b[i]);
	memset(f,0x3f,sizeof(f));
	f[0][0]=0;
	for (int i=0;i<=n;++i)
		for (int j=0;j<=n;++j)
		{
			if (!i&&!j) continue;
			if (i) f[i][j]=min(f[i][j],f[i-1][j]+W[b[i]][j]);
			if (j) f[i][j]=min(f[i][j],f[i][j-1]+B[w[j]][i]);
		}
	printf("%d",f[n][n]+ans);
	return 0;
}

Measured memory_bytes: 78464
<?php

$dice = new Dice(explode(' ', trim(fgets(STDIN))));

$orders = str_split(trim(fgets(STDIN)));

foreach ($orders as $order) {
    switch ($order) {
        case 'N':
            $dice->rollN();
            break;
        case 'E':
            $dice->rollE();
            break;
        case 'W':
            $dice->rollW();
            break;
        case 'S':
            $dice->rollS();
            break;
    }
}

echo $dice->top, PHP_EOL;


class Dice
{
    public $sides;
    
    public $top;
    public $bottom;
    public $right;
    public $left;
    public $front;
    public $back;
    
    public function __construct($sides)
    {
        $this->sides = $sides;
        list($this->top, $this->front, $this->right, $this->left, $this->back, $this->bottom) = $sides;
    }
    
     public function rollS()
    {
        $tmp = [$this->front, $this->back, $this->right, $this->left, $this->bottom, $this->top];
        list($this->bottom, $this->top, $this->right, $this->left, $this->back, $this->front) = $tmp;
    }
    
    public function rollN()
    {
        $tmp = [$this->front, $this->back, $this->right, $this->left, $this->bottom, $this->top];
        list($this->top, $this->bottom, $this->right, $this->left, $this->front, $this->back) = $tmp;
    }
    
    public function rollW()
    {
        $tmp = [$this->front, $this->back, $this->right, $this->left, $this->bottom, $this->top];
        list($this->front, $this->back, $this->top, $this->bottom, $this->right, $this->left) = $tmp;
    }
    
    public function rollE()
    {
        $tmp = [$this->front, $this->back, $this->right, $this->left, $this->bottom, $this->top];
        list($this->front, $this->back, $this->bottom, $this->top, $this->left, $this->right) = $tmp;
    }
}





function getStdin()
{
    return trim(fgets(STDIN));
}

function explodeStdin()
{
    return trim(fgets(STDIN));
}

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

int main(){
  string s;
  long long k,ans=0,r=1;cin>>s>>k;
  char c1=s.at(0),c2;

  if(s.size()==1){
   cout<<k/2<<endl;
    return 0;
  }
  for(int i=0;i<s.size()-1;i++){
    c2=s.at(i+1);
    if(c1==c2){
      r++;
      if(i==s.size()-2){
        ans+=r/2;
      }
    }else{
      ans+=r/2;
      r=1;
    }
    c1=c2;
  }
  ans*=k;
  
  if(s.size()>=3 && s.at(0)==s.at(s.size()-1)){
    int j=0,st=1,en=1;
    while(s.at(j)==s.at(j+1)){
      st++;
      j++;
      if(j==s.size()-1) break;
    }
    j=s.size()-1;
    while(s.at(j)==s.at(j-1)){
      en++;
      j--;
      if(j==0) break;
    }
    if((st==en) && (st%2)) ans+=k-1;
  }
    
  long long ii=0;
  while(s.at(ii)==s.at(ii+1)){
    ii++;
    if(ii==s.size()-1){
      ans=(ii+1)*k/2;
      break;
    }
  }

  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 100
int main(){
  int i;
  int j;
  int n;
  int mini;
  int count=0;
  int tmp;
  int A[N];
  scanf("%d",&n);
  for( i=0; i<n; i++ ){
    scanf("%d",&A[i]);
  }
  for( i=0; i<n; i++ ){
    mini = i;
    for( j=i; j<n ; j++ ){
      if( A[j] < A[mini] ){
	mini = j;
      }
    }
    if( mini != i ) count++;
    tmp=A[i];
    A[i]=A[mini];
    A[mini]=tmp;
  }
  for( i=0; i<n; i++ ){
    printf("%d", A[i]);
    if( i<n-1 ) printf(" ");
  }
  printf("\n%d\n",count); 
  return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
const ll INF=1e9+7;
const ll N = 100002;
int n,m,R;
vector<int> r,ju;
int d[201][201];
int ans=INF;

int nagasa(){
	int ans=0;
	FOR(i,1,R){
		ans+=d[r[ju[i]]][r[ju[i-1]]];
	}
	return ans;
}



int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>m>>R;
	FOR(i,0,R)ju.pb(i);
	r.resize(R);
	FOR(i,0,R){
		cin>>r.at(i);
		r[i]--;
	}
	FOR(i,0,201){
		FOR(j,0,201){
			d[i][j]=INF;
		}
	}
	FOR(i,0,m){
		int a,b,c;
		cin>>a>>b>>c;
		a--;b--;
		if(d[a][b]>c){
			d[a][b]=d[b][a]=c;
		}
	}
	FOR(i,0,n){
		FOR(j,0,n){
			FOR(k,0,n){
				if(d[j][k]>d[j][i]+d[i][k])d[j][k]=d[j][i]+d[i][k];
			}
		}
	}
	ans=nagasa();
	do{
		int k=nagasa();
		if(ans>k)ans=k;
	}while(NEXTP(ju));
	pri(ans);
	return 0;
}


Measured memory_bytes: 384
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!int;
    foreach (n; 1..N+1) if (n * (n+1) / 2 == N) {
        writeln("Yes");
        writeln(n+1);
        int[][] res;
        res.length = n+1;
        foreach (ref r; res) r ~= n;
        int x = 1;
        foreach (i; 0..n+1) {
            foreach (j; i+1..n+1) {
                res[i] ~= x;
                res[j] ~= x;
                ++x;
            }
        }
        foreach (r; res) writeln(r.to!(string[]).join(" "));
        return;
    }
    writeln("No");
}

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

using namespace std;

#define INF 1000000000
#define INFLL 0x3f3f3f3f3f3f3f3fLL 
#define EPS 10e-9
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define st first
#define nd second
#define sz(v) int(v.size())
#define all(X) (X).begin(), (X).end()
#define FOR(I, A, B) for(int I = A; I < B; I++)
#define RFOR(I, A, B) for(int I = A; I >= B; I--)

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef vector<iii> viii;
typedef vector<ll> vll;

int main(){
	int n;
	cin >> n;
	set<string> s;
	FOR(i,0,n){
		string r;
		cin >> r;
		s.insert(r);
	}
	cout << sz(s) << endl;
	return 0;
}


Measured memory_bytes: 19080
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pi acos(-1)
const int N=2e5+5;
ll a[N];
    int n;ll k;
ll dis(ll a,ll b){
    return  min(abs(a-b),k-abs(a-b));
}
int main(){
    cin>>k>>n;
    ll s=0;
    for(int i=0;i<n;i++){
            cin>>a[i];
    }
    ll ans=1e6+5;
    for(int i=0;i<n;i++){
         ans=min(ans,k-dis(a[i],a[(i+1)%n]));
    }
    cout<<ans;
}


Measured memory_bytes: 1792
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
//#include<memory>
#include<functional>
#include<cassert>
#include<set>
#include<stack>
#include<random>

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, -1, 0, 1};
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    int n = S.size()-1;
    ll sum = 0;
    for (int s = 0; s < 1<<n; s++) {
        ll tmp = 0;
        int now = 0;
        for (int i = 0; i < n; i++) {
            if ((s>>i)&1) {
                ll plus = stoll(S.substr(now, i+1-now));
                tmp += plus;
                now = i+1;
            }
        }
        tmp += stoll(S.substr(now, n+1-now));
        sum += tmp;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		int tot = 0;
		for(int i=0;i<N;i++) tot ^= A[i];
		int[] ans = new int[N];
		for(int i=0;i<N;i++){
			ans[i] = tot ^ A[i];
		}
		Console.WriteLine(String.Join(" ",ans));
		
		
	}
	int N;
	int[] A;
	public Sol(){
		N = ri();
		A = ria();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 48464
use v5.18; # strict say state
use warnings;
use List::Util qw(reduce first max min sum0);

chomp (my $n = <STDIN>);
chomp (my @a = split / /, <STDIN>);
for my $i (1..($n-1)) {
  $a[$i] = 0 if $a[$i] == $a[$i-1];
}
say scalar grep {$_==0} @a;

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

ll n, ans;
string s;

map < string, bool > a;

inline ll read(){
	ll s = 0, w = 1;
	char ch = getchar();
	for (; ch < '0' || ch > '9'; ch = getchar()) w *= ch == '-' ? -1 : 1;
	for (; ch >= '0' && ch <= '9'; ch = getchar()) s = s * 10 + ch - '0';
	return s * w;
}

inline void work(){
	n = read();
	REP(i, 1, n) cin >> s, a[s] < 1 ? ans++, a[s] = 1 : ans = ans;
	printf("%lld\n", ans);
}

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

Measured memory_bytes: 19280