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

int main() {
	int k, m, n;
	cin >> k >> m >> n;
	int a = m / k;
	int b = n / k;
	int r_m = m % k;
	int r_n = n % k;
	if (a == b && r_m != 0 & r_n != 0)
		cout << "NG";
	else
		cout << "OK";



	return 0;
}

Measured memory_bytes: 3636
<?php
  list($n) = explode(" ", trim(fgets(STDIN)));

  $a = array_map('intval', explode(" ", trim(fgets(STDIN))));

  $gcd=$a[0];
  for($i=1;$i<$n;$i++){
    $gcd=gmp_gcd($gcd,$a[$i]);
  }

  //1000000までの素数
  $pmkey = createPrimeNumber(1000000);

  $array = [];
  for($i=0;$i<$n;$i++){
    if(isset($pmkey[$a[$i]])) {
      if(isset($array[$a[$i]])){
        if($gcd==1){
          echo "setwise coprime";
        }else{
          echo "not coprime";
        }
        exit;
      }
      $array[$a[$i]]=true;
    }else{
      $res = factorize($a[$i]);
      foreach($res as $key => $val){
        if(isset($array[$key])){
          if($gcd==1){
            echo "setwise coprime";
          }else{
            echo "not coprime";
          }
          exit;
        }
        $array[$key]=true;      
      }
    }
  }
  echo "pairwise coprime";

function factorize($n){
  $res = [];
  for($i=2; $i*$i<=$n; $i++){
    if($n % $i != 0) continue;
    $res[$i]=0;
    while($n % $i == 0){      
      $res[$i]++;
      $n /= $i;
    }
  }
  if($n != 1){
    $res[$n]=1;
  }
  return $res;
}

    function createPrimeNumber($n){
      $sqrt = floor(sqrt($n));
      $lists = array_fill(2, $n-1, true);
      for ($i=2; $i<=$sqrt; $i++) {
        if (isset($lists[$i])) {
          for ($j=$i*2; $j<=$n; $j+=$i) {
            unset($lists[$j]);
          }
        }
      }
      return $lists;
    }

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

#define INF 999999999
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
#define pub push_back
#define pob pop_back
#ifdef LOCAL
  #define de(e) cout << "L" << __LINE__ << ": " << e << "\n" // debug echo
  #define dr(e) cout << "L" << __LINE__ << ": " << #e << " -> " << e << "\n" // debug repr
#else
  #define de(e)
  #define dr(e)
#endif
#define out(fmt, ...) printf(fmt, __VA_ARGS__); printf("\n")
int gcd(int m, int n) { if((0 == m) || (0 == n)){return 0;} while(m != n){ if(m > n){m -= n;}else{n -= m;} } return m; }
int lcm(int m, int n) { if((0 == m) || (0 == n)){return 0;} return (m / gcd(m, n)) * n; }

//
// Implementation
//

#define MAX_N 500

int N;
int C[MAX_N];
int S[MAX_N];
int F[MAX_N];

int solve(int num) {
  int sum = S[num] + C[num];
  for (int i=num+1; i<N-1; i++) {
    if (sum < S[i]) {
      sum += S[i] - sum;
      sum += C[i];
    } else {
      int wait = (sum - S[i]) % F[i];
      sum += ((wait == 0) ? 0 : (F[i] - wait)) + C[i];
    }
    dr(sum);
  }
  return sum;
}

int main() {
  cin >> N;
  rep(i, N-1) {
    cin >> C[i];
    cin >> S[i];
    cin >> F[i];
  }

  rep(i, N-1) {
    cout << solve(i) << endl;
  }
  cout << 0 << endl;
}


Measured memory_bytes: 256
package main

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

