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

using namespace std;

int main(){
    int n;
    std::cin>>n;
    char s[n], t[n];
    std::cin>>s;
    std::cin>>t;
    int len = n*2;
    string final;
    for(int i = 0; i<n; i++){
        final = final + s[i] + t[i];
    }
    std::cout << final << std::endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tl3;



const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;



int main() {
	int n;
	cin >> n;
	cout << n * n * n << endl;
}


Measured memory_bytes: 3628
x,y,z,k=map(int, input().split())
a=list(map(int, input().split()))
b=list(map(int, input().split()))
c=list(map(int, input().split()))
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

t=[]

for i in a:
    for j in b:
      t.append(i+j)

t.sort(reverse=True)
t=t[:min(k,x*y)]

ans=[]
for i in c:
    for j in t:
      ans.append(i+j)

ans.sort(reverse=True)
for i in range(k):
    print(ans[i])

Measured memory_bytes: 160876
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int H, W, A, B;
    cin >> H >> W >> A >> B;
    char s[H][W];
    rep(i, H){
        rep(j, W){
            if((i < B && j < A) || (i >= B && j >= A)) s[i][j] = '1';
            else s[i][j] = '0';
        }
    }
    rep(i, H){
        rep(j, W) cout << s[i][j]; cout << endl;
    }
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

int main()
{
    int K, Q;
    cin >> K >> Q;
    vector<int> D(K);
    for (auto &x : D) cin >> x;

    while (Q--) {
        int N, X, M;
        cin >> N >> X >> M;
        N--;
        X %= M;

        vector<lint> add;
        for (auto d : D) {
            if (d) add.emplace_back((d - 1) % M + 1);
            else add.emplace_back(M);
        }
        __int128_t tot = accumulate(add.begin(), add.end(), 0LL);
        lint cycle = N / K;
        tot *= cycle;
        int rem = N % K;
        for (int i = 0; i < rem; i++) tot += add[i];
        tot += X;
        lint ret = N - tot / M;
        cout << ret << endl;
    }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }
inline void print() { cout << "\n"; }
template<class T, class... Ts>inline void print(const T& a, const Ts&... ts) { cout << a << " "; print(ts...); }
template<class T>inline void print(const vector<T>& v) { for (int i = 0; i < v.size(); ++i)cout << v[i] << (i == v.size() - 1 ? "\n" : " "); }
template<class T>inline void print(const vector<vector<T>>& v) { for (auto& a : v)print(a); }

int main() {
    init();

    int n, k; cin >> n >> k;
    k = min(k, 20);
    string s; cin >> s;
    FOR(i, 0, k) {
        string t = s;
        reverse(all(t));
        string u = s + t;
        FOR(j, 0, n + 1)chmin(s, u.substr(j, n));
        reverse(all(s));
    }
    reverse(all(s));
    print(s);
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#include <map>
#include <string>
#include <cstdlib>

using namespace std;

int main() {
	
	int n;
	cin >> n;
	
	if (n % 10 == n / 100) puts("Yes");
	else puts("No");
	

	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main (){
    int i,a,b;
    int n;
    scanf("%d",&n);
    if(n>=105 && n<135){
        printf("1\n");
    }
    else if(n>=135 && n<165){
        printf("2\n");
    }
    else if(n>=165 && n<189){
        printf("3\n");
    }
    else if(n>=185 && n<195){
        printf("4\n");
    }
    else if(n>=195){
        printf("5\n");
    }
    else printf("0\n");
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
  
int main()
{
  int t[4][14];
  int n, i,j,c;
  char m, d;
  for(i=0; i < 4; i++){
    for(j=0; j < 14; j++){
      t[i][j]=0;
    }
  }
 scanf("%d", &c);
  for(i = 0; i < c; i++){
    scanf("%c", &d);
    scanf("%c %d", &m, &n);
    if(m == 'S'){
      t[0][n] = 1;
    }
    else if(m == 'H'){
      t[1][n] = 1;
    }
    else if(m == 'C'){
      t[2][n] = 1;
    }
    else if(m == 'D'){
      t[3][n] = 1;
    }
  }
  for(j=1; j < 14; j++){
    if(t[0][j] != 1){
      printf("S %d\n", j);
    }
  }
  
 for(j=1; j < 14; j++){
    if(t[1][j] != 1){
      printf("H %d\n", j);
    }
  }
  
 for(j=1; j < 14; j++){
    if(t[2][j] != 1){
      printf("C %d\n", j);
    }
  }
  
 for(j=1; j < 14; j++){
    if(t[3][j] != 1){
      printf("D %d\n", j);
    }
  }
 return 0;
}


Measured memory_bytes: 2104
num_V, num_E = map(int, input().split())

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1]*n
    
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x
    
    def size(self, x):
        return -self.parents[self.find(x)]

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

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

root = []
for i in range(num_E):
    s, t, w = map(int, input().split())
    root.append((s,t,w))

root = sorted(root, key = lambda x:x[2])

uf = UnionFind(num_V)
ans = 0

for s, t, w in root:
    if uf.same(s,t):
        continue
    else:
        uf.union(s,t)
        ans += w

print(ans)


Measured memory_bytes: 25024
#include<bits/stdc++.h>
#define ll long long int 
using namespace std;
int main()
{
      string s,s1;
    ll c=0;
     cin>>s>>s1;
       for(int i=0; i<s.size(); i++){
        if(s[i]==s1[i])c++;
        }
    cout<<c<<endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
int h,w,total=0,maxm=0;
string ss[1002],sa[2];
string a="JOI";
bool c(int x,int y){
	if(x>=0&&y>=0&&x<h&&y<w){
	if(ss[x][y]==sa[0][0]&&ss[x+1][y]==sa[1][0]&&ss[x][y+1]==sa[0][1]&&ss[x+1][y+1]==sa[1][1])return true;
	}
	return false;
}
int main()
{
	scanf("%d%d",&h,&w);
	for(int i=0;i<h;i++){
		cin >> ss[i];
		ss[i]+="K";
	}
	for(int i=0;i<=w;i++)ss[h]+="K";
	cin >> sa[0] >> sa[1];
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(c(i,j))total++;
		}
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			int A=c(i-1,j-1)+c(i,j)+c(i-1,j)+c(i,j-1);
			string sx;
			sx+=ss[i][j];
			for(int k=0;k<3;k++){
				ss[i][j]=a[k];
				int b=c(i-1,j-1)+c(i,j)+c(i,j-1)+c(i-1,j);
				maxm=max(maxm,b-A);
			}
			ss[i][j]=sx[0];
		}
	}
	printf("%d\n",total+maxm);

}

Measured memory_bytes: 2284
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sz(a) int(a.size())
#define clr(a) memset(a,0,sizeof(a))
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
const int inf=1e9;
const ll Inf=1e18;
const int N=3e3+10;
const int mod=1e9+7;
const int inv2=(mod+1)/2;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
template<typename T> bool chkmax(T &a,T b) { return a<b?a=b,1:0; };
template<typename T> bool chkmin(T &a,T b) { return a>b?a=b,1:0; };
int add(int a,int b) { return a+b>=mod?a+b-mod:a+b; }
int sub(int a,int b) { return a-b<0?a-b+mod:a-b; }
void inc(int &a,int b) { a=(a+b>=mod?a+b-mod:a+b); }
void dec(int &a,int b) { a=(a-b<0?a-b+mod:a-b); }
int n,q,a[N],f[N][N],pw=1;
struct data {
    int x,y,z;
};
int qpow(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() {
    n=gi(),q=gi();
    for(int i=1;i<=n;i++) a[i]=gi();
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++) f[i][j]=a[i]<a[j];
    while(q--) {
        pw=2ll*pw%mod;
        int i=gi(),j=gi();
        vector<data> v;
        if(i>j) swap(i,j);
        auto insert=[&](int x,int y,int z,int op=0) {
                        v.pb({x,y,z});
                        //cerr<<x<<" "<<y<<" "<<z<<" "<<op<<endl;
                    };
        for(int k=1;k<=n;k++) {
            insert(i,k,1ll*inv2*add(f[i][k],f[j][k])%mod,1);
            insert(k,i,1ll*inv2*add(f[k][i],f[k][j])%mod,2);
            insert(j,k,1ll*inv2*add(f[i][k],f[j][k])%mod,3);
            insert(k,j,1ll*inv2*add(f[k][i],f[k][j])%mod,4);
        }
        insert(i,j,1ll*inv2*add(f[i][j],f[j][i])%mod);
        insert(j,i,1ll*inv2*add(f[i][j],f[j][i])%mod);
        for(auto i:v) f[i.x][i.y]=i.z;
        cerr<<endl;
    }
    int ans=0;
    for(int i=1;i<=n;i++)
        for(int j=i+1;j<=n;j++) inc(ans,1ll*f[j][i]*pw%mod);
    cout<<ans;
    return 0;
}


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;


int main() {
    int n; cin >> n;
    V<ll> c(n - 1), s(n - 1), f(n - 1);
    for(int i = 0; i < n - 1; i++) cin >> c[i] >> s[i] >> f[i];

    for(int i = 0; i < n - 1; i++){
        ll sum = c[i] + s[i];
        for(int j = i + 1; j < n - 1; j++){
            if(s[j] < sum){
                if((sum - s[j]) % f[j] != 0){
                    ll tmp = (sum - s[j] + (f[j] - 1)) / f[j];
                    sum += ((s[j] + f[j] * tmp) - sum);
                }
            }else{
                sum = s[j];
            }
            sum += c[j];
        }
        cout << sum << endl;
    }
    cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 3608
#include<iostream>
#include<cstring>
#include<cmath>
#include<queue>
#include<algorithm>
#define LL long long
#define INF 0x3f3f3f3f
using namespace std;
const int N=2e5+100;
int arr[N];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    LL n;
    while(cin>>n) {
        LL ans=0;
        ans=n/11*2;
        if(n%11==0)ans+=0;
        else if(n%11<=6)ans+=1;
        else ans+=2;
        cout<<ans<<endl;
    }
    return 0;
}

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

class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] ips = br.readLine().split(" ");
        int n = Integer.parseInt(ips[0]);
        int k = Integer.parseInt(ips[1]);
        int c = Integer.parseInt(ips[2]);
        char[] str = br.readLine().toCharArray();
        Sol sol = new Sol(n, k, c, str);
        sol.sol();
    }
}

