akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890123456789LL
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) (((x) < 0)?-(x):(x))
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

using cat = long long;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N, M;
	int S[2];
	cin >> N >> M >> S[0] >> S[1];
	S[0]--, S[1]--;
	vector< vector< pair<int, cat> > > G(N);
	for(int i = 0; i < M; i++) {
		int u, v;
		cat d;
		cin >> u >> v >> d;
		G[--u].push_back({--v, d});
		G[v].push_back({u, d});
	}
	vector<cat> dist[2], cnt[2];
	cat mod = 1000000007;
	for(int k = 0; k < 2; k++) {
		dist[k].resize(N, OVER9000);
		cnt[k].resize(N, 0);
		priority_queue< pair<cat, int>, vector< pair<cat, int> >, greater< pair<cat, int> > > q;
		dist[k][S[k]] = 0;
		q.push({0, S[k]});
		cnt[k][S[k]] = 1;
		while(!q.empty()) {
			pair<cat, int> p = q.top();
			q.pop();
			if(p.ff != dist[k][p.ss]) continue;
			ALL_THE(G[p.ss], it) if(p.ff == dist[k][it->ff]+it->ss) {
				cnt[k][p.ss] += cnt[k][it->ff];
				if(cnt[k][p.ss] >= mod) cnt[k][p.ss] -= mod;
			}
			ALL_THE(G[p.ss], it) if(dist[k][it->ff] > p.ff+it->ss) {
				dist[k][it->ff] = p.ff+it->ss;
				q.push({dist[k][it->ff], it->ff});
			}
		}
	}
	cat ans = cnt[0][S[1]] * cnt[0][S[1]] % mod;
	for(int i = 0; i < N; i++) if(dist[0][i]+dist[1][i] == dist[0][S[1]])
		if(dist[0][i] == dist[1][i]) {
			cat paths = cnt[0][i] * cnt[1][i] % mod;
			ans -= paths * paths % mod;
		}
	for(int i = 0; i < N; i++) if(dist[0][i]+dist[1][i] == dist[0][S[1]])
		ALL_THE(G[i], it) if(dist[0][it->ff]+dist[1][it->ff] == dist[0][S[1]])
			if(dist[0][i] < dist[1][i] && dist[0][it->ff] > dist[1][it->ff]) {
				if(dist[0][i] + dist[1][it->ff] + it->ss != dist[0][S[1]]) continue;
				cat paths = cnt[0][i] * cnt[1][it->ff] % mod;
				ans -= paths * paths % mod;
			}
	ans %= mod;
	if(ans < 0) ans += mod;
	cout << ans << "\n";
	return 0;
}

// look at my code
// my code is amazing


Measured memory_bytes: 18772
#include<stdio.h>
#include<string.h>

int main(){
  int i,n,j,s;
  int m[11][11];
  char buf[500],*prev,*ind;
  do{
    fgets(buf,500,stdin);
    n=atoi(buf);
    if(!n) break;
    for(j=0,i=0;i<n;i++,j=0){
      fgets(buf,500,stdin);
      prev=ind=buf;
      while((ind=strchr(ind,' '))!=NULL){
	*ind='\0';
	ind++;
	m[i][j++]=atoi(prev);
	prev=ind;
      }
      m[i][j]=atoi(prev);
    }
    for(i=0,s=0;i<n;i++){
      m[i][n]=m[n][i]=0;
      for(j=0;j<n;j++){
	m[i][n]+=m[i][j];
	m[n][i]+=m[j][i];
      }
      s+=m[i][n];
    }
    m[n][n]=s;
    n++;
    for(i=0;i<n;i++){
      for(j=0;j<n;j++){
	printf("%5d",m[i][j]);
      }
      printf("\n");
    }
  }while(1);
  return 0;
}

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

/* void printv(stack<int> q){ */
/*   for(int i:q)cout<<i<<' '; */
/*   cout<<endl; */
/* } */

// Note:this is a wrong answer
int main() {
  string s;
  cin >> s;
  stack<int> tmp;
  stack<pair<int, int>> ans; // pos, areas

  for (int i = 0; i < int(s.length()); i++) {
    if (s[i] == '\\') {
      tmp.push(i);
    } else if (s[i] == '/') {
      if (!tmp.empty()) {
        int distance = i + 1 - tmp.top();
        int area = distance - 1;
        while (!ans.empty() && ans.top().first > tmp.top()) {
          area += ans.top().second;
          ans.pop();
        }
        ans.push(make_pair(tmp.top(), area));
        tmp.pop();
      }
    }
  }

  int sum_areas = 0;
  vector<int> L;
  while (!ans.empty()) {
    sum_areas += ans.top().second;
    L.push_back(ans.top().second);
    ans.pop();
  }
  reverse(L.begin(), L.end());
  cout << sum_areas << endl;
  cout << L.size();
  for (int i : L) {
    cout << ' ' << i;
  }
  cout << endl;
}



Measured memory_bytes: 3272
r,g,b,n = (int(i) for i in input().split())