func readf(sc *bufio.Scanner) float64 {
	f, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func Abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func maxSub(list []int) int {
	max := 0
	for i := range list {
		if i == len(list)-1 {
			continue
		}
		sub := list[i+1] - list[i]
		if max < sub {
			max = sub
		}
	}
	return max
}

func subSList(list []int) []int {
	sl := make([]int, len(list)-1)
	for i := range list {
		if i == len(list)-1 {
			continue
		}
		sub := list[i+1] - list[i]
		sl[i] = sub
	}
	sort.Ints(sl)
	return sl
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	sc.Scan()
	m, _ := strconv.Atoi(sc.Text())

	x := make([]int, m)
	for i := range x {
		sc.Scan()
		x[i], _ = strconv.Atoi(sc.Text())
	}

	if m == 1 || m < n {
		fmt.Println(0)
		return
	}

	sort.Ints(x)
	sl := subSList(x)

	c := Abs(x[len(x)-1] - x[0])
	for i := 0; i < n-1; i++ {
		c = c - sl[len(sl)-1-i]
	}

	fmt.Println(c)
}


Measured memory_bytes: 2944
// B.cpp
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 110;

int n;

int main()
{
    scanf("%d", &n);
    int b = n & 1;
    n -= b;
    vector<pair<int, int>> ansBox;
    for (int i = 1; i <= (n << 1); i++)
    {
        for (int j = i + 1; j <= n; j++)
            if (j != i && j != (n - i + 1))
                ansBox.push_back(make_pair(i, j));
    }
    if (b)
    {
        n += b;
        for (int i = 1; i < n; i++)
            ansBox.push_back(make_pair(i, n));
    }
    printf("%lld\n", 1LL * ansBox.size());
    for (auto x : ansBox)
        printf("%d %d\n", x.first, x.second);
    return 0;
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int INF = 0x3f3f3f3f;
const int N = 1e5 + 10;
const int p = 1e9 + 7;
LL quick_mod(LL a, LL b) {
    LL ans = 1;
    a %= p;
    while (b) {
        if (b & 1) {
            ans = ans * a % p;
            b--;
        }
        b >>= 1;
        a = a * a % p;
    }
    return ans;
}

LL C(LL n, LL m) {
    if (m > n) return 0;
    LL ans = 1;
    for (int i = 1; i <= m; i++) {
        LL a = (n + i - m) % p;
        LL b = i % p;
        ans = ans * (a * quick_mod(b, p - 2) % p) % p;
    }
    return ans;
}

LL Lucas(LL n, LL m) {
    if (m == 0) return 1;
    return C(n % p, m % p) * Lucas(n / p, m / p) % p;
}
int main() {
    LL n, a, b;
    cin >> n >> a >> b;
    if (n == 2) {
        printf("0\n");
        return 0;
    }
    LL n1 = quick_mod(2, n) - 1;
    LL a1 = Lucas(n, a);
    LL a2 = Lucas(n, b);
    // a1 = (a1 % p + a2 % p) % p;
    n1 = (n1 - a2 + p) % p;
    cout << (n1 % p - a1 % p + p) % p << '\n';
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static boolean[] primes;

	static void primeSet(final int MAX){
		primes = new boolean[MAX+1];

		primes[2] = true;
		for(int i=3;i<=MAX;i+=2){
			primes[i] = true;
		}
		int rt = (int) Math.sqrt(MAX);
		for(int i=3;i<=rt;i+=2){
			if(primes[i]){
				for(int j=i*2;j<=MAX;j+=i){
					primes[j] = false;
				}
			}
		}
	}

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);

		primeSet(50021);

		while(stdIn.hasNext()){
			int n = stdIn.nextInt();
			
			for(int i=n-1;;i--){
				if(primes[i]){
					System.out.print(i+" ");
					break;
				}
			}
			for(int i=n+1;;i++){
				if(primes[i]){
					System.out.println(i);
					break;
				}
			}
		}	
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int N;
    scanf("%d",&N);
    ll A[N],C=0,D=0;
    for(int i=0;i<N;i++){
		scanf("%lld",&A[i]);
	}
	sort(A,A+N);
	int K=N/2;
	
	A[N/2];
	if(N%2){
		if( (A[K]-A[K-1]) > (A[K+1]-A[K]) ){
			//D bigger
			for(int i=0;i<K;i++){
				C+=A[i];
			}
			for(int i=K;i<N;i++){
				D+=A[i];
			}
			printf("%lld",2*D-2*C-A[K+1]-A[K]);
		}else{
			//C bigger
			for(int i=0;i<K+1;i++){
				C+=A[i];
			}
			for(int i=K+1;i<N;i++){
				D+=A[i];
			}
			printf("%lld",2*D-2*C+A[K-1]+A[K]);
		}
	}else{
		for(int i=0;i<K;i++){
			C+=A[i];
		}
		for(int i=K;i<N;i++){
			D+=A[i];
		}
		printf("%lld",2*D-2*C-A[K]+A[K-1]);
	}
}
	


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

int main(){

    string N;

    cin >> N;

    int n_total = 0, i;

    for(i=0 ; i < N.size(); i++){
        n_total += N[i] - '0';
    }

    if(stoi(N) % n_total == 0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    

    return 0;
}

/*基本*/
/*
入力：cin >> A >> B;
出力：cout << "hello world" <<endl;

stringクラス
.size()：文字列長を返す
.substr(,)：部分文字列を返す
.find(検索する文字列,開始位置)：文字列を検索。見つけた最初の文字の位置を返す

stoi(str)：文字列を整型で解釈
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    int main(){
      string N;
      cin >>N;

      for(int i=0;i<3;i++){
        if(N.at(i)=='7'){
        cout <<"Yes"<<endl;
          return 0;
        }
      }
      cout <<"No"<<endl;
      return 0;
    }


Measured memory_bytes: 3620
<?php
  $n=trim(fgets(STDIN));
  $h = explode(" ", trim(fgets(STDIN)));

  $count = 0;
  while(array_sum($h) < (101*$n)){
      $min = min($h);
      $flag = false;
      for($j=0; $j<$n; $j++){
          if($h[$j] >= $min && $h[$j] != 101){
              $flag=true;
              $h[$j] -= $min;
          }else{
              if($flag){
                  $count += $min;
              }
              $flag = false;
          }
          if($h[$j] == 0) $h[$j] = 101;
      }
      if($flag) $count+=$min;
  }
  echo $count;

Measured memory_bytes: 5112
A,B,K = (int(i) for i in input().split())

answers = []
for i in range(K):
  if A+i <= B:
    answers.append(A+i)
  if B-i >= A:
    answers.append(B-i)

answers = list(set(answers))
answers.sort()
for ans in answers:
  print(ans)


Measured memory_bytes: 3060
#include<iostream>
#include<complex>
using namespace std;
#define dff 1e-10
int main(){
  complex<double> a,b,c,d;
  while(cin >>a.real()>>a.imag()>>b.real()>>b.imag()>>c.real()>>c.imag()>>d.real()>>d.imag()){
    complex<double> vab,vcd;
    vab = a-b;
    vcd = c-d;
    double v = vab.real()*vcd.real()+vab.imag()*vcd.imag();
    if(v<dff && v>=-dff) cout <<"YES"<<endl;
    else cout <<"NO"<<endl;
  }
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;

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

    int a, b, c;
    cin >> a >> b >> c;
    bool ans = false;
    for (int t = 0; t < 61; t++)
    {
        if ((60 * t + c) % (a + b) <= a)
        {
            cout << 60 * t + c << endl;
            ans = true;
            break;
        }
    }
    if (!ans)
        cout << -1 << endl;
}


Measured memory_bytes: 3204
#include <stdio.h>
#include <math.h>



int main(void)
{
    long long int a,b,c,d,max;
    scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
    max = a*c;
    if(max < a*d) max = a*d;
    if(max < b*c) max = b*c;
    if(max < b*d) max = b*d;

    printf("%lld",max);
    
    return 0;
}

Measured memory_bytes: 2148
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pie 3.1415926536
#define pb push_back
#define N 1000000007
#define M 998244353
#define ff first
#define ss second
#define INF 1ll<<63 - 1
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define nrep(i,a,b) for(int i=a;i>=b;i--)
#define pl pair<ll,ll>
#define pi pair<int,int>
#define pll pair<pair<ll,ll>, ll> 
#define pii pair< int, pair<int,int> >
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll t,x=0,b,y,q,z,k,n,m;
    cin>>n>>k;
    ll r,s,p;
    cin>>r>>s>>p;
    string str;
    cin>>str;
    ll dp[n+5][3];
    memset(dp,0,sizeof(dp));
    ll ans = 0;
    rep(i,0,k-1){
    	if(str[i] == 's'){
    		dp[i][0] = r;
		}else{
			dp[i][0] = 0;
		}
		if(str[i] == 'p'){
    		dp[i][1] = s;
		}else{
			dp[i][1] = 0;
		}
		if(str[i] == 'r'){
    		dp[i][2] = p;
		}else{
			dp[i][2] = 0;
		}
		if(i + k >= n){
			ans += max(dp[i][0],max(dp[i][1],dp[i][2]));
			continue;
		}
		ll val = 0;
		for(ll j = i+k;j<n;j+=k){
			if(str[j] == 's'){
    			dp[j][0] = r;
    			dp[j][0] += max(dp[j-k][1],dp[j-k][2]);
			}else{
				dp[j][0] = 0;
				dp[j][0] += max(dp[j-k][1],dp[j-k][2]);
			}
			if(str[j] == 'p'){
	    		dp[j][1] = s;
	    		dp[j][1] += max(dp[j-k][0],dp[j-k][2]);
			}else{
				dp[j][1] = 0;
				dp[j][1] += max(dp[j-k][0],dp[j-k][2]);
			}
			if(str[j] == 'r'){
	    		dp[j][2] = p;
	    		dp[j][2] += max(dp[j-k][1],dp[j-k][0]);
			}else{
				dp[j][2] = 0;
				dp[j][2] += max(dp[j-k][1],dp[j-k][0]);
			}
			val = max(val,max(dp[j][0],max(dp[j][1],dp[j][2])));
		}
		ans +=val;
	}
	cout<<ans;
}


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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    string S;
    cin >> S;
    sort(S.begin(), S.end());
    if(S == "abc") cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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


Measured memory_bytes: 7004
n, k = map(int, input().split())
p = list(map(int, input().split()))

for i in range(n):
  p[i] = (p[i]+1)/2
  
num = sum(p[:k])
max_num = num

for i in range(k,n):
  num = num - p[i-k] + p[i]
  max_num = max(max_num, num)
  
  
print(max_num)

Measured memory_bytes: 24816
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template<typename T>
struct FenwickTree{
    vector<T> data;
    int sz;

    FenwickTree(int n) : sz(n + 2) { data.assign(sz, 0); }

    void add(int i, T x){
        ++i;
        while(i <= sz){
            data[i] += x;
            i += i & -i;
        }
        return;
    }

    T sum(int i){
        ++i;
        T res = 0;
        while(i > 0){
            res += data[i];
            i -= i & -i;
        }
        return res;
    }

    T sum(int l, int r){
        return sum(r) - sum(l - 1);
    }
};

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

    int n;
    cin >> n;
    vector<P> table;
    for(int i = 0; i < n; ++i){
        int a;
        cin >> a;
        table.emplace_back(a, i);
    }
    sort(table.rbegin(), table.rend());
    FenwickTree<ll> bit(n);
    ll ans = 0;
    for(auto p : table){
        ans += bit.sum(p.second);
        bit.add(p.second, 1);
    }
    cout << ans << endl;
}


Measured memory_bytes: 6156
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <stack> 
#include <sstream>
#include <set>

typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
int gcd(int a, int b){
    if(a%b==0){
        return b;
    }else{
        return (gcd(b,a%b));
    }
}
int lcm(int a, int b){
    int x = gcd(a,b);
    return (a*b/x);
}

using namespace std;
ll k (ll a){
    
    ll ans =0;
    while(a != 0){
        ans += a;
        a--;
        
    }
    return ans;
}

int main(){
    int n;
    cin  >> n;
    vector<string> vec(n);

    string s;
    REP(i,n){
        cin >> s;
        SORT(s);
        vec[i] = s;
    }
    SORT(vec);

    ll ans = 0;
    
    for(int i=0;i<n-1;++i){
        if(vec[i] == vec[i+1]){
            ll cnt = 0;
            int jj;
            for(int j = i; j < n-1;j++){
                if(vec[j] == vec[j+1]){
                    cnt++;
                }else{
                    jj = j;
                    break;
                }
                if(j == n-2) jj = j;
            }
        
            ll x = k(cnt);
            
            ans += x;
            i = jj;
            
        }
    }

    cout << ans <<endl;

    
}






Measured memory_bytes: 5760
X, K, D = map(int, input().split())

x = X % D
k = K - abs(X//D)
# print(x, k)
if k < 0:
    print(min(abs(X + K * D), abs(X - K * D)))
else:
    if k % 2 == 0:
        print(abs(x))
    else:
        print(abs(abs(x)-D))

Measured memory_bytes: 9188
import sys
N, M = map(int, input().split())
X = list(map(int, input().split()))

if N >= M:
  print(0)
  sys.exit()

X.sort() # O(MlogM)

# O(M)
D = []
for i in range(M-1):
  D.append(X[i+1] - X[i])

D.sort() # O(MlogM)

print(sum(D[:M-N])) # O(M)


Measured memory_bytes: 13968
n=int(input())#读入，注意不加int()会RE
ans=0#ans为最终答案
for i in range (0,n):#[0,n)中有n个数，强迫症可以这么写:for i in range (1,n+1)即[1,n+1)即[1,n]
    s=input().split()#一行输入多组数据
    ans+=int(s[1])-int(s[0])+1#区间元素个数为(末项-首项+1)
print(ans)#print自带回车

Measured memory_bytes: 3060
a, b = (int(i) for i in input().split())  

if a == b: 
    print(-1)
elif a < 0 or b < 0: 
    print (-1)
else:
    for i in range(1, int(10 ** 10 / a)):
        if a * i % b != 0:
            print(a * i)
            exit()
        else:
            continue
    print(-1)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
    using namespace std;
	typedef long long int ll; 
     
    int main() {
      ll N;
      cin >> N; 
      ll m; 
      cin >> m; 
      
      for(int i=0; i<5; i++){
        ll A;
        cin>> A;
        m= min( A, m ); 
      }
      if(N%m==0) cout<< (N/m)+4 << endl;
      if(N%m!=0) cout<< (N/m)+5 << endl;      
    }

Measured memory_bytes: 256
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

def lcm(a, b):
    return a * b // gcd(a, b)
 
a, b = 1, 1
n = int(input())
for i in range(n):
    a = lcm(a, int(input()))
print(a)


Measured memory_bytes: 2940
// Contest.cpp : アプリケーションのエントリ ポイントを定義します。
//

#include"iostream"
#include"string"
#include"vector"
#include"algorithm"

using namespace std;

int main()
{
	/*int n,k;
	cin >> n;
	vector<char>s(n);
	for (int j = 0; j < n; j++)  cin >> s[j];
	cin >> k;
	for (int i = 0; i < n; i++)
	{
		if (s[i] != s[k-1]) {
			s[i] = '*';
		}
	}

	for (int l = 0; l < n; l++)
	{
		cout << s[l] ;
	}*/
	int a,p;
	cin >> a >> p;
	int b;
	b = 3 * a + p;
	cout<<b/2<<endl;
	return 0;
}






Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()

if S == "zyxwvutsrqponmlkjihgfedcba":
	print(-1)
elif len(S) < len(ascii_lowercase):
	for char in ascii_lowercase:
		if char not in S:
			print(S+char)
			break
else:
	S = S[::-1]
	for i in range(len(S)-1):
		if S[i+1] < S[i]:
			for char in sorted(S[:i+1]):
				if char > S[i+1]:
					print(S[::-1][:-i-2]+char)
					exit()


Measured memory_bytes: 5204
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define dbg(x) cout<<#x<<":"<<x<<endl
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;

int main(){
  ll l;
  cin>>l;
  if(l==2){
    cout<<"2 2"<<endl;
    cout<<"1 2 0"<<endl;
    cout<<"1 2 1"<<endl;
    return 0;
  }
  l--;
  vector<ll> bt;
  ll t=l;
  ll cnt=0;
  while(t){
    cnt+=t%2;
    bt.pb(t%2);
    t/=2;
  }

  ll n=bt.size();
  cout<<n<<" "<<(n-1)*2+cnt<<endl;
  ll k=pow(2,n-2);
  for(int i=0;i<n-1;i++){
    cout<<i+1<<" "<<i+2<<" "<<0<<endl;
    cout<<i+1<<" "<<i+2<<" "<<k<<endl;
    k/=2;
  }
  
  cout<<1<<" "<<n<<" "<<l<<endl;
  for(int i=0;i<bt.size()-1;i++){
    if(bt[i]==0)continue;
    l-=pow(2,i);
    cout<<1<<" "<<n-i<<" "<<l<<endl;
  }
  return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
void main()
{
  long int a,i,sum=0;
  scanf("%ld",&a);
  for(i=1;i<=a;i++)
  {
    if(i%3==0)
    {
       sum=sum+0;
    }
    else if(i%5==0)
    {
        sum=sum+0;
    }
else
{
  sum=sum+i;
  }
  }
  printf("%ld",sum);
}


Measured memory_bytes: 1728
// Problem : A - ∴ (Therefore)
// Contest : AtCoder - AtCoder Beginner Contest 168
// URL : https://atcoder.jp/contests/abc168/tasks/abc168_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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

#define ll long long
#define endl "\n"
#define lb "lower_bound"
#define ub "upper_bound"
#define bs "binary_search"

int dif(int a,int b){if(a > b)return a - b;else return b - a;}
int min(int a,int b){if(a > b)return b;else return a;}
int max(int a,int b){if(a > b)return a;else return b;}
int gcd(int a, int b){if(b == 0)return a;return gcd(b, a%b);}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL),cout.tie(NULL);
    int n;
    cin>>n;
    n = n%10;
    if(n == 2 || n == 4 || n == 5 || n == 7 || n == 9)
    cout<<"hon";
    else if(n == 3)
    cout<<"bon";
    else cout<<"pon";
	return 0;
}


