akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    ll n, a, b;
    cin >> n >> a >> b;    

    ll t = n/(a+b);
    ll ret = t*a;
    if(n-t*(a+b) >= a) ret += a;
    else ret += n-t*(a+b);
    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep1(i, n) for(int i=1; i<(int)(n); i++)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> wi;
typedef vector<string> vs;

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

  int n;
  cin >> n;
  double ans=0.0;
  rep(i, n){
    double x;
    string u;
    cin >> x >> u;
    if(u=="JPY")ans+=x;
    else ans+=x*380000.0;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3816
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#include <climits>
#include <vector>
using namespace std;

const int MOD = 1000000007;

int main() {

	string a, b, c;
	cin >> a >> b >> c;

	if (a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0])cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>

#include<queue>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
 
#define INF (1e9)
typedef long long unsigned int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
 

template<typename T>
int vector_finder(std::vector<T> vec, T number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int gcd(int a,int b){
	if(b>0){
		return gcd(b, a % b);
	}else{
		return a;
	}
}

ll N,M;


int main()
{
	int N;
	cin >> N;
	int A[2][N];
	REP(i,2){
		REP(j,N){
			cin >> A[i][j];
		}
	}
	int ans = 0;
	REP(i, N)
	{
		int sum = 0;
		for (int j = 0; j <= i;j++){
			sum += A[0][j];
		}
		for (int j = i; j < N;j++){
			sum += A[1][j];
		}
		if(sum>ans){
			ans = sum;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int g[33][33];
int dy_1[]={0,0,1,-1};
int dx_1[]={1,-1,0,0};
int dy_2[]={1,1,-1,-1};
int dx_2[]={1,-1,1,-1};
int dy_3[]={2,-2,0,0};
int dx_3[]={0,0,2,-2};
void m(int y,int x,int size);
int main(){
  int x,y,size;
  while(scanf("%d,%d,%d",&x,&y,&size) != EOF){
    m( y , x , size );
  }
  int ret,count;
  count = ret = 0;
  for(int i=0;i<10;i++){
    for(int j=0;j<10;j++){
      if(g[i][j] == 0)count++;
      ret = max( ret , g[i][j] );
    }
  }
  cout << count << endl;
  cout << ret << endl;
}
void m(int y,int x,int size){
  g[y][x]++;
  if(size == 3){
    for(int i=0;i<4;i++){
      g[y + dy_1[i]][x + dx_1[i]]++;
      g[y + dy_2[i]][x + dx_2[i]]++;
      g[y + dy_3[i]][x + dx_3[i]]++;
    }
  }
  if(size == 2){
    for(int i=0;i<4;i++){
      g[y + dy_1[i]][x + dx_1[i]]++;
      g[y + dy_2[i]][x + dx_2[i]]++;
    }
  }if(size == 1){
    for(int i=0;i<4;i++){
      g[y + dy_1[i]][x + dx_1[i]]++;
    }
  }
}

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

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

Measured memory_bytes: 3640
a_begin, a_end, b_begin, b_end = gets.split(' ').map(&:to_i)
result = 0
if a_begin < b_begin
  if b_begin <= a_end
    if b_end <= a_end
      result = b_end - b_begin
    else
      result = a_end - b_begin
    end
  end
else
  if a_begin <= b_end
    if a_end <= b_end
      result = a_end - a_begin
    else
      result = b_end - a_begin
    end
  end
end
puts result

Measured memory_bytes: 1788
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,m = LI()
    v = [[] for i in range(n)]
    for _ in range(m):
        a,b = LI()
        a -= 1
        b -= 1
        v[a].append(b)
        v[b].append(a)
    q = [(0,0)]
    d = [float("inf")]*n
    d[0] = 0
    pre = [None]*n
    while q:
        dx,x = heappop(q)
        nd = dx+1
        for y in v[x]:
            if nd < d[y]:
                d[y] = nd
                pre[y] = x
                heappush(q,(nd,y))
    if float("inf") in d:
        print("No")
        return
    print("Yes")
    for i in pre[1:]:
        print(i+1)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 99184
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <iomanip>
#include <cassert>
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(true){
        string s;
        getline(cin, s);
        if(s[0] == '.') break;
        int len = s.size();
        bool ok = true;
        stack<char> left_br;
        for(int i = 0; i < len; i++){
            if(s[i] == '('){
                left_br.push('(');
            }else if(s[i] == ')'){
                if(left_br.empty() || left_br.top() != '('){
                    ok = false;
                    break;
                }
                left_br.pop();
            }else if(s[i] == '['){
                left_br.push('[');
            }else if(s[i] == ']'){
                if(left_br.empty() || left_br.top() != '['){
                    ok = false;
                    break;
                }
                left_br.pop();
            }
        }
        if(ok && left_br.empty()){
            puts("yes");
        }else{
            puts("no");
        }
    }
    return 0;
}

Measured memory_bytes: 1200
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
typedef long long ll;
#define rep(i,n) for(ll i=0; i<(ll)(n); i++)
#define REP(i,l,r) for(ll i=l; i<(ll)(r); i++)
#define max(l,r) ((l)>(r)?l:r)
#define min(l,r) ((l)<(r)?l:r)
#define swap(l,r) {ll tp=l;l=r;r=tp;}
const ll MOD = 1000000007;
int upcmpll(const void *a,const void *b){
    return (*(ll*)a == *(ll*)b?0:(*(ll*)a > *(ll*)b?1:-1));
}
void sort_u(ll *a,int n){qsort(a,n,sizeof(ll),upcmpll);}

int main(){
    int n, k, s; scanf("%d%d%d", &n, &k, &s);
    int a[101010];
    int m = n / k, r = n % k;
    if(k <= n){
        rep(i, n){
            if(i < k) a[i] = s;
            else if(s > 2)a[i] = s/2 + 1;
            else a[i] = 10;
        }
    }

    rep(i, n) printf("%d ", a[i]);
}

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

#define sswap(x, y) { x+=y; y=x-y; x-=y; }
#define LSOne(S) ((S) & (-S))

#define EPS 1e-6
#define MOD 1000000007

#define fi first
#define se second
#define pb push_back
#define ende '\n'

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mset(x, y) memset(&x, (y), sizeof(x))

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
	int k, n;
	vi h;
	cin >> n >> k;
	while (n--) {
		int e; cin >> e;
		h.pb(e);
	}
	sort(all(h));
	ll ans = 1123456789;
	for (int i = 0; i < h.size()-k+1; i++) 
		if (h[i+k-1]-h[i] < ans) ans = h[i+k-1]-h[i];
	cout << ans << ende;
	//0  1  2  3  4
	//5  5  7  7  7
  return 0;
}


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

int main(){
    int N;
    cin>>N;
    vector<int> a(N);
    for(int i=0;i<N;i++){
        cin>>a.at(i);
    }
    vector<int> A(N,0);
    //reverse(a.begin(),a.end());
    int tmp=0;
    for(int i=0;i<N;i++){
        int j=N-i-1;
        tmp = 0;
        for(int l=1;l<=N/(j+1);l++){
            int L=l*(j+1);
            tmp+=A.at(L-1);
        }
        tmp=tmp%2;
        if(tmp != a.at(j)){
            A.at(j)=1;
        }
    }
    int ans = accumulate(A.begin(),A.end(),0);
    cout<<ans<<endl;
    for(int i=0;i<N;i++){
        if(A.at(i)==1){
            if(ans != 1){
                cout<<i+1<<" ";
            }
            else{
                cout<<i+1<<endl;
            }
            ans-=1;
        }
    }
}

Measured memory_bytes: 2432
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>
#include<map>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    int n, ans = 0;
    cin >> n;
    vector<pair<ll, ll>> z(n);
    for(int i = 0; i < n; i++){
        ll x, y;
        cin >> x >> y;
        z[i] = make_pair(x, y);
    }
    map<pair<ll, ll>, int> mp;
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            mp[make_pair(z[i].first - z[j].first, z[i].second - z[j].second)]++;
            mp[make_pair(z[j].first - z[i].first, z[j].second - z[i].second)]++;
        }
    }
    for(auto&& i : mp){
        ans = max(ans, i.second);
    }
    ans = n - ans;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <complex>
#include <algorithm>
//C
#include <cstdio>
#include <cmath>
#include <cstring>
 
#define REP(i,x) for(int i = 0 ; i < (int)(x) ; i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long
 
using namespace std;

string str;

vector<int> table;// ZqÌDæxðo¦Ä¨­zñ
int N;// Zq
int idx;// \¶ðÍÌCfbNX
// Zq»è
bool isOp(char c){
	return c=='+'||c=='-'||c=='*'||c=='/';
}
// ZqÉ¶ÄvZ
// 0ÌÆ«ÉfalseðÔ·
pair<bool,int> calc(int a,int b,char op){
	if(op=='+')return make_pair(true,a+b);
	if(op=='-')return make_pair(true,a-b);
	if(op=='*')return make_pair(true,a*b);
	if(b==0)return make_pair(false,0);
	return make_pair(true,a/b);
}

pair<bool,int> expr(int depth){
	if(depth==N){
		if(str[idx]=='('){
			idx++;
			pair<bool,int> a=expr(0);
			idx++;
			return a;
		}
		else{
			int num=0;
			while(idx<str.size() && isdigit(str[idx])){
				num=num*10+str[idx++]-'0';
			}
			return make_pair(true,num);
		}
	}
	else{
		pair<bool,int> a=expr(depth+1);
		if(!a.first)
			return a;
		if(idx<str.size() && isOp(str[idx]) && table[idx]==depth){
			char op=str[idx++];
			pair<bool,int> b=expr(depth+1);
			if(!b.first) return b;
			a=calc(a.second,b.second,op);
			if(!a.first)return a;
		}
		return a;
	}
}



int main()
{
	while(cin>>str && str!="#"){
		vector<int> res;
		// ZqÌÊuðo¦Ä¨­
		table.assign(str.size(),-1);
		vector<int> pos;
		REP(i,str.size())if(isOp(str[i]))pos.push_back(i);
		vector<int> perm;
		N = pos.size();
		REP(i,pos.size())perm.push_back(i);
		// next_permutationÅSTõ
		do{
			REP(i,perm.size())table[pos[i]] = perm[i];
			idx=0;
			pair<bool,int> tmp = expr(0);
			if(tmp.first)res.push_back(tmp.second);
		}
		while(next_permutation(ALL(perm)));
		// ¯¶Êðí
		sort(ALL(res));
		res.erase(unique(ALL(res)),res.end());

		cout << res.size() << endl;
	}
	return 0;
}

Measured memory_bytes: 3080
h,w=map(int,input().split())
grid=[list(input()) for _ in range(h)]
dist=[[-1]*w for _ in range(h)]
dist[0][0]=0
Q=[(0,0)]
tile=h*w
cnt=0

white=0
for i in range(h):
    white+=grid[i].count(".")

while Q:
    Q_alt=[]
    for q in Q:
        if grid[q[1]][q[0]]!="#":
            if q[0]!=0:
                if grid[q[1]][q[0]-1]!="#" and dist[q[1]][q[0]-1]==-1:
                    dist[q[1]][q[0]-1]=cnt+1
                    Q_alt.append((q[0]-1,q[1]))
            if q[0]!=w-1:
                if grid[q[1]][q[0]+1]!="#" and dist[q[1]][q[0]+1]==-1:
                    dist[q[1]][q[0]+1]=cnt+1
                    Q_alt.append((q[0]+1,q[1]))
            if q[1]!=0:
                if grid[q[1]-1][q[0]]!="#" and dist[q[1]-1][q[0]]==-1:
                    dist[q[1]-1][q[0]]=cnt+1
                    Q_alt.append((q[0],q[1]-1))
            if q[1]!=h-1:
                if grid[q[1]+1][q[0]]!="#" and dist[q[1]+1][q[0]]==-1:
                    dist[q[1]+1][q[0]]=cnt+1
                    Q_alt.append((q[0],q[1]+1))
    cnt+=1
    Q=Q_alt

if dist[h-1][w-1]==-1:
    print(-1)
else:
    print(white-dist[h-1][w-1]-1)

Measured memory_bytes: 3192
#include <bits/stdc++.h>
 
using namespace std;
 
using tint = long long;
using ld = long double;
 
#define forsn(i, s, n) for(int i = s; i < int(n); i++)
#define forn(i, n) forsn(i, 0, n)
 
using vi = vector<int>;
#define pb push_back
#define rsz resize
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
 
using pi = pair<int,int>;
#define f first
#define s second
#define mp make_pair
 
#define DBG(x) cerr << #x << " = " << x << endl;
 
const int MOD = 1e9+7;
const int MX = 5e5+5;
const int INF = 1e9;
const ld PI = acos(ld(-1)); 
 
void NACHO(string name = "out"){
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen((name+".in").c_str(), "r", stdin);
    //freopen((name+".out").c_str(), "w", stdout);
}
 
int main(){
	NACHO();
	int n, m;
	cin >> n >> m;
	vector<vi> adj (n);
	forn(i, m){
		int u, v;
		cin >> u >> v;
		--u; --v;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	vector<bool> visited (n, 0);
	int tam;
	function<void(int)> dfs = [&](int node){
		visited[node] = 1;
		++tam;
		for(auto u : adj[node]){
			if(!visited[u]) dfs(u);
		}
	};
	int maxi = -INF;
	forn(i, n){
		if(!visited[i]){
			tam = 0;
			dfs(i);
			maxi = max(maxi, tam);
		}
	}
	cout << maxi << "\n";
}


Measured memory_bytes: 26480
#include <bits/stdc++.h>
using namespace std;
int gcd(int a,int b){
  if(a%b==0){return b;}
  else{return gcd(b,a%b);}
}
int main(){
    int N,ans=1;
    cin>>N;
    vector<int> A(N),L(N),R(N);
    for(int i=0;i<N;i++){cin>>A.at(i);}
    for(int i=0;i<N;i++){
        if(i==0){L.at(0)=A.at(0);}
        else{L.at(i)=gcd(A.at(i),L.at(i-1));}
    }
    for(int i=N-1;i>=0;i--){
        if(i==N-1){R.at(N-1)=A.at(N-1);}
        else{R.at(i)=gcd(A.at(i),R.at(i+1));}
    }
    for(int i=0;i<N;i++){
        if(i==0){ans=max(ans,R.at(1));}
        else if(i==N-1){ans=max(ans,L.at(N-2));}
        else{ans=max(ans,gcd(R.at(i+1),L.at(i-1)));}
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4192
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int paramA = Integer.parseInt(scanner.nextLine());
        String paramS = scanner.nextLine();
        scanner.close();
        if (paramA >= 3200) {
            System.out.println(paramS);
        } else {
            System.out.println("red");
        }
    }
}

Measured memory_bytes: 21844
#include <iostream>

using namespace std;
using ll = long long;
using ld = long double;

void solve(ll H, ll W) {
  cout << ((H == 1 || W == 1) ? 1 : (H * W + 1) / 2) << endl;
}

int main() {
  ll H;
  cin >> H;
  ll W;
  cin >> W;
  solve(H, W);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
const int MOD=1000000007;

bool isPowerOfTwo (ll x)  
{  
    return x && (!(x&(x-1)));  
}
bool isPrime(int n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
int highestPowerof2(unsigned int n) 
{ 
    // Invalid input 
    if (n < 1) 
        return 0; 
  
    int res = 1;
    for (int i=0; i<8*sizeof(unsigned int); i++) 
    { 
        int curr = 1 << i; 
        if (curr > n) 
           break; 
  
        res = curr; 
    } 
  
    return res; 
} 
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}       
////////////////////////////////////////////////////////////////////

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(NULL);
  int t=1;
  while(t--)
  {
      ll n;
      cin>>n;
      ll ans=(n/500)*1000;
      n%=500;
      ans+=(n/5)*5;  
      cout<<ans;
  }
  return 0;
}

Measured memory_bytes: 256
S = input()

ret = set()
for i in range(len("dreamer")):
    ret.add("dreamer"[i:])
for i in range(len("eraser")):
    ret.add("eraser"[i:])
for i in range(len("dream")):
    ret.add("dream"[i:])
for i in range(len("erase")):
    ret.add("erase"[i:])

word = ""

for i in reversed(range(len(S))):
    word = S[i] + word
    if word not in ret:
        print("NO")
        exit()
    elif word == "dreamer" or word == "eraser":
        word = ""
    elif word == "dream" or word == "erase":
        word = ""
    else:
        continue

if word == "":
    print("YES")

Measured memory_bytes: 3188
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)     (x).begin(),(x).end()
# define UNIQ(c)    (c).erase(unique(ALL((c))), end((c)))
# define mp         make_pair
# define eb         emplace_back
# define FOR(i,a,b) for(int i=(a);i<(b);++i)
# define REP(i,n)   FOR(i,0,n)
# define INIT       std::ios::sync_with_stdio(false);std::cin.tie(0);


int main() {
	int N, K;
	while (cin >> N >> K&&N&&K) {
		vector<int> R(N);
		int ans = 0;
		map<int, bool> appeared;
		for (int i = 0; i < N; i++) cin >> R[i];

		for (int i = 0; i < (1 << N); i++) {
			vector<int> cards;
			for (int k = 0; k < N; k++) {
				if ((i >> k) & 1) cards.push_back(R[k]);
			}
			if (cards.size() != K) continue;
			sort(cards.begin(), cards.end());

			do {
				string joined = "";
				for (auto val : cards) {
					joined += to_string(val);
				}
				if (!appeared[stoi(joined)]) {
					appeared[stoi(joined)] = true;
					ans++;
				}
			} while (next_permutation(cards.begin(), cards.end()));
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3392
import java.util.Scanner;
public class Main{
	public static void main(String[]args){
	Scanner scan=new Scanner(System.in);
	long a=scan.nextInt();
	String b=scan.next();
	String c=scan.next();
	String d=scan.next();
int ans=0;
	for(int i=0;i<a;i++) {
		char x=b.charAt(i);
		char y=c.charAt(i);
		char z=d.charAt(i);
		if(x==y&&y==z) {
		}
		else if(x==y||y==z||x==z) {
			ans++;
		}
		else {
			ans+=2;
		}
	}
	System.out.println(ans);
	}
}

Measured memory_bytes: 21844
#include "bits/stdc++.h"
using namespace std;
typedef pair<long long, long long> P;
int main() {
	long long H; cin >> H;
	long long ans = 0;
	for (long long i = 0; pow(2, i) <= H; i++) {
		ans += pow(2, i);
	}
	cout << ans << endl;
}

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

#include <unordered_map>

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    ll n, k;
    cin >> n >> k;
    VL a(n), b(n);
    REP(i,n) scanf("%lld %lld", &a[i], &b[i]);
    ll ans = 0;
    REP(i,n){
        if ((k - a[i]) == (k ^ a[i])) ans += b[i];
    }
    FOR(x,1,30){
        if (((k >> x) & 1) == 0) continue;
        ll mask = k - (1LL << x);
        REP(i,x){
            if (((mask >> i) & 1) == 0) mask += (1LL << i);
        }
        ll tmp = 0;
        REP(i,n){
            if ((mask - a[i]) == (mask ^ a[i])){
                tmp += b[i];
            }
        }
        // cout << mask << " " << tmp << endl;
        ans = max(ans, tmp);
    }
    cout << ans << endl;

    return 0;
}





Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int a[1000005];
int temp[1000005];
int main(){
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	while(k--){
		for(int i=1;i<=n;i++){
			++temp[max(1,i-a[i])];
			--temp[min(n+1,i+a[i]+1)];
		}
		int s=0;
		bool f=true;
		for(int i=1;i<=n;i++){
			a[i]=s+=temp[i];
			if(a[i]!=n){
				f=false;
			}
		}
		if(f){
			break;
		}
		memset(temp,0,sizeof(temp));
	}
	for(int i=1;i<=n;i++)
		cout<<a[i]<<" ";
	return 0;
}

Measured memory_bytes: 8268
#include<stdio.h>

int main(){
    int k, x, a;

    scanf("%d", &k);
    scanf("%d", &x);

    for(int i=k-1; i>0; i--){
        a = x-i;
        if(a<-1000000) continue;
        printf("%d ", a);
    }

    for(int i=0; i<k; i++){
        a = x+i;
        if(a>1000000) continue;
        printf("%d ", a);
    }

    return 0;
}

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

namespace ABC135_B
{
    class Program
    {
        static void Main(string[] args) {
            long n = long.Parse(Console.ReadLine());
            string[] input = Console.ReadLine().Split();

            long[] nArr = new long[n];
            for (long i = 0; i < n; i++) {
                nArr[i] = long.Parse(input[i]);
            }

            long[] sortArr = (long[])nArr.Clone();
            Array.Sort(sortArr);

            long oneIndex = -1;
            long twoIndex = -1;
            for(int i = 0; i < n; i++) {
                if(nArr[i] != sortArr[i]) {
                    if (oneIndex != -1 && twoIndex != -1) {
                        Console.WriteLine("NO");
                        return;
                    }

                    if (oneIndex == -1)
                        oneIndex = i;
                    else
                        twoIndex = i;
                }
            }

            if (oneIndex == -1 && twoIndex == -1)
                Console.WriteLine("YES");
            else if (nArr[oneIndex] == sortArr[twoIndex] && nArr[twoIndex] == sortArr[oneIndex])
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");

        }
    }
}

Measured memory_bytes: 11348
n = input()
t, a = map(int, input().split())
h = list(map(int, input().split()))
a = (t - a)/0.006
hNew = h.copy()
hNew.append(a)
hNew.sort()
num = hNew.index(a)
if abs(hNew[num] - hNew[num-1]) < abs(hNew[num+1] - hNew[num]):
    print(h.index(hNew[num-1])+1)
else:
    print(h.index(hNew[num+1])+1)

Measured memory_bytes: 3064
// J'aime
// Chemise Blanche

#include <bits/stdc++.h>
using namespace std;

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  s[k - 1] = tolower(s[k - 1]);
  cout << s << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3524
#include <stdio.h>
int main(void){
    // Your code here!
    int a,b,c;
    
    scanf("%d %d %d\n",&a,&b,&c);
    
    if(a*b <= c) printf("%d\n",a*b);
    else         printf("%d\n",c);
    return 0;
}


Measured memory_bytes: 128
N, A, B = map(int, input().split())
S = input()
cnt = 1
cnt_b = 0
for i in range(N):
    if(S[i] == "c"):
        print("No")
    else:
        if(cnt <= A+B):
            if(S[i] == "a"):
                print("Yes")
                cnt += 1
            else:
                cnt_b += 1
                if(cnt_b <= B):
                    print("Yes")
                    cnt += 1
                else:
                    print("No")
        else:
            print("No")

Measured memory_bytes: 4016
#include <bits/stdc++.h>
using namespace std;
#define int                     long long int
#define ld                      long double
#define pb                      push_back
#define MOD                     1000000007
#define inf                     3e18
#define vi                      vector<int>
#define vld                     vector<ld>
#define pii                     pair<int,int>
#define mii                     map<int,int>
#define fi                      first
#define se                      second
#define fastIO                  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << " "<< name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

void inp_out()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
    #endif
}

int32_t main()
{
	fastIO
	inp_out();
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	int ans=0;
	ans+=min(k,a);
	k-=a;
	k=max(0ll,k);
	k-=b;
	k=max(0ll,k);
	ans-=min(k,c);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
int main(){
    ll po = 0;
    ll N;
    cin >> N;
    ll ans = 0;
    for(ll i = 0; i < N; i++){
        ll p;
        cin >> p;
        ans += p;
        po = max(po, p);
    }
    cout << ans - po / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    long long h, w;
    cin >> h >> w;
    if (h == 1 || w == 1)
    {
        cout << "1\n";
    }
    else
    {
        cout << h * w / 2 + (h * w) % 2 << "\n";
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=2000005,mod=1000000007;
int f[N]={1};
int qp(int a,int b)
{
	int ans=1;
	while(b)
	{
		if(b&1)
			ans=ans*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ans;
}
int c(int n,int m)
{
	return f[n]*qp(f[m],mod-2)%mod*qp(f[n-m],mod-2)%mod;
}
signed main()
{
	ios::sync_with_stdio(false);
	for(int i=1;i<=2000000;i++)
		f[i]=f[i-1]*i%mod;
	int n,k;string s;
	cin>>k>>s;
	n=s.size();
	int ans=0;
	for(int i=n;i<=n+k;i++)
	{
		int zh=qp(26,n+k-i);
		zh=zh*c(i-1,n-1)%mod;
		zh=zh*qp(25,i-n)%mod;
		ans=(ans+zh)%mod;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 19960
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int a[2][4];
  for(int i=0;i<2;i++)
    for(int j=0;j<4;j++)
      cin>>a[i][j];
  int s[2]={};
  
  for(int i=0;i<2;i++)
    for(int j=0;j<4;j++)
      s[i]+=a[i][j];
  
  cout<<max(s[0],s[1])<<endl;
  return 0;
}

Measured memory_bytes: 3068
//In The Name Of Allah
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define double long double 
#define fi first
#define se second
#define pii pair<int, int>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

signed main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  if (a[n - 1] - a[0] > 1) {
    cout << "No\n";
  } else if (a[n - 1] - a[0] == 1) {
    int cnt1 = 0, cnt2 = 0;
    for (int i = 0; i < n; i++) {
      if (a[i] == a[0]) cnt1++;
      else cnt2++;
    }
    if (cnt2 == 1 || a[0] < cnt1) {
      cout << "No\n";
      return 0;
    }
    int dov = a[n - 1] - cnt1;
    if (0 < dov && dov * 2 <= cnt2) {
      cout << "Yes\n";
    } else {
      cout << "No\n";
    }
  } else {
    if (a[0] == n - 1) {
      cout << "Yes\n";
    } else if (2 * a[0] <= n) {
      cout << "Yes\n";
    } else {
      cout << "No\n";
    }
  }
}



Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int S[100005];
int T[50005];

int main()
{
	int N;
	cin >> N;
	REP(i, N)
	{
		cin >> S[i];
	}
	int q;
	cin >> q;
	REP(i, q)
	{
		cin >> T[i];
	}
	sort(S, S + N);
	int sum = 0;
	REP(i, q)
	{
		int b = -1, t = N;
		while (abs(t - b) > 1)
		{
			int m = (b + t) / 2;
			if (T[i] == S[m])
			{
				sum++;
				break;
			}
			if (S[m] > T[i])
			{
				t = m;
			}
			else
			{
				b = m;
			}
		}
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 3716
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

struct edge{int to;ll cost;};
vector<edge> G[200200];
ll D[200200];
void dijkstra(int N,int S){
  priority_queue<pair<ll,int>,vector<pair<ll,int>>,greater<pair<ll,int>>> que;
  rep(i,N) D[i]=1001001001001001001;
  D[S]=0;
  que.push(mp(0,S));
  while(!que.empty()){
    PII P=que.top();
    que.pop();
    int X=P.second;
    if(D[X]<P.first) continue;
    rep(i,G[X].size()){
      edge E=G[X][i];
      if(D[E.to]>D[X]+E.cost){
        D[E.to]=D[X]+E.cost;
        que.push(mp(D[E.to],E.to));
      }
    }
  }
}

int main(){
  int N,M,S;
  cin>>N>>M>>S;
  VI U(M),V(M),A(M),B(M);
  rep(i,M) cin>>U[i]>>V[i]>>A[i]>>B[i];
  VI C(N),F(N);
  rep(i,N) cin>>C[i]>>F[i];
  map<PII,int> E;
  int cnt=0;
  rep(i,N) rep(j,2501) E[mp(i,j)]=cnt++;
  rep(i,N) rep(j,2500) G[E[mp(i,j+1)]].pb(edge{E[mp(i,j)],0});
  rep(i,N) rep(j,2501) G[E[mp(i,j)]].pb(edge{E[mp(i,min(j+C[i],2500ll))],F[i]});
  rep(i,M) rep(j,2501) if(j-A[i]>=0) G[E[mp(U[i]-1,j)]].pb(edge{E[mp(V[i]-1,j-A[i])],B[i]});
  rep(i,M) rep(j,2501) if(j-A[i]>=0) G[E[mp(V[i]-1,j)]].pb(edge{E[mp(U[i]-1,j-A[i])],B[i]});
  dijkstra(N*2501,E[mp(0,min(S,2500))]);
  rep(i,N-1){
    ll tmp=LLONG_MAX;
    rep(j,2501) tmp=min(tmp,D[E[mp(i+1,j)]]);
    cout<<tmp<<endl;
  }
}

Measured memory_bytes: 34924
#include <bits/stdc++.h>
using namespace std;
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#define debug(x...) cout << #x << " = "; _print(x)
typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll;
#define rep(i,a,b) for (int i = (a); i < (b); ++i)
#define per(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define mp make_pair 
#define pb push_back
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL) 
const int mod = 1e9 + 7, mxn = 1e5 + 1;

int solve(){
	long double x, y;
	cin>> x>> y;
	long double mul = x*y;
	ll ans = mul;
	cout<< ans<< "\n";
	return 0;	
}
 
int main()
{
    fast;
    int t = 1;
    //cin>> t;
    while(t--){  
        solve();
    }
    return 0;
}
//v.clear(), vis.clear(); vis.resize(n + 1, 0), v.resize(n + 1);
 
/*  inv[1] = 1; // inv is ll
    for(int i=2; i<=mxn; ++i)
        inv[i]=mod-mod/i*inv[mod%i]%mod;*/
        
// lower bound   >=  
// upper bound   >
// vector<int>().swap(vec); //free memory from vec


Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,m;
  cin >> n >> m;
  vector<int> k(m);
  vector<vector<int>> s(m,vector<int>(10));
  int tmp;
  int i,j;
  for(i=0;i<m;i++){
    cin >> k[i];
    for(j=0;j<k[i];j++){
      cin >> tmp;
      s[i][tmp-1] = 1;
    }
  }
  vector<int> p(m);
  for(i=0;i<m;i++){
    cin >> p[i];
  }
  int mp[10];
  int onoff = 0,ans = 0;
  int a,b,c,d,e,f,g,h,l;
  vector<int> z(10);
  for(i=0;i<n;i++){
    z[i] = 1;
  }
  for(a=0;a<z[0] +1;a++){
    for(b=0;b<z[1] +1;b++){
      for(c=0;c<z[2] +1;c++){
        for(d=0;d<z[3] +1;d++){
          for(e=0;e<z[4] +1;e++){
            for(f=0;f<z[5] +1;f++){
              for(g=0;g<z[6] +1;g++){ 
                for(h=0;h<z[7] +1;h++){    
                  for(i=0;i<z[8] +1;i++){
                    for(j=0;j<z[9] +1;j++){
                      tmp = 0;
                      for(l=0;l < m;l++){
                        onoff = a * s[l][0] + b * s[l][1] + c * s[l][2] + d * s[l][3] + e * s[l][4] + f * s[l][5] + g * s[l][6] + h * s[l][7] + i * s[l][8] + j * s[l][9];

                        if(onoff % 2 == p[l]){
                          tmp++;
                        }
                      }
                      ans += tmp/m;
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
ll n,k,a[100010],dp[100010];
int main ( )
{
	scanf("%lld%lld",&n,&k);
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
	memset(dp,0x7f,sizeof(dp));
	dp[1]=0;
	for(ll i=2;i<=n;i++)
		for(ll j=1;j<=k&&i-j>=1;j++)
		   dp[i]=std::min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
	cout<<dp[n];
	return 0;
}

Measured memory_bytes: 1792
import sys
input = sys.stdin.readline
import math
from functools import reduce


def read():
    N = int(input().strip())
    W = []
    for i in range(N):
        w = input().strip()
        W.append(w)
    return N, W


def solve(N, W):
    used = dict()
    for w in W:
        if w in used.keys():
            return "No"
        used[w] = True
    for i in range(N-1):
        if W[i][-1] != W[i+1][0]:
            return "No"
    return "Yes"


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


Measured memory_bytes: 9432
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    ll N; cin >> N;
    vector<int> c;
    while(N) {
        c.emplace_back((N-1) % 26);
        N = (N - 1) / 26;
    }

    reverse(c.begin(), c.end());
    for(auto e : c) cout << (char)('a' + e);
    cout << endl;
    return 0;
}


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

int main() {
  int n;
  cin>>n;
  int a[n];
  for(int i=0; i<n; i++) cin>>a[i];

  int64_t kabu = 0;
  int64_t money = 1000;

  for(int i=0; i<n-1; i++) {
    int64_t add = money/a[i];
    kabu += add;
    money -= add*a[i];

    if(a[i]>a[i+1]) {
      money += a[i]*kabu;
      kabu = 0;
    }
  }

  money += a[n-1]*kabu;
  kabu = 0;


  cout<<money<<endl;

  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define VIZ {printf("digraph G{\n"); for(int i=1;i<=n;i++) for es(i,e) printf("%d->%d;\n",i,vb[e]); puts("}");}
#define VIZ2 {printf("graph G{\n"); for(int i=1;i<=n;i++) for es(i,e) if(vb[e]>=i)printf("%d--%d;\n",i,vb[e]); puts("}");}
#define SZ 666666
int n,m,l[SZ],r[SZ];
pii qs[SZ]; int Q=0;
bool cmpl(pii a,pii b)
{
	return a.se-a.fi>b.se-b.fi;
}
int bs[SZ];
void edt(int x,int y)
{
	for(;x<=m;x+=x&-x)
		bs[x]+=y;
}
int sum(int x)
{
	int s=0;
	for(;x>=1;x-=x&-x)
		s+=bs[x];
	return s;
}
int anss[SZ];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",l+i,r+i);
		qs[++Q]=pii(l[i],r[i]);
		edt(l[i],1); edt(r[i]+1,-1);
	}
	sort(qs+1,qs+1+Q,cmpl);
	int cur=1,out=0;
	for(int i=m;i>=1;i--)
	{
		while(cur<=Q&&qs[cur].se-qs[cur].fi+1>=i)
		{
			edt(qs[cur].fi,-1); edt(qs[cur].se+1,1);
			++out; ++cur;
		}
		int cc=0;
		for(int p=i;p<=m;p+=i)
			cc+=sum(p);
		anss[i]=out+cc;
	}
	for(int i=1;i<=m;i++)
		printf("%d\n",anss[i]);
}


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

int main() {
    const int MAX_N = 10;
    int N, M, E[MAX_N][MAX_N];
    vector<int> v;
    cin >> N >> M;
    for (int i = 0; i < N; ++i){
        for (int j = 0; j < N; ++j){
            E[i][j] = 0;
        }   
    }
    for (int i = 0; i < N; ++i){
        v.push_back(i);
    }
    for (int i = 0; i < M; ++i){
        int a, b;
        cin >> a >> b;
        E[a-1][b-1] = 1;
        E[b-1][a-1] = 1;
    }

    int ans = 0;
    do {
        if (v[0] != 0) break;
        // for (int i = 0; i < N; ++i){
        //     cout << v[i] + 1;
        // }cout << endl;

        bool f = true;
        for (int i = 0; i < N-1; ++i){
            if (E[v[i]][v[i+1]] == 0){
                f = false;
                break;
            }
        }
        if (f) ans++;

    } while (next_permutation(v.begin(), v.end()));
    cout << ans << endl;
    return 0;
}


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

typedef long long ll;

const int N = 51;

pair<ll,ll> pts[N];
ll x[N], y[N];

int main () {
	int n, k; cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i];
		pts[i] = {x[i], y[i]};
	}
	sort(x, x+n); sort(y, y+n);
	ll ans = (x[n-1]-x[0])*(y[n-1]-y[0]);
	for (int x0 = 0; x0 < n; x0++) {
		for (int y0 = 0; y0 < n; y0++) {
			for (int x1 = x0+1; x1 < n; x1++) {
				for (int y1 = y0+1; y1 < n; y1++) {
					ll temp = (x[x1]-x[x0])*(y[y1]-y[y0]);
					if (temp < ans) {
						int cnt = 0;
						for (int i = 0; i < n; i++)
							if (x[x0] <= pts[i].first and pts[i].first <= x[x1] and y[y0] <= pts[i].second and pts[i].second <= y[y1])
								cnt++;
						if (cnt >= k)
							ans = temp;
					}
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
#include<cstdio>
#include<algorithm>
using namespace std;
int n, K, w[16], D[17][65536], F[65537], InvF[65537], Mod = 1000000007, res;
int Pow(int a, int b) {
	int r = 1;
	while (b) {
		if (b & 1)r = 1ll * r*a%Mod;
		a = 1ll * a*a%Mod; b >>= 1;
	}
	return r;
}
int PP(int n, int k) {
	return 1ll*F[n] * InvF[n - k] % Mod;
}
int main() {
	int i, j, k;
	scanf("%d%d", &n, &K);
	F[0] = 1;
	for (i = 1; i <= (1 << n); i++)F[i] = 1ll * F[i - 1] * i%Mod;
	InvF[i - 1] = Pow(F[i - 1], Mod - 2);
	for (i = (1 << n); i >= 1; i--)InvF[i - 1] = 1ll * InvF[i] * i%Mod;
	for (i = 0; i < K; i++) {
		scanf("%d", &w[i]);
	}
	D[K][0] = 1;
	for (i = K-1; i >= 0; i--) {
		for (j = 0; j < (1 << n); j++) {
			D[i][j] = (D[i][j] + D[i + 1][j]) % Mod;
			for (k = 0; k < n; k++) {
				if ((j >> k) & 1)continue;
				int c = (1 << n) - w[i] - j;
				if (c < (1<<k)-1)continue;
				D[i][j | (1 << k)] = (D[i][j | (1 << k)] + 1ll * D[i + 1][j] * PP(c, (1 << k) - 1)%Mod * (1<<k)) % Mod;
			}
		}
	}
	for (i = 0; i < (1 << n); i++) {
		int c = 0;
		for (j = 0; j < n; j++) {
			if ((i >> j) & 1)c++;
		}
		int t = 1ll * D[0][i] * F[(1<<n) - i - 1] % Mod;
		if (c & 1) res = (res + Mod - t) % Mod;
		else res = (res + t) % Mod;
	}
	printf("%d\n", 1ll*res*(1<<n)%Mod);
}

Measured memory_bytes: 4736
def resolve():
    x,n = map(int, input().split())
    if n == 0:
        print(x)
        return

    p = list(map(int, input().split()))
    p.sort()
    i = 0  # (p < X) p[i] == X (X < p)
    s_i = 0
    l_i = n
    while i < n:
        if p[i] == x: break
        elif p[i] > x: 
            print(x)
            return
        else: i += 1

    s_i = i-1
    l_i = i+1

    ans = 0
    diff = 1
    while True:
        if s_i < 0 or p[s_i] < x-diff:
            ans = x-diff
            break
        elif l_i >= n or p[l_i] > x+diff:
            ans = x+diff
            break
        else:
            s_i -= 1
            l_i += 1
            diff += 1

    print(ans)

resolve()

Measured memory_bytes: 61956
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#define ll long long
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    ll arr[n];
    for(ll i=0;i<n;i++)cin>>arr[i];
    sort(arr,arr+n);
    cout<<abs(arr[0]-arr[n-1]);
    return 0;
}


Measured memory_bytes: 256
a = int(input())
b = int(input())
if a == 1 :
    if b == 2 :
        print("3")
    if b == 3 :
        print("2")
if a == 2 :
    if b == 1 :
        print("3")
    if b == 3 :
        print("1")
if a == 3 :
    if b == 2 :
        print("1")
    if b == 1 :
        print("2")

Measured memory_bytes: 2568
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll =long long;
int main(){
    int k,n;
    cin>>k>>n;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    int sum =0;
    int maxk=0;
    rep(i,n-1){
        maxk=max(maxk,a[i+1]-a[i]);

    }
    maxk=max(maxk,k-a[n-1]+a[0]);
    int ans=k-maxk;
  cout << ans;
   
}
    

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
//#define int long long  
int main(){
    int x,y,z;
    cin >> x >> y >> z;
    cout <<(x-z)/(y+z) << endl;
	return 0;
}

Measured memory_bytes: 256
// 最小全域技を求める
// O(E log V)


#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

template<typename T>
T prim(vector<vector<pair<int, T>>> &g){
    int n = (int)g.size();
    T ret = 0;
    vector<bool> used(n, false);
    using P = pair<T, int>;
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, 0});
    while(!que.empty()){
        auto p = que.top();
        que.pop();
        if(used[p.second]) continue;
        used[p.second] = true;
        ret += p.first;
        for(auto &e : g[p.second]){
            que.push({e.second, e.first});
        }
    }

    return ret;
}

signed main(){
    
    int n, m; cin >> n >> m;
    vector<vector<pair<int, int>>> g(n);
    for(int i = 0; i < m; i++){
        int a, b, c; cin >> a >> b >> c;
        g[a].push_back({b, c});
        g[b].push_back({a, c});
    }

    cout << prim<int>(g) << endl;
    return 0;
}



Measured memory_bytes: 12436
#include <stdio.h>

int main(){
  int N,M;
  int A;
  int all=0;
  int i;
  scanf("%d %d",&N,&M);
  
  for(i=0;i<M;i++){
    scanf("%d",&A);
    all+=A;
  }
  
  if(N-all >=0) printf("%d\n",N-all);
  else printf("-1\n");
  
  return 0;
}



Measured memory_bytes: 1732