akhauriyash/Code-Regression huggingface dataset:
using Yorukatsu043.Questions;
using Yorukatsu043.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Yorukatsu043.Questions
{
    /// <summary>
    /// ABC136 C
    /// </summary>
    public class QuestionB : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var n = inputStream.ReadInt();
            var h = inputStream.ReadIntArray();

            h[0]--;

            for (int i = 1; i < h.Length; i++)
            {
                if (h[i] > h[i - 1])
                {
                    h[i]--;
                }
                else if (h[i] < h[i - 1])
                {
                    yield return "No";
                    yield break;
                }
            }

            yield return "Yes";
        }
    }
}


namespace Yorukatsu043
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionB();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace Yorukatsu043.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace Yorukatsu043.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 26204
import math

while True:
    n = int(input())
    if n == 0:
        break
    score = list(map(int, input().split()))
    ave = 0
    sum = 0
    for i in range(n):
        ave += score[i]
        sum += score[i]**2
    ave /= n
    sum = (sum - n*ave**2) / n
    print("%f" %(math.sqrt(sum)))


Measured memory_bytes: 5700
import scala.io.StdIn


object Main extends App {
  val Array(a, b, t)  = StdIn.readLine().split(" ").map(_.toInt)

  def solve(a: Int, b: Int, t: Int): Int = {
    Math.floor((t + 0.5) / a).toInt * b
  }
  println(solve(a, b, t))

}
  





Measured memory_bytes: 27316
#include<iostream>
using namespace std;
#define inRange(x,a,b) (a <= x && x <= b)

int win[26] = {};

struct node{
    int id;
    node *left;
    node *right;
    node (int i){
        id = i;
        left = NULL;
        right = NULL;
    }
};

node* new_node(int id){
    node *ret;
    ret = (node*)malloc(sizeof(node));
    ret->id = id;
    ret->left = NULL;
    ret->right = NULL;
    return ret;
}

string s;

node* f(int &pos){
    if(inRange(s[pos], 'a', 'z')){
        return new_node(s[pos++]-'a');
    }
    if(s[pos] == '['){
        pos++;
        node* ret = new_node(-1);
        ret->left = f(pos);
        pos++;  // -
        ret->right = f(pos);
        pos++;  // ]
        return ret;
    }
    return NULL;    // unreachable
}

bool valid = true;

int dfs(node *cur){
    if(cur->id != -1){
        return cur->id;
    }else{
        int a = dfs(cur->left);
        int b = dfs(cur->right);
        int judge = (win[a]!=0) + (win[b]!=0);
        if(judge == 0 || judge == 2){
            valid = false;
        }
        if(win[a] == 0){
            win[b]--;
            return b;
        }else if(win[b] == 0){
            win[a]--;
            return a;
        }else{
            // invalid
            return 0;
        }
    }
}

int main(){
    cin >> s;
    char c; int x;
    while(cin >> c >> x){
        win[c-'a'] = x;
    }
    int pos = 0;
    node *root = f(pos);
    cout << (win[dfs(root)] == 0 && valid ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 3228
n, a, b = map(int, input().split())
d = b-a
d_nearest_side = min(a-1, n-b)
if d % 2 == 0:
    print(d//2)
else:
    move_side = 1 + (d-1)//2 + d_nearest_side
    print(int(move_side))

Measured memory_bytes: 38992
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int k = scanner.nextInt(), n = scanner.nextInt();
        int[] nums = new int[n];
        for (int i = 0; i < n; i ++)
            nums[i] = scanner.nextInt();
        int max = k - nums[n - 1] + nums[0];
        for (int i = 1; i < n; i ++)
            max = Math.max(nums[i] - nums[i - 1], max);
        System.out.println(k - max);
    }

}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
#define print(x) cout<<'>'<<#x<<':'<<x<<endl;
#define F first
#define S second
const int mod=1000000007;

void solve(){
    int a,b;
    string x,y;
    int ans=0;
    cin>>a>>b;
    bool pos;
    for (int i=a;i<=b;i++){
        x=to_string(i);
        pos=true;
        for (int j=0;j<(x.size()+1)/2;j++){
            if (x[j]!=x[x.size()-1-j]){pos=false;break;}
        }
        if (pos){ans++;i+=9;}
    }cout<<ans<<endl;

}

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

    solve();

    return 0;
}




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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
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; }
typedef long long ll;

const long long INF = 1LL << 60;

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

int main()
{
    ll A, B, C, D;
    cin >> A >> B >> C >> D;

    ll min = C * D / gcd(C, D);
    ll ans = 0;

    ll st = A + C - (A % C);
    if (st <= B) {
        ans += 1 + ((B - st) / C);
    }

    st = A + D - (A % D);
    if (st <= B) {
        ans += 1 + ((B - st) / D);
    }

    st = A + min - (A % min);
    if (st <= B) {
        ans -= 1 + ((B - st) / min);
    }
    if (A % C == 0) ans++;
    if (A % D == 0) ans++;
    if (A % min == 0) ans--;

    ans = (B - A + 1) - ans;

    cout << ans << endl;
    return 0;
}

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