Measured memory_bytes: 3652
use std::str::FromStr;
use std::collections::{HashMap,HashSet,VecDeque,BinaryHeap};
use std::cmp::{max,min,Ordering};
use std::io::Read;

fn main() {

    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut buf_it = buf.split_whitespace();

    let N = buf_it.next().unwrap().parse::<usize>().unwrap();
    let mut S = (0..N).map(|_| buf_it.next().unwrap().parse::<usize>().unwrap()).collect::<Vec<_>>();

    let cnt = mergeSort(&mut S,0,N);
    println!("{}",S.iter().map(|&s| format!("{}",s)).collect::<Vec<_>>().join(" "));
    println!("{}",cnt);

}

fn mergeSort(S:&mut Vec<usize>,left:usize,right:usize)->usize{
    let mut cnt = 0;
    if left+1 < right{
        let mid = (left + right)/2;
        cnt += mergeSort(S, left, mid);
        cnt += mergeSort(S, mid, right);
        cnt += merge(S,left,mid,right);
    }
    cnt
}

fn merge(S:&mut Vec<usize>,left:usize,mid:usize,right:usize)->usize{
    let mut cnt = 0;
    let mut L = (left..mid).map(|i| S[i]).collect::<Vec<_>>();
    let mut R = (mid..right).map(|i| S[i]).collect::<Vec<_>>();
    let INF = 1_000_100_000;
    L.push(INF);
    R.push(INF);
    let mut i = 0;
    let mut j = 0;
    for k in left..right{
        if L[i] <= R[j]{
            S[k] = L[i];
            i += 1;
        } else {
            S[k] = R[j];
            j += 1
        }
        cnt += 1;
    }
    cnt
}


