akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>

using namespace std;

class DICE{
public:
    int top;
    int bottom;
    int right;
    int left;
    int front;
    int back;
    void South();
    void North();
    void East();
    void West();
    void LF();
    void RF();
};

void DICE::South(){
    int temp = back;
    back = top;
    top = front;
    front = bottom;
    bottom = temp;
}

void DICE::North(){
    int temp = front;
    front = top;
    top = back;
    back = bottom;
    bottom = temp;
}

void DICE::West(){
    int temp = left;
    left = top;
    top = right;
    right = bottom;
    bottom = temp;
}

void DICE::East(){
    int temp = right;
    right = top;
    top = left;
    left = bottom;
    bottom = temp;
}

void DICE::RF(){
    int temp = front;
    front = left;
    left = back;
    back = right;
    right = temp;
}

void DICE::LF(){
    int temp = front;
    front = right;
    right = back;
    back = left;
    left = temp;
}


int main(){
    DICE d;
    cin>>d.top>>d.back>>d.right>>d.left>>d.front>>d.bottom;
    int n;
    cin>>n;

    for(int i=0;i<n;i++){
        int top,back;
        cin>>top>>back;
        if(d.top != top)
        {
            d.South();
            if(d.top != top)
            {
                d.South();
                if(d.top != top)
                {
                    d.South();
                    if(d.top != top)
                    {
                        d.South();
                        if(d.top != top)
                        {
                            d.East();
                            if(d.top != top)
                            {
                                d.East();
                                d.East();
                            }
                        }
                    }
                }
            }
        }

        if(d.back != back)
        {
            d.RF();
            if(d.back != back)
            {
                d.RF();
                if(d.back != back)
                {
                    d.RF();
                    if(d.back != back){
                        d.RF();
                    }
                }
            }
        }

        cout<<d.right<<endl;
    }

    return 0;
}

Measured memory_bytes: 1160
/*/ Author: KaySeeKay /*/

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

/*/---------------------------Defines-----------------------------------------/*/

#pragma GCC optimize("Ofast") 
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)  
#define fn1 for( int i =1;i<=n; i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define endl '\n'
#define PI  3.14159265358979323846
#define MOD 1000000007
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
const int N = 2e6+5;  
const int INF = 1e18L;
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
/*/-----------------------------Debug begins----------------------------------/*/
vector<string> split(const string& s, char c) {
    vector<string> v; stringstream ss(s); string x;
    while (getline(ss, x, c)) v.emplace_back(x); return move(v);
}
template<typename T, typename... Args>
inline string arrStr(T arr, int n) {
    stringstream s; s << "[";
    for(int i = 0; i < n - 1; i++) s << arr[i] << ",";
    if(n>0)
    s << arr[n - 1] ;
    s<< "]";
    return s.str();
}
#define trace(args...) {__trace_begin(__LINE__); __trace(split(#args, ',').begin(), args);}
inline void __trace_begin(int line) { cerr << "#" << line << ": "; }
template<typename T> inline void __trace_out_var(vector<T> val) { cerr << arrStr(val, val.size()); }
template<typename T> inline void __trace_out_var(T* val) { cerr << arrStr(val, 10); }
template<typename T> inline void __trace_out_var(T val) { cerr << val; }
inline void __trace(vector<string>::iterator it) { cerr << endl; }
 
template<typename T, typename... Args>
inline void __trace(vector<string>::iterator it, T a, Args... args) {
    cerr << it->substr((*it)[0] == ' ', it->length()) << "=";
    __trace_out_var(a);
    cerr << "; ";
    __trace(++it, args...);
}
/*/-----------------------------Code begins----------------------------------/*/
int ar[N];
int dp[N];

signed main(){
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
  IOS;
  int T=1;
  // cin >> T;
  while(T--){
    int n;
    cin >> n ;
    int ans = 0;
    for(int i=1;i<=n;i++){
      for(int j =1;j*i<n;j++){
        int r = n - i*j;
        if(r>0)ans++;
      }
    }
    cout << ans;
    
  
  }
  return 0;
}

Measured memory_bytes: 3664
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			final int N = sc.nextInt();
			
			if(N == 0){
				break;
			}
			
			int[] array = new int[N];
			
			for(int i = 0; i < N; i++){
				array[i] = sc.nextInt();
			}
			
			int count = 0;
			for(int i = N-1; i >= 1; i--){
				for(int j = 0; j < i; j++){
					if(array[j] > array[j+1]){
						int tmp = array[j];
						array[j] = array[j+1];
						array[j+1] = tmp;
						count++;
					}
				}
			}
			
			System.out.println(count);
		}
		
	}

}

Measured memory_bytes: 12000
#include <stdio.h>
int buf[30],cnt;

void recur(int n){
  int i;

  if(n <= buf[cnt]){
    for(i=1; i<=cnt; i++)
      printf("%d ",buf[i]);
    printf("%d\n",n);
  }
  
  if(n>1){
    cnt++;
    for(i = (n-1<buf[cnt-1])?n-1:buf[cnt-1]; i>=1; i--){
      buf[cnt] = i;
      recur(n-i);
    }
    cnt--;
  }
}

int main(){
  int n;
  buf[0] = 31;

  while(1){
    cnt = 0;
    scanf("%d",&n);
    if(!n) break;
    recur(n);
  }

  return 0;
}

Measured memory_bytes: 0
package main

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

