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

int modTable[2001][2001];
long long m = 1000000007;
int t;
int nCrM(int n, int r)
{
    if(n == r || r == 0)
        return 1;
    else if((t = modTable[n][r]) != 0)
        return t;
        
    t = modTable[n][r] = modTable[n][n-r] = (nCrM(n-1,r)%m + nCrM(n-1,r-1)%m)%m;
    return t;
}

int main()
{
    int n, k;
    cin >> n >> k;
    int i = 1;
    long long mod1=0,mod2=0,mod3=0,mod4=0;
    long long ans;
    while(i <= k)
    {
        if(k==1)
            mod1 = 1;
        else
            mod1 = nCrM(k-1,i-1);
        
        if(n-k-1 > 0)
        {
            if(i-2 >= 0 && n-k-1 >= i-2)
                mod2 = nCrM(n-k-1,i-2);

            if(i-1 >= 0 && n-k-1 >= i-1)
                mod3 = 2*nCrM(n-k-1,i-1);
                
            if(i >= 0 && n-k-1 >= i)
                mod4 = nCrM(n-k-1,i);
        }
        else if(n-k == 1)
        {
            if(i == 1)
                mod3 = 2;
            else if(i == 2)
                mod2 = 1;
        }
        else if(n-k == 0)
        {
            if(i == 1)
                mod2 = 1;
        }
        
        ans = (mod1 * ((mod2+mod3+mod4)%m)) % m;
        cout << ans << endl;
        mod2 = mod3 = mod4 = 0;
        i++;
    }
    return 0;
}

Measured memory_bytes: 15104
import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int a[] = new int [n];
        long sum = 0;
        for(int i = 0;i < n;i++){
            a[i] = in.nextInt();
            sum = sum + a[i];
        }
        Arrays.sort(a);
        System.out.print(a[0]+ " "+a[a.length - 1]+" "+sum);
        System.out.println();
    }
}


Measured memory_bytes: 42092
#include<cmath>
#include<bits/stdc++.h>
#define MAX(a,b) (a>b? a:b)
#define MIN(a,b) (a>b? b:a)
#define rep(i,n) for(lint i=0;i<(lint)(n);i++)
#define repr(i,n) for(lint i=(lint)(n);i>0;--i)
#define reps(i,a,b) for(lint i=a;i<=(lint)(b);i++)
typedef long long lint;
typedef long double ld;
using namespace std;
const ld PI = acos(-1.0);

int main(){
	int K, N;
	string S;
	cin >> N >> S >> K;
	string A = S;
	rep(i,N) {
		if(A[i]!=A[K-1]) A[i] = '*';
	}
	cout << A << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		int M = sc.nextInt();
		long Lx = 0;
		long Rx = N + 1;
		
		for(int i = 0; i < M; i++) {
			long l = sc.nextInt();
			long r = sc.nextInt();
			Lx = Math.max(Lx, l);
			Rx = Math.min(Rx, r);
		}
		
		long ans = Rx - Lx + 1;
		
		if(ans >= 0) {
			System.out.println(ans);
		} else {
			System.out.println(0);
		}
		
	}
}


Measured memory_bytes: 64136
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    string X;
    cin >> X;
    stack<char> x;
    int ans = X.length();
    REP(i, X.length()){
        if(X[i] == 'S'){
            x.push('S');
            // ans--;
        }
        if(X[i] == 'T'){
            if(!x.empty() && x.top() == 'S'){
                ans -= 2;
                x.pop();
            }
        }
    }
    // ans += x.size();
    pr(ans);
}

Measured memory_bytes: 640
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int N; cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A[i], A[i]--;

    vector<bool> used(N);
    int p = 0, ans = 0, valid = true;
    while(p != 1) {
        used[p] = true;
        ans++;
        p = A[p];
        if(used[p]) {
            valid = false;
            break;
        }
    }

    if(valid) cout << ans << endl;
    else cout << -1 << endl;
    return 0;
}


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

int main() {
  int a,b,c;
  int d=0;
  cin >> a >> b >> c;
  for(int i=a;i<=b;i++){
    if(i%c==0){
      d++;
    }
  }
  cout << d << endl;
}

Measured memory_bytes: 3612
import * as fs from 'fs';

const input = fs.readFileSync('/dev/stdin', 'utf8');
//const input = fs.readFileSync('./input.txt', 'utf8');

_d(input);

function _d(input: string) {
  const [_n, _a, _q, ..._bc] = input.split('\n');
  _bc.splice(-1, 1); // 末尾の改行を取り除く

  const A = _a.split(' ').map(Number);

  const BC = _bc.map((b_c) => {
    const [b, c] = b_c.split(' ');
    return [parseInt(b), parseInt(c)] as const;
  });

  let sum = BigInt(A.reduce((p, c) => p + c, 0)); // 最大 10^10 なので桁溢れしない

  const map = new Map<number, number>();
  for (const a of A) {
    const count = map.get(a) || 0;
    map.set(a, count + 1);
  }

  for (const [B, C] of BC) {
    const countB = map.get(B);
    if (countB === undefined) {
      // その数字は１つもないので変化なし
      console.log(sum.toString());
      continue;
    }

    sum += BigInt(countB * (C - B));
    map.delete(B);
    const countC = map.get(C) || 0;
    map.set(C, countB + countC);
    console.log(sum.toString());
  }
}