Measured memory_bytes: 39844
using namespace std;

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <limits>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <numeric>
typedef long long ll;
typedef pair<int,int> p;

int main()
{
  int n,d, x;
  cin >> n >> d >> x;
  vector<int> v(n, 0);
  for (int i = 0; i < n; i++){
    cin >> v[i];
  }
  int res = x;
  for (int i = 0; i < n; i++){
    int day = 1;
    while(day <= d) {
      res++;
      // cout << day << endl;
      day += v[i];
    }
  }
  cout << res << endl;
  return 0;
}


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

int main(){

    int N;
    cin >> N;
    vector<long long> A(N), B(N), plus;
    for(int i = 0; i < N; i++) cin >> A[i];
    for(int i = 0; i < N; i++) cin >> B[i];

    long long count = 0, need = 0;
    for(int i = 0; i < N; i++){
        if(A[i] > B[i]) plus.push_back(A[i] - B[i]);
        else if(A[i] < B[i]){
            need += B[i] - A[i];
            count++;
        }
    }

    sort(plus.rbegin(), plus.rend());
    for(int i = 0; i < plus.size(); i++){
        if(need <= 0) break;
        need -= plus[i];
        count++;
    }

    if(need > 0) cout << -1 << endl;
    else cout << count << endl;

    return 0;
}

