akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

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

        int n = sc.nextInt();
        int x = sc.nextInt();

        if(x == 0){
            System.out.println("0 0 0");
            sc.close();
            System.exit(0);
        }

        for(int i = 0; i <= n; i++){
            for(int j = 0; j <= n - i; j++){
                if(10000*i + 5000*j + 1000*(n - i - j) == x){
                    System.out.println(i + " " + j + " " + (n - i - j));
                    sc.close();
                    System.exit(0);
                }
            }
        }

        System.out.println("-1 -1 -1");
        sc.close();
    }
}

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

int main() {
  int a,b;cin>>a>>b;
  for(int i=1;i<2000;i++){
    if(i*8/100==a&&i*10/100==b){
      cout<<i<<endl;
      return 0;
    }
  }
  cout<<-1<<endl;
}

Measured memory_bytes: 3620
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int N = scan.nextInt();
        int numOfOdd = (int) Math.ceil(N/2.0);
        os.println(numOfOdd/ (double) N);
    }
}

Measured memory_bytes: 21844
import Control.Monad
import Data.List
main = do
  n <- read <$> getLine
  v <- forM [1..n] $ \i -> do
    a <- read <$> getLine
    forM [1..a] $ \j -> do
      [x,y] <- map read . words <$> getLine
      return (x,y)
  print $ maximum $ length <$> filter (o v) (subsequences [1..n])
o s k = and [(y == 0) /= (x `elem` k) | i <- k,(x,y) <- s !! (i-1)]


Measured memory_bytes: 4968
#include<stdio.h>

int main(void)
{
    int i, x; 

    i = 0;

    do{
	scanf("%d", &x);
	if(x > 0){
	    i++;
	    printf("Case %d: %d\n", i, x);
	}
    }while(x > 0);
    
    return 0;
}

Measured memory_bytes: 600
const input = require("fs").readFileSync("/dev/stdin", "utf8")

;(input => {

    const lines = input.split('\n')
    const [L, R, d] = lines[0].split(" ").map(Number)

    let count = 0;
    for (let i = L; i <= R; i++) {
        if (i % d === 0) count++
    }

    console.log(count)

})(input)


Measured memory_bytes: 29692
N = int(input())
M = list(map(int, input().split()))
U = list(map(int, input().split()))

ans = 0
for i in range(N):
    m = M[i] + M[i + 1] - U[i]
    if m > 0:
        ans += U[i]
        M[i + 1] = min(m, M[i + 1])
    else:
        ans += M[i] + M[i + 1]
        M[i + 1] = 0

print(ans)


Measured memory_bytes: 18468
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

N, M = mi()
ks = []
for i in range(M):
    a = li()
    ks.append(a)
P = li()

cnt = 0
for i in range(2**N):
    x = bin(i)[2:].zfill(N)
    l = list(map(int, list(x)))
    flag = 1
    for i in range(M):
        num , *switchs = ks[i]
        if sum([l[sw-1] for sw in switchs]) % 2 != P[i]:
            flag = 0
            break
    if flag:
        cnt += 1

print(cnt)

Measured memory_bytes: 3064
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    vector<vector<char>>g(2,vector<char>(3));
    rep(i,2)rep(j,3)cin>>g[i][j];
    if(g[0][0]==g[1][2]&&g[0][1]==g[1][1]&&g[0][2]==g[1][0])return puts("YES")*0;
    else
        cout<<"NO"<<endl;
}


Measured memory_bytes: 256
N = gets.to_i
S = gets.chomp!.split('')

higasi_ruiseki = [0]
nisi_ruiseki  = [0]
S.each do |c|
  if c == 'E'
    higasi_ruiseki << higasi_ruiseki.last + 1
    nisi_ruiseki << nisi_ruiseki.last
  else
    nisi_ruiseki << nisi_ruiseki.last + 1
    higasi_ruiseki << higasi_ruiseki.last
  end
end

ans = Float::INFINITY

N.times do |i|
  gyaku = 0
  gyaku += nisi_ruiseki[i]
  gyaku += higasi_ruiseki[N] - higasi_ruiseki[i + 1]
  if ans > gyaku
    ans = gyaku
  end
end

puts  ans


Measured memory_bytes: 33924
s = input()
ans = True

if 'N' in s and not('S' in s) or 'S' in s and not('N' in s):
    ans = False
if 'E' in s and not('W' in s) or 'W' in s and not('E' in s):
    ans = False
if ans:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9104
#include<cstdio>
#include<algorithm>
#include<utility>
#include<vector>
#include<math.h>

using namespace std;

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

typedef long long int ll;

int f(ll a, ll b){
  int dignum_a,dignum_b;
  REP(i,10){
    if(a/pow(10,i)>=1) dignum_a=i+1;
    if(b/pow(10,i)>=1) dignum_b=i+1;
  }
  return min(dignum_a,dignum_b);
}