class Sol {
    int n,k,c;
    char[] arr;
    int[] chosen;
    LinkedList<Integer> res;
    
    Sol(int n, int k, int c, char[] arr){
        this.n = n;
        this.k = k;
        this.c = c;
        this.arr = arr;
        this.chosen = new int[n];
        res = new LinkedList<Integer>();
    }
    
    void sol(){
        int counter = 0;
        for(int i = 0; i < n && counter != k;++i){
            char curr = arr[i];
            if(curr != 'x'){
                counter++;
                chosen[i] = counter;
                i+=c;
            }
        }
        
        counter = k;
        for(int i = n-1; i >= 0 && counter != 0;--i){
            char curr = arr[i];
            if(curr != 'x'){
                chosen[i]-=counter;
                if(chosen[i] == 0){
                    res.addFirst(i);
                }
                i-=c;
                counter--;
            }
        }
        
        for(int el : res)
           System.out.println(el+1);
    }
}

Measured memory_bytes: 49616
n=int(input())
#a,b=map(int,input().split())
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
nst=list(str(n))
total=0
for ni in nst:
    total+=int(ni)
if n%total ==0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9076
// iostream のscanf, printf では間に合わなかった
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <vector>

using namespace std;

#define INF (1<<29)
#define mp make_pair
#define pb push_back

