akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <tuple>
#include <cassert>
#include <exception>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
#define fprint(NUM,X) cout << fixed << setprecision(NUM) << (X) << endl
#define fprints(NUM,X,Y) cout << fixed << setprecision(NUM) << (X) << " " << (Y) << endl
static const int INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[200010],dp[1010][1010];
double w[1000],v[1000];
double box[200010];

int extgcd(int a,int b,int &x,int &y){
  int p = a;
  if(b != 0){
    p = extgcd(b,a % b,y,x);
    y -= (a/b) * x;
  }else{
    x = 1;y = 0;
  }
  return p;
}

int main(){
  int x,y;
  cin >> n >> m;
  extgcd(n,m,x,y);
  cout << x <<" " << y << endl;
  return 0;
}


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

std::vector<int> c, t;
const static int INF = (1 << 30);
int n, m;

void getTheNumberOfCoin(){
    for(int j = 0; j <= n; j++){
        t[j] = INF;
    }
    t[0] = 0;

    for(int i = 0; i < m; i++){
        for(int j = 0; j + c[i] <= n; j++){
            t[ j + c[i] ] = std::min(t[j] + 1, t[ j + c[i] ]);
        }
    }
}

int main(void){
    std::cin >> n >> m;
    c.resize(m);

    for(int i = 0; i < m; i++){
        std::cin >> c[i];
    }

    t.resize(n+1);

    getTheNumberOfCoin();

    std::cout << t[n] << std::endl;



    return 0;
}


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

int main(){
	int n,k;
	cin>>n>>k;
	int h[n];
	for(int i=0; i<n; i++) cin>>h[i];
	int dp[n];
	fill(dp,dp+n,(int) 2e9);
	dp[0]=0;
	for(int i=1; i<n; i++){
		for(int j=max(0,i-k); j<i; j++){
			dp[i] = min(dp[i], dp[j]+abs(h[i]-h[j]));
		}
	}
	cout<<dp[n-1];
}

Measured memory_bytes: 1024
import Control.Monad
import Data.List

solve :: [[Int]] -> [[Int]] -> [Double]
solve _ [] = []
solve xys (o:os) = res : solve xys os
  where res = sum $ s xys o

s :: [[Int]] -> [Int] -> [Double]
s _ [_] = []
s xys (o1:o2:os) = res : s xys (o2:os)
  where [x1, y1] = xys !! (o1 - 1)
        [x2, y2] = xys !! (o2 - 1)
        res = sqrt . fromIntegral $ (x1 - x2) ^ 2 + (y1 - y2) ^ 2

main :: IO ()
main = do
  n <- readLn
  xys <- replicateM n $ map read . words <$> getLine
  let p = permutations [1..n]
  let r = solve xys p
  print $ sum r / fromIntegral (length r)

Measured memory_bytes: 4220
/* --- author: dxm --- */
#include<bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;

#define INF 1e9
#define Inf 1e18
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;

void qread(int &x){
	int neg=1;x=0;
	char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')neg=-1;c=getchar();}
	while(c>='0'&&c<='9')x=10*x+c-'0',c=getchar();
	x*=neg;
}

const int maxn=200005;
int n,m,last;
int a[maxn],val[maxn],sum[maxn];

bool check(int k){
	memset(sum,0,sizeof(sum));
	memset(val,0,sizeof(val));
	m=1;
	val[m-1]=1;
	sum[m-1]=a[0];
	REP(i,n-1){
		if(m&&a[i]>sum[m-1]){
			if(val[m-1]==1)sum[m-1]=a[i];
			else val[m++]=1,sum[m-1]=a[i];
			continue;
		}
		int pos=lower_bound(sum,sum+m,a[i])-sum;
		if(pos<m&&val[pos]==k)pos--;
		else sum[pos]=a[i];
		if(pos<0)return false;
		int ori=val[pos];
		sum[pos]--;
		if((!pos&&!sum[pos])||(pos&&sum[pos]==sum[pos-1]))pos--;
		pos++;
		val[pos]=ori+1;
		sum[pos]=(!pos?0:sum[pos-1])+1;
		while(pos>=1&&val[pos]==val[pos-1])sum[pos-1]=sum[pos],pos--;
		if(a[i]>sum[pos]){
			pos++;
			val[pos]=1;
			sum[pos]=a[i];
		}
		while(pos>=1&&val[pos]==val[pos-1])sum[pos-1]=a[i],pos--;
		m=pos+1;
	}
	return true;
}

int main(){
#ifdef FILE
	freopen("FILE.in","r",stdin);
	freopen("FILE.out","w",stdout);
#endif
	scanf("%d",&n);
	rep(i,n)scanf("%d",&a[i]);
	int l=0,r=n+1;
	while(r-l>1){
		int mid=(l+r)>>1;
		if(check(mid))r=mid;
		else l=mid;
	}
	printf("%d\n",r);
#ifdef TIME
	printf("Running Time = %d ms\n",int(clock()*1000.0/CLOCKS_PER_SEC));
#endif
	return 0;
}

/*
Input:
-----------------
Output:
*/


Measured memory_bytes: 2688
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <time.h>
#include <stdlib.h>
using namespace std;

#define v 1000003

int main(){
	int a,x;
	scanf("%d %d",&x,&a);
	if(x<a) printf("0\n");
	else printf("10\n");
	
		
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <iomanip>
#include <functional>
#include <cassert>

using namespace std;

typedef long long ll;

vector <int> dx = {0, 0, -1, 1};
vector <int> dy = {-1, 1, 0, 0};

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
#endif
  int n;
  cin >> n;
  vector <int> p(n * n);
  for (int i = 0; i < n * n; ++i) {
    cin >> p[i];
    --p[i];
  }
  vector <vector <int>> best(n, vector <int> (n, n));
  vector <vector <int>> used(n, vector <int> (n, 1));
  {
    queue <pair <int, int>> q;
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        if (i == 0 || j == 0 || i == n - 1 || j == n - 1) {
          best[i][j] = 1;
          q.push({i, j});
        }
      }
    }
    while (!q.empty()) {
      auto p = q.front();
      q.pop();
      int x = p.first, y = p.second;
      for (int k = 0; k < 4; ++k) {
        int nx = x + dx[k], ny = y + dy[k];
        if (0 <= nx && nx < n && 0 <= ny && ny < n && best[x][y] + used[nx][ny] < best[nx][ny]) {
          best[nx][ny] = best[x][y] + used[nx][ny];
          q.push({nx, ny});
        }
      }
    }
  }

  int ans = 0;
  for (int i = 0; i < n * n; ++i) {
    int x = p[i] / n, y = p[i] % n;
    ans += best[x][y] - 1;
    used[x][y] = 0;
    --best[x][y];
    queue <pair <int, int>> q;
    q.push({x, y});
    while (!q.empty()) {
      auto p = q.front();
      q.pop();
      int x = p.first, y = p.second;
      for (int k = 0; k < 4; ++k) {
        int nx = x + dx[k], ny = y + dy[k];
        if (0 <= nx && nx < n && 0 <= ny && ny < n && best[x][y] + used[nx][ny] < best[nx][ny]) {
          best[nx][ny] = best[x][y] + used[nx][ny];
          q.push({nx, ny});
        }
      }
    }
  }

  cout << ans << '\n';
}



