akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define ALL(v) (v).begin(), (v).end()
#define ios() ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
constexpr ll MOD = 10e9+7;
constexpr ll INF = 1LL << 60;
constexpr int Inf = 1e9;
inline int in() {int x; cin >> x; return x;}
template <typename T> inline void out(const T& x) {cout << x << endl;}
template <class T> inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}
template <class T> inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
//UP = 0;RIGHT = 1; DOWN = 2; LEFT =3;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b)
{
  if (a < b)
    gcd(b, a);
  int r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}
void eratos(bool * isPrime,int max){
  fill(isPrime,isPrime + max,true);
  isPrime[0] = false; 
  isPrime[1] = false; 
  for(int i=2; i<=max/i; ++i) 
      if(isPrime[i]) 
          for(int j=2; j<=max/i; ++j) 
              isPrime[i*j] = false;    
}
//

signed main()
{
  ios();
  int A,B,C,X;
  cin >> A >> B >> C >> X;
  int cnt = 0;
  rep(i,A+1)
  {
    rep(j,B+1)
    {
      rep(k,C+1)
      {
        if(500 *i  + 100 * j + 50 * k == X)
        {
          cnt ++;
        }
      }
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define rep(i,a,n) for(int i=a;i<n;++i)
#define per(i,a,n) for(int i=n-1;i>=a;--i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) ((int)x.size())
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
const ll mod=1000000007; // 998244353 = (119<<23)+1
ll powmod(ll a,ll b) {ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
// head
const int nax=1005;
int x,y,z,k;
ll p[nax],q[nax],r[nax];
set<pair<ll,pair<pii,int>>> co;
int main() {
	  ios::sync_with_stdio(false);
  	cin.tie(0);
		cin>>x>>y>>z>>k;
		rep(i,0,x) cin>>p[i];
		rep(i,0,y) cin>>q[i];
		rep(i,0,z) cin>>r[i];
		sort(p,p+x),sort(q,q+y),sort(r,r+z);
		int c=0;
		co.insert(mp((p[x-1]+q[y-1]+r[z-1]),mp(mp(x-1,y-1),z-1)));
		while(c<k) {
			auto it=--co.end();
			cout<<it->fi<<'\n';
			pair<pii,int> state=it->se;
			co.erase(it);
//			cout<<state.fi.fi<<' '<<state.fi.se<<' '<<state.se<<'\n';
			int xtran=state.fi.fi-1;
			int ytran=state.fi.se-1;
			int ztran=state.se-1;
			if(xtran>=0) co.insert(mp((p[xtran]+q[state.fi.se]+r[state.se]),mp(mp(xtran,state.fi.se),state.se)));
			if(ytran>=0) co.insert(mp((p[state.fi.fi]+q[ytran]+r[state.se]),mp(mp(state.fi.fi,ytran),state.se)));
			if(ztran>=0) co.insert(mp((p[state.fi.fi]+q[state.fi.se]+r[ztran]),mp(mp(state.fi.fi,state.fi.se),ztran)));
			c++;
		}
}


Measured memory_bytes: 640
import java.io.*;
import java.util.*;
public class Main {
	static BufferedReader br;
	static int cin() throws Exception
	{
		return Integer.valueOf(br.readLine());
	}
	static int[] split() throws Exception
	{
		String[] cmd=br.readLine().split(" ");
		int[] ans=new int[cmd.length];
		for(int i=0;i<cmd.length;i++)
		{
			ans[i]=Integer.valueOf(cmd[i]);
		}
		return ans;
	}
	static long[] splitL() throws IOException
	{
		String[] cmd=br.readLine().split(" ");
		long[] ans=new long[cmd.length];
		for(int i=0;i<cmd.length;i++)
		{
			ans[i]=Long.valueOf(cmd[i]);
		}
		return ans;
	}
	static long mod=1000000007;
	public static void main(String[] args) throws Exception{
		// TODO Auto-generated method stub
		br=new BufferedReader(new InputStreamReader(System.in));
		long n=Long.valueOf(br.readLine());
		if(n%2!=0)
			System.out.println(0);
		else
		{
			long x=n/2;
			long twos=x;
			long fives=0;
			long st=2;
			while(true)
			{
				long h=x/st;
				if(h==0)
					break;
				twos+=h;
				st=st*2;
			}
			st=5;
			while(true)
			{
				long h=x/st;
				if(h==0)
					break;
				fives+=h;
				st=st*5;
			}
			System.out.println(Math.min(twos, fives));
		}
	}
}


Measured memory_bytes: 32540
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for (int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
typedef long long ll;

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

Measured memory_bytes: 256
def main():
    """
    1 <= H,W <= 500
    0 <= a(i,j) <= 9
    """
    H, W = map(int, input().split())
    a = [
        list(map(int, input().split()))
        for _ in range(H)
    ]

    ans = editorial(H, W, a)

    print(len(ans))
    for y1, x1, x, y in ans:
        print(y1+1, x1+1, x+1, y+1)


def editorial(H, W, a):
    op = []
    for i in range(H):
        for j in range(W-1):
            if a[i][j] % 2 == 1:
                a[i][j] -= 1
                a[i][j+1] -= 1
                op.append((i, j, i, j+1))

    for i in range(H-1):
        if a[i][W-1] % 2 == 1:
            a[i][W-1] -= 1
            a[i+1][W-1] -= 1
            op.append((i, W-1, i+1, W-1))

    return op


if __name__ == '__main__':
    main()


Measured memory_bytes: 22836
n,m,x,y = map(int,input().split())
x_max = max(list(map(int,input().split())))
y_min = min(list(map(int,input().split())))
if x_max+1<=y_min:
    if x_max+1>x and x_max+1<=y:
        print('No War')
    else:
        print('War')
else:
    print('War')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = a; i < n; i++)
#define Repr(i, n, a) for (int i = n; i >= a; i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

bool check(int n)
{
    int a[10] = {};
    while (n > 0)
    {
        int m = n % 10;
        n /= 10;
        a[m]++;
    }
    if (a[1] * a[2] * a[3] * a[4] == 1)
        return true;
    else
        return false;
}

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

    bool f[5][5] = {};
    rep(i, 3)
    {
        int a, b;
        cin >> a >> b;
        f[a][b] = true;
        f[b][a] = true;
    }
    Rep(i, 1234, 4322)
    {
        if (!check(i))
            continue;
        int c[4];
        int n = i;
        c[0] = n % 10;
        n /= 10;
        c[1] = n % 10;
        n /= 10;
        c[2] = n % 10;
        c[3] = n / 10;
        if (f[c[0]][c[1]] && f[c[1]][c[2]] && f[c[2]][c[3]])
        {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
}

Measured memory_bytes: 256
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]
print("Yes" if a[0]-b[0]==a[1]-b[1]==a[2]-b[2] and a[0]-c[0]==a[1]-c[1]==a[2]-c[2] else "No")

Measured memory_bytes: 3064
import std.algorithm;
import std.range;
import std.stdio;
import std.math;
import std.array;
import std.string;
import std.conv;

/// 数列の読み込み
auto readNums(T = int)() {
	return readln().chomp.split.map!(to!T).array;
}

auto gcd(T)(T m, T n) {
	if(n == 0) {
		return m;
	}
	if(n > m) {
		return gcd(n, m);
	}
	return gcd(n, m % n);
}

void main() {
	auto nums = readNums();
	auto a = nums[0];
	auto b = nums[1];
	auto k = nums[2];
	auto d = gcd(a, b);
	
	auto n = d;
	auto div = d;
	for(size_t count = 0; count < k; --n) {
		if(d % n == 0) {
			++count;
			div = n;
		}
	}
	writefln("%s", div);
}


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

int main(){
	int N;
	cin >> N;
	vector<int> A(N), B(N), C;
	for(int i=0; i<N; i++){
		cin >> A[i] >> B[i];
		C.push_back(A[i]);
		C.push_back(B[i]);
	}
	sort(C.begin(), C.end());
	LL sum = 0;
	for(int i=0; i<N; i++) sum += C[i];
	if(C[N-2] == C[N-1]){
		for(int i=0; i<N; i++){
			if(A[i] <= C[N-1] && B[i] <= C[N-1]){
				cout << sum << endl;
				return 0;
			}
		}
	}else{
		for(int i=0; i<N; i++){
			if(A[i] <= C[N-1] && B[i] < C[N-1]){
				cout << sum << endl;
				return 0;
			}
			if(A[i] < C[N-1] && B[i] <= C[N-1]){
				cout << sum << endl;
				return 0;
			}
		}
	}
	LL ch1 = 0, ch2 = 0;
	for(int i=0; i<N; i++){
		ch1 += A[i]; ch2 += B[i];
	}
	if(ch1 == sum){
		cout << sum << endl;
		return 0;
	}
	if(ch2 == sum){
		cout << sum << endl;
		return 0;
	}
	if(C[N-1] == C[N-2] || C[N-1] == C[N]){
		cout << sum << endl;
		return 0;
	}
	int s = 0, t = 0;
	if(C[N-1] == C[N]){
		for(int i=0; i<N; i++){
			if(A[i] == C[N-1] && B[i] == C[N-1]){
				for(int j=0; j<N && i != j; j++){
					if(A[j] < C[N-1]) s++;
					if(B[j] < C[N-1]) t++;
				}
				if(s == 0 || t == 0){
					cout << sum << endl;
					return 0;
				}else{
					LL ans1, ans2;
					ans1 = sum - C[N-2] + C[N];
					ans2 = sum - C[N-1] + C[N+1];
					cout << min(ans1, ans2) << endl;
					return 0;
				}
			}
		}
		cout << sum << endl;
		return 0;
	}else{
		int p, q;
		for(int i=0; i<N; i++){
			if(A[i] == C[N-1] || B[i] == C[N-1]) p = i;
			if(A[i] == C[N] || B[i] == C[N]) q = i;
		}
		if(p == q){
			for(int j=0; j<N && j != p; j++){
					if(A[j] < C[N-1]) s++;
					if(B[j] < C[N-1]) t++;
			}
			if(s == 0 || t == 0){
				cout << sum - C[N-1] + C[N] << endl;
				return 0;
			}else{
				LL ans1, ans2;
				ans1 = sum - C[N-2] + C[N];
				ans2 = sum - C[N-1] + C[N+1];
				cout << min(ans1, ans2) << endl;
				return 0;
			}
		}else{
			cout << sum - C[N-1] + C[N] << endl;
			return 0;
		}
	}
	return 0;
}

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

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, m, n) for (ll i = (m); i < (n); i++)
#define FORR(i, m, n) for (ll i = (m); i >= (n); i--)
#define INF 1e9
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((ll)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl

int main(int argc, char const *argv[])
{
    ll r, g, b, n;
    ll res = 0;
    cin >> r >> g >> b >> n;
    for (ll i = 0; i <= n / r; i++)
    {
        for (ll j = 0; j <= (n - i * r) / g; j++)
        {
            ll k = (n - i * r - j * g) / b;
            if (i * r + j * g + k * b == n)
            {
                // dump(i);
                // dump(j);
                // dump(k);
                res++;
            }
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define n_p(v) next_permutation(v.begin(),v.end())
#define to_ll(b) stoll(b)
#define MOD 1000000007
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp

signed main(){
	int n,x; cin>>n>>x;
	ll ans=1;
	ll cnt=0;
	rep(i,0,n){
		int a; cin>>a;
		cnt+=a;
		if(cnt>x) break;
		ans++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#ifndef CLion
//#pragma GCC optimize ("O3")
#endif

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>

#define F first
#define S second
#define pb push_back
#define ll long long
#define all(x) x.begin() , x.end()
#define rep(i,s,e) for (int i = s; i < e; ++i)
#define rev(i,s,e) for (int i = s; i > e; --i)
#define mem(a,v) memset(a , v , sizeof a)
//#define mod(x,m) ((x%m + m)%m)
using namespace std;
using namespace __gnu_pbds;

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
        tree_order_statistics_node_update>;

const int N = 2e5 + 99 , mod = 1e9 + 7;


void Main(int cse , bool last){
    ll a , b , c, d;
    cin >> a >> b >> c >> d;
    cout << max( {a * c , a * d , b * c , b * d} );
}

int main(){

#ifndef CLion
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#endif
#ifdef CLion
    freopen( "in.txt" , "r" , stdin  );
//    freopen( "out.txt", "w" , stdout );
    clock_t st = clock();
#endif

    int t = 1;
//    cin >> t;
    for ( int cse = 1; cse <= t; ++cse ) Main(cse, cse == t);

#ifdef CLion
    clock_t en = clock();
    cout << "\n\nTime: " << fixed << (en - st - 0.0) / CLOCKS_PER_SEC;
#endif
    return 0;
}

Measured memory_bytes: 3664
import sys
n = int(input())
s = list(str(input()))
if n%2 == 1:
     print('No')
else:
     for i in range(int(n/2)):
          if s[i] == s[int(n/2+i)]:
               continue
          else:
               print('No')
               sys.exit()
     print('Yes')


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

using ll = long long;
#define countof(a) (sizeof(a)/sizeof((a)[0]))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_v(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << endl; }
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }
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;}
void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 

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

    string S; cin >>S;
    cout << S.substr(0, S.size() - 8) << endl;
}


Measured memory_bytes: 256
N = int(input())
S = {}
for i in range(N):
    s = input()
    if s in S:
        S[s] += 1
    else:
        S[s] = 1

key = list(S.keys())
value = list(S.values())
m = max(value)

Ans = []
for i in range(len(key)):
    Ans.append([value[i],key[i]])
Ans.sort()
for i in range(len(key)):
    if Ans[i][0] == m:
        print(Ans[i][1])

Measured memory_bytes: 53844
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int x = sc.nextInt();
			int y = sc.nextInt();
			int z = sc.nextInt();

			int tmp = x - z;
			int result = tmp / (y + z);

			System.out.println(result);
		}
	}
}


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

using namespace std;
using ll = long long;

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

  int h, w;
  cin >> h >> w;
  int ch, cw;
  int dh, dw;
  cin >> ch >> cw;
  cin >> dh >> dw;
  ch--;
  cw--;
  dh--;
  dw--;
  vector<vector<char>> s(h, vector<char>(w));
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> s[i][j];
    }
  }

  auto check = [&](int x, int y) {
    if (x < 0 || x >= w || y < 0 || y >= h)
      return false;
    if (s[y][x] == '#')
      return false;
    return true;
  };

  deque<tuple<int, int, int>> q;
  q.push_front({cw, ch, 0});
  vector<vector<bool>> visit(h, vector<bool>(w, false));
  while (!q.empty()) {
    auto [x, y, d] = q.front();
    q.pop_front();
    if (visit[y][x])
      continue;
    visit[y][x] = true;
    if (x == dw && y == dh) {
      cout << d << endl;
      return 0;
    }
    for (int dy = -2; dy <= 2; dy++) {
      for (int dx = -2; dx <= 2; dx++) {
        if (dx == 0 && dy == 0)
          continue;
        if (!check(x + dx, y + dy))
          continue;
        if ((dx == -1 && dy == 0) || (dx == 1 && dy == 0) ||
            (dx == 0 && dy == -1) || (dx == 0 && dy == 1))
          q.push_front({x + dx, y + dy, d});
        else
          q.push_back({x + dx, y + dy, d + 1});
      }
    }
  }
  cout << -1 << endl;

  return 0;
}


