akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    rep(i, n) cin >> x[i] >> y[i];

    vector<int> nums(n);
    rep(i, n) nums[i] = i;
    ld sum = 0;
    ld cnt = 0;
    do {
        rep(i, n -1) {
            ld dx = x[nums[i]] - x[nums[i+1]];
            ld dy = y[nums[i]] - y[nums[i+1]];
         //   cout << dx << " " << dy << endl;
            ld dist = sqrtl(dx * dx + dy * dy);
            sum += dist;
        }
        cnt ++;
    } while (next_permutation(nums.begin(), nums.end()));
    printf("%.10Lf\n", sum / cnt);
    return 0;
}

Measured memory_bytes: 3736
//abc047_a.cpp
//Fri Oct 19 22:41:15 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	int a,b,c;
	cin >> a >> b >> c;

	if (a+b == c || a+c == b || b+c == a){
		cout << "Yes" << endl;
	}else {
		cout << "No" << endl;
	}

}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
char s[200010];
int main(){
	int i,ans=0,n;
	scanf("%s",s+1);
	n=strlen(s+1);
	for(i=1;i<=n;i++)ans+=s[i]-'0';
	if(ans%9)printf("No\n");
	else printf("Yes\n");
return 0;
}

Measured memory_bytes: 1836
n = int(input())
li=[list(map(int,input().split())) for _ in range(n-1)]
for i in range(n-1):
    ans=li[i][1]+li[i][0]
    for j in range(i+1,n-1):
        if ans>=li[j][1]:
            if ans%li[j][2]==0:
                ans+=li[j][0]
            else:
                ans=(ans//li[j][2]+1)*li[j][2]+li[j][0]
        else:
            ans=li[j][1]+li[j][0]
    print(ans)
print("0")

Measured memory_bytes: 3188
package main

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

func main() {
	S := sc.next()
	prev := ""
	SArr := strings.Split(S, "")
	for _, v := range SArr {
		if v == prev {
			fmt.Println("Bad")
			return
		}
		prev = v
	}
	fmt.Println("Good")
}

var (
	sc scanner
)

func init() {
	sc = scanner{
		buf: make([]string, 0, 0),
		cur: 0,
		r:   bufio.NewReader(os.Stdin),
	}
}

type scanner struct {
	buf []string
	cur int
	r   *bufio.Reader
}

func (s *scanner) readln() {
	rbuf := make([]byte, 0, 0)
	for {
		line, prefix, err := s.r.ReadLine()
		if err != nil {
			panic(err)
		}
		rbuf = append(rbuf, line...)
		if prefix == false {
			break
		}
	}
	s.cur = 0
	s.buf = strings.Split(*(*string)(unsafe.Pointer(&rbuf)), " ")
}
func (s *scanner) isFull() bool {
	if s.cur == len(s.buf) {
		return true
	}
	return false
}
func (s *scanner) resetCur() {
	s.cur = 0
}
func (s *scanner) next() string {
	if s.cur == 0 {
		s.readln()
	}
	res := s.buf[s.cur]
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nexts() []string {
	s.readln()
	s.resetCur()
	return s.buf
}
func (s *scanner) nextInt() int {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.Atoi(s.buf[s.cur])
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nextInts() []int {
	s.readln()
	res := make([]int, len(s.buf))
	for i := range s.buf {
		res[i], _ = strconv.Atoi(s.buf[i])
	}
	s.resetCur()
	return res
}
func (s *scanner) nextFloat() float64 {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.ParseFloat(s.buf[s.cur],
		64)
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nextFloats() []float64 {
	s.readln()
	res := make([]float64, len(s.buf))
	for i := range s.buf {
		res[i], _ = strconv.ParseFloat(s.buf[i],
			64)
	}
	s.resetCur()
	return res
}
func digits(x int) int {
	return len(strconv.Itoa(x))
}
func powInt(x, p int) (result int) {
	result = 1
	for i := 0; i < p; i++ {
		result *= x
	}
	return
}
func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}
func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}
func abs(x int) int {
	return int(math.Abs(float64(x)))
}
func varDump(value ...interface{}) {
	for _, v := range value {
		fmt.Fprintf(os.Stderr, "%#v\n", v)
	}
}
func yes() {
	fmt.Println("Yes")
}
func no() {
	fmt.Println("No")
}

// Pair a
type Pair struct {
	first  int
	second int
}

// Queue a
type Queue struct {
	v []Pair
}

// Push for queue
func (q *Queue) Push(v Pair) {
	q.v = append(q.v, v)
}

// Pop for queue
func (q *Queue) Pop() Pair {
	r := q.v[0]
	q.v = q.v[1:]
	return r
}

// Front for queue
func (q Queue) Front() Pair {
	return q.v[0]
}

// Empty return true if empty
func (q Queue) Empty() bool {
	return len(q.v) == 0
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int MOD = 1e9+7;
const double EPS = 1.0e-10;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int get(int num){
	int ret = 0;
	while(num) {
		num /= 10;
		ret++;
	}
	return ret;
}

int main(){
	int n;
	cin >> n;
	ll cnt[10][10] = {};
	for(int i = 1; i <= n; i++){
		int front = i/pow(10,get(i)-1);
		int back = i%10;
		cnt[front][back]++; 
	}
	ll ans = 0;
	for(int i = 1; i <= 9; i++){
		for(int j = 1; j <= 9; j++){
			ans += cnt[i][j]*cnt[j][i];
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
n, m = map(int, input().split())
ps_list = [list(input().split()) for _ in range(m)]

ans_dic = {}
pen_dic = {}
for ps in ps_list:
    p = int(ps[0])
    ans_dic[p] = 0
    pen_dic[p] = 0
ans = 0
pen = 0

for ps in ps_list:
    p, s = ps
    p = int(p)
    if s == 'AC':
        if ans_dic[p] == 0:
            ans += 1
            pen += pen_dic[p]
        ans_dic[p] = 1
    elif s == 'WA':
        pen_dic[p] += 1

print(ans, pen)

Measured memory_bytes: 44184
/**
 * Shell Sort
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_2_D&lang=ja
 */

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int cnt = 0;

/**
 * 現在の並び替え状態を出力する
 */
void trace(vector <int>A) {
  int size = A.size();
  for (int i = 0; i < size; i++) {
    cout << A.at(i);
    if (i < size - 1) {
      cout << ' ';
    }
  }

  cout << endl;
}

vector <int>insertionSort(vector <int>A, int N, int g) {
  /**
   * insertionSort(A, n, g)
   *   for i = g to n-1
   *     v = A[i]
   *     j = i - g
   *     while j >= 0 && A[j] > v
   *       A[j+g] = A[j]
   *       j = j - g
   *       cnt++
   *     A[j+g] = v
   */
  for (int i = g; i < N; i++) {
    int v = A.at(i);
    int j = i - g;
    while (j >= 0 && A.at(j) > v) {
      A.at(j + g) = A.at(j);
      // cout << "途中経過 ";
      // trace(A);
      j = j - g;
      cnt++;
    }
    A.at(j + g) = v;
  }

  return A;
}

vector <int>shellSort(vector <int>A, int N) {
  /**
   * shellSort(A, n)
   *   cnt = 0
   *   m = ?
   *   G[] = {?, ?,..., ?}
   *   for i = 0 to m-1
   *     insertionSort(A, n, G[i])
   */
  vector <int>G;

  // 3倍した値に1を加える
  for (int h = 1; h < N; h = 3 * h + 1) {
      G.push_back(h); 
  }

  // Nが1でも、1回はソートすること
  if (G.size() == 0) {
    G.push_back(1);
  }

  // 小さい値から加えていったため、逆順にする必要がある
  std::reverse(G.begin(), G.end());

  // 選択ソートを実行する
  int m = G.size();
  for (int i = 0; i < m; i++) {
    A = insertionSort(A, N, G.at(i));
  }
  
  // 結果の出力
  cout << m << endl;
  trace(G);
  cout << cnt << endl;
  int size = A.size();
  for (int i = 0; i < size; i++) {
    cout << A.at(i) << endl;
  }
 
  return A;
}

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

  vector <int>A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  //trace(A);

  vector <int>B = shellSort(A, N);
  //trace(B);

  return 0;
}




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

using namespace std;

int abs(int x){
	if(x >0)
		return x;

	else return -x;
}

int main()
{
	int n;
	cin>>n;
	int k;
	cin>>k;
	int a[n];

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

	int dp[n];
	dp[0]=0;

	for(int i=1;i<n;i++){
		int t=i-1;
		int mini=INT_MAX;
		while(t>-1 && t>=i-k){
			mini = min(mini, dp[t] + abs(a[i]-a[t]));
			t--;
		}
		dp[i] = mini;
	}

	cout<<dp[n-1]<<endl;

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <map>
#include <queue>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N, M, A[100], sum = 0;
    cin >> N >> M;
    REP(i, N) {
        cin >> A[i];
        sum += A[i];
    }
    sort(A, A + N, greater<int>());
    bool ok = true;
    REP(i, M) {
        ok &= sum <= 4 * M * A[i];
    }
    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<lint, int> P;

struct edge{int to; lint cost;};
const int MAX_N = 1e5;
const lint INF = 1e18;
int N;
vector<edge> G[MAX_N+5];
lint d[MAX_N+5];

void dijkstra(int s){
    priority_queue<P, vector<P>, greater<P>> pq;
    fill(d, d+N+1, INF); d[s] = 0;
    pq.push(P(0, s));

    while(pq.size()){
        P p = pq.top(); pq.pop();
        int v = p.second;
        if(d[v]<p.first) continue;
        for(int i=0;i<G[v].size();i++){
            edge e = G[v][i];
            if(d[v]+e.cost<d[e.to]){
                d[e.to] = d[v] + e.cost;
                pq.push(P(d[e.to], e.to));
            }
        }
    }
}

int main(){
    cin >> N;
    for(int i=0;i<N-1;i++){
        int a, b; lint c; cin >> a >> b >> c;
        edge e1; e1.to = b; e1.cost = c;
        edge e2; e2.to = a; e2.cost = c;
        G[a].push_back(e1); G[b].push_back(e2);
    }

    int q, k; cin >> q >> k;
    dijkstra(k);

    for(int i=0;i<q;i++){
        int x, y; cin >> x >> y;
        printf("%lld\n", d[x]+d[y]);
    }

    return 0;
}

Measured memory_bytes: 11120
#include <bits/stdc++.h>
#define REP(i, n) for (int i=0;i<(n);i++)
#define ALL(v) v.begin(), v.end()
#define INF 1e9
#define ll long long
#define P pair<ll, ll>

using namespace std;


void solve(std::string S){
    ll cnt0 = 0;
    ll cnt1 = 0;
    REP(i, S.length()){
        if (S[i] == '0') cnt0++;
        else cnt1++;
    }
    ll ans = 2*min(cnt0, cnt1);
    cout << ans << endl;
}

// 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 S;
    std::cin >> S;
    solve(S);
    return 0;
}


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

typedef long long ll;

int main(void)
{
    int a, b, x;
    cin >> a >> b >> x;
        
    if(a <= x && a + b >= x) puts("YES");
    else puts("NO");

    
    return 0;
}

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

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	while(1) {
		c -= b;
		if(c <= 0) {
			cout << "Yes" << endl;
			break;
		}
		a -= d;
		if(a <= 0) {
			cout << "No" << endl;
			break;
		} 
	}
}

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

int main() {
  int n; 
  cin >> n;
  vector<int>a(n);
  rep(i,n){
    cin>>a.at(i);
  }
  int ans=0;
  rep(i,n-1){
    if(a.at(i)==a.at(i+1)){
      ans++;
      a.at(i+1)=-1;
    }
  } 
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import sys
import collections
import itertools
import math
import re
from collections import Counter
from collections import deque

MOD = 10 ** 9 + 7

N, M = [int(x) for x in input().split()]

PYC = []
for i in range(M):
    p, y = [int(x) for x in input().split()]
    PYC.append((p, y, i))

PYC = sorted(PYC)

city = {}

pCount = 1
preP = -1
for p, y, c in PYC:
    if preP != p:
        pCount = 1
    city[c] = (p, pCount)
    pCount += 1
    preP = p

for i in range(M):
    print("{:06d}{:06d}".format(city[i][0], city[i][1]))


sys.exit(0)


Measured memory_bytes: 38652
#include <stdio.h>
#include <string.h>
#include <stdbool.h>

int main() {
	int i, cs, ccont = 0, ocont = 0;
	char S[11];
	bool flag = false;

	scanf("%s", S);

	if (S[0] == 'A') {				// 頭文字 'A' チェック
		for (i = 2; i < strlen(S) - 1; i++) {
			if (S[i] == 'C') {
				ccont++;
				cs = i;
			}
		}
		if (ccont == 1) {			// 'C' チェック
			for (i = 0; i < strlen(S); i++) {
				if (i != 0 && cs != i && S[i] < 97) 
					ocont++;
			}
			if (ocont == 0) {		// 小文字チェック
				flag = true;
			}
		}
	}

	printf(flag == true ? "AC\n" : "WA\n");

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;
#define ll long long

int main() {
    ll n, a = 1073741824;
    cin >> n;
    vector<ll> numbers(n);
    bool possible = true;
    for(auto &i: numbers) {
        cin >> i;
        if(i % 2) possible = false;
    }
    if(possible) {
        for(auto &i: numbers) {
            while(i % a != 0) a /= 2;
        }
        cout << (ll) (log(a)/log(2)) << endl;
    } else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M;
  cin >> N >> M;
  
  vector<int>X(M);
  for (int i = 0; i < M; i++) {
    cin >> X.at(i);
  }
  sort(X.begin(), X.end());
  
  vector<int>Y(M-1);
  for (int i = 0; i < M-1; i++) {
    Y.at(i) = X.at(i+1) - X.at(i);
  }
  sort(Y.begin(), Y.end());
  int sum = 0;
  for (int i = 0; i < M-N; i++) {
    sum += Y.at(i);
  }
  cout << sum << endl;
}
  
  
  
  

Measured memory_bytes: 3980
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = s.size();
    int ans = n * (n - 1) / 2 + 1;
    int d[26] = {};
    rep(i, 0, s.size()){
        d[s[i] - 'a']++;
    }
    rep(i, 0, 26){
        ans -= d[i] * (d[i] - 1) / 2;
    }
    cout << ans << endl;
}

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

using pint = pair<int,int>;
vector<vector<pint>> input;

vector<int> integer_to_vector(int bit, int n){
    vector<int> S;
    for(int i=0;i<n;i++){
        if(bit & (1<<i)){
            S.push_back(i);
        }
    }
    return(S);
}

void print_element(vector<int> S){
    for(int i=0;i<S.size();i++){
        cout << S.at(i) << " ";
    }
    cout << endl;
}

int count(int bit, int N){
  int cnt=0;
  for(int i=0;i<N;i++){
    if( (bit & 1<<i) == 1){
      cnt++;
    }
  }
  
  return(bit);
}

bool judge(int bit,int N){
  for(int i=0;i<N;i++){
    if(!(bit & 1<<i)){
      continue;
    }
    
    for(pint xy : input[i]){
      int x,y;
      x = xy.first;
      y = xy.second;
      if( !(bit & 1<<x) && y == 1){
        return false;
      }
      if( (bit & 1<<x) && y == 0){
        return false;
      }
    }
  }
    
  return true;
}

int main(){
  int N;
  cin >> N;
  input.resize(N);
  for(int i=0;i<N;i++){
    int A;
    cin >> A;
    input[i].resize(A);
    for(int j=0;j<A;j++){
      int x,y;
      cin >> input[i][j].first >> input[i][j].second;
      input[i][j].first--;
    }
  }
  
  int res=0;
  for(int bit=(1<<N)-1;bit>=0;bit--){
    int num=0;
    if(judge(bit,N)){
      for(int i=0;i<N;i++){
        if(bit & 1<<i){
          num++;
        }
      }
    }
    if(res < num){
      res = num;
    }
  }
  
  cout << res << endl;
  
  return(0);
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a=0,b=0,c=0,d=0,e=0,f=0,t1=0,t2=0;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&d);
	scanf("%d",&e);
	scanf("%d",&f);
	if(a <= b && a<= c && a<= d){
		t1 = b + c + d;
	}
	if(b <= a && b <= c && b<= d){
		t1= a + c + d;
	}
	if(c <= a && c<= b && c <= d){
		t1 =a + b + d;
	}
	if(d <= a && d <= b && d<= c){
		t1 = a + b + c;
	}
	if(e<f){
		t2 = f;
	}
	else{
		t2 = e;
	} 
	printf("%d\n",t1+t2);
	return 0;
}


Measured memory_bytes: 2064
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MOD2 998244353
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}
ll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll mod(ll n){return n%=MOD1;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{ ll a , b;}fr;
int cmp1( const void *p, const void *q ) { return ((fr*)p) ->a - ((fr*)q)->a;}
int cmp2( const void *p, const void *q ) { return ((fr*)q) ->a - ((fr*)p)->a;}
void strsortup(fr*a,int n){qsort(a,n,sizeof(fr),cmp1);}
void strsortdown(fr*a,int n){qsort(a,n,sizeof(fr),cmp2);}

ll reach[10]={};
ll dfs(ll n, ll adj[n][n], ll cur){
    ll ans=0;
    rep(i,0,n){
        if(reach[i]==0 && i!=cur){
            break;
        }
        if(i==n-1) return 1;
    }
    reach[cur]=1;
    rep(i,0,n){
        if(adj[cur][i]){
            if(reach[i]==0) ans+=dfs(n,adj,i);

        }
    }
    reach[cur]=0;
    return ans;
}

int main(void){
    // char ;
    ll n,m;
    scanf("%lld%lld",&n,&m);
    ll a[m],b[m],adj[n][n];
    rep(i,0,n) rep(j,0,n) adj[i][j]=0;
    rep(i,0,m){
        scanf("%lld%lld",&a[i],&b[i]);
        adj[a[i]-1][b[i]-1]=1;
        adj[b[i]-1][a[i]-1]=1;
        // adj[a[i]-1][n]++;
        // adj[b[i]-1][n]++;
    }
    printf("%lld\n",dfs(n,adj,0));
    return 0;
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC_D
{
    class D072
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] p = Console.ReadLine().Split(' ').Select(z => int.Parse(z)).ToArray();

            int counter = 0;
            for(int i = 0; i < N; i++)
            {
                int id = i + 1;
                if (p[i] == id)
                {
                    if (i == N - 1) swap(p, i, i - 1);
                    else swap(p, i, i + 1);
                    counter++;
                }
            }
            Console.WriteLine(counter);
        }

        static void swap(int[] p, int i, int j)
        {
            int z = p[i];
            p[i] = p[j];
            p[j] = z;
        }

    }
}


Measured memory_bytes: 20064
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	LL n;
	cin>>n;
	if(n<=9){
		cout<<n<<endl;
		return 0;
	}
	LL t=n;
	int f=0,c=0;
	while(t!=0){
		c++;
		if(t/10==0)break;
		if(t%10!=9){
			f=1;
		}
		if(t/10==0)break;
		else t/=10;
	}
	//cout<<c<<" "<<t<<endl;
	if(f==0){
		cout<<t+(c-1)*9<<endl;
	}else{
		cout<<(t-1)+(c-1)*9<<endl;
	}
    return 0;
}


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

using namespace std;

int main(int argc, const char *argv[]) {
  int a, b, c;
  cin >> a >> b >> c;
  int mx = max({a, b, c});
  int diff = (mx - a) + (mx - b) + (mx - c);
  if (diff % 2 == 1) {
    diff += 3;
  }

  cout << diff / 2 << '\n';
  return 0;
}

Measured memory_bytes: 3640
"""
N = list(map(int,input().split()))
S = [str(input()) for _ in range(N)]
S = [list(map(int,list(input()))) for _ in range(h)] 
print(*S,sep="")
"""

import sys
sys.setrecursionlimit(10**6)
input = lambda: sys.stdin.readline().rstrip()

s = list(map(int,input()))
print(sum(s))

# メモ
# sに入力を一文字ずつ配列に入れ、それの合計を出した

Measured memory_bytes: 2940
import sys
sys.setrecursionlimit(300000)
from collections import defaultdict
 
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')
 
 
N = I()
S = input()

# N = 39
# S = 'RBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBB'
 
d = defaultdict(int)
for c in S:
    d[c] += 1
plus = d['R'] * d['G'] * d['B']

# print(plus)
 
minus = 0
for j in range(1, N - 1):
    for l in range(1, N):
        i, k = j - l, j + l
        if i < 0 or k > N - 1:
            break
        if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
            minus += 1
 
print(plus - minus)

Measured memory_bytes: 68644
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder.Question
{
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            var x = ReadHelper.ReadValues<int>();
            Console.WriteLine(x.Select((x, i) => (x, i)).First(x => x.x == 0).i + 1);
        }

        static class ReadHelper
        {
            internal static T ReadValue<T>()
            {
                return (T)Convert.ChangeType(Console.ReadLine(), typeof(T));
            }
            internal static (T1, T2) ReadValue<T1, T2>()
            {
                var input = Console.ReadLine().Split(' ');
                return ((T1)Convert.ChangeType(input[0], typeof(T1)), (T2)Convert.ChangeType(input[1], typeof(T2)));
            }
            internal static (T1, T2, T3) ReadValue<T1, T2, T3>()
            {
                var input = Console.ReadLine().Split(' ');
                return ((T1)Convert.ChangeType(input[0], typeof(T1)), (T2)Convert.ChangeType(input[1], typeof(T2)), (T3)Convert.ChangeType(input[2], typeof(T3)));
            }
            internal static (T1, T2, T3, T4) ReadValue<T1, T2, T3, T4>()
            {
                var input = Console.ReadLine().Split(' ');
                return ((T1)Convert.ChangeType(input[0], typeof(T1)), (T2)Convert.ChangeType(input[1], typeof(T2)), (T3)Convert.ChangeType(input[2], typeof(T3)), (T4)Convert.ChangeType(input[3], typeof(T4)));
            }
            internal static T[] ReadValues<T>()
            {
                var input = Console.ReadLine().Split(' ');
                return input.Select(x => (T)Convert.ChangeType(x, typeof(T))).ToArray();
            }
        }

        static class MathAlgorithm
        {
            internal static bool IsPrime(long n)
            {
                if (n == 2) return true;
                if (n < 2 || n % 2 == 0) return false;
                var sqrt = Math.Sqrt(n);
                for (int i = 3; i <= sqrt; i += 2) if (n % i == 0) return false;
                return true;
            }
            internal static IEnumerable<long> EnumeratePrimes(long n)
            {
                var i = 2L;
                while (i * i <= n)
                {
                    if (n % i == 0)
                    {
                        n /= i;
                        yield return i;
                    }
                    else
                    {
                        i += i == 2 ? 1 : 2;
                    }
                }
                if (n != 1) yield return n;
            }
        }
    }
}


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