Measured memory_bytes: 93896
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

std::string pad(int num)
{
    char buffer[4];
    std::snprintf(buffer, sizeof(buffer), "%03d", num);
    return buffer;
}

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

struct Hashing {
    ull seed, mod;
    vector <ull> hs, pw;

    Hashing(ull seed = 31, ull mod = 1000173169) :
        seed(seed),
        mod(mod) {}

    void build(int n, const string& s) {
        hs.assign(n + 1, 0);
        pw.assign(n + 1, 1);
        pw[0] = 1;

        for (int i = 1; i <= n; ++i)
            pw[i] = pw[i - 1] * seed % mod;
        for (int i = 1; i <= n; ++i)
            hs[i] = (hs[i - 1] * seed + s[i]) % mod;
    }

    ull hash(int l, int r) {
        return (hs[r] - hs[l - 1] * pw[r - l + 1] % mod + mod) % mod;
    }
};

int solve()
{
    int n;

    std::cin >> n;

    vector<int> v = fetch_vec<int>(n);

    if (n == 0)
        cout << 0 << endl;

    int min = v[0];
    int ans = 1;
    for (int i  = 1; i < n; ++i) {
        if (v[i] < min) {
            min = v[i];
        }

        if (v[i] == min) ++ans;
    }

    cout << ans << endl;

    return 0;
}

int main()
{
//    std::cout << solve() << std::endl;
    solve();

    return 0;
}

Measured memory_bytes: 1024
//abc075d
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
#include <functional>
#include <queue>
//#include <stack>
#include <climits>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
//#pragma comment(lib, "winmm.lib")
using namespace std;
typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> P;

int n,k;
int x[51];
int y[51];
ll min(ll a,ll b){
    if(a>b)return b;
    else return a;
}