int main(){
  ll n,j;
  scanf("%lld",&n);
  int sqn;
  sqn = (int)sqrt((double)n);
  for(int i=sqn;i>0;i--){
    if(n%i==0){
      j=n/i;
      printf("%d",f(n,j));
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=(a);i<(b);i++)
#define fore(i,a,b) for(int i=(a);i<=(b);i++)
#define pb push_back
#define F first
#define S second
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
void amin(ll &a, ll b){ a=min(a,b); }
void amax(ll &a, ll b){ a=max(a,b); }
void SD(int t=0){ cout<<"PASSED "<<t<<endl; }
const ll INF = ll(1e18);
const int MOD = 1e9+7;

ll add(ll a,ll b)
{
	a%=MOD; b%=MOD;
	a+=b;a%=MOD;
	if(a<0) a+=MOD;
	return a;
}

const int MAXN = 100005;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	int n,m; cin>>n>>m;
	set<int> s;
	forn(i,0,m){ int x; cin>>x; s.insert(x); }
	
	ll dp[n+1]{};
	dp[0]=1;
	fore(i,1,n){
		if(s.count(i)) continue;
		dp[i]=add(dp[i-1],dp[i]);
		if(i-2>=0) dp[i]=add(dp[i-2],dp[i]);
	}
	
	cout<<dp[n]<<'\n';
	
	return 0;
}


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

int main(){
    int a,b,c,d,e,max; cin >> a >> b;
    c = a+b;
    d = a-b;
    e = a*b;
    if(c > d){
        max = c;
        if(max < e){
            max = e;
        }
    }else{
        max = d;
        if(max < e){
            max = e;
        }
    }
    cout << max << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <stdlib.h>

using namespace std;

int n;
int h[100005];
int dp[100005];

int main(void)
{
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> h[i];
	
	for(int i = 1; i <= n; i++) dp[i] = 1e9+5;
	dp[1] = 0;
	for(int i = 1; i < n; i++){
		dp[i+1] = min(dp[i+1], dp[i] + abs(h[i]-h[i+1]));
		if(i+2 <= n) dp[i+2] = min(dp[i+2], dp[i] + abs(h[i]-h[i+2]));
	}
	cout << dp[n] << endl;
	
	return 0;
}

Measured memory_bytes: 1024
n=int(input())
info=[input().split() for i in range(n)]

A=[[['',0,0,0,0,0,0,0,0,0,0] for i in range(3)]for j in range(4)]

for new in info:
    A[int(new[0])-1][int(new[1])-1][int(new[2])]+=int(new[3])

for j in range(4):
    for k in A[j]:
        print(*k)
    if j < 3:print('#'*20)


Measured memory_bytes: 5624
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF = 1e9;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll s;
    cin >> s;
    ll x1 = 0, y1 = 0, x2 = INF, y2 = 1;
    ll x3 = (INF - s%INF) % INF;
    ll y3 = (s + x3) / INF;
    cout << x1 << " " << y1 << " " << x2 << " " << y2 << " " << x3 << " " << y3 << endl;
    return 0;
}

Measured memory_bytes: 3568
// When you are hungry for something and you're determined and you're focused 
// and you're committed to something it's hard to surrender, isn't it?

#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define ll long long 
#define int ll
#define mod 1000000007
#define mod1 1000000006
#define modi 998244353
#define setbit(x) __builtin_popcount(x)
#define fff(i,n) for(int i=0;i<n;i++)
#define ff first
#define ss second
#define pb push_back
vector<ll> vi[300005];
int color[100005];
ll pa[500005];
ll si[500005];
#define pb push_back
bool visi[1000005]={false};
bool is[100005];
ll fac[10000001];
ll prime[400005];
ll bit[100005];
const long double eps = 1.0e-14;      // allowable error
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
 
 
void fact(){
    fac[0]=1;
    for(int i=1;i<=10000000;i++){
        fac[i]=(fac[i-1]*i)%mod;
    }
    return ;
}
void sieve(){
    prime[0]=0;
    prime[1]=0;
    for(int i=2;i<400005;i++){
        prime[i]=1;
    }
    for(int i=2;i*i<400005;i++){
        if(prime[i]==1){
            for(int j=i*i;j<400005;j+=i){
                prime[j]=0;
            }
        }
    }
    
}
 
ll power(ll n , ll p ){
    if(p==0)
        return 1;
    
    ll res = power((n*n)%mod,p/2);
    if(p%2==1)
        res = (n*res)%mod;
    
    return res;
}
 
 
void upd(ll i,ll val,ll n) {
    for(;i<=n;i+=i&(-i))
        bit[i]+=val;
}
 
ll qry(ll i) {
    ll sum=0;
    for(;i>0;i-=i&(-i))
        sum+=bit[i];
    return sum;
}
 
 
ll fin(ll u) {
    if(pa[u]==u)
        return u;
    return fin(pa[u]);
}
 
void uni(ll u,ll v) {
    ll p1=fin(u);
    ll p2=fin(v);
    if(p1==p2)
        return;
    if(si[p1]<si[p2])
        swap(p1,p2);
    si[p1]+=si[p2];
    pa[p2]=p1;
    return;
}
 
int32_t main() {
    fio
    
    string s;
    cin >> s;
    int n=s.size();
    int c=0;
    
    int i=0,j=n-1;
    while(i<=j) {
        if(s[i]!=s[j])
        c++;
        i++,j--;
    }
    cout << c ;
    
	return 0;
    
}

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

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

  for (int i = 0; i < S.size(); i++) {
      if(S==T) {
        puts("Yes");
        return 0;
      }
      S = S.back()+S;
      S.pop_back();
  }
  puts("No");
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>

#include <iostream>

int main() {
	int a, b;
	std::cin >> a >> b;
	int d = a / b;
	int r = a % b;
	double aa, bb, f;
	aa = a;
	bb = b;
	f = aa / bb;
	std::cout << d << " " << r << " ";
	printf("%f", f);
	return 0;
}

Measured memory_bytes: 3220
#include<iostream>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<string>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
using namespace std;
#define ll long long
#define inf 0x3f3f3f3f3f3f3f3f
#define mod 1000000009
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define max 100010
int n;
vector<pair<int ,int> >G[max];
bool visit[max];
ll d[max];
void dijkstra(int k)
{
	memset(visit,false,sizeof(visit));
	for(int i=1;i<=n;i++)
		d[i]=inf;
	priority_queue<pair<int ,int> >PQ;
	d[k]=0;
	visit[k]=true;
	PQ.push(make_pair(0,k));
	while(!PQ.empty())
	{
		pair<int ,int>f=PQ.top();
		PQ.pop();
		int u=f.second;
		visit[u]=true;
		if(d[u]<f.first*(-1))
			continue;
		for(int j=0;j<G[u].size();j++)
		{
			int v=G[u][j].first;
			if(visit[v]==true)
				continue;
			if(d[v]>d[u]+G[u][j].second)
			{
				d[v]=d[u]+G[u][j].second;
				PQ.push(make_pair(d[v]*(-1),v));
			}
		}
	}
}
int main()
{
	//freopen("Text.txt","r",stdin);
	int u,v,c,q,k;
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		scanf("%d%d%d",&u,&v,&c);
		G[u].push_back(make_pair(v,c));
		G[v].push_back(make_pair(u,c));
	}
	scanf("%d%d",&q,&k);
	dijkstra(k);
	for(int i=1;i<=q;i++)
	{
		scanf("%d%d",&u,&v);
		printf("%lld\n",d[u]+d[v]);
	}
	return 0;
}