typedef pair<int,int> pii;

int main(){
	int n, m;
	cin >> n >> m;
	vector<pii> treasure;
	for( int i = 0; i < n; i++ ){
		int x, y;
		//cin >> x >> y;
		scanf("%d %d", &x, &y);
		treasure.pb( mp(x,y) );
	}
	sort(treasure.begin(), treasure.end());
	for( int i = 0; i < m; i++ ){
		int x1, y1, x2, y2;
		//cin >> x1 >> y1 >> x2 >> y2;
		scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
		// search
		int ans = 0;
		vector<pii>::iterator it = lower_bound(treasure.begin(),treasure.end(),mp(x1,y1));
		while( 1 ){
			if( it == treasure.end() || *it > mp(x2,y2) ) break;
			if( x1 <= (*it).first && (*it).first <= x2 && y1 <= (*it).second && (*it).second <= y2 ) ans++;
			it++;
		}
		//cout << ans << endl;
		printf("%d\n", ans);
	}
}

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

int main(){
 int W,H,x,y,r;
 cin >> W >> H >> x >> y >> r;
 if(x>=r && x<=W-r && y>=r && y<=H-r){
  cout << "Yes" << endl;}
 else{
  cout << "No" << endl;}
} 



Measured memory_bytes: 3100
DBG = true
n = gets.to_i
a = gets.chomp
b = gets.chomp
c = gets.chomp
sum = 0
for i in 0...n
  if a[i] != b[i] && b[i] != c[i] && c[i] != a[i]
    sum += 2
  elsif a[i] != b[i] || b[i] != c[i] || c[i] != a[i]
    sum += 1
  end
end
puts "#{sum}"


Measured memory_bytes: 1788
//In The Name of Allah
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N = 2e6 + 10;
const ll mod = 1e9 + 7;

ll fact[N], inv[N];

ll Pow(ll a, ll b){
    ll res = 1;
    for (; b; b = b >> 1)
        res = res * (b & 1 ? a : 1) % mod, a = a * a % mod;
    return res;
}

ll C(ll n, ll m){
    if (m < 0 || n < m)
        return 0;
    return fact[n] * inv[m] % mod * inv[n - m] % mod;
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    fact[0] = inv[0] = 1;
    for (ll i = 1; i < N; i ++)
        fact[i] = fact[i - 1] * i % mod, inv[i] = Pow(fact[i], mod - 2);
    ll ans = 0;
    for (ll x = r1; x <= r2; x ++)
        ans = (ans + C(x + c2 + 1, x + 1) - C(x + c1, x + 1)) % mod;
    ans = (ans + mod) % mod;
    cout << ans;
    return 0;
}


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

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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<int> VECINT;
typedef vector<ll> VECLL;

int main() {
  int N,A,B;cin>>N>>A>>B;
  int ans=0;
  FOR(i,1,N+1) {
    string numstr = to_string(i);
    int sum = 0;
    for (auto c:numstr) sum += c-'0';
    if (A<=sum && sum<=B) ans += i;
  }
  OUT(ans);

  return 0;
}

Measured memory_bytes: 256
/**************************************
 * Au: Hany01
 * Prob: agc003b
 * Date: Oct 20th, 2018
 * Email: hany01@foxmail.com
**************************************/

#include<bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define File(a) freopen(a".in", "r", stdin), freopen(a".out", "w", stdout)
#define Rep(i, j) for (register int i = 0, i##_end_ = j; i < i##_end_; ++ i)
#define For(i, j ,k) for (register int i = (j), i##_end_ = (k); i <= i##_end_; ++ i)
#define Fordown(i, j, k) for (register int i = (j), i##_end_ = (k); i >= i##_end_; -- i)
#define Set(a, b) memset(a, b, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define SZ(a) ((int)(a.size()))
#define ALL(a) a.begin(), a.end()
#define PB(a) push_back(a)
#define MP(a, b) make_pair(a, b)
#define X first
#define Y second
#define INF (0x3f3f3f3f)
#define INF1 (2139062143)
#define y1 wozenmezhemecaia 
#ifdef hany01
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#endif