cnt = 0
for i in range((n+1)//r + 1):
    for j in range((n+1)//g + 1):
        s = i*r + g*j
        if s>n:
            continue
        if (n-s)%b == 0:
            cnt += 1


print(cnt)

Measured memory_bytes: 40812
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
using namespace std;

int main(){
    unsigned long long Q, H, S, D, N;
    cin >> Q >> H >> S >> D >> N;

    //1Lの最小金額
    unsigned long long one;
    one = 4*Q;
    if(2*H < one)
        one = 2*H;
    if(S < one)
        one = S;

    //2Lの最小金額
    unsigned long long two;
    two = 8*Q;
    if(4*H < two)
        two = 4*H;
    if(2*S < two)
        two = 2*S;
    if(D < two)
        two = D;
    
    unsigned long long sum;
    //1Lと2Lを組み合わせて買う
    if(N%2 == 0)
        sum = two*(N/2);
    else
        sum = two*(N/2) + one;

    cout << sum << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
class Solver{
public:
    static const int MAXN=2e5+10;
    const ll MOD=1e9+7;
    ll n,k;
    ll fact[MAXN];
    ll inv[MAXN];
    ll qpow(ll n,ll t){
        ll a=n,r=1;
        while(t){
            if(t&1)r=(r*a)%MOD;
            a=(a*a)%MOD;
            t>>=1;
        }
        return r;
    }
    ll C(ll s,ll t){
        return fact[s]*inv[t]%MOD*inv[s-t]%MOD;
    }
    void preCal(){
        fact[0]=inv[0]=1;
        for(int u=1;u<MAXN;u++){
            fact[u]=(fact[u-1]*u)%MOD;
            inv[u]=qpow(fact[u],MOD-2);
        }
    }
    void solve(){
        preCal();
        cin>>n>>k;
        k=min(k,n-1);
        ll ans=0;
        for(int z=0;z<=k;z++){
            ans=(ans+C(n,z)*C(n-1,z)%MOD)%MOD;
        }
        cout<<ans;
    }
};
int main()
{
    // freopen("in.txt","r",stdin);
    (new Solver())->solve();
}

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

using LL = long long;

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

    LL N;
    cin >> N;
    vector<LL> L;
    L.reserve(86);
    L[0] = 2;
    L[1] = 1;
    for (int i = 2; i <= N; i++){
        L[i] = L[i - 2] + L[i - 1];
    }

    cout << L[N] << endl;

    return 0;
}

Measured memory_bytes: 256
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
  

n = int(input())
np = set(prime_factorize(n))
npl = []
for i in np:
    j = 1
    j *= i
    while j <= n:
        npl.append(j)
        j *= i
npl.sort()

cz = 2
ans = 0
for cz in npl:
    # print(n, cz)
    if cz > n:
        break
    if n % cz == 0:
        ans += 1
        n //= cz
print(ans)

Measured memory_bytes: 9168
#include<iostream>
#include<algorithm>
#include<utility>
using namespace std;
const int N=1e5+5;
int n,ans;
pair<int,int> a[N];
int main(){
	cin>>n;
	for(int i=1;i<=n;++i){
		cin>>a[i].first;
		a[i].second=i;
	}
	sort(a+1,a+n+1);
	for(int i=1;i<=n;++i) if((i&1)!=(a[i].second&1)) ++ans;
	cout<<(ans>>1)<<endl;
	return 0;
} 

Measured memory_bytes: 1152
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define MP(x,y) make_pair(x,y)
#define X first
#define Y second

using namespace std;
using ll= long long ;

ll pow_mod(ll a, ll b){
  ll r = 1;
  for(;b>0; b>>=1){
    if(b&1) r = (r*a) ;
    a = (a * a);
  }
  return r;
}



int main(void){
  ll a, b, c, d, n;
  cin >>  n >> a >> b >> c >> d;
  bool ok = false;
  rep(i, n){
    if( a + i*c - (n-i-1)*d <= b &&  b <= a + i*d - (n-i-1)*c){
      ok = true;
    }
  }
  if(ok) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
//package atcoder;
 
import java.util.*;
//import java.math.BigDecimal;
 
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int s[] = new int [5];
		for(int i=0;i<5;i++) {
			s[i] = sc.nextInt();
		}
		for(int j=0;j<5;j++) {
			if(s[j]==0) {
				System.out.println(j+1);
				break;
			}
		}
		
	}
}

Measured memory_bytes: 35812
#include <bits/stdc++.h>
using namespace std;
const int MAXn = 1e5 + 10;
typedef pair<long long, int> pii;
pii ar[MAXn];
long long n, sz[MAXn], root, disroot, d[MAXn], hp3[MAXn];
vector<int> vec[MAXn];
vector<pii> ans;

bool cmp(pii p1, pii p2) {
	return p1.first > p2.first;
}

long long dfs1(int v, int  par) {
	long long res = 0;
	for (int i = 0; i < vec[v].size(); i++)
		if (vec[v][i] != par) {
			res += dfs1(vec[v][i], v) + hp3[vec[v][i]];
			hp3[v] += hp3[vec[v][i]];
		}
	hp3[v]++;

	return res;
	
}

void dfs2(int v, int par, long long sth) {
	if (sth != d[v]) {
		cout << -1;
		exit(0);
	}
	for (int i = 0; i < vec[v].size(); i++) {
		if (vec[v][i] != par) {
			dfs2(vec[v][i], v, sth - (hp3[vec[v][i]]) + (hp3[ar[0].second] - hp3[vec[v][i]]));
			
		}
		
	}
	
}
int main() {
	cin >> n;
	fill_n(sz, MAXn, 1);
	for (int i = 0; i < n; i++) {
		long long di;
		cin >> di;
		d[i] = di;
		ar[i].first = di;
		ar[i].second = i;
	}
	sort(ar, ar + n);
	for (int i = n - 1; i > 0; i--) {
		long long hp = ar[i].first - n;
		hp += 2LL * sz[ar[i].second];
		int hp2 = lower_bound(ar, ar + n, pii(hp, -1)) - ar;
		if (ar[hp2].first != hp)
			return cout << -1,0;
		sz[ar[hp2].second] += sz[ar[i].second];
		vec[ar[hp2].second].push_back(ar[i].second);
		vec[ar[i].second].push_back(ar[hp2].second);
		ans.push_back(pii(ar[i].second, ar[hp2].second));
	}
	disroot = dfs1(ar[0].second, -1);
	dfs2(ar[0].second, -1, disroot);
	if (ans.size() != n - 1)
		return cout << -1,0;
	for (int i = 0; i < ans.size(); i++)
		cout << ans[i].first + 1<< ' ' << ans[i].second + 1<< endl;
}

Measured memory_bytes: 16240
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i, n, init) for (ll i = init; i < (n); i++)
#define repd(i, n, init) for (ll i = (n); i >= init; i--)
#define repm(i, m) for (auto i = m.begin(); i != m.end(); i++)
#define repb(bit, n, init) for (ll bit = init; bit < (1 << n); ++bit)