int main() {
    cin >> n >> k;
    REP(i,n){
        cin >> x[i] >> y[i];
    }
    ll res = LONG_MAX;
    REP(a,n){
        REP(b,n){
            REP(c,n){
                REP(d,n){
                    ll w = abs(x[a]-x[b]);
                    ll h = abs(y[c]-y[d]);
                    int cnt = 0;
                    int xl = min(x[a],x[b]);
                    int xh = max(x[a],x[b]);
                    int yl = min(y[c],y[d]);
                    int yh = max(y[c],y[d]);
                    REP(e,n){
                        if(xl<=x[e]&&x[e]<=xh&&yl<=y[e]&&y[e]<=yh){
                            cnt++;
                        }
                    }
                    if(k<=cnt){
                        res = min(res,h*w);
                    }
                }
            }
        }
    }
    put(res);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  int a,b; cin >>a>>b;
  int keta = 1+floor(log10(b));
  a*=pow(10,keta);
  a+=b;
  double sq = sqrt(a);
  bool ok = false;
  if (sq == floor(sq)) ok = true;
  ok();
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	char c[2];
	int fr[1000][1000],n,i,j,k,x,ans;
	while(scanf("%d",&n)){
		if(n==0)break;
		ans=0;
		for(i=0;i<n;i++){
			k=0;
			for(j=0;j<n;j++){
				scanf("%1s",&c);
				if(c[0]=='.'){fr[i][j]=++k;if(fr[i][j]>ans)ans=fr[i][j];}else{k=0;fr[i][j]=0;}
			}
		}
		if(ans<2){printf("%d\n",ans);continue;}

		ans=0;
		for(j=0;j<n;j++){
			k=0;
			for(i=n-1;i>=0;i--){
				x=fr[i][j];
				if(x){
					if(++k<x)x=k;
					if(x>2 && x>fr[i+1][j-1]){
						x=fr[i+1][j-1]+1;
						if(x>ans)ans=x;
					}
					fr[i][j]=x;
				}
				else{k=0;}
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 4504
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
double pi = acos(-1.0);
const double EPS=1e-9;
#define MOD ll(1e9L+7)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define t() ll tt;cin>>tt;while(tt--) 
#define t2() ll tt2; cin>>tt2; for(ll tti=1;tti<=tt2;tti++)
#define printcj "Case #"<<tti<<": "
#define debug1(x) cerr << #x << " = " << x << '\n';
#define debug2(x, y) cout << #x << " = " << x << "   " << #y << " = " << y << "\n";

const ll N=101,K=100001;
ll n,k,a[N];
ll dp[K];

int main()
{
    fastio;
    ll i,j,x;
    cin>>n>>k;
    for(i=0;i<n;i++)cin>>a[i];

    for(j=0;j<=k;j++)dp[j] = 0;
    //  dp[j] = no of ways such that sum of candies is j
    // dp[j] += dp[j-x] ; where x => [1,a[i]]

    /*NOTE 
        dp[i][j] = 0;
        for(x=0 to x=a[i]) dp[i][j] += dp[i-1][j-x]
        similarly
            dp[j]=0;
            dp[j] = dp[j] + dp[j-1] + ...... + dp[j-x]
        // we start x from 1  
            dp[j] += dp[j-1] + ......... + dp[j-x]
        //for fast access use prefix sum/sliding window type approach
    */  



    //base case 
    dp[0]=1;

    for(i=0;i<n;i++){
        ll L=max(0LL,k-a[i]),R=k; //window of [L,R]
        ll sum=0; //window sum
        for(j=L;j<=R;j++) sum = (sum+dp[j])%MOD;

        for(R=k;R>=0;R--){
            ll temp = dp[R];
            dp[R] = sum;
            sum = (sum-temp+MOD)%MOD;
            if(L!=0){
                L--;
                sum = (sum+dp[L])%MOD;
            }
        }
    }
    cout<<dp[k];

    
}

Measured memory_bytes: 4424
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++) 
#define rrep(i,n) for(int i = 1; i <= (int)(n); i++) 
#define pb push_back
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef unsigned long long ull;

//constexpr ll mod = 1000000007;
//constexpr ll INF = mod * mod;
//constexpr double pi = 3.14159265358979;

int main(){
    bool table[110];
    memset(table, false, sizeof(table));
    for(int i=1; i<=9; ++i)for(int j=1; j<=9; ++j){
        table[i*j] = true;
    }
    
    int n;
    scanf("%d", &n);
    puts(table[n] ? "Yes" : "No");
}

Measured memory_bytes: 256
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');
		long n = long.Parse(input[0]);
		long b = long.Parse(input[1]);
    long a = long.Parse(input[2]);
		bool answer = true;
    long[] answers = new long[n];
    long looked = 0;

    if(a > n) answer = false;
    else if(a+b-1 > n) answer = false;
    else if(a*b < n) answer = false;

    if(!answer) Console.WriteLine(-1);
    else if(b != 1)
    {
      for(long i = 0; i < a; i++)
      {
        answers[i] = a-i;
      }
      looked = a;
      
      long setc = (n-a)/(b-1);
      long restc = (n-a)%(b-1);
      long num = a;

      for(long i = 0; i < restc; i++)
      {
        num += setc+1;
        for(long j = 0; j < setc+1; j++)
        {
          answers[looked] = num-j;
          looked++;
        }
      }

      for(long i = 0; i < b-1-restc; i++)
      {
        num += setc;
        for(long j = 0; j < setc; j++)
        {
          answers[looked] = num-j;
          looked++;
        }
      }

      Console.WriteLine(string.Join(" ", answers));
    }else
    {
      for(long i = 0; i < n; i++) answers[i] = n-i;
      Console.WriteLine(string.Join(" ", answers));
    }
	}
}

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

int main() {
  int N;
  cin >> N;
  vector<ll> H(N);
  for(int i=0; i<N; i++) cin >> H.at(i);
  int max_length = 0;
  
  int len = 0;
  for(int i=0; i<N-1; i++){
    if(H.at(i) >= H.at(i+1)) len++;
    else{
      //cout << "i: " << i << " len: " << len
      //  << " max_length: " << max_length << endl;
      max_length = max(len, max_length);
      len = 0;
    }
  }
  max_length = max(len, max_length);
  
  cout << max_length << endl;
}


Measured memory_bytes: 1024
package main

import (
	"fmt"
)


func main() {
	var n int
	m := []int{}
	fmt.Scan(&n)
	
	for i:=0;i<n;i++{
		var a int
		fmt.Scan(&a)
		m=append(m,a)
	}

	min := 1000000001
	ans := true
	for i:=n-1;i>=0;i--{
		if m[i] <= min{
			min=m[i]
		} else if m[i]-1 <=min {
			min=m[i]-1
		} else {
			ans = false
			break
		}
	}
	if ans {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}	
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;

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

   ll a, b, k;
   cin >> a >> b >> k;

   ll A = max((ll)0, a - k);
   k -= a - A;
   ll B = max((ll)0, b - k);
   printf("%lld %lld\n", A, B);
   return 0;
}

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

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

    int left[H][W], right[H][W], up[H][W], down[H][W];
    int cur = 0;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if (S[i][j] == '#') cur = 0;
            else ++cur;
            left[i][j] = cur;
        }
        cur = 0;
    }
    cur = 0;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if (S[i][W-1-j] == '#') cur = 0;
            else ++cur;
            right[i][W-1-j] = cur;
        }
        cur = 0;
    }
    cur = 0;
    for (int j = 0; j < W; ++j) {
        for (int i = 0; i < H; ++i) {
            if (S[i][j] == '#') cur = 0;
            else ++cur;
            up[i][j] = cur;
        }
        cur = 0;
    }
    cur = 0;
    for (int j = 0; j < W; ++j) {
        for (int i = 0; i < H; ++i) {
            if (S[H-1-i][j] == '#') cur = 0;
            else ++cur;
            down[H-1-i][j] = cur;
        }
        cur = 0;
    }

    int res = 0;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if (S[i][j] == '#') continue;
            cur = left[i][j] + right[i][j] + up[i][j] + down[i][j] - 3;
            res = max(res, cur);
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 66816
#include <cstdio>
#include <queue>
#include <map>
using namespace std;

