akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P,VECP,greater<P> > PQP;
typedef priority_queue<ll, VECLL, greater<ll> > PQll;

#define rep(i,a,n) for(ll i = a;i < n;i++)   
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

#include <bits/stdc++.h>
#define rep(i,a,n) for(ll i = a;i < n;i++)
typedef long long ll;
using namespace std;

int main(){
    
    ll n,k;
    cin >> n >> k;
    double ruiseki[n] = {};

    rep(i,0,n){
        ll a;
        cin >> a;
        ruiseki[i] = (double)(1+a)/2.0;
        if(i > 0) ruiseki[i] += ruiseki[i-1];
    }

    double ans = 0;
    rep(i,k-1,n){
        if(i == k-1) ans = ruiseki[i];
        else ans = max(ans,ruiseki[i] - ruiseki[i-k]);
    }
    cout << setprecision(10) << ans << endl;
    return 0;
}


Measured memory_bytes: 5344
#include <iostream>

char A[100000 + 10];

int main()
{
  int N;
  std::cin >> N >> A;
  A[N] = 'E';

  int val = 0;
  int cur = 1;
  int ans = 0;
  while (val < N && cur < N)
  {
    while (A[val] == A[cur]) ++cur;
    if (cur < N)
    {
      ++ans;
      val = cur + 1;
      cur = val + 1;
    }
  }

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

  return 0;
}



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

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String arg = br.readLine();
        String[] inputArray = arg.split(" ");
        int[] inputIntArray = new int[inputArray.length];

        for (int count = 0; count < inputIntArray.length; count++) {
            inputIntArray[count] = Integer.parseInt(inputArray[count]);
        }
        int x = inputIntArray[0];
        int y = inputIntArray[1];

        int menseki = x * y;
        int nagasa = (x + y) * 2;

        System.out.println(menseki + " " + nagasa);
    }
}

Measured memory_bytes: 16896
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    final Scanner s = new Scanner(System.in);
    final int a = Integer.parseInt(s.next());
    final int b = Integer.parseInt(s.next());

    if (a > 0) {
      System.out.println("Positive");
    } else if (a == 0 || b >= 0) {
      System.out.println("Zero");
    } else {
      if ((b - a) % 2 == 0) {
        System.out.println("Negative");
      } else {
        System.out.println("Positive");
      }
    }
  }
}

Measured memory_bytes: 22612
sub c{$s=$t=0;$%=$_[0];$s+=$_,$%&&$s>=0&&($t+=$s+1,$s=-1),!$%&&$s<=0&&($t-=$s-1,$s=1),$%=!$%for@a;$t}<>;@a=glob<>;print c(0)<c(1)?c(0):c(1)

Measured memory_bytes: 27008
#include <iostream>
#include <vector>
#include <set>
#include <numeric>
#include <algorithm>
// #include <cmath>
// #include <string>
// #include <map>
// #include <iomanip>

// #define MOD 1000000007

using namespace std;
// typedef unsigned long long ull;
typedef long long ll;

void p() {
    cout << "\n";
}
template<class Head, class... Body>
void p(Head head, Body... body) {
    cout << head << ",";
    p(body...);
}

template<typename T>
ostream& operator<<(ostream& os, const multiset<T>& s) {
    os << "{";
    for (const auto& i : s) {
        os << i << " ";
    }
    os << "}";
    return os;
}


int main(int argc, char const *argv[]) {
    int A, B;
    cin >> A >> B;
    if (A+B < 10) {
        cout << A+B << endl;
    } else {
        cout << "error" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const int INF = 2000000000;
using namespace std;

int main(){
    string s;
    cin >> s;
    rep(i,s.size()){
        if(s[i] == ','){
            cout << ' ';
        }else{
            cout << s[i];
        }
    }
    cout << endl;
}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

const int dx[] = {0, -1, 1, 0};
const int dy[] = {-1, 0, 0, 1};

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int N;
    cin >> N;
    double res = 0;

    vector<P> v(N);
    vector<int> per(N);
    for(int i = 0; i < N; ++i) {
        cin >> v[i].F >> v[i].S;
        per[i] = i;
    }

    int cnt = 0;
    do {
        ++cnt;
        double sum = 0;
        for(int i = 1; i < N; ++i) {
            pair<double, double> x, y;
            x = MP(v[per[i - 1]].F, v[per[i - 1]].S);
            y = MP(v[per[i]].F, v[per[i]].S);
            sum += sqrt((x.F - y.F) * (x.F - y.F) + (x.S - y.S) * (x.S - y.S));
        }
        res += sum;
    } while(next_permutation(all(per)));

    printf("%.10lf\n", res / cnt);

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
using namespace std;
 
int main(){
    int r,c,sum,total_sum = 0;
    scanf("%d %d",&r,&c);
    int table[r+1][c+1];
 
    for(int i = 0; i < r+1; i++){
        for(int j = 0; j < c+1; j++){
            table[i][j] = 0;
        }
    }
 
    for(int i = 0; i < r; i++){
        sum = 0;
        for(int j = 0; j < c; j++){
            scanf("%d",&table[i][j]);
            sum += table[i][j];
            table[r][j] += table[i][j];
        }
        table[i][c] = sum;
        total_sum += sum;
    }
    table[r][c] = total_sum;
 
    for(int i = 0; i < r+1; i++){
        for(int j = 0; j < c; j++){
            printf("%d ",table[i][j]);
        }
        printf("%d\n",table[i][c]);
    }
}


Measured memory_bytes: 2732
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      int c = sc.nextInt();
      int x = sc.nextInt();

      int cnt = 0;
      for(int i = 0; i <= a; i++) {
        for(int j = 0; j <= b; j++) {
           int diff = x - 500 * i - 100 * j;
           if(diff >= 0 && diff % 50 == 0 && diff / 50 <= c)
            cnt++;
        }
      }
      System.out.println(cnt);
  }
}