int main()
{
    ll W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    cout << (x >= r && y >= r && W - r >= x && H - r >= y ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 3128
import sys

lines = sys.stdin.readlines()
s = [ord(c) - 96 for c in lines[0].strip()]
t = [ord(c) - 96 for c in lines[1].strip()]

def check(s, t):
  if not len(s) and len(t):
    print('Yes')
    return
  elif not len(t) and len(s):
    print('No')
    return
  elif not len(s) and not len(t):
    print('No')
    return
    
  if min(s) < max(t):
    print('Yes')
  elif min(s) > max(t):
    print('No')
  else:
    s.remove(min(s))
    t.remove(max(t))
    return check(s, t)

check(s, t)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)
#define repv(x, arr) for (auto &x : arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a, b) make_pair(a, b)
#define op(i) cout << (i) << endl;
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 2147483600;
const ll infl = 1e17;


int main()
{
    int n;
    cin >> n;
    int now = n;
    int cnt = 0;
    while (now>1){
        if (now%2==1)
            break;
        cnt++;
        now /= 2;
    }
    if (now==1)
        cout << "No" << endl;
    
    else {
        while (now > 1)
        {
            cnt++;
            now /= 2;
        }
        cout << "Yes" << endl;
        vll x = {1, 2, 3, n + 1, n + 2, n + 3};
        rep(i, 5) cout << x[i] << " " << x[i + 1] << endl;
        if (n%2==1){
        repf(i,2,n/2+1){
            cout << 1 << " " << 2 * i << endl;
            cout << 2 * i << " " << 2 * i + 1 << endl;
            cout << 1 << " " << 2 * i + 1 + n << endl;
            cout << 2 * i + 1 + n << " " << 2 * i + n << endl;
        }
        }
        else {
            repf(i,2,n/2){
                cout << 1 << " " << 2 * i << endl;
                cout << 2 * i << " " << 2 * i + 1 << endl;
                cout << 1 << " " << 2 * i + 1 + n << endl;
                cout << 2 * i + 1 + n << " " << 2 * i + n << endl;
            }
            int z = n + 1;
            int x = 1;
            int y = 0;
            repf(k,2,cnt+1){
                if((z>>k)&1){
                    x += (1 << k);
                    break;
                }
            }
            y = (z ^ x);
            cout << x+n << " " << n << endl;
            cout << y << " " << 2 * n << endl;
        }
    }
    
}


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

int main(){
    double n,m; cin >> n >> m;
    vector<int> A(n);
    double sum = 0;
    rep(i,n){
        cin >> A[i];
        sum += A[i];
    }
    sort(A.begin(),A.end());
    reverse(A.begin(),A.end());
    bool flag = true;

    rep(i,m){
        if(A[i] < sum/(4*m)){
            flag = false;
        }
    }

    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }


}

Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.*;

public class Main implements Runnable {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        // Run with 32MB stack
        Thread thread = new Thread(null, new Main(), "", 32 * 1024 * 1024);
        thread.start();
    }

    @Override
    public void run() {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        int N = Integer.parseInt(scanner.next());
        for (int i = 1; i < 10; i++) {
            for (int j = 1; j < 10; j++) {
                if (i * j == N) {
                    System.out.println("Yes");
                    return;
                }
            }
        }
        System.out.println("No");
    }
}


Measured memory_bytes: 25300
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int ps[] = new int [3];
		int dr[] = new int [2];
		int p,d;
		p=2001;
		for(int i=0;i<3;i++){
			ps[i]=sc.nextInt();
			if(p>ps[i]){
				p=ps[i];
			}
		}
		d=2001;
		for(int i=0 ; i<2 ; i++){
			dr[i] = sc.nextInt();
			if(d>dr[i]){
				d=dr[i];
			}
		}
		System.out.println(p+d-50);
	}
}

Measured memory_bytes: 17232
#include<iostream>
#include<string>
using namespace std;
 
int main(){
  string a, result;
  cin >> a;
  int str_len = a.length();
  for (int i(0);i < str_len; i++){
    // cout << (a[i] == '0') << endl;
    if (a[i] == '0' || a[i] == '1'){
      // 文字を追加する
      result = result += a[i];
    } else if (result.length() != 0 && a[i] == 'B') {
      // 文字を削除する
      result.erase( --result.end() );
    }
  }
  cout << result;
  // int a[] = {0,0,2,0,1,0,1,0,0,1,0,1,0};
  // int b,c;
  // cin >> b >> c;
  // cout << (a[b] == a[c] ? "Yes" : "No");
  // cin>>a>>b>>c;
  // cout << a[0] << b[0] << c[0];
  // char d[] = {a[0],b[0],c[0],'\0'};
  // cout << d;
  // const char *a = "dabfab";
  // char a[] = "si"; 
  // int a[2]={1,4};
  //cout << &a[0]<< &a[1] << &a[2];
  return 0;
}