char data[12][12];
int move[] = {-3, -2, -1, 1, 2, 3};

int main(void)
{
	int n;
	char c;
	scanf("%d", &n);
	
	for (int i = 0; i < n; i++){
		for (int j = 0; j < 12; j++){
			for (int k = 0; k < 12; k++){
				data[j][k] = '0';
			}
		}
		scanf("%c", &c);
		for (int j = 0; j < 8; j++){
			scanf("%s", data[j]);
		}
		int x, y;
		scanf("%d %d", &x, &y);
		
		queue <int> qx, qy;
		qx.push(y - 1);
		qy.push(x - 1);
		data[y - 1][x - 1] = '0';
		
		pair <int, int> now;
		while (!qx.empty()){
			now.first = qx.front();
			now.second = qy.front();
			qx.pop();
			qy.pop();
			for (int j = 0; j < 6; j++){
				if (data[now.first + move[j]][now.second] == '1' && 0 <= now.first + move[j]){
					data[now.first + move[j]][now.second] = '0';
//					printf("!!	%d %d\n", now.first + move[j], now.second);
					qx.push(now.first + move[j]);
					qy.push(now.second);
				}
				if (data[now.first][now.second + move[j]] == '1' && 0 <= now.second + move[j]){
					data[now.first][now.second + move[j]] = '0';
//					printf("!!	%d %d\n", now.first, now.second + move[j]);
					qx.push(now.first);
					qy.push(now.second + move[j]);
				}
				
			}
		}
		
		printf("Data %d:\n", i + 1);
		for (int j = 0; j < 8; j++){
			printf("%s\n", data[j]);
		}
		scanf("%c", &c);
	}
	
	return (0);
}

Measured memory_bytes: 0
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
const int mod = 1000000007;
int binpow(int a, int b) {
	int ret = 1;
	while (b) {
		if (b & 1) ret = 1LL * ret * a % mod;
		a = 1LL * a * a % mod;
		b >>= 1;
	}
	return ret;
}
int main() {
	int n;
	cin >> n;
	vector<int> h(n);
	for (int i = 0; i < n; ++i) cin >> h[i];
	vector<int> dp = { 2 };
	int firstlow = (n == 1 ? 1 : h[1]);
	dp[0] = 1LL * dp[0] * binpow(2, max(h[0] - firstlow, 0)) % mod;
	for (int i = 1; i < n; ++i) {
		vector<int> ndp(i + 1);
		int low = (i == n - 1 ? 1 : h[i + 1]);
		if (h[i] <= low) {
			for (int j = 0; j < i; ++j) {
				ndp[j] = dp[j];
				ndp[i] = (ndp[i] + dp[j]) % mod;
			}
		}
		else {
			int mx = min(h[i - 1], h[i]);
			int s = 0;
			for (int j = i - 1; j >= 0; --j) {
				mx = min(mx, (j == 0 ? 1 : h[j - 1]));
				ndp[j] = 1LL * dp[j] * binpow(2, h[i] - max(low, mx)) % mod;
				s = (s + dp[j]) % mod;
			}
			ndp[i] = 1LL * s * binpow(2, h[i] - max(min(h[i - 1], h[i]), low)) % mod;
		}
		dp = ndp;
	}
	int sum = 0;
	for (int i = 0; i < n; ++i) {
		sum = (sum + dp[i]) % mod;
	}
	cout << sum << '\n';
	return 0;
}

Measured memory_bytes: 256
import java.lang.Math;
import java.util.*;
class Main {
	
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int X[] = new int[N];
        for (int i=0; i<N; i++) {
        		X[i] = sc.nextInt();
        }
        Arrays.sort(X);
        int min = X[0];
        int P = min;
        int Sum = 1000000000;
        while (true) {
        		int sum = 0;
        		for (int i=0; i<N; i++) {
        			sum += Math.pow(X[i]-P, 2);
        		}
        		P++;
        		if (Sum < sum) break;
        		Sum = sum;
        }
        System.out.println(Sum);
    }
} 

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

namespace ABC148A
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = int.Parse(Console.ReadLine());
            var b = int.Parse(Console.ReadLine());

            int c = 6 - a - b;
            Console.WriteLine(c);

            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13140
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vvi G(n, vi(n));
    rep(i, n) {
        int oo;
        cin >> oo;
        int k;
        cin >> k;
        rep(i, k) {
            int s;
            cin >> s;
            G[oo-1][s-1] = 1;
        }
    }

    rep(i, n) {
        rep(j, n) {
            cout << G[i][j] << (j == n-1?'\n':' ');
        }
    }
}


Measured memory_bytes: 3240
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#define MOD 1000000007LL
using namespace std;

