akhauriyash/Code-Regression huggingface dataset:
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

//macro
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define EPS (1e-8)
#define equals(a,b)(fabs((a)-(b))<EPS)

using ll = long long;
using ull = unsigned long long;
using vb = vector<bool>;
using vi = vector<int>;
using vll = vector<ll>;
using vs = vector<string>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vvll = vector<vll>;
//func
template<typename A, typename T>void assign2d(A&arr, ll H, ll W, T t) { arr.resize(H); REP(i, H) arr[i].assign(W, t); }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); REP(i, n)os << v[i] << (i == n - 1 ? "" : " "); return os; }
template <class T = int> inline T IN() { T x; cin >> x; return x; }
template<class T> inline void OUT(const T &x) { cout << x << "\n"; }
void YESNO(bool c) { OUT(c ? "YES" : "NO"); };
void YesNo(bool c) { OUT(c ? "Yes" : "No"); };
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); /*cout << fixed << setprecision(6);*/ } } pre__;

int main() {
	int X, A, B;
	cin >> X >> A >> B;
	X -= A;
	OUT(X%B);
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		int X = F, A = F, B = F;
		WriteLine((X - A) % B);
	}
}


Measured memory_bytes: 13140
#include <cstdio>
#include <iostream>
#include <cstring>
#include <vector>
#include <queue>
#include <algorithm>
#include <list>
using namespace std;
#define MS0(I) memset(I, 0, sizeof(I));
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, s, n) for(int i = (s); i < (n); ++i)
#define MAX 10
typedef long long LL;
typedef unsigned long long ULL;
int m[MAX][MAX], s[10];
int main(void){
    int n, k; scanf("%d%d", &n, &k);
    rep(i, 10) rep(j, 10) scanf("%d", &m[i][j]);
    rep(i, 10) rep(j, 10) rep(k, 10) m[j][k] = min(m[j][k], m[j][i] + m[i][k]);
    
    rep(i, n) rep(j, k){
        int in;
        scanf("%d", &in);
        if(in != -1) s[in]++;
    }
    int ret = 0;
    rep(i, 10) ret += s[i]*m[i][1]; 
    printf("%d", ret);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
double pi = 2 * acos(0.0);
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int r;
    cin >> r;
    cout << fixed << setprecision(12) << 2 * pi * r;
    return 0;
}


Measured memory_bytes: 3776
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n;
  cin >> n;
  string s = to_string(n);
  ll sum = 0;
  for(int i = 0;i < s.size();i++)sum += s[i] - '0';
  if(n % sum == 0)cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3668
#include<iostream>
using namespace std;
int main(){
	int a,b,c,d,e,s;
	cin>>a>>b>>c>>d>>e;

	if(a<0){
		s=(a*(-1)*c)+d+(b*e);
	}
	else if(a==0){
		s=d+((b-a)*e);
	}
	else{
	s=((b-a)*e);
	}

	cout<<s<<endl;

	return 0;
}




Measured memory_bytes: 3104
#include<stdio.h>

int main(void){

	int h,w;
	int i,j;

	while(scanf("%d %d",&h,&w)!=EOF){

		if(h==0 && w==0)
			break;

		for(i=0;i<h;i++){
			for(j=0;j<w;j++)
				printf("#");

			puts("");
		}
		puts("");

	}

	return 0;

}

Measured memory_bytes: 588
X, Y = map(int, input().split())

b = (Y - 2*X)/2
a = X - b

is_int = (a.is_integer() and b.is_integer())
is_positive = (a >= 0 and b >= 0)
if is_int and is_positive and (a + b) == X and (2*a + 4*b) == Y:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9120
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
int32_t main()
{
	#ifndef ONLINE_JUDGE
	freopen("in","r",stdin);
	freopen("out","w",stdout);
	#endif

	int a,b,c,d;
	cin>>a>>b>>c>>d;

	int cd=(c*d)/__gcd(c,d);


	int l,r,cc,dd,cdd;
	l=((a+c-1)/c)*c; r=(b/c)*c;
	cc=max(0LL, (r-l+c)/c);
	l=((a+d-1)/d)*d;r=(b/d)*d;
	dd=max(0LL,(r-l+d)/d);
	l=((a+cd-1)/cd)*cd;r=(b/cd)*cd;
	cdd=max(0LL,(r-l+cd)/cd);
	int tot=b-a+1;


	int div=cc+dd - cdd;
	cout<<tot-div;
	
}

Measured memory_bytes: 3636
# https://atcoder.jp/contests/keyence2020/tasks/keyence2020_b


class Robot(object):
    def __init__(self, data):
        self.x = int(data[0])
        self.l = int(data[1])
        self.low = self.x - self.l
        self.high = self.x + self.l

    def contain(self, other):
        return self.low < other.low < self.high or self.low < other.high < self.high or self.low < other.x < self.high

    def __str__(self):
        return "(x=%d, l=%d)" % (self.x, self.l)


def main():
    n = int(input())
    robots = [Robot(input().split(" ")) for _ in range(n)]
    robots.sort(key=lambda robo: robo.high)
    count = 1
    available = robots[0]
    for i in range(1, n):
        if robots[i].low >= available.high:
            available = robots[i]
            count += 1
    print(count)


if __name__ == '__main__':
    main()