Measured memory_bytes: 6152
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


def main():
    D, T, S = NMI()
    if D <= T * S:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()

Measured memory_bytes: 9416
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cstdarg>
#include <string>
#include <cmath>
#include <vector>
#include <deque>
#include <utility>
#include <algorithm>
#include <fstream>
using namespace std;

namespace Namespace_Random_Generator {
	class Random_Generator {
	public:
		inline unsigned int get_random_value() const {
			return (((rand()) & 65535UL) << 16UL) + ((rand()) & 65535UL);
		}
	};
};
using namespace Namespace_Random_Generator;
Random_Generator QQ;

int const MAX_N = 315;

int dp[2][MAX_N][MAX_N / 2 * MAX_N / 2];
int groups[MAX_N], groupsBackCount[MAX_N];
int const MODULE = 998244353;

inline void add(int& x, int y) {
	x += y;
	if (x >= MODULE) {
		x -= MODULE;
	}
}

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	
	string st;
	int k;
	cin >> st >> k;
	int n = (int)st.length();
	int cnt_ones = 0, cnt_moves = 0;
	int zeroC = 0;
	int maxGroup = 0;
	for (int i=0; i<n; i++)
		if (st[i] == '1') {
			groups[zeroC]++;
			cnt_ones++;
			cnt_moves += zeroC;
			maxGroup = zeroC;
		}
		else {
			zeroC++;
		}
	groupsBackCount[maxGroup] = groups[maxGroup];
	for (int i = maxGroup - 1; i >= 0; i--)
		groupsBackCount[i] = groupsBackCount[i + 1] + groups[i];

	int from = 0;
	dp[from][0][0] = 1;
	for (int i = 0; i <= maxGroup; i++) {
		int to = 1 - from;
		for (int used = 0; used <= cnt_ones; used++)
			for (int moves = 0; moves <= min(k, cnt_moves); moves++)
				dp[to][used][moves] = 0;

		for (int used = 0; used <= cnt_ones; used++)
			for (int moves = 0; moves <= min(k, cnt_moves); moves++)
				if (dp[from][used][moves])
					for (int newTaken = max(0, cnt_ones - used - groupsBackCount[i + 1]); newTaken <= cnt_ones - used; newTaken++)
						add(dp[to][used + newTaken][moves + max(0, newTaken - groups[i])], dp[from][used][moves]);

		swap(from, to);
	}

	int ans = 0;
	for (int moves = 0; moves <= min(cnt_moves, k); moves++)
		add(ans, dp[from][cnt_ones][moves]);

	cout << ans;
	return 0;
}