Measured memory_bytes: 504
import sys
S = input()
T = input()

ans = ''
if T in S:
    for i in range(len(S)):
        if S[i] == '?':
            ans += 'a'
        else:
            ans += S[i]
    print(ans)
    sys.exit()

ok_flag=False
for i in range(len(S)):
    if S[i] == '?' or S[i] == T[0]:
        for j in range(len(T)):
            if i + j > len(S) - 1:
                break
            if S[i+j] != T[j] and S[i+j] != '?':
                break
        else:
            ok_flag = True
            s_p = i

if ok_flag:
    ans = ''
    for i in range(len(S)):
        if i == s_p:
            for j in range(len(T)):
                ans += T[j]
        elif i in list(range(s_p+1,s_p+len(T))):
            continue
        elif S[i] == '?':
            ans += 'a'
        else:
            ans += S[i]
    
    print(ans)
else:
    print('UNRESTORABLE')

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <cstdio>
#include <utility>
#include <climits>
#include <algorithm>
#include <queue>
#include <set>

using namespace std;

int cnt = 0;
vector<int> BubbleSort(vector<int> a){
    for(int i=0;i<a.size()-1;i++){
        for(int j=a.size()-1;j>=i+1;j--){
            if(a[j] < a[j-1]){
                swap(a[j],a[j-1]);
                cnt++;
            }
        }
    }
    return a;
}

vector<int> SelectionSort(vector<int> a){
    int mini;
    for(int i=0;i<a.size();i++){
        mini = i;
        for(int j=i;j<a.size();j++){
            if(a[j] < a[mini]){
                mini = j;
            }
        }
        if(i!=mini)cnt++;
        swap(a[i],a[mini]);
    }
    return a;
}

int main(void){
    int n;
    cin >> n;
    vector<int>a(n);
    for(int i=0;i<n;i++)
        cin >> a[i];
    
    a = SelectionSort(a);
    for(int i=0;i<n;i++){
        cout << a[i];
        if(i!=n-1)cout << " ";
    }
    cout << endl;
    cout << cnt << endl;
    
    
    return 0;
}

Measured memory_bytes: 1216
n=int(input())
a=list(map(int,input().split()))
k=[0]*8
s=0
for i in a:
    if i<400:
        k[0]+=1
    elif i<800:
        k[1]+=1
    elif i<1200:
        k[2]+=1
    elif i<1600:
        k[3]+=1
    elif i<2000:
        k[4]+=1
    elif i<2400:
        k[5]+=1
    elif i<2800:
        k[6]+=1
    elif i<3200:
        k[7]+=1
    else:
        s+=1
if k.count(0)==8:
    b=1
    c=s
    print(str(b)+" "+str(c))
else:
    b=8-k.count(0)
    c=b+s
    print(str(b)+" "+str(c))

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

using namespace std;

int a[222222], b[222222];
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
		scanf("%d", a + i);
	sort(a, a + n);
	int c = 0;
	while (n--) {
		if (b[n]) continue;
		for (int i = 1; i < 31; i++) {
			int x = (1 << i) - a[n];
			if (x <= 0) continue;
			int j = lower_bound(a, a + n, x) - a;
			if (j >= n || a[j] != x || b[j])
				continue;
			c++;
			int k = upper_bound(a, a + n, x) - a;
			while (b[--k]);
			b[k] = 1;
			break;
		}
	}
	cout << c << endl;
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
   ll sum=0, n,m,l;
    cin>>n>>m>>l;
    if(n==m && n%l==0){cout<<1<<endl;}
    else if(m==n && m%l!=0){cout<<0<<endl;} 
    else cout<<((m-n)+1)/l;

}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i < (int)(n); i++)
#define REP(i, m, n) for(int i = (m); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

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

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

template<class T> inline auto __lcm(T& a, T& b) 
{ return a * b / __gcd(a, b); }


int main() {
    ll L, R;  cin >> L >> R;
    ll l = L % 2019;
    ll r = R % 2019;
    ll ans = INF;
    for (ll i = L; i <= min(L + 2019*1LL, R); ++i) {
        for (ll j = i+1; j <= min(L + 2019*1LL, R); ++j) {
            chmin(ans, i*j % 2019);
        }
    }

    print(ans);

    return 0;
}



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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

int N, M, Q;
vector<int> a, b, c, d;
vector<int> A;
int ans = 0;

int calc() {
    int ret = 0;
    rep(i, Q) if (A[b[i]] - A[a[i]] == c[i]) ret += d[i];
    return ret;
}

void rec(int i) {
    if (i == N) {
        chmax(ans, calc());
        return;
    }

    int start = 1;
    if (i != 0) start = A[i - 1];
    for (int v = start; v <= M; v++) {
        A[i] = v;
        rec(i + 1);
    }
}

int main() {
    cin >> N >> M >> Q;
    a.resize(Q);
    b.resize(Q);
    c.resize(Q);
    d.resize(Q);
    rep(i, Q) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--;
        b[i]--;
    }

    A.resize(N, 1);
    rec(0);
    cout << ans << endl;
}


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

using namespace std;
#define rep(j,n) for(int j=0;j<(n);j++)