int main()
{
  int N;
  cin >> N;
  vector<array<int, 2>> point(N);
  vector<vector<double>> distance(N, vector<double>(N, 0));
  vector<int> index(N);
  rep(i, N)
  {
    int x, y;
    cin >> x >> y;
    point[i][0] = x;
    point[i][1] = y;
    index[i] = i;
  }
  double ans = 0;
  int count = 0;

  for (int i = 0; i < N; i++)
  {
    for (int j = i + 1; j < N; j++)
    {
      distance[i][j] = sqrt(pow(point[i][0] - point[j][0], 2) + pow(point[i][1] - point[j][1], 2));
      distance[j][i] = distance[i][j];
    }
  }

  do
  {
    rep(i, N - 1)
    {
      ans += distance[index[i]][index[i + 1]];
    }
    count++;
  } while (next_permutation(index.begin(), index.end()));

  //cout << count << endl;
  cout << setprecision(15) << ans / count << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <cstdio>
using namespace std;
typedef complex<double> P;
#define X real()
#define Y imag()

double dot(P a, P b){
  return (a.X * b.X + a.Y * b.Y);
}

int main(){
  P p1, p2;
  double x1, x2, y1, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  p1 = P(x1,y1);
  p2 = P(x2,y2);
  p2 -= p1;
  int q;
  cin >> q;
  for(int i = 0; i < q; ++i){
    P p;
    cin >> x1 >> y1;
    p = P(x1,y1);
    p -= p1;
    p = p1 + dot(p2,p)/abs(p2)/abs(p2)*p2;
    printf("%.9lf %.8lf\n",p.X,p.Y);
  }
  return 0;
}

Measured memory_bytes: 3252
S = input()
tmp = 0
ans = 0
for i in range(len(S)):
    if S[i] == "0":
        if tmp > 0:
            ans += 2
        tmp -= 1
    elif S[i] == "1":
        if tmp < 0:
            ans += 2
        tmp += 1
    
print(ans)

Measured memory_bytes: 3188
import java.util.*;
    public class Main {
    	public static void main(String[] args){
    		Scanner sc = new Scanner(System.in);
    		// 整数の入力
    		int n = sc.nextInt();
          	int[] a = new int[n];
          
          	for (int i = 0; i<a.length; i++){
              a[i] = sc.nextInt();
            }
          
            int result = 0;
          	for (int i = 0; i<a.length; i++){
              for (int j = 0; j<a.length; j++){
                if(i != j){
                  result += a[i] * a[j];
                }                  
              }
            }
          	
          	result = result / 2;
              
          
    		// 出力
    		System.out.println(result);
    	}
    }

Measured memory_bytes: 22868
#include <iostream>
#include <array>
#define repeat_reverse(i, n) for (int i = (n)-1; (i) >= 0; --(i))
using ll = long long;
using namespace std;
 
int main() {
    string s; cin >> s;
    int n = s.size();
    array<int, 26> cnt = {};
    ll result = 1;
    repeat_reverse (i, n) {
        char c = s[i] - 'a';
        cnt[c] += 1;
        result += n - i - cnt[c];
    }
    cout << result << endl;
    return 0;
}

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

void func_A() {
    int A, B;
    cin >> A >> B;
    int res = A > 2 * B ? A - 2 * B : 0;
    cout << res << endl;
}
void func_B() {
    int N;
    cin >> N;
    vector<ll> d(N);
    rep(i, N) {
        cin >> d[i];
    }
    ll res = 0;
    for(int i = 0; i < N - 1; i++) {
        for(int j = i + 1; j < N; j++) {
            res += d[i] * d[j];
        }
    }
    cout << res << endl;
}
int main() {
    func_B();
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

Measured memory_bytes: 21716
def check(n):
    count = 0
    for i in range(1, n + 1):
        if(n % i == 0):
            count += 1
    if(count == 8 and n % 2 != 0):
        return True
    else:
        return False


n = int(input())
count = 0
for i in range(1, n + 1):
    if(check(i)):
        count += 1
print(count)


Measured memory_bytes: 9180
#include "bits/stdc++.h"

using namespace std;

//using Matrix = vector< vector<int> >;
typedef long long ll;
typedef pair<int, int> P;
#define fir first
#define sec second

const int INF = 1e9 + 10;
//const ll INF = 1e18 + 10LL;
int dx[5] = {0, 0, 1, -1, 0}, dy[5] = {1, -1, 0, 0, 0};
const double EPS = 1e-10;
bool cmp(P a, P b) { return a.second < b.second; } //End sort (Interval scheduling problem)
ll MOD = 1e9 + 7;

int n, m;

vector<int> divisor(int m) {
	vector<int> res;
	for (int i = 1; i * i <= m; i++) {
		if (m % i == 0) {
			res.push_back(i);
			if (i != m / i) res.push_back(m / i);
		}
	}
	return res;
}

void solve() {
	vector<int> div = divisor(m);

	sort(div.begin(), div.end());
	
	int ans = 0;
	for (int i = 0; i < div.size(); i++) {
		if (m / div[i] >= n) ans = max(ans, div[i]);
	}

	printf("%d\n", ans);
}

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

	solve();
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define repr(i, n, m) for (int i = (int)(n) - 1; i >= (int)(m); i--)
using namespace std;
using ll = int64_t;
const int MOD = 1000000007; // 10^9+7

ll N, M;
vector<ll> A;

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}

int main() {
// https://atcoder.jp/contests/abc150/tasks/abc150_d
    cin >> N >> M;
    A.resize(N);
    rep(i, 0, N) 
    { 
        cin >> A[i]; 
        A[i] /= 2L; 
    }
    
    ll l = A[0];
    rep(i, 1, N) l = lcm(l, A[i]);
    
    rep(i, 0, N) 
    {
        if ((l / A[i]) % 2 == 0)
        {
            cout << 0 << endl;
            return 0;
        }  
    }

    cout << (M / l + 1L) / 2L << endl;
}


Measured memory_bytes: 1024
import sys
#import numpy as np

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N = i2n()
    n = (N-2) * 180
    print(n)

main()


Measured memory_bytes: 38384
import math

a,b,angle = input().split()
a = float(a)
b = float(b)
angle = math.pi * float(angle)/180

c = (a**2+b**2-2*a*b*math.cos(angle))**(1/2)

S = a * b * math.sin(angle) * (1/2)
L = a + b + c
h = b * math.sin(angle)

print(S)
print(L)
print(h)






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

int main() {
  int a, b, c;
  cin >> a >> b;
  c = (a + b) % 2;
  
  if (c != 0) {
    cout << (a + b) / 2 + 1 << endl;
  } else {
    cout << (a + b) / 2 << endl;
  }
}


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

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("3");
            WillReturn.Add("2 5");
            //9
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("2");
            WillReturn.Add("3");
            //6
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("6");
            WillReturn.Add("0 153 10 10 23");
            //53
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();

        int[] BArr = InputList[1].Split(' ').Select(X => int.Parse(X)).ToArray();
        int UB = BArr.GetUpperBound(0);
        var AList = new List<int>();

        long Answer = 0;
        for (int I = 0; I <= UB + 1; I++) {
            int Ind1 = I - 1;
            int Ind2 = I;

            var Kouho = new List<int>();
            if (Ind1 >= 0) {
                Kouho.Add(BArr[Ind1]);
            }
            if (Ind2 <= UB) {
                Kouho.Add(BArr[Ind2]);
            }
            Answer += Kouho.Min();
        }
        Console.WriteLine(Answer);
    }
}