Measured memory_bytes: 17580
N, M = map(int, input().split())

MAX = 300000
MOD = 1000000007
fac = [0]*MAX
finv = [0]*MAX
inv = [0]*MAX
fac[0] = 1
fac[1] = 1
finv[0] = 1
finv[1] = 1
inv[1] = 1
for i in range(2, MAX):
  fac[i] = fac[i-1]*i%MOD
  inv[i] = MOD - inv[MOD%i]*(MOD//i)%MOD
  finv[i] = finv[i-1]*inv[i]%MOD
def COM(n, k):
  if n < 0 or k < 0 or n < k:
    return 0
  return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD

fs = []
n = M
c = 2
while n > 1:
  if c*c > n:
    fs.append(n)
    break
  if n%c == 0:
    n = n//c
    fs.append(c)
  else:
    c += 1
#print(fs)
Ns = {}
for f in fs:
  if not(f in Ns):
    Ns[f] = 0
  Ns[f] += 1
r = 1
for f in Ns:
  n = Ns[f]
  r = r*COM(N-1+n, n)%MOD
print(r)


Measured memory_bytes: 38644
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
using namespace std;

#define rep(i,n) for(int (i)=0; (i)<(int)(n); ++(i))
#define foreach(c,i) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
typedef pair<string,int> Psi;

string in;

inline bool check(const string& str) {
  rep (i,str.size()) if (str[0] != str[i]) return false;
  return true;
}

char another(const char a, const char b) {
  static const char cs[3] = { 'r', 'g', 'b' };
  rep (i,3) if (cs[i] != a && cs[i] != b) return cs[i];
}

int main() {
  while (cin >> in) {
    if (in == "0") break;
    if (check(in)) { cout << 0 << endl; continue; }
    
    queue<Psi> q;
    set<string> s;
    q.push(make_pair(in, 0));

    int ans = -1;
    while (!q.empty()) {
      Psi p = q.front(); q.pop();
      string str = p.first;
      
      if (s.count(str)) continue;
      s.insert(str);
      
      if (check(str)) {
        ans = p.second;
        break;
      }
      
      for (int i = 0; i < str.size() - 1; ++i) {
        if (str[i] != str[i+1]) {
          string copy = str;
          char c = another(str[i], str[i+1]);
          copy[i] = copy[i+1] = c;
          q.push(make_pair(copy, p.second + 1));
        }
      }
    }
    
    
    if (ans == -1) {
      cout << "NA" <<endl;
    } else {
      cout << ans << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <utility>
#include <typeinfo>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <vector>
#include <tuple>
#define REP(i,n) for(int i=0;i<n;i++)
typedef long long int ll;
using namespace std;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
 
int main()
{
	string s;
	cin >> s ;
	REP(i,s.length())
	{
		if(i == 3)
		{
			cout << s[i] << " ";
		}
		else
		{
			cout << s[i];
		}
	}
	cout << endl;
    return 0 ; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
ll powmod(ll n, ll k, ll m) {
ll r=1;
 for(; k>0; k >>=1) {
   if(k&1) r=(r*n)%m;
   n=(n*n)%m;
 }
  return r;
}

ll fact(ll n) {
ll a=1;
rep(i,n) {
a=a*(n-i);
}
return a;
}

ll pow(ll a, ll b) {
ll x=1;
rep(i,b) {
x=x*a;
}
return x;
}



int main() {
ll K;
  string S;
  cin >>K>>S;
  
  
  if(S.size()<=K) {
cout<<S<<endl;
  }
else {
rep(i,K) {
cout<<S.at(i);
}
  cout<<"..."<<endl;
}

}
  
  

Measured memory_bytes: 3604
#include <iostream>
#include <vector>

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

int main() {
  int N;
  std::cin >> N;
  std::vector<long long> a(N);
  for (int i = 0; i < N; ++i)
    std::cin >> a[i];

  long long inf = 1LL << 60;
  std::vector<std::vector<long long>> dp(N + 7,
                                         std::vector<long long>(N + 7, -inf));
  for (int i = 0; i <= N; ++i)
    dp[i][i] = 0;
  for (int k = 0; k <= N; ++k) {
    for (int i = 0; i <= N - k; ++i) {
      int j = i + k;
      chmax(dp[i][j + 1], a[j] - dp[i][j]);
      if (i > 0)
        chmax(dp[i - 1][j], a[i - 1] - dp[i][j]);
    }
  }
  std::cout << dp[0][N] << std::endl;
}


Measured memory_bytes: 71040
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
int main(void)
{
	char s[101];
	int i,flg,n;
	scanf("%d",&n);
	scanf("%s",s);
	if(n%2==1)	flg=0;
	else {
		flg=1;
		for(i=0;i<n/2;i++)	{
			if(s[i]!=s[i+n/2])	{
				flg=0;	break;
			}
		}
	}
	if(flg==1)	printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include<cstdio>

int main(){
    int H,W;
    for(;;){
        scanf("%d %d",&H,&W);
        if(H == 0 && W == 0){
            break;
        }
        
        for(int i = 1; i <= H; i++){
            if(i == 1 || i == H){
                for(int j = 1; j <= W; j++){
                        printf("#");
                }
                printf("\n");
            }else if(2 <= i && i <= H - 1){
                for(int k = 1; k <= W; k++){
                    if(k == 1 || k == W){
                        printf("#");
                    }else if(2 <=k && k <= W - 1){
                        printf(".");
                    }
                }
                printf("\n");
            }
        }
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 2572
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int[] A = new int[N];
		for (int i = 0; i < N; i++) {
			A[i] = scan.nextInt();
		}
		insertionSort(A, N);
	}

	public static void insertionSort(int[] A, int N) {
		// ??????????????????
		String output = Arrays.toString(A).replaceAll(",", "");
		// ?????????????????????
		System.out.println(output.substring(1, output.length() - 1));
		
		for (int i = 1; i < N; i++) {
			int v = A[i];
			int j = i - 1;
			// ?????§???????????????????????°???????????????????????\????????????????????????????????§??????
			while (j >= 0 && A[j] > v) {
				A[j + 1] = A[j];
				A[j] = v;
				j--;
			}

			output = Arrays.toString(A).replaceAll(",", "");
			System.out.println(output.substring(1, output.length() - 1));
		}
	}
}

Measured memory_bytes: 30864
#include<bits/stdc++.h>
using namespace std;
string numprint(int n,string word){
    string ans ="";
    for (int i=0;i<n;i++){
        ans = ans + word;
    }
    return ans;
}
int main(){
    int sx,sy,tx,ty;
    cin >> sx >> sy >> tx >> ty;

    cout << numprint(tx-sx,"R");
    cout << numprint(ty-sy,"U");
    cout << numprint(tx-sx,"L");
    cout << numprint(ty-sy+1,"D");
    cout << numprint(tx-sx+1,"R");
    cout << numprint(ty-sy+1,"U");
    cout << "LU";
    cout << numprint(tx-sx+1,"L");
    cout << numprint(ty-sy+1,"D");
    cout << "R";
    cout << endl;    
}

Measured memory_bytes: 256
program answer
  implicit none

  integer :: K, S, i, j, count

  read(*,*) K, S

  count=0
  do i = 0, K
     do j = 0, S-i
        if(j<=K.and.S-i-j>=0.and.S-i-j<=K) then
           count=count+1
        end if
     end do
  end do
  write(*,*) count
 stop
end program answer

Measured memory_bytes: 2668
A =[[[0 for i in range(10)] for j in range(3)] for k in range(4)]

n = int(input())
for i in range(n):
    b,f,r,v =map(int,input().split())
    A[b-1][f-1][r-1] += v
for i in range(4):
    for j in range(3):
        for k in range(10):
            print(" {}".format(A[i][j][k]), end="")
        print("")
    if i < 3:
        print("#"*20, end="")
        print("")
    



Measured memory_bytes: 5624
import math
import sys
a = int(input())

b = math.ceil(a/7)
c = math.floor(a/4)

for i in range(b,c+1):
    x = 7*i-a
    y = a-4*i
    if x%3==0 and y%3==0:
        print("Yes")
        sys.exit()
print("No")

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

int main()
{
  ll n; cin>>n;
  for(int i =0; i*4 <= n; i++) {
    for(int j =0; j*7 <= n; j++) {
      if(i*4 + j*7 == n) {
        cout << "Yes" << endl;
        return 0;
      };
    }
  }
  cout << "No" << endl;
  return 0;
}

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

#define f first
#define s second
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define ll long long
#define ull unsigned long long
#define db double
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pli pair<ll, int>
#define px pair<db, db>
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define input(a) for (auto& el : a) cin >> el;
#define output(a) cout << '!'; for (auto& el : a) cout << el << ' '; cout << '\n'; cout.flush();
#define sz(el) int(el.size())
#define sq(a) ((a) * (a))
#define xll bitset<128>
#define xmin(a,b) a = min(a, b)
#define xmax(a,b) a = max(a, b)
#define sun(a) sort(all(a)); a.resize(unique(all(a)) - a.begin());
/**/  /// extra
//#define forn(i,n) for (int i = 0; i < n; ++i)
//#define rforn(i,n) for (int i = n - 1; i >= 0; --i)
#define bn '\n'
#define vi vector<int>
#define vii vector<vi>
#define vl vector<ll>
#define vll vector<vl>
//#define G vector<vector<pii>>
#define GVE vector<vector<edge>>
#define usi unordered_set<int>
#define usp set<pii>
/**/

using namespace std;

const int INF = 1'000'000'017;
const ll LLINF = 1'000'000'000'000'000'017LL;
const ld inf = 1.0 / 0.0;
const ld eps = 1e-9;
const int MOD = 998244353;

//mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

//uniform_int_distribution<int> uid(l, r); [l, r]
//int x = uid(rng);

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

    int a, b;
    cin >> a >> b;
    cout << 6 - a - b;
    return 0;
}


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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





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






int main()
{
    FAST();

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    string s;
    cin >> s;
    for(int i=0;i<3;i++)
    {
        if(s[i] == '7')
        {
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
    return 0;
}


Measured memory_bytes: 3652
package main

import (
	"fmt"
	"strconv"
)

var A int
var B int

func main() {
	fmt.Scanf("%d %d", &A, &B)

	ans := 0
	for i := A; i <= B; i++ {
		s := []rune(strconv.Itoa(i))
		for j := 0; j < len(s); j++ {
			if s[j] != s[len(s)-j-1] {
				break
			}
			if j == len(s)-1 {
				ans++
			}
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		if (h * w % 2 == 1 && (x + y) % 2 == 1) {
		    System.out.println("No");
		} else {
		    System.out.println("Yes");
		}
	}
}



Measured memory_bytes: 26352
#include <stdio.h>
int main(void){
    int a,b;
    scanf("%d %d",&a,&b);
    
    if(a<b){
        printf("a < b\n");
    }
    else if(a>b){
        printf("a > b\n");
    }
    else{
        printf("a == b\n");
    }
    return 0;
}



Measured memory_bytes: 2040
using System;
using System.Collections.Generic;

class Program
{
    static void Main()
    {
        string[] inputs = Console.ReadLine().Split();
        int maxCount = int.Parse(inputs[0]);
        int length = int.Parse(inputs[1]);
        List<string> datas = new List<string>();
        for(var i = 0;i < maxCount;i++) datas.Add(Console.ReadLine());
        datas.Sort();
        Console.WriteLine(string.Join("", datas.ToArray()));
    }
}

Measured memory_bytes: 13408
import sys,collections,math,random,fractions,bisect;sys.setrecursionlimit(10**7)
sr = sys.stdin.readline; P = print; P2 = lambda x: print(*x, sep="\n")
def I(i=0): t = [int(x)-i for x in sr().split()];return t
def S(): t = sr().split(); return t if len(t) > 1 else t[0]
L1,L2,L3,L4, = [],[],[],[]
 
H,N = I()
A = I()
if sum(A) >= H:
    print("Yes")
else:
    print("No")


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

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,a,b) for(int (i)=int(a);(i)<int(b);(i)++)
#define rrep(i,a,b) for(int (i)=int(a);(i)>=int(b);(i)--)

#define put(a) cout << (a) << endl
#define puts(a) cout << (a) << " "

#define llint long long int

#define INF (long long)(1e9+1)
#define MOD (long long)(1e9+7)
#define INF64 (long long)(1e18+1)

#define F first
#define S second

#define Pii  pair<int,int>
#define Pll  pair<long long,long long>
#define Piii pair<int,pair<int,int>>
#define Plll pair<long long,pair<long long,long long>>

#define Vll(a,b,c)    vector<vector<long long>> (a)((b),vector<long long>((c))
#define Vlll(a,b,c,d) vector<vector<vector<long long>>> (a)((b),vector<vector<long long>>((c),vector<long long>((d)))

#define MAX_N 1000000

llint my_binary_search(llint ary[], llint key, llint left, llint right) {
	llint middle;
	if (right < left) {
		return -(INF64);
	} else {
		middle = left + (right - left) / 2;
		if (ary[middle] > key) {
			return my_binary_search(ary, key, left, middle - 1);
		} else if (ary[middle] < key) {
			return my_binary_search(ary, key, middle + 1, right);
		} else {
			return middle;
		}
	}
}

struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for(int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

int main (void)
{
	//INPUT
	llint x,k;
	cin >> k >> x;

	if (500*k>=x) {
		put("Yes");
	} else {
		put("No");
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll n,ca=0,cb=0;
  cin>>n;
  ll a[n*3];
  priority_queue<ll> pa,pb;
  for(ll i=0;i<n*3;i++){
    cin>>a[i];
    if(i<n){
      ca+=a[i];
      pa.push(-a[i]);
    }else if(i>=n*2){
      cb+=a[i];
      pb.push(a[i]);
    }
  }
  ll aa[n+1],bb[n+1];
  aa[0]=ca;
  for(ll i=1;i<=n;i++){
    ca+=a[i+n-1];
    pa.push(-a[i+n-1]);
    ca+=pa.top();
    pa.pop();
    aa[i]=ca;
  }
  bb[n]=cb;
  for(ll i=n-1;i>=0;i--){
    cb+=a[i+n];
    pb.push(a[i+n]);
    cb-=pb.top();
    pb.pop();
    bb[i]=cb;
  }
  ll ma=aa[0]-bb[0];
  for(ll i=1;i<=n;i++){
    ma=max(aa[i]-bb[i],ma);
  }
  cout<<ma<<endl;
}
  
  

Measured memory_bytes: 5876
#include <stdio.h>
int gcd(int a, int b);
int main(int argc, const char * argv[]) {
    int a,b,c;
    scanf("%d %d", &a, &b);
    c=gcd(a,b);
    printf("%d\n", c);
    return 0;
}
int gcd(int a, int b)
{
    return (b!=0)?gcd(b,a%b):a;
}



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

int main()
{
    int N;
    cin >> N;
    long long A[N], B[N+1];
    for(int i=0;i<N+1;i++) {
        cin >> A[i];
    }
    for(int i=0;i<N;i++) {
        cin >> B[i];
    }

    long long ans = 0;
    for(int i=0;i<N;i++) {
        long long V = min(A[i], B[i]);
        A[i] -= V;
        B[i] -= V;
        ans += V;

        V = min(A[i+1], B[i]);
        A[i+1] -= V;
        B[i] -= V;
        ans += V;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    i64 N, K;
    read(N, K);

    vector<pii> v(N);
    rep(i, N) {
        read(v[i].first, v[i].second);
    }

    sort(all(v));

    i64 p = 0;
    rep(i, N) {
        p += v[i].second;
        if (p >= K) {
            print(v[i].first);
            return 0;
        }
    }

    return 0;
}


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

using namespace std;

int main()
{
    int n,r[101];
    double sum=0;
    cin >> n;
    for(int i=0;i<n;i++)
    {
        cin >> r[i];
        sum=sum+(1.0*1/r[i]);
    }
    cout << setprecision(14);
    cout << (1/sum) << endl;
    return 0;
}



Measured memory_bytes: 256
from collections import Counter


def main():
    n, k, q = map(int, input().split())
    a = Counter([int(input()) for _ in range(q)])
    p = [0 for _ in range(n)]
    for key, v in a.items():
        p[key-1] += v

    for s in p:
        if s-q <= -k:
            print("No")
        else:
            print("Yes")


if __name__ == "__main__":
    main()


Measured memory_bytes: 11892
import scala.io.StdIn.readLine

object Main {

  def sum(n:Int, s:Int, x:Int):Int = {
    if(n*9<s|| (n-1)*n/2>s) 0
    else if(n==1) { if(s >= 0 && s<=9 && s > x ) 1 else 0 }
    else { for(i <- 0 to 9 if s>=i && i>x) yield sum(n-1,s-i,if(i>x) i else x) }.sum
  }

  def getSum(sb:StringBuilder):Unit = {
    val r = readLine.split(" ").map(_.toInt)

    if(r(0)==0 && r(1)==0)  print(sb.result)
    else {
      println(sum(r(0),r(1),-1))
      getSum(sb)
    }
  }

  def main(args:Array[String]) = getSum(new StringBuilder)
}

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

using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define mp make_pair
#define pb push_back
#define pf push_front
#define ss second
#define ff first
#define sz(x) (int)x.size()
#define newl "\n"
#define vi vector<int>
#define pii pair<int, int>
#define vii vector<pii>
#define vl vector<ll>
#define pll pair<ll, ll>
#define vll vector<pll>
#define coutp cout << fixed << setprecision(12)
#define mem(x, val) memset(x, val, sizeof(x))
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define all(v) (v).begin(), (v).end()

const ld pi = 3.14159265359;
ll INF = 1e18 + 10;
ll MOD = 998244353;
ll mod = 1e9 + 9;

inline ll add(ll a, ll b, ll m)
{
    if ((a + b) >= m)
        return (a + b) % m;
    return a + b;
}

inline ll mul(ll a, ll b, ll m)
{
    if ((a * b) < m)
        return a * b;
    return (a * b) % m;
}

ll power(ll x, ll y, ll m)
{
    ll res = 1;
    x = x % m;
    if (x == 0)
        return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % m;
        y = y >> 1;
        x = (x * x) % m;
    }
    return res;
}

void solve()
{
    int n;
    cin>>n;
    vi a(n);
    map<int,int> m; 
    for(int i=0;i<n;i++) {
        int x;
        cin>>x;
        a[i]=x;
        m[x]++;
    }
    int ans=0;
    for(int i=0;i<n;i++) {
        int x = a[i];
        bool f=1;
        for(int j=2;j*j<=x;j++) {
            if(x%j==0) {
                if(m[j]>=1) f=0; 
                if(m[x/j]>=1) f=0;
            }
        }
        if(m[a[i]]>1) f=0;
        if(a[i]!=1)
            if(m[1]>=1) f=0;
        if(f) {
            ans++;
        }
    }
     cout<<ans;


}

int main()
{
    fastio;
    int t;

    t = 1;
    //cin >> t;
    //int test=t;
    while (t-- > 0)
    {
        //cout<<"Case #"<<(test-t)<<": ";
        solve();
        cout << newl;
    }

    return 0;
}

Measured memory_bytes: 32876
#include <iostream>
    #include<bits/stdc++.h>
    #include<vector>
    #include<string>
    #define ll long long
    #define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    #define vi vector<ll>
    #define el printf("\n")
    #define N 100001
    #define s second
    #define pb(x) push_back(x)
    #define f first
    using namespace std;

ll pw(ll a, ll n)
{
    ll ans=1;
    while(n>0)
    {
        if (n%2!=0)
        {
            ans=ans*a;
        }
        a=a*a;
        n=n/2;
    }
    return ans;
}
bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.first < b.first);
}

    int main()
    {
        IOS;
        ll n,W;
        cin >> n >> W;
        vector<vector<ll>> dp(n+1,vector<ll>(W+1,0));
        vector<pair<ll,ll>> L;

        for(int i=0;i<n;i++)
        {
            ll w,v;
            cin >> w >> v;
            L.push_back(make_pair(w,v));
        }
       // sort(L.begin(),L.end(),sortbysec)
        for(int i=1;i<n+1;i++)
        {
            for(int j=1;j<W+1;j++)
            {




                if(j<L[i-1].first)
                    dp[i][j]=dp[i-1][j];
                else
                    dp[i][j]=max(dp[i-1][j],L[i-1].second+dp[i-1][j-L[i-1].first]);



            }
        }
        cout << dp[n][W];
        return 0;
    }


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

using namespace std;

int main()
{
    int x;
    cin >> x;
    if (x >= 400 && x < 600) {
        cout << 8 << endl;
        return 0;
    } else if (x >= 600 && x < 800) {
        cout << 7 << endl;
        return 0;
    } else if (x >= 800 && x < 1000) {
        cout << 6 << endl;
        return 0;
    } else if (x >= 1000 && x < 1200) {
        cout << 5 << endl;
        return 0;
    } else if (x >= 1200 && x < 1400) {
        cout << 4 << endl;
        return 0;
    } else if (x >= 1400 && x < 1600) {
        cout << 3 << endl;
        return 0;
    } else if (x >= 1600 && x < 1800) {
        cout << 2 << endl;
        return 0;
    } else if (x >= 1800 && x < 2000) {
        cout << 1 << endl;
        return 0;
    }
}

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

using namespace std;

int main(){
    int n,p;
    cin>>n>>p;
    vector <int> a(n);
    bool even=true;
    bool odd=true;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        if(a[i]%2==1)even=false;
    }
    if(even&&p==0){
        long ans=pow(2,n);
        cout<<ans<<endl;
    }else if(even&&p==1){
        cout<<0<<endl;
    }else{
        long ans=pow(2,n-1);
        cout<<ans<<endl;
    }
    
}

Measured memory_bytes: 256
// AOJ 0303: Mighty Man
// 2017.10.31 bal4u@uu

#include <stdio.h>
#include <string.h>

typedef struct { int c, w; } T;
T tbl[1002];
int s[1002];
char f[1002][1002];
char buf[22], *p;

int getint()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

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

	fgets(p=buf, 10, stdin), n = getint();
	for (i = 1; i <= n; i++) {
		fgets(p=buf, 20, stdin), tbl[i].c = getint(), p++, tbl[i].w = getint();
	}
	memset(f, 0, sizeof(f)); for (i = 1; i <= n; i++) f[i][i] = 1;
	for (s[0] = 0, i = 1; i <= n; i++) s[i] = s[i-1] + tbl[i].w;

	for (k = 1; k <= n; k++) {
		for (i = 1; i <= n-k+1; i++) {
			j = i+k-1;
			if (!f[i][j]) continue;
			if (j+1 <= n) {
				if (s[j]-s[i-1] <= tbl[j+1].c) {
					f[i][j+1] = 1;
				}
			}
			if (i-1 >= 1) {
				if (s[j]-s[i-1] <= tbl[i-1].c) {
					f[i-1][j] = 1;
				}
			}
		}
	}

	memset(s, -1, sizeof(s)); s[0] = 0;
	for (i = 1; i <= n; i++) for (j = 1; j <= n; j++) {
		if (f[i][j] && (s[j] < 0 || s[i-1]+1 < s[j])) s[j] = s[i-1]+1;
	}
	printf("%d\n", s[n]);
	return 0;
}

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

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back


int main(){
    int n;
    while(cin>>n){
        bool data[400000]={false};
        vector<int> ans;
        if(n==1)break;
        
        for(int i=2;i<=n;i++){
            if(n%i==0){
                if(i%7==1 || i%7==6){
                    if(data[i]==false){
                        ans.push_back(i);
                        for(int j=1;i*j<=300000;j++){
                            data[i*j]=true;
                        }
                    }
                }
            }
        }
        cout<<n<<": ";
        rep(i,ans.size()){
            cout<<ans[i];
            if(i!=ans.size()-1)cout<<" ";
            else cout<<endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 1608
from collections import deque

# 上下左右1マスを検索するために必要とする
dis_x = [1, 0, -1, 0]
dis_y = [0, 1, 0, -1]

# 迷路の縦幅,横幅
max_h, max_w = map(int, input().split())

s = []
for _ in range(max_h):
    line = input()
    # 横1マスを壁でPadding. これでindex out of boundを防ぐ
    s.append(list("#{}#".format(line)))

# 縦1マスを壁でPadding. これでindex out of boundを防ぐ
s = [list("#" * (max_w + 2))] + s + [list("#" * (max_w + 2))]
dist = [ [0] * (max_w + 2) for _ in range(max_h+2)]

queue = deque()
for i in range(1, max_h+1):
    for j in range(1, max_w+1):
        if s[i][j] == '#':
            queue.append((i, j))

while queue:
    # 先頭の値を取り出す
    h, w = queue.popleft()

    # 上下左右4マスに対し処理
    for i in range(4):

        # 移動距離
        dx, dy = dis_x[i], dis_y[i]

        # もし次のマスの黒塗りが終わっていないなら
        if s[h+dy][w+dx] == '.':
            s[h+dy][w+dx] = '#'
            dist[h+dy][w+dx] = dist[h][w] + 1

            queue.append((h+dy, w+dx))


print(max(max(l) for l in dist))

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

const int MAXN = 200005;

int A[MAXN], B[MAXN], C[MAXN];

int N, M, L;

int main() {
	cin >> N >> M;
	for(int i = 0, c; i < N; i++) {
		cin >> c;
		A[c]++;
		C[i] = c;
	}
	for(int i = 1; i <= N; i++) {
		for(int j = max(0, i-A[i]); j < i; j++)
			B[j]++;
	}
	for(int i = 0; i < N; i++) L += !!B[i];

	for(int a, b; M--;) {
		cin >> a >> b; a--;
		int c = C[a];
		if(0 <= c-A[c]) {
			B[c-A[c]]--;
			if(!B[c-A[c]]) L--;
		}
		A[c]--;
		A[b]++;
		if(0 <= b-A[b]) {
			if(!B[b-A[b]]) L++;
			B[b-A[b]]++;
		}
		C[a] = b;
		printf("%d\n", N-L);
	}
	return 0;
}

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


void solve(long long H, long long W, long long N){
    cout<<ceil(1.0*N/(max(H, W)))<<endl;
}

int main(){
    long long H;
    scanf("%lld",&H);
    long long W;
    scanf("%lld",&W);
    long long N;
    scanf("%lld",&N);
    solve(H, W, N);
    return 0;
}


Measured memory_bytes: 256