template<typename T> inline bool chkmax(T &a, T b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline T read() {
    register char c_; register T _, __;
    for (_ = 0, __ = 1, c_ = getchar(); !isdigit(c_); c_ = getchar()) if (c_ == '-')  __ = -1;
    for ( ; isdigit(c_); c_ = getchar()) _ = (_ << 1) + (_ << 3) + (c_ ^ 48);
    return _ * __;
}
//EOT


int main()
{
#ifdef hany01
    File("agc003b");
#endif

	int rest = 0;
	LL ans = 0;
	For(i, 1, read<int>()) {
		int ai = read<int>();
		ans += (ai + rest) / 2;
		rest = ((ai + rest) & 1);
		if (!ai && rest) rest = 0;
	}
	cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;

int main() {
	int a,b;
	cin>>a>>b;
	//a copies of b and b copies of a
	int c;
	int d;
	int bb=b;
	int aa=a;
	int i=0;
	if(a>b){
    	while(a--){
    	    int k=pow(10,i);
    	    b=b*k;
    	    c+=b;
    	    i++;
    	    b=bb;
    	    
    	}
    	cout<<c<<endl;
	}
	else{
    	int j=0;
    	while(b--){
    	    int k=pow(10,j);
    	    a=a*k;
    	    d+=a;
    	    j++;
    	    a=aa;
    	}
    	cout<<d<<endl;
	}
// 	if(c>d){
// 	    cout<<d<<endl;
// 	}
// 	else{
// 	    cout<<c<<endl;
// 	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  int a , b;
  int d , r;
  double f;
  
  scanf("%d %d",&a,&b);

  d = a/b;
  r = a%b;
  f = (double)a/b;

  printf("%d %d %f\n",d,r,f);

  return 0;
}


Measured memory_bytes: 2108
/*  Success may not come to me immediately,
 *  but it will come definitely....
 */
#include <bits/stdc++.h>
//=====================================================================
using namespace std;
//=====================================================================
#define opt ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
//=====================================================================
#define li      int64_t
#define ld      double_t
#define ulli    uint64_t
//=====================================================================
#define rep(i,a,b)  for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define repi(i,v)   for(i=v.begin();i!=v.end();i++)
#define repir(i,v)  for(i=v.rbegin();i!=v.rend();i++)
#define elif        else if
#define mset(a,b)   memset(a,b,sizeof(a))
#define nl          cout<<'\n'
//=====================================================================
typedef vector<li>       vli;
typedef vector<string>   vstr;
typedef pair<li,li>      pli;
typedef pair<li,pli >    ppli;
typedef pair<li,ppli >   pppli;
typedef vector<pli >     vpl;
typedef vector<ppli >    vppli;
typedef vector<pppli >   vpppli;
//=====================================================================
#define pb  push_back
#define pob pop_back
#define pf  push_front
#define pof pop_front
#define all(v)  v.begin(),v.end()
#define itr iterator
#define rtr reverse_iterator
#define sz  size()
#define lb  lower_bound
#define ub  upper_bound
#define bs  binary_search
#define mp  make_pair
#define F   first
#define S   second
//=====================================================================
#define mod (li)(1e9+7)
#define inf (li)(1e18)
#define MX1 (li)(1e5+5)
#define MX2 (li)(1e6+5)
#define pi  acos(-1)
//=====================================================================
li power(li a,li b){li ans=1;while(b){if(b&1){ans=(ans*a)%mod;}
a=(a*a)%mod;b>>=1;}return ans;}
//=====================================================================
li mmi(li n){return power(n,mod-2);}
//=====================================================================
li two(li n){return (1LL<<n);}
//=====================================================================
void onbit(li &n,li x){n|=two(x);}
//=====================================================================
void offbit(li &n,li x){n&=~two(x);}
//=====================================================================
li cntbit(li n){li res=0;while(n and ++res)n-=n&-n;return res;}
//=====================================================================
li dx[]={-1,0,1,0},dy[]={0,-1,0,1};
//=====================================================================
/*------------------------MAIN CODE BEGINS NOW!------------------------*/

li n,a[MX1];

void solve(){
  li i;cin>>n;
  rep(i,1,n+1) cin>>a[i];
  li cnt=0;
  rep(i,1,n){
    if(a[i]==i and a[i+1]==i+1){
      swap(a[i],a[i+1]);
      i++;
      cnt++;
    }
    if(a[i]==i){
      swap(a[i],a[i+1]);
      cnt++;
    }
  }
  if(a[n]==n) swap(a[n],a[n-1]),cnt++;
  cout<<cnt;
}

int main(){
  opt
  #ifndef ONLINE_JUDGE
  #endif
  li t=1;
  //cin>>t;
  while(t--){
    solve();
  }
  return 0;
}

Measured memory_bytes: 1024
fun main(args: Array<String>) {
    val (a, b, x) = readLine()!!.split(" ").map { it.toInt() }
    val v = a * a * b
    val naname = Math.sqrt((a * a + b * b).toDouble())
    fun bsearch(s: Double, e:Double) : Double {
        if (Math.abs(s - e) < 0.0000001) return s
        val mid = s + (e - s) / 2
        val l1 = length(a, mid)
        val v2 = if (l1 < naname) {
            v - (vol(a, mid) * a)
        } else {
            vol(b, 90 - mid) * a
        }
        if (v2 < x.toDouble()) {
            return bsearch(s , mid)
        } else {
            return bsearch(mid, e)
        }
    }
    println(bsearch(0.toDouble(), 90.toDouble()))
}

fun vol(x: Int, a: Double) : Double {
    return length2(x,a) * x / 2
}

fun length(x: Int, a: Double): Double {
    return x / Math.cos(Math.toRadians(a))
}

fun length2(x: Int, a: Double): Double {
    return x * Math.tan(Math.toRadians(a))
}

Measured memory_bytes: 36032
#include <bits/stdc++.h>
using namespace std;
int main(){
	int h, w, ek; cin >> h >> w >> ek;
	vector<int> f(w, 0);
	f[0] = 1;
	for(int i = 0; i < h; i++){
		vector<int> nf(w, 0);
		for(int j = 0; j < 1<<(w - 1); j++){
			bool bad = false;
			for(int k = 0; k < w - 2; k++){
				if(((j>>k)&1) && ((j>>(k+1))&1)) bad = true;
			}
			if(!bad){
				for(int k = 0; k < w; k++){
					int nk = k;
					if((j>>nk)&1) nk++;
					if(k && ((j>>(k - 1))&1)) nk--;
					nf[nk] += f[k];
					const int mod = 1000000007;
					if(nf[nk] >= mod) nf[nk] -= mod;
				}
			}
		}
		f = nf;
	}
	cout << f[ek - 1] << endl;
	return 0;
}


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

void fnSelectionSort(vector<int> &argviSort, int &argiSortCnt)
{
  for (int ixSorting = 0; ixSorting < argviSort.size() - 1; ixSorting++)
  {
    int ixMinimum = ixSorting;
    bool bSorting = false;

    for (int j = ixSorting + 1; j < argviSort.size(); j++)
    {
      if (argviSort[j] < argviSort[ixMinimum])
      {
        ixMinimum = j;
        bSorting = true;
      }
    }
    if (bSorting)
    {
      swap(argviSort[ixSorting], argviSort[ixMinimum]);
      argiSortCnt++;
    }
  }
}

void fnOutput(const vector<int> &argviSort, int argiSortCnt)
{
  for (int i = 0; i < argviSort.size(); i++)
  {
    if (i) cout << " ";
    cout << argviSort[i];
  }
  cout << endl;
  cout << argiSortCnt << endl;
}

int main()
{
  int iSortCnt = 0;
  vector<int> viSort;
  int iMaxSize;
  
  cin >> iMaxSize;
  for (int i = 0; i < iMaxSize; i++)
  {
    int iNum;
    cin >> iNum;
    viSort.push_back(iNum);
  }

  fnSelectionSort(viSort, iSortCnt);
  fnOutput(viSort, iSortCnt);

  return 0;
}

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

using namespace std;

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

    int count = 0;
    for(int a = 1; a < n; a++) {
        if(n % a == 0) {
            count += n / a - 1;
        }else {
            count += n / a;
        }
    }

    cout << count << endl;
}

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

int n;
typedef pair<long long,long long>P;
vector<P>e[100005];
int ans[100005]={0};
int used[100005]={0};
void dfs(long long now){
	for(int i = 0; i < e[now].size();i++){
		long long next = e[now][i].first;
		long long ncost = e[now][i].second;
		if(used[next]) continue;
		if(ncost%2==0){
			ans[next]=ans[now];
		}
		else{
			ans[next]=(ans[now]+1)%2;
		}
		used[next]=1;
		dfs(next);
	}
	return;
}

int main(){
	cin >> n;
	for(int i = 0; i < n-1; i++){
		long long a,b,c;
		cin >> a >> b >> c;
		a--;b--;
		e[a].push_back(P(b, c));
		e[b].push_back(P(a, c));
	}
	
	ans[0]=0;
	used[0]=1;
	dfs(0);
	for(int i = 0; i < n; i++) cout<<ans[i]<<endl;
}



Measured memory_bytes: 10240
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main(){

  string s, t; cin >> s >> t;
  int a, b; cin >> a >> b;
  string u; cin >> u;
  if(u == s) a--;
  else b--;
  cout << a <<" " << b << endl;

  return 0;
}


Measured memory_bytes: 256
import numpy as np
X = int(input())

v = np.arange(1, 100010)
a = np.zeros(v.shape[0], dtype='int')
a[0] += 1
for i in range(1, 318):
    # for i in range(X, 100010):
    a += (v % i == 0).astype('int')

a[:317] -= 1
prime = v[a == 1][1:]
print(prime[prime >= X][0])


Measured memory_bytes: 16948
#include <iostream>
#include <string>
#include <map>
#include <vector>

using namespace std;

int main(int argc, char const *argv[])
{
    string s;
    int cnt0 = 0;
    map<char, int> mp;
    vector<int> vec;
    cin >> s;
    for (int i = 0; i < s.size(); ++i) {
        mp[s[i]]++;
    }

    for(auto x : mp) {
        vec.emplace_back(x.second);
    }
    if (vec.size()==2&&vec[0]==2) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define A 10000

int x;
int P[A];
int M[A][A];

void Matrix(){
  int i,j,k,l,n,m;
  n=x;
  
 for(i=1;i<=n;i++){
    M[i][i]=0;
  }
  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j=i+l-1;
      M[i][j]=100000;
      for(k=i;k<=j-1;k++){
    m=M[i][k]+M[k+1][j]+P[i]*P[k+1]*P[j+1];
    if(m<M[i][j]){
      M[i][j]=m;
    }
      }
    }
  }
  printf("%d\n", M[1][x]);
}