int main(){
	int n, a, b;
	string s;
	cin >> n >> a >> b >> s;
	int q = 0;
	int aq = 0;
	for(int i = 0; i < n; i++){
		if(s[i] == 'c') cout << "No" << endl;
		if(s[i] == 'a'){
			if(q < a + b) {
				cout << "Yes" << endl; 
				q++;
			}
			else cout << "No" << endl;
		}
		if(s[i] == 'b'){
			if(q < a + b && aq < b){
				cout << "Yes" << endl;
				q++;
				aq++;
			}
			else cout << "No" << endl;
		}
	}
}

Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
using vs = vector<string>; using tll = tuple<ll, ll, ll>; using vtll = vector<tll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop, bitSearch, bitList, nod//
//gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv, doubling, digitDP//
//dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal ,RMQ, LCA//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD2 = 1000000007, MOD = 998244353, INF = 1LL << 60, ans = 0, z = 0, o = 1;
vl flag, D; vpll path;
//***********//
//main内でCOMinit(N+1)を忘れずに！
vl fac, finv, inv;
void COMinit(ll N) {
	fac.resize(N);
	finv.resize(N);
	inv.resize(N);
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (ll i = 2; i < N; 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;
	}
}
ll COM(ll n, ll 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() {
	ll A, B;
	cin >> N >> A >> B >> K;
	COMinit(N + 1);
	//Aをi箇所に塗った時のBの塗り数
	for (i = 0; i <= N; i++) {
		if (A * i <= K) {
			if ((K - A * i) % B == 0 && (K - A * i) / B <= N) {
				ll j = (K - A * i) / B;
				//debug(i, j);
				(ans += COM(N, i) * COM(N, j)) %= MOD;
			}
		}
	}
	cout << ans;
}

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

const int N = 100, W = 10000;
struct Item {int cost, weight;} items[N];
int c[W + 1];

void knapsack(int n, int w)
{
    memset(c, 0, sizeof(c));

    for (int i = 0; i < n; ++i)
    {
        int weight = items[i].weight;
        int cost = items[i].cost;
        int num = w / weight;
        for (int k = 1; num > 0; k *= 2)
        {
            if (k > num) k = num;
            num -= k;
            //cout << "      " << k << endl;
            for (int j = w; j >= weight * k; --j){
                c[j] = max(c[j], c[j - weight * k] + cost * k);
                //cout << c[j] << endl;
                }

        }
        //cout << endl;

    }
    cout << c[w]<< endl;
}

int main(){

    int n, c, time = 0;
    cin >> n >> c;
    while(time < n){
        cin >> items[time].cost >> items[time].weight;
        time++;
    }
    knapsack(n,c);
   return 0;
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;

const long long N = 1e5 + 17;
ll cnt, lnt, mn = N, mx, a[N], n, m,k, x, y, ans, sum;
pair<ll,ll>pr[N];
vector<ll>v,v2,v3;
map<ll,ll>mp;
bool used[N], t1, t2;
vector<string>sv;
vector<char>vi;

int main()
{
    cin >> n >> m >> k;
    x = k;
    for(ll i = 0; i < 10; i ++)
    {
        x = x * n - m;
        cout << x << endl;
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

}


Measured memory_bytes: 26232
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();

		System.out.println(Math.abs(x-a) < Math.abs(x-b) ? "A" : "B");
	}
}

Measured memory_bytes: 35628
import java.util.*;

class Main {
    public static void main(String[] args) {
        final Scanner cin = new Scanner(System.in);

        int n = cin.nextInt();
        String s = cin.next();

        int cnt = 0;
        for (int pin = 0; pin <= 999; pin++) {
            int pos = 100;
            for (int i = 0; i < s.length(); i++) {
                char c = (char) ((pin / pos) % 10 + '0');
                if (s.charAt(i) == c)
                    pos /= 10;
                if (pos == 0) break;
            }
            if (pos == 0) ++cnt;
        }
        System.out.println(cnt);
    }
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	ll x,k,d; cin>>x>>k>>d;
	ll moves = abs(x)/d; //number of moves in the gg direction
	if(x<0)
	{
		x+=min(k,moves)*d;
		k-=min(k,moves);
	}
	else
	{
		x-=min(k,moves)*d;
		k-=min(k,moves);
	}
	//k moves left to oscillate
	k%=2;
	for(int z=0;z<k;z++)
	{
		if(x<0)
		{
			x+=d;
		}
		else
		{
			x-=d;
		}
	}
	cout<<abs(x)<<'\n';
}


Measured memory_bytes: 3660
program main
   integer, allocatable :: d(:), c(:)
   read(*, *)N
   allocate(d(N))
   read(*, *) d
   c = (/d(1)/)
   do i = 2, N
      if(any(c == d(i))) cycle
      c = [c, d(i)]
   enddo
   write(*, *) size(c)
   deallocate(d)
   deallocate(c)
end


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
    int n;
    cin>>n;
    int k = n%10;
    if(k==3)
    {
        cout<<"bon";
    }
    else if(k==0||k==1||k==6||k==8)
    {
        cout<<"pon";
    }
    else
    {
        cout<<"hon";
    }
      
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
ll MOD = 1000000007;
//ll INF = 21474836470000000;
ll INF = 1000000000000000;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<pair<ll,ll>>>;

int main(){
    ll N,Z,W;
    cin >> N >> Z >> W;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];
    if(N == 1){
        cout << abs(A[N-1]-W) << endl;
        return 0;
    }
    cout << max(abs(A[N-1]-W),abs(A[N-2]-A[N-1])) << endl;
}



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