int table[102][102];

int main() {
	int r, c;
	cin >> r >> c;
	for (int i = 0; i < r; ++i) {
		for (int i2 = 0; i2 < c; ++i2) {
			cin >> table[i][i2];
		}
	}

	int lsum = 0;
	for (int i = 0; i < r; ++i) {
		int sum = 0;
		for (int i2 = 0; i2 < c; ++i2) {
			cout << table[i][i2] << ' ';
			sum += table[i][i2];
		}
		cout << sum << endl;
		lsum += sum;
	}

	for (int i2 = 0; i2 < c; ++i2) {
		int sum = 0;
		for (int i = 0; i < r; ++i) {
			sum += table[i][i2];
		}
		cout << sum << ' ';
	}

	cout << lsum << endl;

	return 0;
}

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

int main(){
    ll n;   cin >> n;
    vector<ll> a(n);
    for(int i=0; i<n-1; i++){
        ll x;   cin >> x;
        a.at(x-1) += 1;
    }
    for(int i=0; i<n; i++)
        cout << a.at(i) << endl;

}

Measured memory_bytes: 4756
import java.util.*;
import java.math.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int l = s.length();
		int N = 0;
		int S = 0;
		int E = 0;
		int W = 0;
		String mozi = null;
		
		for (int i = 0; i < l; i++) {
			if (i != l - 1) {
				mozi = s.substring(i, i+1);
			} else {
				mozi = s.substring(i);
			}
			if (mozi.equals("N")) {
				N++;
			} else if (mozi.equals("S")) {
				S++;
			} else if (mozi.equals("E")) {
				E++;
			} else {
				W++;
			}
		}
		
		if ((N == 0 && S > 0) || (N > 0 && S == 0) || (W == 0 && E > 0) || (W > 0 && E == 0)) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}
	}
}


