akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int i;
  string color;

  cin >> N;
  
  for (i=0; i < N; i++) {
    cin >> color;
    if (color == "Y") {
      cout << "Four";
      break;
    }
  }
  
  if (color != "Y")
    cout << "Three";
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();

		if (k % 2 == 0) {
			System.out.print((k / 2) * (k / 2));
		} else {
			System.out.print((k / 2) * (k / 2 + 1));
		}
	}
}

Measured memory_bytes: 21844
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;
/*
Node treeMinimum(Node x){


}

Node treeMaximum(Node x){


}

Node treeSearch(Node u, int k){


}

Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}
*/

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

 while(x!=NIL){
   y=x;
    if(z->key < x->key){
      x=x->left;
    }
    else {
      x=x->right;
    }
  }
  z->parent=y;
  if(y==NIL){
    root=z;
  }
  else{
    if(z->key < y->key){
      y->left=z;
    }
    else{
      y->right=z;
    }
  }


}

void inorder(Node u){
if(u==NIL)return ;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);

}
void preorder(Node u){
 if(u==NIL)return ;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
   } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}

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

int main(){
  int a, b, c, i = 0;
  cin >> a >> b >> c;
  bool ok = false;
  
  int data[b];
  data[0] = 0;
  
  while(1){
    int A = (b * i + c ) % a;
    if(A == 0){
      ok = true;
      break;
    }
    else{
      if(data[0] == A)
        break;
      else{
      data[i] = A;
      i++;
      }
    }
  }
  
  if(ok)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
    

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits>

using int64 = long long;

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

    int T, A;
    std::cin >> T >> A;

    std::vector<int64> H(N);

    int ans = 1;
    int64 diff = std::numeric_limits<int64>::max();

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

        int64 ave1000 = T * 1000 - H[i] * 6;

        if (abs(ave1000 - A * 1000) < diff) {
            ans = i + 1;
            diff = abs(ave1000 - A * 1000);
        }
    }

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;

public final class Main {

    public static void main(String[] args) {
        final FastScanner fs = new FastScanner();
        final int n = fs.nextInt();
        int[] arr = new int[n + 1];
        for (int i = 0; i < n; i++) {
            arr[i] = fs.nextInt();
        }
        int[] dp = new int[n + 1];
        Arrays.fill(dp, (int) 1e9);
        dp[0] = 0;
        for (int i = 0; i < n - 1; i++) {
            dp[i + 1] = Math.min(dp[i + 1], dp[i] + Math.abs(arr[i + 1] - arr[i]));
            dp[i + 2] = Math.min(dp[i + 2], dp[i] + Math.abs(arr[i + 2] - arr[i]));
        }
        System.out.println(dp[n - 1]);
    }

    static final class Utils {
        public static void shuffleSort(int[] arr) {
            shuffle(arr);
            Arrays.sort(arr);
        }

        public static void shuffleSort(long[] arr) {
            shuffle(arr);
            Arrays.sort(arr);
        }

        public static void shuffle(int[] arr) {
            final Random r = new Random();

            for (int i = 0; i <= arr.length - 2; i++) {
                final int j = i + r.nextInt(arr.length - i);
                swap(arr, i, j);
            }
        }

        public static void shuffle(long[] arr) {
            final Random r = new Random();

            for (int i = 0; i <= arr.length - 2; i++) {
                final int j = i + r.nextInt(arr.length - i);
                swap(arr, i, j);
            }
        }

        public static void swap(int[] arr, int i, int j) {
            final int t = arr[i];
            arr[i] = arr[j];
            arr[j] = t;
        }

        public static void swap(long[] arr, int i, int j) {
            final long t = arr[i];
            arr[i] = arr[j];
            arr[j] = t;
        }

        private Utils() {}
    }

    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        private String next() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    //noinspection CallToPrintStackTrace
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

        int[] nextIntArray(int n) {
            final int[] a = new int[n];
            for (int i = 0; i < n; i++) { a[i] = nextInt(); }
            return a;
        }

        long[] nextLongArray(int n) {
            final long[] a = new long[n];
            for (int i = 0; i < n; i++) { a[i] = nextLong(); }
            return a;
        }
    }
}


Measured memory_bytes: 43144
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

M,K = inpl()
MAX = 2**M

if M != 1 and MAX > K:
    ans = []
    for i in range(MAX):
        if i != K:
            ans.append(i)
    ans.append(K)
    for i in reversed(range(MAX)):
        if i != K:
            ans.append(i)
    ans.append(K)
    print(' '.join(map(str,ans)))
elif M == 1:
    if K == 0:
        print('0 0 1 1')
    else:
        print(-1)
else:
    print(-1)


Measured memory_bytes: 32808
#include <iostream>

using namespace std;