#define ll long long
#define int ll
#define pii pair<int, int>
#define pb push_back
#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define FOR(i, a, b) for (int i=a; i<b; i++)
#define REPD(i, n) for (int i=n-1; i>=0; i--)
#define FORD(i, a, b) for (int i=a; i>=b; i--)
#define vi vector<int>
#define all(v) v.begin(), v.end()
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

using namespace std;

void solve() {

    int N;
    cin >> N;
    vector<ll> A(N);
    vector<ll> B(N);
    vector<ll> C(N-1);
    REP(i, N) cin >> A.at(i);
    REP(i, N) cin >> B.at(i);
    REP(i, N-1) cin >> C.at(i);

    ll ans = 0;
    ll before = -1;
    REP(i, N) {
        if (before+1 == A.at(i)) ans += C.at(before-1);
        before = A.at(i);
        ans += B.at(before-1);
         
    }
    print(ans);

}

signed main() {
    solve();
}


Measured memory_bytes: 764
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdio>

using namespace std;
int main(void) {
  int n, x;
  int a[100]={0};
  cin>>n>>x;
  for(int i=0; i<n; i++) {
    cin>>a[i];
    x-=a[i];
  }
  sort(a, a+n);
  // cout<<x<<" "<<a[0]<<endl;
  cout<<n+(x/a[0])<<endl;
  return 0;
}


Measured memory_bytes: 256
from itertools import product
n = int(input())
s = input()
ans = s.count('R')*s.count('G')*s.count('B')
for i in range(n-2):
    for j in range(i+1, n):
        k = 2*j-i
        if k <= n-1 and s[i] != s[j] and s[j] != s[k] and s[k] != s[i]: ans -= 1
print(ans)

Measured memory_bytes: 73592
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;

int main() {

   ll x; cin >> x;
   ll ans = x / 11 * 2;

   if(x % 11 == 0) {
      cout << ans << endl;
   } else {
      if(x % 11 > 6) {
         cout << ans + 2 << endl;
      } else {
         cout << ans + 1 << endl;
      }
   }

   return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int 
main(){
	int i;
	char s[4];
	
	for(i=0;i<4;i++)scanf("%c",&s[i]);
	
	for(i=0;i<3;i++){
		if(s[i]==s[i+1]){
			printf("Bad\n");
			return 0;
		}
	}
	printf("Good\n");

 return 0;
}

Measured memory_bytes: 128
X,Y = map(int,input().split())
if X>Y:
    X,Y = Y,X
if(X+Y)%3:
    print(0)
    exit()
n = (X+Y)//3
if X < n:
    print(0)
    exit()

MOD = 10**9+7
r = X-n

maxn = n+5
fac = [1,1] + [0]*maxn
finv = [1,1] + [0]*maxn
inv = [0,1] + [0]*maxn
for i in range(2,maxn+2):
    fac[i] = fac[i-1] * i % MOD
    inv[i] = -inv[MOD%i] * (MOD // i) % MOD
    finv[i] = finv[i-1] * inv[i] % MOD

def ncr(n,r):
    if n < r: return 0
    if n < 0 or r < 0: return 0
    return fac[n] * (finv[r] * finv[n-r] % MOD) % MOD

print(ncr(n,r))

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

using namespace std;

typedef long double ld;
typedef long long ll;

int main() {
#ifdef LOCAL
  assert(freopen("a.in", "r", stdin));
#endif

  ios_base::sync_with_stdio(false);

  int n;
  cin >> n;
  ll ans = 0;
  ll cur = 0;

  vector<int> a(n), b(n);
  for (int i = 0; i < n; ++i)
    cin >> a[i] >> b[i];

  for (int i = n - 1; i >= 0; --i) {
    int r = (a[i] + cur) % b[i];
    if (r != 0)
      r = b[i] - r;
    cur += r;
    ans += r;
  }

  cout << ans << endl;
}



Measured memory_bytes: 1024
S = input()
first = int(S[:2])
second = int(S[2:])
if first < 13 and first > 0:
  if second < 13 and second > 0:
    print("AMBIGUOUS")
  else:
    print("MMYY")
else:
  if second < 13 and second > 0:
    print("YYMM")
  else:
    print("NA")

Measured memory_bytes: 3060
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		Scanner sc = new Scanner(System.in);
		main.solve(sc);
		sc.close();
	}

	void solve(Scanner sc) {
		int sx = sc.nextInt();
		int sy = sc.nextInt();
		int tx = sc.nextInt();
		int ty = sc.nextInt();
		StringBuilder sb = new StringBuilder();

		// 1/2
		for (int k = 0; k < ty - sy; k++) {
			sb.append("U");
		}

		for (int k = 0; k < tx - sx; k++) {
			sb.append("R");
		}

		for (int k = 0; k < ty - sy; k++) {
			sb.append("D");
		}

		for (int k = 0; k < tx - sx; k++) {
			sb.append("L");
		}

		// 2/2
		sx--;
		sb.append("L");

		for (int k = 0; k < ty + 1 - sy; k++) {
			sb.append("U");
		}

		for (int k = 0; k < tx - sx; k++) {
			sb.append("R");
		}

		sb.append("D");


		sb.append("R");

		for (int k = 0; k < ty+1 - sy; k++) {
			sb.append("D");
		}

		for (int k = 0; k < tx - sx; k++) {
			sb.append("L");
		}

		sb.append("U");

		System.out.println(sb);
	}
}