Measured memory_bytes: 6056
import sys
input = sys.stdin.readline

from fractions import gcd


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


def mod_inv(a, m):
    return pow(a, m-2, m)


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

LCM = 1
for a in A:
    LCM = lcm(LCM, a)

# ans = LCM * sum([mod_inv(a, MOD) for a in A]) % MOD
ans = 0
for a in A:
    ans += LCM * mod_inv(a, MOD) % MOD
    ans %= MOD

print(ans)


Measured memory_bytes: 6136
#include<stdio.h>

int main(){
  int i,j,n,A[100]={},v=0,k;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);
  for(i=0;i<n;i++){
    if(i!=n-1)printf("%d ",A[i]);
    else printf("%d",A[i]);
  }
  printf("\n");
  for(i=1;i<=n-1;i++){
    v=A[i];
    j=i-1;
    while(j>=0 && A[j]>v){
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=v;
    for(k=0;k<n;k++){
      if(k!=n-1)printf("%d ",A[k]);
      else printf("%d",A[k]);
    }
    printf("\n");
  }
  return 0;
}

 
  



Measured memory_bytes: 2144
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int ans=0;
  ans+=min(d,a);
  d-=a;
  d-=b;
  if(d>0)
    ans+=d*-1;
  cout<<ans;
  return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define LOWER(a,x) lower_bound(ALL(a), x) - a.begin() - 1;
#define COUNT(a,x)  upper_bound(ALL(a), x) - lower_bound(ALL(a), x);
#define MCOUNT(a,x,y) upper_bound(ALL(a), y) - lower_bound(ALL(a), x);
#define INF 111111111111111111
#define MOD 1000000007
#define pb push_back
#define F first
#define S second
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, tmp = 0, ma = 0, mi = 0;
string s;
bool flag, ok;
ll dx[4] = { 1,-1,0,0 }, dy[4] = { 0,0,1,-1 };
ll ddx[8] = { 1,-1,0,0,1,1,-1,-1 }, ddy[8] = { 0,0,1,-1,1,-1,1,-1 };
#pragma endregion
#define MAX 111111