Measured memory_bytes: 22736
K=int(input())
N=0 #現在のルンルン数の数
lun=list(range(1,10))
while 1:
    N+=1
    x=lun[N-1]
    if x%10 != 0:
        lun.append(10*x+x%10-1)
    lun.append(10*x+x%10)
    if x%10 != 9:
        lun.append(10*x+x%10+1)
    if N==K:
        break
print(lun[N-1])


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

/*
int 2の32乗 -1        10の9乗
long long 2の63乗 -1  10の18乗
*/

int main() {
  int N, K;
  cin >> N >> K;
  ll ans = K;
  rep(i, 0, N - 1) ans *= K - 1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3572
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto dg = readln.split.to!(long[]);
    auto D = dg[0];
    auto G = dg[1];
    long[] ps, cs;
    foreach (_; 0..D) {
        auto pc = readln.split.to!(long[]);
        ps ~= pc[0];
        cs ~= pc[1];
    }
    long r = long.max;
    foreach (x; 0..(1<<D)) {
        long g, rr;
        foreach (i; 0..D) if (x & (1<<i)) {
            rr += ps[i];
            g += 100*(i+1)*ps[i] + cs[i];
        }
        foreach_reverse (i; 0..D) if (!(x & (1<<i))) {
            foreach (_; 0..ps[i]) {
                if (g >= G) break;
                rr += 1;
                g += 100*(i+1);
            }
        }
        if (g >= G) {
            r = min(r, rr);
        }
    }
    writeln(r);
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

using namespace std;

int main(){
  int A,B,N;
  cin >> N >> A >> B;
  int ans = 0;
  for(int i = 1; i <= N; i++){
    int sumDigit = i/10000 + (i/1000)%10 + (i/100)%10 + (i/10)%10 + (i)%10 ;
    if(A <= sumDigit && sumDigit <= B) ans += i;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

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; }
const int INF = (1 << 29);
const long long INFL = (1LL<<60);
const double eps = (1e-9);

vector<int> a = {1, 3, 5, 7, 8, 10, 12};
vector<int> b = {4, 6, 9, 11};
vector<int> c = {2};

int main(int argc, char* argv[])
{
  int x, y;
  cin >> x >> y;

  if ((EXIST(a, x) && EXIST(a, y)) || (EXIST(b, x) && EXIST(b, y)) ||
      (EXIST(c, x) && EXIST(c, y))) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,D ;
    cin >> A >> B >> C >> D ;
  if (A+B > C+D)
    cout << "Left" << endl;
  else if (A+B == C+D)
    cout << "Balanced" << endl;
  else
    cout << "Right" << endl;
}

Measured memory_bytes: 256
//By Zank100
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define din(t) long long t;cin>>t;
#define in(t) cin>>t;
int main() 
{
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	din(A);din(B);
	ll ans;
	if(B>A)
    {
        ll a=A-1;
        if(A==2)
        {
    		ans=B-1;
        }else if(B%a<=1)
        {
            ans=B/a;
        }else{
            ans=B/a;
            ans++;
        }
    }else if(B==1){
        ans=0;
    }else{
        ans=1;
    }
	cout<<ans<<endl;
}

Measured memory_bytes: 256
import numpy as np

def spaceinput():
    return list(map(int,input().split(" ")))
    
N=int(input())
a=np.array(spaceinput())


cnt_minus=0
cnt_zero=0
for sa in a:
    if sa==0:
        cnt_zero+=1
    if sa<0:
        cnt_minus+=1


a_abs=np.abs(a)
suma=np.sum(a_abs)


if cnt_minus%2==0 or cnt_zero>0:
    res=suma
else:
    res=suma-2*np.min(a_abs)

print(res)


Measured memory_bytes: 23360
N, X, Y = map(int, input().split())
dis_comb = [0]*N

for i in range(1, N):
    for j in range(i+1, N+1):
        dis_comb[min(abs(i-j), abs(X-i)+1+abs(Y-j))] += 1

for i in range(1, N):
    print(dis_comb[i])


Measured memory_bytes: 46044
#include <bits/stdc++.h>
using namespace std;
#define push_back pb
#define make_pair mp
using ll =  long long;
const int INF = 0x3f3f3f3f;

int A, B, T;

void solve()
{
    cout << (T/A)*B << "\n";
}

int main()
{
	cin >> A >> B >> T;
	solve();
	return 0;
}

Measured memory_bytes: 256
# C
import collections
n, k = map(int, input().split())
a = [int(i) for i in input().split()]
unique_a = list(set(a))
process_count = len(unique_a) - k
c = collections.Counter(a)
values, counts = zip(*c.most_common())

counts = list(counts)
counts.sort()
ans = 0

for i in range(process_count):
    ans += counts[i]
print(ans)

Measured memory_bytes: 61180
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep0(i, n) for (int i = 0; i <= (n); i++)
#define rep2(a, n) for (int i = a; i < (n); i++)
#define rep3(i, a, n) for (int i = a; i < (n); i++)
#define maxs(x, y) (x = max(x, y))
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;
const int NUM = 100010;
int dp[NUM][3];

int main(void) {
  int n;
  cin >> n;
  rep(i, n) {
    vector<int> a(3);
    rep(i, 3) cin >> a[i];
    rep(j, 3) rep(k, 3) if (j != k) { maxs(dp[i + 1][j], dp[i][k] + a[j]); }
  }
  int ans = 0;
  rep(i, 3) maxs(ans, dp[n][i]);
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 4772
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
int n;
ll X;
ll x[100001];
ll gcd( ll a, ll b )
{
	// 引数に０がある場合は０を返す
    if(b==0){
        return a;
    }
    else{
        return gcd(b,a%b);
    }
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n>>X;
    for(int i=0;i<n;i++) {
        cin>>x[i];
    }
    if(n==1) {
        cout<<abs(x[0]-X)<<"\n";
        return 0;
    }
    ll a[n];
    for(int i=0;i<n;i++){
        a[i]=abs(x[i]-X);
    }
    sort(a,a+n);

    ll ans=gcd(a[0],a[1]);
    for(int i=2;i<n;i++){
        ans=gcd(ans,a[i]);
    }
    cout << ans<< "\n";
}

Measured memory_bytes: 1792
N = int(input())
A = list(map(int,input().split()))

res = 0
while 1:
    judge = 1
    for i in range(N):
        x = A[i]
        if x%2 == 0:
            A[i] = x//2
        else:
            judge = 0
            break
    if judge:
        res += 1
    else:
        break
print(res)

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

using namespace std;

int main(){
  string str;
  while(getline(cin, str)){
    if(str == "END OF INPUT") break;
    int idx = 0;
    while(idx < str.size()){
      int cnt = 0;
      while(idx < str.size() && str[idx++]!=' ') cnt++;
      cout << cnt;
    }
    cout << endl;
  }
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;


int main()
{
	int month[12];

	month[0] = 0, month[1] = 1, month[2] = 0, month[3] = 2, month[4] = 0, month[5] = 2, month[6] = 0, month[7] = 0, month[8] = 2, month[9] = 0, month[10] = 2, month[11] = 0;

	int x, y;
	cin >> x >> y;
	if (month[x-1] == month[y-1]) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int max = 1;
    for (int i=1; i<=N/2; i++) {
      if (i * i > N) {
        break;
      } else {
        max = Math.max(max, i * i);
      }
    }
    System.out.println(max);
  }
}

Measured memory_bytes: 23124
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <cstring>
#include <queue>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cstdlib>
#include <sstream>
#include <bitset>

using namespace std;

using ll = long long;
using Vec = vector<ll>;
using P = pair<ll, ll>;
using VecP = vector<P>;
#define rep(i, n) for(ll i=0;i<(n);i++)
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

//static const ll MOD = 1000000007;
//static const ll INF = 1000000000;
//#define PI 3.14159265359

int main() {
    // input
    ll N, K;
    cin >> N >> K;
    Vec A(N);
    rep(i, N) {
        cin >> A[i];
    }

    // process
    rep(i, N - K) {
        ll x = A[i];
        ll y = A[K + i];
        if (x >= y) {
            cout << "No" << endl;
        } else {
            cout << "Yes" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 4412
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = LLONG_MAX;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */

int main() {
    int w;
    cin >> w;
    rep(i, w/105+1) {
        rep(j, w/104+1) {
            rep(k, w/103+1) {
                rep(l,w/102+1) {
                    rep(m,w/101+1) {
                        rep(n,w/100+1) {
                            int ans = 105*i+104*j+103*k+102*l+101*m+100*n;
                            if(ans==w){
                                cout << 1 << endl;
                                return 0;
                            }
                            if(ans>w)break;
                        }
                    }
                }
            }
        }
    }
    cout << 0 << endl;
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, s, n) for (int i = s; i < (int)(n); i++)
#define inpv(i, n, v) rep(i,n) do {int tmp; cin>>tmp; v.push_back(tmp);} while(0)
#define outv(i,n,v) rep(i,n) cout << v[i] << endl

void Main() {
    char a,b,c;
    cin >> a >> b >> c;
    if (a == b && b == c) {
        cout << "No";
    } else cout << "Yes";
    /*
    vector<int> v;
    inpv(i,n,v);
    */
}


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

Measured memory_bytes: 256
import java.util.Scanner;

// 9
class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] x = new int[N];
		for(int i = 0; i < N; i++)
			x[i] = sc.nextInt();
		
		int ans = 0;
		for (int i = 0; i < x.length; i++) {
			if(x[i] <= Math.abs(K - x[i])) ans += x[i] * 2;
			else ans += Math.abs(K - x[i]) * 2;
		}
		
		System.out.println(ans);
	}

}


Measured memory_bytes: 35848
#include <bits/stdc++.h>
#define C(a, b) memcpy((a) + 1, (b) + 1, n << 2)
#define U(x) using permutation::x

const int N = 100054;
typedef int perm[N], *pperm;
typedef std::initializer_list <pperm> il;

int n, K;

namespace permutation {
	perm buf[2], I, U, F;
	pperm cur = *buf, nxt = buf[1];
	int stamp = 0;

	void init() {std::iota(I + 1, I + (n + 1), 1);}
	void read(pperm a) {for (int i = 1; i <= n; ++i) scanf("%d", a + i);}
	void print(pperm a) {for (int i = 1; i <= n; ++i) printf("%d%c", a[i], i == n ? 10 : 32);}
	void mul(pperm a, pperm b, pperm c) {for (int i = 1; i <= n; ++i) a[i] = b[c[i]];}
	void inv(pperm a, pperm b) {for (int i = 1; i <= n; ++i) a[b[i]] = i;}
	void multiply(pperm a, const il &fs) {C(nxt, I); for (pperm g : fs) std::swap(cur, nxt), mul(nxt, cur, g); C(a, nxt);}
	void pow(pperm a, pperm b, int K) {
		int i, j, c; ++stamp;
		for (i = 1; i <= n; ++i) if (U[i] != stamp) {
			for (c = 0, j = i; U[j] != stamp; j = b[j], ++c) U[j] = stamp, F[c] = j;
			for (j = 0; j < c; ++j) a[F[j]] = F[(j + K) % c];
		}
	}
}

U(init); U(read); U(print); U(mul); U(inv); U(multiply); U(pow);

perm g[3], A, B, BabA, AbaB, L, M, R, ans;

int main() {
	perm &a = *g, &b = g[1], &c = g[2];
	scanf("%d%d", &n, &K), init();
	read(a), read(b), inv(A, a), inv(B, b), mul(c, b, A);
	if (--K < 2) return print(g[K]), 0;
	multiply(BabA, {B, a, b, A}), multiply(AbaB, {A, b, a, B});
	pow(L, BabA, (K - 2) / 6), pow(R, AbaB, (K - 2) / 6);
	switch ((K - 2) % 6) {
		case 0: multiply(M, {}); break;
		case 1: multiply(M, {B}); break;
		case 2: multiply(M, {B, a, B}); break;
		case 3: multiply(M, {B, a, a, B}); break;
		case 4: multiply(M, {B, a, b, a, B}); break;
		case 5: multiply(M, {B, a, b, A, b, a, B}); break;
	}
	multiply(ans, {c, L, M, R}), print(ans);
	return 0;
}
/*
a = 4 5 1 2 3	A = 3 4 5 1 2
b = 3 2 1 5 4	B = 3 2 1 5 4
c = 1 5 4 3 2	C = 1 5 4 3 2
d = 4 5 1 2 3	D = 3 4 5 1 2
e = 4 3 2 1 5	E = 4 3 2 1 5

 2 c = b A = b A|
 3 d = c B = b A|B
 4 e = d C = b A|B|a B
 5 f = e D = b A|B a|a B
 6 g = f E = b A|B a|b|a B
 7 h = g F = b A|B a b|A|b a B
 8 i = h G = b A|B a b A|A b a B
 9 j = i H = b A|B a b A|B|A b a B
*/

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

int n;

int ans[10009];

int main(){
	scanf("%d",&n);
	for(int x=1;x<=100;++x){
		for(int y=1;y<=100;++y){
			for(int z=1;z<=100;++z){
				int t=x*x+y*y+z*z+x*y+y*z+z*x;
				if(t<=n)ans[t]++;
			}
		}
	}
	for(int i=1;i<=n;++i)printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 3824
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::cmp::max;

fn main() {
    input! {
        n: usize, m: usize, k: u32,
        a: [u32; n],
        b: [u32; m],
    };
    // 初期状態を設定する. 最初aの山からは0個. bの山からはとれるだけとるものとする
    let mut x = 0; // aの山からいくつとるか
    let mut acost = 0;
    let mut y = 0; // bの山からいくつとるか
    let mut bcost = 0;
    for i in 0..m {
        // もし読んでも最大コストに収まるなら読む
        if bcost + b[i] <= k {
            bcost += b[i];
            y += 1;
        } else {
            break;
        }
    }
    let mut ans = x + y;

    // aの山から読む個数を一つずつふやしていく
    for i in 0..n {
        // 一つ読むとこういうふうに変化する
        x += 1;
        acost += a[i];
        // もし最大コストを超えていた場合は, 超えなくなるまでbの山を減らす. bの山から一冊も読んでいない場合はそれ以上減らせない
        while acost + bcost > k && y > 0 {
            bcost -= b[y - 1];
            y -= 1;
        }
        // 可能な限りyを減らしてもまだコストを超える場合はもう無理なのであきらめる
        if acost + bcost > k {
            break;
        } else {
            ans = max(ans, x + y);
        }
    }
    println!("{}", ans);
}


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

#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    int a[n],b[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    if(n%2==0){
        int m=n/2;
        b[m]=a[0];
        int num=1;
        for(int i=m-1;i>=0;i--){
            b[i]=a[num];
            num+=2;
        }
        num=2;
        for(int i=m+1;i<n;i++){
            b[i]=a[num];
            num+=2;
        }
    }
    else{
        int m=(n-1)/2;
        b[m]=a[0];
        int num=2;
        for(int i=m-1;i>=0;i--){
            b[i]=a[num];
            num+=2;
        }
        num=1;
        for(int i=m+1;i<n;i++){
            b[i]=a[num];
            num+=2;
        }
    }
    for(int i=0;i<n-1;i++){
        cout <<b[i]<<" ";
    }
    cout <<b[n-1]<<endl;
    return 0;
}



Measured memory_bytes: 3712
N, M = map(int, input().split())
p = list(map(int, input().split()))
xy = [list(map(int, input().split())) for _ in range(M)]

parent = list(range(N))

def root(arg):
    if arg == parent[arg]:
        return arg
    else:
        ret = root(parent[arg])
        parent[arg] = ret
        return ret

def unite(src, dst):
    r_src = root(src)
    r_dst = root(dst)
    #
    if r_src != r_dst:
        parent[r_src] = r_dst

for xi, yi in xy:
    unite(xi - 1, yi - 1)

ans = 0
for i, pi in enumerate(p):
    if root(i) == root(pi - 1):
        ans += 1

print(ans)


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

int main() {
  int N;
  long long sum =0;
  cin >> N;
  for(int i=1;i<N+1;i++){
    if(i%3==0 || i%5==0) continue;
    sum += i;
  }
  cout << sum;
}

Measured memory_bytes: 3636
n, k, q = map(int, input().split())
a = list(map(int, input().split()))

if q == 1:
    print(0)
    exit()

ans = 10 ** 10
for i, y in enumerate(a):
    li = []
    l = 0
    cnd = []
    for j, x in enumerate(a + [-1]):
        if i == j:
            continue
        if x < y:
            if l - k + 1 >= 0:
                li.sort()
                cnd += li[:l-k+1]
            li = []
            l = 0
        else:
            li.append(x)
            l += 1

    if len(cnd) >= q - 1:
        cnd.sort()
        sub = cnd[q-2] - y
        ans = min(ans, sub)

print(ans)


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

class Program
{
    static void Main(string[] args)
    {
        new Program().Calc();
    }

    Scanner cin;

    public Program() { }

    void Calc()
    {
        cin = new Scanner();

        string s = cin.next();

        bool flag1 = false;
        bool flag2 = false;
        bool flag3 = true;

        flag1 = (s[0] == 'A');

        for (int i = 1; i < s.Length; ++i)
            //for (int i = 2; i <= s.Length - 2; ++i)
        {
            if (!flag2 && 2 <= i && i <= s.Length - 2 && s[i] == 'C')
            {
                flag2 = true;
            }
            else if (!('a' <= s[i] && s[i] <= 'z'))
            {
                flag3 = false;
            }
        }

        Console.WriteLine((flag1 && flag2 && flag3)? "AC" : "WA");
    }
}

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const double EPS = 1e-10;
const int INF = 2147483647;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

int h, w;
char s[55][55];

int main()
{
	cin >> h >> w;
	int a[2][8] = { {1,1,-1,-1,0,0,1,-1},{1,-1,1,-1,1,-1,0,0} };

	for(int i=0;i<h;i++)
		for (int j = 0;j < w;j++) {
			cin >> s[i][j];
		}

	for (int i = 0;i<h;i++)
		for (int j = 0;j < w;j++) {

			if (s[i][j] != '#') {
				int temp = 0;
				for (int k = 0;k < 8;k++) {
					int newi = i + a[0][k];
					int newj = j + a[1][k];
					if (0 <= newi && newi < h && newj >= 0 && newj < w && s[newi][newj] == '#') temp++;
				}
				s[i][j] = temp + '0';
			}			
		}

	for (int i = 0;i < h;i++) {
		for (int j = 0;j < w;j++) {
			cout << s[i][j];
		}
		cout << endl;
	}


	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {

	public static void main(String[] args) throws IOException{
		BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
		String str =br.readLine();
		String[] stra = str.split(" ");
		
		int a = Integer.parseInt(stra[0]);
		int b = Integer.parseInt(stra[1]);
		double f= (double)a/b;
		int d = a/b;
		int r = a%b;
		System.out.printf("%d %d %.7f",d,r,f);
	}

}

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

int main() {
	string S;
	cin >> S;
	int ans = 753;
	for (int i = 0; i <= (int)S.size() - 3; i++) {
		int tmp = stoi(S.substr(i, 3));
		if (ans > abs(753 - tmp)) {
			ans = abs(753 - tmp);
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstring>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

typedef long long ll;

int main(){
    int a,b;
    cin >> a  >> b;
    if(a==b){
        cout << "a == b" << endl;
    }
    else if(a<b){
        cout << "a < b" << endl;
    }else
        cout << "a > b" << endl;
    return 0;
}

Measured memory_bytes: 1160
// 　　＿＿
// 　／　<＠ﾌ
//  ｜(ﾉﾉハ))
//  ﾉ从ﾟヮﾟ从
// 　ﾉ｜ｿﾉГ|つ author:hotarunx
// 〈_ﾉ^^^ヽ|
// 　~~tｧtｧ~
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long
constexpr int ceil(int a, int b) { return (a + b - 1) / b; }

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

    int n, x, t;
    cin >> n >> x >> t;

    const int ans = ceil(n, x) * t;
    cout << ans << endl;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main(){
	ll a, b, c;
    cin >> a >> b >> c;
    if(4*a*b < (c-a-b)*(c-a-b) && c-a-b > 0){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
//
// Created by Myabu on 2020/01/07.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <numeric>

using namespace std;
bool pair_compare_by_second(pair<int, int> left, pair<int, int> right) {
    if(left.second != right.second){
        return left.second > right.second;
    }else{
        return left.first > right.first;
    }
}
int main(void){
    int n;
    cin>>n;

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

    vector<pair<int, int> > zero_count;
    vector<pair<int, int> > one_count;

    map<int, int> zero_map;
    map<int, int> one_map;

    for (int i = 0; i < n; ++i) {
        if(i%2==0){
            zero_map[v[i]] = zero_map[v[i]] + 1;
        }else{
            one_map[v[i]] = one_map[v[i]] + 1;
        }
    }

    for (auto itr : zero_map) {
        zero_count.push_back(make_pair(itr.first, itr.second));
    }

    for (auto itr : one_map) {
        one_count.push_back(make_pair(itr.first, itr.second));
    }

    zero_count.push_back(make_pair(-10,-10));
    one_count.push_back(make_pair(-10,-10));
    sort(zero_count.begin(), zero_count.end(), pair_compare_by_second);
    sort(one_count.begin(), one_count.end(), pair_compare_by_second);

    int zero, one;

    if(zero_count[0].first  == one_count[0].first){
        zero = zero_count[0].first;
        one = one_count[1].first;
        int temp_1 = 0;
        for (int i = 0; i < n; ++i) {
            if(i%2==0){
                if(zero != v[i]){
                    temp_1 ++;
                }
            }else{
                if(one != v[i]){
                    temp_1 ++;
                }
            }
        }
        
        zero = zero_count[1].first;
        one = one_count[0].first;
        int temp_2 = 0;
        for (int i = 0; i < n; ++i) {
            if (i % 2 == 0) {
                if (zero != v[i]) {
                    temp_2++;
                }
            } else {
                if (one != v[i]) {
                    temp_2++;
                }
            }
        }
        
        cout<<min(temp_1,temp_2)<<endl;
        return 0;
        
    }else{
        zero = zero_count[0].first;
        one = one_count[0].first;
    }
//    cout<<zero<<one<<endl;
    int count = 0;
    for (int i = 0; i < n; ++i) {
        if (i % 2 == 0) {
            if (zero != v[i]) {
                count++;
            }
        } else {
            if (one != v[i]) {
                count++;
            }
        }
    }


    cout<<count<<endl;

    return 0;
}

Measured memory_bytes: 6520
#include <iostream>
    #include <algorithm>
    #include <utility>
    #include <map>
    #include <vector>
    #include <cstring>
    #include <climits>
    #include <queue>
    #include <cmath>
    #include <iomanip>
    #include <set>
    #include <bitset>
     
    using namespace std;
     
    typedef long long LL;
    typedef pair<int, int> pii;
    typedef pair<int, pii> tmp;
    typedef pair<int, tmp> state;
     
    int H, W, K;
    int sx, sy, ex, ey;
    // U, R, D, L
    int dx[4] = {-1, 0, 1, 0};
    int dy[4] = {0, 1, 0, -1};
    priority_queue<state, vector<state>, greater<state> > pq;
     
    int main() {
      scanf("%d%d%d", &H, &W, &K);
      scanf("%d%d%d%d", &sx, &sy, &ex, &ey);
      sx--; sy--; ex--; ey--;
      vector<vector<char> > mat(H, vector<char>(W, '.'));
      vector<vector<int> > dist(H, vector<int>(W, -1));
      for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
          scanf(" %c", &mat[i][j]);
        }
      }
     
      dist[sx][sy] = 0;
      pq.push(state(0, tmp(-1, pii(sx, sy))));
      while (pq.size()) {
        int d = pq.top().first;
        int prv = pq.top().second.first;
        int x = pq.top().second.second.first, y = pq.top().second.second.second;
        pq.pop();
        if (d != dist[x][y]) continue;
        if (x == ex && y == ey) {
          break;
        }
        for (int i = 0; i < 4; i++) {
          if ((i + 2) % 4 == prv || i == prv) continue;
          for (int k = 1; k <= max(H, W); k++) {
            int nx = x + dx[i] * k, ny = y + dy[i] * k;
            if (nx < 0 || ny < 0 || nx >= H || ny >= W) break;
            if (mat[nx][ny] == '@') break;
            int nd = d + (k + K - 1) / K;
            if (dist[nx][ny] == -1 || dist[nx][ny] > nd) {
              dist[nx][ny] = nd;
              pq.push(state(nd, tmp(i, pii(nx, ny))));
            } 
          }
        }
      }
      printf("%d\n", dist[ex][ey]);
    }

Measured memory_bytes: 28512
class WeightedUnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
        self.weight = [0] * (n+1)

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            y = self.find(self.par[x])
            self.weight[x] += self.weight[self.par[x]]
            self.par[x] = y
            return y

    def union(self, x, y, w):
        rx = self.find(x)
        ry = self.find(y)
        if self.rank[rx] < self.rank[ry]:
            self.par[rx] = ry
            self.weight[rx] = w - self.weight[x] + self.weight[y]
        else:
            self.par[ry] = rx
            self.weight[ry] = -w - self.weight[y] + self.weight[x]
            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1

    def is_same(self, x, y):
        return self.find(x) == self.find(y)

    def diff(self, x, y):
        return self.weight[x] - self.weight[y]


N, M = map(int, input().split())

wuf = WeightedUnionFind(N+1)

ans = 'Yes'
for i in range(M):
    L, R, D = map(int, input().split())

    if wuf.is_same(L, R):
        if wuf.diff(L, R) != D:
            ans = 'No'
            break
    else:
        wuf.union(L, R, D)

print(ans)

Measured memory_bytes: 84156
//c-1.cpp
#include<iostream>
using namespace std;

int main(){
    int n,k,q,i;
    cin>>n>>k>>q;
    int nhai[100000];
    int qhai[100000] = {}; // reset all 0
    for(i=0;i<n;i++){
        nhai[i] = k-q; // nhai reset all k 
    }
    for(i=0;i<q;i++){
        cin>>k;  //もうkは使わないから、変数の使い回し
        qhai[k-1] += 1; //input end
    }
    for(i=0;i<n;i++){
        nhai[i] += qhai[i];
    } // operations end
    for(i=0;i<n;i++){
        if(nhai[i] <= 0){
            cout<<"No"<<endl;
        }else{
            cout<<"Yes"<<endl;
        }
    }
}

Measured memory_bytes: 1408
w = gets.to_i
n = gets.to_i

array = (1..w).map{|i| i}
n.times do
  a1, a2 = gets.split(",").map(&:to_i)
  array[a1 - 1], array[a2 - 1] = array[a2 - 1], array[a1 - 1]
end

array.each do |i|
  puts i
end

Measured memory_bytes: 8596
#include <iostream>
#include <vector>
#include <array>
#include <cmath>
#include <string>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <limits>  //std::numeric_limits<int>::max(), min()

int main (void) {

  int r, D, x; std::cin >> r >> D >> x;

  int nx = x;
  for(int i=0; i<10; i++){
    nx = r*nx-D;
    std::cout << nx << std::endl;
  }

  return 0;
}

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

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

Measured memory_bytes: 3596
// #include <bits/stdc++.h>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <map>
#include <math.h>
#include <algorithm> // std::sort, std::min, std::next_permutation, std::lower_bound
#include <iomanip> // std::setprecision
#include <cmath> // std::ceil
#include <numeric> // std::gcd, std::lcm
#include <limits> // std::numeric_limits<long int>::max()
#include <unordered_map>
#include <map>
#include <cmath> // std::atan2

using namespace std;
typedef long long ll;
#define INF 1999999999
#define MODA 1000000007 
#define rep(i,n) for (long long i = 0; i < (n); ++i)

int main() {
  ll H, W;
  cin >> H >> W;
  vector<string> S(H);
  rep(i,H) cin >> S[i];

  vector<vector<ll> > latcount(H);
  rep(i, H) latcount[i].resize(W, 0);
  rep(i, H) {
    ll left = -1;
    rep(j, W + 1) {
      // j == W needs to be judged first so that j do not refer outside of range, S[i][W].
      if (j == W || S[i][j] == '#') {
        if (left != -1) {
          for (int k = left; k < j; ++k) {
            latcount[i][k] = j - left;
            // cerr << latcount[i][k] << endl;
          }
          left = -1;
        }
      }
      else if(S[i][j] == '.') {
        if (left == -1) left = j;
        // cerr << i <<" "<< j <<" "<< left << endl;
      }
    }
  }  

  vector<vector<ll> > loncount(H);
  rep(i, H) loncount[i].resize(W, 0);
  rep(j, W) {
    ll up = -1;
    rep(i, H + 1) {      
      // i == H needs to be judged first so that i do not refer outside of range, S[H][j].
      if ( i == H || S[i][j] == '#') {
        if (up != -1) {
          for (int k = up; k < i; ++k) {
            loncount[k][j] = i - up;
          }
          up = -1;
        }
      }
      else if(S[i][j] == '.') {
        if (up == -1) up = i;
      }
    }
  }  

  ll maxcount = 0;
  rep(i, H) {
    rep(j, W) {
      maxcount = max(maxcount, latcount[i][j] + loncount[i][j] - 1);
    }
  }
  cout << maxcount << endl;
  return 0;
}


Measured memory_bytes: 68992
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <climits>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define ye cout<<"YES";
#define no cout<<"NO";
#define ln cout<<"\n";
// cout<<"Case #"<<ts<<": “;
//priority_queue < pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> pq;


using namespace std;

ll mod(ll x, ll m) {
	return (x % m + m) % m;
}

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

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ll t = 1, r, n, a, d, c, b, x, y, sum, cnt, i, j, k, m, l, q, maxx, minn, temp, ans, flag, g, ts;
	ll mod = 1000000007;
	char ch, chh;
	double dans;
	string str, ttr;

	//cin >> t;


	for (ts = 1; ts <= t; ts++)
	{
		flag = 0; sum = 0; cnt = 0; ans = 0; k = 0; maxx = 0; minn = 0; a = 0; b = 0; temp = 0;

		cin >> n;
		ll arr[n];

		ll brr[1000001];

		memset(brr, 0, sizeof(brr));

		for (i = 0; i < n; i++)
		{
			cin >> arr[i];
			brr[arr[i]] = 1;
		}


		sort(arr, arr + n);

		for (i = 0; i < n; i++)
		{
			flag = 0;
			if (i + 1 < n && arr[i] == arr[i + 1]) {
				while ((i + 1) < n && arr[i] == arr[i + 1])
				{
					i++;
				}
				continue;
			}

			for (j = 1; j <= sqrt(arr[i]); j++)
			{
				if (arr[i] % j == 0)
				{
					a = arr[i] / j;

					if (brr[j] == 1 && j != arr[i])
					{
						flag = 1;
						break;
					}
					if (a != arr[i])
					{
						if (brr[a] == 1)
						{
							flag = 1;
							break;
						}
					}

				}
			}
			if (flag == 0)
				cnt++;
		}



		cout << cnt;


		ln
	}
	return 0;
}


Measured memory_bytes: 13052
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define REP(i,a,b) for (auto i = a; i != b; i++)
#define ll long long int
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second
#define pb push_back
#define SQ(a) (a)*(a)
 
using namespace std;


int main()
{
    std::ios::sync_with_stdio(false);
    int T = 1;
    //cin>>T;
    for(int t = 1;t<=T;t++)
    {
        string s;
        cin>>s;
        if(s[0] == 'R' && s[1] == 'R'&& s[2] == 'R')
        	cout<<3<<endl;
        else if((s[0] == 'R' && s[1] == 'R') || (s[1] == 'R' && s[2] == 'R'))
        	cout<<2<<endl;
        else if(s[0] == 'R' || s[1] == 'R' || s[2] == 'R')
        	cout<<1<<endl;
        else
        	cout<<0<<endl;
        
    }

    return 0;
}


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

int main() {
  char s[101];
  int k;

  cin >> k;
  cin >> s;

  int len = strlen(s);
  if (len <= k) {
    rep(i, len) { cout << s[i]; }
    cout << endl;
  } else {
    rep(i, k) { cout << s[i]; }
    cout << "..." << endl;
  }

  return 0;
}

Measured memory_bytes: 3636
a, b, c = [int(x) for x in raw_input().split(" ")]
list =[a,b,c]
list_2 = []

for x in range(len(list)):
    mini = min(list)
    list_2.append(mini)
    list.remove(mini)

for x in range(0, len(list_2)):
    a = list_2[x]

    if x == 0:
        req = str(a) + " "
    else:
        req += str(a) + " "

q = req.rstrip()
print(q)

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

namespace EXA2019B
{
    class MainClass
    {

        static int[] s;
        static string n;

        public static void Main(string[] args)
        {
            s = Array.ConvertAll(Console.ReadLine().Split().ToArray(), int.Parse);
            n = Console.ReadLine();
            int rcnt = 0; 
            int bcnt = 0;
            for(int i = 0; i < s[0]; i++)
            {
                if (n[i] == 'R')
                {
                    rcnt++;
                }
                else
                {
                    bcnt++;
                }
            }

            string ans = "";
            if (rcnt > bcnt)
            {
                ans = "Yes";
            }
            else
            {
                ans = "No";
            }
            Console.WriteLine(ans);



        }
    }
}


Measured memory_bytes: 13268
from sys import stdin, setrecursionlimit
from collections import Counter, deque, defaultdict
from math import floor, ceil
from bisect import bisect_left
from random import randint
from itertools import combinations
setrecursionlimit(100000)

INF = int(1e10)
MOD = int(1e9 + 7)

def solve(N, X, Y):
    # xi + yiのmax, minとxi - yiのmax, minを使う
    xyp = [X[i] + Y[i] for i in range(N)]
    xym = [X[i] - Y[i] for i in range(N)]
    ans1 = max(xyp) - min(xyp)
    ans2 = max(xym) - min(xym)
    ans = max(ans1, ans2)
    return ans

def main():
    from builtins import int, map
    N = int(input())
    X, Y = [], []
    for _ in range(N):
        xi, yi = map(int, input().split())
        X.append(xi)
        Y.append(yi)
    print(solve(N, X, Y))

if __name__ == '__main__':
    main()


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

using namespace std;
constexpr int64_t MOD = 1'000'000'007;
constexpr int     MAX =     2'000'005;

int64_t fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
int64_t COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(void) {
    int K;
    string S;
    cin >> K >> S;

    COMinit();
    int N = S.size();
    int T = K + N;
    int64_t ans = 0;
    int64_t tmp = 1;
    for(int i=T; i>=N; i--) {
        ans += COM(T, i) * tmp;
        ans %= MOD;
        tmp *= 25;
        tmp %= MOD;
    }

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


Measured memory_bytes: 51208