Measured memory_bytes: 21972
void main() {
	auto ip = readAs!(int[]), x = ip[0], y = ip[1];
	"%d %d".writefln(x*y, 2*(x+y));
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 2464
n, m, x = map(int, input().split())
A = [int(i) for i in input().split()]

A.append(x)
A.sort()
idx = A.index(x)

l = len(A[:idx])
r = len(A[idx:]) - 1
if l < r:
    print(l)
else:
    print(r)

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
typedef long long ll;
ll h, w, ans;
string str[10];
int main(void){
    // Your code here!
    cin >> h >> w;
    for (ll i = 0; i < h; i++) {
        cin >> str[i];
    }
    for (ll i = 0; i < h; i++) {
        for (ll j = 0; j < w; j++) {
            if (str[i][j] == '#') ans++;
        }
    }
    if (ans == h + w - 1) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
}


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

const int INF = 1001001001;
//const ll INF = 1000000000000000000;

int func(ll a, ll b) {
	int x, y;
	x = static_cast<int>(log10(a)); x++;
	y = static_cast<int>(log10(b)); y++;
	return max(x,y);
}

int main() {
	ll n;
	cin >> n;

	int ans = INF;
	for (int i = 1; i <= static_cast<int>(sqrt(n)); i++) {
		if (n % i == 0) {
			ans = min(ans, func(i, n/i));
		}
	}
	cout << ans << endl;
	return 0;
} 

Measured memory_bytes: 256
import java.io.*;
import java.util.*;


class Main{
    public static void main(String[] args){
	BufferedReader sc=new BufferedReader(new InputStreamReader(System.in));
	int t = 1<<15;
	int[] num = new int[t+1];
	for(int i=1; i*i<=t; i++){
	    num[i*i]++;
	    for(int j=i; i*i+j*j<=t; j++){
		num[i*i+j*j]++;
		for(int k=j; i*i+j*j+k*k<=t; k++){
		    num[i*i+j*j+k*k]++;
		    for(int l=k; i*i+j*j+k*k+l*l<=t; l++){
			num[i*i+j*j+k*k+l*l]++;
		    }
		}
	    }
	}
	try {
	    while(true){
		int n = Integer.valueOf(sc.readLine());
		if(n==0)
		    break;
		System.out.println(num[n]);
	    }
	}catch(Exception e){
	    System.out.println("Error");
	}
    }
}

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

using namespace std;
using ll = long long;

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

    int n, at;
    cin >> n;
    set<int> a, d;
    for(int i = 0; i < n; ++i) {
        cin >> at;
        if(a.find(at) != a.end()) d.insert(at);
        a.emplace(at);
    }

    int ans = 0, p, m;

    while(!a.empty()) {
        p = *a.begin();
        if(d.find(p) == d.end()) ans++;
        m = *a.rbegin();
        for(int i = p; i <= m; i += p) a.erase(i);
    }

    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 13020
n = int(input())
c = str(input())
# print(list(c))

import collections
a = collections.Counter(c)
t = a["R"]
# print(a)
m = min(a["W"],a["R"])
# print(m)

co = 0

for i,j in enumerate(c):
    if co >=m or i>=t:
        break
    else:

        if j == "W":
            co +=1
        # print(i,j)
        
# print(m,co)
print(min(m,co))





Measured memory_bytes: 9524
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long int h, w;
    cin >> h >> w;
    if (h == 1 || w == 1)
    {
        cout << 1 << endl;
    }
    else
    {
        cout << (h * w + 1) / 2 << endl;
    }
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<string> s(n);
    for(int i=0; i<n; i++){
        cin >> s.at(i);
    }
    sort(s.begin(), s.end());

    int ans = 1;

    for(int i=1; i<n; i++){
        if(s.at(i-1)!=s.at(i)){ans++;}
    }

    cout << ans << endl;
}