using ll = long long;
using P = pair<int, int>;

int main(int, char**)
{
  int h, w, k;
  cin >> h >> w >> k;

  vector< vector<char> > c(h, vector<char>(w));
  rep(i,h) rep(j,w) cin >> c[i][j];

  auto countbl = [&](int hsel, int wsel, vector< vector<char> > c) {
    vector< vector<char> > tmp = c;
    int mask = 1;
    rep(i,6) {      
      if (hsel & mask) rep(j,w) tmp[i][j] = 'r';
      if (wsel & mask) rep(j,h) tmp[j][i] = 'r';
      mask <<= 1;
    }
    int bl = 0;
    rep(i,h) rep(j,w) bl+=(tmp[i][j]=='#');

    return bl==k;
  };

  int ans = 0;
  rep(i,1<<h) rep(j,1<<w) ans += countbl(i,j,c);
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
using namespace std;
#define INF 110000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,int> P;


int main(){
    int N,a[110000];
    cin>>N;

    for(int i=0;i<N;i++) cin>>a[i];

    int maxa=0,mina=110000;
    for(int i=0;i<N;i++){
        maxa=max(maxa,a[i]);
        mina=min(mina,a[i]);
    }
    if(maxa-mina>=2) cout<<"No"<<endl;
    else if(maxa==mina){
        int x=a[0];
        if(x==N-1 || 2*x<=N) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }else{
        int p=0,q=0;
        for(int i=0;i<N;i++){
            if(a[i]==mina) p++;
            else q++; 
        }
        if(maxa*2<=2*p+q && p<maxa) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }


}


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

int main() {
  int a,b,c;
  int i,n1,n2,n3,n4;

  cin >> a;
  cin >> b;
  cin >> c;
  
  if(a*b >= c)
    cout << c;
  else
    cout << a*b;
  
}


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

int main()
{
    int n, k;
	cin>>n;
	if(n % 1000 == 0)
	{
		cout<<0;
	 } else{
	 	k = n%1000;
	 	k = 1000 - k;
	 	cout<<k;
	 }
	return 0;
}


Measured memory_bytes: 3620
import java.util.Scanner;

class Main{
      public static void main(String args[]){
	  Scanner sc = new Scanner(System.in);
	  int a,b,c,d;
	  a = sc.nextInt();
	  b = sc.nextInt();
	  c = sc.nextInt();
	  d = sc.nextInt();
	  while(true){
	      c-=b;
	      if(c<=0){
		  System.out.println("Yes");
		  break;
	      }
	      a-=d;
	      if(a<=0){
		  System.out.println("No");
		  break;
	      }
	  }
      }
}


Measured memory_bytes: 35728
#include<stdio.h>
#include<iostream>
#include<bitset>
using namespace std;
int main(){
  int k=0,ans=0,i,j,n,a[20],x[20][20],y[20][20],tmp,sum=0;
  scanf("%d\n",&n);
  for(i=0;i<n;i++){
    scanf("%d\n",&a[i]);
    for(j=0;j<a[i];j++){
      scanf("%d %d\n",&x[i][j],&y[i][j]);
    }
  }
  for(tmp=0;tmp<(1<<n);tmp++){
    bitset<20> s(tmp);
    for(i=0;i<n;i++){
      if(s[i]==1){
        for(j=0;j<a[i];j++){
          if(s[x[i][j]-1]!=y[i][j]){
            k=1;
            break;
          }
        }
      }
      if(k==1){
          break;
        }
    }
    if(k==0){
      for(i=0;i<n;i++){
        if(s[i]==1){
          sum++;
        }
      }
      if(sum>ans){
        ans=sum;
      }
    }
    k=0,sum=0;
  }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include <time.h>
typedef long long ll;
typedef long double ld;
#define INF (1LL<<60)
#define MOD1 1000000007
/*swap 交換*/
void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
/*2つのうち大きい数を返す*/
ll max2(ll a,ll b){return a>=b?a:b;}
/*2つのうち小さい数を返す*/
ll min2(ll a,ll b){return a>=b?b:a;}
/*絶対値*/
ll ABS(ll a){return a>=0?a:(-a);}
typedef struct{
    ll aa;
    ll bb;
}frequent;
// 小大
int compare(const void *a, const void *b){
    return *(ll *)a>*(ll *)b?1:*(ll *)a<*(ll *)b?-1:0;}
/*aのb進数時の桁数*/
ll digits(ll a, ll b){return a/b?1+digits(a/b,b):1;}
/*nをa進数にしたときの、i桁目の数*/
ll placenai(ll n, ll a, ll i){return i==1?n%a:placenai(n/a,a,i-1);}
int main(void){
    ll n,m,i,j,ans=0,l,q;
    scanf("%lld%lld",&n,&m);
    ll k[m],s[m][10],p[m],onoff[m];
    for(i=0;i<m;i++){
        scanf("%lld",&k[i]);
        for(j=0;j<k[i];j++){
            scanf("%lld",&s[i][j]);
        }
    }
    for(i=0;i<m;i++){
        scanf("%lld",&p[i]);
    }
    ll sw=pow(2,n);
    // printf("%lld %lld? ",sw,x);
    for(i=0;i<sw;i++){
        for(j=0;j<m;j++){
            onoff[j]=0;
        }
        for(j=1;j<=n;j++){
            if(placenai(i,2,j)==1){
                for(l=0;l<m;l++){
                    for(q=0;q<k[l];q++){
                        if(j==s[l][q]){
                            onoff[l]++;
                            break;
                        }
                    }
                }
                // // printf("//%lld %lld// ",i,j);
                // for(l=0;l<k[j-1];l++){
                //     printf("%lld ",s[j-1][l]-1);
                //     // onoff[s[j-1][l]-1]++;
                // }
            }
        }
        for(j=0;j<m;j++){
            // printf("%lld ",onoff[j]);
            if(onoff[j]%2!=p[j]) break;
        }
        // printf("\n");
        if(j==m){
            ans++;
            // printf("%lld ",i);
        }
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int maxn = 2e5 + 100;
char str[maxn];
int a[maxn];
int dp[(1<<26)];
int main()
{
    cin>>str;
    int L = strlen(str), ans = 0;
    for(int i = 0; i < L; i++){
        ans ^= (1<<(str[i] - 'a'));
        a[i] = ans;
    }
    memset(dp, 1, sizeof(dp));
    for(int i = 0; i < L; i++){
        int ok = 0;
        for(int j = 0; j < 26; j++) if(a[i] == 0 || (a[i]^(1<<j)) == 0) { dp[a[i]] = 1; ok = 1; break; }
        if(ok) continue;
        for(int j = 0; j < 26; j++)
            dp[a[i]] = min(dp[a[i]^(1<<j)]+1, dp[a[i]]);
        //  cout<<dp[a[i]]<<endl;
    }
    cout<<dp[a[L-1]]<<endl;
    return 0;
}


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

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  string s;
  cin >> s;
  int counta = 0, countb = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'a') {
      if (counta + countb < a + b) {
        cout << "Yes" << endl;
        counta++;
      } else {
        cout << "No" << endl;
      }
    } else if (s[i] == 'b') {
      if (counta + countb < a + b && countb < b) {
        cout << "Yes" << endl;
        countb++;
      } else {
        cout << "No" << endl;
      }
    } else {
      cout << "No" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
   int k,x,a; cin>>k>>x; a=x-k;
   rep(i,2*k-1) { a++; cout<<a<<" ";}
  cout<<endl;
}

Measured memory_bytes: 256
from collections import deque

def solve(n, m, AB):
    g = [[] for _ in range(n)]
    for a, b in AB:
        g[a - 1].append(b - 1)
        g[b - 1].append(a - 1)

    q = deque(maxlen = n)
    q.append((0, 0))
    used = {0}
    while len(q) > 0:
        i, d = q.popleft()
        if d >= 2:
            break
        for c in g[i]:
            if c in used:
                continue
            if d == 1 and c == n - 1:
                return 'POSSIBLE'
            q.append((c, d + 1))
            used.add(c)
    return 'IMPOSSIBLE'

_n, _m = map(int, input().split())
_AB = [map(int, input().split()) for _ in range(_m)]
print(solve(_n, _m, _AB))


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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,mi=1000000000,sum=0,a,b;
	string sa,sb;
	cin>>n;
	for(int i=1;i<n;i++){
		a=i;b=n-i;
		sa=to_string(a);sb=to_string(b);
		for(int j=0;j<sa.length();j++){
			sum+=stoi(sa.substr(j,1));
		}
		for(int k=0;k<sb.length();k++){
			sum+=stoi(sb.substr(k,1));
		}
		mi=min(mi,sum);
		sum=0;
	}
	cout<<mi<<endl;
	return 0;
}


Measured memory_bytes: 3688
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

S = input()

a = ["A", ""]

for a, b, c, d in product(a, repeat=4):
	if a+"KIH"+b+"B"+c+"R"+d == S:
		print("YES")
		break
else:
	print("NO")

Measured memory_bytes: 5200
from bisect import bisect
import itertools
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

sum_a = list(itertools.accumulate(a))
sum_b = list(itertools.accumulate(b))

nokori = k
counter = 0
ans = [0]

sum_a = [0] + sum_a #Bだけ取る場合に対応する

for i in sum_a:
    if i > k:
        break
    ans.append(counter + bisect(sum_b, k - i))
    counter +=1
print(max(ans))

Measured memory_bytes: 133548
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    N = int(input())
    A = sorted(map(int, input().split()), reverse=True)
    MAX_V = 10 ** 18

    if A[-1] == 0:
        print(0)
        exit()

    ans = 1
    for a in A:
        ans *= a
        if ans > MAX_V:
            ans = -1
            break
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 88432
import sys, re
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from collections import deque, defaultdict, Counter
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop, heapify
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()
ab = [LIST() for _ in range(M)]

#連結リスト
graph = [[] for _ in range(N)]

for a, b in ab:
	graph[a-1].append(b-1)
	graph[b-1].append(a-1)

#print(graph)
ans = 0

for x in permutations(range(1, N)):
	tmp = 0
	for i in range(N-1):
		if x[i] in graph[tmp]:
			tmp = x[i]
		else:
			break
	else:
		ans += 1

print(ans)


Measured memory_bytes: 5964
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <limits>
#include <queue>

using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin >> n;
    vector<pair<ll, ll>> xy(n);
    vector<pair<ll, ll>> x(n), y(n);
    for(int i = 0; i < n; ++i){
        ll xi, yi;
        cin >> xi >> yi;
        xy.at(i) = make_pair(xi, yi);
        x.at(i) = make_pair(xi, i);
        y.at(i) = make_pair(yi, i);
    }
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());

    priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> q;
    vector<bool> visited(n, false);
    q.push(make_pair(0, 0));
    ll count = 0;
    ll ans = 0;
    while(!q.empty() && count < n){
        auto p = q.top();
        q.pop();
        const ll i = p.second;
        const ll d = p.first;
        if(visited.at(i)){ continue; }
        visited.at(i) = true;
        ans += d;
        count++;

        const ll ix = lower_bound(
            x.begin(), x.end(), make_pair(xy.at(i).first, i)) - x.begin();
        const ll iy = lower_bound(
            y.begin(), y.end(), make_pair(xy.at(i).second, i)) - y.begin();
        if(ix > 0){
            ll nxt = x.at(ix - 1).second;
            if(!visited.at(nxt)){
                ll nxtd = abs(xy.at(nxt).first - xy.at(i).first);
                q.push(make_pair(nxtd, nxt));
            }
        }
        if(ix < n - 1){
            ll nxt = x.at(ix + 1).second;
            if(!visited.at(nxt)){
                ll nxtd = abs(xy.at(nxt).first - xy.at(i).first);
                q.push(make_pair(nxtd, nxt));
            }
        }
        if(iy > 0){
            ll nxt = y.at(iy - 1).second;
            if(!visited.at(nxt)){
                ll nxtd = abs(xy.at(nxt).second - xy.at(i).second);
                q.push(make_pair(nxtd, nxt));
            }
        }
        if(iy < n - 1){
            ll nxt = y.at(iy + 1).second;
            if(!visited.at(nxt)){
                ll nxtd = abs(xy.at(nxt).second - xy.at(i).second);
                q.push(make_pair(nxtd, nxt));
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 8308
h, w = map(int, input().split())
hw = [list(input()) for _ in range(h)]
num = 0
for i in range(h):
    num+=hw[i].count('#')

def check(i, j):
    if not (0<=i<h and 0<=j<w):
        return False
    if hw[i][j] == '#':
        return True
    return False

checked = set()
for i in range(h):
    for j in range(w):
        if hw[i][j] == '#':
            if (i,j) in checked:
                continue

            exist = False

            for di,dj in [(1,0),(-1,0),(0,1),(0,-1)]:
                ci = i + di
                cj = j + dj
                if check(ci, cj):
                    checked.add((ci,cj))
                    exist = True
            if exist:
                checked.add((i,j))
if num == len(checked):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i ++)
#define irep(i,n) for (int i = (int)(n) - 1;i >= 0;--i)
using namespace std;
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;

ll dp[3010][3010][4];

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

    int r,c,K; cin >> r >> c >> K;
    vector<vector<ll>> grid(r,vector<ll>(c,0));
    rep(i,K) {
        int r1,c1,v; cin >> r1 >> c1 >> v;
        --r1; --c1;
        grid[r1][c1] = v;
    }
    rep(i,r + 1)rep(j,c + 1)rep(k,4) dp[i][j][k] = 0;

    rep(i,r) {
        rep(j,c) {
            rep(k,4) {
                ll x = 0;
                rep(l,4) x = max(x,dp[i][j + 1][l]);
                if (k == 0) {
                    dp[i + 1][j + 1][k] = max(dp[i + 1][j + 1][k],x);
                } else if (k == 1) {
                    dp[i + 1][j + 1][k] = max(dp[i + 1][j + 1][k],x + grid[i][j]);
                }
                dp[i + 1][j + 1][k] = max(dp[i + 1][j + 1][k],dp[i + 1][j][k]);
                if (k > 0) {
                    dp[i + 1][j + 1][k] = max(dp[i + 1][j + 1][k],dp[i + 1][j][k - 1] + grid[i][j]);
                }
            }
        }
    }
    ll ans = 0;
    rep(i,4) ans = max(ans,dp[r][c][i]);
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 355740
#include<bits/stdc++.h>
using namespace std;
#define next Next
#define last Last
#define int long long
const int N=1e6+5;
int n;
char a[N];
/*char buf[1<<21],*p1=buf,*p2=buf;
inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}*/
#define gc getchar
inline int read()
{
	int ret=0,f=0;char c=gc();
	while(!isdigit(c)){if(c=='-')f=1;c=gc();}
	while(isdigit(c)){ret=ret*10+c-48;c=gc();}
	if(f)return -ret;return ret;
}
signed main()
{
	scanf("%s",a+1);
	n=strlen(a+1);
	for(int i=1;i<=n;i++)
		if(i%2==1)
		{
			if(a[i]=='L'){puts("No");return 0;}
		}
		else{
			if(a[i]=='R'){puts("No");return 0;}
		}
	puts("Yes");
}


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

#define endl "\n"
#define PB push_back
#define F first 
#define S second
#define int long long 
#define Runner_up ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

signed main()
{	
	Runner_up
	int n; cin>>n;
	int z = 100; int ans=0;
	while(true){
		if(z >= n) break;
		++ans;
		z = z + z/100;
	}
	cout<<ans;

	return 0;	
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
 
const int mod=1e9+7;
 
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};
 
mint c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}
 
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
 
    return true;
}
 
map<ll, ll> primeFact(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}
 
void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
void printv(vll& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}
 
int main()
{
  //init(); // mint初期化
  cin.tie( 0 );
  ios::sync_with_stdio( false );
 
  int n;
  cin>>n;
  vi p(n);
  rep(i,n)cin>>p[i];
  rvisort(p);
  int ans=vtotal(p)-p[0]/2;
  cout(ans);
 
  return 0;
}

Measured memory_bytes: 125568
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T>>
#define bn(x) ((1 << x) - 1)
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};