Measured memory_bytes: 8948
import java.util.* ;
class Main {
  public static void main(String[] args) {
    
    Scanner scan = new Scanner(System.in);
  	String s = scan.next() ;
    char ch[] = s.toCharArray() ;
    ArrayList<Character> a = new ArrayList<>();
    int count = 0 ;
    for(int i = 0 ; i <3 ;i++){
      if(!a.contains(ch[i])){
        a.add(ch[i]);
      }
    }
    if(a.size() !=3){
      System.out.println("No");
    }else{
      System.out.println("Yes");
    }
  }
}


Measured memory_bytes: 22740
a,b,k = map(int,input().split())
for i in range(k):
    if i%2==0:
        if a%2==1:
            a-=1
        c =a//2
        b+=c
        a-=c
    else:
        if b%2==1:
            b-=1
        c =b//2
        a+=c
        b-=c
print(a,b)

Measured memory_bytes: 9176
N = int(input())
S = [input() for i in range(N)]

from collections import Counter

s = Counter(S)

k = s.most_common()

maxc = k[0][1]

l = []
for i in k:
    if i[1]<maxc:
        break
    else:
        l.append(i[0])

print(*sorted(l), sep="\n")

Measured memory_bytes: 50124
#include <stdio.h>
#include <iostream>
#include <set>
#include <vector>
#include <map>
using namespace std;

int main() {

  std::map<string, int> mp; 

  int n;
  cin >> n;

  for (int i = 0; i < n; i++) {
    string com, tango;
    cin >> com >> tango;

    if (com == "insert") {
      mp[tango] = 1;
    } else if (com == "find") {
      if (mp[tango] == 1) {
        cout << "yes" << endl;
      } else {
        cout << "no" << endl;
      }
    }

  }

}


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

int main() {
    int n;
    string s;
    cin >> n >> s;
    rep(i, s.size()) {
        s[i] = s[i] + n;
        if(s[i] > 'Z') {
            s[i] = s[i] - 26;
        }
    }

    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3624
using System;

namespace abc123_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = new string[5];
            int[] num = new int[5];
            for (int i = 0; i < num.Length; ++i)
            {
                input[i] = Console.ReadLine();
                num[i] = int.Parse(input[i]);
            }
            //int[] abcde = Enumerable.Range(1, 5).Select(_ => Console.ReadLine()).Select(x => int.Parse(x)).ToArray();

            int difference = int.Parse(Console.ReadLine());

            int result = 0;
            int NG = 0;
            for (int i = 0; i < num.Length; ++i)
            {
                if (NG != 0) break;
                for (int j = (i + 1); j < num.Length; ++j)
                {
                    if (Math.Abs(result = num[i] - num[j]) > difference)
                    {
                        ++NG;
                        break;
                    }
                }
            }

            if (NG == 0) Console.WriteLine("Yay!");
            else Console.WriteLine(":(");
        }
    }
}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = 1001002003004005006ll;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b, c;
	cin >> a >> b >> c;
	if (c >= a && c <= b) puts("Yes");
	else puts("No");
	return 0;
}

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

using namespace std;

vector <int> v;
map <int, int> m;

int main() {
	int N, H;
	scanf("%d %d", &N, &H);
	for (int i = 0; i < N; i++) {
		int x, y;
		scanf("%d %d", &x, &y);
		v.push_back(x);
		v.push_back(y);
		m[x]++;
	}
	sort(v.begin(), v.end());
	int ans = 0, cur = 0;
	for (int i = v.size() - 1; i >= 0; i--) {
		cur += v[i];
		ans++;
		if (cur >= H) {
			printf("%d\n", ans);
			return 0;
		}
		if (m.count(v[i]) > 0) {
			while(true) {
				cur += v[i];
				ans++;
				if (cur >= H) {
					printf("%d\n", ans);
					return 0;
				}
			}
		}
	}
	printf("-1 -1 -1\n");
	return 0;	
}

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

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define eb emplace_back

