akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
using namespace std;

int main()
{
	int n,a[100];
	cin>>n;
	for(int i=0;i<n;i++) cin>>a[i];
	
	cout<<*max_element(&a[0],&a[n])-*min_element(&a[0],&a[n])<<endl;
	
	return 0;
}


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

int main() {
    ll n;
    cin >> n;
    vector<P> v(n);
    rep(i,n) {
        ll a, b;
        cin >> a >> b;
        v[i] = {b,a};
    }
    sort(v.begin(), v.end());
    ll s = 0;
    rep(i,n) {
        P p = v[i];
        s += p.second;
        if (s > p.first) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 6400
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.IO.Pipes;
using System.Linq;
using System.Numerics;

namespace Atcoder
{
	class Program
	{
		/*
			string s = Console.ReadLine();
			string[] ST = Console.ReadLine().Split(' ').ToArray();
			string S = strArray[0];
			string T = strArray[1];

			int[] HWN = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
			int H = intArray[0];
			int W = intArray[1];
			int N = int.Parse(Console.ReadLine());

			List<int> A = new List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToList());
			
			double[] R = Console.ReadLine().Split(' ').Select(i => double.Parse(i)).ToArray();

			Boolean ok = false;
			
			List<int> dp = Enumerable.Repeat(値, 個数).ToList();
			
			Console.WriteLine(ans);
			Console.WriteLine("Yes");
			Console.WriteLine("No");
			Console.ReadKey();
			Console.WriteLine(cnt);

			for(int i= 0; i < N; i++)
		*/

		static void Main(string[] args)
		{
			int N = int.Parse(Console.ReadLine());
			int len = N.ToString().Length;
			
			if(len == 1)
            {
				Console.WriteLine(N);
				return;
			}
			
			int cnt = 0;
			int line = (int)Math.Pow(10, len - 1);

			if(len % 2 != 0)
            {
				cnt += N - line + 1;
            }
			int num = 9;
			for(int i = 1;i < line;i *= 100)
            {
				cnt += num;
				num *= 100;
            }
			Console.WriteLine(cnt);
		}

		class Item : IComparable
		{
			public string A;
			public int B;
			public Item(string a, int b)
			{
				this.A = a;
				this.B = b;
			}
			public int CompareTo(object obj)
			{
				return B - ((Item)obj).B;
			}
		}

		/// <summary>
		/// 回文
		/// </summary>
		/// <param name="Target"></param>
		/// <param name="len"></param>
		/// <returns></returns>
		static bool Palindrome(string Target , int len)
        {
			bool yes = true;

			for(int i = 0;i < len; i++)
            {
				if(Target[i] != Target[len - 1 - i])
                {
					yes = false;
					break;
                }
            }
			return yes;
        }

		/// <summary>
		/// アナグラム
		/// </summary>
		/// <param name="word1"></param>
		/// <param name="word2"></param>
		/// <returns></returns>
		static bool IsAnagramOf(string word1, string word2)
		{
			char[] val1 = word1.ToCharArray();
			char[] val2 = word2.ToCharArray();
			Array.Sort(val1);
			Array.Sort(val2);
			word1 = new string(val1);
			word2 = new string(val2);

			return word1 == word2;
			//return word1.OrderBy(x => x).SequenceEqual(word2.OrderBy(x => x));
		}

		/// <summary>
		/// 最小公倍数
		/// </summary>
		/// <param name="a"></param>
		/// <param name="b"></param>
		/// <returns></returns>
		public static BigInteger Lcm(BigInteger a, BigInteger b)
		{
			return a * b / Gcd(a, b);
		}

		/// <summary>
		/// 最大公約数
		/// </summary>
		/// <param name="a"></param>
		/// <param name="b"></param>
		/// <returns></returns>
		public static BigInteger Gcd(BigInteger a, BigInteger b)
		{
			if (a < b)
				// 引数を入替えて自分を呼び出す
				return Gcd(b, a);
			while (b != 0)
			{
				var remainder = a % b;
				a = b;
				b = remainder;
			}
			return a;
		}
	}
}

Measured memory_bytes: 27876
#include <iostream>
#include <string>

using namespace std;

int main()
{
    string str;
    cin >> str;
    string checkstr(begin(str), begin(str) + str.size() / 2);
    if (str != string(rbegin(str), rend(str)))
    {
        cout << "No\n";
        return 0;
    }
    if (checkstr != string(rbegin(checkstr), rend(checkstr)))
    {
        cout << "No\n";
        return 0;
    }
    checkstr = string(begin(str) + str.size() / 2 + 1, end(str));

    if (checkstr != string(rbegin(checkstr), rend(checkstr)))
    {
        cout << "No\n";
        return 0;
    }
    cout << "Yes\n";
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{
  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);

    String[] sl = r.readLine().split("[\\s]+");
    
    int a = Integer.parseInt(sl[0]);
    int b = Integer.parseInt(sl[1]);
    int c = Integer.parseInt(sl[2]);

    if(a > b)
    {
      int t = a;
      a = b;
      b = t;
    }
    
    if(b > c)
    {
      int t = b;
      b = c;
      c = t;
    }
    
    if(a > b)
    {
      int t = a;
      a = b;
      b = t;
    }
    
    if(a == b && b == c)
    {
      System.out.println(0);
      System.exit(0);
    }
    
    if(b == c)
    {
      if((b - a) % 2 == 0)
      {
        System.out.println((b - a) / 2);
        System.exit(0);
      }
      else
      {
        System.out.println((b - a + 1) / 2 + 1);
        System.exit(0);
      }
    }
    
    if(a == b)
    {
      System.out.println(c - a);
      System.exit(0);
    }

    // a < b < c
    
   int v = 0;
   v += c - b;
   a += c - b;
   b += c - b;
   
   if((b - a) % 2 == 0)
   {
     System.out.println(v + (b - a) / 2);
     System.exit(0);
   }
   else
   {
     System.out.println(v + (b - a + 1) / 2 + 1);
     System.exit(0);
   }

  }
}


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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair



int main() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << min(c, b / a) << endl;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
//#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>

using namespace std;


int main(){
    char C[2][3];
    cin >> C[0][0] >> C[0][1] >> C[0][2];
    cin >> C[1][0] >> C[1][1] >> C[1][2];

    if(C[0][0] == C[1][2] and C[0][1] == C[1][1] and C[0][2] == C[1][0]){
        puts("YES");
        return 0;
    }else{
        puts("NO");
        return 0;
    }

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*(b/gcd(a,b));}
int main(){
  int n,a,b;
  scanf("%d",&n);
  for(scanf("%d",&a);--n;a=lcm(a,b))scanf("%d",&b);
  printf("%d\n",a);
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n-1);
  for (int i = 0;i < n;i++){
    cin >> a[i];
  }
  for (int i = 0;i < n;i++){
    cin >> b[i];
  }
  for (int i = 0;i < n-1;i++){
    cin >> c[i];
  }
  int ans = 0;
  
  for (int i = 0;i < n;i++){
    ans += b[i];
  }
  for (int i = 0;i < n-1;i++){
    if (a[i]+1 == a[i+1]){
      ans += c[a[i]-1];
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
typedef long long ll;

ll qpow(ll a, ll k) {
    ll res = 1;
    while(k) {
        if(k & 1)
            res = (a * res) % mod;
        k >>= 1;
        a = (a * a) % mod;
    }
    return res;
}
ll C(ll a, ll b, ll p) {
    if(b > a)
        return 0;
    if(a == b)
        return 1;
    ll ans1 = 1;
    ll ans2 = 1;
    for(ll i = 1; i <= b; i++) {
        ans1 = ans1 * (a - i + 1) % p;
        ans2 = ans2 * i % p;
    }
    return ans1 * qpow(ans2, p - 2) % p;
}
ll lucas(ll a, ll b, ll p) {
    if(b == 0)
        return 1;
    return C(a % p, b % p, p) * lucas(a / p, b / p, p) % p;
}
int main() {
    ll n, a, b;
    scanf("%lld%lld%lld", &n, &a, &b);
    ll sum = qpow(2, n)-1;
    ll sum1 = lucas(n, a, mod);
    ll sum2 = lucas(n, b, mod);
    printf("%lld\n", (sum - sum1 - sum2 + mod + mod) % mod);

}


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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    long long n;
    cin >> n;
    int ans = 0;
    auto r = n;
    for (long long d = 2; d*d <= n; d++) {
        int c = 0;
        while (r % d == 0) {
            r /= d;
            c++;
        }
        for (int j = 1; c >= j; j++) {
            c -= j;
            ans++;
        }
    }
    if (r > 1) {
        ans++;
    }
    cout << ans << endl;
}



Measured memory_bytes: 3652
#include <cstdio>
#include <string>
#include <algorithm>

using namespace std;

int main() {
    char buf[1<<4];
    scanf("%s", buf);
    string W(buf);
    transform(W.begin(), W.end(), W.begin(), [](char c)->char {
        return c |= 0x20;
    });

    int res=0;
    string T;
    for (char c; scanf("%c", &c)!=EOF;) {
        if (((c|0x20)>='a'&&(c|0x20)<='z') || c=='-' || c=='_') {
            T += c;
            continue;
        }

        if (T == "END_OF_TEXT") break;
        if (!T.length()) continue;

        transform(T.begin(), T.end(), T.begin(), [](char c)->char {
            return c |= 0x20;
        });

        if (W == T)
            ++res;

        T = "";
    }

    printf("%d\n", res);
    fprintf(stderr, "-");
    return 0;
}       

Measured memory_bytes: 2820
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");

for(var i=0;i<Arr.length;i=i+2){
   var a=Arr[i].split(" ").map(Number);
   var b=Arr[i+1].split(" ").map(Number);
   var hit=0;
   var blow=0;
   for(var j=0;j<4;j++){
      if(a[j]===b[j])hit++;
      else if(a.indexOf(b[j])!=-1)blow++;
   }
   console.log(hit+" "+blow);
}

Measured memory_bytes: 7644
#include<bits/stdc++.h>
#define N 100005
using namespace std;
int n;
int a[N];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	int mx=-1e9,mn=1e9;
	for(int i=1;i<=n;i++) mx=max(mx,a[i]),mn=min(mn,a[i]);
	if(mx-mn>=2) return puts("No"),0;
	if(mn==mx){
		if(n-1==mn||mn<=n/2) return puts("Yes"),0;
		return puts("No"),0;
	}
	int sm=0,bg=0;
	for(int i=1;i<=n;i++) if(a[i]==mn) sm++;
	bg=n-sm;
	int col=mx-sm;
	if(col<=0||col>bg/2) return puts("No"),0;
	return puts("Yes"),0;
} 

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <stdio.h>
#define fin freopen("input", "r", stdin)
#define whatis(x) cerr << #x << ": " << x << endl;

using namespace std;
using ll = long long;

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

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

    if (n % 2 == 1) {
        cout << "0" << endl;
        return 0;
    }

    sort(ar.begin(), ar.end());

    int mid = n/2;

    int ans = ar[mid] - ar[mid-1];

    cout << ans << endl;

    


    return 0;
}