mint c[4005][4005];

void init()
{
    c[0][0] = 1;
    for (int i = 0; i <= 4000; i++)
    {
        for (int j = 0; j <= i; j++)
        {
            c[i + 1][j] += c[i][j];
            c[i + 1][j + 1] += c[i][j];
        }
    }
}

mint comb(int n, int k)
{
    return c[n][k];
}

mint f2(int n, int k)
{
    return comb(n + k - 1, k - 1);
}

mint f(int n, int k)
{
    if (n < k)
        return 0;
    if (n == 0 && k == 0)
        return 1;
    if (k < 1)
        return 0;
    return f2(n - k, k);
}

int main()
{
    init();
    int n, k;
    cin >> n >> k;

    for (int i = 1; i <= k; i++)
    {
        mint b = f(k, i);
        mint r = 0;
        {
            r += f(n - k, i - 1);
            r += f(n - k, i);
            r += f(n - k, i);
            r += f(n - k, i + 1);
        }
        mint ans = b * r;
        printf("%lld\n", ans.x);
    }

    return 0;
}


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int AB = A + B;
  int CD = C + D;
  if (AB > CD) cout << "Left" << endl;
  if (AB == CD) cout << "Balanced" << endl;
  if (AB < CD) cout << "Right" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

int main(){
	ll a,b,c;
	scanf("%lld%lld%lld",&a,&b,&c);
	printf("%lld",a==b?c:a==c?b:a);
}