Measured memory_bytes: 2428
#include <bits/stdc++.h>
using namespace std;
 
int main(){

    int N, K;
    
    cin >> N;
    cin >> K;

    vector<long> H(N);

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

    // sort
    sort(H.begin(), H.end(), greater<long>());

    long n_attack = 0;

    if(K >= N){
        cout << 0 << endl;
    }else{
        for(int i=K; i<N; i++){
            n_attack += H[i];
        }
        cout << n_attack << endl;
    }

    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>

using namespace std;

int main() {
	int i, j;
	string n;

	cin >> n;

	int num, sum = 0;
	for (i = 0; i < n.length(); i++) {
		num = (int)n[i] - 48;
		sum += num;

		
		//cout << num << endl;
	}
	if (stoi(n)%sum==0)
	{
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}




	return 0;
}

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

#define INF 0x3f3f3f3f

typedef long long ll;
typedef pair<int, int> P;

int h, w, n;
int a;
int ans[110];

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

	cin >> h >> w >> n;
	int cw = 0, ch = 0;
	bool flg = false;
	for (int i = 0; i < n; i++) {
		cin >> a;
		while (a--) {
			if (!flg) ans[cw++] = i+1;
			else ans[cw--] = i+1;
			if (cw == w || cw < 0) {
				flg = (flg ? false : true);
				if (cw == w) cw--;
				else cw++;
				for (int j = 0; j < w; j++) cout << ans[j] << ' ';
				cout << endl;
			}
		}
	}



	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
int pow(int n){
	int k=1;
	for(int i=0;i<n;i++){
		k=k*100;
	}
	return k;
}
int main(){
	int a=0;
	int d,n;
	scanf("%d%d",&d,&n);
	int b=pow(d);
	for(int i=1;true;i++){
		if(i%100!=0)a++;
		if(a==n){
			printf("%d\n",b*i);
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
struct node{
	int s,e;
}x[100000];
bool cmp(struct node a1,struct node a2)
{
	return a1.e<a2.e;
}
int main(void)
{
	int n;
	scanf("%d",&n);
	int i;
	for(i=0;i<n;i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		x[i].s=a-b;
		x[i].e=a+b;
	}
	sort(x,x+n,cmp);
	int ans=0,t=x[0].s;
	for(i=0;i<n;i++)
	{
		if(t<=x[i].s)
		{
			ans++;
			t=x[i].e;
		}
	}
	printf("%d",ans);
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <algorithm>
#include <typeinfo>
#define _USE_MATH_DEFINES
#include <cmath>

using namespace std;

string EnqDeq_str(string s){
    char tmp;
    tmp = s[0];
    for(int i=0; i<s.size()-1; i++){
        s[i] = s[i+1];
    }
    s[s.size()-1] = tmp;
    return s;
}

string getSubStr(string s, int i, int j){
    vector<string> tmp(j-i+1);
    for(int h=0; h<j-i+1; h++){
        tmp[h] = s[i+h];
    }
    string subStr;
    for(int h=0; h<j-i+1; h++){
        subStr += tmp[h];
    }
    return subStr;
}

int main(){

    string s, p;
    cin >> s;
    cin >> p;

    for(int i=0; i<s.size(); i++){
        if(p==getSubStr(s,0,p.size()-1)){
            cout << "Yes" << endl;
            return 0;
        }
        s = EnqDeq_str(s);
    }

    cout << "No" << endl;

    return 0;
}



Measured memory_bytes: 3192
#include<cstdio>

int main(){
    unsigned X;
    scanf("%u", &X);
	unsigned r = X, a = 360;
	while(a % X != 0){
		r = a % X;
		a = X;
		X = r;
	}
    printf("%u\n", 360/r);
	return 0;
}

Measured memory_bytes: 1736
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>

using namespace std;
int main() {
    int n;
    cin>>n;
    vector<int> a;
    int x;
    for (int i=0;i<n;++i){
        cin>>x;
        a.push_back(x);
    }
    sort(a.begin(),a.end());
    for (int i=0;i<n-1;++i){
        if (a[i]==a[i+1]){
            cout<<"NO";
            return 0;
        }
    }
    cout<<"YES";
}

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

int main() {
  int a,b;
  string ans="No";
  cin >> a >> b;
  a*=10;
  if(b>9) a*=10;
  if(b>99) a*=10;
  for(int i=1;i*i<=a+b;i++) {
    if(i*i==a+b) ans="Yes";
  };
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;
 
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;
 
const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;
 
#define _  %  MOD
#define __ %= MOD
 
#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))
 
#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
#define fbo find_by_order
#define ook order_of_key
 
ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent
 
int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
	string s;
	cin>>s;
	if(s[2]==s[3] && s[4]==s[5]) cout<<"Yes\n";
	else cout<<"No\n";
	return 0;	
}
// JUST ASK YOURSELF DID YOU GIVE YOUR BEST ? ISSE ZYADA
// KUCH KAR BHI NAHI SAKTE !! ENJOY AND GIVE YOUR BEST!!



Measured memory_bytes: 3616
fun main() {
    val (n, k) = run {
        val (n, k) = readLine()!!.split(' ').map { it.toLong() }
        n.toInt() to k
    }
    val a = readLine()!!.split(' ').map { it.toInt() }

    val (s, l, c) = run {
        val r = mutableListOf<Int>()
        val visited = IntArray(n + 1) { -1 }

        var v = 1
        while (visited[v] == -1) {
            visited[v] = r.size
            r.add(v)
            v = a[v - 1]
        }

        val l = visited[v]
        val c = r.size - visited[v]
        Triple(r, l, c)
    }

    val i = if (k < l) {
        k.toInt()
    } else {
        ((k - l) % c).toInt() + l
    }

    println(s[i])
}


Measured memory_bytes: 64468
from sys import stdin


def main():
    N, K = [int(x) for x in stdin.readline().rstrip().split()]
    S = stdin.readline().rstrip()
    score = 0
    for i, c in enumerate(S[:-1]):
        if c == S[i + 1]:
            score += 1
    print(min(N - 1, score + 2 * K))


if __name__ == "__main__":
    main()


Measured memory_bytes: 3316
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

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

    vector<int> a(N);

    for( int n = 0; n < N; n++ )
    {
        int A;
        cin >> A;
        a.push_back(A);
    }

    int count = 0;

    while(true)
    {
        bool exitflag = false;
        for( auto x : a )
        {
            if( x % 2 != 0 )
            {
                // 奇数があったら
                exitflag = true;
                break;
            }
        }

        if( exitflag == true )
        {
            break;
        }

        count++;
        for( auto &x : a )
        {
            x /= 2;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i < n; i++)
#define repv(i,n) for(int i = n-1; i >= 0; i--)
#define fi first
#define sc second
#define pb push_back
using namespace std;
typedef long long ll;

char BUF[3500000];
inline void I(int&a){scanf("%d",&a);}
inline void I(int&a,int&b){scanf("%d%d",&a,&b);}
inline void I(int&a,int&b,int&c){scanf("%d%d%d",&a,&b,&c);}
inline void I(int&a,int&b,int&c,int&d){scanf("%d%d%d%d",&a,&b,&c,&d);}
inline void L(ll&a){scanf("%lld",&a);}
inline void L(ll&a,ll&b){scanf("%lld%lld",&a,&b);}
inline void L(ll&a,ll&b,ll&c){scanf("%lld%lld%lld",&a,&b,&c);}
inline void L(ll&a,ll&b,ll&c,ll&d){scanf("%lld%lld%lld%lld",&a,&b,&c,&d);}
inline void S(string&str){str.clear();scanf("%s",BUF);int s=strlen(BUF);rep(i,s)str.pb(BUF[i]);}
inline void SV(vector<int>&v){v.clear();scanf("%s",BUF);int s=strlen(BUF);rep(i,s)if('a'<=BUF[i]&&BUF[i]<='z')v.pb(BUF[i]-'a');else v.pb(BUF[i]-'A');}

const auto EPS = 1e-10;
const auto INF = 100000000;
const auto MOD = 1000000007;
typedef pair<int,int> P;

int n, m;
vector<int> e[100000];
set<P> se;
set<P> pre;

bool dfs(int root, int v){
    if(root == v) return true;
    rep(i,e[v].size()){
        if(se.count(P(v,e[v][i]))) continue;
        se.insert(P(v,e[v][i]));
        se.insert(P(e[v][i],v));
        return dfs(root, e[v][i]);
    }
    return false;
}

int main(){
    I(n,m);
    rep(i,m){
        int a, b;
        I(a,b);
        a--; b--;
        e[a].push_back(b);
        e[b].push_back(a);
        if(pre.count(P(a,b))){
            se.insert(P(a,b));
            se.insert(P(b,a));
        }
        pre.insert(P(a,b));
        pre.insert(P(b,a));
    }
    rep(i,n){
        rep(j,e[i].size()){
            if(se.count(P(i,e[i][j]))) continue;
            se.insert(P(i,e[i][j]));
            se.insert(P(e[i][j],i)); 
            bool ret = dfs(i, e[i][j]);
            if(!ret){
                cout << "NO" << endl;
                return 0;
            }
        }
    }
    cout << "YES" << endl;
}
































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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  
  sort(A.begin(), A.end());
  
  cout << A.at(N - 1) - A.at(0) << endl;
}

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

using namespace std;

struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}init;

typedef long long LL;
#define fin "\n"
template<typename T>void chmin(T &a,T b){a=min(a,b);}
template<typename T>void chmax(T &a,T b){a=max(a,b);}
template<typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}

int main(){
    string S;cin>>S;
    int n=S.size();
    int cnt=0;
    int res=0;
    for(int i=0;i<n;i++){
        if(S[i]=='S')cnt++;
        else if(cnt==0)res++;
        else cnt--;
        
    }
    cout<<res+cnt<<endl;
    return 0;
}


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;

#define PI (2*acos(0.0))
#define eps 1e-9
#define pb push_back
#define endl "\n"
#define watch(x) cout << (#x) << " is " << (x) << endl;
#define show(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi] << " "; cout << endl;
#define showpair(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi].first << " " << v[fi].second << endl;
#define ff first
#define ss second
#define fu cout << "lol" << endl;
#define precision(n) cout << fixed << setprecision(n);
#define lb lower_bound
#define up upper_bound
#define vscan for(i = 0;i<n;i++){cin>>in; v.pb(in);}
#define all(a) a.begin(), a.end()
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define mem(a,val) memset(a,val,sizeof(a))
#define loop(i,n) for(i = 0; i < n; i++)
#define TC() ull T; cin>>T; while(T--)
#define IN(x) {scanf("%d",&x);}
#define LL(x) {scanf("%lld",&x);}
#define CC(x) {scanf("%c",&x);}
#define pfl(x) printf("%d\n",x)
#define pfll(x) printf("%lld\n",x)
#define newl puts("")
#define space printf(" ")
#define MOD 1000000007
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL);

const int N = 1e7+5;
int arr[N];

int main()
{
    ll i = 0, j = 0, cs = 0, in;
    int n; IN(n);
    ll ans = 0;
    for(i = 1; i <= n; i++){
        for(j = i; j <= n; j+=i){
            arr[j]++;
        }
        ans += arr[i]*i;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 42816
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,r,g,n,b,p,a[10000];
    scanf("%d",&n);
    int maxi=INT_MIN,mini=INT_MAX;
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        maxi=max(a[i],maxi);
        mini=min(a[i],mini);
    }
    printf("%d",maxi-mini);
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		int[] d = new int[n];
		for (int i = 0; i < n; i++) {
			d[i] = sc.nextInt();
		}

		int r = 0;
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				r += d[i] * d[j];
			}
		}

		System.out.println(r);

		sc.close();
	}
}