var dp []int
var child [][]int

func main() {
  n := NextInt()
  dp = make([]int,n+1)
  child = make([][]int,n+1)
  for i:=2;i<n+1;i++ {
    m := NextInt()
    child[m] = append(child[m],i)
  }
  fmt.Println(dfs(1)-1)
}

func dfs(v int) int {
  if len(child[v]) == 0 { dp[v] = 1;return 1 }
  if dp[v] != 0 { return dp[v] }
  var tmp []int = []int{math.MaxInt32}
  for _,e := range child[v] { tmp = append(tmp,dfs(e)) }
  sort.Sort(sort.Reverse(sort.IntSlice(tmp)))
  var m int = 0
  for i:=1;i<len(tmp);i++ {
    if m < tmp[i]+i { m = tmp[i]+i }
  }
  dp[v] = m
  return m
}

var reader = bufio.NewReaderSize(os.Stdin,1000000)
func NextInt() int {
  var buffer []byte
  for {
    line,isPrefix,err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
    if !isPrefix { break }
  }
  n,_ := strconv.Atoi(string(buffer))
  return n
}

Measured memory_bytes: 64512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define all(obj) obj.begin(), obj.end()
#define debug(x) cerr << #x << ":" << x << "\n"
#define vdebug(vec) cerr << #vec << ":"; for (auto e : vec) cerr << e << " "; cout << "\n"
#define vvdebug(vv) cerr << #vv << ":\n"; for (auto vec : vv) { for (auto e : vec) cerr << e << " "; cerr << endl; }
#define YN(f) cout << (f ? "YES" : "NO") << endl
#define Yn(f) cout << (f ? "Yes" : "No") << endl
#define yn(f) cout << (f ? "yes" : "no") << endl
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

int main () {
	int N; cin >> N;
	vi X(N); rep(i, N) cin >> X.at(i);
	sort(all(X));

	auto sub = [&](int P) {
		int res = 0;
		rep(i, N) res += (X.at(i) - P) * (X.at(i) - P);
		return res;
	};

	int l = X.at(0), r = X.at(N - 1), m;
	while (r - l > 1) {
		m = (l + r) / 2;
		if (sub(l) > sub(r)) l = m;
		else r = m;
	}
	cout << min(sub(l), sub(r)) << endl;
}

Measured memory_bytes: 256
import sys

W, a, b = (int(i) for i in input().split(" "))

if a <= b  <= a + W or a <= b + W <= a + W:
	print("0")
elif a + W < b:
	c = b - (a + W)
	print(c)
elif b + W < a:
	c = a - (b + W)
	print(c)


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <functional>
using namespace std;
using Int = long long;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,f,t) for(int i=f;i<t;i++)
#define P(r) do{cout<<#r": ";for(const auto &i:r){cout<<i<<" ";}cout<<endl;}while(0)
int main()
{
    int N; cin >> N;
    vector<vector<int>> node(N);
    REP(i, N-1) {
        int a, b; cin >> a >> b;
        a--, b--;
        node[a].push_back(b);
        node[b].push_back(a);
    }
    // find path from 0 to N-1
    vector<int> path;
    function<bool(int, int)> dfs;
    dfs = [&](int x, int prev) -> bool {
        if (x == N - 1) {
            path.push_back(x);
            return true;
        }
        for (auto child : node[x]) {
            if (child != prev && dfs(child, x)) {
                path.push_back(x);
                return true;
            }
        }
        return false;
    };
    dfs(0, -1);
    reverse(path.begin(), path.end());
    // count nodes
    function<int(int, int)> count;
    count = [&](int x, int prev) -> int {
        int res = 1;
        for (auto child : node[x]) {
            if (child != prev) {
                res += count(child, x);
            }
        }
        return res;
    };
    int fenec = 0;
    REP(i, (path.size() + 1) / 2) {
        fenec++;
        for (auto child : node[path[i]]) {
            if (i + 1 < path.size() && child == path[i+1]) continue;
            if (i - 1 >= 0 && child == path[i-1]) continue;
            fenec += count(child, path[i]);
        }
    }
    cout << ((fenec > (N - fenec)) ? "Fennec" : "Snuke") << endl;
    return 0;
}