typedef unsigned long long ll;
typedef long double ld;

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

	ll a, b; cin >> a >> b;
	
	if (a > b) {
		swap(a, b);
	}
	
	if ((b-a)%2 != 0) {
		cout << "IMPOSSIBLE" << endl;
	} else {
		cout << a + ((b-a)/2) << endl;
	}
		
	
}


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

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


Measured memory_bytes: 3096
import collections
n = int(input())
# w = list(map(int, input().split()))
#n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
# data = [list(map(int, input().split())) for i in range(n)]
q = int(input())
#p = list(map(int, input().split()))
#a = list(map(int, input().split()))
# ab_sorted = sorted(ab, key=lambda x: x[0])
bc = [list(map(int, input().split())) for i in range(q)]
# print(min(15*n, 100*(n//10+1), 100*(n//10)+15*(n % 10)))
a_count = collections.Counter(a)
a_list = dict(list(a_count.items()))
#print(a_list)
total = sum(a)
for b, c in bc:
    if b in a_list:
        total += (c-b)*a_list[b]
        num = a_list[b]
        a_list[b] = 0
        if c in a_list:
            a_list[c] += num
        else:
            a_list[c] = num
            
    print(total)


Measured memory_bytes: 43236
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

using Graph = vector<vector<ll>>;

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

#define MAX_N 2010

const long long INF = 1LL << 60;

//境界値に注意！！！