int main(){

int n,i,m,count;
  scanf("%d",&x);

  for(i=0;i<x;i++){
    scanf("%d %d",&P[i+1],&m);

  }
  P[i+1]=m;
  
  Matrix();

  return 0;
}

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

using namespace std;
#define N 100100
#define SIGMA 26

const string answer[2] = {"NO\n", "YES\n"};

unsigned long long ans, h, w;
int main()
{
    cin >> h >> w;
    if (h == 1LL || w == 1LL){
        cout << 1;
        return 0;
    }
    ans = (h / 2LL + (h & 1LL)) * (w / 2LL + (w & 1LL)) +
        (h / 2LL) * (w / 2LL);
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;



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

	int H, W;
	cin >> H >> W;
	vector<string> a(H);
	REP(i, H) {
		cin >> a[i];
		a[i] = "#" + a[i] + "#";
	}
	REP(j, W + 2) cout << '#';
	cout << "\n";
	REP(i, H) cout << a[i] << "\n";
	REP(j, W + 2) cout << "#";
	cout << "\n";

	return 0;
}

Measured memory_bytes: 256
from collections import deque

N = int(input())

A = deque()

for i in range(N):
	b= input()
	if b == "deleteFirst":
		A.popleft()
	elif b == "deleteLast":
		A.pop()
	else:
		b, c = b.split()
		c = int(c)
	
		if b == "insert":
			A.appendleft(c)
		elif b == "delete":
			if (c in A):
				A.remove(c)