Measured memory_bytes: 9428
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int , int>
#define fast ios_base::sync_with_stdio(0)
#define mx 100005
#define inf 100000000000000000LL
ll arr[mx], dp[mx];
int main()
{
    int n;
    while(scanf("%d",&n)){
        for(int i=1; i<=n; i++)
            scanf("%lld",&arr[i]);
        dp[n] = 0;
        dp[n-1] = llabs(arr[n] - arr[n-1]);
        for(int i = n-2; i>=1; i--)
            dp[i] = min(dp[i+1] + llabs(arr[i]-arr[i+1]), dp[i+2] + llabs(arr[i] - arr[i+2]));
        printf("%lld\n", dp[1]);
        return 0;
    }
}



Measured memory_bytes: 1792
N, L = map(int, input().split())

abs_tastes = []
tastes = []
for i in range(1, N + 1):
    taste = L + i - 1
    abs_tastes.append(abs(taste))
    tastes.append(taste)
min_taste = min(abs_tastes)
argmin = abs_tastes.index(min_taste)
sum_taste = sum(tastes)
print(sum_taste - tastes[argmin])

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

namespace mondai0021
{
	class Program
	{
		static void Main(string[] args)
		{
			var	n	= int.Parse( Console.ReadLine() );
			for( int i = 0; i < n; i++ ) {
				var	v	= Array.ConvertAll( Console.ReadLine().Split(), vv => double.Parse( vv ) );
				var	x1	= v[ 2 ] - v[ 0 ];
				var	y1	= v[ 3 ] - v[ 1 ];
				var	x2	= v[ 6 ] - v[ 4 ];
				var	y2	= v[ 7 ] - v[ 5 ];
				var	cross	= x1 * y2 - y1 * x2;
				if( cross == 0.0 ) {
					Console.WriteLine( "YES" );
				} else {
					Console.WriteLine( "NO" );
				}
			}
		}
	}
}