int main() {
    ll x,ans=1;
    cin >> x;
    for (ll i=2;i<=x;i++){
        ll a=i;
        if (i*a>x)continue;
        while (i*a<=x){
            a*=i;
        }
        ans=max(ans,a);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>

#define INF 1000000001
#define LINF 1000000000000000001

using namespace std;

typedef long long Int;
typedef pair<Int, Int> P;

Int gcd(Int x, Int y){
	if(y == 0)
		return x;
	return gcd(y, x % y);
}

Int lcm(Int x, Int y){
	return x * y / gcd(x, y);
}

int n, a[100001], c[100001] = {0};

int main(){
	cin >> n;
	int cnt = 0;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		if(a[i] > n)
			cnt++;
		else
			c[a[i]]++;
	}
	for(int i = 1; i <= n; i++){
		if(c[i] != i && c[i] != 0){
			if(c[i] > i){
				cnt += c[i]-i;
			}
			else
				cnt += c[i];
		}
	}
	cout << cnt << endl;
	
	return 0;
}

Measured memory_bytes: 640
#include <math.h>

#include <algorithm>
#include <iostream>
#include <vector>
using ll = long long;
#define rep(inc, bgn, end) for (int inc = bgn; inc < end; ++inc)
#define repe(inc, bgn, end) for (int inc = bgn; inc <= end; ++inc)
#include <queue>

using namespace std;
#define INF 1001001001

struct load {
    int from;
    int to;
};
int main() {
    int n, m;
    cin >> n >> m;
    // vector<load> maze(m);

    // vector<vector<bool>> maze(n, vector<bool>(n, false));
    // queue<int> room;

    struct room {
        // int load;
        vector<int> load;
        int light;
        int idx;
        int len = INF;
    };

    vector<room> maze(n);
    rep(i, 0, n) {
        maze[i].idx = i;
    }
    rep(i, 0, m) {
        // printf("%d\n", i);
        // cin >> maze[i].from >> maze[i].to;
        int a, b;
        cin >> a >> b;
        // maze[--a][--b] = true;
        // maze[b][a]     = true;
        maze[--a].load.push_back(--b);
        maze[b].load.push_back(a);
    }
    maze[0].len = 0;
    // vector<bool> vis(n, false);
    // room.push(0);

    // vector<int> light(n);
    // vector<int> len(n);
    // int len = 0;
    queue<room> vis;
    vis.push(maze[0]);
    while (!vis.empty()) {
        room crr = vis.front();
        vis.pop();
        // vis[crr] = true;
        // rep(next, 0, n) {
        // printf("search: %d", crr.idx);
        for (int next : crr.load) {
            // printf("  search: %d", next);
            if (maze[next].len > crr.len + 1) {
                maze[next].len   = crr.len + 1;
                maze[next].light = crr.idx;
                vis.push(maze[next]);
                // if (maze[crr][next]) {
                //     if (!vis[next]) {
                //         room.push(next);
                //         light[next] = crr;
                //     }
            }
        }
    }

    cout << "Yes" << endl;
    rep(i, 1, n) {
        cout << maze[i].light + 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 18584
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



ll L,R;
ll POW[61];
ll dp[65][2][2][2];


int main(){

	POW[0] = 1;
	for(int i = 1; i <= 60; i++){

		POW[i] = POW[i-1]*2;
	}

	scanf("%lld %lld",&L,&R);

	for(int i = 0; i <= 60; i++){
		for(int a = 0; a < 2; a++){
			for(int b = 0; b < 2; b++){
				for(int c = 0; c < 2; c++){
					dp[i][a][b][c] = 0;
				}
			}
		}
	}

	dp[60][0][0][0] = 1;

	for(int i = 59; i >= 0; i--){

		ll lb = L>>i&1;
		ll rb = R>>i&1;

		for(int a = 0; a < 2; a++){
			for(int b = 0; b < 2; b++){
				for(int c = 0; c < 2; c++){

					ll pre = dp[i+1][a][b][c];

					for(ll x = 0; x < 2; x++){
						for(ll y = 0; y < 2; y++){
							if(x == 1 && y == 0)continue;

							ll next_a = a,next_b = b,next_c = c;

							if(c == 0 && x != y)continue;
							if(x & y)next_c = 1;

							if(!a && !x && lb)continue;
							if(!b && y && !rb)continue;
							if(x && !lb)next_a = 1;
							if(!y && rb)next_b = 1;

							dp[i][next_a][next_b][next_c] += pre;
							dp[i][next_a][next_b][next_c] %= MOD;
						}
					}
				}
			}
		}
	}

	ll ans = 0;
	for(int a = 0; a < 2; a++){
		for(int b = 0; b < 2; b++){
			for(int c = 0; c < 2; c++){

				ans += dp[0][a][b][c];
				ans %= MOD;
			}
		}
	}

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

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int dp[8001][16001];
int a[8001];
int main()
{
	string s;
	cin>>s;
	int x,y,i,j;
	cin>>x>>y;
	int k=0;
	int w=0;
	for(i=0;i<s.size();i++)
	{
		if(s[i]=='T')
		{
			k++;
			a[k]=w;
			w=0;
		}
		else
		{
			w++;
		}
	}
	k++;
	a[k]=w;
	dp[1][a[1]+8000]=1;
	for(i=3;i<=k;i+=2)
	{
		for(j=0;j<=16000;j++)
		{
			if(j+a[i]<=16000)
			{
				dp[i][j]=dp[i-2][j+a[i]];
			}
			if(j-a[i]>=0)
			{
				dp[i][j]=dp[i][j]||dp[i-2][j-a[i]];
			}
		}
	}
	dp[0][8000]=1;
	for(i=2;i<=k;i+=2)
	{
		for(j=0;j<=16000;j++)
		{
			if(j+a[i]<=16000)
			{
				dp[i][j]=dp[i-2][j+a[i]];
			}
			if(j-a[i]>=0)
			{
				dp[i][j]=dp[i][j]||dp[i-2][j-a[i]];
			}
		}
	}
	int ans;
	if(k%2==0)
	{
		ans=dp[k][y+8000]&&dp[k-1][x+8000];
	}
	else
	{
		ans=dp[k][x+8000]&&dp[k-1][y+8000];
	}
	cout<<(ans==0?"No":"Yes");
	return 0;
}

Measured memory_bytes: 497792
def main():
    H, W = map(int, input().split())
    N = int(input())
    A = tuple(map(int, input().split()))

    m = [[0 for i in range(W)] for j in range(H)]
    a = []
    j = 1
    for i in A:
        for _ in range(i):
            a.append(j)
        j += 1

    i = 0
    for h in range(H):
        for w in range(W):
            m[h][w] = a[i]
            i += 1

    flag = 1
    for c in m:
        if flag == -1:
            print(*c[::-1])
        else:
            print(*c)
        flag *= -1

main()


Measured memory_bytes: 3956
import java.util.*;

public class Main{
  public Main(){}
  
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    String[] tokens = scanner.nextLine().split(" +");
    
 	int m = Integer.parseInt(tokens[0]);
    int n = Integer.parseInt(tokens[1]);
    
    for(int i=0; i<n+1; i++){
      System.out.print("#");
    }
    System.out.println("#");
    
    while(scanner.hasNext()){
    	System.out.print("#");
    	System.out.print(scanner.nextLine().trim());
    	System.out.println("#");
    }
    
    for(int i=0; i<n+1; i++){
      System.out.print("#");
    }
    System.out.println("#");
  }
}

Measured memory_bytes: 22612
#include<iostream>
#define H 1401

using namespace std;

int ans[H][H];

int main(){
    int maxlen=0;
    int h,w;
    cin>>h>>w;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>ans[i][j];
            ans[i][j]=1-ans[i][j];
            maxlen=max(maxlen,ans[i][j]);
        }
    }

    for(int i=1;i<h;i++){
        for(int j=1;j<w;j++){
            if(ans[i][j]==0) continue;
            ans[i][j]=min(ans[i-1][j-1],min(ans[i-1][j],ans[i][j-1]))+1;
            maxlen=max(maxlen,ans[i][j]);
        }
    }

    cout<<maxlen*maxlen<<endl;
    return 0;

}



Measured memory_bytes: 10752
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const long long LINF = 1000000000000000018ll;
const int INF = 1000000009;
const int mod = 1000000007;
const int mod2 = 998244353;

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

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::cout << std::setprecision(20) << std::fixed;

  int N;
  cin >> N;

  int cnt[100005] = {0};
  for (int x = 1; x <= 102; x++) {
    for (int y = 1; y <= 102; y++) {
      for (int z = 1; z <= 102; z++) {
        cnt[x * x + y * y + z * z + x * y + y * z + z * x]++;
      }
    }
  }

  for (int i = 1; i <= N; i++) {
    cout << cnt[i] << "\n";
  }
  return 0;
}

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