ll sum1, sum2;
ll b[MAX], c[MAX];
int main(void) {
  vll a;
  priority_queue<ll, vll, greater<ll>> pq1;
  priority_queue<ll> pq2;
  cin >> n;
  FOR(i, 0, 3 * n) {
	cin >> tmp;
	a.pb(tmp);
  }

  FOR(i, 0, n) {
	pq1.push(a[i]);
	sum1 += a[i];
  }
  b[0] = sum1;
  FOR(i, 2 * n, 3 * n) {
	pq2.push(a[i]);
	sum2 += a[i];
  }
  c[n] = sum2;

  FOR(i, n, 2 * n) {
	sum1 += a[i];
	pq1.push(a[i]);
	tmp = pq1.top();
	pq1.pop();
	sum1 -= tmp;
	b[i - n + 1] = sum1;
  }
  RFOR(i, n, 2 * n) {
	sum2 += a[i];
	pq2.push(a[i]);
	tmp = pq2.top();
	pq2.pop();
	sum2 -= tmp;
	c[i - n] = sum2;
  }
  ans = -INF;
  FOR(i, 0, n + 1) {
	ans = max(ans, b[i] - c[i]);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 8428
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    
    int n; cin >> n;
    double ans = 0;
    rep(i,n){
        double x; cin >> x;
        ans += 1.0/x;
    }
    
    cout << setprecision(14) << 1.0/ans <<ln;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <map>
#include <queue>
#include <climits>
#define rep(i,n) for (int i=0;i<(n);i++)

using namespace std;


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

	vector<int> k(m);
	vector<vector<int>> s(m, vector<int>(n));
	vector<int> p(m);

	for (int i = 0;i < m;i++) {
		cin >> k[i];
		for (int j = 0;j < k[i];j++) {
			cin >> s[i][j];
		}
	}

	for (int i = 0;i < m;i++) {
		cin >> p[i];
	}

	int ans = 0;
	vector<int> on(n);
	for (int b = 0;b < (1 << n);b++) {
		for (int a = 0;a < n;a++) {
			if (b & (1 << a)) on[a] = 1;
			else on[a] = 0;
		}

		int flag = 0;

		for (int i = 0;i < m;i++) {
			int sum = 0;

			for (int j = 0;j < k[i];j++) {
				if (on[s[i][j] - 1] == 1) sum++;
			}

			if (sum % 2 != p[i]) {
				flag = 1;
				break;
			}
		}

		if (flag == 0) ans++;
	}
	
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3556
n = int(input())
c10n = 1
c8n = 1
c9n = 1

mod = 10**9+7
for i in range(n):
    c10n *= 10
    c10n %= mod
for i in range(n):
    c8n *= 8
    c8n %= mod
for i in range(n):
    c9n *= 9
    c9n %= mod

ans = (c10n - c9n)*2 - (c10n - c8n)
ans %= mod
print(ans)

Measured memory_bytes: 64148
#include <bits/stdc++.h>
using namespace std;
 
int dp[100005];
bool visited[100005];
vector<int> edge[100005]; 

void visit(int vertex)
{
	if(!visited[vertex])
	{
		visited[vertex] = 1;
		dp[vertex] = 0;
		for(auto child : edge[vertex] )
		{
			if(!visited[child] ) visit(child);
			dp[vertex] = max(dp[vertex], 1+dp[child]);
		}
	}	
	return;
}

int main()
{
	int m,n,x,y,mx = -1;
	cin>>n>>m;
	
	for(int i=1;i<=m;i++)
	{
		cin>>x>>y;
		edge[x].push_back(y);
	}
	
	for(int i=1;i<=n;i++)
	{
		if(!visited[i]) 
		{
			visit(i);
		}
	}
	
	for(int i=1;i<=n;i++)
	{
		mx = max(mx,dp[i]);
	}
	cout<<mx<<endl;
	
	return 0;
}


Measured memory_bytes: 12272
bingo_pattern = [[6, 7, 8], [3, 4, 5], [0, 1, 2], [0, 3, 6], [
    1, 4, 7], [2, 5, 8], [0, 4, 8], [6, 4, 2]]


def bingo_achieved(bingo_sheat_list, punch_number_list):

    punch_position_list = []
    for n in punch_number_list:
        try:
            punch_position_list.append(bingo_sheat_list.index(n))
        except ValueError:
            pass

    for p in bingo_pattern:
        if set(p) <= set(punch_position_list):
            return 'Yes'

    return 'No'


if __name__ == '__main__':
    bingo_sheat_list = input().split()
    bingo_sheat_list.extend(input().split())
    bingo_sheat_list.extend(input().split())
    punch_number = int(input())
    punch_number_list = [input() for i in range(punch_number)]
    print(bingo_achieved(list(map(int, bingo_sheat_list)),
                         list(map(int, punch_number_list))))


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

int main(){
    int N,M; cin>>N>>M;
    vector<vector<int>> city(N+1,vector<int>());

    while(M--){
        int a,b; cin>>a>>b;
        city[a].push_back(b);
        city[b].push_back(a);
    }

    for(int i=1; i<=N; i++){
        cout << city[i].size() << endl;
    }
}


Measured memory_bytes: 3596
#include<iostream>
#include<cstdio>
#define maxn 200010
#define maxm 8010
#define ll long long
using namespace std;

int n, a[maxn], b[maxn];

const int p = 1000000007;

const int add = 2010;

ll f[2 * add + 10][2 * add + 10];

ll pow_mod(ll x, ll n){
	ll s = 1;
	for(; n; n >>= 1){
		if(n & 1) s = (s * x) % p;
		x = (x * x) % p;	
	}
	return s;
}

const int N = 8000;
ll fac[maxm], inv[maxm];
void init(){ fac[0] = 1;
	for(int i = 1; i <= N; ++i) fac[i] = fac[i - 1] * i % p;
	inv[N] = pow_mod(fac[N], p - 2);
	for(int i = N - 1; ~i; --i) inv[i] = inv[i + 1] * (i + 1) % p;
}

ll C(int n, int m){
	if(n < m) return 0;
	return fac[n] * inv[m] % p * inv[n - m] % p;
}

ll ans;
int main(){
	scanf("%d", &n); init();
	for(int i = 1; i <= n; ++i){
		scanf("%d%d", &a[i], &b[i]);
		++f[-a[i] + add][-b[i] + add];
	}
	for(int i = 1; i <= 2 * add; ++i)
		for(int j = 1; j <= 2 * add; ++j) f[i][j] = (f[i][j] + f[i][j - 1] + f[i - 1][j]) % p;
	for(int i = 1; i <= n; ++i){
		ans = (ans + f[a[i] + add][b[i] + add]) % p;
		ans = (ans - C(2 * a[i] + 2 * b[i], 2 * a[i])) % p;	
	}
	ans = ans * pow_mod(2, p - 2) % p;
	cout << (ans + p) % p << endl;
	return 0;
}

Measured memory_bytes: 128768
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
int main(){
  ll n,mi=10000000000,ma=-10000000000,r;
  cin >> n;
  for(int i=0;i<n;i++){
    cin>>r;
    ma=max(ma,r-mi);
    mi=min(mi,r);
  }
  cout << ma << endl;
  return 0;
}


Measured memory_bytes: 3104
import sys
from collections import defaultdict, deque
import bisect
from heapq import *
from math import factorial, ceil
sys.setrecursionlimit(200000)
input = sys.stdin.readline

# N, M, = map(int, input().split())
# N = int(input())
# L = [int(v) for v in input().split()]
# L = [[int(v) for v in input().split()] for _ in range(N)]
# L = [int(input()) for _ in range(N)]
# L = [list(input().strip())  for _ in range(N)]
# S = input().strip()

N, M, = map(int, input().split())

ans = 0
if N == 1 and M == 1:
    ans += 400000

if N <= 3:
    ans += (4 - N) * 100000

if M <= 3:
    ans += (4 - M) * 100000

print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n){
    cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  ll ans=0,p=0,q=0;
  bool is=false;
  rep(i,n-1){
    if(is==true && a.at(i)==a.at(i+1)){
      q=a.at(i);
      break;
    }
    if(a.at(i)==a.at(i+1)){
      is=true;
      i++;
      p=a.at(i);
    }
  }
  cout << p*q;
}


Measured memory_bytes: 3960
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7


def main():
  N = int(input())
  ans = 'No'
  for i in range(1,10):
    n = N/i
    for j in range(1,10):
      if n == j:
        ans = 'Yes'
  
  print(ans)
  
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 3060
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll x;
    //cin>>x;
    while(cin>>x)
    {
        ll ans=0;
        ll s=x/11;
        int x1=x-s*11;
        if(x1==0)
            ans=s*2;
        else if(x1<=6)
            ans=1+s*2;
        else if(x1>6&&x1<=11)
            ans=2+s*2;
        cout<<ans<<endl;
    }

    return 0;
}


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

using namespace std;
using ll = long long;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 9223372036854775807
#define all(x) (x).begin(), (x).end()
#define PI 3.141592653589793

ll ts = 1000000007;

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

  double a, b, h, m, s, ans;
  cin >> a >> b >> h >> m;

  s = 360 * (m / 60) - (360 * (h / 12) + 30 * (m / 60));
  s = fabs(s);
  s = s * PI / 180;

  ans = (a * a) + (b * b) - (2 * a * b * cos(s));

  cout << fixed << setprecision(10) << sqrt(ans) << "\n";
}