Measured memory_bytes: 640
def Nroll(list):
	a = [list[1],list[5],list[2],list[3],list[0],list[4]]
	return a
def Wroll(list):
	a = [list[2],list[1],list[5],list[0],list[4],list[3]]
	return a
dice = list(map(int,input().split()))
roll = str(input())
pos = [0,1,2,3,4,5]
for i in roll:
	if i == "N":
		pos = Nroll(pos)
	elif i == "S":
		pos = Nroll(Nroll(Nroll(pos)))
	elif i == "W":
		pos = Wroll(pos)
	else:
		pos = Wroll(Wroll(Wroll(pos)))
print(dice[pos[0]])


Measured memory_bytes: 5604
#include <cstdio>
#include <utility>
#include <vector>
#include <algorithm>
using namespace std;

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

int main() {
	auto read = [](int n) {
		vector<int> v;
		while (n--)
			v.push_back(in());
		return move(v);
	};
	vector<int> a = read(in()), b = read(in()), r;
	set_symmetric_difference(a.begin(), a.end(), b.begin(), b.end(), inserter(r, r.end()));
	for (int x: r)
		outl(x);
}


Measured memory_bytes: 5884
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = Integer.parseInt(sc.next());
        int w = Integer.parseInt(sc.next());
        List<String> a = new ArrayList<>();
        for (int i = 0; i < h; i++) {
            String s = sc.next();
            if (s.contains("#")) {
                a.add(s);
            }
        }
        sc.close();
        List<Integer> b = new ArrayList<>();
        for (int i = 0; i < w; i++) {
            boolean f = false;
            for (String x : a) {
                if (x.charAt(i) == '#') {
                    f = true;
                    break;
                }
            }
            if (f) {
                b.add(i);
            }
        }
        for (String x : a) {
            for (int i = 0; i < w; i++) {
                if (b.contains(i))
                    System.out.print(x.charAt(i));
            }
            System.out.println();
        }
    }
}