Measured memory_bytes: 23252
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())
#define endl "\n"

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



int n, res;
string s[3];

signed main() {
	cin >> n;
	rep(i,3) cin >> s[i];
	rep(i,n) {
		int a[26] = {};
		rep(j,3) a[s[j][i]-'a']++;
		res += 3 - *max_element(a,a+26);
	}
	cout << res << endl;
}


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

#define ll long long
using vt = ll; //ここで数値の型を変えられる
#define rep(i, n) for (vt i = 0; i < (vt)(n); i++)
#define reps(i, s, n) for(vt i = (vt) (s); i < (vt) (n); i++) 
#define all(v) v.begin(), v.end()
#define P pair<ll, ll>
const ll  MOD = 1000000007;

vector<ll> f(vector<ll> v) {
	sort(all(v));
	vector<ll> u;
	reps(i, 1, v.size()) v.at(i) %= v.at(0);
	rep(i, v.size()) {
		if (v.at(i) != 0) {
			u.push_back(v.at(i));
		}
	}
	if (u.size() > 1) return f(u);
	else return u;
}

int main() {
	ll n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n) cin >> a.at(i);
	cout << f(a).at(0);
	return 0;
}

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

int main() {
    vector<string> v{"black","blue","lime","aqua","red","fuchsia","yellow","white"};
    string s;
    while(cin >> s, s != "0") cout << v[4*(s[1]>'7')+2*(s[3]>'7')+1*(s[5]>'7')] << "\n";
    return 0;
}