print(" ".join(map(str, A)))
	

Measured memory_bytes: 47872
#line 2 "../../library/template.hpp"
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using pl = pair<ll, ll>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0; i < (ll)n; i++)
#define rep3(i, l, r) for(ll i = l; i < (ll)r; i++)
#define per(i, n) for(ll i = (ll)n-1; i >= 0; i--)
#define per3(i, l, r) for(ll i = (ll)r-1; i >= (ll)l; i--)
#define all(v) begin(v), end(v)
template<class T, class U>
inline void cmax(T& a, U b) { if (a < b) a = b; }
template<class T, class U>
inline void cmin(T& a, U b) { if (a > b) a = b; }

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    cerr << fixed << setprecision(15);
  }
} io_setup;

constexpr char el = '\n';

template<class T, class U>
ostream &operator<<(ostream &os, const pair<T, U>& p) {
  os << p.first << " " << p.second;
  return os;
}
template<class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.first >> p.second;
  return is;
}
template<class T>
ostream &operator<<(ostream &os, const vector< T > &v) {
  rep(i, v.size())
    os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<class T>
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}
#line 3 "../../library/div_round_up.hpp"

// return ceil(n/m)
inline ll div_round_up(ll n, ll m) {
  return (n+m-1) / m;
}
#line 3 "c2.cpp"

int main() {
  ll n;
  cin >> n;
  vl a(5);
  cin >> a;

  ll ans = 4 + div_round_up(n, *min_element(all(a)));
  cout << ans << el;
}


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

using namespace std;
 
using ll = long long;
using ull = unsigned long long;
using ldouble = long double;
 
const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s) cout << fixed << setprecision(10) << s << endl;

string res;

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

    println(48 - n);
}


Measured memory_bytes: 3508
#include<stdio.h>
#include<stdbool.h>
#define N 8
#define NFR -1
#define FR 1


int row[N], col[N], dpos[2*N-1], dneg[2*N-1];
bool S[N][N];

void initialize(){
  int i;
  for( i = 0 ; i < N ; i++){
    row[i] = FR;
    col[i] = FR;
  }
  for( i = 0 ; i < 2*N-1 ; i++){
    dpos[i] = FR;
    dneg[i] = FR;
  }
}

void print(){
  int i, j;
  for( i = 0 ; i < N ; i++){
    for( j = 0 ; j < N ; j++){
      if( S[i][j] ){
        if( row[i] != j) return;
      }
    }
  }

  for( i = 0 ; i < N ; i++ ){
    for( j = 0 ; j < N ; j++ ){
      if(row[i] != j)
      printf(".");
      else printf("Q");
    }
    printf("\n");
  }
}

void qeen(int i){
  int j;
  if( i == N ){
    print();
    return;
  }

  for( j = 0 ; j < N ; j++ ){
    // {i, j }がクイーンの攻撃範囲にあるか調査
    if( col[j] == NFR || dpos[i+j] == NFR || dneg[i-j+(N-1)] == NFR) continue;
    //{i, j}がクイーンの攻撃範囲に入っていなければクイーンの配置
    row[i] = j;
    col[j] = NFR;
    dpos[i+j] = NFR;
    dneg[i-j+(N-1)] = NFR;
    //　次の行
    qeen(i+1);
    row[i] = FR;
    col[j] = FR;
    dpos[i+j] = FR;
    dneg[i-j+(N-1)] = FR;
  }
}

int main(){
  int i, j, k, r, c;

  initialize();

  for( i = 0 ; i < N ; i++){
    for( j = 0 ; j < N ; j++){
      S[i][j] = false;
    }
  }

  scanf("%d", &k);
  for( i = 0 ; i < k ; i++){
    scanf("%d%d", &r, &c);
    S[r][c] = true;
  }
  qeen(0);

  return 0;
}



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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int L = a + b;
  int R = c + d;
  
  if (L > R)  cout << "Left" << endl;
  else if (L == R)  cout << "Balanced" << endl;
  else if (L < R)  cout << "Right" << endl;
  
  
  
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int r, x, y, H, W;
    
    scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
    if (x >= r && y >= r && (H - r) >= y && (W - r) >= x) {
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    
    return 0;
}