Measured memory_bytes: 44256
def main():
    N, K = map(int, input().split())
    ans = 0
    if K % 2 == 1:
        ans = (N // K) ** 3
    else:
        ans = (N // K) ** 3
        r = K // 2
        ans += len([1 for v in range(1, N+1) if v % K == r]) ** 3
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 70736
# https://atcoder.jp/contests/abc065/tasks/arc076_a
# C - Reconciled?
import math

# (n+m) C (m)
# 犬同士と猿同士が隣り合わないようにする

N, M = list(map(int, input().split()))
mod = 10 ** 9 + 7

# 個体は識別されてる
if abs(N-M) <= 1:
    dog_p = math.factorial(N)
    monky_p = math.factorial(M)
    work = ((dog_p % mod) * (monky_p % mod)) % mod

    if N != M:
        ans = work
    else:
        ans = ((work % mod) * (2 % mod)) % mod
else:
    # 全匹並べられない
    ans = 0

print(ans)


Measured memory_bytes: 4368
//Bismillah Hir Rehmanir Rahim
//Allah knows best
using namespace std;
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#define endl "\n"
#define mini -10000000000000000
#define start ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define f(i, a, n) for( i=a; i<n;i++)
#define ll long long
#define pi 3.141592653589793
#define vi              vector<int>
#define si              set<int>
#define pb              push_back
#define mp              make_pair
#define mod             1000000007
#define rr              return 0
#define ff              first
#define in              insert
#define ss              second
#define setbits(x)      __builtin_popcountll(x)
#define zrbits(x)       __builtin_ctzll(x)
#define deb(x)          cout << #x << " = " << x << endl
ll mx=1000000;
ll pr[1000000];
/*void sieve()
{
    ll i,j,n,m;
    pr[0]=1;
    pr[1]=1;
    for(i=2;i*i<=mx;i++)
    {
        if(pr[i]==0)
        {
            for(j=i*2;j<=mx;j++)
                pr[j]=1;
        }
    }
}
void SieveOfEratosthenes(ll n, bool prime[],
                         bool primesquare[], ll a[])
{
    for (ll i = 2; i <= n; i++)
        prime[i] = true;
    for (ll i = 0; i <= (n * n + 1); i++)
        primesquare[i] = false;
    prime[1] = false;
    for (ll p = 2; p * p <= n; p++) {
        if (prime[p] == true) {
            for (ll i = p * 2; i <= n; i += p)
                prime[i] = false;
        }
    }
    ll j = 0;
    for (ll p = 2; p <= n; p++) {
        if (prime[p]) {
            a[j] = p;
            primesquare[p * p] = true;
            j++;
        }
    }
}
ll countDivisors(ll n)
{
    if (n == 1)
        return 1;
    bool prime[n + 1], primesquare[n * n + 1];
    ll a[n];
    SieveOfEratosthenes(n, prime, primesquare, a);
    ll ans = 1;
    for (ll i = 0;; i++) {
        if (a[i] * a[i] * a[i] > n)
            break;
        ll cnt = 1;
        while (n % a[i] == 0)
        {
            n = n / a[i];
            cnt = cnt + 1;
        }
        ans = ans * cnt;
    }
    if (prime[n])
        ans = ans * 2;
    else if (primesquare[n])
        ans = ans * 3;
    else if (n != 1)
        ans = ans * 4;
    return ans;
}*/
int main()
{
    //freopen("in.txt","r",stdin);
    start;
    ll i,j,k,n,m;
   cin>>n;
   ll cnt=0,c=0,ans=0;
   //sieve();
   for(i=1;i<n;i++)
   {
       /*if(pr[i]==1)
       {
         ll a,b;
         for(j=1;j*j<=i;j++)
         {
             if(i%j==0)
             {
                 a=j;
                 b=i/j;
                 if(a==b)
                    cnt++;
                 else cnt+=2;
             }
         }
       }
       else
        c+=2;*/
        j=1;
        while(i*j<n)
        {
            j++;
            cnt++;
        }
   }
   ans=cnt;
   cout<<ans<<endl;
    rr;
}


Measured memory_bytes: 3636
abcd = input()
symbol = ["+", "-"]
list_cand = [(i, j, k) for i in symbol for j in symbol for k in symbol]
for cand in list_cand:
  temp_str = abcd[0] + cand[0] + abcd[1] + cand[1] + abcd[2] + cand[2] + abcd[3]
  if eval(temp_str) == 7:
    print(temp_str + "=7")
    exit()

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

template<class M, class N>
constexpr common_type_t<M, N> gcd(M a, N b){
	if(a < b){
		common_type_t<M, N> tmp = a;
		a = b;
		b = tmp;
	}
	if(b==0) return a;
	else return gcd(b, a%b);
}

template<class M, class N>
constexpr common_type_t<M, N> lcm(M a, N b){
	if(a==0 || b==0) return 0;
	return a*b / gcd(a, b);
}

int main(void){
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    long long tmp1 = b / c - (a-1) / c;
    long long tmp2 = b / d - (a-1) / d;
    long long tmp3 = b / lcm(c,d) - (a-1) / lcm(c,d);
    long long ans = tmp1 + tmp2 - tmp3;
    cout << (b-a+1-ans) << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	long long int x,y;
	scanf("%lld %lld",&x,&y);
	
	if(x==0||y==0){
		if(x>0){
			printf("%lld\n",x+1);
		}else if(y>0){
			printf("%lld\n",y);
		}else if(x<0){
			printf("%lld\n",-x);
		}else{
			printf("%lld\n",-y+1);
		}
	}else if(x<0 && y<0){
		if(y-x>0){
			printf("%lld\n",y-x);
		}else{
			printf("%lld\n",-y+x+2);
		}
	}else if(x>0 && y<0){
		if(-y>x){
			printf("%lld\n",-y-x+1);
		}else{
			printf("%lld\n",y+x+1);
		}
	}else if(x<0 && y>0){
		if(y>-x){
			printf("%lld\n",y+x+1);
		}else{
			printf("%lld\n",-y-x+1);
		}
	}else if(x>0 && y>0){
		if(y>x){
			printf("%lld\n",y-x);
		}else{
			printf("%lld\n",-y+x+2);
		}
	}
	
	return 0;
}

Measured memory_bytes: 128
const main = (input) => {
  const args = input.split('\n')
  const n = Number(args[0])
  let ac = 0
  let wa = 0
  let tle = 0
  let re = 0
  for (let i = 0; i < n; i++) {
    if (args[i + 1] === 'AC') {
      ac++
    }
    else if (args[i + 1] === 'WA') {
      wa++
    }
    else if(args[i+1] === 'TLE') {
      tle++
    }
    else if(args[i+1] === 'RE') {
      re++
    }
  }
  console.log(`AC x ${ac}`)
  console.log(`WA x ${wa}`)
  console.log(`TLE x ${tle}`)
  console.log(`RE x ${re}`)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 37268
#include <bits/stdc++.h>
#define LL long long
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
using namespace std;
typedef pair<int,int>pii;
int n,m;
int ans=0;
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		int x;
		cin>>x;
		x=abs(x-m);
		ans=__gcd(ans,x);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#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;};

using vec = vector<ll>;
using vvec = vector<vec>;
using vvvec = vector<vvec>;

int main(){
    int H, W, N;
    cin >> H >> W >> N;
    vvec c(H, vec(W, 0));
    rep(i, N){
        int x, y; ll v;
        cin >> x >> y >> v;
        x--, y--;
        c[x][y] = v;
    }
    vvvec dp(H, vvec(W, vec(4, 0)));
    int dx[] = {1, 0}, dy[] = {0, 1};
    rep(i, H){
        rep(j, W){
            rep(k, 4){
                rep(m, 2){
                    int ni = i+dx[m], nj = j+dy[m];
                    if(ni >= H || nj >= W) continue;
                    rep(n, 2){
                        if(k+n > 3) continue;
                        int nk;
                        if(m == 0) nk = 0;
                        else nk = k+n;
                        ll add = c[i][j]*n;
                        chmax(dp[ni][nj][nk], dp[i][j][k]+add);
                    }
                }
            }
        }
    }
    ll ans = 0;
    rep(k, 4){
        chmax(ans, dp[H-1][W-1][k] + (k < 3? c[H-1][W-1] : 0));
    }
    cout << ans << endl;
}

Measured memory_bytes: 706644
n = int(input())
t_list = [int(input()) for _ in range(n)]


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd(a, b)


lcm_now = 1
for t in t_list:
    lcm_now = lcm(lcm_now, t)
print(lcm_now)


Measured memory_bytes: 3060
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using E = System.Linq.Enumerable;
 
class Program
 {
        static void Main(string[] args)
        {
          //N,Mの入力を受け取る
          var Today = Console.ReadLine();
          if(Today == "Sunny"){
            Console.WriteLine("Cloudy"); 
          }else if (Today == "Cloudy"){
            Console.WriteLine("Rainy"); 
          }else{
            Console.WriteLine("Sunny"); 
          }
        }
 }
 


Measured memory_bytes: 11092
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <random>

using namespace std;


int main()
{
	int A,B;
	int ans = 0;

	cin >> A >> B;

	if (A + B > A - B){
		ans = A + B;
	}else{
		ans = A - B;
	}

	if ( ans < A * B){
		ans = A * B;
	}

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


	return 0;
}



Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#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(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define DUMP(x) cout<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;

class DWorstCase {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int Q;
	    in>>Q;
	    REP(i, Q){
	        lint A, B;
	        in>>A>>B;
	        if(A>B) swap(A, B);
	        if(B<=A+1) out<<2*A-2<<'\n';
	        else{
	            lint left = A - 1, right = B + 1;
	            while(1<right-left){
	                lint mid = (left+right) / 2;
	                if(mid*mid<A*B) left = mid;
	                else right = mid;
	            }
	            if(A*B<=(left)*(left+1)) out<<2*left-2<<'\n';
	            else out<<2*left-1<<'\n';
	        }
	    }
	}
};


int main() {
	DWorstCase solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <string>
#include <vector>
#define rep(i, s, n) for (int i = s; i < (n); i++)
#define ll long long int
using namespace std;

int main(void) {
  string S, T;
  cin >> S >> T;
  
  for (int i = 0; i < S.length(); i ++) {
    if (S[i]!= T[i]) {
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");
  
  return 0;
}



Measured memory_bytes: 3116
import random
import numpy as np

def is_prime(q,k=50):
    # q = abs(q)
    #計算するまでもなく判定できるものははじく
    if q == 2: return 1
    if q < 2 or q&1 == 0: return 0

    #n-1=2^s*dとし（但しaは整数、dは奇数)、dを求める
    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1
    
    #判定をk回繰り返す
    for i in range(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        #[0,s-1]の範囲すべてをチェック
        while t != q-1 and y != 1 and y != q-1: 
            y = pow(y,2,q)
            t <<= 1
        if y != q-1 and t&1 == 0:
            return 0
    return 1
  
chk = np.array([0]*10**5)
for i in range(10**5):
  chk[i] = is_prime(i+1,15)
  
ans = np.array([0]*10**5)
for i in range(2,10**5):
  ans[i] = chk[i]&chk[(i+1)//2]
np.cumsum(ans,out=ans)

import sys
input = sys.stdin.readline
q = int(input())
for i in range(q):
  l,s = map(int,input().split())
  print(ans[s-1]-ans[max(0,l-2)])

Measured memory_bytes: 17304
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

#include <vector>
using namespace std;

template<class Monoid, class Operation>
struct segment_tree {
  int n;
  Monoid ide;
  vector<Monoid> node;
  Operation ope;
  segment_tree(int sz,Monoid ide, Operation ope) 
    : ide(ide), ope(ope){
      init(vector<Monoid>(sz, ide));
  }
  segment_tree(const vector<Monoid>& ini, Monoid ide, Operation ope) 
    : ide(ide), ope(ope) {
      init(ini);
  }
  void init(const vector<Monoid>& ini) {
    n = 1;
    while(n < ini.size()) n <<= 1;
    node.resize(n * 2 - 1);
    for(int i = 0;i < ini.size();i++)
      node[i + n - 1] = ini[i];
    for(int i = n - 2;i >= 0;i--) 
      node[i] = ope(node[i * 2 + 1], node[i * 2 + 2]);
  }
  void update(int i, Monoid x) {
    i += n - 1;
    node[i] = x;
    while(i > 0) {
      i = (i - 1) / 2;
      node[i] = ope(node[i * 2 + 1], node[i * 2 + 2]);
    }
  }
  Monoid get(int i) {
    return node[i + n - 1];
  }
  Monoid get(int a,int b,int k = 0,int l = 0 ,int r = -1) {
    if(r < 0) r = n;
    if(a <= l && r <= b) return node[k];
    if(b <= l || r <= a) return ide;
    return ope(get(a,b,k * 2 + 1,l, (l + r) / 2),get(a,b,k * 2 + 2, (l + r) / 2 , r));
  }
};

i64 N;
vector<i64> a;

int main() {
  cin >> N;
  a.resize(N);
  rep(i,0,N - 1) cin >> a[i];
  i64 ok = 0;
  i64 ng = N;
  auto func = [](i64 a, i64 b) { return a + b; };

  vector<i64> b = a;
  sort(all(b));

  while(ng - ok > 1) {
    i64 mid = (ok + ng) / 2;
    segment_tree<i64, decltype(func)> seg(202020,0,func);
    seg.update(101010, 1);
    i64 now = 0;
    i64 ans = 0;
    for(int i = 0;i < N;i++) {
      if(a[i] < b[mid]) now--;
      else now++;
      ans += seg.get(0, 101010 + now + 1);
      seg.update(101010 + now, seg.get(101010 + now) + 1);
    }
    if(N * (N + 1) / 2 - ans < N * (N + 1) / 4 + 1) ok = mid;
    else ng = mid;
  }

  cout << b[ok] << endl;
}


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

#define NREP() for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(),(x).end()
#define MSG(x) cout << x << endl;
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
using ll = long long;
const static ll MOD = 1e9 + 7;

int main(int argc, char *argv[]) {
    ll n;
    cin >> n;

    map<ll, ll> m;

    NREP() {
        ll tmp;
        cin >> tmp;
        m[tmp] += 1;
    }

    ll ans = 0;
    for (auto & itr : m) {
        if (itr.first == itr.second) continue;

        if (itr.second > itr.first) {
            ans += itr.second - itr.first;
        } else {
            ans += itr.second;
        }
    }

    MSG(ans)
}





Measured memory_bytes: 6272
import sys
stdin = sys.stdin
def ls(): return stdin.readline()
S = ls()
first, second = int(S[:2]), int(S[2:])
def is_my(f, s):
    return 0 < f < 13

def is_ym(f, s):
    return 0 < s < 13
ym, my = is_ym(first,second), is_my(first, second)
if ym and my:
    print("AMBIGUOUS")
elif ym and not my:
    print("YYMM")
elif my and not ym:
    print("MMYY")
else:
    print("NA")


Measured memory_bytes: 3060
def ABC079D():
    H, W = map(int, input().split())
    c = [list(map(int, input().split())) for i in range(10)]
    A = [list(map(int, input().split())) for i in range(H)]
    #c = csgraph.floyd_warshall(c, False)
    for k in range(10):
        for i in range(10):
            for j in range(10):
                c[i][j] = min(c[i][j], c[i][k] + c[k][j])
    #print(c)
    ans = 0
    for i in A:
        for j in i:
            if j != -1 and j != 1:
                ans += c[j][1]
                #print(c[j][1], j)
    print(int(ans))
ABC079D()

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

#define REP(i,n)for (int i=0;i<(n);i++)
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ll long long
using namespace std;
typedef pair<int,int> P;
int main(){
	int n;
	cin>>n;
	if(n%10==9||n/10==9){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}


Measured memory_bytes: 256
S = list(input())
T = list(input())
ans = 0
for i in range(len(S)-len(T)+1):
    ans_pre = 0
    for j in range(len(T)):
        if T[j] == S[i+j]:
            ans_pre += 1
    ans = max(ans, ans_pre)
    
print(len(T) - ans)

Measured memory_bytes: 9120
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
typedef long long ll;
#define repp(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
long long modpow(long long a,long long n,long long p)
{
    if(n==1)
    {
        return a%p;
    }
    if(n%2==1)
    {
        return a*modpow(a,n-1,p)%p;
    }
    long long t = modpow(a,n/2,p);
    return t*t%p;
}


int main()
{
    /*A
    int a,b;
    cin>>a>>b;

    if(a<=5)
    {
        cout<<0<<endl;
    }
    else if(a>=13)
    {
        cout<<b<<endl;
    }
    else
    {
        cout<<b/2<<endl;
    }
    */
    /*B
    int r,d,a;
    cin>>r>>d>>a;
    int b[11];
    for(int i=1;i<=10;i++)
    {
        if(i==1)
        {
            b[i]=r*a-d;
        }
        else
        {
            b[i]=r*b[i-1]-d;
        }
    }

    for(int i=1;i<=10;i++)
    {
        cout<<b[i]<<endl;
    }
    */
    int n,m;
    cin>>n>>m;
    int L[m],R[m];
    for(int i=0;i<m;i++)
    {
        cin>>L[i]>>R[i];
    }

    int maxL = 1;
    int minR = n;
    for(int i=0;i<m;i++)
    {
        maxL =max(maxL,L[i]);
    }

    for(int i=0;i<m;i++)
    {
        minR =min(minR,R[i]);
    }
    
    
    if(maxL>minR)
    {
        cout<<0<<endl;
    }
    else
    {
        cout<<minR-maxL+1<<endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define INF 100000000000
#define mod 1000000007
#define pll pair<long,long>
#define se second
#define fi first
#define pb push_back
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef tree<pll,null_type,less<pll>,rb_tree_tag,tree_order_statistics_node_update>pllordered_set;

set<pair<ll,ll> > s;
vector<ll> g[10005];
vector<ll> deg(10005);

int main()
{
			ios_base::sync_with_stdio(false);
			cin.tie(NULL);
			ll n;
			cin>>n;
			vector<pll> edge;
			for(ll i=1;i<n;i++)
			{
				ll x,y;
				cin>>x>>y;
				edge.pb({x,y});
				g[x].pb(y);
				g[y].pb(x);
				deg[x]++;
				deg[y]++;
			}
			vector<ll> c(n);
			for(ll i=0;i<n;i++)
			{
				cin>>c[i];
			}
			for(ll i=1;i<=n;i++)
			{
				s.insert({deg[i],i});
			}
			sort(c.begin(),c.end());
			ll idx=0;
			vector<ll> ans(10005,0);
			vector<ll> vis(10005,0);
			ll res=0;
			while(!s.empty())
			{
				pll x=*s.begin();
				ans[x.se]=c[idx];
				vis[x.se]=1;
				idx++;
				s.erase(s.find({deg[x.se],x.se}));
				for(auto i:g[x.se])
				{
					if(!vis[i]){
						s.erase(s.find({deg[i],i}));
						deg[i]--;
						s.insert({deg[i],i});
					}
					
				} 
				
			}
			for(auto i:edge)
			{
				res+=min(ans[i.fi],ans[i.se]);
			}
			cout<<res<<endl;
			for(ll i=1;i<=n;i++)
				cout<<ans[i]<<" ";
			
			
			
}


Measured memory_bytes: 2044
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 1e2 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	double ans = 0;
	cin >> n;
	while (n--)
	{
		int x;
		cin >> x;
		ans += 1.0 / x;
	}
	printf("%.15f\n", 1.0 / ans);
	return 0;
}

Measured memory_bytes: 256
from itertools import permutations, product
from collections import defaultdict
from heapq import heappop, heappush

N, M, R = map(int, input().split())
r = [int(x) for x in input().split()]
abc = [[int(x) for x in input().split()] for _ in range(M)]


class Graph(object):
    def __init__(self):
        self.graph = defaultdict(list)

    def __len__(self):
        return len(self.graph)

    def add_edge(self, src, dst, weight=1):
        self.graph[src].append((dst, weight))

    def get_nodes(self):
        return self.graph.keys()


class Dijkstra(object):
    def __init__(self, graph, start):
        g = graph.graph

        self.dist = defaultdict(lambda: float('inf'))
        self.dist[start] = 0
        self.prev = defaultdict(lambda: None)

        Q = []
        heappush(Q, (self.dist[start], start))

        while Q:
            dist_u, u = heappop(Q)
            if self.dist[u] < dist_u:
                continue
            for v, weight in g[u]:
                alt = dist_u + weight
                if self.dist[v] > alt:
                    self.dist[v] = alt
                    self.prev[v] = u
                    heappush(Q, (alt, v))

    def shortest_distance(self, goal):
        return self.dist[goal]

    def shortest_path(self, goal):
        path = []
        node = goal
        while node is not None:
            path.append(node)
            node = self.prev[node]
        return path[::-1]


g = Graph()
for a, b, c in abc:
    g.add_edge(a - 1, b - 1, c)
    g.add_edge(b - 1, a - 1, c)

D = dict()
for ri in r:
    D[ri - 1] = Dijkstra(g, ri - 1)

ans = float('inf')
for route in permutations(r):
    d = 0
    for i in range(R - 1):
        s = route[i] - 1
        g = route[i + 1] - 1
        d += int(D[s].shortest_distance(g))
    ans = min(ans, d)
print(ans)

Measured memory_bytes: 9548
//#pragma once
#include <stdio.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <numeric>
#include<bitset>

using namespace std;
#define modd 1000000007
#define moda 1000003


typedef pair<long long, long long> pl;



#define ll long long




/*
class UnionFind {
public:
	vector <ll> par; 
	vector <ll> siz;
	vector <ll> gr;

	// Constructor
	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) ,gr(sz_){
		for (ll i = 0; i < sz_; ++i) par[i] = i; 
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;

		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}



	bool issame(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}

	ll size(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}


};*/


long long N, M, K, a, b, c, d,e, H, W;
long long A[200005] = {};
long long B[200005] = {};
long long C[200005] = {};
ll X[2][51] = {};
ll Y[2][51] = {};
ll sx, sy, ex, ey;
bool f, ff,fff;
string S[100];
set <long long>sll;
pl bufpl;
vector <long long>vl[100005];
vector <pl>vpl[20];
vector <string> vs[20];
set<ll> llset;

struct ST
{
	long long Kati;
	int bangou;

	bool operator<(const ST& another) const
	{
		return Kati < another.Kati;//比較
	};

};



vector <ST> vst;
ST st[200005];
ST bufst;
string bufS;

bitset<5000> bits;

int main() {


	while (true) {
		cin >> N;
		if (N == 0) {
			break;
		}

		for (int i = 0; i < N; i++) {
			cin >> S[i];
			a = 0;
			for (int j = 0; j < S[i].size(); j++) {
				if (S[i][j] == '.') {
					a++;
				}
				else {
					if (S[i][j] == '*') {

					}

				}
			}


		}

		if (N == 1) {
			cout <<S[0][0]-'0'<<endl;
		}

		for (int i = N - 1; i >= 0; i--) {

			a = 0;
			for (int j = 0; j < S[i].size(); j++) {
				if (S[i][j] == '.') {
					a++;
				}
				else {
					if (S[i][j] == '*') {
						b = 1;
						for (int i = 0; i < vl[a + 1].size(); i++) {
							b *= vl[a + 1][i];
						}

						if (a > 0) {
							vl[a].push_back(b);
						}
						else {
							cout << b << endl;
						}
						vl[a + 1].clear();
					}
					else if (S[i][j] == '+') {
						b = 0;
						for (int i = 0; i < vl[a + 1].size(); i++) {
							b += vl[a + 1][i];
						}
						if (a > 0) {
							vl[a].push_back(b);
						}
						else {
							cout << b << endl;
						}

						vl[a + 1].clear();
					}
					else {
						vl[a].push_back(S[i][j] - '0');
					}

				}
			}


		}
		S[0] = "";
		for (int i = 1; i < 100; i++) {
			S[i] = S[0];
		}


	}

	
	return 0;

}



Measured memory_bytes: 5504
N,M=[int(x) for x in input().split()]
num_list = [None]*N
error = False
for y in range(M):
    s_,c = input().split()
    s = int(s_)
    if s == 1 and c == '0' and N > 1:
        error = True
    elif num_list[s-1] is not None and num_list[s-1]!=c:
        error = True
    else:
        num_list[s-1] = c
    #print(num_list)

if error:
    print('-1')
else:
    for y in range(N):
        if num_list[y] is None:
            if y==0 and N >1:
                num_list[y] = '1'   
            else:
                num_list[y] = '0'

    number = ''.join(num_list)
    print(number)

Measured memory_bytes: 38256
#ifndef LOCAL
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define sim template < class c
#define int long long
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << '\n'; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef tree< pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 2e5 + 10 ;
const ll INF = 1e18 + 10 ;
int lcm(int a, int b){
    return a / __gcd(a, b) * b ;
}
signed main(){
    fastio
    int a , b ;
    cin >> a >> b ; 
    cout << lcm(a, b) << endl;
    return 0; 
}

Measured memory_bytes: 3596
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
vector<int> edge[100001];
bool used[100001];


int main(int argc, char const* argv[])
{
  int n, m;
  cin >> n >> m;
  for(int i = 0; i < m; i++){
    int a, b;
    cin >> a >> b;
    a--; b--;
    edge[a].pb(b);
    edge[b].pb(a);
  }
  for(int i = 0; i < n; i++){
    if(edge[i].size() % 2 != 0){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
	return 0;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
#include <regex>
#ifdef _DEBUG
#include "debug.h"
#endif
#define int ll
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define all(v) (v).begin(),(v).end()
#define mkpr make_pair
#define mktp make_tuple
#define tv(tp, i) get<(i)>(tp)
#define CLEAR(obj) obj = decltype(obj)()
#define var auto
#define OUT(type) type &
#define IN(type) const type &
#define self (*this)
#define in :
#define True true
#define False false
using namespace std; using int32 = int32_t; using str = string; using cstr = const str;
using ll = long long; using ull = unsigned long long; using cint = const int; using cll = const ll;
using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>;
using vb = vector<bool>; using vvb = vector<vb>; using vd = vector<double>; using vvd = vector<vd>;
using vc = vector<char>; using vvc = vector<vc>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using pdd = pair<double, double>; using psl = pair<string, ll>;
using tiii = tuple<int, int, int>; using tlll = tuple<ll, ll, ll>;
static const int MGN = 10; static const int ARYSZ_MAX = (int)1e7;
static const ll LINF = LLONG_MAX/2;
#ifdef int
static const int INF = LINF;
#else
static const int INF = INT_MAX/2;
#endif
static double EPS = 1e-9;
#define FASTCIN() cin.tie(0);ios::sync_with_stdio(false);
#ifdef IMPORT_SAMPLE
#define DEBUG_IMPORT(file) vs args(argv, argv+argc);str sample = make_sample(args, file);ifstream ifs(sample); cin.rdbuf(ifs.rdbuf());
#else
#define DEBUG_IMPORT(file)
#endif
static inline bool DBLEQ(double a, double b) {return abs(a - b) < EPS;}
static inline void EPR(str msg) {cerr << msg << endl;}
static inline void AST(bool exp, str msg) {if(!exp){EPR(msg);} assert(exp);}
static inline void TAST(bool exp, str msg) {if(!exp){EPR(msg);} while(!exp){}}


int32 main(int32 argc, char* argv[]) {
    FASTCIN();
    DEBUG_IMPORT("sample-2");


    string S,T; cin>>S>>T;
    int N = S.size(), M = T.size();
    //var dp = vector<vs>(N+1, vs(M+1, ""));
    var dp  = vvi(N+1, vi(M+1, 0));

    REP(i,N) {
        REP(j,M) {
            if (T[j] == S[i]) {
                dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j] + 1);
            }
            dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j+1]);
            dp[i+1][j+1] = max(dp[i+1][j+1], dp[i+1][j]);
        }
    }

    str ans = "";
    int i = N, j =M;
    while (0<i and 0<j) {
        if (dp[i][j] == dp[i-1][j] + 1 and dp[i][j] == dp[i][j-1] + 1) {
            ans += S[i - 1];
            i -= 1; j -= 1;
        } else if (dp[i][j] == dp[i-1][j]) {
            i -= 1;
        } else if (dp[i][j] == dp[i][j-1]) {
            j -= 1;
        }
    }

    reverse(ans.begin(), ans.end());
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 70784
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <queue>
#include "math.h"
#include <complex>
#include <iomanip>
#include <map>
#define ifor(i,a,b) for (int i=(a);i<(b);i++)
#define rfor(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define rep(i,n) for (int i=0;i<(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
using namespace std;
typedef long double ld;
typedef long long int  lli;
typedef complex <double> P;
const double eps = 1e-11;
int vex[4]={1,0,-1,0};
int vey[4]={0,1,0,-1};
typedef vector<double> Vec;
typedef vector<int> vec;
typedef vector<Vec> MAT;
typedef vector<vec> mat;
lli MOD=1000000007;
int main(){
  lli a,b,c;
  cin >> a >> b >> c;
  if(a%2==0||b%2==0||c%2==0){
    cout<<0<<endl;
    return 0;
  }
  lli d = min (a*b,b*c);
  cout<<min(d,a*c)<<endl;
}


Measured memory_bytes: 256
from itertools import product 
N = int(input())
A = [[[int(x) for x in input().split()] for _ in range(int(input()))] for i in range(N)]

def judge1(joukens, case):
    i = 1
    for jouken in joukens:
        if case[jouken[0]-1] != jouken[1]:
            i = 0
    return bool(i)

def judge(case):
    for i in range(N):
        if case[i] == 0:
            continue
        else:
            joukens = A[i]
            if judge1(joukens,case):
                continue
            else:
                return False
    return True

for case in list(product([1,0],repeat=N)):
    if judge(case):
        print(sum(case))
        break

Measured memory_bytes: 8820
import sys
from collections import defaultdict

readline = sys.stdin.buffer.readline


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


sys.setrecursionlimit(10**5)


def main():
    h, n = geta(int)
    a, b = [0] * (n + 1), [0] * (n + 1)
    for i in range(n):
        a[i + 1], b[i + 1] = geta(int)

    INF = 10**9
    dp = [[INF] * (h + 1) for _ in range(n + 1)]

    for i in range(1, n + 1):
        for j in range(0, h + 1):
            if j <= a[i]:
                dp[i][j] = min(b[i], dp[i - 1][j])
            else:
                dp[i][j] = min(dp[i][j - a[i]] + b[i], dp[i - 1][j])

    print(dp[n][h])


if __name__ == "__main__":
    main()

Measured memory_bytes: 118512
#include<iostream>
#include<string>
using namespace std;
int main(void){
	int n,k;
	cin>>n>>k;
	int d[100],a[100][100];
	for(int i(0);i<k;i++){
		cin>>d[i];
		for(int j(0);j<d[i];j++){
			cin>>a[i][j];
		}
	}
	bool snack[100]={0};
	for(int i(0);i<k;i++){
		for(int j(0);j<d[i];j++){
			snack[a[i][j]-1] = true;
		}
	}
	int ans(n);
	for(int i(0);i<n;i++){
		if(snack[i] == true)ans--;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3164
use std::io::Read;

fn digit_sum(v: i32) -> i32 {
    let mut val = v;
    let mut res = 0;
    while val > 0 {
        res += val % 10;
        val /= 10;
    }
    res
}

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).ok();
    let n = buf.trim().parse::<i32>().unwrap();
    let mut res = 10000000;
    for i in 1..n {
        res = std::cmp::min(res, digit_sum(i) + digit_sum(n-i));
    }
    println!("{}", res);
}


Measured memory_bytes: 4352
#include<iostream>

using namespace std;

signed main(){
	long long int a,b,x;
	cin >> a >> b >> x;
	long long int ans = 0;
	if(a%x == 0){
	cout << b/x - a/x + 1 << endl;
	return 0;
	}
	else{
	cout << b/x - a/x << endl;
	}
	
	

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i,n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
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; 
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
bool solve(ll a,ll b,ll c,ll k){
  if(a<b && b<c) return true;
  if(k==0) return false;
  bool t=false;
  if(solve(a*2,b,c,k-1)){
    t=true;
  }
  if(solve(a,b*2,c,k-1)){
    t=true;
  }
  if(solve(a,b,c*2,k-1)){
    t=true;
  }
  return t;
}
int main(){
  ll a,b,c;
  cin>>a>>b>>c;
  ll k;
  cin>>k;
  if(solve(a,b,c,k)){
    COUT("Yes");
  }
  else{
    COUT("No");
  }
}

Measured memory_bytes: 3628
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

const int N = 100000;
int n;
// int color[N];
int group[N];
vector<int> v[N];

void setColor(int r, int c){
  queue<int> q;
  q.push(r);
  group[r] = c;

  while(!q.empty()){
    int x = q.front(); q.pop();
    for(int i=0;i<v[x].size();i++){
      int y = v[x][i];
      if(group[y] == -1){
        q.push(y);
        group[y] = c;
      }
    }
  }
}

void assignColor(){
  int id = 1;
  for(int i=0;i<n;i++) group[i] = -1;
  for(int u=0;u<n;u++){
    if(group[u] == -1) setColor(u, id++);
  }
}

int main(){
  int m;
  cin >> n >> m;
  int s, t;
  for(int i=0;i<m;i++){
    cin >> s >> t;
    v[s].push_back(t);
    v[t].push_back(s);
  }
  assignColor();

  int qn; cin >> qn;
  for(int i=0;i<qn;i++){
    cin >> s >> t;
    if(group[s] == group[t]) cout << "yes" << endl;
    else cout << "no" << endl;
  }
  return 0;
}



Measured memory_bytes: 8892
#include<stdio.h>
#define N 100
#define MAX 2000
#define INFTY (1<<21)
#define WHITE 0
#define GRAY 1
#define BLACK 2


int A[N][N], n;

void a()
{
  int i, u, v, minv, sum = 0;
  int d[N], color[N];

  for( i = 0 ; i < n ; i++)
  {
    d[i] = INFTY;
    color[i] = WHITE;
  }
  d[0] = 0;
  color[0] = GRAY;
  while(1)
  {
    minv = INFTY;
    u = -1;
    for( i = 0; i < n ; i++)
    {
      if(minv > d[i] && color[i] != BLACK)
      {
        u = i;
        minv = d[i];
      }
    }
    if( u == -1 ) 
        break;
    color[u] = BLACK;
    for( v = 0 ; v < n ; v++)
    {
      if( color[v] != BLACK && A[u][v] != INFTY )
      {
        if( d[v] > d[u] + A[u][v] )
        {
          d[v] = d[u] + A[u][v];
          color[v] = GRAY;
        }
      }
    }
  }
  for( i = 0 ; i < n ; i++ )
  {
    printf("%d %d\n", i, (d[i] == INFTY ? -1 : d[i]));
  }
}


int main()
{
  int i, j, s;
  int u, v, c, k;
  scanf("%d", &n);
  for( i = 0 ; i < n ; i++ )
  {
    for( j = 0 ; j < n ; j ++)
    {
      A[i][j] = INFTY;
    }
  }
  for( i = 0 ; i < n ; i++ )
  {
    scanf("%d%d", &u, &k);
    for( j = 0 ; j < k ; j ++)
    {
      scanf("%d%d", &v, &c);
      A[u][v] = c;
    }
  }

  a();

  return 0;
}



Measured memory_bytes: 2084
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
using namespace std;
int main(){
    int a,b,k;
    cin>>a>>b>>k;
    set<int> s;
    for(int i=0;i<k&&a+i<=b;i++){
        s.insert(i+a);
    }
    for(int i=k-1;i>=0&&b-i>=a;i--){
        s.insert(b-i);
    }
    for(auto itr=s.begin();itr!=s.end();++itr){
        cout<<*itr<<endl;
    }





return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		
		String s  = sc.next();
		String p  = sc.next();
		
		sc.close();
		
		boolean answer = computeRingPattern(s,p);
		
		if(answer){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
		
		
	}

	private static boolean computeRingPattern(String s, String p) {
		
		char[] strings = new char[s.length()+p.length()];
		
		for(int i= 0; i< s.length() +p.length();i++){
			
			if(i < s.length()){
				
				strings[i] = s.charAt(i);
			}else{
				
				strings[i] = s.charAt(i -s.length());
				
			}
			
		}
		
		for(int i = 0; i<strings.length -p.length() +1 ;i++){
			
			for(int j =0; j<p.length();j++){
				
				
				if(strings[i+j] != p.charAt(j)){
					
					break;
				}
				
				if((j + 1) == p.length()){
					return true;
				}
				
			}
			
			
		}
		
		
		return false;
	}

}



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

using namespace std;

int main()
{
    long long n;
    cin>>n;
    vector <long long> a(n);
    for(long long i=0;i<n;i++)
    {
        cin>>a[i];
    }
    long long q;
    cin>>q;
    for(long long i=0;i<q;i++)
    {
        long long k;
        cin>>k;
        cout<<lower_bound(a.begin(),a.end(),k)-a.begin()<<" ";
        cout<<upper_bound(a.begin(),a.end(),k)-a.begin()<<endl;
    }
    return 0;
}



Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define pb(a) push_back(a)
#define pr(a) cout<<(a)<<endl
#define PR(a,b) cout<<(a)<<" "<<(b)<<endl
#define F first
#define S second
#define ll long long
bool check(int n,int m,int x,int y){return (x<0||x>=n||y<0||y>=m)?false:true;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
typedef pair<int,int> P;

int main() {
  int T;
  cin >> T;
  while(T--) {
    string s;
    cin >> s;
    int cnt=0;
    while(s.size()>1) {
      int ans=0;
      REP(i,1,s.size()) {
	int x,y;
	stringstream ss1,ss2;
	ss1 << s.substr(0,i);
	ss2 << s.substr(i);
	ss1 >> x;
	ss2 >> y;
	ans=max(ans,x*y);
      }
      stringstream ss;
      string t;
      ss << ans;
      ss >> t;
      if(s==t) {
	cnt=-1;
	break;
      }
      s=t;
      cnt++;
    }
    pr(cnt);
  }
  return 0;
}


Measured memory_bytes: 1240
#include <stdio.h>
#include <stdlib.h>
//#include <string.h>
//#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

#define N 200000

//降順
int des(const void *a, const void *b)
{
  return *(int *)b - *(int *)a;
}

int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  int a, cnt[N] = {}, sum = 0;
  for (int i=0; i<n; i++) {
    scanf("%d", &a);
    cnt[a-1]++;
  }
  qsort(cnt, n, sizeof(int), des);
  for (int i=n-1; i>=k; i--)
    sum += cnt[i];
  printf("%d\n", sum);
  return 0;
}


Measured memory_bytes: 1404