int main(){
  int N, M;
  cin >> N;
  map<string,int> m;
  vector<string> s(N);
  for(int i=0; i<N; i++){
    cin >> s.at(i);
    m[s.at(i)]++;
  }
  cin >> M;
  vector<string> t(M);
  for(int i=0; i<M; i++){
    cin >> t.at(i);
    m[t.at(i)]--;
  }
  int ans = 0;
  for(string S: s){
    ans=max(ans,m[S]);
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 3600
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define N 3001
vector<vector<int> > dp(N, vector<int> (N));
//vector<vector<string> > ans(N, vector<string> (N));
void fn(string &s, string &t, int n1, int n2){
    for(int i=0;i<=n1;i++) dp[i][n2]= 0;//, ans[i][n2]="";
    for(int j=0;j<=n2;j++) dp[n1][j]=0;//, ans[n1][j]="";
    
    string q;
    for(int i=n1-1;i>=0;i--){
        for(int j= n2-1;j>=0;j--){
            if(s[i]==t[j])
            {
                dp[i][j]= 1+ dp[i+1][j+1];
               // ans[i][j]=s[i]+ ans[i+1][j+1];
            }
            else
            {dp[i][j]= max(dp[i+1][j], dp[i][j+1]);
           // ans[i][j]= ans[i+1][j].size()>=ans[i][j+1].size()?ans[i+1][j]:ans[i][j+1];
                
            }
        }
    }
    //return q;
}

int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    
    string s,t;
    cin>>s>>t;
    fn(s,t,s.size(), t.size());  
    /*for(int i=0;i<s.size();i++){
        for(int j=0;j<t.size();j++) cout<<dp[i][j]<<" ";
        cout<<endl;
    }*/
    
    
    
    
  int i=0,j=0;
    string p="";
    while(i<s.size() && j<t.size()){
        if(dp[i][j]==dp[i+1][j]) i++;
       else if(dp[i][j]== dp[i][j+1]) j++;
        else  {
            p+=s[i];
            i++;
            j++;
        }
    }
    cout<<p<<endl;
     
    
    
    
    
    
}

Measured memory_bytes: 35584
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.io.BufferedOutputStream;
import java.util.function.LongPredicate;
import java.util.function.Predicate;
import java.util.List;
import java.io.*;
import java.util.*;
import java.io.PrintWriter;

public class Main {
    public static void main(final String[] args) {
    	Scanner scanner = new Scanner(System.in);
    	int[][] a = new int[3][3];
    	for (int i = 0; i < a.length; i++) {
			for(int j=0;j<a[i].length;j++) {
				a[i][j] = scanner.nextInt();
			}
		}
    	boolean[][] b = new boolean[3][3];
    	int n = scanner.nextInt();
    	List<Integer> list = new ArrayList<>();
    	for(int i=0;i<n;i++) {
    		list.add(scanner.nextInt());
    	}
    	for(int i=0;i<3;i++) {
    		for(int j=0;j<3;j++) {
    			b[i][j] = list.contains(a[i][j]) ? true: false;
    		}
    	}

    	boolean flag = false;
    	for(int i=0;i<3;i++) {
    		if (b[i][0] && b[i][1] && b[i][2]) flag = true;
    	}
    	for(int i=0;i<3;i++) {
    		if (b[0][i] && b[1][i] && b[2][i]) flag = true;
    	}
    	if (b[0][0] && b[1][1] && b[2][2]) flag = true;
    	if (b[2][0] && b[1][1] && b[0][2]) flag = true;
    	
    	if (flag) {
    		System.out.println("Yes");
    	}else {
    		System.out.println("No");
    	}
    }
}


Measured memory_bytes: 23764
#include<stdio.h>

int main(void) {
	int X, Y, a;
	scanf("%d%d", &X, &Y);

	for (a = 0; a <= X; a++) {
		if (2 * a + 4 * (X - a) == Y) {
			printf("Yes");
return 0;
		}
		}
printf("No");
	return 0;
}


Measured memory_bytes: 1732
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

X, Y = get_ints

puts X + Y/2


Measured memory_bytes: 14356
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())


#define MOD 998244353



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

	int n;
	cin >> n;
	map<int, int> mp;
	rep(i,n) {
		int d;
		cin >> d;

		if ((i==0 && d) || (i && d == 0)) {
			cout << 0 << endl;
			return 0;
		}
		++mp[d];
	}

	long long ans = 1;
	int prev_f = -1;
	int prev_s = 1;


	for (auto p : mp) {
		if (prev_f + 1 != p.first) {
			ans = 0;
			break;
		}
		rep(i, p.second) {
			ans *= prev_s;
			ans %= MOD;
		}

		prev_f = p.first;
		prev_s = p.second;
	}
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 4992
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Library;
using static Library.Input;

namespace AtCoderTemplate
{
    class ProgramA
    {
        static void Main()
        {
            var s = Line;
            if (Enumerable.Range(0, 3).Any(i => s[i] == s[i + 1]))
            {
                System.Console.WriteLine("Bad");
            }
            else
            {
                System.Console.WriteLine("Good");
            }
        }
    }
}

namespace Library
{
    class Input
    {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line => Console.ReadLine();

        public static string[] StrArr => Line.Split(' ');

        public static int NextInt => int.Parse(NextWord());

        public static long NextLong => long.Parse(NextWord());

        public static List<int> IntList => StrArr.Select(int.Parse).ToList();

        public static List<long> LongList => StrArr.Select(long.Parse).ToList();

        public static IEnumerable<long[]> TakeLine(int N)
        {
            return Enumerable.Repeat(0, N).Select(_ => Console.ReadLine().Split(' ').Select(long.Parse).ToArray());
        }

        public static string NextWord()
        {
            while (!enumerator.MoveNext())
            {
                enumerator = StrArr.AsEnumerable().GetEnumerator();
            }
            return enumerator.Current;
        }
    }
}


Measured memory_bytes: 13268
package main

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