Measured memory_bytes: 5700
n    = gets.to_i
info = []

n.times do
  x, y, h = gets.split.map(&:to_i)
  if h > 0
    info << [x, y, h]
  end
end

n = info.size
if n == 1
  puts [info[0][0], info[0][1], info[0][2]].join(" ")
else
  for prex in 0 .. 100
    for prey in 0 .. 100
      preh = info[0][2] + (prex - info[0][0]).abs + (prey - info[0][1]).abs
      for i in 1 .. n - 1
        if preh - (prex - info[i][0]).abs - (prey - info[i][1]).abs != info[i][2]
          break
        elsif i == n - 1
          puts [prex, prey, preh].join(" ")
          exit
        end
      end
    end
  end
end


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


#define NITEM(arr) (sizeof(arr)/sizeof(arr[0]))


typedef int (*cmp_t)(const void *, const void *);


int main(void)
{
	int X, i;

	while(scanf("%d", &X)==1)
	{
		for(i=1;i*(i+1)/2<X;i++)
			;
		printf("%d\n", i);
	}

	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define pb push_back
#define ss second
#define ff first
#define all(x) x.begin(), x.end()
#define INF 300000000000001
#define ll_max 9000000000000000000
#define PI 3.14159265358979323846L
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define db(args...) {string _ss = #args; replace(_ss.begin(), _ss.end(), ',' , ' '); stringstream ___s(_ss) ; debug(___s, args);}
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<pair<ll,ll> > vll;
typedef vector<int> vi;
typedef pair<ll,ll> pll;
const ll mod = 1000000007;
const ll N = 1001;
const ll M = log2(N);

struct point {
    ll x, y, i;
    bool operator == (const point b)
    {
        if(this -> x == b.x && this -> y == b.y) return 1;
        return 0;
    }
    bool operator != (const point b) {return !(*this == b);}
    friend bool operator < (const point a, const point b)
    {
        if(a.x != b.x)
            return a.x < b.x;
        return a.y < b.y;
    }
};

void debug(stringstream &s){}
template <typename T, typename... Args>
void debug(stringstream &s, T a, Args... args)
{
    string word;
    s >> word;
    cerr << word << " = " << a << endl;
    debug(s, args...);
}
bool overflow;
ll fast_exp(ll x, ll n)
{
    if(n == 0) return 1;
    ll ans;
    if(n % 2 == 0)
    {
         ans = fast_exp(x, n / 2);
         if(ans > ans * ans % mod)
                overflow = 1;
         ans = ans * ans % mod;
    }
    else
    {
        ans = fast_exp(x, n - 1);
        if(ans > ans * x % mod)
            overflow = 1;
        ans = ans * x % mod;
    }
    return ans;
}

vector<int> adj[N];

int main()
{
    fast;
    int _ = 1;
    //cin >> _;
    while(_--)
    {
        ll n = 0, m = 0, x = 0, y = 0, ans = 1, k;
        cin >> n;
        ans = n % 1000;
        if(ans > 0)
            ans = 1000 - ans;
        cout << ans << "\n";
    }
    return 0;
}


Measured memory_bytes: 3672
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n,i,j,cut=0,flag=1;
	int A[101];
	cin>>n;
	for(i=0;i<n;i++){
		cin>>A[i];
	}
	while(flag==1){
		flag=0;
		for(j=n-1;j>0;j--){
			if(A[j-1]>A[j]){
				swap(A[j-1],A[j]);
				cut++;
				flag=1;
			}
		}
	}
	for(i=0;i<n;i++){
		if(i!=0){
			cout<<" ";
		}
		cout<<A[i];
	}
	cout<<endl;
	cout<<cut<<endl;
	return 0;
}

Measured memory_bytes: 3104
#include<bits/stdc++.h>
#define MAXN 100005
#define MOD 1000000007
using namespace std ;	int n ;
int a[MAXN], f[MAXN] ;

int main() {
	scanf("%d",&n) ;
	for (int i=1; i<=n; ++i)	scanf("%d",a+i) ;
	int mx = -1 ;
	for (int i=1; i<=n; ++i) {
		if ( a[i] >= mx + 2 )
			f[i] = f[i-1] + 1, ++++mx ;	
		else	f[i] = f[i-1] ;
	}

	long long ans = 1 ;
	for (int i=1; i<=n; ++i) {
		int k = i - 1 - f[i-1] ;
		if ( k <= 0 )	( ans *= i ) %= MOD ;
		else	( ans *= ( i - k ) ) %= MOD  ;
	}
	
	printf("%lld\n",ans) ;

	return 0 ;
}


Measured memory_bytes: 1024
N,M=map(int,input().split())
if N<=1 and M<=1:
  print(0)
elif N<=1:
  print(M*(M-1)//2)
elif M<=1:
  print(N*(N-1)//2)
else:
  print(N*(N-1)//2+M*(M-1)//2)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int a[100005];
bool cmp(int x,int y)
{
    return x>y;
}
int main()
{
   //freopen("t5.in","r",stdin);
   //freopen("t5.out","w",stdout);
   //ios::sync_with_stdio(false);
   //cin.tie(0); cout.tie(0);
    int i,j,n,m;
    cin>>n>>m;
    int sum=0;
    for(i=0;i<n;i++)cin>>a[i],sum+=a[i];
    sort(a,a+n,cmp);
    if(a[m-1]*4*m>=sum)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <queue> 
#include <cctype> 
#include <climits> 
#include <stack> 
#include <map> 
#include <cstring> 
#include <numeric>

using namespace std; 

const long long mod=1e9+7;

int main(){

    int a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
};
    int k;
    cin>>k;

    cout<<a[k-1]<<endl;
    return 0;
}

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

vector<int> C(26, 0); // C[i]
vector<vector<int> > S(365, vector<int>(26, 0)); // S[d][i]
int D;
int N;

int score(vector<int> V) {
	vector<int> c = C;
	int s = 0;
	for (int d = 0; d < D; d++) {
		c[V[d]] = 0;
		s += S[d][V[d]];
		s -= accumulate(c.begin(), c.end(), 0);
		for (int i = 0; i < N; i++) {
			c[i] += C[i];
		}
	}
	return s;
}

int main() {
	cin >> D;
	N = 26;
	for (int i = 0; i < N; i++) {
		cin >> C[i];
	}
	for (int d = 0; d < D; d++) {
		for (int i = 0; i < N; i++) {
			cin >> S[d][i];
		}
	}
	vector<int> V(D, 0);
	for (int d = 0; d < D; d++) {
//		cin >> V[d];
//		V[d]--;
		int i = 0;
		for (int j = 1; j < N; j++) {
			if (S[d][i] < S[d][j]) i = j;
		}
		V[d] = i;
	}
	random_device seed_gen;
	mt19937 engine(seed_gen());
	uniform_real_distribution<> dist1(0.0, 1.0);

	vector<int> newV = V;
//	cout << "cur " << score(V);
//	for (int d = 0; d < D; d++) { cout << " " << V[d]+1; }
//	cout << endl;
	int ms = score(V);
	for (int j = 0; j < 10000; j++) {
		newV = V;
		for (int k = 0; k < 1; k++) {
			newV[int(dist1(engine) * D)] = int(dist1(engine) * N);
		}
		int ns = score(newV);
//		cout << "new " << ns;
//		for (int d = 0; d < D; d++) { cout << " " << newV[d]+1; }
//		cout << endl;
		if (ms < ns) V = newV;
	}

	for (int d = 0; d < D; d++) {
		cout << V[d] + 1 << endl;
	}
	return(0);
}


Measured memory_bytes: 3684
#include<stdio.h>

int main(){
  int n, k, l[50];
  int i, j, t, res;
  
  scanf("%d%d", &n, &k);

  for(i=0; i<n; i++){
    scanf("%d", &l[i]);
  }

  for(i=0; i<n-1; i++){
    for(j=i+1; j<n; j++){
      if(l[i]<l[j]){
	t=l[i];
	l[i]=l[j];
	l[j]=t;
      }
    }
  }

  res=0;
  for(i=0; i<k; i++){
    res+=l[i];
  }
  
  printf("%d\n", res);
  
  return 0;
}


Measured memory_bytes: 128
using System;
using System.Linq;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Net.NetworkInformation;

namespace ConsoleApp5
{
    class Program
    {

        static void Main(string[] args)
        {
            var nm = System.Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            UnionFind unionFInd = new UnionFind(nm[0]);
            var numbers = System.Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            for (int i = 0; i < nm[1]; i++)
            {
                var xy = System.Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
                unionFInd.Union(xy[0], xy[1]);
            }

            int count = 0;

            for(int i = 0; i < numbers.Length; i++)
            {
                if(unionFInd.Some(i+1, numbers[i])){
                    count++;
                }
            }

            Console.WriteLine(count);
        }
    }

    public class UnionFind
    {
        int[] Parents { get; set; }
        int[] Rank { get; set; }
        public UnionFind(int n)
        {
            Parents = new int[n+1];
            Rank = new int[n+1];
            for (int i = 1; i < n; i++)
            {
                Parents[i] = i;
                Rank[i] = 0;
            }
        }

        public int Find(int x)
        {
            if(Parents[x] == x)  return x;

            Parents[x] = Find(Parents[x]);
            return Parents[x];
        }


        public void Union(int x, int y)
        {
            var rx = Find(x);
            var ry = Find(y);
            if (rx == ry) return;
            if(Rank[rx] < Rank[ry])
            {
                Parents[rx] = ry;
            }
            else { 
                Parents[ry] = rx;
                if (Rank[rx] == Rank[ry]) Rank[rx]++;
            }
        }

        public bool Some(int x, int y)
        {
            return Find(x) == Find(y);
        }
    }
}


Measured memory_bytes: 48504
#include <bits/stdc++.h>
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define sort(a) sort((a).begin(),(a).end())
#define rev(a) reverse((a).begin(),(a).end())
using db = double;
using namespace std;
typedef long long ll;


int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  cout << ceil((double(n)-1)/(k-1)) << endl;
}


Measured memory_bytes: 640
#include <stdio.h>
int main(void){
    int i,cnt,K;
    char S[100];
    scanf("%d",&K);
    scanf("%s",S);
    for(cnt=0;S[cnt] != '\0';cnt++){}
    if(cnt<=K){
        printf("%s\n",S);
    }else{
        for(i=0;i<K;i++){
            printf("%c",S[i]);
        }
        printf("...\n");
    }
    return 0;
}

Measured memory_bytes: 1660
n, k, q = gets.split.map(&:to_i)
as = []
aaa = Array.new(n, k-q)
q.times do
  a = gets.to_i - 1
  aaa[a] += 1
end
aaa.each do |aa|
  if aa > 0
    puts 'Yes'
  else
    puts 'No'
  end
end

Measured memory_bytes: 3196
#include<stdio.h>
#include<math.h>
#include<string.h>

#define xam(x,y) (x>y?x:y)
int turaras[100000],times[100000],n,l;

int solve(int i){
	if(times[i]!=-1)return times[i];
	int time=0;
	if(turaras[i]<turaras[i-1]&&i>0){
		time=solve(i-1);		
	}
	if(turaras[i]<turaras[i+1]&&i<n-1){
		time=xam(time,solve(i+1));		
	}	
	return times[i]=time+l-turaras[i];
}

int main(){
	int i;
	scanf("%d%d",&n,&l);
	memset(times,-1,sizeof(times));
	for(i=0;i<n;i++){
		scanf("%d",turaras+i);	
	}
	int max=0;
	for(i=0;i<n;i++){
		max=xam(max,solve(i));	
	}
	printf("%d\n",max);
return 0;
}

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



class Program
{
    public void Proc()
    {
        Reader.IsDebug = false;
        int inputCount = int.Parse(Reader.ReadLine());
        Dictionary<long, int> list = new Dictionary<long, int>();
        for(int i=0; i<inputCount; i++) {
            long num = long.Parse(Reader.ReadLine());
            list.Add(num, i);
        }
        List<KeyValuePair<long, int>> orderd = list.OrderBy(a=>a.Key).ToList();
        int cnt = 0;
        for(int i=0; i<orderd.Count; i++) {
            if((i-orderd[i].Value) % 2 != 0) {
                cnt++;
            }
        }
        Console.WriteLine(cnt / 2);
    }

    public class Reader
    {
        public static bool IsDebug = true;
        private static String PlainInput = @"

5
10
8
5
3
2

";
        private static System.IO.StringReader Sr = null;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (Sr == null)
                {
                    Sr = new System.IO.StringReader(PlainInput.Trim());
                }
                return Sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
    }
    static void Main()
    {
        Program prg = new Program();
        prg.Proc();
    }
}

Measured memory_bytes: 20564
#include<bits/stdc++.h>
using namespace std;
char a[10010]; 
bool c, f;
int main() {
    scanf("%s", a);
    for(int i=0; i<strlen(a); i++) {
        if(a[i]=='C') c=true;
        if(a[i]=='F'&&c==true) f=true;
    }
    if(f==true) cout<<"Yes"<<endl; 
    else cout<<"No\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using   namespace      std;
typedef long long      LL;
typedef vector<int>    VI;
typedef pair<int,int>  PII;

char g[2005][2005];
int row[2005][2005];
int col[2005][2005];

int main(){

	int h, w, x;
	scanf("%d %d", &h, &w);
	getchar();

	for(int i=1; i<=h; i++){
		for(int j=1; j<=w; j++){
			g[i][j] = getchar();
			if(g[i][j] == '.'){
				row[i][j] = row[i][j-1] + 1;
				col[i][j] = col[i-1][j] + 1;
			}
		}
		getchar();

		x = 0;
		for(int j=w; j>=0; j--){
			if(g[i][j] == '.'){
				row[i][j] += x;
				x++;
			}
			else{
				x = 0;
			}
		}
	}

	for(int j=1; j<=w; j++){
		x = 0;
		for(int i=h; i>=0; i--){
			if(g[i][j] == '.'){
				col[i][j] += x;
				x++;
			}
			else{
				x = 0;
			}
		}
	}

	int mx = 0;

	for(int i=1; i<=h; i++){
		for(int j=1; j<=w; j++){
			mx = max(mx, row[i][j] + col[i][j] - 1);
		}
	}

	printf("%d\n", mx);

	return 0;
}

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

long long n,now,cnt,last;
long long a[100010];

int main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	sort(a+1,a+n+1);
	for(int i=n;i>0;i--){
		if(a[i]!=now){
			cnt=1;
			now=a[i];
		}else{
			cnt++;
		}
		if(cnt==2){
			if(last!=0){
				printf("%lld\n",now*last);
				return 0;
			}else{
				last=now;
			}
		}
		if(cnt==4){
			printf("%lld\n",now*now);
			return 0;
		}
	}
	printf("%lld\n",0);
	return 0;
}

Measured memory_bytes: 1024
fun main(args: Array<String>) {
    readLine()?.let {
        var result = 0
        it.forEach {
           result += it.toString().toInt()
        }
        val r = if (result % 9 == 0 || result == 0) {
            "Yes"
        } else {
            "No"
        }
        println(r)
    }
}

Measured memory_bytes: 48932
a,b = map(int,input().split())

if a in {1,3,5,7,8,10,12} and b in {1,3,5,7,8,10,12}:
    print("Yes")
elif a in{2} and b in {2}:
    print("Yes")
elif a in {4,6,9,11} and b in {4,6,9,11}:
    print("Yes")   

else:
    print("No")


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    { 
        static void Main(string[] args)
        {
            //[summary]C - Monsters Battle Royale
            int n = int.Parse(Console.ReadLine());

            //モンスターを体力が少ない順に並べる
            var monsters = ReadLine().OrderBy(x => x).ToList();

            //モンスターが最後の1匹になるまで繰り返し
            while (monsters.Count > 1)
            {
                //一番体力の少ないモンスターが他のモンスターを攻撃
                int attacker = monsters[0];

                for(int i = 1; i < monsters.Count; i++)
                {
                    monsters[i] %= attacker;
                }

                //体力ゼロのモンスターは除外した後、体力の少ない順に並べ直し
                monsters = monsters.Where(x => x > 0).
                                    OrderBy(x => x).ToList();
            }

            //最後に残ったモンスターの体力を出力
            Console.WriteLine(monsters[0]);
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine().TrimEnd();
            var array = line.Split(' ');
            var numbers = new List<int>();

            foreach (var s in array)
            {
                int num = int.Parse(s);
                numbers.Add(num);
            }

            return numbers;
        }
    }
}

Measured memory_bytes: 24544
n,m = map(int,input().split())
if m != 0:
    l = [list(map(int,input().split())) for i in range(m)]
    s,c = [list(i) for i in zip(*l)]
z = ['a'] * n
for i in range(m):
    if z[s[i]-1] == 'a':
        z[s[i]-1] = str(c[i])
    elif z[s[i]-1] == str(c[i]):
        pass
    else:
        print('-1')
        exit(0)
if n == 1:
    if z[0] == 'a':
        print(0)
    else:
        print(z[0])
else:
    if z[0] == '0':
        print(-1)
    else:
        if z[0] == 'a':
            z[0] = '1'
        for i in range(1,n):
            if z[i] == 'a':
                z[i] = '0'
        print(''.join(z))


Measured memory_bytes: 9180
/*
 * main.cpp
 *
 *  Created on: 2020/04/11
 *      Author: SkAaO
 */

#include <iostream>

using namespace std;

int main(){
	int A, B;
	cin >> A >> B;

	for(int i = 1;;i++){
		int hole_num = (A - 1) * (i - 1) + 1;
		if(hole_num >= B){
			cout << i - 1 << endl;
			break;
		}
	}

	return 0;
}




Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	double A, B;
	  
	scanf("%lf %lf", &A, &B);
	  
	if (A > B) {
		printf("GREATER");
	} else if (A < B) {
		printf("LESS");
	} else {
		printf("EQUAL");
	}
	
	return 0;
}

Measured memory_bytes: 128
use std::cmp::*;
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let c: i64 = itr.next().unwrap().parse().unwrap();
    let mut rx = vec![0i64; n];
    let mut rv = vec![0i64; n];
    for i in 0..n {
        rx[i] = itr.next().unwrap().parse().unwrap();
        rv[i] = itr.next().unwrap().parse().unwrap();
    }
    let mut lx = vec![0; n];
    let mut lv = rv.clone();
    let mut lmax = vec![0; n];
    let mut rmax = vec![0; n];
    lv.reverse();
    for i in 0..n {
        lx[i] = c - rx[n - 1 - i];
    }
    for i in 0..n - 1 {
        lv[i + 1] += lv[i];
        rv[i + 1] += rv[i];
        lmax[i + 1] = max(lmax[i], lv[i] - lx[i]);
        rmax[i + 1] = max(rmax[i], rv[i] - rx[i]);
    }

    let mut ans = 0i64;
    for i in 0..n {
        ans = max(ans, lv[i] - lx[i]);
        ans = max(ans, lv[i] - lx[i] * 2 + rmax[n - 1 - i]);
    }
    for i in 0..n {
        ans = max(ans, rv[i] - rx[i]);
        ans = max(ans, rv[i] - rx[i] * 2 + lmax[n - 1 - i]);
    }
    println!("{}", ans);
}


Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;

int line(int &x,int &y){
  if(y%2==0)return x+y/2;
  else return x-(y+1)/2;
}
bool include(vi &p,int n){
  for(int i=0;i<p.size();i++){
    if(p[i]==n)return true;
  }
  return false;
}


int main(){
  int i,X,N,ans=500;
  cin>>X>>N;
  vi p(N);
  for(i=0;i<N;i++){
    cin>>p[i];
  }
  for(i=0;i<N;i++){
    if(!include(p,line(X,i))){ans=line(X,i);break;}
  }
  if(ans==500)ans=line(X,N);
  cout<<ans<<endl;
}

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

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

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

  vector<ll> h(n, 0);

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

  vector<ll> dp(n, INF);
  dp[0] = 0;

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

  cout << dp[n - 1] << endl;

  return 0; 
}


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

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

    rep(i,m) n -= a[i];

    if(n < 0) cout << "-1" << endl;
    else cout << n << endl;
    
    return 0;
}



Measured memory_bytes: 3668