int main(int argc, char** argv)
{
     string S;
     string source = "CODEFESTIVAL2016";

     cin >> S;

     int count = 0;

     for (int i = 0; i < source.length(); i++) {
	  if (S.at(i) != source.at(i)) {
	       count++;
	  }
     }

     cout << count << endl;
     
     return 0;
}


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

static const int MAX_P = 300100;
int in;

bool input() {
	cin >> in;
	if(in == 1)
		return false;
	return true;
}

void solve() {
	vector<int> printed;
	cout << in << ":";
	for(int a = 6; a <= in;) {
		if(in % a == 0 && ((in / a) % 7 == 1 || (in / a) % 7 == 6)) {
			bool flag = true;
			for(int i = 0; i < printed.size(); i++) {
				int cp = a;
				if(cp % printed[i] == 0 && ((cp / printed[i]) % 7 == 1 || (cp / printed[i]) % 7 == 6)) {
					flag = false;
					break;
				}
			}
			if(flag) {
				cout << " " << a;
				printed.push_back(a);
			}
		}

		if(a % 7 == 1)
			a += 5;
		else
			a += 2;
	}
	cout << endl;
}

int main() {
	while(input()) {
		solve();
	}
}

Measured memory_bytes: 1216
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    if (N & 1) {
        cout << 0 << endl;
    } else {
        ll ans = 0;
        ll base = 10;
        while (base <= N) {
            ans += N / base;
            base *= 5;
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
using System;


public class Test
{

	public static void Main()
	{
       string line = Console.ReadLine();
       int ans = 0;

       for(int x=line.Length-1;x>=0;x--){
        int half = x/2;
        string text1 = line.Substring(0,half);
        string text2 = line.Substring(half,x-half);
          if(text1==text2 && ans<(text1.Length*2)){
            ans = text1.Length*2;
          }
       }
       Console.WriteLine(ans);
       
	}

}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> a(H);
  for (int i = 0; i < H; i++) cin >> a[i];

  vector<vector<bool>> flag(H, vector<bool>(W));
  for (int i = 0; i < H; i++) {
    int white_n = 0;
    for (int j = 0; j < W; j++) {
      if (a[i][j] == '.') white_n++;
    }

    if (white_n == W) {
      for (int j = 0; j < W; j++) flag[i][j] = true;
    }
  }

  for (int i = 0; i < W; i++) {
    int white_n = 0;
    for (int j = 0; j < H; j++) {
      if (a[j][i] == '.') white_n++;
    }

    if (white_n == H) {
      for (int j = 0; j < H; j++) flag[j][i] = true;
    }
  }

  for (int i = 0; i < H; i++) {
    int cout_n = 0;
    for (int j = 0; j < W; j++) {
      if (flag[i][j] == false && j == W - 1) {
        cout << a[i][j] << endl;
        cout_n++;
      } else if (flag[i][j] == false) {
        cout << a[i][j];
        cout_n++;
      } else if (j == W - 1 && cout_n >= 1) cout << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */



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

    /*
        ある数列を広義単調増加にするために必要な最小スワップ数について。
        広義単調増加にするということと、転倒数 0 ということが同値。
        ①スワップ 1 回で転倒数は高々 1 しか減らない。
        ②広義単調増加でないならば必ずスワップ によって転倒数を 1 減らせる箇所がある。
        ①②より最小スワップ数は転倒数
    */

    int n; cin >> n;
    vector<int> a(n), b(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];

    int const inf = 1<<29;
    vector<vector<int>> dp((1<<n)+1, vector<int>(55, inf));
    dp[0][0] = 0;
    // dp[mask][s] := mask にある集合を左詰めで広義単調増加に並べ、さらに最後の数字が s であるようにした時の最小スワップ数（転倒数）

    rep(bit, 1<<n) {
        int cnt = __builtin_popcount(bit);

        // まだ使っていない要素について (元の位置, 自分より左にいる要素の数+1) を持つ
        // 転倒数は、新しく mask に加える値 p_i について j<i かつ p_j > p_i なる (i, j) を足していく方針で数え上げる
        // なので、p_i について、自分より左側で自分より大きい値を足す　それが下の p.second - cnt である
        // p.seocnd は mask の状態での自分より左にある要素、cnt はそのうち自分より大きくない要素
        vector<pair<int, int>> rest;
        int itr = cnt;
        rep(i, n) if(!(bit&(1<<i))) rest.emplace_back(i, itr++);

        rep(s, 51) {
            if (dp[bit][s] == inf) continue;
            for(auto p: rest){
                int ns = -1;
                if (abs(p.first - cnt)%2 == 0) ns = a[p.first];
                else ns = b[p.first];

                if (ns>=s) chmin(dp[bit | 1<<p.first][ns], dp[bit][s] + (p.second - cnt));
            }
        }
    }
    
    int ans = inf;
    rep(s, 51) chmin(ans, dp[(1<<n)-1][s]);
    cout << (ans == inf? -1:ans) << endl;
    return 0;
}


Measured memory_bytes: 67840
s = int(input())

a = [s]
ai = s
for i in range(2, 10**6 + 2):
    if ai % 2 == 0:
        ai = ai/2
        if ai in a:
            print(i)
            break
    else:
        ai = 3*ai + 1
        if ai in a:
            print(i)
            break
    a.append(ai)

Measured memory_bytes: 9188
#include <cstdio>
#include <cstdlib>
#include <algorithm>
using namespace std;

int main() {
    int N, M;
    scanf("%d %d", &N, &M);
    int X[M];
    for (int i = 0; i < M; i++) {
        scanf("%d", &X[i]);
    }
    if (N >= M || M == 1) {
        printf("0\n");
    } else {
        sort(X, X + M);
        int dist[M - 1];
        for (int i = 0; i < M - 1; i++) {
            dist[i] = X[i + 1] - X[i];
        }
        sort(dist, dist + (M - 1));
        int sum = 0;
        for (int i = 0; i < M - N; i++) {
            sum += dist[i];
        }
        printf("%d\n", sum);
    }
    return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false); cin.tie(0)
#define loop(i, a, b) for(lli i=a; i<b; i++)
#define loopb(i, a, b) for(lli i=a; i>=b; i--)
#define pb push_back
typedef long long int lli;
typedef pair<lli, lli> pii;
typedef vector<lli> vll;
// use to avoid collision
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
// for pair in unordered_map
struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
lli power(lli x, lli y){
    lli res = 1;
    x = x ;
    while (y > 0) {
        if (y & 1)
            res = (res*x) ;
        y = y>>1;
        x = (x*x);
    }
    return res;
}
lli solve(){
	lli n, m;
	cin>>n>>m;
	string s;
	cin>>s;
	n++;
	reverse(s.begin(), s.end());
	lli mx = m;
	lli count = m;
	vll res;
	res.pb(0);
//	cout<<s<<"\n";
	loop(i, 1, n-1){
		count--;
		if(s[i] == '0'){
			mx = max(mx, i+m);
			if(count <= 0){
				count = m;
				res.pb(i);
			}
		}
		else{
			if(count > 0)
				continue;
			else{
				count = mx-i;
				if(count <= 0){
					cout<<-1<<"\n";
					return 0;
				}
				res.pb(i-(m-count));
			}
		}
//		cout<<count<<" "<<mx<<"\n";
	}
	res.pb(n-1);
	lli sz = res.size();
	reverse(res.begin(), res.end());
	lli prev = res[0];
	loop(i, 1, sz){
		cout<<abs(res[i] - prev)<<" ";
		prev = res[i];
//		cout<<res[i]<<" ";
	}
	cout<<"\n";
	return 0;
}
int main(){
	fastio;
	lli t;
//	cin>>t;
	t = 1;
	while(t>0){
		t--;
		solve();
	}
}

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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;

static LL P = 1000000007;

int isPrime(LL p){
	if(p<=1) return 0;
	if(p==2 || p==3 || p==5 || p==7) return 1;
	if(p==4 || p==6 || p==8 || p==9) return 0;

	LL i;
	int ret = 1;
	for(i=2; i*i<=p; i++){
		if(p%i==0 && i!=p){
			ret = 0;
			break;
		}
	}
	return ret;
}

void factorize(long long N, map<long long, int> &mp){
	if(N == 1){
		printf("1 is not prime.\n");
		return;
	}
	if(isPrime(N)){
		mp[N] += 1;
		return;
	}

	long long i = 2, n = N;
	for(i = 2; n != 1 && i < (N/2) + 1; i++){
		if((n % i)==0){
			if(isPrime(i)){
				int e = 0;
				long long u = n;
				while((u % i)==0){
					e++;
					u = u / i;
					n = u;
				}
				mp[i] += e;
				if(isPrime(n)){
					mp[n] += 1;
					break;
				}
			}
		}
	}
	return;
}


int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	long long N;
	map<long long, int> mp;

	cin >> N;

	for(int i = 2; i <=N; i++){
		factorize(i, mp);
	}

	LL ans = 1;
	for(auto itr = mp.begin(); itr != mp.end(); itr++){
		long long p = itr->first;
		int v = itr->second;
		if(v == 0) continue;
		ans *= ((v + 1) % P);
		ans = ans % P;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
import heapq
n, m = map(int, input().split())
A = list(map(lambda x: -int(x), input().split()))
heapq.heapify(A)

for _ in range(m):
    x = heapq.heappop(A)*(-1)
    x //= 2
    heapq.heappush(A, -x)
print(-sum(A))



Measured memory_bytes: 14252
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author ei13333
 */

#include <bits/stdc++.h>

using namespace std;

class TaskA
{
public:
  void solve(istream &cin, ostream &cout)
  {
    int M;
    cin >> M;
    cout << 48 - M << endl;
  }
};


int main()
{
  TaskA solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return (0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a;i<(int)b;++i)
int main(){
    while(1){
        int a,b;char c;
        cin>>a>>c>>b;
        if(c=='?')break;
        if(c=='+')cout<<a+b<<endl;
        else if(c=='-')cout<<a-b<<endl;
        else if(c=='/')cout<<a/b<<endl;
        else if(c=='*')cout<<a*b<<endl;
    }
    return 0;
}


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

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


int GCD(int a, int b, int c){
  return gcd(a, gcd(b, c));
}

int main(){
  int K;
  cin >> K;
  
  int ans=0;
  
  for (int a=1; a<=K; a++){
    for (int b=1; b<=K; b++){
      for (int c=1; c<=K; c++){
        ans += GCD (a, b, c);
      }
    }
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 3136
#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i=a;i<b;++i) 
#define ROF(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vlli vector<long long int>
#define pb push_back
#define mp make_pair
#define all(c)  ((c).begin()), ((c).end())
using namespace std;
int main(){
	int n;
	cin>>n;
	cout<<800*n-200*(n/15);
}




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

int n;
int a[101];

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

  reverse(a, a+n);

  for(int i = 0; i < n-1; i++){
    cout << a[i] << " ";
  }
  cout << a[n-1] << endl;
}

Measured memory_bytes: 3092
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  int a,b,h;
  cin >> a >> b >> h;

  int ans = ( a + b ) * h / 2;

  cout << ans ;
  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

Measured memory_bytes: 256
s=input()
s=[1 if x in ['A','G','C','T'] else 0 for x in s]
cnt=0
ma=0
p=s[0]
if p==1:
    cnt+=1
    ma=1
for i in range(1,len(s)):
    if s[i]==1:
        cnt+=1
        if ma<cnt:
            ma=cnt
    else:
        cnt=0
print(ma)

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

using namespace std;

int main() {
	string a, b, c;
	cin >> a >> b >> c;
	int asz, bsz, csz;
	asz = a.size();
	bsz = b.size();
	csz = c.size();
	if ((a[asz - 1] == b[0]) && (b[bsz - 1] == c[0])) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from sys import stdin
# import numpy as np

s_in = lambda: stdin.readline()[:-1]  # s = s_in()
d_in = lambda: int(stdin.readline())  # N = d_in()
ds_in = lambda: list(map(int, stdin.readline().split()))  # List = ds_in()


N, A, B = ds_in()

a = min(A, B)
b = max(0, A + B - N)

print(a, b)




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

long long f[55];
int n;

int main()
{
	f[0] = 2;
	cin>>n;
	for(int i=1;i<=n;++i)
		f[i] = f[i-1]*2+2;
	cout<<f[n]<<endl;
	return 0;
}

Measured memory_bytes: 256
from collections import Counter

N = int(input())
A = list(map(int, input().split()))
Q = int(input())

A_counter = Counter(A)
A_sum = sum(A)

for _ in range(Q):
    b, c = list(map(int, input().split()))
    inc_num = A_counter[b] * (c - b)
    A_sum += inc_num
    print(A_sum)
    A_counter[c] += A_counter[b]
    A_counter[b] = 0

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

typedef vector<int> veci;
typedef pair<int, int> pii;
typedef vector<pii> vecii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vecl;
typedef vector<pll> vecll;
#define EPS (1e-9)
#define MOD (1e9 + 7)
#define fi first
#define se second
#define endl '\n'

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

    ll ans = ll(1e12);
    for (ll i=1; i*i<=n; ++i) {
        if (n%i==0) {
            ans = min(ans, i-1+(n/i)-1);
        }
    }

    cout << ans << endl;
}

int main(int argc, char* argv[]) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef LOCAL_TEST
    (void)argc;
    const string strpath = string(argv[0]) + string("-test.in");
    freopen(strpath.c_str(), "r", stdin);
    int tcs;
    cin >> tcs;
    while (tcs-- > 0)
#endif
        solve();
}


Measured memory_bytes: 256
from itertools import groupby

S = input()
K = int(input())

A = [len(tuple(v)) for _, v in groupby(S)]
if len(A) == 1:
    print((A[0] * K) // 2)
    quit()

if S[0] == S[-1]:
    m = sum(a // 2 for a in A) - A[0] // 2 - A[-1] // 2
    print(K * m + (K - 1) * ((A[0] + A[-1]) // 2) + A[0] // 2 + A[-1] // 2)
else:
    print(sum(a // 2 for a in A) * K)


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

if n <= 111:
    ans = 111
elif n <= 222:
    ans = 222
elif n <= 333:
    ans = 333
elif n <= 444:
    ans = 444
elif n <= 555:
    ans = 555
elif n <= 666:
    ans = 666
elif n <= 777:
    ans = 777
elif n <= 888:
    ans = 888
elif n <= 999:
    ans = 999

print(ans)


Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main(void) {
    int N = 0;

    cin >> N;
    //cout << "N " << N << "\n";

    int W[N];

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

    for (int T=0; T<N; T++) {
        int S1 = 0;
        int S2 = 0;
        //cout << "T " << T << "\n";
        for (int i=0; i<N; i++) {
            if (i <= T) {
                S1 += W[i];
            } else {
                S2 += W[i];
            }
            //cout << "internal " << S1 << " " << S2 << "\n";
        }
        //cout << "external " << S1 << " " << S2 << "\n";
        if (abs(S2-S1) < min) {
            min = abs(S2-S1);
        }
        //cout << "min " << min << "\n";
    }

    cout << min;

    return 0;
}

Measured memory_bytes: 256
import itertools

n, m = map(int, input().split())
k_list = [list(map(int, input().split())) for _ in range(m)]
p = list(map(int, input().split()))

ans = 0
for i in itertools.product([0, 1], repeat=n):
    test = True
    for j in range(m):
        count = 0
        for s in k_list[j][1:]:
            count += i[s-1]
        if count % 2 != p[j]:
            test = False
            break
    if test:
        ans += 1

print(ans)

Measured memory_bytes: 3188
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_set>
#include <iomanip>
using namespace std;

int main(int argc, char const *argv[]) {
  string s;cin>>s;
  s[5]=' ';
  s[13]=' ';
  cout<<s<<endl;
  return 0;
}


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

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> a(h);
  for (int i = 0; i < h; i ++) cin >> a.at(i);

  vector<int> dx = {1, 0, -1, 0, 1, -1, -1, 1};
  vector<int> dy = {0, 1, 0, -1, 1, 1, -1, -1};

  for (int i = 0; i < h; i ++) {
    for (int j = 0; j < w; j ++) {
      if (a.at(i).at(j) == '#') continue;

      int num = 0;
      for (int d = 0; d < 8; d ++) {
        int ni = i + dy.at(d);
        int nj = j + dx.at(d);

        if (ni < 0 || h <= ni) continue;
        if (nj < 0 || w <= nj) continue;
        if (a.at(ni).at(nj) == '#') num ++;
      }
      a.at(i).at(j) = char(num + '0');
    }
  }

  for (int i = 0; i < h; i ++) cout << a.at(i) << endl;
}


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

a = list(map(int, input().split()))
cnt = 0
b = 0
c = [0]
for i in range(n):
    b += a[i]
    c.append(b)

c.sort()
i=0
ncm=0
m = 1
while True:
    i += 1
    if i == n+1:
        ncm += m*(m-1)//2
        break        
    if c[i] == c[i-1]:
        m += 1
        continue
    else:
        ncm += m*(m-1)//2
        m = 1

print(ncm)

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

#define DUMP(x) cout << #x << " = " << (x) << endl;
#define REP(i, n) for(size_t i = 0; i < (n); i++)
#define REPR(i, n) for(size_t i = (n); i >= 0; i--)
#define FOR(i, a, b) for(size_t i = (a); i < (b); i++)
#define FOREACH(x,a) for(auto& (x) : (a))

const int INF = 1e9;
const int MOD = 1e9 + 7;

int N;
vector<int> X;

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

    cin >> N;
    vector<int> sort_X;
    REP(i, N) {
        int x; cin >> x;
        X.push_back(x);
        sort_X.push_back(x);
    }
    sort(sort_X.begin(), sort_X.end());
    REP(i, N) {
        if(X[i] > sort_X[N / 2 - 1]) cout << sort_X[N / 2 - 1] << "\n";
        else cout << sort_X[N / 2] << "\n";
    }
}

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

#define int long long
#define ll long long
#define pb push_back

int n;
vector<vector<int>> h(11);
vector<int> ans;

void rec(int u, int y){
    ans.pb(y);
    if (u <= 0) return;
    int now = 0;
    if (y == 0){
        if (h[u - 1][0] < n){
            n -= h[u - 1][0];
            rec(u - 1, 1);
        }
        else{
            rec(u - 1, 0);
        }
        return;
    }
    if (y == 9){
        if (h[u - 1][8] < n){
            n -= h[u - 1][8];
            rec(u - 1, 9);
        }
        else{
            rec(u - 1, 8);
        }
        return;
    }
    if (h[u - 1][y - 1] >= n){
        rec(u - 1, y - 1);
        return;
    }
    n -= h[u - 1][y - 1];
    if (h[u - 1][y] >= n){
        rec(u - 1, y);
        return;
    }
    n -= h[u - 1][y];
    rec(u - 1, y + 1);
    return;
}

main(){
    cin >> n;
    for(int i = 0; i < 11; i++) h[i].resize(10);
    for(int i = 0; i < 10; i++){
        h[0][i] = 1;
    }
    for(int i = 1; i < 11; i++){
        for(int j = 0; j < 10; j++){
            if (j == 0){
                h[i][j] = h[i - 1][j] + h[i - 1][j + 1];
                continue;
            }
            if (j == 9){
                h[i][j] = h[i - 1][j - 1] + h[i - 1][j];
                continue;
            }
            h[i][j] = h[i - 1][j - 1] + h[i - 1][j] + h[i - 1][j + 1];
        }
    }
    int now = 0;
    int he = 0;
    int le = 0;
    bool en = 0;
    for(int i = 0; i < 11; i++){
        if (en == 1) break;
        for(int j = 1; j < 10; j++){
            now += h[i][j];
            if (now >= n){
                now -= h[i][j];
                n -= now;
                he = i;
                le = j;
                en = 1;
                break;
            }
        }
    }
    rec(he, le);
    for(int i = 0; i < ans.size(); i++){
        cout << ans[i];
    }
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;
#define vi vector<int>
#define vl vector<long long>
#define vvi vector< vector<int> >
#define vvl vector< vector<ll> >
#define vp vector<P>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPD(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORD(i, a, b) for (int i = (int)(a); i >= (int)(b); i--)
#define INF 1e18
#define INFTY 1e9
const int mod = 1000000007;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

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

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

//cout << fixed << setprecision(10) << y << endl;
struct edge {int to, cost;};
vector< vector<edge> > es;

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

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

int main() {
    char a;
    cin >> a;
    if (a >= 97) cout << 'a' << endl;
    else cout << 'A' << endl;
    return 0;
}

Measured memory_bytes: 3600
package main

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

func main() {
	s := []rune(getString())
	l := len(s)

	ans := "AC"
	flagC := false
L:
	for i, r := range s {
		switch {
		case i == 0:
			if r != 'A' {
				ans = "WA"
				break L
			}
		case i >= 2 && i <= l-2:
			if (!flagC) && (r == 'C') {
				flagC = true
				break
			} else if r < 'a' {
				ans = "WA"
				break L
			}
		default:
			if r < 'a' {
				ans = "WA"
				break L
			}
		}
	}
	if !flagC {
		ans = "WA"
	}

	fmt.Println(ans)
}

// -----------------------------------------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
}

func getInt() int {
	i, err := strconv.Atoi(getString())
	if err != nil {
		panic(err)
	}
	return i
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}


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

int main(){
	int n,ans=0;cin>>n;
	int a[101];
	for(int i=1;i<=n-1;i++)scanf("%d",&a[i]);
	for(int i=1;i<=n-2;i++)ans+=min(a[i],a[i+1]);
	cout<<ans+a[1]+a[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        
        System.out.println( (A+B>=C) ? "Yes" : "No" );
    }
}


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

namespace ConsoleApplication19
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            if (a[0] != a[1] && a[1] != a[2] && a[0] != a[2])
                Console.WriteLine(3);
            if (a[0] == a[1] && a[1] == a[2])
                Console.WriteLine(1);
            else if ((a[0] == a[1] || a[1] == a[2] || a[0] == a[2]) && (a[1] != a[2] || a[1] != a[2] || a[0] != a[1]))
                Console.WriteLine(2);
        }

    }
}


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

int main() {
  int W, H, x, y, r; cin >> W >> H >> x >> y >> r;
  cout << ( (0 <= x - r && x + r <= W && 0 <= y - r && y + r <= H) ? "Yes" : "No" ) << endl;
  return 0;
}



Measured memory_bytes: 3096
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <string>
#include <numeric>
#include <queue>
#include <cstdio>
#include <cstring>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001001000
//#define mod 1000000007
#define mod 998244353
#define pi 3.1415926535
using namespace std;
struct __INIT {
	__INIT() {
		cin.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(15);
	}
}__init;

int main(void) {
    ll n;
    cin>>n;
    vl l(n);
    rep(i,n) cin>>l[i];
    ll ans = 0;
    rep(i,n){
        for(ll j = i+1;j<n;j++){
            for(ll k = j+1;k<n;k++){
                vl pitsu(3);
                pitsu[0] = l[i];
                pitsu[1] = l[j];
                pitsu[2] = l[k];
                sort(all(pitsu));
                if(pitsu[0] == pitsu[1] || pitsu[1] == pitsu[2]) continue;
                if(pitsu[0]+pitsu[1] > pitsu[2]){
                    ans++;
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3680
import fractions
def lcm(a, b):
  return a*b // fractions.gcd(a, b)

n = int(input())
a = list(map(int, input().split()))
l = 1
ans = 0
for i in a:
  l = lcm(l, i)

for i in a:
  ans += l//i

print(ans % 1000000007)

Measured memory_bytes: 6112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
long long mod = 1000000007;
const ll INF = 100100100100100100;

int main(){
  string s;
  cin >> s;
  string t = "";
  for(int i=s.size()-1;i>=0;i--){
    t.push_back(s.at(i));
  }
  int count = 0;
  for(int i=0;i<s.size();i++){
    if(t.at(i) != s.at(i)) count++;
  }
  cout << count/2 << endl;
} 

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int h, n;

    scanf("%d %d", &h, &n);

    int arr[100000];

    int sum=0;

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

        sum = sum + arr[i];
    }

    if(sum>=h)
    {
        printf("Yes\n");
    }

    else
    {
        printf("No\n");
    }

    return 0;
}


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

int64_t calcGCD(int64_t a, int64_t b)
	{
		while (a)
		{
			b %= a;
			std::swap(a, b);
		}
		return b;
}

int64_t calcLCM(int64_t a, int64_t b)
{
	// if (a * b == 0) return 0;
	return a / calcGCD(a, b) * b;
}

int64_t A, B, C, D;
int64_t calc(int64_t num)
{
	return num - num / C - num / D + num / calcLCM(C, D);
}

int main()
{
	scanf("%lld%lld%lld%lld", &A, &B, &C, &D);
	printf("%lld\n", calc(B) - calc(A - 1));

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	string s; 
	cin >> s; 
	int n = s.size();
	long long ans = 0;
	long long cnt[33] = {};
	for(long long i=0;i<n;i++){
		ans+=(i-cnt[s[i]-'a']);
		cnt[s[i]-'a']++;
	}
	cout<<ans+1ll<<endl;
	return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<cassert>

typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using std::cout;
using std::vector;
using std::endl;
using std::cin;
using std::string;
using std::max;
using std::min;
using std::abs;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const ll INF = 5000000000000;
//typedef std::pair<int, int> P;
struct edge { int to;double cost; };
#define VMAX 1010

     ll N,M;
     ll A[100010],B[100010];
     ll K[11],P[11];
     ll ans;
     char S[100];
int main() {
    cin>>N>>M;
    REP(i,20)S[i]='a';
    DEB(S[0])END
    REP(i,M){
        char s,t;
        int a,b;
        cin>>a>>b;
        s=a+'0',t=b+'0';
        if(S[a-1]=='a')S[a-1]=t;
        else if(S[a-1]!=t){cout<<"-1";return 0;}
    }
    if(S[0]=='a')S[0]='1';
    if(M==0){
        if(N==1)cout<<0;
        if(N==2)cout<<10;
        if(N==3)cout<<100;
        return 0;
    }
    if(S[0]=='0'){
        if(N==1) cout<<0;
        else cout<<"-1";
        return 0;
    }

    REP(i,N){
        if(S[i]=='a')cout<<'0';
        else cout<<S[i];
    }

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

int main() {
  string s;
  cin >> s;
  cout << count(s.begin(), s.end(), '+') - count(s.begin(), s.end(), '-') << endl;
}



Measured memory_bytes: 256
h, w = gets.split.map(&:to_i)
ahw = h.times.map { gets.chomp.split('') }

ahw.select { |ah| ah.include?('#') }
   .transpose
   .select { |aw| aw.include?('#') }
   .transpose.map(&:join)
   .each { |ah| puts ah }


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

#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
int main(){
  int n;cin>>n;
  vector<ll>v(n/2),v2(n/2);
  for(int i=0;i<n;i++){
    if(i%2)
      cin>>v[i/2];
    else
      cin>>v2[i/2];
  }
  sort(ALL(v));
  sort(ALL(v2));
  vector<pair<int,int> >pii1(n/2),pii2(n/2);

  int ma1=0,ma2=0;
  for(int i=0;i<n/2-1;i++){
    int cnt=1;
    while(v[i]==v[i+1]){
      i++;
      cnt++;
    }
    pii1[i]=mp(cnt,v[i]);
  }
  for(int i=0;i<n/2-1;i++){
    int cnt=1;
    while(v2[i]==v2[i+1]){
      i++;
      cnt++;
    }
    pii2[i]=mp(cnt,v2[i]);
  }
  sort(ALL(pii1),greater<pair<int,int> >());
  sort(ALL(pii2),greater<pair<int,int> >());
  pii1.pb(mp(0,-1));
  pii2.pb(mp(0,-2));
  if(pii1[0].S==pii2[0].S)
    cout<<min((n-pii1[0].F-pii2[1].F),(n-pii1[1].F-pii2[0].F))<<endl;
  else
    cout<<(n-pii1[0].F-pii2[0].F)<<endl;
  return 0;
}


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

using namespace std;

#define int long long
#define MOD 1000000007

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#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 all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}

//typedef long long ll;
#define TENNINE 1000000005
#define TENFIVE 100005
//#define int long long

int a, b, c, d;
int g;

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

int fun(int i)
{

    int l = (c * d) / g;

    //cout << l << endl;

    if (i == 0 || i == -1)
    {
        return 0;
    }

    return i - (i / c + i / d - i / l);
}

signed main()
{
    cin >> a >> b >> c >> d;

    if (c <= d)
    {
        g = gcd(d, c);
    }
    else
    {
        g = gcd(c, d);
    }

    //cout << g << endl;

    //cout << fun(b) << " " << fun(a - 1) << endl;

    cout << fun(b) - fun(a - 1) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define eb emplace_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
using namespace std;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' ');stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T,typename... Args>
void err(istream_iterator<string>it,T a,Args... args)
{
	cerr<<*it<<"= " <<a<<" ";
	err(++it,args...);
}
void solve()
{
   string s; cin>>s;
   int n=s.length();
   int res1=0,res2=0;
   rep(i,0,n-1)
   {
   	if(i&1)
   	{
   	    if(s[i]=='0')
		res2++;
		else
		res1++;	
	}
	else
	{
		if(s[i]=='1')
		res2++;
		else
		res1++;
	}
   }
   cout<<min(res1,res2)<<"\n";
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int t=1;
  while(t--)
  {
	 solve();
  }
  return 0;
}




Measured memory_bytes: 512
#include<cstdio>
const int mod=1000000007;
struct mat{
	int a[5][5];
	mat operator*(const mat&m)const{
		mat b;
		for(int i=0;i<5;i++){
			for(int j=0;j<5;j++)b.a[i][j]=0;
			for(int j=0;j<5;j++)if(a[i][j])
				for(int k=0;k<5;k++)b.a[i][k]=(b.a[i][k]+1ll*a[i][j]*m.a[j][k])%mod;
		}
		return b;
	}
};
int main(){
	int n;scanf("%d",&n);
	mat A=(mat){{
		{2,mod-1,1,mod-1,((n-1ll)*n+1)%mod},
		{1,0,0,0,0},
		{0,1,0,0,0},
		{0,0,0,1,1},
		{0,0,0,0,1}
	}},B=(mat){{
		{1,0,0,0,0},
		{0,1,0,0,0},
		{0,0,1,0,0},
		{0,0,0,1,0},
		{0,0,0,0,1},
	}};
	for(int m=n-1;m;m>>=1){
		if(m&1)B=B*A;
		A=A*A;
	}
	int ans=((B.a[0][0]+mod-B.a[1][0])*(n+1ll)
		+B.a[0][1]+mod-B.a[1][1]
		+B.a[0][3]+mod-B.a[1][3]
		+B.a[0][4]+mod-B.a[1][4])%mod;
	printf("%d\n",ans);
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <cstring>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

signed main() {
    int n;
    cin >> n;
    vll a(n);
    
    rep(i, n) cin >> a[i];
    map<ll, ll> ma;
    rep(i, n) ma[a[i]]++;
    
    ll res = 0;
    for (auto it : ma) res += it.second * (it.second - 1) / 2;
    
    
    rep(i, n) {
        ll ban = ma[a[i]];
        ll before = ban * (ban - 1) / 2;
        ll after = (ban - 1) * (ban - 2) / 2;
        ll sabun = before - after;
        cout << res - sabun << endl;
    }
}


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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	ll n, m;
	cin >>n >>m;
	/*
	vector<VI> ba(n, VI(m, 0));
	rep(i, n) rep(j, m){
		
		rep2(p,-1,2) rep2(q,-1,2){
			if(i+p<0 || i+p>=n || j+q<0 || j+q>=m) continue;
			ba[i+p][j+q] ^=1;
		}
	}
	
	for(auto xl: ba){for(auto x :xl) cerr<<x<<" ";dbg();}
	*/
	if(n==2 ||m==2) cout << 0 <<"\n";
	else if(n==1 && m==1) cout <<1 <<"\n";
	else if(n==1 || m==1) cout << max(n, m)-2 <<"\n";
	else cout << (m-2) * (n-2) <<"\n";
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;
int main(){
   ll n,k;
   cin>>n>>k;
   ll ans=pow(k-1,n-1);
   ans*=k;

   cout<<ans;
return 0;
}


Measured memory_bytes: 256
n=int(input())
s=[input() for i in range(n)]
a=[0,0,0,0,0]
for i in s:
  if i[0]=="M":
    a[0]+=1
  elif i[0]=="A":
    a[1]+=1
  elif i[0]=="R":
    a[2]+=1
  elif i[0]=="C":
    a[3]+=1
  elif i[0]=="H":
    a[4]+=1
cnt=0
for i in range(3):
  for j in range(i+1,4):
    for k in range(j+1,5):
      cnt+=a[i]*a[j]*a[k]
print(cnt)


Measured memory_bytes: 9772