Measured memory_bytes: 4208
#include<bits/stdc++.h>
#define ll long long

using namespace std;

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

    int x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;

    vector<ll>r,g,v;
    for(int i=0;i<a;i++){
        ll x; cin>>x;
        r.push_back(x);
    }
    for(int i=0;i<b;i++){
        ll x; cin>>x;
        g.push_back(x);
    }for(int i=0;i<c;i++){
        ll x; cin>>x;
        v.push_back(x);
    }
    sort(r.rbegin(),r.rend());
    sort(g.rbegin(),g.rend());

    for(int i=0;i<min(x,a);i++) v.push_back(r[i]);
    for(int i=0;i<min(y,b);i++) v.push_back(g[i]);

    sort(v.rbegin(),v.rend());

    ll ans=0;
    int temp=v.size();
    for(int i=0;i<min(x+y,temp);i++){
        ans+=v[i];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 7920
def mpw(n,m):
    ret=1
    while m>0:
        if m&1:
            ret*=n
            ret%=M
        n*=n
        n%=M;
        m>>=1
    return ret;
def pw(n,m):
    ret=1
    while m>0:
        if m&1:
            ret*=n
        n*=n
        m>>=1
    return ret;
def delta(i,j):
    if i==j:
        return 1
    return 0
def mtxmpw(A,m):
    ret=[[delta(i,j) for i in range(len(A))] for j in range(len(A))]
    while m>0:
        if m&1:
            ret=mul(ret,A)
        A=mul(A,A)
        m>>=1
    return ret
def mul(A,B):
    ret=[[0 for i in range(len(B[0]))] for j in range(len(A))]
    for i in range(len(A)):
        for j in range(len(B[0])):
            for k in range(len(B)):
                ret[i][j]+=A[i][k]*B[k][j]
                ret[i][j]%=M
    return ret

L,A,B,M=map(int,input().split())
ans=0
d=0
for k in range(18,0,-1):
    l=max((pw(10,(k-1))-A+B-1)//B,0)
    r=min((pw(10,k)-A-1)//B,L-1)
    if l<=r:
        MT=[[1,mpw(10,k),0],[0,mpw(10,k),(M-B*mpw(10,k)%M)%M],[0,0,mpw(10,k)]]
        v=[[(A+B*r)%M],[(A+B*(r-1)%M+M)%M],[1]]
        u=mul(mtxmpw(MT,r-l),v)
        ans+=mpw(10,d)*u[0][0]%M;
        ans%=M;
        d+=(r-l+1)*k
print(ans)

Measured memory_bytes: 3192
#include <vector>
#include <list>
#include <map>
#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>
#include <fstream>

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

const ll INF = 1LL << 40;
const ll LIM = 100 * 1000;

int solve(void);

int main(void)
{

	while (solve())
	{
	}
	return 0;
}

int solve(void)
{
	ll N;
	cin >> N;
	vector<ll> b(N);
	for(auto& bi :b)
		cin >> bi;
	vector<ll> ans;

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

		pll m(0, -1);
		for (int j = 0; j < N; j++)
		{
			if (b[j] > 0 && pc + 1 == b[j] && m.first < b[j])
			{
				m.first = max(b[j], m.first);
				m.second = j;
			}
			if (j == N-1 && m.first > 0)
			{
				ans.push_back(m.first);
				b[m.second] = 0;
			}
			if (b[j] > 0) pc++;
		}
	}

	if (ans.size() == N)
	{
		for (int i = N - 1; i >= 0; i--)
		{
			if(i == N - 1)
				cout << ans[i];
			else
				cout << " " << ans[i];
		}
		cout << endl;
	}
	else
	{
		cout << -1 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <cstdio>

#define REDIRECT(x) freopen(x".in", "r", stdin), freopen(x".out", "w", stdout)
#define CLOSEALL() fclose(stdin), fclose(stdout)

using namespace std;
typedef long long i64;

i64 N, K;

i64 simulate(i64 x, i64 y)
{
	if(y == 0)
		return (-x);
	return simulate(y, x % y) + 2 * (x / y) * y;
}

int main()
{
	//REDIRECT("light");

	scanf("%lld%lld", &N, &K);
	printf("%lld\n", simulate(max(K, N - K), min(K, N - K)) + N);

	CLOSEALL();
	return 0;
}


Measured memory_bytes: 252
//https://atcoder.jp/contests/abc118/tasks/abc118_a

#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <bitset>


using namespace std;
int main(){
	int a,b,ans;
	cin>>a>>b;
	
	if(b%a==0) ans=a+b;
	else ans=b-a;

	cout<<ans<<endl;
}



Measured memory_bytes: 256
n,m=map(int,input().split())

food=[0]*m
ans=[]
for _ in range(n):
    a=list(map(int,input().split()))
    for j in range(a[0]):
        ans.append(a[j+1])
temp=0
for i in range(m+1):
    b=ans.count(i)
    if b==n:
        temp+=1
print(temp)

Measured memory_bytes: 3064
S = input()
dp = [[0] * 13 for _ in range(10 ** 5 + 5)]
MOD = 10 ** 9 + 7
dp[0][0] = 1
n = len(S)
for i in range(n):
    if S[i] == "?":
        c = -1
    else:
        c = int(S[i])

    for j in range(10):
        if c != -1 and c != j:
            continue
        for ki in range(13):
            dp[i + 1][(ki * 10 + j) % 13] += dp[i][ki]

    for j in range(13):
        dp[i + 1][j] %= MOD

print(dp[n][5])


Measured memory_bytes: 62172
#include <bits/stdc++.h>
using namespace std;
#define maxx 100100
long long dp[200][maxx],peso[200],valor[200];

int main() {
	int n,w;
	cin >> n >> w;
	
	for(int i = 1; i <= n; i++){
		cin >> peso[i] >> valor[i];
	}
	
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= w; j++){
			if(peso[i] <= j){
				dp[i][j] = max(valor[i]+dp[i-1][j-peso[i]],dp[i-1][j]);
			}
			else dp[i][j] = dp[i-1][j];
		}
	}
	cout << dp[n][w] << endl;
	return 0;
}

Measured memory_bytes: 79360
def main():
    abcd = [int(_x) for _x in input().split()]
    a = abcd[0]
    b = abcd[1]
    c = abcd[2]
    d = abcd[3]

    while True:
        c = c - b
        if c <= 0:
            print("Yes")
            return
        a = a - d
        if a <= 0:
            print("No")
            return


main()


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

typedef vector<int> vi;
typedef pair<int,int> ii;
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()

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

	int n, k;
	string s;
	cin >> n >> k >> s;
	--k;
	s[k] = 'a' + (s[k] - 'A');
	cout << s << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
/*int main()
{
  int N;
  int A[200010], result[200010];
  int sum=0;
  scanf("%d",&N);
  for(int i=2;i<=N;i++){
    scanf("%d",&A[i]);
    result[A[i]]++;
  }
  for(int i=1;i<=N;i++){
    printf("%d\n",result[i]);
  }
}*/

int a[200010];
int ans[200010];
int main(){
int n;
scanf("%d",&n);
for(int i=2;i<=n;i++) scanf("%d",&a[i]);
for(int i=2;i<=n;i++) ans[a[i]]++;
for(int i=1;i<=n;i++) printf("%d\n",ans[i]);
}

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

ll MOD = 1e9+7;

int main() {
  int n;
  cin >> n;
  vector<ll>a(n);
  rep(i,0,n) cin >> a[i];
  vector<ll>cnt0(61);
  vector<ll>cnt1(61);
  rep(i,0,n){
    for(int bit = 0; bit < 61;++bit){
      if(a[i]&(1LL<<bit)) cnt1[bit]++;
      else cnt0[bit]++;
    }
  }
  ll ans = 0;
  ll c = 1;
  rep(i,0,61){
    ll tmp = (cnt0[i]*cnt1[i])%MOD*c%MOD;
    ans = (ans+tmp)%MOD;
    c = (c*2)%MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 2560
A = []
for i in range(3):
  B = list(map(int, input().split()))
  A.append(B)
P = [[0,0,0],[0,0,0],[0,0,0]]

N = int(input())
a = [int(input()) for i in range(N)]
  
for i in a:
  for j in range(3):
    for k in range(3):
      if i == A[j][k]:
        P[j][k] = 1

if P[0][0] * P[0][1] * P[0][2] == 1 or P[1][0] * P[1][1] * P[1][2] == 1 or P[2][0] * P[2][1]\
*P[2][2] == 1 or P[0][0] * P[1][0] *P[2][0] == 1 or P[0][1] * P[1][1] * P[2][1] == 1 or\
P[0][2] * P[1][2] * P[2][2] == 1 or P[0][0] * P[1][1] * P[2][2] == 1 or\
P[0][2] * P[1][1] * P[2][0] == 1:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
vector<int> a,b,c,d;
vector<int> G[10001];  
int visited[10001]={0};  
int link[10001]={0};
int n; 
int can(int t)
{  
	int tmp,i;
    for(i=0;i<G[t].size();i++)
	{ 
        tmp=G[t][i];  
        if(!visited[tmp])
		{
            visited[tmp]=1;  
            if(link[tmp]==-1||can(link[tmp]))
			{
            	link[tmp]=t;  
                return 1;  
            }  
        }  
    }  
    return 0;  
}  
int maxmatch()  
{  
    int num=0; 
	int i; 
    for(i=0;i<n;i++)
	{  
        memset(visited,0,sizeof(visited));  
        if(can(i))
		{  
            num++;  
        }  
    }  
    return num;  
}  
int main()  
{  
	int i,j;
	scanf("%d",&n);
	a.resize(n);
	b.resize(n);
	c.resize(n);
	d.resize(n);
	memset(link,-1,sizeof(link));  
    for(i=0;i<n;i++)
	{
        scanf("%d %d",&a[i],&b[i]);    
	}
	for(i=0;i<n;i++)
	{
		scanf("%d %d",&c[i],&d[i]);
		for(j=0;j<n;j++)
		{
			if(a[j]<c[i]&&b[j]<d[i])
			{
				G[j].push_back(i+n);  
        		G[i+n].push_back(j);
			}
		}
    }  
    printf("%d\n",maxmatch());    
    return 0;  
}  

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

int main() {
  int N,W;
  cin >> N >> W;
  vector<pair<int,int>> wv(N);
  for (int i=0; i<N; i++) {
    cin >> wv[i].first >> wv[i].second;
  }
  long smallw = wv[0].first;
  
  sort(wv.begin(),wv.end());
  
  int cc0 = 0;
  int cc1 = 0;
  int cc2 = 0;
  int cc3 = 0;
  for (int i=0; i<N; i++) {
    if (wv[i].first == smallw) {
      cc0++;
      continue;
    }
    if (wv[i].first == smallw+1) {
      cc1++;
      continue;
    }
    if (wv[i].first == smallw+2) {
      cc2++;
      continue;
    }
    cc3++;
  }
  
  vector<long> vv0(cc0+1,0);
  vector<long> vv1(cc1+1,0);
  vector<long> vv2(cc2+1,0);
  vector<long> vv3(cc3+1,0);
  for (int i=cc0-1; i>=0; i--) {
    vv0[cc0-i] = vv0[cc0-1-i] + wv[i].second;
  }
  for (int i=cc1-1; i>=0; i--) {
    vv1[cc1-i] = vv1[cc1-1-i] + wv[i+cc0].second;
  }
  for (int i=cc2-1; i>=0; i--) {
    vv2[cc2-i] = vv2[cc2-1-i] + wv[i+cc0+cc1].second;
  }
  for (int i=cc3-1; i>=0; i--) {
    vv3[cc3-i] = vv3[cc3-1-i] + wv[i+cc0+cc1+cc2].second;
  }
  long ans = 0;
  long term = 0;
  for(int i=0; i<cc0+1; i++) {
    for(int j=0; j<cc1+1; j++) {
      for(int k=0; k<cc2+1; k++) {
        for(int l=0; l<cc3+1; l++) {
          if ((i+j+k+l)*smallw+j+k*2+l*3 > W) {
            continue;
          }
          term = vv0[i] + vv1[j] + vv2[k] + vv3[l];
          ans = max(term,ans);
          term = 0;
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm> 
#include <iostream>
#include <cstring>
#include <cmath>
#include <cstdio>
using namespace std;
int main()
{
	int a=(getchar()-'0')*10;
	a+=(getchar()-'0');
	int b=(getchar()-'0')*10;
	b+=(getchar()-'0');
	if ((b>12||(!b))&&(a>12||(!a)))
	{
		printf("NA");
		return 0;
	}
	if ((b<=12&&b>=1)&&(a<=12&&a>=1))
	{
		printf("AMBIGUOUS");
		return 0;
	}
	if (a<=12&&a>=1)
	{
		printf("MMYY");
		return 0;
	}
	printf("YYMM");
	return 0;
}

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

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

typedef long long ll;
typedef pair<int, int> P;

const int MAX = 1e5 + 5;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int N, K, h[MAX];

int main(){
    cin >> N >> K;
    rep(i, N) cin >> h[i];

    int ans = 0;
    rep(i, N){
        if (K <= h[i]) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 640
//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimise ("ofast")
#pragma GCC optimise("unroll-loops")

using namespace std;

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

const int N = 200000 + 10;
const ll MOD = 1000000000 + 7;
const ll INF = 1000000000000000000;
const ll LOG = 25;

int n, a[N], num[N];

bool cmp(int x, int y){
	return a[x] < a[y];
}

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++) {cin >> a[i]; num[i] = i;}
	sort(num + 1, num + n + 1, cmp);
	for (int i = 1; i <= n; i++) a[num[i]] = i;
	int ans = 0;
	for (int i = 1; i <= n; i++){
		if (i % 2 == 1 && a[i] % 2 != 1) ans ++;
	}
	cout << ans;









	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
const int MOD = 1000000007;
const int INF = 2147483647;
const int SEG_SIZE = 1<<17;

int Seg_tree[SEG_SIZE*2];


void update(int i,int x)
{
   int now = i+SEG_SIZE;
   Seg_tree[now]=x;
   while(1)
   {
      
      now/=2;
      if(now==0)break;
      Seg_tree[now] = min(Seg_tree[now*2],Seg_tree[now*2+1]);
   }
}

int find(int l,int r)
{
   int res = INF;
   l+=SEG_SIZE;
   r+=SEG_SIZE;
   while(1)
   {
      
      if(l%2==1)
      {
         res=min(res,Seg_tree[l]);
         l++;
      }
      
      if(r%2==1)
      {
         res=min(res,Seg_tree[r-1]);
         r--;
      }
      if(l==r)break;
      l/=2;
      r/=2;
   }
   return res;
}


int main()
{
   rep(i,SEG_SIZE*2)
   {
      Seg_tree[i]=INF;
   }
   int n,q;
   cin >> n >> q;
   rep(i,q)
   {
      int com,x,y;
      cin >> com >> x >> y;
      
      if(com==0)
      {
         update(x,y);
      }else
      {y++;
         cout<<find(x,y)<<endl;
      }
      
   }
   return 0;
}


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

using P = pair<int,int>;
using P3 = pair<P, int>;
using ll = long long int;
constexpr ll INF = 1LL<<60;

int main() {
    int w, h, n;
    cin >> w >> h >> n;
    vector<ll> x(n), y(n);
    vector<P> p(n);
    for(int i=0;i<n;i++){
        cin >> x[i] >> y[i];
        p[i] = P(x[i], y[i]);
    }
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    ll ans = INF, ansx, ansy;
    
    for(int i=max(0,n/2-10);i<=min(n,n/2+10);i++){
        for(int j=max(0,n/2-10);j<=min(n,n/2+10);j++){
            ll tmp = 0;
            ll tx = x[i], ty = y[j], dmax = 0;
            for(int k=0;k<n;k++){
                tmp += abs(p[k].first - tx) + abs(p[k].second - ty);
                dmax = max(dmax, abs(p[k].first - tx) + abs(p[k].second - ty));
            }
            if(ans > tmp*2-dmax){
                ans = tmp*2-dmax;
                ansx = tx;
                ansy = ty;
            }
        }
    }
    
    cout << ans << endl;
    cout << ansx << " " << ansy << endl;
    return 0;
}



Measured memory_bytes: 5220
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<int>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<60;
const ll mod=1e9+7;

int main(){
    int i,j;
    ll n;
    cin>>n;
    int l[n];
    for(i=0;i<n;i++) cin>>l[i];
    sort(l,l+n);
    vector<int> v;
    for(i=0;i<n;i++){
        for(j=i+1;j<n;j++){
            v.pb(l[i]+l[j]);
        }
    }
    ll ans=n*(n-1)*(n-2)/6;
    sort(v.begin(),v.end());
    ll ban=0;
    ll p=0;
    for(i=0;i<n;i++){
        while(v[p]<=l[i]) p++;
        ban+=p;
    }
    cout<<ans-ban<<endl;
  
}

Measured memory_bytes: 10604
#include<stdio.h>

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

  if(X<1 || X>9){
    return 1;
  }

  if(X == 5 || X == 7 || X == 3){
     printf("YES\n");
  }else{
    printf("NO\n");
  }

  return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>


int a, b, ans;
char c;

int main(){
	scanf("%d %c %d", &a, &c, &b);
	if (c == '+'){
		ans = a + b;
	}
	if (c == '-'){
		ans = a - b;
	}

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

	return 0;
}

Measured memory_bytes: 256
program abc8
 implicit none
 integer,allocatable::a(:)
 integer::N=0,i,ia=0,ib=0,s=0
 read(*,*)N
 allocate(a(N))
 read(*,*)(a(i),i=1,N)
 do ib=1,N
  if(mod(ib,2)==1.and.mod(a(ib),2)==1)then
   s=s+1
  end if
 end do
 print'(i0)',s
end program abc8

Measured memory_bytes: 2704
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define FOR(i, r, n) for (int i=(int)(r); i<=(int)(n); i++)
#define all(v) v.begin(), v.end()
#define INF 2147483647
#define INF64 9223372036854775807
#define MOD 1000000007

int main(){

    int D;cin>>D;
    vector<int> c(27);
    vector<vector<int>> s(D+1, vector<int>(27));
    FOR(i, 1, 26) cin>>c[i];
    FOR(i, 1, D) FOR(j, 1, 26) cin>>s[i][j];

    vector<int> last(27, 0), last_kari(27, 0);
    int64_t v=0;

    FOR(d, 1, D){
        int64_t v_max=0, t_max=1;
        FOR(t, 1, 26){
            int64_t v_kari=v;

            v_kari+=(int64_t)s[d][t];
            last_kari[t]=d;
            FOR(i, 1, 26){
                v_kari-=(int64_t)c[i]*(d-last_kari[i]);
            }
            
            if(v_kari>v_max){
                t_max=t;
                v_max=v_kari;
            }

        }

        v+=(int64_t)s[d][t_max];
        last[t_max]=d;
        FOR(i, 1, 26){
            v-=(int64_t)c[i]*(d-last[i]);
        }

        cout<<t_max<<endl;

    }

}

Measured memory_bytes: 3684
#include<bits/stdc++.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define rep(i,n) for(int i = 0;  i < n ; ++i)
#define REP(i,a,b) for(int i = a ; i <= b ; ++i)
#define filei freopen("input.txt", "r", stdin);
#define fileo freopen("output.txt", "w", stdout);
#define gooi cout<<"Case #"<<i+1<<" :";
#define s(n) scanf("%d",&n)
#define rev(i,n) for(int i = n ; i >= 0 ; --i)
#define REV(i,a,b) for(int i = a ; i >= b ; --i)
#define miN(a,b) (((a)<(b))?(a):(b))
#define sc(n) scanf("%c",&n)
#define tr(c,i) for(typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define INF 1000000000
#define pii pair<long long int,long long int>
#define pb(a) push_back(a)
#define F first
#define S second
typedef long long ll;
using namespace std;
#define MAXN   10000001 
int spf[MAXN];  
void sieve(){ 
    spf[1] = 1; 
    for (int i=2; i<MAXN; i++)  spf[i] = i; 
    for (int i=4; i<MAXN; i+=2) spf[i] = 2; 
    for (int i=3; i*i<MAXN; i++){  
        if (spf[i] == i){  
            for (int j=i*i; j<MAXN; j+=i) 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
}  
ll getFactorization(int x){ 
    ll ret = 1; 
    while (x != 1){ 
        int a = spf[x];
        int b = 1;
        while(spf[x]==a){ 
            x = x / spf[x];
            b++; 
        }
        ret*=b;
    } 
    return ret; 
}
void pre(){}
void solve(){
    ll n;cin>>n;
    ll ans  =0 ;
    for(int i=1;i<=n;i++){
        ans+=getFactorization(i)*i;
    }
    cout<<ans<<"\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    pre();
    sieve();
    long long int num = 1;
    //cin>>num;
    for(long long int i=0;i<num;i++){
       	solve();
    }   
}





Measured memory_bytes: 42704
#include<bits/stdc++.h>
#define fs first
#define sc second
#define pi 3.141592653589793238462643383279502884197
//#define e 2.7182818284590452353602874713526624977572

#ifdef ONLINE_JUDGE
#define getchar getchar_unlocked
#endif

typedef long long int ll;
typedef long double ld;
typedef std::vector<ll> vi;
typedef std::vector<bool> vb;
typedef std::vector<char> vc;
typedef std::pair<ll,ll> pii;
typedef std::vector<pii> vii;

using namespace std;
const int mod=1e9+7;

inline int ri(){
    int res=0,neg=0;
    char c=getchar();
    while((c<'0'||c>'9')&&c!='-')c=getchar();
    if(c=='-')neg=1,c=getchar();
    while(c>='0'&&c<='9'){res=(res<<1)+(res<<3)+c-48;c=getchar();}
    return neg?-res:res;
}

inline ll rl(){
    ll res=0,neg=0;
    char c=getchar();
    while((c<'0'||c>'9')&&c!='-')c=getchar();
    if(c=='-')neg=1,c=getchar();
    while(c>='0'&&c<='9'){res=(res<<1)+(res<<3)+c-48;c=getchar();}
    return neg?-res:res;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n=rl(),m=rl(),k=rl();
    if(k==0){
        cout<<"Yes\n";
        return 0;
    }
    for(int x=0;x<=m;++x){
        ld tmp=(k-n*x)*1.0/(m-2*x);
        if(ceil(tmp)==floor(tmp)&&tmp>=0&&tmp<=n){
            cout<<"Yes\n";
            return 0;
        }
    }
    cout<<"No\n";
    return 0;
}


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

using namespace std;

int main() {
  string s;
  
  cin >> s;
  
  int year  = stoi(s.substr(0, 4));
  int month = stoi(s.substr(5, 2));
  int day   = stoi(s.substr(8, 2));
  
  cout << (year * 10000 + month * 100 + day > 20190430 ? "TBD" : "Heisei") << endl;
  
  return 0;
}

Measured memory_bytes: 256
import std.conv, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.container, std.math, std.range, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken().to!int; }
long readLong() { return readToken().to!long; }
real readReal() { return readToken().to!real; }

void chmin(T)(ref T t, in T f) { if (t > f) t = f; }
void chmax(T)(ref T t, in T f) { if (t < f) t = f; }

int binarySearch(T)(in T[] as, in bool delegate(T) test) { int low = -1, upp = cast(int)(as.length); for (; low + 1 < upp; ) { int mid = (low + upp) >> 1; (test(as[mid]) ? low : upp) = mid; } return upp; }
int lowerBound(T)(in T[] as, in T val) { return as.binarySearch((T a) => (a < val)); }
int upperBound(T)(in T[] as, in T val) { return as.binarySearch((T a) => (a <= val)); }


int N, Q;
long[] A;
long[] X;

void main() {
  try {
    for (; ; ) {
      N = readInt();
      Q = readInt();
      A = new long[N];
      foreach (i; 0 .. N) {
        A[i] = readLong();
      }
      X = new long[Q];
      foreach (q; 0 .. Q) {
        X[q] = readLong();
      }
      A.sort();
      A.reverse();
      debug {
        writefln("A = %s", A);
      }
      
      auto ASum = new long[N + 1];
      foreach (i; 0 .. N) {
        ASum[i + 1] = ASum[i] + A[i];
      }
      auto tail2Sum = new long[N + 2];
      foreach_reverse (i; 0 .. N) {
        tail2Sum[i] = A[i] + tail2Sum[i + 2];
      }
      
      foreach (q; 0 .. Q) {
        bool prefer(long a, long b) {
          return (tuple(abs(a - X[q]), a) < tuple(abs(b - X[q]), b));
        }
        int lo = 1, hi = (N + 1) / 2 + 1;
        for (; lo + 1 < hi; ) {
          const mid = (lo + hi) / 2;
          const res = prefer(A[mid - 1], A[2 * (mid - 1)]);
          (res ? hi : lo) = mid;
        }
        debug {
          writefln("lo = %s", lo);
        }
        long ans;
        ans += ASum[lo];
        ans += tail2Sum[2 * lo];
        writeln(ans);
      }
    }
  } catch (EOFException e) {
  }
}


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

typedef long long int ll;

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

int main() {
  ll n;
  cin >> n;
  if (n/100 == n%10) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  return 0;
}

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

#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int, int>
#define f first
#define s second
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()

const int inf = (int)1e9;
const int mod = inf+7;

int n, cnt, a[100100], used[100100];

int main(){

	cin >> n;
	for(int i=0;i<n;i++) {
		scanf("%d", a+i);
	}

	int ind = 0;
	used[ind] = 1;
	while(ind!=1) {
		if(cnt>=100100) {
			printf("-1\n");
			return 0;
		}
		if(used[ind] == 1) {
			used[a[ind]-1] = 1;
			cnt++;
			ind = a[ind]-1;
		}
	}
	printf("%d\n", cnt);

	return 0;
}

Measured memory_bytes: 1024
var a,b:longint;
k,i:integer;
begin 
	read(a,b);
	read(k);
	for i:=1 to k do 
	begin 
		if i mod 2<>0 then 
		begin 
			if a mod 2<>0 then a:=a-1;
			b:=b+a div 2;
			a:=a div 2;
		end;
		if i mod 2=0 then 
		begin 
			if b mod 2<>0 then b:=b-1;
			a:=a+b div 2;
			b:=b div 2;
		end;
	end;
	write(a,' ',b);
end.

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define PRECISION(x) cout << fixed << setprecision(x); 
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(i,n) for (int i = 0; i < n; ++i)
#define DO(X) while(X--)
#define DRI(X) int (X); cin >> X
#define DRII(X, Y) int X, Y; cin >> X >> Y
#define DRIII(X, Y, Z) int X, Y, Z; cin >> X >> Y >> Z
#define read(X) for(int &ele : (X)) cin >> ele
#define readI(X) for(int idx = 1; idx < SZ((X)); ++idx) cin >> (X)[idx]
#define debug(x) cerr << '>' << #x << ':' << x << endl
#define MP make_pair
#define PB push_back
#define F first
#define S second

using namespace std;
typedef long long LL;
const int INF = 1<<29;
inline int in() { int x; cin >> x; return x; }
template<class T> void max_self(T & a, const T & b) { if(a < b) a = b; }
template<class T> void min_self(T & a, const T & b) { if(a > b) a = b; }

int main(){
	FAST_IO 
	DRI(N);
	int curNum = 1;
	REP(rep, N){
		int brickN; cin >> brickN;
		if(brickN == curNum) curNum++;
	}
	int toBreak = N - curNum + 1;
	cout << (toBreak < N ? toBreak : -1) << endl;
	return 0;
}

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

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = (int)1e9 + 7;

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

    string s; int x, y;
    cin >> s >> x >> y;

    int dir = 2;
    vector<int> xsec, ysec;
    REP(i, s.size()){
        if(s[i] == 'F'){
            if(dir == 2) x--;
            else if(dir == 0) xsec.back()++;
            else if(dir == 1) ysec.back()++;
        }else{
            dir = (dir + 1) % 2;
            (dir == 0 ? xsec : ysec).pb(0);
        }
    }

    set<int> dp1;
    dp1.insert(0);
    REP(i, xsec.size()){
        set<int> tmp;
        for(int st : dp1){
            tmp.insert(st + xsec[i]);
            tmp.insert(st - xsec[i]);
        }
        swap(dp1, tmp);
    }

    set<int> dp2;
    dp2.insert(0);
    REP(i, ysec.size()){
        set<int> tmp;
        for(int st : dp2){
            tmp.insert(st + ysec[i]);
            tmp.insert(st - ysec[i]);
        }
        swap(dp2, tmp);
    }

    auto itr1 = dp1.lower_bound(x);
    auto itr2 = dp2.lower_bound(y);

    if(itr1 != dp1.end() && *itr1 == x && itr2 != dp2.end() && *itr2 == y){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 768
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;


int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);

    vector<pair<ll,ll> > z(n); 
    int i,j;
    for(i=0; i<n; i++) {
        int a, b;
        scanf("%d%d", &a, &b);
        z[i]=make_pair(a,b);
    }
    sort(z.begin(), z.end());

    if(n==1) {
        printf("1\n"); return 0;
    }
    int ans = INF;
    for(i=0; i<n; i++) {
        for(j=i+1; j<n; j++) {
            ll dx = z[j].first - z[i].first;
            ll dy = z[j].second - z[i].second;

            int flag[100]={0};
            int k;
            int cnt=0;
            for(k=0; k<n; k++) {
                if(flag[k]) continue;
                flag[k]=1;
                cnt++;
                ll xcurr = z[k].first;
                ll ycurr = z[k].second;
                while( 1 ) {
                    xcurr += dx;
                    ycurr += dy;

                    auto it = find( z.begin(), z.end(), make_pair( xcurr, ycurr ) );
                    if(it == z.end()) {
                        break;
                    }
                    else {
                        flag[it-z.begin()]=1;
                    }
                }
            }
            ans = MIN(ans, cnt);
        }
    }
    printf("%d\n", ans);

    return 0;
}


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

#ifdef _DEBUG
inline void dump() { cerr << endl; }
template<typename Head> void dump(Head&& head) { cerr << head; dump(); }
template<typename Head, typename... Tail> void dump(Head&& head, Tail&&... tail) { cerr << head << ", "; dump(forward<Tail>(tail)...); }
#define debug(...) do {cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; dump(__VA_ARGS__); } while (false)
#else
#define dump(...)
#define debug(...)
#endif

template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////

const ll inf = 1LL<<60;

int main()
{
  ll l; cin >> l;
  ll r; cin >> r;
  ll d; cin >> d;

  ll a = (l-1)/d;
  ll b = r/d;
  cout << b-a << endl;

  return 0;
}


Measured memory_bytes: 3584