Measured memory_bytes: 2100
//#include <iostream>
//#include <vector>
//#include <algorithm>
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)

using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF = 100000000;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main(){
  string S;
  cin >> S;
  if(S[0]=='S'){
    cout << "Cloudy" << endl;
  }
  if(S[0]=='C'){
    cout << "Rainy" << endl;
  }
  if(S[0]=='R'){
    cout << "Sunny" << endl;
  }

  return 0;
}

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

int** make2dArray(int x,int y){
	int** array = (int**)malloc(sizeof(int*) * x);
	for (int i = 0; i < x; i++) {
		array[i] = (int*)malloc(sizeof(int) * y);
	}
	return array;
}
void printArray(int* a, int length) {
	for (int i = 0; i < length; i++) {
		printf("%d ", a[i]);
	}
}
void print2dIntArray(int** a,int x,int y) {
	for (int i = 0; i < x; i++) {
		for (int j = 0; j < y; j++) {
			if (j == y - 1) {
				printf("%d\n", a[i][j]);
			}
			else {
				printf("%d ", a[i][j]);
			}
		}
	}
}
void print2dLongArray(long long** a, int x, int y) {
	for (int i = 0; i < x; i++) {
		for (int j = 0; j < y; j++) {
			if (j == y - 1) {
				printf("%llu\n", a[i][j]);
			}
			else {
				printf("%llu ", a[i][j]);
			}
		}
	}
}
int* getColFromArray(int** array, int x, int j) {
	int* a = (int*)malloc(sizeof(int) * x);
	for (int i = 0; i < x; i++) {
		a[i] = array[i][j];
	}
	return a;
}
long long int arrayTimes(int* a1, int* a2, int length) {
	long long int res = 0;
	for (int i = 0; i < length; i++) {
		res = res + a1[i] * a2[i];
	}
	return res;
}
void call(int n) {
	for (int i = 1; i <= n; i++) {
		int x = i;
		if (x % 3 == 0) {
			printf(" %d", i);
			continue;
		}
		do{
			if (x % 10 == 3) {
				printf(" %d", i);
				break;
			}
			x /= 10;
		} while (x);
	}
}
void call1(int n) {
	for (int i = 1; i <= n; i++) {
		if (i % 3 == 0 || i % 10 == 3) {
			printf(" %d", i);
		}
		else {
			int x;
			x = i;
			x = x / 10;
			if (x != 0 && x % 10 == 3) {
				printf(" %d", i);
			}
		}
		
	}
	printf("\n");
}
	int main() {
		int n;
		scanf("%d", &n);
		call(n);
		printf("\n");
	}