Measured memory_bytes: 25032
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

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

#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

use std::f64::consts::PI;

fn main() {
    let v = read_vec::<f64>();
    let a = v[0];
    let b = v[1];
    let c = v[2];

    let s = a * b * (2.0 * PI * c / 360.0).sin() / 2.0;
    println!("{}", s);
    let l = a + b + (a * a + b * b - 2.0 * a * b * (2.0 * PI * c / 360.0).cos()).sqrt();
    println!("{}", l);
    let h = b * (2.0 * PI * c / 360.0).sin();
    println!("{}", h);
}



Measured memory_bytes: 5184
import sys
from collections import Counter
input = sys.stdin.readline

N = int(input())
A = input().split()
a = Counter(A)

ans_all = 0
for x in a.keys():
    m = a[x]
    ans_all += m * (m - 1) // 2

for x in A:
    m = a[x] - 1
    print(ans_all - m)


Measured memory_bytes: 26768
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int a, b, c, k;

int solve() {
    if (k <= a) return k;
    k -= a;
    if (k <= b) return a;
    k -= b;
    return a - k;
}

void input() {
    cin >> a >> b >> c >> k;
}

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

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 3156
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
using namespace std;
typedef long long ll;
typedef long long int llint;
typedef pair<ll, ll> pa;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define MAX_T 1001
#define pi pair<int,int>
#define pl pair<ll,ll>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define INF (1 << 29) //536870912 2の29乗
const long double PI = acos(-1);
const ll DEP = 1e18;
const int I = 1001001001001001ll;
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
bool check[100001];
int p[100001];
int main(){
    int N; cin >> N;
    for(int i = 0; i < N; i++){
        cin >> p[i];
        if(i+1 == p[i]) check[i] = true;
        else check[i] = false;
    }
    int ans = 0;
    for(int i = 1; i < N; i++){
        //cout << check[i] << endl;
        if(check[i-1] && check[i]){
            ans++;
            check[i-1] = false;
            check[i] = false; 
        } else if(!check[i] && check[i-1]){
            ans++;
            check[i-1] = false;
        }
    }
    if(check[N-1]) ans++;
    cout << ans << endl;
}