Measured memory_bytes: 14204
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] vowel = { "a", "e", "i", "o", "u" };
		String c = getString(sc);
		boolean isVowel=false;
		for(String s:vowel) {
			if(s.equals(c)) {
				isVowel=true;
				break;
			}
		}
		if(isVowel) {
			System.out.println("vowel");
		}else {
			System.out.println("consonant");
		}
	}

	/**
	 * *汎用メソッド<br>
	 * 入力した配列に対する順列を取得
	 *
	 * @param numArray
	 * @return
	 */
	private static List<Integer[]> getPermutation(int[] numArray) {
		List<Integer[]> permutation = new ArrayList<>();
		Integer[] ans = new Integer[numArray.length];
		boolean[] used = new boolean[numArray.length];

		return buildPermutaion(permutation, numArray, ans, used, 0);
	}

	/**
	 * *汎用メソッド(内部)<br>
	 * 入力した配列に対する順列を作成
	 *
	 * @param list
	 * @param numArray
	 * @param ans
	 * @param used
	 * @param depth
	 * @return
	 */
	private static List<Integer[]> buildPermutaion(List<Integer[]> list, int[] numArray, Integer[] ans, boolean[] used,
			int depth) {

		// 全部使い切った時=>できた順列を返す
		if (depth == numArray.length) {
			list.add(ans.clone());
			return list;
		}
		// 使い切っていない場合

		for (int i = 0; i < numArray.length; i++) {
			if (used[i]) {
				continue;
			}
			ans[depth] = numArray[i];
			used[i] = true;
			list = buildPermutaion(list, numArray, ans, used, depth + 1);

			used[i] = false;
		}

		return list;
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をlongで返却
	 *
	 * @return
	 */
	public static long getLong(Scanner sc) {

		return Long.parseLong(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をintで返却
	 *
	 * @return
	 */
	public static int getInt(Scanner sc) {

		return Integer.parseInt(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をStringで返却
	 *
	 * @return
	 */
	public static String getString(Scanner sc) {

		return sc.next();
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をint配列で返却
	 *
	 * @return
	 */
	public static int[] getIntArray(Scanner sc) {
		String line = "";
		// 直前にnext()を実行していると改行コードだけ取ってしまうのでその対策
		while (line.equals("")) {
			line = sc.nextLine();
		}

		String[] strArray = line.split(" ");
		int[] intArray = new int[strArray.length];
		for (int i = 0; i < strArray.length; i++) {
			intArray[i] = Integer.parseInt(strArray[i]);
		}
		return intArray;
	}

}


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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) { ll d = euclid(b, a % b, y, x);
        return y -= a/b * x, d; }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1) ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1); return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e) return Mod(1);
        Mod r = *this ^ (e / 2); r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

struct Point {
    ll x, y;
    const Point operator-(const Point p) const {
        Point r;
        r.x = x - p.x, r.y = y - p.y;
        return r;
    }
    const ll norm2() const { return x * x + y * y; }
};

ll cross(Point p0, Point p1) {
    return p0.x * p1.y - p1.x * p0.y;
}

ll sqr(ll x) { return x * x; }

vector<ll> encode(vector<Point> p) {
    vector<ll> vals;
    rep(i, 0, p.size() - 1) {
        vals.push_back((p[i + 1] - p[i]).norm2());
        if (i + 2 < p.size()) {
            vals.push_back(cross(p[i + 1] - p[i], p[i + 2] - p[i + 1]));
        }
    }
    return vals;
}

vector<Point> getline() {
    int m; cin >> m;
    vector<Point> p(m);
    rep(i, 0, m) cin >> p[i].x >> p[i].y;
    return p;
}

void out(vector<ll> v) {
    for (int h : v) cout << h << " ";
}
void out(vector<Point> v) {
    for (Point h : v) cout << "(" << h.x << ", " << h.y << "), ";
}

int main() {
    for (;;) {
        int n; cin >> n; if (!n) break;
        vector<Point> base = getline();
        vector<Point> baser(base.rbegin(), base.rend());
        vector<ll> s1 = encode(base), s2 = encode(baser);

        vector<int> ans;
        rep(i, 1, n + 1) {
            vector<ll> e = encode(getline());
            if (e == s1 || e == s2) {
                ans.push_back(i);
            }
        }
        for (int h : ans) cout << h << endl;
        cout << "+++++" << endl;
    }
}


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

int main() {
  long int A,B,H,M;
  cin >> A >> B >> H >> M;
  long double a,b,c,pi;

  c=60.0000000000000;
  pi =  3.1415926535;

  a = H*360.00000000/12.000000+ M/c*30.00000000000;
  b = M / 60.00000000 * 360.000000;

  a = 2*pi* a /360.0000000;
  b = 2*pi* b /360.0000000;

  long double len;
  len = sqrt(pow(A,2)+pow(B,2)-2*A*B*cos(b-a));


  cout << fixed << setprecision(11)<< len << endl;

}


Measured memory_bytes: 4164
#include<cstdio>
#include <iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<cstdlib>
#include<list>
#include<set>
#include<numeric>

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

int W, H;
int e1[100][100], e2[100][100], n1[100][100], n2[100][100];
const int mod = 100000;

int main() {
	while (cin >> W >> H, W) {
		for (int i = 1; i < W; i++) {
			e2[i][0] = 1;
		}
		for (int j = 1; j < H; j++) {
			n2[0][j] = 1;
			for (int i = 1; i < W; i++) {
				e1[i][j] = (n2[i - 1][j]) % mod;
				e2[i][j] = (e1[i - 1][j] + e2[i - 1][j]) % mod;
				n1[i][j] = (e2[i][j - 1]) % mod;
				n2[i][j] = (n1[i][j - 1] + n2[i][j - 1]) % mod;
			}
		}
		int s = (e1[W - 1][H - 1] + e2[W - 1][H - 1] + n1[W - 1][H - 1] + n2[W - 1][H - 1]) % mod;
		cout << s << endl;
	}
	return 0;
}

Measured memory_bytes: 3160
from collections import defaultdict

n = int(input())
ana_dict = defaultdict(int)
n_pair = 0
for _ in range(n):
    s = input()
    t = [0,] * 26
    for c in s:
        t[ord(c) - ord('a')] += 1
    t = tuple(t)
    if t in ana_dict:
        n_pair += ana_dict[t]
    ana_dict[t] += 1
print(n_pair)

Measured memory_bytes: 36192
#include <iostream>
#include <map>

using namespace std;

int main() {
	int n, a, b;
	long long k;
	cin >> n >> k;

	map<int, long long> nums;
	for (int i = 0; i < n; i++) {
		cin >> a >> b;
		nums[a] += b;
	}

	long long rank = 0;
	for (auto p : nums) {
		rank += p.second;
		if (rank >= k) {
			cout << p.first << endl;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 4224
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>
 
using namespace std;
using LLONG = long long;
 
int main()
{
    char a, b;
    cin >> a >> b;
    if (a == b)
    {
        cout << 'H' << endl;
    }
    else
    {
        cout << 'D' << endl;
    }
 
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		if(a<b&&a<c){
			if(b<c){
				System.out.println(a+" "+b+" "+c);
			}else{
				System.out.println(a+" "+c+" "+b);
			}
		}else if(b<a&&b<c){
				if(a<c){
					System.out.println(b+" "+a+" "+c);
				}else{
					System.out.println(b+" "+c+" "+a);
				}
		}else {
			if(a<b){
				System.out.println(c+" "+a+" "+b);
			}else{
				System.out.println(c+" "+b+" "+a);
			}
		}
	}
}

Measured memory_bytes: 26124
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<map>
using namespace std;
map<long long,int>mp;
long long n,i,a[200005],w=0;
int main()
{
    mp.clear();
    scanf("%lld",&n);
    for(i=0;i<n;i++)
    {
        scanf("%lld",&a[i]);
        if(mp[a[i]]==0)mp[a[i]]=1;
        else w=1;
    }
    if(!w)printf("YES\n");
    else printf("NO\n");
}

Measured memory_bytes: 14336
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <memory>

#define int long long

using namespace std;

void Main()
{
	int n, m;
	cin >> n >> m;
	int num = 0;

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

	int ans = 0;
	for (auto ai : a) {
		if (4 * m * ai < total) {
			continue;
		}
		ans++;
	}

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

}

int32_t main()
{
	Main();
	return 0;
}



Measured memory_bytes: 256
#pragma GCC target("sse,sse2,sse3,sse4.1,sse4.2,popcnt,abm,mmx,avx")
#pragma comment(linker,"/STACK:102400000,102400000")
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#include<bits/stdc++.h>
#define re register
using namespace std;
typedef long long ll;
typedef double db;
const ll inf=2e9,N=2001001,MAX=2001;
inline void read(register ll &ret)
{
    ret=0;register ll pd=0;register char c=getchar();
    while(!isdigit(c)){pd|=c=='-';c=getchar();}
    while(isdigit(c)){ret=(ret<<1)+(ret<<3)+(c^48);c=getchar();}
    ret=pd?-ret:ret;
}
ll n,ans;
char s[N];
int main()
{
	read(n);
	scanf("%s",s+1);
	for(re int i=1;i<=n;i++)
		if(s[i]!=s[i-1])
			ans++;
	printf("%lld\n",ans);
	exit(0);
}


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

using namespace std;

using ll = long long;
using ld = long double;
using D = double;
using uint = unsigned int;
template<typename T>
using pair2 = pair<T, T>;

#ifdef WIN32
    #define LLD "%I64d"
#else
    #define LLD "%lld"
#endif

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second

char color[] = "RYGB";

int main()
{
    int h, w, d;
    scanf("%d%d%d", &h, &w, &d);
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            int c1 = (i + j) / d % 2;
            int c2 = (i - j + w) / d % 2;
            int c = c1 * 2 + c2;
            printf("%c", color[c]);
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define sz(x) ((int)x.size())
#define pb push_back
#define ii pair<int,int>
#define ppb pop_back
#define orta ((bas+son)>>1)
#define st first
#define nd second
#define ll long long
#define N 200005
#define inf 2000000005
#define MOD 1000000007
#define LOG 20
#define EPS 0.000000001
#define M 305
using namespace std;

int n,a,b;
int f[N],inv[N];

int add(int x,int y) {

	x+=y;
	while(x>=MOD) x-=MOD;
	while(x<0) x+=MOD;
	return x;

}

int mul(int x,int y) {

	return (ll)x*y%MOD;

}

int fe(int x,int y) {

	if(y==0) return 1;
	if(y&1) return mul(x,fe(x,y-1));
	int res=fe(x,y>>1);
	return mul(res,res);

} 

int C(int x,int y) {

	int res=1;
	for(int i=1;i<=y;i++) {
		res=mul(res,x-i+1);
		res=mul(res,fe(i,MOD-2));
	}
	return res;

}

void solve() {

	cin>>n>>a>>b;
	int ans=add(fe(2,n),-1);
	ans=add(ans,-C(n,a));
	ans=add(ans,-C(n,b));
	cout<<ans;

}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);	

	int t=1;
	//cin>>t;
	while(t--) solve();

}

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

using ll=long long;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DBG(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	printf("%lld",x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

const int inf=LLONG_MAX/3;

signed main(){
	int n=read();
	vi a;
	map<int,int> c;
	REP(i,n)
		c[read()]++;
	int o=0,t=0;
	for(auto& kv:c){
		if(kv.second>=3)
			kv.second=2-kv.second%2;
		if(kv.second==1)
			o++;
		else
			t++;
	}
	cout<<o+t-t%2<<endl;
}


Measured memory_bytes: 6528
while True:
    
    h, w = map(int, input().split())
    
    if h == 0 and w == 0:
        break
    
    for i in range(h):
        for j in range(w):
            if (i+j) % 2 == 0:
                print("#", end="")
            else:
                print(".", end="")
        print()
    print()


Measured memory_bytes: 7000
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue = BinaryHeap!(Array!long, "a<b");
// dfmt on

void main()
{
    long X, Y;
    scan(X, Y);
    long a = 100000 * max(4 - X, 0);
    long b = 100000 * max(4 - Y, 0);
    long c = (X == 1 && Y == 1) ? 400000 : 0;
    writeln(a + b + c);
}


Measured memory_bytes: 256
N,W=map(int,input().split(' '))
bag=[tuple(map(int,input().split(' '))) for _ in range(N)]
dp1,dp2=[0]*(W+1),[0]*(W+1)
for i in range(N):
    dp1=dp2
    dp2=[0]*(W+1)
    for j in range(1,W+1):
        if j<bag[i][0]:
            dp2[j]=dp1[j]
        else:
            dp2[j]=max(dp1[j],dp1[j-bag[i][0]]+bag[i][1])
print(dp2[-1])

Measured memory_bytes: 67024
#include <bits/stdc++.h>
using namespace std;
const double PI=3.1415926535897932;

int main() { 
  double a, b, x;
  cin >> a >> b >> x;
  if(x <= a*a*b/2) {
    double y = 2*x/a/b;
    printf("%12.10lf\n", 90-(atan(y/b)/PI*180));
  } else {
    double aki = a*a*b - x;
    double y = 2*aki/a/a;
    printf("%12.10lf\n", (atan(y/a)/PI*180));
  }
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>

using namespace std;

int main()
{
    int a, b, k;
    scanf("%d %d %d", &a, &b, &k);
    int imax = max(a, b);
    int cnt = 0;
    for(int i = imax; i >= 1; --i)
    {
        if(a % i == 0 && b % i == 0)
            cnt++;
        if(cnt == k)
        {
            printf("%d\n", i);
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
# include <bits/stdc++.h>
# define ll long long int
# define ld long double
# define pb push_back
# define mp make_pair
# define mod 998244353 
# define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

int main(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#else
// online submission
	#endif
	IOS
	int n,k;
	cin >> n >> k;
	vector<ll> cost;
	vector<ll> ans(n,0);
	for(int i = 0; i < n; i++){
		ll x;
		cin >> x;
		cost.pb(x);
	}
	ans[1] = abs(cost[1] - cost[0]);
	for(int i = 2; i < n; i++){
      	ll mini = INT_MAX;
      	for(int j = 1; j <= k && i - j >= 0; j++){
        	mini = min(mini, ans[i - j] + abs(cost[i] - cost[i - j]));
        }
		ans[i] = mini;
	}
	cout << ans[n - 1];
	return 0;
}


Measured memory_bytes: 4996
// https://atcoder.jp/contests/agc023/tasks/agc023_b

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll N;
  cin >> N;

  V<string> mat(N);
  rep(i, N) cin >> mat[i];

  ll res = 0;

  rep(col, N) {
    ll ok = true;

    rep(j, N) rep(i, j) {
      unless(mat[i][(j + col) % N] == mat[j][(i + col) % N]) {
        ok = false;
        break;
      }
    }

    if (ok) res++;
  }

  res *= N;
  cout << res << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

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

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

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


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

int main(){
  int n,k;
  cin >>n >>k;
  if(k==1) cout << 0 << endl;
  else if(n==1) cout << 1 << endl;
  else cout << n-k << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	string s;
	cin >> s;
	int pos1, pos2, cont=0;
	pos1=0;
	pos2=s.size()-1;
	if(s.size()%2==0) {
		while((pos2-pos1)>0) {
			if(s[pos1]!=s[pos2]) {
				s[pos1]=s[pos2];
				cont++;
			}
			pos1++;
			pos2--;
		}
	} else {
		while(pos2!=pos1) {
			if(pos2==pos1) {
				break;
			}
			
			if(s[pos1]!=s[pos2]) {
				s[pos1]=s[pos2];
				cont++;
			}
			pos1++;
			pos2--;
		}
	}
	cout << cont << endl;
	return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector <int> W(N);
    for(int i = 0;i < N; i++)
    {
        cin >> W[i];
    }
    vector <int> sum_W(N);
    sum_W[0] = W[0];
    for(int i = 1;i < N; i++)
    {
        sum_W[i] = sum_W[i - 1] + W[i]; 
    }

    int min_count = 100 * 100;
    int count = 0;
    for(int i = 0;i < N; i++)
    {
        count = sum_W[i] - (sum_W[N - 1] - sum_W[i]); 
        min_count = min(abs(count), min_count);
    }

    cout << min_count << endl;
    return 0;  

}

Measured memory_bytes: 256
//testing not my code
#include<stdio.h>
int p[100005],count[100005];
int root(int n){
    if(p[n]!=n)
        p[n]=root(p[n]);
    return p[n];
}
void uni(int x,int y){
    x=root(x);y=root(y);
    if(x!=y){
        p[x]=y;
        count[y]+=count[x];
    }
    return ;
}
int main(){
    int n,m,k,i;
    scanf("%d%d%d",&n,&m,&k);
    int a[100005],b[100005],c[100005],d[100005],e[100005];
    for(i=0;i<m;i++){
        scanf("%d%d",&a[i],&b[i]);
        a[i]--;b[i]--;
    }
    for(i=0;i<k;i++){
        scanf("%d%d",&c[i],&d[i]);
        c[i]--;
        d[i]--;
    }
    for(i=0;i<n;i++){
        p[i]=i;
        count[i]=1;
    }
    for(i=0;i<m;i++)
        uni(a[i],b[i]);
    for(i=0;i<n;i++) e[i]=1;
    for(i=0;i<m;i++){
        if(root(a[i])==root(b[i])){
            e[a[i]]++;e[b[i]]++;
        }
    }
    for(i=0;i<k;i++){
        if(root(c[i])==root(d[i])){
            e[c[i]]++;e[d[i]]++;
        }
    }
    for(i=0;i<n;i++)
        printf("%d ",count[root(i)]-e[i]);
    printf("\n");
    return 0;
}


Measured memory_bytes: 4096
#include<bits/stdc++.h>
#define int long long
using namespace std;
struct UnionFind{
  vector<int> par,rank;
  UnionFind(int N){
    for(int i=0;i<N;i++){
      par.push_back(i);
      rank.push_back(1);
    }
  }
  int find(int x){
    if(par[x]==x)
      return x;
    else{
      int y=find(par[x]);
      par[x]=y;
      return y;
    }
  }
  void unite(int x,int y){
    int x2=find(x),y2=find(y);
    if(rank[x2]>=rank[y2])
      par[y2]=x2,rank[x2]=max(rank[x2],rank[y2]+1);
    else
      par[x2]=y2;
  }
  bool same(int x,int y){
    return find(x)==find(y);
  }
};
signed main(){
  int N,M;
  cin>>N>>M;
  vector<int> A(N);
  for(int &i:A){
    cin>>i;
    i--;
  }
  UnionFind B(N);
  for(int i=0;i<M;i++){
    int x,y;
    cin>>x>>y;
    B.unite(x-1,y-1);
  }
  int ans=0;
  for(int i=0;i<N;i++)
    if(B.same(i,A[i]))
      ans++;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 5888
#include<iostream>
#include<algorithm>
using namespace std;
#define ll long long
const int MAXN=400000;
const ll INF=1e18;
int n;
ll a[MAXN+10];
ll s1,s2;
ll ans=INF;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)scanf("%lld",a+i),s2+=a[i];
	for(int i=1;i<n;++i)
	{
		s1+=a[i];
		s2-=a[i];
		ans=min(ans,abs(s1-s2));
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;


int main()
{
    int r;
    cin>> r;
   // printf("%f\n",2*M_PI*r);
   // cout << 2*M_PI*r << endl;
   cout << setprecision(17) << 2*M_PI*r  << '\n';

}


Measured memory_bytes: 3260
list=input().split(" ")
n=int(list[0])
k=int(list[1])

sho=k*2
slist=[]

while sho>=1:
    sho=sho/2
    slist.insert(0, sho)

#print(slist)
nagasa=len(slist)
kaisulist=[]
now=0

for i in range(n):
    switch=0
    while switch==0:
        if now>=nagasa:
            switch=1
        elif i+1>=slist[now]:
            now+=1
        else:
            switch=1
    kaisulist.append(nagasa-now)
#print(kaisulist)

answer=0

for kl in kaisulist:
    answer+=(0.5**kl)

answer=answer/n
print(answer)

Measured memory_bytes: 3864
#include <iostream>
#include <vector>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>

using namespace std;

using ull = unsigned long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vull = vector<ull>;
using vpii = vector<pii>;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define rFOR(i,a,b) for(int i=(b);i>=(a);i--)
#define SORT(a) sort((a).begin(),(a).end());
#define rSORT(a) sort((a).rbegin(),(a).rend());
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;

//sankou
//vvi = vector<vector<int>>(20, vector<int>(10, 0));

int isP(int n) {
    if(n<=1) return 0;
    FOR(i,2,(int)sqrt(n)) {
        if(n%i==0) return 0;
    }
    return 1;
}

int main() {
    
    int yc=0;
    string s;
    cin >>s;
    if(s=="abc") yc=1;
    if(s=="acb") yc=1;
    if(s=="bac") yc=1;
    if(s=="bca") yc=1;
    if(s=="cab") yc=1;
    if(s=="cba") yc=1;
    Yn(yc);
    return 0;
}

Measured memory_bytes: 256
sx, sy, tx, ty = list(map(int, input().split()))

dx = tx - sx
dy = ty - sy
d1 = ['U']*dy + ['R']*dx
d2 = ['D']*dy + ['L']*dx
d3 = ['L'] + ['U']*(dy+1) + ['R']*(dx+1) + ['D']
d4 = ['R'] + ['D']*(dy+1) + ['L']*(dx+1) + ['U']

print(''.join(d1+d2+d3+d4))


Measured memory_bytes: 9192
implicit none
integer :: N
character(100) :: a,b,c
integer :: i, op

read *,N
read *,a
read *,b
read *,c

op = 0
do i = 1, N
   if (a(i:i) == b(i:i)) then
      if (b(i:i) == c(i:i)) then
         cycle
      else
         op = op + 1
      endif
   else
      if (a(i:i) == c(i:i)) then
         op = op + 1
      else if (b(i:i) == c(i:i)) then
         op = op + 1
      else
         op = op + 2
      endif
   endif
enddo

write(6,'(i0)') op
stop
end

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  vector<int>v(n);
  for(int i=0;i<n;i++)
  {
    cin>>v[i];
  }
  int small=n+1,ans=0;
  for(int i=0;i<n;i++)
  {
	if(small>v[i])
    {
      ans++;
      small=v[i];
    }
  }
  cout<<ans<<endl;
}

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

int main()
{
ll n ;
cin >> n ;
ans+=(n/500) * 1000;
n=n%500;
ans+=(n/5) * 5;
cout << ans << endl;
return 0;
}

Measured memory_bytes: 384
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<vector>
using namespace std;
using uint = unsigned int;
using ll = long long;
const int M = 1e9 + 7;
const ll MLL = 1e18L + 9;
#pragma unused(M)
#pragma unused(MLL)
#ifdef LOCAL
#include"basic.hpp"
#else
template <class... T> void printl(T&&...){ }
template <class... T> void printc(T&&...){ }
template <class... T> void prints(T&&...){ }
#endif

int main(){
    int i, o, j, l, dump;
    cin >> i >> o >> dump >> j >> l >> dump >> dump;
    ll ans = 0ll + o + i / 2 * 2 + j / 2 * 2 + l / 2 * 2 + (i % 2 && j % 2 && l % 2 ? 3 : 0);
    if(i && j && l){
        ans = max(ans, 0ll + o + 3 + (i - 1) / 2 * 2 + (j - 1) / 2 * 2 + (l - 1) / 2 * 2);
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long i64;
typedef pair<i64,i64> P;


int n, a[101];

int main(){
	cin >> n;
	for(int i = 0; i < n; i++){cin >> a[i];}
	
	int cnt = 0;
	for(int i = 1; i < n-1; i++){
		if((a[i] < a[i+1] && a[i] > a[i-1]) || (a[i] > a[i+1] && a[i] < a[i-1])){
			cnt++;
		}
	}
	cout << cnt << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int i, j, n;
  while( 1 ) {
    int ans = 0, sum = 0;
    scanf("%d", &n);
    if(!n) break;
    for(i = 1; i < n; ++i) {
      sum = i;
      for(j = i + 1; j < n; ++j) {
        sum += j;
        if(sum == n) {
          ans++;
          break;
        } else if(sum > n) break;
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}


Measured memory_bytes: 2592
#include<iostream>
#include<sstream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cfloat>
#include<functional>
#include<map>
#include<string>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<bitset>
#include<list>
#include<numeric>
#include<complex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<long long, long long> ll_ll;
typedef pair<double, double> d_d;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define rep2d(i, j, n) for(i = 0;i < n;++i)for(j = i + 1;j < n;++j)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define sc(x) cin >> x
#define sc2(x, y) cin >> x >> y
#define sc3(x, y, z) cin >> x >> y >> z
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << x << "\n"
#define pri2(x, y) cout << x << " " << y << "\n"
#define pri3(x, y, z) cout << x << " " << y << " " << z << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << x << "\n"
#define debug2(x, y) cout << " --- " << x << " " << y << "\n"
#define debug3(x, y, z) cout << " --- " << x << " " << y << " " << z << "\n"
#define debugn(i, n, a) rep(i, n)cout << " --- " << a[i] << "\n";
#define debugin(i, n, a) rep(i, n)printf(" --- %10d\n", a[i])
#define debugi2n(i, n, a, b) rep(i, n)printf(" --- %10d %10d\n", a[i], b[i])
#define debugiin(i, n, a) rep(i, n)printf(" --- %10d %10d\n", a[i].first, a[i].second)
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)


signed main(void){
  int i, j;
  for(int testcase = 0;;testcase++){
    int(n);
    if(n == 0)break;
    bool fl = true, vsted[n];
    ll sum = 0, w[n], d[n];
    int cnt = 0;
    rep(i, n){
      sc2(w[i], d[i]);
      vsted[i] = true;
      if(w[i] == d[i])cnt++;
      if(w[i] > d[i])fl = false;
    }

    if(!fl || cnt >= 2){
      pri("No"); continue;
    }

    rep(i, n)sum += w[i];

    cnt = 0;
    for(int tmp = n;tmp;cnt++){
      rep(i, n)if(vsted[i] && sum <= d[i]){
        vsted[i] = false;
        sum -= w[i];
        tmp--;
      }
      if(cnt >= 30)break;
    }

    if(cnt < 30)pri("Yes");
    else pri("No");


//*/

//*/ break;
  }
  return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N+1);
  for(int i=0; i<N; i++) cin >> A.at(i);
  A.at(N)=100001;
  sort(A.begin(), A.end());
  vector<int> cnt(N);
  int j=0;
  for(int i=0; i<N; i++){
    cnt.at(j)++;
    if(A.at(i)!=A.at(i+1)) j++; 
  }
  int ans=0;
  int flag=0;
  for(int i=0; i<N; i++){
    if(cnt.at(i)==1) ans++;
    else if(cnt.at(i)==0) continue;
    else if(cnt.at(i)%2==1) ans++;
    else{
      if(flag==0){
        ans++;
        flag++;
      }
      else{
        ans++;
        flag=0;
      }
    }
  }
  cout << ans-flag << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

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

	cout << N*(N-1)/2 + M*(M-1)/2 << endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
c = [list(map(int, input().split())) for i in range(n)]
p = [list(map(int, input().split())) for i in range(n)]
ans2 = -10**10
for i in range(1, 2**10):
  ans = 0
  count = [0]*n
  for j in range(10):
     if ((i >> j) & 1):
        for k in range(n):
          if c[k][j] == 1:
            count[k] += 1
  for l in range(n):
    ans += p[l][count[l]]
  if ans> ans2:
    ans2 =ans
print(ans2)
    

Measured memory_bytes: 3064
N, T = map(int, input().split())
t = list(map(int, input().split()))
time = 0

for i in range(N-1):
  if t[i + 1] - t[i] >= T:
    time += T
  else:
    time += t[i + 1] -t[i]
 
time += T
print(time)
  
  

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

using namespace std;
#define ll long long
#define ld long double
#define rep(i,h) for(int i = 0; i < h; ++i)
#define rep1(i,h) for(int i = 0; i <= h; ++i)
#define rep2(i,k,h) for(int i = k; i < h; ++i)
#define rep3(i,k,h) for(int i = k; i <= h; ++i)
#define INF LLong_MAX // long long INF
#define inf INT_MAX // int inf

typedef pair<int,int> int_pair;
typedef pair<string,string> string_pair;

int main() {
    int n,ans=0;
    cin >> n;
    rep3(i,1,n) {
        int j = i;
        int count = 1;
        while(j >= 10) {
            j/=10;
            count++;
        }
        if(count%2 == 1) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
#ifdef HOME
	freopen("arc88b.in", "r", stdin);
	freopen("arc88b.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	string str;
	int ant, n;

	cin >> str;

	ant = (n = str.size());
	for (int i = 0; i < n - 1; ++i)
		if (str[i] != str[i + 1])
			ant = min(ant, max(i + 1, n - i - 1));

	cout << ant << endl;

	return 0; }


Measured memory_bytes: 512
#include<iostream>
using namespace std;
int n,m;
char c[50][50],s[50][50];
int main()
{
    cin>>n>>m;
    bool ok=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++)cin>>c[i][j];
    }
    for(int i=0;i<m;i++){
        for(int j=0;j<m;j++)cin>>s[i][j];
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(i+m-1>=n or j+-1>=n)continue;
            bool can=1;
            for(int k=0;k<m;k++)
            {
                for(int l=0;l<m;l++)
                {
                    if(c[i+k][j+l]!=s[k][l])can=0;
                }
            }
            if(can){
              ok=1; break;
            }
        }
    }
    cout<<(ok?"Yes":"No")<<endl;
}


Measured memory_bytes: 256
while True :
    n = int(input())
    if n == 0 : break
    numList = [0 for i in range(10)] 
    for i in range(n) :
        c = int(input())
        numList[c] += 1

    for i in range(10) :
        cnt = '*' * numList[i] 
        if len(cnt) == 0 : print("-")
        else : print(cnt)



Measured memory_bytes: 5624
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 1001001001
#define LINF (1LL << 62)
using namespace std;
using ll = long long;
using P = pair<int, int>;

void solv() {
    ll N, A, B;
    cin >> N >> A >> B;
    ll group = A + B;
    if (group == 0) {
        cout << "0" << endl;
        return;
    }
    ll d = N / group;
    ll npg = N % group;
    if (npg == 0) {
        cout << d * A << endl;
        return;
    } else {
        ll count;
        if (npg >= A) {
            count = d * A + A;
        } else {
            count = d * A + npg;
        }
        cout << count << endl;
        return;
    }
}

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

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

int arr[100007];
int dp[100007];

int Solve(int idx, int n, int k){
//	cout<<cost<<" "<<idx<<endl;
	if(idx >= n)return 1e9;
	if(idx == n - 1){
		return 0;	
	}
	
	if(dp[idx] != -1)return dp[idx];
	
	int ans = 1e9;
	for(int i = 1; i <= k ;i++){
		ans = min(ans, abs(arr[idx] - arr[idx+i]) + Solve(idx+i, n, k));
	}
	
	return dp[idx] = ans;
}

int main(){
	int n, k; cin>>n>>k;
	memset(dp,-1,sizeof(dp));
	for(int i = 0; i < n; i++)cin>>arr[i];
		
	cout<<Solve(0,n,k)<<endl;
	return 0;
}

Measured memory_bytes: 10752
#include <stdio.h>
#include <vector>
#include <iostream>
// #include <bits/stdc++.h>

using namespace std;
#define _GLIBCXX_DEBUG

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

    int N;
    cin >> N;

    vector<int> H(N);

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

    int ans = 0, num = 0;

    for (int i = 0; i < N; i++)
    {
        if (num <= H[i])
        {
            num = H[i];
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;

using ll = long long;
constexpr int INF = numeric_limits<int>::max();
template <typename T, typename... Args>
const T& min(const T& a, Args... args) {
  return min(a, min(args...));
}
template <typename T, typename... Args>
const T& max(const T& a, Args... args) {
  return max(a, max(args...));
}

#pragma GCC optimize("O3")
static const auto __ = [] {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  return nullptr;
}();

int main(int argc, char* argv[]) {
  int n;
  cin >> n;
  int h[n];
  for (int& h_ : h) {
    cin >> h_;
  }
  int dp[n];
  dp[0] = 0;
  dp[1] = abs(h[1] - h[0]);
  for (int i = 2; i < n; ++i) {
    dp[i] =
        min(dp[i - 2] + abs(h[i - 2] - h[i]), dp[i - 1] + abs(h[i - 1] - h[i]));
  }
  cout << dp[n - 1] << '\n';
  return 0;
}


Measured memory_bytes: 4396