Measured memory_bytes: 2096
{-# LANGUAGE FlexibleInstances    #-}
{-# LANGUAGE TypeSynonymInstances #-}

import           Control.Applicative
import           Control.DeepSeq
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                    as A
import qualified Data.Array.IArray             as IA
import qualified Data.Array.IO                 as AI
import qualified Data.Array.MArray             as MA
import qualified Data.Array.ST                 as STA
import qualified Data.Array.Unboxed            as AU
import           Data.Bits
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import qualified Data.Graph                    as G
import           Data.Int
import qualified Data.IntMap                   as IM
import qualified Data.IntSet                   as IS
import           Data.List
import qualified Data.Map.Strict               as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Sequence                 as SQ
import qualified Data.Set                      as S
import           Data.Time
import qualified Data.Tree                     as T
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as VM
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM

readInt :: IO [Int]
readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readInts :: Int -> IO [[Int]]
readInts n = replicateM n readInt

readInteger :: IO [Integer]
readInteger = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readIntegers :: Int -> IO [[Integer]]
readIntegers n = replicateM n readInteger

readString :: IO [String]
readString = map BS.unpack . BS.words <$> BS.getLine

readStrings :: Int -> IO [[String]]
readStrings n = replicateM n <$> readString

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

count :: Eq a => a -> [a] -> Int
count a as = length $ filter (== a) as

put :: Show a => a -> IO ()
put = putStr . show

putList :: Show a => [a] -> IO ()
putList [n     ] = put n
putList (n : ns) = do
  put n
  putStr " "
  putList ns

putStrList :: [String] -> IO ()
putStrList [n     ] = putStr n
putStrList (n : ns) = do
  putStr n
  putStr " "
  putStrList ns

yesNoUpper b | b         = putStrLn "YES"
             | otherwise = putStrLn "NO"

yesNo b | b         = putStrLn "Yes"
        | otherwise = putStrLn "No"

main = do
  [a, b] <- readInt
  putStrLn $ f a b

f a b | a == b    = "Draw"
      | a == 1    = "Alice"
      | b == 1    = "Bob"
      | a > b     = "Alice"
      | otherwise = "Bob"


Measured memory_bytes: 380
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<algorithm>
#include<list>
#include<cmath>
#include<iomanip>
#include<queue>
#include<functional>
#include<climits>
#include<iterator>
#include<unordered_map>

using namespace std;

const double pi=4*atan(1.0);

int mod=1000000007;

int main() {
	int n,m;
	cin>>n>>m;
	vector<int> Coins(m);
	for(auto& val:Coins)
		cin>>val;

	sort(begin(Coins),end(Coins));

	vector<int> dp(n+1,INT_MAX);
	dp[0]=0;
	for(int i=1;i<n+1;++i){
		for(int j=0;j<m;++j){
			if(i>=Coins[j]){
				dp[i]=min(dp[i],dp[i-Coins[j]]+1);
			}
		}
	}

	cout<<dp[n]<<endl;

	//system("pause");
	return 0;
}

Measured memory_bytes: 3192
import java.util.Arrays;

public class Main {
  private static void solve() {
    char[] s = ns();
    System.out.println(Arrays.copyOf(s, s.length - 8));
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}




Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int g[5][5];
void kill()
{
	cout << "Yes";
	exit(0);
}
void check(vector<int> &a, vector<int>&b)
{
	for (int i = 0; i < 3; i++)
		for (int j = 0; j < 3; j++)
			if (g[i + 1][j + 1] != a[i] + b[j])
				return;
	kill();
}
void solve(int a1, int b1)
{
	vector<int> a(3), b(3);
	a[0] = a1, b[0] = b1;
	a[1] = g[2][1] - g[1][1] + a1;
	a[2] = g[3][1] - g[1][1] + a1;
	b[1] = g[1][2] - g[1][1] + b1;
	b[2] = g[1][3] - g[1][1] + b1;
	check(a, b);
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	for (int i = 0; i < 3; i++)
		for (int j = 0; j < 3; j++)
			cin >> g[i + 1][j + 1];
	for (int i = 0; i <= 100; i++)
		for (int j = 0; j <= 100; j++)
			solve(i, j);
	cout << "No";
	return 0;
}


Measured memory_bytes: 256
n = int(input())
S = []
ans = ''
for i in range(n):
	s = list(input())
	S.append(s)


S[0].sort()

for i in range(len(S[0])):
	if n == 1:
		ans = ''.join(S[0])
	a = S[0][i]
	l = 0
	for j in range(n - 1):
		if a in S[j + 1]:
			S[j + 1].remove(a)
			l += 1
		if l == n - 1:
			ans += a


print(ans)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;

int main() {
	long long N, D[100000], ANS = 1, MOD = 998244353;
	map<long long, long long> mp;
	cin >> N;
	for (int i = 0; i < N; i++) cin >> D[i], mp[D[i]]++;
	if (D[0] != 0) {
		cout << 0 << endl;
		return 0;
	}
	if (mp[0] != 1) {
		cout << 0 << endl;
		return 0;
	}
	for (auto it = mp.begin(); it != mp.end(); it++) {
		if (it->first == 0) continue;
		for (int i = 0; i < it->second; i++) {
			ANS *= mp[it->first - 1];
			ANS %= MOD;
		}
	}
	cout << ANS << endl;
}

Measured memory_bytes: 7552
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ll n;
	ll m =20;
	cin>>n;
  	if(n==1)
    {
      cout<<1<<"\n";
      return 0;
    }
      
	for(int i=1;i<=sqrtl(n);i++)
	{
		if(n%i==0)
		{
			ll j=n/i;
			if(j%10==0)
				j += 10;
			if(i%10==0)
				i += 10;
			ll k = (ll)max(ceil((log(i))/log(10)),ceil((log(j))/log(10)));
			if(k<m)
				m=k; 
		}
	}
	cout<<m<<"\n";
}

Measured memory_bytes: 3840
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ld = long double;
// constexpr auto mod = 1000000007;
using namespace std;

int main() {
  string w;
  cin >> w;
  set<char> s;
  multiset<char> ms;
  for (const auto &c : w) {
    s.emplace(c);
    ms.emplace(c);
  }
  cout << (all_of(ALL(s), [&ms](const char &c) { return ms.count(c) % 2 == 0; })
               ? "Yes"
               : "No")
       << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
void call(int n){
	for(int i = 1;++i<=n;){
		int x = i;
		if ( x % 3 == 0 ){
			printf(" %d",i);
		}
		else{
			while(x){
				if ( x % 10 == 3 ){
					printf(" %d",i);
					break;
				}
				x /= 10;
			}
		}
	}
	putchar('\n');
}

int main(){
	int buf;
	scanf("%d",&buf);
	call(buf);
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
const ll INF=1e9+7;
const ll N = 300003;

ll n,ans=0,wa,xo;
vector<ll> a;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;a.resize(n);
	FOR(i,0,n)cin>>a[i];
	ll r=0,l=1;
	wa = a[0];
	xo = a[0];
	while(l<n+1){
		while( (wa+a[l]) == (xo^a[l]) && l<n){
			wa += a[l];
			xo = xo ^ a[l];
			l++;
			if(l==n)break;
		}
		ans += l-r;
		wa -= a[r];
		xo = xo ^ a[r];
		r++;
		if(r==l){
			l++;
			xo=wa=a[r];
		}
	}
	pri(ans);
	return 0;
}


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

int main()
{
   int n,k;
   cin >> n >> k;
   vector<int> p(n);
   for (int i=0;i<n;++i) cin >> p[i];
   sort(p.begin(),p.end());
   int sum=0;
   for (int i=0;i<k;++i){
     sum+=p[i];
   }
   cout << sum << endl;
}

Measured memory_bytes: 3632