const mod = 1000000007

// 1MB
const ioBufferSize = 1 * 1024 * 1024

var sc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	sc.Split(bufio.ScanWords)
	return sc
}()

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func abs(a int) int {
	if a < 0 {
		return -a
	}

	return a
}

func main() {
	n := nextInt()
	h := make([]int, n)

	for i := 0; i < n; i++ {
		h[i] = nextInt()
	}

	m := 0
	for i := 0; i < n; i++ {
		c := 0
		for i < n-1 && h[i] >= h[i+1] {
			i++
			c++
		}

		if m < c {
			m = c
		}
	}

	fmt.Println(m)
}


Measured memory_bytes: 4096
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}


signed main(void) {
    int n;
    cin >> n;
    vi v(n),c(n);
    rep(i,n)cin >> v[i];
    rep(i,n)cin >> c[i];
    vi a(n);
    rep(i,n)a[i] = v[i]-c[i];
    sort(all(a));
    int ans = 0;
    rep(i,n){
        if(a[i] > 0)ans += a[i];
    }
    cout << ans << endl;
}


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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

int main() {
    int n; double avg;
    cin>>n;
    vector<int> a(n);
    rep(i,0,n){
        cin>>a[i];
        avg+=a[i];
    }
    avg/=n;

    int ans=0;
    rep(i,0,n){
        if(abs(a[ans]-avg)>abs(a[i]-avg)){ans=i;}
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3628
N = gets.strip.to_i
a = gets.strip.split.map(&:to_i)

number_parted_a = a.map {|x| (x/400).to_i }.sort
legends, without_legends = number_parted_a.partition {|x| x>7 }

colored_count = without_legends.group_by {|x| x }.length
legend_count = legends.length

min = [colored_count, 1].max
max = colored_count + legend_count

puts [min, max].join(' ')


Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define ll          long long
#define pll         vector< pair<ll ,ll> >
#define vll         vector<ll>
#define vi          vector<int>
#define hell        1000000007
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define pb          push_back
#define F           first
#define S           second
#define mp          make_pair
#define all(v)      v.begin(), v.end()
#define lb          lower_bound  //value not less than(>=)
#define ub          upper_bound  //value greater than(>)
#define bs          binary_search
#define pcont(v)    for(auto it:v) cout<<it<<" ";cout<<endl
#define ret(x)      return cout << x,0;
#define pi          pair<ll,pair<ll,ll> >
int const MAX = 1e5 + 5;
using namespace std;

ll cnt(ll n)
{
    ll c=0;
    while(n%2==0)
    {
        c++;
        n/=2;
    }
    return c;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
    ll n;
    cin >> n;
    ll a[n];
    rep(i,0,n) cin >> a[i];
    ll ans=0;

   // cout << cnt(5);
    rep(i,0,n)
    {
        ans+=cnt(a[i]);
    }
    cout << ans;
}


Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>

//#include<bits/stdc++.h>


using namespace std;

int main() {
	
	int n, m, k;
	cin >> n >> m >> k;
	if (m - n == k - m)cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;
typedef long long ll;

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

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

#define Cins(T, n, xs) \
  vector<T> xs(n);     \
  for (int i = 0; i < n; ++i) cin >> xs[i]

void Main() {
  Cin(int, n, x);
  Cins(int, n, ls);

  int d = 0;
  int ans = 1;
  for (int i = 0; i < n; ++i) {
    d = d + ls[i];
    if (d <= x) ans++;
  }

  cout << ans << endl;
}

int main() {
  cout << fixed << setprecision(15);
  Main();
  return 0;
}

Measured memory_bytes: 256
local function meld(a,b)
    if not a then
        return b
    elseif not b then
        return a
    elseif a[1]<b[1] then
        b[4]=a[3]
        a[3]=b
        return a
    else
        a[4]=b[3]
        b[3]=a
        return b
    end
end

local function pair(a)
    local b,c,d,e
    while a do
        c=false
        b=a
        a=a[4]
        b[4]=false
        if a then
            c=a
            a=a[4]   
            c[4]=false
        end
        b=meld(b,c)
        b[4]=d
        d=b
    end
    while d do
        e=d
        d=d[4]
        a=meld(a,e)
    end
    return a
end


local PairingHeap={}

PairingHeap.empty=function(self)
    return not self[1]
end

PairingHeap.push=function(self,key,value)
    self[1]=meld(self[1],{key,value,false,false})
end

PairingHeap.top=function(self)
    return self[1][2]
end

PairingHeap.pop=function(self)
    self[1]=pair(self[1][3])
end

PairingHeap.join=function(self,other)
    if self[1][1]<other[1][1]then
		other[1][4]=self[1][3]
        self[1][3]=other[1]
	else
		self[1][4]=other[1][3]
        other[1][3]=self[1]
        self[1]=other[1]
    end
    return self
end

PairingHeap.new=function(self)
    local obj={}
    setmetatable(obj,{__index=PairingHeap})
    return obj
end

----------
 
local n,d,a=io.read("n","n","n")
local pq=PairingHeap:new()
for i=1,n do
    local x,h=io.read("n","n")
    pq:push(x,{x,h,0})
end
 
local atack=0
local total=0
while not pq:empty() do
    local pop=pq:top()
    local x,h,c=pop[1],pop[2],pop[3]
    pq:pop()
    if c==0 then
        if atack*a<h then
            h=h-atack*a
            local count=math.floor((h-1)/a)+1
            pq:push(x+2*d+0.5,{x+2*d,count,1})
            total=total+count
            atack=atack+count
        end
    else
        atack=atack-h
    end
end
print(string.format("%d",total))

Measured memory_bytes: 55688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, c = 0, z = 0;
    string s;
    cin >> n >> s;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'I') c++;
        else c--;
        z = max(z, c);
    }
    cout << z;
}