Measured memory_bytes: 13396
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        CP sc = new CP();

        System.out.println(sc.nextInt() ^ 1);
    }

    /*****************************************************************************/
    static class CP {
        BufferedReader bufferedReader;
        StringTokenizer stringTokenizer;

        public CP() {
            bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        }

        int nextInt() {
            return Integer.parseInt(NNNN());
        }

        long nextLong() {
            return Long.parseLong(NNNN());
        }

        double nextDouble() {
            return Double.parseDouble(NNNN());
        }

        String NNNN() {
            while (stringTokenizer == null || !stringTokenizer.hasMoreElements()) {
                try {
                    stringTokenizer = new StringTokenizer(bufferedReader.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return stringTokenizer.nextToken();
        }

        String nextLine() {
            String spl = "";
            try {
                spl = bufferedReader.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return spl;
        }
    }
    /*****************************************************************************/
}

Measured memory_bytes: 32752
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A: Zero-Sum Ranges
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 200000;

/* typedef */

typedef long long ll;
typedef map<ll,ll> mll;

/* global variables */

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);

  ll asum = 0, cnt = 0;
  mll sumcs;
  sumcs[0] = 1;

  for (int i = 0; i < n; i++) {
    int ai;
    scanf("%d", &ai);

    asum += ai;
    mll::iterator mit = sumcs.find(asum);
    if (mit == sumcs.end()) sumcs[asum]++;
    else cnt += mit->second++;
  }

  printf("%lld\n", cnt);
  return 0;
}


Measured memory_bytes: 12800
#include <iostream>
#include <vector>

using namespace std;
int main()
{
	int n;
	cin >> n;

	vector<int> a;
	vector<int> b;
	vector<int> c;

	int temp;
	for (int i = 0; i < n; i++)
	{
		cin >> temp;
		a.push_back(temp);
	}
	for (int i = 0; i < n; i++)
	{
		cin >> temp;
		b.push_back(temp);
	}
	for (int i = 0; i < n - 1; i++)
	{
		cin >> temp;
		c.push_back(temp);
	}

	int lastA = 0;
	int satP = 0;

	satP += b[a[0] - 1];
	lastA = a[0];
	for (int i = 1; i < n; i++)
	{
		satP += b[a[i] - 1];

		if (a[i] - 1 == lastA)
		{
			satP += c[a[i]-2];
		}

		lastA = a[i];
	}
	cout << satP;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int i,n,t;
    int ara[105];
    t = 0;
    scanf("%d",&n);
    for(i = 0;i < n;i++){
        scanf("%d",&ara[i]);
    }
    for(i = 0;i < n;i++){
        if((i + 1) % 2 != 0 && ara[i] % 2 != 0){
            t++;
        }
    }
    printf("%d\n",t);
    return 0;
}


Measured memory_bytes: 3820
#include <bits/stdc++.h>  
#define ll long long
#define mk make_pair
#define y1 yyy
using namespace std;

const int N = 5e5 + 5;

ll n, a, b, c, d;

int main() {
	cin >> n >> a >> b >> c >> d;
	n--;
	bool ok = 0;
	for (int i = 0; i <= n; i++) {
		ll l = a + (c + d) * i - d * n;
		ll r = a + (c + d) * i - c * n;
		if (b >= l && b <= r) ok = 1;
	}
	if (ok) puts("YES");
	else puts("NO");
}

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

int main(){
    ll n;
    cin >> n;
    ll ans = 0;
    ll sqrtn = sqrt(n);
    for(ll i = 2; i <= sqrtn; i++){
        if(n%i==0){
            ll cnt = 0;
            while(n%i==0){
                n /= i;
                cnt++;
            }
            ll j = 1;
            while(cnt>=j){
                cnt -= j;
                ans++;
                j++;
            }
        }
    }
    if(n != 1)ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3680
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Main {

  public static void main(String[] args) {
    new Main().run();
  }

  public void run() {
    
    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(in.readLine());
      String line = in.readLine();
      int nHalf = n >> 1;

      Integer num;
      Map<Integer,Integer> mapA = new HashMap<>();
      Map<Integer,Integer> mapB = new HashMap<>();
      List<Map<Integer,Integer>> aMap = new ArrayList<>();
      aMap.add(mapA);
      aMap.add(mapB);
      int offset=0,next=0;
      char regx = ' ';

      for(int i=0; i<n; i++) {
        if((next = line.indexOf(regx,offset)) == -1)
          next = line.length();
        num = new Integer(line.substring(offset, next));
        offset = ++next;

        // aMap.get(i&1).merge(num, 1, Integer::sum);
        if(aMap.get(i&1).containsKey(num))
          aMap.get(i&1).replace(num, aMap.get(i&1).get(num) + 1);
        else
          aMap.get(i&1).put(num, 1);
      }

      int[] vm1 = {0,0};
      int[] vm2 = {0,0};
      int[] x   = {0,0};

      for (int i=0; i<aMap.size(); i++) {
        int j = i;
        aMap.get(j).forEach((key,val) -> {
          if(vm1[j] < val) {
            vm2[j] = vm1[j];
            vm1[j] = val;
            x[j]  = key;
          } else if(vm2[j] < val) {
            vm2[j] = val;
          }
        });
      }

      int ans = 0;
      int cca1 = nHalf - vm1[0];
      int ccb1 = nHalf - vm1[1];
      int cca2 = nHalf - vm2[0];
      int ccb2 = nHalf - vm2[1];

      if(x[0] == x[1])
        ans = cca2 > ccb2 ? cca1 + ccb2 : cca2 + ccb1;
      else
        ans = cca1 + ccb1;

      System.out.println(ans);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
}

Measured memory_bytes: 46428
#include <stdio.h>

int main(){
  int N,X;
  int L[101];
  scanf("%d %d",&N,&X);
  int cnt = 1;
  int D = 0;
  for(int i=0; i<N; i++){
    scanf("%d",&L[i]);
    D += L[i];
    if(D <= X){
     cnt++; 
    }
  }
  printf("%d\n",cnt);
}

Measured memory_bytes: 128
def main():
    n, m = map(int, input().split())
    # nは偶数、mは奇数
    # n+mから2つ選ぶ選び方は
    # n:m = 0:2 和は 偶数、選び方はmC2
    # n:m = 1:1 和は 奇数 （今回はこれは含めない）
    # n:m = 2:0 和は 偶数、選び方はnC2
    cnt = 0
    if m >= 2:
        cnt += m * (m -1) // 2
    if n >=2:
        cnt += n * (n -1) // 2
    print(cnt)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9112
fun main(args: Array<String>) {
    val (n, m, l) = readLine()!!.split(" ").map(String::toInt)
    val a = (0 until n).map { readLine()!!.split(" ").map(String::toLong) }
    val b = (0 until m).map { readLine()!!.split(" ").map(String::toLong) }
    val ans = (0 until n).map { i -> (0 until l).map { j -> (0 until m).map { k -> a[i][k] * b[k][j] }.sum() } }
    ans.map { it.joinToString(" ") }.forEach(::println)
}



Measured memory_bytes: 70120
ri=lambda:map(int,input().split(' '))

l,r=ri()
if r//2019 > l//2019:
  print(0)
  import sys
  sys.exit(0)
l%=2019
r%=2019
if l>r:
  print(0)
else:
  best = 2020
  for x in range(l,r+1):
    for y in range(l,r+1):
      if x!=y:
        cur = (x*y)%2019
        best=min(best,cur)
  print(best)
              


Measured memory_bytes: 3060
N = int(input())
W = [input() for i in range(N)]

if len(W) != len(set(W)):
    print('No')
    exit()

ini = W[0][0]
for i in W:
    if i[0] == ini:
        ini = i[-1]
    else:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 3060
# coding: utf-8
# Here your code !

import sys
import math

r = sys.stdin.readlines()

n = [[int(i) for i in (j.split())] for j in r]

for i in range(1,n[0][0]+1):
    sq = []
    for a in n[i]:  #a is lengthes
        sq.append(a**2)
    if (sum(sq)-2*max(sq) == 0):
        print("YES")
    else:
        print("NO")

Measured memory_bytes: 7920
def mark(s, x):
    for i in xrange(x + x, len(s), x):
        s[i] = False

def sieve(n):
    s = [True] * n
    for x in xrange(2, int(n**0.5) + 1):
        if s[x]: mark(s, x)
    return [i for i in xrange(0,n) if s[i] and i > 1]

n = int(input())
ans = [i for i in sieve(55555) if i%5 == 1]

print ' '.join(map(str,ans[:n]))

Measured memory_bytes: 3204
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <climits>
//#include "h.h"
using namespace std;

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define pm(first, second) pb(mp(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()

int main(){

	while(true){
		string S;
		cin >> S;
		if(S == "#")break;
		set<string> st1, st2;
		st1.insert(S);
		for(char c = 'y'; c >= 'a'; c--){
			/*cout << "###############" << endl << c << endl;
			for(auto itr = st1.begin(); itr != st1.end(); itr++){
				cout << *itr << endl;
			}*/
			for(auto itr = st1.begin(); itr != st1.end(); itr++){
				string tmp = *itr;
				int posc=-1,poscpo=-1;
				for(int i = 0; i < tmp.size(); i ++){
					if(poscpo == -1 && tmp[i] == c+1){
						poscpo = i;
					}
					if(tmp[i] == c && poscpo == -1){
						tmp[i]++;
						st2.insert(tmp);
						tmp[i]--;
					}
				}
				if(poscpo == -1){
					st2.insert(tmp);
				}
			}
			st1 = st2;
			st2.erase(all(st2));
		}
		cout << st1.size() << endl;
		if(st1.size() <= 10){
			for(auto itr = st1.begin(); itr != st1.end(); itr++){
				cout << *itr << endl;
			}
		}
		else{
			auto itr = st1.begin();
			for(int i = 0; i < 5; i ++){
				cout << *itr << endl;
				itr++;
			}
			itr = st1.end();
			for(int i = 0; i < 5; i ++){
				itr--;
			}
			for(int i = 0; i < 5; i ++){
				cout << *itr << endl;
				itr++;
			}
		}
	}

	return 0;
}


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

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

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

const double eps = 1e-10;

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

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

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

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

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

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

	int64 N;
	while (cin >> N && N) {
		vector<string> step(N);
		REP(i, N) cin >> step[i];
		int on_down = 1;
		int64 d[2] = {1, 1};
		int64 res = 0;
		REP(i, N) {
			if (step[i] == "lu") {
				if (d[0]) d[0] = 0;
			} else if (step[i] == "ld") {
				if (!d[0]) d[0] = 1;
			} else if (step[i] == "ru") {
				if (d[1]) d[1] = 0;
			} else if (step[i] == "rd") {
				if (!d[1]) d[1] = 1;
			}
			if ((on_down && !d[0] && !d[1]) || (!on_down && d[0] && d[1])) {
				res++;
				on_down ^= 1;
			}
		}
		cout << res << endl;
	}
}



Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline std::ostream& operator << (std::ostream& out, const std::vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }


int main() {
	IOS;
	ll h, res = 1;
	cin >> h;
	while (h > 0) {
		h /= 2;
		res *= 2;
	}
	put(res - 1);
	return 0;
}


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

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

Measured memory_bytes: 640
n = int(input())


def sum_digit(n):
    s = 0
    while n > 0:
        s += n % 10
        n //= 10
    return s


res = 10000000000
for a in range(1,n):
    b = n - a
    res = min(res, sum_digit(a) + sum_digit(b))
print(res)


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

int main()
{
  long long N, M, K, ans;
  cin >> N >> M >> K;
  vector<long long> A(N), B(M);
  ans = 0;
  for (int i = 0; i < N; i++)
  {
    long long tmpA;
    cin >> tmpA;
    if (i == 0) A.at(i) = tmpA;
    else A.at(i) = A.at(i-1) + tmpA;
  }
  for (int i = 0; i < M; i++)
  {
    long long tmpB;
    cin >> tmpB;
    if (i == 0) B.at(i) = tmpB;
    else B.at(i) = B.at(i-1) + tmpB;
    if (B.at(i) <= K) ans = i+1;
  }
  for (int i = 0; i < N; i++)
  {
    long long num = i+1;
    long long restK = K - A.at(i);
    if (restK < 0) break;
    long long left = 0, right = M-1;
    if (left == right)
    {
      if (restK >= B.at(left)) num++;
      ans = max(ans, num);
    }
    else
    {
      if (restK >= B.at(right)) num += right+1;
      else if (restK >= B.at(left))
      {
        while (right - left != 1)
        {
          long long mid = (left + right)/2;
          if (restK >= B.at(mid)) left = mid;
          else right = mid;
        }
        num += left+1;
      }
      ans = max(ans, num);
    }
  }
  cout << ans << endl;
}


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

namespace AtcoderTemplateForCSharp
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var s = Console.ReadLine().Split(' ').Select(x => int.Parse(x));
            var a = s.First();
            var b = s.Last();
            if (a + b == 15)
            {
                Console.WriteLine('+');
            }
            else if (a * b == 15)
            {
                Console.WriteLine('*');
            }
            else
            {
                Console.WriteLine('x');
            }
        }
    }
}

Measured memory_bytes: 13396
N = int(input())

ac, wa, tle, re = 0, 0, 0, 0

for i in range(N):
  S = input()
  if S=='AC':
    ac+=1
  elif S=='WA':
    wa+=1
  elif S=='TLE':
    tle+=1
  elif S=='RE':
    re+=1

print('AC x %d'%ac)
print('WA x %d'%wa)
print('TLE x %d'%tle)
print('RE x %d'%re)

Measured memory_bytes: 9204
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

n,k=I()
r,s,p=I()
t = X()
for i in range(n-k):
    if t[i+k]==t[i]:
        t[i+k]=0

print(t.count("r")*p+t.count("s")*r+t.count("p")*s)


Measured memory_bytes: 11296
#include<iostream>
#include<algorithm>
using lint=int64_t;
using namespace std;

int main()
{
	int N;
	int H[100]={};

	cin >> N;
	for(int i=0;i<N;i++)
		cin >> H[i];
	
	int ans=0;
	int Max=H[0];
	for(int i=0;i<N;i++)
	{
		if(H[i]>=Max)
			ans++;

		Max=max(Max,H[i]);
	}

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <string>
#include <iostream>
//#include <cmath>
#include <algorithm> //!!

int main(){
    int N, L;
    std::cin>>N>>L;
    std::string s[N];
    for(int i=0;i<N;++i){
        std::cin>>s[i];
    }
    std::sort(s, s+N); //!!
    for(int i=0;i<N;++i){
        std::cout<<s[i];
    }
    std::cout<<std::endl;
}

Measured memory_bytes: 256
//https://kimiyuki.net/writeup/algo/etc/icpc-2017-asia-c/　を参考
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,t;
int main()
{
    ll start=0;//生徒ごとの検査開始時刻.(h[i]を足していくだけで良い)
    ll interval=0;
    cin >> n >> t;
    ll student[n];
    ll resttime[n];
    ll h[n];
    memset(student,0,sizeof(student));
    memset(h,0,sizeof(h));
    for(int i=0;i<n;i++)
    {
        cin >> h[i];
        //長いintervalの影響を受けるのは,このi以降のインデックスの人のみ.
        //このiより前のインデックスの人は長いintervalの内にどんどん先の機械に移る事ができるので,
        //前のインデックスの人が後のインデックスの人のintervalに悩まされる事はない.
        interval=max(interval,h[i]);
        //確定で検査できる機械の番号は割り算で求める.
        student[i]=max(0LL,(t-start)/interval);
        //その後,intervalで割った時の余りの時間,あと1つの機械が使える.余りの時間がh[i]以上ならギリギリ1つ完了する.
        resttime[i]=(t-start)%interval;
        if(resttime[i]>=h[i]) student[i]++;
        //調整(出力は現在こなしている機械or"待っている"機械なので.)
        student[i]++;
        start+=h[i];
    }
    for(int i=0;i<n;i++)
    {
        cout << student[i] << endl;
    }

}


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

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

    std::cout << (((a < b && a < c && c < b) || (b < a && b < c && c < a)) ? "Yes" : "No") << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){
	int n,a[4],count;

	while(cin >> n){
		count=0;
		for(a[0]=0;a[0]<10;a[0]++)
			for(a[1]=0;a[1]<10;a[1]++)
				for(a[2]=0;a[2]<10;a[2]++)
					for(a[3]=0;a[3]<10;a[3]++)
						if(a[0]+a[1]+a[2]+a[3]==n){
							count++;
							break;
						}
		cout << count << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
N=int(input())
XYU=[tuple(input().split()) for _ in range(N)]
U=[]
R=[]
D=[]
L=[]
for x,y,u in XYU:
 x,y = int(x),int(y)
 if u=="U":
  U.append((x,y))
 elif u=="D":
  D.append((x,y))
 elif u=="L":
  L.append((x,y))
 else:
  R.append((x,y))
ans=[10**9]
def z(A):
 A.sort()
 n=p=-10**9
 for k,c,a in A:
  if k!=n:
   if a==1:
    n=k
    p=c
   continue
  if a==1:
   p=c
   continue
  if (c-p)*5<ans[0]:
   ans[0]=(c-p)*5
z([(x,y,1) for x,y in U]+[(x,y,-1) for x,y in D])
z([(y,x,1) for x,y in R]+[(y,x,-1) for x,y in L])
z([(x+y,x-y,1) for x,y in R]+[(x+y,x-y,-1) for x,y in U])
z([(x+y,x-y,1) for x,y in D]+[(x+y,x-y,-1) for x,y in L])
z([(x-y,x+y,1) for x,y in U]+[(x-y,x+y,-1) for x,y in L])
z([(x-y,x+y,1) for x,y in R]+[(x-y,x+y,-1) for x,y in D])
print("SAFE" if ans[0]>=10**9 else ans[0])


Measured memory_bytes: 102780
N = int(input())
btc_a = 380000.0
btc_b = btc_a / (10 ** 8)
ans = 0.0
for i in range(N):
  x, n = input().split()
  if n == "JPY":
    ans += int(x)
  else:
    a, b = map(int, x.split("."))
    ans += a * btc_a
    ans += b * btc_b
print(ans)

Measured memory_bytes: 9132
import java.util.Scanner;
import java.util.Arrays;

public class Main {

    public static void main(String[] args) {
        new Main().solve();
    }

    void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int Q = sc.nextInt();
        int[][] LR = new int[N + 1][N + 1];
        for (int i = 0; i < M; i++) {
            int L = sc.nextInt();
            int R = sc.nextInt();
            LR[L][R]++;
        }
        for (int i = 1; i <= N; i++) {
            for (int j = 2; j <= N; j++) {
                LR[i][j] += LR[i][j - 1];
            }
        }
        for (int i = 1; i <= Q; i++) {
            int p = sc.nextInt();
            int q = sc.nextInt();
            int ans = 0;
            for (int j = p; j <= q; j++) {
                ans += LR[j][q] - LR[j][p - 1];
            }
            System.out.println(ans);
        }

    }
}

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

const int MAX = 3005;
int n_test;

int n;
double p[MAX];
double dp[MAX][MAX];

void input() {
    cin >> n;
    for(int i = 1; i <= n; ++i) cin >> p[i];
    for(int i = 0; i <= n; ++i) for(int j = 0; j <= n; ++j) dp[i][j] = 0;
}

void solve() {
    dp[1][1] = p[1];
    dp[1][0] = 1 - p[1];
    for(int i = 2; i <= n; ++i) { 
        dp[i][0] = dp[i - 1][0]*(1 - p[i]);
        dp[i][i] = dp[i - 1][i - 1]*p[i];
        for(int j = 1; j < i; ++j)
            dp[i][j] = dp[i - 1][j - 1]*p[i] + dp[i - 1][j]*(1 - p[i]);
    }
    double res = 0;
    for(int i = n/2 + 1; i <= n; ++i) res += dp[n][i];
    cout << setprecision(20) << res << "\n";
}

int main() {
    n_test = 1;
    //cin >> n_test;
    for(int i = 0; i < n_test; ++i) {
        input();
        solve();
    }
}

Measured memory_bytes: 70656
numbers = gets.chomp.chars.map(&:to_i)
sum = 0
["+", "-"].each do |op1|
  ["+", "-"].each do |op2|
    ["+", "-"].each do |op3|
      sum = numbers[0]
      if op1 == "+"
        sum += numbers[1]
      elsif op1 == "-"
        sum -= numbers[1]
      end
      if op2 == "+"
        sum += numbers[2]
      elsif op2 == "-"
        sum -= numbers[2]
      end
      if op3 == "+"
        sum += numbers[3]
      elsif op3 == "-"
        sum -= numbers[3]
      end
      if sum == 7
        puts "#{numbers[0]}#{op1}#{numbers[1]}#{op2}#{numbers[2]}#{op3}#{numbers[3]}=7"
        exit
      end
    end
  end
end

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

int LEN = 100000;

class Proc {
public:
	char name[40];
	int t;
};

class Queue {
public:
	int head;
	int tail;
	Proc data[100000];
/*
	Queue() {
		head = 0;
		tail = 0;
	}
	*/
	void enqueue(Proc x) {
		data[tail] = x;
		tail = (tail+1) % LEN;
	}
	Proc dequeue(){
		Proc x = data[head];
		head = (head+1) % LEN;
		return x;
	}
};

int main(void) {
	int n, q;
	scanf("%d %d", &n, &q);

/*
	Proc *proc;
	proc = (Proc *)malloc(sizeof(Proc)*n);
*/	

	Queue queue;
	for(int i = 1; i <= n; i++) {
		scanf("%s %d", queue.data[i].name, &queue.data[i].t);
	}

	queue.head = 1;
	queue.tail = n+1;

	int elapse = 0;
	while(queue.head != queue.tail) {
		Proc proc = queue.dequeue();
		int c = (q < proc.t) ? q : proc.t;
		proc.t -= c;
		elapse += c;
		if(proc.t > 0) {
			queue.enqueue(proc);
		} else {
			printf("%s %d\n", proc.name, elapse);
		}
	}


	/*
	for(int i = 0; i < n; i++) {
		printf("%s %d\n", proc[i].name, proc[i].t);
	}
	*/

	//free(proc);
	return 0;
}


Measured memory_bytes: 7408
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;

int N, A;
int x[111];
ll coudp[111][111][5555];
string divide[4] = { "dream","dreamer","erase","eraser" };
int main()
{
	int N;
	cin >> N;

	vector<vector<int>> data(10, vector<int>(10));
	for (int i = 1; i < 10; i++)
	{
		for (int j = 1; j < 10; j++)
		{
			data[i][j] = i * j;
		}
	}

	bool ans = false;
	for (int i = 1; i < 10; i++)
	{
		for (int j = 1; j < 10; j++)
		{
			if (N == data[i][j])
			{
				ans = true;
				break;
			}
			
		}
	}

	if (ans)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	
	return 0;
}
	

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int n,m; cin>>n>>m;
  vector<int> c(n);
  vector<vector<int>> a(n,vector<int>(0));
  for(int i=0; i<m; ++i){int p,q; cin>>p>>q; a[p-1].push_back(q-1); a[q-1].push_back(p-1);}
  vector<bool> d(n,false);
  queue<int> que; que.push(0);
  while(true){
    int p=que.front(),q=a[p].size();
    while(q--) if(d[a[p][q]]==false){ que.push(a[p][q]); c[a[p][q]]=p; d[a[p][q]]=true;}
    que.pop();
    if(que.empty()) break;
  }
  bool solve=true;
  for(int i=0; i<n; ++i) solve&=d[i];
  if(solve==false){ cout<<"No"<<endl; return 0;}
  cout<<"Yes"<<endl;
  for(int i=1; i<n; ++i) cout<<c[i]+1<<endl;
  return 0;
}


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

using namespace std;

int rab[100010];
bool couple[100010];
int n;


int main() {   

  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    rab[i] = x;
  }
  int res = 0;
  for (int i = 1; i <= n; i++) {
    if (!couple[i] && rab[rab[i]] == i) {
      res++;
      couple[i] = couple[rab[i]] = 1;
    }
  }
  cout << res << "\n";
  return 0;
} 