Measured memory_bytes: 9600
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<string>
#include<cmath>
#include<queue>
#include<vector>
#include<sstream>
#include<algorithm>
#include<stack>
#include<map>
#include<set>
#define rep(i,n) for(int i=0;(i)<(n);i++)
#define rep1(i,n) for(int i=1;(i)<=(n);i++)
#define mst(a,b) memset(a,b,sizeof(a))
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define dbg(a) cout<<"* "<< #a <<" : "<<a<<endl
#define fr first
#define se second
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ls x<<1
#define rs x<<1|1
#define lowbit(x) x&(-x)
#define ac cout<<ans<<endl
//#define DEBUG 0
using namespace std;
const double pi=acos(-1.0);
const double eps=1e-6;
const ull hashp=1e7+19;
const ll INF=0x3f3f3f3f3f3f3f3fll;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;
const int maxn=3e5+100;
int gcd(int a,int b){
	return b?gcd(b,a%b):a;
}
ll qpow(ll a,ll b){
	ll ret=1;
	while(b){
		if(b&1)ret*=a;
		b>>=1;
		a*=a;
	}
	return ret;
}
ll get(ll x){
	return x*(x+1)/2;
}
struct node{
	ll val;
	int num;
	bool operator < (const node&z)const {
		return val<z.val;
	}
}a[maxn];
void solve()
{
    int n,m;scdd(n,m);
    rep1(i,n)scanf("%lld%d",&a[i].val,&a[i].num);
    sort(a+1,a+n+1);
    ll ans=0;
    rep1(i,n){
    	int t=min(m,a[i].num);
    	m-=t;
    	ans+=1LL*a[i].val*t;
    	if(!m)break;
	}
	ac;
}
int main(){
	//freopen("in.txt","r",stdin);
	//freopen("D://out.txt","w",stdout);
    //IOS;
    solve();
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int main () {FIN
    
    int a, b, c;
    cin >> a >> b >> c;
    if (a > b) swap(a, b);
    if (b > c) swap(b, c);
    if (a > b) swap(a, b);
    cout << a << " " << b << " " << c << "\n";
    return 0;
}


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

using namespace std;

int main(){

    string S;
    cin >> S;

    bool ans = true;
    for(int i = 0; i < S.length(); i++){
        if(i % 2 == 0 && S.at(i) == 'L') ans = false;
        else if(i % 2 == 1 && S.at(i) == 'R') ans = false;
    }
    
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define ull unsigned long long

int hantei(int x){
    int i,max=sqrt(x);
    for (i=2; i<=max; i++) {
        if (x%i==0) return 1;
    }
    return 0;
}

int main(){
    int x;
    scanf("%d",&x);
    while (hantei(x)) x++;
    printf("%d",x);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string>
using namespace std;

int main() {
	char s;
	int a[26] = {};
	while (cin >> s) {
		if (islower(s)) a[s - 'a']++;
		if (isupper(s)) a[s - 'A']++;
	}
	for (int i = 0; i < 26; i++) {
		char ch = i + 'a';
		cout << ch << " : " << a[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 3112
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;

using namespace std;

int n;
// 具材の価値の配列
priority_queue<double> que;
double solve();

int main() {
  cin >> n;
  rep(i, n) {
    double v;
    cin >> v;
    // 小さい方から取り出したいので
    que.push(v * -1);
  }

  cout << solve() << endl;
}

// 合成
double join(double a, double b) {
  return (a + b) / 2;
}

// 小さい方から合成していく
double solve() {
  double ans = 0.0;

  while (que.size() >= 2) {
    double a = que.top();
    que.pop();
    double b = que.top();
    que.pop();
    double joined = join(a, b);
    que.push(joined);
  }
  ans = que.top() * -1;
  return ans;
}


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

int main() {
  string S, T;
  cin >> S >> T;

  int A, B;
  cin >> A >> B;

  string X;
  cin >> X;

  if (X == S) { A--; cout << A << " " << B << endl; }
  if (X == T) { B--; cout << A << " " << B << endl; }

}



Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
#include <stack>
using namespace std;

#define rep(i, n) for (int i=0; i<int(n); i++)
using ll = long long;


int main() {
	int n, m;
	cin >> n >> m;
	int A[m], B[m];
	rep(i, m) cin >> A[i] >> B[i];
	set<int> s;
	rep(i, m) {
		if (A[i]==1) s.insert(B[i]);
	}
	rep(i, m) {
		if (B[i]==n) {
			if (s.count(A[i])) {
				cout << "POSSIBLE" << endl;
				return 0;
			}
		}
	}
	cout << "IMPOSSIBLE" << endl;
}

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


int main() {
    string s;
    cin >> s;
    s[3] = '8';
    cout << s << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define wh while
#define db double
#define pb .push_back
#define sz .size()
#define vc vector
#define vcd vector <double>
#define vcf vector <float>
#define vci vector <int>
#define vcs vector <string>
#define sti set <int>
#define fi .first
#define se .second
#define yes true
#define no false
#define bg .begin()
#define ed .end()
#define ad a,b,c,d
#define till n i<n.size();
set <int> A;
vector <int> B;
vector <int> C;
vector <int> D;
sti G;
bool t;
bool f;
int cnt=0;
int main(){
    string s;
    getline(cin,s);
    for(int i=0;i<s.size();i++){
        if(s[i]==','){
            s[i]=' ';
        }
    }
    for(int j=0;j<s.size();j++){
        cout<<s[j];
    }






}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main()
{
  char t[1000003], p[10003];
  fgets(t, 1000002, stdin);
  fgets(p, 10002, stdin);
  t[strlen(t)-1]='\0';
  p[strlen(p)-1]='\0';
  int plen = strlen(p);
  int tlen = strlen(t);
  if (plen>tlen) return 0;
  int ll = tlen-plen+1;
  for (int i=0; i<ll; i++) {
    if (strncmp(t+i, p, plen)==0)
	printf("%d\n", i);
  }
  return 0;
}


Measured memory_bytes: 2840