Measured memory_bytes: 256
n = int(input())
s = [input() for _ in range(n)]

ans = 0
a = 0
for b in range(n):
    flag = 0
    for i in range(n):
        if flag == 1:
            break
        for j in range(n):
            if s[(i+a)%n][(j+b)%n] != s[(j+a)%n][(i+b)%n]:
                flag = 1
                break
    else:
        ans += n

print(ans)

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

using namespace std;

#define FastIO ios_base :: sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define read(in) freopen("Input.txt","r",stdin)
#define write(out) freopen("Ouput.txt","w",stdout)
#define pf printf
#define sf scanf
#define fr0(i,n) for(int i=0 ; i<n ; i++)
#define fr1(i,n) for(int i=1 ; i<=n ; i++)
#define fr2(i,n) for(int i=n ; i>=1 ; i--)
#define frx(i,x,n) for(int i=x ; i<=n ; i++)
#define sf1(val) scanf("%lld",&val)
#define sf2(val1,val2) scanf("%lld %lld",&val1,&val2)
#define INF 999999999999999999
#define Pi 2*acos(0.0)
#define len 200000

typedef long long int lli;

lli a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,sum=0,total=0,res=0,ans=0;

int main()
{
    //FastIO;

    //read(in);

    sf2(t,d);
    
    fr1(i,t)
    {
    	double ans=0.0;
    	
    	sf2(x,y);	if(x<0)	x*=(-1);	if(y<0)	y*=(-1);
    	
    	ans=sqrt(x*x+y*y);		if(ans<=d)	sum++;
    }
    pf("%lld\n",sum);
}

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

int main(){
  ll n,ans=0; cin >>n;
  for(ll i = 2, m=n; i*i<=m;i++){
    ll z = i;
    while(n%z==0){
      ans++;
      n/=z;
      z*=i;
    }
    while(n%i==0) n/=i;
  }
  cout << ans + (n!=1) << endl;
  return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)


void solve(long long A, long long B){
  if (A>9 || B>9) cout<<"-1"<<endl;
  else cout<<A*B<<endl;
}

int main(){
  long long A;
  scanf("%lld",&A);
  long long B;
  scanf("%lld",&B);
  solve(A, B);
  return 0;
}


Measured memory_bytes: 256
def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

n, k = map(int, input().split(' '))

x = Base_10_to_n(n, k)
print(len(str(x)))


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

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)
#define rep1(i,n) rep(i,1,n+1)
#define repR(i,s,n) for(ll i = (n-1); i >= (s); i--)
#define repR0(i,n) repR(i,0,n)
#define repR1(i,n) repR(i,1,n+1)

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;
#define fcout cout << fixed << setprecision(18)

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

int a[100];
int cells[100][100]; // r * c

ll GCD(ll x, ll y) {
  if (y == 0) return x;
  else return GCD(y, x % y);
}

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

  vector<ll> A(N);
  rep0(i, N) cin >> A[i];

  ll ans = A[0];
  rep0(i, N) {
    ans = ans * A[i] / GCD(ans, A[i]);
  }

  cout << ans << BR;
  return 0;
}


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

int main()
{
	/*#ifndef ONLINE_JUDGE
		freopen("in.txt","r",stdin);
		freopen("out.txt","w",stdout);
	#endif*/
	ios_base::sync_with_stdio(false);
   	cin.tie(NULL);

   	ll N; cin >> N;
   	vector<ll> pesos(N);
   	ll sum = 0;
   	for (int i = 0; i < N; ++i)
   	{
   		ll peso; cin >> peso;
   		pesos[i] = peso;
   		sum += peso;
   	}

   	//sort(pesos.begin(), pesos.end());
   	ll a=pesos[0] ,b = sum-pesos[0];
   	sum = abs(b-a);
   	for (int i = 1; i < N-1; ++i)
   	{
   		a += pesos[i];
   		b -= pesos[i];
   		ll nsum = abs(a-b);
   		if (sum > nsum)
   		{
   			sum = nsum;
   		}
   	}
   	cout << sum << endl;



	return 0;	
}

Measured memory_bytes: 256
n, a, b = map(int, input().split())
mod = 10 ** 9 + 7

if n == 2:
    print(0)
    exit()

ans = pow(2, n, mod)
ans -= 1


def cmb(r, mod):
    if r<0:
        return 0
    return g1[r-1] * g2[r] % mod

mod = 10**9+7 #出力の制限
N = 2 * 10 ** 5
g1 = [n % mod] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブ

for i in range( 2, N + 1 ):
    g1.append((g1[-1] * (n - i + 1)) % mod)
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

ans -= cmb(a, mod)
ans -= cmb(b, mod)
ans %= mod

print(ans)


Measured memory_bytes: 27112
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string.h>
#include<string>
#include<set>
#include<limits.h>
#define int long long
using namespace std;

signed main() {
	int a; cin >> a;
	int n = a;
	int b = 0;
	while (a) {
		b += a % 10;
		a /= 10;
	}
	if (n%b == 0)puts("Yes");
	else puts("No");
}

Measured memory_bytes: 256