Measured memory_bytes: 128
/*
_________________________
|   LIVE FREE OR DIE     |
|       327 2153         |
|          New           |
|_______HAMPSHIRE________|

*/
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define MAX 20
#define int long long
#define MOD 998244353


int check(int a,int b)
{
	int p = pow(a,5);
	int q = pow(b,5);
	return p-q;

}
int32_t main()
{
	IOS
	int x;cin>>x;
	for(int i=-1000;i<=1000;i++)
	{
		for(int j=-1000;j<=1000;j++)
		{
			if(check(i,j)==x){
				cout<<i<<" "<<j;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 4048
package main

import "fmt"

type i64 int64

const MOD i64 = 1000000007

// n!を保持する配列、n!の逆元を保持する配列
var fact, invf [202020]i64

// b**nをmodで割った余りを返却する
func modPow(b, n, mod i64) i64 {
	if n == 1 {
		return b
	}
    // (b**2)の(n/2)乗として計算
	ret := modPow(b*b%mod, n/2, mod)
	if n&1 == 1 {
		ret = ret * b % mod
	}
	return ret
}

// nの逆元を計算する
func inverse(n i64) i64 {
	return modPow(n, MOD-2, MOD)
}

func comb(n, k i64) i64 {
	if k < 0 || n < k {
		return 0
	}
	return fact[n] * invf[k] % MOD * invf[n-k] % MOD
}

func main() {
	var h, w, a, b, ans i64
	fmt.Scan(&h, &w, &a, &b)

	fact[0] = 1
	invf[0] = 1

	for i := i64(1); i <= 200020; i++ {
		fact[i] = (fact[i-1] * i) % MOD
		invf[i] = inverse(fact[i])
	}

	for i := i64(1); i <= h-a; i++ {
		ans += comb(b-1+i-1, b-1) * comb(w-b-1+h-i, h-i) % MOD
        ans %= MOD
	}
    
    fmt.Println(ans)
}


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

using ll = long long;
using pii = pair<int, int>; using pll = pair<ll, ll>;

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

template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class F, class S> istream& operator >> (istream& s, pair<F, S>& p)
{ s >> p.first >> p.second; return s;}

int main()
{
    int H, W, K; cin >> H >> W >> K;
    vector<string> C(H); cin >> C;

    int ans = 0;

    for (int h_pat = 0; h_pat < (1<<H); h_pat++) {
        for (int w_pat = 0; w_pat < (1<<W); w_pat++) {
            int c = 0;
            for (int h = 0; h < H; h++) {
                if (h_pat & (1 << h)) continue;
                for (int w = 0; w < W; w++) {
                    if (w_pat & (1 << w)) continue;
                    if (C[h][w] == '#') c++;
                }
            }
            if (c == K) ans++;
        }
    }

    cout << ans << endl;
}


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

using namespace std;

#define intt long long 
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int N = 200005;

int n;
int a[N];

map <int, int> mp;

int main() {

	FAST;

	cin >> n;
	for (int i = 1; i <= n; i ++) {
		cin >> a[i];
	}
	for (int i = 1; i <= n; i ++) {
		mp[a[i]] ++;
	}
	for (auto i : mp) {
		if (i.second > 1) {
			cout << "NO\n";
			return 0;
		}
	}
	cout << "YES\n";
	return 0;
}

Measured memory_bytes: 10368
#import 
#=input()
n=int(input())
#=map(int,input().split())
#=list(map(int,input().split()))
#=[list(map(int,input().split())) for _ in range()]
c = 0
d = 0
for i in range(n):
    a,b = map(int,input().split())
    if a == b:
        c += 1
    else:
        c = 0
    if c == 3:
        d = 1
        break
if d != 1:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 9172
N = int(input())
Tlist = [int(N) for N in input().split()]
M = int(input())
PXlist = [[int(i) for i in input().split()]for j in range(M)]
def time_sum():
    s = 0
    for i in range(0,N):
        s = s+Tlist[i]
    return s
def time_cal():
    empty = []
    for i in range(0,M):
        empty.append(time_sum() - Tlist[PXlist[i][0]-1] + PXlist[i][1])
    return empty
for i in time_cal():
    print(i)

Measured memory_bytes: 3064