Measured memory_bytes: 3068
using System;
using System.Linq;
 
namespace Aizu
{
    class OnlineJudge
    {
        public static void Main()
        {
            var d = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            Console.WriteLine(Enumerable.Range(d[0], d[1] - d[0] + 1).Count(q => d[2] % q == 0));
        }
    }
}

Measured memory_bytes: 13956
if __name__ == "__main__":
  N, A, B = map(int, input().split())
  
  if( (B-A) % 2 == 0 ):
    print( (B-A)//2 )
  elif(N-B < A-1):
    cnt = N-B+1
    A += 1
    print( cnt + (B-A)//2 )
  else:
    cnt = A
    B -= 1
    print( cnt + (B-A)//2 )

Measured memory_bytes: 3064
#include <stdio.h>

int main(int argc, const char * argv[])
{
    int d = 100000;
    int n;
    
    scanf("%d", &n);
    while (n>0){
        d = d*1.05;
        if (d%1000 != 0) d = (d / 1000) * 1000 + 1000;
        n--;
    }
    printf("%d\n",d);
    return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
const int MAX=100010;
int n,m;
int x,y;
int ans;
int dp[MAX],bio[MAX],pozvana[MAX];
vector<int>ts;
vector<int>graf[MAX];
void top_sort(int x){
	if(pozvana[x]){
		cout<<"ERR\n";
	}
	pozvana[x]=1;
	for(auto y:graf[x]){
		if(bio[y]) continue;
		top_sort(y);
	}
	pozvana[x]=0;
	bio[x]=1;
	ts.push_back(x);
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>x>>y;
		graf[y].push_back(x);
	}
	for(int i=1;i<=n;i++){
		if(bio[i]) continue;
		top_sort(i);
	}
	dp[0]=0;
	for(int i=1;i<ts.size();i++){
		int x=ts[i];
		for(auto y:graf[x]){
			dp[x]=max(dp[x],dp[y]+1);
		}
		ans=max(ans,dp[x]);
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 11896
N = int(input())
dp = [[[[0 for l in range(4)] for k in range(4)]
       for j in range(4)] for i in range(N)]
for j in range(4):
    for k in range(4):
        for l in range(4):
            if not (j == 0 and k == 1 and l == 2)\
                    and not(j == 0 and k == 2 and l == 1)\
                    and not (j == 2 and k == 0 and l == 1):
                dp[2][j][k][l] = 1
for i in range(2, N-1):
    for j in range(4):
        for k in range(4):
            for l in range(4):
                dp[i][j][k][l] %= 10**9+7
                dp[i+1][k][l][0] += dp[i][j][k][l]
                # 0123: ACGT
                # AG?
                # ?GA
                # A?G
                # ?AG
                if not (j == 0 and k == 2) \
                   and not (k == 2 and l == 0)\
                   and not (j == 0 and l == 2)\
                   and not (k == 0 and l == 2):
                    dp[i+1][k][l][1] += dp[i][j][k][l]
                # ?AC
                if not (k == 0 and l == 1):
                    dp[i+1][k][l][2] += dp[i][j][k][l]
                dp[i+1][k][l][3] += dp[i][j][k][l]
ans = 0
for j in range(4):
    for k in range(4):
        for l in range(4):
            ans += dp[N-1][j][k][l]
ans %= 10**9+7
print(ans)


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

#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++)

using namespace std;
const int INF = 1 << 30;
const long long MOD = 1000000000 + 7;
const double PI = acos(-1);



int main() {
	int N, K; cin >> N >> K;
	vector<int> V;
	rep(i, N) {
		int v; cin >> v;
		V.push_back(v);
	}
	
	long long ans = 0;
	rep(i, N + 1) {
		rep(j, N - i + 1) {
			if (K >= i + j) {
				rep(k, K - i - j + 1) {
					if (i + j + k != 0) {
						//cout << i << " " << j << " " << k << endl;
						priority_queue<int, vector<int>, greater<int>> pq;
						rep(l, i)pq.push(V[V.size() - l - 1]);
						rep(l, j)pq.push(V[l]);
						int count = 0;
						/*cout << "num" << endl;
						cout << pq.size() << endl;
						cout << count << endl;*/
						while (!pq.empty() && count != k) {
							pq.pop();
							//cout << "pop" << endl;
							++count;
						}
						/*cout << "num" << endl;*/
						long long num = 0;
						while (!pq.empty()) {
							num += (long long)pq.top();
							pq.pop();
						}
						if (ans < num)ans = num;
						/*cout << num << endl;*/
					}
				}
			}
		}
	}
	cout << ans;

}

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

int main() {
  ll n;
  cin >> n;
  vector<string> s(3);
  for(ll i=0;i<3;i++) {
    cin >> s[i];
  }
  ll ans=0;
  for(ll i=0;i<n;i++) {
    set<char> ss;
    for(ll j=0;j<3;j++) {
      ss.insert(s[j][i]);
    }
    ans+=ss.size()-1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<queue>
#define MAXN 40000

using namespace std;

int n;
int prime[MAXN+1];

bool isPrime(int x)
{
    int i;
    for(i=2;i<=floor(sqrt(x));i++)
        if(x%i==0)
            return false;
    return true;
}
void getPrime()
{
    memset(prime,0,sizeof(prime));
    for(int i=2;i<=MAXN;i++)
    {
        if(!prime[i])prime[++prime[0]]=i;
        for(int j=1;j<=prime[0]&&prime[j]<=MAXN/i;j++)
        {
            prime[prime[j]*i]=1;
            if(i%prime[j]==0) break;
        }
    }
}

int main()
{
    int i;
    cin>>n;
    if(isPrime(n))
        printf("%d: %d\n",n,n);
    else
    {
        printf("%d:",n);
        getPrime();
        for(i=1;i<prime[0];i++)
            while(n%prime[i]==0)
            {
                printf(" %d",prime[i]);
                n=n/prime[i];
            }
        if(n!=1)
            printf(" %d",n);
        printf("\n");
    }
    return 0;
}



Measured memory_bytes: 3348
def main():
    N, M, *HAB = map(int, open(0).read().split())
    H = [0]*N
    for i in range(N):
        H[i] = HAB[i]
    A, B = [0]*M, [0]*M
    for i in range(M):
        A[i] = HAB[N + 2 * i + 0] - 1
        B[i] = HAB[N + 2 * i + 1] - 1
    # print(N, M, H, A, B)
    ans = set()
    for i in range(M):
        a = A[i]
        b = B[i]
        ha = H[a]
        hb = H[b]
        if ha < hb:
            ans.add(a)
        elif hb < ha:
            ans.add(b)
        else:
            ans.add(a)
            ans.add(b)
    print(N - len(ans))

if __name__ == '__main__':
    main()


Measured memory_bytes: 44108