Measured memory_bytes: 768
//
// Created on 2020/09/25.
//


#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
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; }
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;



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

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

    int one_index;
    for (int i = 0; i < n; ++i) {
        int temp;
        cin>>temp;
        if(temp == 1){
            one_index = i;
        }
    }

    int ans = 1;
//    ans += (one_index - 1 + (k-1) - 1 ) / (k-1);
//    ans += (((n-1)-one_index - 1) + (k-1) - 1) / (k - 1);
    ans += (n - k + (k - 1) -1) / (k - 1);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
#define pii pair<int,int>
#define mp make_pair
#define p push
#define f first
#define s second
using namespace std;
char b[444][444];
bool vis[444][444];
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1},n,m;
long long ans;
int main()
{
	cin>>n>>m;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			cin>>b[i][j];
		}
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			if(vis[i][j])
			{
				continue;
			}
			queue<pii>q;
			q.p(mp(i,j));
			vis[i][j]=true;
			long long cnt1=0,cnt2=0;
			while(!q.empty())
			{
				pii i=q.front();
				q.pop();
				if(b[i.f][i.s]=='.')
				{
					cnt1++;
				}
				else
				{
					cnt2++;
				}
				for(int d=0;d<4;d++)
				{
					int x=i.f+dx[d],y=i.s+dy[d];
					if(0<=x && x<n && 0<=y && y<m)
					{
						if(b[i.f][i.s]!=b[x][y] && !vis[x][y])
						{
							vis[x][y]=true;
							q.p(mp(x,y));
						}
					}
				}
			}
			ans+=cnt1*cnt2;
		}
	}
	cout<<ans<<endl; 
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = (1'000'000'000 + 7);

bool is_ok(string s)
{
    int n = s.size();
    rep(i, n / 2)
    {
        if (s[i] != s[n - 1 - i])
        {
            return false;
        }
    }
    return true;
}

int main()
{
    lld l;
    cin >> l;
    cout << fixed << setprecision(18) << (l / 3.0) * (l / 3.0) * (l / 3.0) << endl;
    return 0;
}

Measured memory_bytes: 256
/*
[abc141] B - Tap Dance
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
#define ALL(c) (c).begin(), (c).end()

string S;

bool solve() {
    for (int i = 0; i < (int)S.length(); i++) {
        if (i % 2 == 0 && S[i] == 'L') {
            return false;
        }
        if (i % 2 == 1 && S[i] == 'R') {
            return false;
        }
    }

    return true;
}

int main() {
    cin >> S;

    cout << (solve() ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256