Measured memory_bytes: 768
#include <stdio.h>
const int N =305;
const int M = 305;
int main()
{
	int m, n;
	while(scanf("%d %d", &n, &m))
	{
		if(n == 0 && m == n)
		{
			break;
		}
		for(int i = 0; i < n; i++)
		{
			for(int j = 0; j < m ; j++)
			{
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
}


Measured memory_bytes: 2028
#include <stdio.h>

int main()
{
	int i, N, a[101], count = 0;
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d", &(a[i]));
	for (i = 2; i <= N; i++) {
		if (a[i] == a[i-1]) {
			count++;
			i++;
		}
	}
	printf("%d\n", count);
	fflush(stdout);
	return 0;
}

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

constexpr int64_t M = 55;
constexpr int64_t MAX = 1LL << M;

int main() {

    int N;	cin >> N;

    vector<int> A(N), B(N);
    REP(i, N) cin >> A[i];
    REP(i, N) cin >> B[i];

    function<bool(int64_t)> check = [&](int64_t m) {
        vector<bool> dp;
        for (int i = 0; i < N; ++i) {
            dp.assign(M + 1, false);
            dp[A[i]] = true;
            for (int j = M; j > 0; --j) if (m & (1LL << j)) {
                for (int k = 0; k <= M; ++k) {
                    if (dp[k]) dp[k % j] = true;
                }
            }
            if (not dp[B[i]]) return false;
        }
        return true;
    };

    int64_t ok = MAX, ng = -1;
    while (abs(ok - ng) > 1) {
        int64_t mid = (ok + ng) / 2;
        if (check(mid)) ok = mid;
        else ng = mid;
    }

    cout << (ok == MAX ? -1 : ok) << endl;

}

Measured memory_bytes: 256
function Main(input) {
	const setting = input.trim().split('\n')
  const str_max_len = setting[0] - 0
  const str = setting[1].split('')

  if (str.length <= str_max_len) {
    console.log(setting[1])
  } else {
    str.splice(str_max_len, str.length, '...')
    console.log(str.join(''))
  }
    }

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 30280
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const int mod=924844033;
const int N=4005;
int n,k;
bool vis[N][2];
bool ed[N];
int tot;
int d[N][N][2];
int f[N];
int fact[N];
int main()
{
    //freopen("captain.in","r",stdin);
    //freopen("captain.out","w",stdout);
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)
        for(int j=0;j<=1;j++)
            if(!vis[i][j]){
                int len=0;
                for(int x=i,y=j;x<=n;x+=k,y^=1)
                    vis[x][y]=1,len++;
                tot+=len;
                ed[tot]=1;
            }
    ed[0]=1;
    d[0][0][0]=1;
    for(int i=0;i<2*n;i++)
        for(int j=0;j<=n;j++){
            d[i+1][j][0]=(d[i][j][0]+d[i][j][1])%mod;
            if(!ed[i])
                d[i+1][j+1][1]=d[i][j][0];
        }
    for(int i=0;i<=n;i++)
        f[i]=(d[2*n][i][0]+d[2*n][i][1])%mod;
    fact[0]=1;
    for(int i=1;i<=n;i++)
        fact[i]=1ll*fact[i-1]*i%mod;
    int ans=0;
    for(int i=0,j=1;i<=n;i++,j=-j)
        ans=((1ll*ans+1ll*j*fact[n-i]*f[i]%mod)%mod+mod)%mod;
    printf("%d\n",ans);
}


Measured memory_bytes: 124544
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int cut[200005];
int main() {
  int n,k; cin >> n >> k;
  REP(i,n) {
    int a; cin >> a;
    cut[a-1]++;
  }
  sort(cut, cut+n);
  int ans = 0;
  REP(i,n-k) ans+=cut[i];
  COUT(ans);
  return 0;
}

Measured memory_bytes: 1024
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
# from scipy.sparse.csgraph import floyd_warshall
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations, combinations_with_replacement
from heapq import heappop, heappush, heapify
from fractions import gcd
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7

def main():
    n,d = map(int,input().split())
    ans = 0
    for _ in range(n):
        x,y = map(int,input().split())
        if (x**2 + y**2)**0.5 <= d:
            ans += 1
    print(ans)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 80196
#include <iostream>

int main() {
    int n, a, b;
    scanf("%d %d %d", &n, &a, &b);
    int sum = 0;
    int num = 0;
    int abc = 0;
    int res = 0;
    for (int i = 1; i <= n; i++) {
        num = i;
        sum = 0;
        while (num > 0) {
            abc = num % 10;
            num = num / 10;
            sum = sum + abc;
        }
        if (sum >= a && sum <= b) {
            res = res + i;
        }
    }
    printf("%d\n", res);
}


Measured memory_bytes: 256
import Control.Monad

main = do
  n <- readLn
  a <- (map read) <$> replicateM n getLine
  putStrLn . show $ solve n a

solve:: Int -> [Int] -> Int
solve n a
  | mod ss 10 /= 0 = ss
  | length aa == 0 = 0
  | otherwise = ss - (minimum $ aa)
  where
    ss = sum a
    aa = filter (\x -> mod x 10 /= 0) a

Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main(){
  char a, b;
  cin >> a >> b;
  if(a=='H'){
    if(b=='H'){
      cout << 'H' << endl;
    }else{
      cout << 'D' << endl;
    }
  }else{
    if(b=='H'){
      cout << 'D' << endl;
    }else{
      cout << 'H' << endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = null;

		try {
			while ((line = br.readLine()) != null) {
				char[] charArray = line.trim().toCharArray();
				if(charArray.length > 20) System.exit(-1);
				
				for(int i = charArray.length - 1; i >= 0; i--){
					System.out.print(charArray[i]);
				}
				System.out.println("");
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 16860
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#include <bits/stdc++.h>
 
#define se second
#define fi first
#define mp make_pair
#define pb push_back
 
using namespace std;
 
typedef long long ll;

int x, y;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> x >> y;
	for(int a = 0; a <= x; a++){
		int b = x - a;
		if(a * 2 + b * 4 == y){
			cout << "Yes";
			exit(0);
		}
	}
	cout << "No";
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <sstream>
#include <algorithm>

using namespace std;

#define	numberof(a)	(sizeof(a) / sizeof(a[0]))
#define	INF		(1000000)
#define Rep(i,n) for(int i = 0; i < (n); i++ )

using namespace std;

typedef long long ll;

int main()
{
	ll A = 0;
	ll B = 0;

	cin >> A >> B;
	cout << max(A + B, max(A - B, A * B)) << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
const ll INF=1000000000LL;
const int MAX=100001;
const double EPS=1e-10;
int main(){
    int n,h,w;
    cin>>n>>w>>h;
    int x[100010]={};
    int y[100010]={};
    for(int i=0;i<n;i++){
        int xx,yy,ww;
        cin>>xx>>yy>>ww;
        x[max(0,xx-ww)]++;
        x[min(w,xx+ww)]--;
        y[max(0,yy-ww)]++;
        y[min(h,yy+ww)]--;
    }
    bool fx=true;bool fy=true;
    for(int i=0;i<w;i++){
        if(i)x[i]+=x[i-1];
        if(x[i]<1){
            fx=false;
        }
    }
    for(int i=0;i<h;i++){
        if(i)y[i]+=y[i-1];
        if(y[i]<1){
            fy=false;
        }
    }
    if(fx||fy){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}



Measured memory_bytes: 3896
/*------------------------------------------------,
|  __                                       __    |
| |  |--.-----.---.-.----.----.-----.-----.|  |_  |
| |  _  |  -__|  _  |  __|  __|  -__|  _  ||   _| |
| |_____|_____|___._|____|____|_____|   __||____| |
|                                   |__|          |
`------------------------------------------------*/
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdint>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

typedef long long ll;
using namespace std;
#define INF 2147483647
#define MOD 10000007
#define REP(count_ver, lower, upper) for (long long count_ver = lower; count_ver < upper; count_ver++)

int gcd(int a, int b) {
  if (a % b == 0) {
    return (b);
  } else {
    return (gcd(b, a % b));
  }
}
int lcm(int a, int b) { return a * b / gcd(a, b); }
bool isPrime(int a) {
  if (a == 1)     return false;
  if (a == 2)     return true;
  if (a % 2 == 0) return false;
  for (int i = 3; i < sqrt(a) + 1; i += 2) if (a != i and a%i==0) return false;
  return true;
}

void execute(){

  int a;
  cin>>a;
  cout<<(a)+(a*a)+(a*a*a)<<endl;

}
int main() {

  cin.tie(0);
  ios::sync_with_stdio(0);
  //cout<<fixed<<setprecision(20);

  execute();

  return 0;
}


Measured memory_bytes: 3688
#include<cstdio>
const int MAXN=3005,MOD=1000000007;

int N,M;
int dp[MAXN][MAXN][2];

int main()
{
	scanf("%d%d",&N,&M);
	dp[0][0][1]=1;
	for(int i=1;i<=N;i++)
		dp[0][i][0]=1;
	for(int i=0;i<M;i++)
		for(int j=0;j<=N;j++)
			for(int k=0;k<2;k++)
			{
				if(j>0)
				{
					(dp[i+1][j-1][k|(j==1)]+=dp[i][j][k])%=MOD;
					(dp[i+1][j][k|(j==1)]+=dp[i][j][k])%=MOD;
				}
				if(j<N)
				{
					(dp[i+1][j+1][k]+=dp[i][j][k])%=MOD;
					(dp[i+1][j][k]+=dp[i][j][k])%=MOD;
				}
			}
	int ans=0;
	for(int j=0;j<=N;j++)
		(ans+=dp[M][j][1])%=MOD;
	printf("%d\n",ans);
	
	return 0;
}


Measured memory_bytes: 70656
n,m,c = map(int, input().split())
b = list(map(int, input().split()))
a = [list(map(int, input().split())) for num in range(n)]
cnt = 0
for i in range(n):
    total = [el1 * el2 for (el1, el2) in zip(a[i], b)]
    if sum(total) + c > 0:
        cnt += 1
    else:
        continue
print(cnt)

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

int main()
{
	LL A,B;
	string ss;
	cin>>A>>B>>ss;
	if(ss[A]!='-')
	{
		cout<<"No"<<endl;
		return 0;
	}
	for(int i=0;i<A+B;i++)
	{
	 	if(i==A)continue;
	 	if(ss[i]<'0'||ss[i]>'9')
	 	{
	 		cout<<"No"<<endl;
	 		return 0;
		}
	}
	
	cout<<"Yes"<<endl;
	return 0;
 } 

Measured memory_bytes: 256
#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(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

using namespace std;
using ll = long long;
using P = pair<int,int>;

constexpr int MOD = 1000000007;
constexpr int INF = 1001001001;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

int main() {
    int w, h, x, y;
    cin >> w >> h >> x >> y;
    
    double s = w / 2.0 * h;
    cout << setprecision(10) << s << " ";
    
    if (x * 2 == w && y * 2 == h)
        cout << 1 << endl;
    else
        cout << 0 << endl;
    
    return 0;
}


Measured memory_bytes: 3740
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp>
//#include <functional> // for less
#define PI acos(-1.0)
#define eps 1e-9
#define ll long long
#define ull unsigned long long
#define nl printf("\n")
#define sf scanf
#define pf printf
#define INF (ll)1e15
#define mod 1000000007

///#define isValid(n,m,nx,ny)nx>=0&&nx<n&&ny>=0&&ny<m
///int kx[]={1, 1, -1, -1, 2, 2, -2, -2}; //knight moves
///int ky[]={2,-2,  2, -2, 1,-1,  1, -1}; //knight moves
///int dx[]={1,-1,0,0,1,-1,1,-1};//eight direction
///int dy[]={0,0,1,-1,1,-1,-1,1};//eight direction
 
///using namespace __gnu_pbds;
using namespace std;
 
///inline double toRad(double deg){return deg*PI/180;}
///inline double toDeg(double rad){return rad*180/PI;}
///typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;
 
const int S=123456;
int main()
{
    #ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
    #endif
    string s;
    while(cin>>s)
    {
        bool f=false;
        for(int i=0;i<=1;i++)
        {
            for(int j=0;j<=1;j++)
            {
                for(int k=0;k<=1;k++)
                {
                    int a=s[0]-'0',b=s[1]-'0',c=s[2]-'0',d=s[3]-'0';
                    int num=0;
                    if(i==0)num=a-b;
                    else num=a+b;

                    if(j==0)num-=c;
                    else num+=c;

                    if(k==0)num-=d;
                    else num+=d;

                    if(num==7)
                    {
                        pf("%d",a);
                        if(i==0)pf("-");
                        else pf("+");

                        pf("%d",b);
                        if(j==0)pf("-");
                        else pf("+");

                        pf("%d",c);
                        if(k==0)pf("-");
                        else pf("+");

                        pf("%d=7\n",d);
                        f=true;
                        break;
                    }
                }
                if(f)break;
            }
            if(f)break;
        }
    }
    return 0;
}
 









 




























Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
using namespace std;

typedef long long ll;
ll MOD = 1e9+7;

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

int main()
{
	ll n,m;
	ll ans=1;
	cin>>n>>m;
	
	ans=m/n;
	while(m%ans!=0)
		ans--;
	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
/*ex4_2
series2*/

# include <stdio.h>
# include <math.h>
int main(void){
    //各文字の箱を作って読み取り
    int l_hand,s_hand,hour,minute;
    scanf("%d %d %d %d",&l_hand,&s_hand,&hour,&minute);
    //二本の針の差を0以上pi以下で計算
    //2*M_PI*(60*hour+minute)/(12*60)は時針の進んだ角度
    //2*M_PI*minute/60は分針の進んだ角度
    double diff=2*M_PI*(60*hour+minute)/(12*60)-2*M_PI*minute/60;
    //余弦定理を用いて端点の差を計算
    printf("%.20f\n",sqrt((l_hand*l_hand+s_hand*s_hand-2*l_hand*s_hand*cos(diff))));
    return 0;
}


Measured memory_bytes: 2596
N = int(input())
dp = [10**9]*(N+1)
dp[0] = 0
for i in range(N):
    j = 1
    while i+6**j <= N:
        dp[i+6**j] = min(dp[i+6**j], dp[i] + 1)
        j += 1
    j = 1
    while i+9**j <= N:
        dp[i+9**j] = min(dp[i+9**j], dp[i] + 1)
        j += 1

print(min(dp[i] + N-i for i in range(N+1)))





Measured memory_bytes: 3828
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)
	s := []rune(nextLine())
	K := nextInt()

	ans := make([]string, 0)
	m := map[string]int{}

	// right := 0
	for left := 0; left < len(s); left++ {
		for right := left + 1; right < min(len(s)+1, left+1+K); right++ {

			if _, ok := m[string(s[left:right])]; !ok {
				ans = append(ans, string(s[left:right]))
				m[string(s[left:right])]++
			}

		}

		// if right == left {
		// 	right++
		// }
	}

	sort.Strings(ans)
	fmt.Println(ans[K-1])

}

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


Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;

int N, ans;
int A[202020];
vector<pii> S;

bool f(int k){
    S.clear();
    for (int i=2; i<=N; i++){
        if (A[i-1] < A[i]) continue;
        if (k <= 1) return false;
        while (!S.empty() && S.back().first > A[i]) S.pop_back();
        for (int j=A[i]; ; j--){
            if (j <= 0) return false;
            if (S.empty()){
                S.push_back(pii(j, 2));
                break;
            }
            pii t = S.back();
            S.pop_back();
            if (t.first == j){
                if (t.second >= k) continue;
                t.second++;
                S.push_back(t);
            }
            else {
                S.push_back(t);
                S.push_back(pii(j, 2));
            }
            break;
        }
    }
    return true;
}

int main(){
    int L, H;
    scanf("%d", &N);
    for (int i=1; i<=N; i++) scanf("%d", &A[i]);
    for (L=1, H=N; L<=H; ){
        int mid = (L+H)/2;
        if (f(mid)) ans = mid, H = mid-1;
        else L = mid+1;
    }
    printf("%d\n", ans);
    return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
using namespace std;
 
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(), a.end()
#define rep(i, st, n) for (int i = (st); i < (n); ++i)
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ld;
 
template <typename T1, typename T2> bool chkmin(T1 &x, T2 y) { return y < x ? (x = y, true) : false; }
template <typename T1, typename T2> bool chkmax(T1 &x, T2 y) { return y > x ? (x = y, true) : false; }

void yes()
{
    cout << "Yes\n";
    exit(0);
}
void no()
{
    cout << "No\n";
    exit(0);
}

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
#ifdef DEBUG
    freopen("in", "r", stdin);
#endif
    
    int n;
    cin >> n;
    map<int, int> cnt;
    for (int i = 0; i < n; ++i)
    {
        int x;
        cin >> x;
        cnt[x]++;
    }
    if (cnt.size() >= 4)
        no();
    if (cnt.size() == 1)
        if (cnt.begin()->fi == 0)
            yes();
        else
            no();
    if (n % 3 != 0)
        no();
    
    vector<pii> t;
    for (auto el : cnt) t.pb(el);
    sort(all(t));
    if (t.size() == 2 && t[0] == mp(0, n / 3) || t.size() == 3 && (t[0].fi ^ t[1].fi ^ t[2].fi) == 0 && t[0].se == n / 3 && t[1].se == n / 3)
    {
        yes();
    }
    else
    {
        no();
    }

    return 0;
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
#define tl 1'000'000'007
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REREP(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, a, n) for (ll i = a; i < n; i++)
#define REFOR(i, n, a) for (ll i = n; i >= a; i--)
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false); 
    ll n;
    cin >> n;
    ll cnt1= 1;
    ll cnt2= 1;
    while(n!=1){
        n/=2;
        cnt2= cnt2*2;
        cnt1+=cnt2;
        // cout << cnt2 << endl;
    }
    cout << cnt1 << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h> 
#include<limits.h>
#include <stdbool.h>
typedef  unsigned long long ll;
#define MOD 10e9+7  //10億　= 10^9
#define length 100000+3000 //10万
#define kw_len 10+2
#define INF 16446000000009000
#define pi 3.1415926535897932384
char oo[100][100];
int main(){
    ll T,Y;
    bool flag=false;
    scanf("%llu%llu",&T,&Y);
    for(int i=0;i<T;i++){
        scanf("%s",oo+i);
    }

    for(int i=0;i<T;i++){
        flag = true;
        for(int j=0;j<Y;j++){
            if(oo[i][j]=='#'){
                flag=false;
            }
        }
        if(flag){
            memset(oo[i],0,Y);
        }
    }
    for(int i=0;i<Y;i++){
        flag = true;
        for(int j=0;j<T;j++){
            if(oo[j][i]=='#'){
                flag=false;
            }
        }
        if(flag){
            for(int n=0;n<T;n++){
                oo[n][i] =0;
            }
        }
    }
    printf("\n\n");
    for(int i=0;i<T;i++){
        for(int j=0;j<Y;j++){
            if(oo[i][j]!=0){
                printf("%c",oo[i][j]);
            }
        }
        printf("\n");
        
    }
    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <bitset>
using namespace std;
const int maxn = 405, maxm = 100005;
int N, M, a[maxm], b[maxm];
bitset<maxn> s[maxn];
int main() {
	scanf("%d %d", &N, &M);
	for(int i = 1; i <= M; ++i) 
		scanf("%d %d", a + i, b + i);
	for(int i = 1; i <= N; ++i) {
		bitset<maxn> &S = s[i];
		S[i] = 1;
		for(int j = M; j; --j) {
			if(S[a[j]] && S[b[j]]) {
				S[0] = 1; break;
			} 
			if(S[a[j]]) S[b[j]] = 1;
			if(S[b[j]]) S[a[j]] = 1;
		}
	}
	int ans = 0;
	for(int i = 1; i <= N; ++i) if(!s[i][0]) {
		for(int j = 1; j < i; ++j) if(!s[j][0]) {
			ans += not (s[i] & s[j]).any();
		}
	}
	printf("%d\n", ans);
	return 0;
}

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

typedef long long ll;

using namespace std;

int main()
{
    ll n;

    cin >> n;

    vector<ll> a(n);

    for (auto &i: a)
        cin >> i;

    vector<ll> sorted(a);

    sort(sorted.begin(), sorted.end(), greater<ll>());

    ll j (0);
    for (ll i=0; i<n; ++i)    
    {
        if (a[i] != sorted[j])
        {
            cout << sorted[j] << endl; 
        }
        else
        {
            cout << sorted[j+1] << endl; 
        }
    }

    return 0;
}


Measured memory_bytes: 4736
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

ll mpow(ll a, ll b){
	if(b==0){
		return a;
	}else if(b%2==0){
		ll memo = mpow(a,b/2);
		return memo*memo%MOD;
	}else{
		return mpow(a,b-1) * a % MOD;
	}
}

int main(void){
	string s;
	cin>>s;
	rep(i,3){
		if(s[i] == s[i+1]){
			cout<<"Bad"<<endl;
			return 0;
		}
	}
	cout<<"Good"<<endl;
	return 0;
}


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

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

    int x;

    cin >> x;

    if(x>=30)
    {
        cout << "Yes";
    }

    else
    {
        cout << "No";
    }


}


Measured memory_bytes: 3608
#include <iostream>
#include <string>

using namespace std;

int main()
{
    string s;
    cin >> s;
    if (s[0]==s[1] && s[0] != s[2])
    {
        if (s[2]==s[3])
            cout << "Yes";
        else cout << "No";
    }
    else if (s[0]==s[2] && s[0] != s[1])
    {
        if (s[1]==s[3])
            cout << "Yes";
        else cout << "No";
    }
    else if (s[0]==s[3] && s[0] != s[1])
    {
        if (s[1]==s[2])
            cout <<  "Yes";
        else cout << "No";
    }
    else cout << "No";
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N;
    cin >> N;
    
    int* p = new int[N];
    int mistake_num = 0;
    
    for(int i=0; i<N; i++)  cin >> p[i];
    
    for(int i=0; i<N; i++){
        if(p[i] != i + 1)   mistake_num++;
    }
    
    if(mistake_num <= 2)    cout << "YES" << endl;
    else    cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    int A, B, C;
    cin>>A>>B>>C;
    bool k=false;
    if(A==B && B!=C) k=true;
    if(A==C && B!=C) k=true;
    if(C==B && B!=A) k=true;
    cout<<(k==true ? "Yes" : "No")<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static int[] boo = new int[100000];
	public static void main(String[] args)throws Exception{
		//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Scanner sc = new Scanner(System.in);
		
		int n = (sc.nextInt());
		//String[] st = br.readLine().split(" ");
		//boolean[] boo = new boolean[100000];
		
		for (int i = 0; i < n; i++) {
			//boo[Integer.parseInt(st[i])%100000] = 1;
			boo[sc.nextInt()%100000] = 1;
		}
		
		int ans = 0;
		//n = Integer.parseInt(br.readLine());
		n = Integer.parseInt(sc.next());
		//st = br.readLine().split(" ");
		for (int i = 0; i < n; i++) {
//			ans += boo[Integer.parseInt(st[i])%100000] ;
			ans += boo[sc.nextInt()%100000] ;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 81064
# 1ずつ増える等差数列の和を返す
# rが右端、lが右端
def sum(l, r)
  (l+r)*(r-l+1)/2
end

B = 10**9 +7
N, K = gets.chomp.split.map(&:to_i)

ans = 0
K.upto(N+1) do |k|
  r_sum = sum(N+1-k, N)
  l_sum = sum(0, k-1)
  ans += r_sum - l_sum + 1
  ans = ans.modulo(B)
end
puts ans


Measured memory_bytes: 14376
#include<bits/stdc++.h>
using namespace std;
struct node{
  node *prev,*next;
  int v;
  node(){next=NULL;}
  node(int v):v(v){next=NULL;}
};
struct mlist{
  node *head,*tail;
  mlist(){
    head=new node();
    tail=new node();
    head->next=tail;
    tail->prev=head;
  }
  void push_front(int v){
    node *tmp=new node(v);
    tmp->next=head->next;
    tmp->next->prev=tmp;
    head->next=tmp;
    tmp->prev=head;
  }
  void pop_front(){
    if(head->next==tail) return;
    node *tmp=head->next->next;
    if(tmp!=NULL) delete(head->next);
    head->next=tmp;
    tmp->prev=head;
  }
  void pop_back(){
    if(tail->prev==head) return;
    node *tmp=tail->prev->prev;
    if(tmp!=NULL) delete(tail->prev);
    tail->prev=tmp;
    tmp->next=tail;
  }
  void erase(int x){
    for(node *it=head->next;it!=tail;it=it->next){
      if(it->v==x){
	it->prev->next=it->next;
	it->next->prev=it->prev;
	delete(it);
	break;
      }
    }
  }
  int front(){
    return head->next->v;
  }
  bool empty(){
    return head->next==NULL;
  }
  node *begin(){
    return head->next;
  }
  node *end(){
    return tail;
  }
};
signed main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin>>n;
  mlist l;
  for(int i=0;i<n;i++){
    string s;
    int x;
    cin>>s;
    if(s=="insert"||s=="delete") cin>>x;
    if(s=="deleteFirst"){
      l.pop_front();
      continue;
    }
    if(s=="deleteLast"){
      l.pop_back();
      continue;
    }
    if(s=="insert"){
      l.push_front(x);
      continue;
    }
    if(s=="delete"){
      l.erase(x);
      continue;
    }
  }
  bool f=0;
  for(node *it=l.begin();it!=l.end();it=it->next){
    if(f) cout<<" ";
    cout<<it->v;
    f=1;
  }
  cout<<endl;
  return 0;
}

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

int main() {

    string s1, s2;

    cin >> s1 >> s2;


    int sum = 0;
    for(int i = 0; i < s1.size(); ++i)
        if(s1[i] != s2[i])
            sum++;

    cout << sum << endl;

    return 0;

}

Measured memory_bytes: 3824
#include <algorithm>
#include <cmath>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <vector>

using namespace std;

int main(void) {
  int N, M, K;

  cin >> N >> M >> K;
  vector<int64_t> N_v(N + 1), M_v(M + 1);
  N_v[0] = 0;
  M_v[0] = 0;
  int x;
  for (int i = 1; i <= N; i++) {
    cin >> x;
    N_v[i] = N_v[i - 1] + x;
  }
  for (int i = 1; i <= M; i++) {
    cin >> x;
    M_v[i] = M_v[i - 1] + x;
  }

  int ans = 0, idx = M;
  for (int i = 0; i <= N && N_v[i] <= K; i++) {
    while (N_v[i] + M_v[idx] > K) {
      idx--;
    }
    ans = max(ans, i + idx);
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 6392