akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,m,a,a1=0;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>a;
        a1+=a;
    }
    if(n<a1){
        cout<<-1<<endl;
    }else{
        cout<<n-a1<<endl;
    }
    
}


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

void solve()
{
    string S = "ACL";

    int K;
    cin>>K;

    string res = "";

    for(int i = 0 ; i < K; i++)
    {
        res += S;
    }

    cout<<res<<endl;
}

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

    solve();

    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
ll N;
map<pair<ll, ll>, ll>  mp;
ll gcd (ll a, ll b) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    return gcd(b, a%b);
}
ll pow_mod(ll a, ll b) {
    if (b == 0) return 1;
    ll k = pow_mod(a, b/2);
    k *= k;
    k %= mod;
    if (b % 2 == 0) return k;
    return (k*a)%mod;
}
int main() {
    cin >> N;
    for (int i = 1; i <= N; i++) {
        ll A, B;
        cin >> A >> B;
        ll C = gcd(abs(A), abs(B));
        if (C != 0) {
            A /= C, B /= C;
            if (A == 0) {
                B /= abs(B);
            }
            else if (B == 0) {
                A /= abs(A);
            }
        }
        mp[make_pair(A, B)]++;
    }
    vector<pair<ll, ll>> v;
    for (auto x: mp) {
        auto p = x.first;
        if (p.first == 0 && p.second == 0) continue;
        auto q = make_pair(-p.second, p.first);
        auto r = make_pair(-q.second, q.first);
        auto s = make_pair(-r.second, r.first);
        auto a = mp[p], b = mp[q], c = mp[r], d = mp[s];
        set<pair<ll, ll>> st;
        if (a) st.insert(p);
        if (b) st.insert(q);
        if (c) st.insert(r);
        if (d) st.insert(s);
        if (*(st.begin()) == p) {
            v.push_back(make_pair(a+c, b+d));
        }
    }
    ll ans = 1;
    for (int i = 0; i < v.size(); i++) {
        ans *= (1+(pow_mod(2, v[i].first)-1)+(pow_mod(2, v[i].second)-1)) % mod;
        ans %= mod;
    }
    ans--;
    ans += mod+mp[make_pair(0, 0)];
    ans %= mod;
    cout << ans << endl;
}

Measured memory_bytes: 56352
#include<stdio.h>
int main()
{
	char a[3][3];
	int i,j;
	for(i=0;i<3;i++)
	{
		for(j=0;j<3;j++)
		{
			scanf("%c",&a[i][j]);
		}
		getchar();
	}
	printf("%c%c%c",a[0][0],a[1][1],a[2][2]);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#define BUFMAX 10

int main(){
    char buf[BUFMAX];
    int num;

    fgets(buf,BUFMAX,stdin);
    buf[BUFMAX-1] = '\0';
    sscanf(buf,"%d", &num);
    num = num * num * num;
    printf("%d\n",num);
    return 0;
}

Measured memory_bytes: 1732
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;

enum mod = 1_000_000_007L;




void main() {
    string s;
    scan(s);
    int ans;
    foreach (i ; 1 .. s.length) {
        if (s[i] != s[i - 1]) ans++;
    }
    writeln(ans);
}




void scan(T...)(ref T args) {
    auto line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x > arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x < arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

void yes(bool ok, string y = "Yes", string n = "No") {
    return writeln(ok ? y : n);
}


Measured memory_bytes: 508
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String[] s = new String[n];
		for(int i = 0; i < n; i++){
			s[i] = sc.next();
		}
		HashMap<String,Integer> map = new HashMap<String,Integer>();
		for(int i = 0; i < n; i++){
			int[] a = new int[10];
			for(int j = 0; j < 10; j++){
				a[j] = s[i].charAt(j);
			}
			Arrays.sort(a);
			String b = "";
			for(int j = 0; j < 10; j++){
				b=b + a[j] + " ";
			}
			if(map.containsKey(b)){
				map.put(b,map.get(b)+1);
			}else{
				map.put(b,0);
			}
		}
		long ans = 0;
		Iterator<String> it = map.keySet().iterator();
		while (it.hasNext()) {
			String key = it.next();
			for(long i = map.get(key); i > 0; i--){
				ans+=i;
			}
		}
		System.out.print(ans);
	}
}


Measured memory_bytes: 113536
#include<iostream>
using namespace std;
#define MAX 100000
typedef long long llong;

int n,k;
llong T[MAX];

int check(llong p){
  int i=0;
  for(int j=0;j<k;j++){
    llong s=0;
    while(s+T[i]<=p){
      s+=T[i];
      i++;
      if(i==n) return n;
    }
  }
  return i;
}

int solve(){
  llong left = 0;
  llong right = 100000 * 10000;
  llong mid;
  while(right - left >1){
    mid = (left + right)/2;
    int v = check(mid);
    if(v>=n) right = mid;
    else left = mid;
  }

  return right;
}

main(){
  cin >> n >> k;
  for(int i =0;i<n;i++) cin >> T[i];
  llong ans = solve();
  cout << ans << endl;
}



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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

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

const ll LINF=1LL<<60;
const int INF=1<<29;
const int MOD=1e9+7;

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


int main(){
    int n, x, t; 
    cin >> n >> x >> t;
    cout << (n+x-1)/x*t << endl;
    return 0;
}

Measured memory_bytes: 3588
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

K = int(input())

ans = set()
def dfs(last, lis):
    ans.add(int(''.join(lis)))
    if len(lis)==11:
        return
    dfs(last, lis+str(last))
    if last!=0:
        dfs(last-1, lis+str(last-1))
    if last!=9:
        dfs(last+1, lis+str(last+1))

for i in range(1, 10):
    dfs(i, str(i))

ans = list(ans)
ans.sort()
print(ans[K-1])

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

const long long MOD = 1000000007;


// from 蟻本(P116)
long long mod_pow(long long x, long long n){
    if(n==0){
        return 1;
    }
    long long res = mod_pow(x * x % MOD,n/2);
    if(n&1){
        res = res * x % MOD;
    }
    return res;
}

// from https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a#3-%E5%89%B2%E3%82%8A%E7%AE%97-a--b
// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a) {
    long long b = MOD, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= MOD;
    if (u < 0) u += MOD;
    return u;
}

void solve(long long n, long long a, long long b){
    long long comna;
    long long comnb;
    long long comn =1;
    for(long long i=1LL;i<=b;i++){
        comn = ((comn * (n+1-i) %MOD)* modinv(i)) % MOD;
        if(i==a){
            comna = comn;
            cerr << comna << endl;
        }
        if(i == b){
            comnb = comn;
            cerr << comnb << endl;
        }
    }
    long long ans = mod_pow(2,n);
    cerr << ans << endl;
    ans = (ans -comna -comnb -1 + MOD *3)%MOD;
    cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long n;
    scanf("%lld",&n);
    long long a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    solve(n, a, b);
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>

int main() {
	int N;
	scanf("%d", &N);
	int input[100000];

	for (int i = 0; i < N; i++)
	{
		scanf("%d", &input[i]);
	}

	int index = 0;
	int cnt = 0;

	for (int i = 0; i < N; i++)
	{
		if (index == 1) {
			printf("%d\n", cnt);
			return 0;
		} else {
			cnt++;
			index = input[index] - 1;
		}
	}
	printf("-1");
	return 0;
}


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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i = (a-1); i >= (b); --i)
#define RREP(i,n) RFOR(i,n,0)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

int cnt = 0;

void insertionSort(vi &a, int g)
{
    FOR(i, g, a.size()) {
        int v = a[i];
        int j = i - g;
        while(j >= 0 && a[j] > v) {
            a[j + g] = a[j];
            j -= g;
            cnt++;
        }
        a[j + g] = v;
    }
}

void shellSort(vi &a) {
    vi v;
    for(int i = 1; i <= a.size(); i = i * 3 + 1) {
        v.push_back(i);
    }
    RREP(i, v.size()) {
        insertionSort(a, v[i]);
    }
    reverse(v.begin(), v.end());
    cout << v.size() << endl;
    cout << v[0];
    FOR(i, 1, v.size()) cout << " " << v[i];
    cout << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(10);
    
    int n; cin >> n;
    vi a(n); REP(i, n) cin >> a[i];

    shellSort(a);

    cout << cnt << endl;

    REP(i, n) cout << a[i] << endl;

    return 0;
}


Measured memory_bytes: 6800
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int SelectionSort(int *a,int n)
{
	int sw=0;
	for(int i=0;i<n;i++){
		int tmp=i;
		for(int j=i+1;j<n;j++){
			if(a[tmp]>a[j]) {
				tmp=j;
			}
		}
		if(tmp!=i){
			swap(a[tmp],a[i]);
			sw++;
		}
	}
	return sw;
}

int main()
{
#ifdef CDZSC
	freopen("Text.txt","r",stdin);
#endif
	int a[150];
	int n,num;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	num=SelectionSort(a, n);
	for(int i=0;i<n;i++){
		if(i) cout<<" ";
		cout<<a[i];
	}
	cout<<endl;
	cout<<num<<endl;
	return 0;
}

Measured memory_bytes: 3060
#include <iostream>


using namespace std;

int main()
{
    double a,b;

    cin >> a >> b;

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


Measured memory_bytes: 3184
def op2(f, c, r):
  if r == 0:
    if f == "1":
      left.append(c)
    elif f == "2":
      right.append(c)

  if r == 1:
    if f == "1":
      right.append(c)
    elif f == "2":
      left.append(c)

S = input()
Q = int(input())
v = [list(input().split()) for i in range(Q)]
rev = 0
left = []
right = []

for val in v:
  if val[0] == "1":
    if rev == 0:
      rev = 1
    elif rev == 1:
      rev = 0
  elif val[0] == "2":
    op2(val[1], val[2], rev)

nleft = left[::-1]
ans = "".join(nleft + [S] + right)

if rev == 0:
  print(ans)
else:
  print(ans[::-1])

Measured memory_bytes: 35680
from collections import defaultdict
def getN():
    return int(input())


def getNM():
    return map(int, input().split())


def getList():
    return list(map(int, input().split()))

N = getN()
nums = getList()
dup = defaultdict(int)

for n in nums:
    dup[n] += 1

poss = len(dup.keys())
dupdup = 0
for val in dup.values():
    if val % 2 == 0:
        dupdup += 1

if dupdup % 2 == 0:
    print(poss)
else:
    print(poss-1)

Measured memory_bytes: 18656
A,B,K=map(int,input().split())
k=0

def sousa(A,B,k):
    if k%2==0:
        return [A//2,B+A//2,k+1]
    else:
        return [A+B//2,B//2,k+1]
    
while 1:
    x=sousa(A,B,k)
    A,B,k=x[0],x[1],x[2]
    if k==K:
        break
    
print(A,B)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int inf = 1e9;
#define rep(i, n) for (int i = 0; i < n; i++)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

int n;
vector<vector<pint>> g (10005);

void dijkstra() {
    int d[n];
    bool seen[n] = {};
    rep (i, n) d[i] = inf;
    d[0] = 0;
    priority_queue<pint, vector<pint>, greater<pint>> pq;
    pq.push ({0, 0});

    while (!pq.empty()) {
        pint f = pq.top();
        pq.pop();
        int u = f.second; // firstはコスト,secondは場所
        seen[u] = 1;

        if (d[u] < f.first) continue;
        // cout << u << " " << d[u] << "\n";
        rep (i, g[u].size()) {
            int v = g[u][i].second;
            if (!seen[v] && d[v] > d[u] + g[u][i].first) {
                d[v] = d[u] + g[u][i].first;
                pq.push ({d[v], v});
            }
        }
    }
    rep (i, n) cout << i << " " << d[i] << "\n";
}

int main() {
    cin >> n;
    rep (i, n) {
        int now, k, v, c;
        cin >> now >> k;
        rep (j, k) {
            cin >> v >> c;
            g[now].push_back ({c, v});
        }
    }
    dijkstra();
}


Measured memory_bytes: 8012
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#define int long long
#define ll getchar();getchar();return 0;
using namespace std;
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n%i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	int ans;
	for (int i = (min(x, y)); i >= 1; i--) {
		if (x%i == 0 && y%i == 0) {
			ans = i;
			break;
		}
	}
	return ans;
}
int yakusuunowa(int n) {
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (n%i == 0)ans += i;
	}
	return ans;
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int ketanowa(int n) {
	int cnt = 0, sum = 0;
	for (int i = 10; i <= n * 10; i *= 10) {
		if (i == 10)cnt += n % i;
		else sum += (n%i - n % (i / 10)) / (i / 10);
	}
	return cnt + sum;
}
signed main() {
	string s;
	cin >> s;
	if ((s[0] == s[1] && s[1] == s[2]) || (s[1] == s[2] && s[2] == s[3]))puts("Yes");
	else puts("No");
	ll
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rrep(i, n) for(ll i = n - 1; i > -1; i--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define fi first
#define se second
#define debug(V) rep(i, V.size()) cout << V[i] << " ";
const ll INF = (1LL << 61) - 1;
const ll MOD = 1000000007 /*998244353*/;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, h, x, y, z, p, q, n, t, r, k, w, l, ans, i, j, u, v;
string S, T;
vl A, B;
void input() {
    cin >> n >> k;
    rep(i, n) {
        cin >> x;
        A.pb(x);
    }
}
void solve() {
    sort(all(A));
    rep(i, k) { a += A[i]; }
    cout << a << endl;
}
int main() {
    // cout<<fixed<<setprecision(15);
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    solve();
}

Measured memory_bytes: 3672
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <list>
#include <utility>
#include <tuple>
#include <cstdio>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <cmath>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
const long long INF = 1LL << 60;
typedef long long ll;
int main() {
    int D;
    cin >> D;
    ll min_num =1;
    if(D == 0){
        min_num = 1;
    }
    else{
        for(int i=0;i<D;i++){
            min_num = min_num*100;
        }
    }
    ll N;
    cin >> N;
    ll ans;
    if(N!=100){
        ans = min_num * N;
    }
    else{
        ans = min_num * 101;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3620
#include <stdio.h>
int n, m, a[100], b[100];
int main() {
	scanf("%d%d", &n, &m);
	for(int i = 0; i < m; i++) scanf("%d%d", &a[i], &b[i]);
	int l = 1, c = 0;
	while(l <= n) {
		int ptr = -1;
		for(int i = 0; i < m; i++) {
			if(a[i] <= l && l <= b[i] && b[ptr] < b[i]) ptr = i;
		}
		if(ptr == -1) { printf("Impossible\n"); return 0; }
		l = b[ptr] + 1; c++;
	}
	printf("%d\n", c);
	return 0;
}

Measured memory_bytes: 2724
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch Tag | diff Tag.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address Tag.cpp && ./a.out

/*

 6/13/2020

 5:01-

 */

LL A,V,B,W,T;

bool solve() {
  if(A>B) swap(A,B);
  return (W-V)*T<=A-B;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;

  cin>>A>>V>>B>>W>>T;
  cout<<(solve()?"YES":"NO")<<endl;

  return 0;
}


Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int k = Integer.parseInt(sc.next());
        int x = Integer.parseInt(sc.next());
        
        if(k * 500 >= x){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 22228
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp> 
#include<ext/pb_ds/tree_policy.hpp> 
#define int long long int
#define all(v) v.begin(),v.end() 
#define rev(v) v.rbegin(),v.rend()
#define ssd ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define ordered_set tree<ll, null_type, less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define trace(x) cerr<<#x<<" : "<<x<<endl;
#define inp 100005
#define en "\n"
using namespace std;
using namespace __gnu_pbds;

signed main() 
{
    ssd
    int i,j,n,k;
	cin>>n>>k;
	vector<int> val(n+5);
	for(i=1;i<=n;i++) cin>>val[i];

	vector<vector<int>> dp(n+5, vector<int>(k+5,0));
	for(i=0;i<=n;i++) dp[i][0]=1; // If x students and no candies available
	int pre[k+5];
	
	for(i=1;i<=n;i++)
	{
		memset(pre,0,sizeof(pre));
		pre[0] = 1;
		for(j=1;j<=k;j++)
		{	
			pre[j] = pre[j-1] + dp[i-1][j];
			pre[j] %= mod;
		}
		for(j=1;j<=k;j++)
		{
			int r = j;
			int l = max(j-val[i], (int)0);
			if(l!=0) 
			{
				l--;
				dp[i][j] = pre[r] - pre[l];
			}
			else
			{
				dp[i][j] = pre[r];	
			}
			dp[i][j] = (dp[i][j] + mod) % mod;
		}
	}
	cout<<dp[n][k];
    return 0;           
}

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

int main()
{
    string s;string t;
    getline(cin,s);
    getline(cin,t);
    for(int i=0;i<s.size();i++)
    {
        if(s[i]!=t[i])
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


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

using namespace std;

vector<set<int> > r2b, b2r;

int pop_red(int i);
int pop_blue(int j);

int
main()
{
    int n;
    cin >> n;
    vector<int> rx(n), ry(n), bx(n), by(n);
    for (int i = 0; i < n; i++)
        cin >> rx[i] >> ry[i];
    for (int i = 0; i < n; i++)
        cin >> bx[i] >> by[i];

    r2b.resize(n);
    b2r.resize(n);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (rx[i] < bx[j] && ry[i] < by[j]) {
                r2b[i].insert(j);
                b2r[j].insert(i);
            }
        }
    }
    int count = 0;
    while (true) {
        for (int i = 0; i < n; i++) {
            if (r2b[i].size() == 1)
                count += pop_red(i);
        }
        for (int j = 0; j < n; j++) {
            if (b2r[j].size() == 1)
                count += pop_blue(j);
        }
        int rmin = -1, rminsize = n + 1;
        for (int i = 0; i < n; i++) {
            if (r2b[i].size() > 0 && r2b[i].size() < rminsize) {
                rmin = i;
                rminsize = r2b[i].size();
            }
        }
        if (rmin == -1)
            break;
        int bmin = -1, bminsize = n + 1;
        for (int j : r2b[rmin]) {
            if (b2r[j].size() > 0 && b2r[j].size() < bminsize) {
                bmin = j;
                bminsize = b2r[j].size();
            }
        }
        count++;
        for (int b : r2b[rmin])
            b2r[b].erase(rmin);
        r2b[rmin].clear();
        for (int r : b2r[bmin])
            r2b[r].erase(bmin);
        b2r[bmin].clear();
    }
    cout << count << endl;
}

int
pop_red(int i)
{
    int count = 1;
    int j = *r2b[i].begin();
    r2b[i].erase(j);
    b2r[j].erase(i);
    auto rem = b2r[j];
    b2r[j].clear();
    for (auto r : rem)
        r2b[r].erase(j);
    for (auto r : rem) {
        if (r2b[r].size() == 1)
            count += pop_red(r);
    }
    return count;
}

int
pop_blue(int j)
{
    int count = 1;
    int i = *b2r[j].begin();
    b2r[j].erase(i);
    r2b[i].erase(j);
    auto rem = r2b[i];
    r2b[i].clear();
    for (auto b : rem)
        b2r[b].erase(i);
    for (auto b : rem) {
        if (b2r[b].size() == 1)
            count += pop_blue(b);
    }
    return count;
}


Measured memory_bytes: 512
#include <stdio.h>
#define NIL -1

int dp[50];
int fib(int n){
    if(n==0 || n==1){
        return dp[n]=1;
    }
    if(dp[n]!=NIL) return dp[n];
    return dp[n]=fib(n-1)+fib(n-2);
}

int main(){
    int n,i;

    for(i=0;i<50;i++){
        dp[i]=NIL;
    }
    scanf("%d",&n);
    printf("%d\n",fib(n));
    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#include <atcoder/convolution>
using namespace std;
using namespace atcoder;
int main(){
  int N, M;
  cin >> N >> M;
  vector<int> a(N);
  for (int i = 0; i < N; i++){
    cin >> a[i];
  }
  vector<int> b(M);
  for (int i = 0; i < M; i++){
    cin >> b[i];
  }
  vector<int> c = convolution(a, b);
  for (int i = 0; i < N + M - 1; i++){
    cout << c[i];
    if (i < N + M - 2){
      cout << ' ';
    }
  }
  cout << endl;
}

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

using namespace std;
typedef pair<int,int> pii;
typedef long long int ll;

#define INF 1 << 29
#define REP(i,n) for(ll i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(ll i=(k);i<(int)(n);i++)



vector<bool> gen_sosuu(vector<bool> sosuu){
  int size = sosuu.size();
  REP(i,size){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(size)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<size;j++){
      sosuu[i*j] =false;
    }
  }
  return sosuu;
}

string s[3];
int ind[3] = {0};
int turn = 0;

int main(){
  REP(i,3) cin >> s[i];
  while(true){
    if(ind[turn] == s[turn].size()){
      printf("%c\n",'A'+turn);
      return 0;
    }
    char now = s[turn][ind[turn]];
    ind[turn]+=1;
    turn = now - 'a';
  }
}


Measured memory_bytes: 256
import math

A,B,H,M = map(int,input().split())
AX = A * math.cos(2*math.pi*(H/12.+M/12./60.))
AY = A * math.sin(2*math.pi*(H/12.+M/12./60.))
BX = B * math.cos(2*math.pi*M/60.)
BY = B * math.sin(2*math.pi*M/60.)

ans = math.sqrt((AX-BX)**2+(AY-BY)**2)
print(ans)

Measured memory_bytes: 9464
import sys
import numpy as np

n = int(input())

a =  map(int, input().split())

ng = False
for an in a:
    if (an % 2 != 0):
        continue
    if (an % 3 == 0) | (an % 5 ==0):
        continue
    else:
        ng = True
        break
if ng:
    print("DENIED")
else:
    print("APPROVED")

Measured memory_bytes: 21520
def primes(n):
  tf = [True] * (n + 1)
  tf[0] = tf[1] = False
  for i in range(2, int(n ** (1 / 2)) + 1):
    if tf[i]:
      for j in range(i ** 2, n + 1, i):
        tf[j] = False
  return [i for i in range(n + 1) if tf[i]]

def add_twin(prime_lst, twin_lst):
  prime_lst2 = prime_lst[1:]
  for x, y in zip(prime_lst, prime_lst2):
    if y - x == 2:
      twin_lst.append(y)

def search_twin(x, twin_lst):
  left = 0
  right = len(twin_lst)
  while left + 1 < right:
    mid = (left + right) // 2
    if twin_lst[mid] > x:
      right = mid
    elif twin_lst[mid] < x:
      left = mid
    else:
      return x
  return twin_lst[left]

prime_lst = primes(10000)
twin_lst = []
add_twin(prime_lst, twin_lst)

while True:
  n = int(input())
  if n == 0:
    break
  a = search_twin(n, twin_lst)
  print(a - 2, a)


Measured memory_bytes: 5708
s = input()
K = int(input())
str_list = []
for i in range(len(s)):
    for j in range(K):
        str_list.append(s[i:i + j + 1])
str_list = sorted(list(set(str_list)))
# print(str_list)
ans = str_list[K - 1]
print(ans)


Measured memory_bytes: 11276
#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        line.pop();
        line
    }};
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        let iter = line.split_whitespace();
        iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
    }};
}

fn solve(a: usize, b: usize, hs: Vec<usize>) -> usize {
    let ed = a - b;
    let mut tmax = 1000000000usize;
    let mut tmin = 1;

    while true {
        let t = (tmax + tmin) / 2;
        let mut et = 0;
        for &h in hs.iter() {
            if h <= t * b {
                continue;
            }

            let r = h - t * b;
            et += r / ed + if r % ed > 0 { 1 } else { 0 };
        }

        if et <= t {
            tmax = t;
        } else {
            tmin = t;
        }

        if t == (tmax + tmin) / 2 {
            return tmax;
        }
    }

    unreachable!();
}

fn main() {
    let (n, a, b) = parse_line!(usize, usize, usize);
    let hs = (0..n).map(|_| parse_line!(usize)).collect();

    println!("{}", solve(a, b, hs));
}

#[test]
fn solve_test() {
    assert_eq!(solve(5, 3, vec![8, 7, 4, 2]), 2);
    assert_eq!(solve(10, 4, vec![20, 20]), 4);
    assert_eq!(
        solve(
            2,
            1,
            vec![900000000, 900000000, 1000000000, 1000000000, 1000000000]
        ),
        800000000
    );
}


Measured memory_bytes: 4352
A, B = map(int, input().split())

def f(n):
    if n % 2:
        return 1 if ((n + 1) // 2) % 2 else 0
    else:
        return n ^ (1 if (n // 2) % 2 else 0)

print(f(A-1) ^ f(B))

Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;

int main(){
    int a,b,c;
    string ans;
    cin >> a >> b >> c;
    if ((a*100+b*10+c)%4 == 0) {
        ans = "YES";
    }else{
        ans = "NO";
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1001001001
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repX(i, n ,x) for (int i = x; i < (int)(n); ++i)
#define repBack(i, n) for (int i = n; i >= 0; --i)
#define dup(x,y) (((x)+(y)-1)/(y))

int main() {
    int N,M;
    cin >> N >> M;
    priority_queue<int,vector<int>,greater<int>> A;
    rep(i,N){
        int a;
        cin >> a;
        A.push(a);
    }
    vector<p> BC(M);
    rep(i,M){
        int b,c;
        cin >> b >> c;
        BC[i] = p(c,b);
    }
    sort(BC.begin(),BC.end(),greater<p>());
    int ni = 0;
    while(true){
        if(ni>=M)break;
        if(A.top()>=BC[ni].first){
            break;
        }else{
            A.pop();
            A.push(BC[ni].first);
            BC[ni].second--;
            if(BC[ni].second==0)ni++;
        }
    }
    ll ans = 0;
    rep(i,N){
        ans += A.top();A.pop();
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1528
#include<bits/stdc++.h>
using namespace std ;
int main(){
    long long n, w ;
    cin >> n >> w ;
    vector<long long> weight(n) ;
    vector<long long> value(n) ;
    for(long long i = 0 ; i < n ; i++){
        cin >> weight[i] >> value[i] ;
    }
    vector<long long> dp(100005,1e15) ;
    dp[0] = 0 ;
    for(long long i = 0 ; i < n ; i++){
        for(long long v = 100004 ; v >= 0 ; v--){
            if(value[i] <= v)
                dp[v] = min(dp[v],dp[v-value[i]]+weight[i]) ;
        }
    }
    long long ans = 0 ;
    for(long long i = 100001 ; i >= 0 ; i--){
        if(dp[i] <= w){
            ans = i ; break ;
        }
    }
    cout << ans << endl ;
}

Measured memory_bytes: 1024
#E
a,b = map(int,input().split())

def extgcd(x,y):
    c1,c2 = x,y
    a1,a2 = 1,0
    b1,b2 = 0,1
    
    while c2:
        m = c1%c2
        q = c1//c2
        c1,c2 = c2,m
        a1,a2 = a2,(a1-q*a2)
        b1,b2 = b2,(b1-q*b2)
        
    return c1,a1,b1

ans = extgcd(a,b)
print(ans[1],ans[2])



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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;

int main() {
  int N, K, X[3000], Y[3000];
  cin >> N >> K;
  for(int i = 0; i < N; i++) {
    cin >> X[i] >> Y[i];
  }
  for(int i = 0; i < N; i++) {
    map< pair< int, int >, int > mp;
    for(int j = 0; j < N; j++) {
      if(i == j)continue;
      auto x = X[i] - X[j];
      auto y = Y[i] - Y[j];
      if(x == 0) y = 1;
      if(y == 0) x = 1;
      if(x * y != 0) {
        if(x < 0) {
          x *= -1;
          y *= -1;
        }
        auto z = __gcd(x, y);
        x /= z;
        y /= z;
      }
      if(++mp[{x, y}] >= K - 1) {
        cout << 1 << endl;
        return 0;
      }
    }
  }
  cout << 0 << endl;
}



Measured memory_bytes: 3304
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0; i<(N); i++)
typedef long long ll;
const ll mod=1e9+7;

ll N;
ll C[505];
ll S[505];
ll F[505];

ll time(ll n){
	ll t=0;
	while(n<N-1){
		if((S[n]<=t)&&(t%F[n]==0)){
			t+=C[n];
			n++;
		}else{
			t++;
		}
	}
	return t;
}

int main(){ 

cin.tie(0);
ios::sync_with_stdio(false);

cin>>N;

rep(i,N-1){
	cin>>C[i]>>S[i]>>F[i];
}

rep(i,N){
	cout<<time(i)<<endl;
}


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int 		  long long
#define	pb 			  push_back
#define all(a)		  (a).begin(),(a).end()
#define sz(x)		  (int)x.size()
#define endl	 	  "\n"
#define inf 		  1000000007
#define FOR(i, a, b)  for(int i=a; i<b; i++)
int dp[1000001] = {inf};

void solve(){
	int n;
	string s;
	cin>>n>>s;
	//cout<<s[0]-'A';
	FOR(i, 0, sz(s)){
		//cout<<('A' + (s[i]-'A'))<<endl;
		s[i] = (char)('A'+((s[i]-'A')+n)%26);
	}
	cout<<s;
}
signed main(){
	#ifdef _DEBUG
		freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
	#endif
	
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
map<char, string> mp;
char player = 'a';
int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
map<char, int> index;
    cin >> mp['a'];
    cin >> mp['b'];
    cin >> mp['c'];
    while(true) {
        if(index[player] == mp[player].size()) {
            cout << (char)(player + ('A' - 'a')) << endl;
            return 0;
        }
        index[player]++;
        player = mp[player][index[player]-1];
    }
    return 0;
}


Measured memory_bytes: 256
n = int(input())

a_list = []

for _ in range(n):
    a_list.append(int(input()))

i = 1
i_set = {i}

while True:
    i = a_list[i - 1]
    if i == 2:
        print(len(i_set))
        break
    elif i in i_set:
        print(-1)
        break
    else:
        i_set.add(i)


Measured memory_bytes: 13220
#include<stdio.h>

int F[45];

void fib(int n){

  int i;

  F[0] = 1;
  F[1] = 1;

  for(i=2;i<=n;i++){
    
    F[i] = F[i - 2] + F[i - 1];

  }


}


int main(){

  int n;

  scanf("%d",&n);

  fib(n);

  printf("%d\n",F[n]);

  return 0;
}


Measured memory_bytes: 2104
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

int main(){
  long long h,w,d;
  cin >> h >> w >> d;
  long long a[h][w];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> a[i][j];
    }
  }
  pair<int,int> value[h*w+1];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      value[a[i][j]] = make_pair(i,j);
    }
  }
  vector<long long> cost[d];
  long long dist = 0;
  long long place;
  for(int i=0;i<d;i++){
    dist = 0;
    cost[i].push_back(0);
    for(int j=1;j<=h*w/d;j++){
      place = d*j+i;
      if(place < 2) continue;
      if(place > h*w) continue;
      dist += abs(value[place].first - value[place-d].first);
      dist += abs(value[place].second - value[place-d].second);
      cost[i].push_back(dist);
      //cout << place << endl;
    }
  }
  long long q;
  cin >> q;
  long long l[q],r[q];
  long long ans;
  long long dd,ld,rd;
  for(int i=0;i<q;i++){
    cin >> l[i] >> r[i];
  }
  for(int i=0;i<q;i++){
    if(d == 1){
      ans = cost[0][r[i]-1]-cost[0][l[i]-1];
      cout << ans << endl;
      continue;
    }
    dd = l[i]%d;
    ld = l[i]/d;
    rd = r[i]/d;
    ans = cost[dd][rd]-cost[dd][ld];
    cout << ans << endl;
  }


  return 0;
}


Measured memory_bytes: 8320
#include <iostream>
#include <cstdio>
#include <cctype>
#include <cstring>
using namespace std;

int main() {
	int count[26];
	char ch;
	for(int i=0; i<26; i++){
		count[i]=0;
	}
	while(scanf("%c", &ch) != EOF){
		if(isalpha(ch)){
			if(isupper(ch)){
				ch = tolower(ch);
			}
			int num = ch - 'a';
			count[num]++;
		}
		// printf("%d\n",sum);
	}
	for(int i=0; i<26; i++){
		char alpha = 'a' + i;
		printf("%c : %d\n", alpha, count[i]);
	}
	return 0;
}


Measured memory_bytes: 3216
#include<bits/stdc++.h>
using namespace std;
int n, ans, t, a[25], c[25];
int main(void)
{
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (int i = 0; i < n; i++)
	{
		cin >> t;
		ans += t;
	}
	for (int i = 0; i < n - 1; i++)
	{
		cin >> c[i];
	}
	for (int i = 0; i < n - 1; i++)
	{
		if (a[i] + 1 == a[i + 1])
		{
			ans += c[a[i] - 1];
		}
	}
	cout << ans << endl;
	return 0;
}

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

class union_find {
    private:
        vector<int> par;
        vector<int> ran;
        vector<ll> size;
    public:
        union_find(int n);
        int find(int x);
        void unite(int x, int y);
        bool same(int x, int y);
        ll show_size(int x);
};

union_find::union_find(int n){
    par.resize(n);
    ran.resize(n);
    size.resize(n);
    rep(i,n) par[i] = i;
    rep(i,n) ran[i] = 0;
    rep(i,n) size[i] = 1;
};

int union_find::find(int x) {
    if(par[x] == x) return x;
    else return par[x] = find(par[x]);
};

void union_find::unite(int x, int y) {
    x = find(x);
    y = find(y);
    if(x == y) return;
    ll t = show_size(x)+show_size(y);
    size[x] = size[y] = t;
    if(ran[x] < ran[y]){
        par[x] = y;
        //size[y] += size[x];
    }
    else{
        par[y] = x;
        //size[x] += size[y];
        if(ran[x] == ran[y]) ran[x]++;
    }
};

ll union_find::show_size(int x) {
    if(par[x] == x) return size[x];
    return show_size(par[x] = find(par[x]));
}

bool union_find::same(int x, int y) {
    return (find(x) == find(y));
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    union_find uf(n);
    rep(i,m){
        int x, y;
        cin >> x >> y;
        uf.unite(x, y);
    }
    vector<bool> used(n, false);
    vector<int> idx(n);
    rep(i,n) idx[i] = i;
    int treeCount = 0;
    rep(i,n) treeCount += (i == uf.find(i));
    if(treeCount == 1){
        cout << 0 << endl;
        return 0;
    }
    sort(idx.begin(), idx.end(), [&](const int& i1, const int& i2){return a[i1] < a[i2];});
    ll ans = 0;
    int cnt = treeCount - 2, total = 2 * (treeCount - 1);
    for(int i : idx){
        if(used[uf.find(i)]){
            if(cnt > 0){
                --cnt;
                ans += a[i];
                --total;
            }
        }
        else{
            used[uf.find(i)] = true;
            ans += a[i];
            --total;
        }
    }
    if(total == 0) cout << ans << endl;
    else cout << "Impossible" << endl;
    return 0;
}


Measured memory_bytes: 6028
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    int A,B;cin >> A >> B;
    int ans = -1;
    int a = -1;
    int b = -1;
    for(int i = 1;i <= 1000;++i){
        a = i * 0.08;
        b = i * 0.1;
        if(a == A)if(b == B){
            ans = i;
            break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,sum=0;
    cin>>n;
    vector<int>v(n);

    for(int i=0;i<n;i++)
    {
        cin>>v[i];
        sum+=v[i];
    }

    double d=(sum*1.0)/n;
    int s1=0,s2=0;

    for(int i=0;i<n;i++)
    {
        s1+=pow(v[i]-ceil(d),2);
        s2+=pow(v[i]-floor(d),2);
    }

    cout<<min(s1,s2)<<endl;
    exit(0);
}


Measured memory_bytes: 3636
#include <stdio.h>

int main(){

  int S[10000], T[500], i, j, n, q, count = 0;

  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%d", &S[i]);
  }

  scanf("%d", &q);
  for(i = 0; i < q; i++){
    scanf("%d", &T[i]);
  }

  for(i = 0; i < q; i++){
    for(j = 0; j < n; j++){
      //printf("%d %d\n", S[j], T[i]); 
      if(S[j] == T[i]){
	count++;
	break;
      }
    }
  }

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

  return 0;
  
  

}



Measured memory_bytes: 2104
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll N;

int main() {
	scanf("%lld", &N);
	if(N == 5 || N == 7 || N == 3) {
		printf("YES\n");
	}
	else {
		printf("NO\n");
	}
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256
#include <bits/stdc++.h> 
 
#define INF (1<<31)//INT_MAX/2
#define MOD 1000000007
 
using ll  = long long;
using ull = unsigned long long;
 
int main(int argc, char *argv[])
{
    std::string S;
    std::cin >> S;

    bool flag = false;
    if (S[0] == 'a' && S[1] == 'b' && S[2] == 'c') {
        flag = true;
    }
    if (S[0] == 'a' && S[1] == 'c' && S[2] == 'b') {
        flag = true;
    }
    if (S[0] == 'b' && S[1] == 'a' && S[2] == 'c') {
        flag = true;
    }
    if (S[0] == 'b' && S[1] == 'c' && S[2] == 'a') {
        flag = true;
    }
    if (S[0] == 'c' && S[1] == 'b' && S[2] == 'a') {
        flag = true;
    }
    if (S[0] == 'c' && S[1] == 'a' && S[2] == 'b') {
        flag = true;
    }

    if (flag) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No"  << std::endl;
    }
    return 0;
}

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

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

    int n; cin>>n;
    vector<int> a(n);
    int all=0;
    for(int &x:a)
    {
        cin>>x;
        all^=x;
    }
    for(int x: a)
    {
        cout<<(all^x)<<" ";
    }
    cout << "\n";
}

Measured memory_bytes: 3988
import sys
stdin = sys.stdin
import numpy as np
 
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
s = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

n, m, c = na()
b = np.array(na())
count = 0
for i in range(n):
    a = np.array(na())
    if np.sum(a * b) + c > 0:
        count += 1

print(count)




Measured memory_bytes: 12436
n = int(input())
w = list(map(int,input().split()))
ssum = [w[0]]+[0]*(n-1)
for i in range(1,n):
  ssum[i] = ssum[i-1]+w[i]
def a(x):
  return abs(ssum[n-1]-2*ssum[i])
ans = ssum[n-1]
for i in range(n-1):
  if a(i) < ans:
    ans = a(i)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i <= (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;

int main() {
  int N; cin >> N;
  vi H(N); rep(i,N) cin >> H.at(i);
  
  int ans = 1;
  int Hmax = H.at(0);
  repf(i,1,N) {
    if (Hmax<=H.at(i)) {
      ans++;
      Hmax = H.at(i);
    }
  }
  
  cout << ans << endl;
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N=in();
	auto V=vecin(N);
	
	int Q=in();
	REP(i,Q){
		int t=in(),u=in(),v=in();
		if(t){
			out(*max_element(V.begin()+u,V.begin()+v));
		}
		else{
			out(*min_element(V.begin()+u,V.begin()+v));
		}
	}

	return 0;
}


Measured memory_bytes: 3160
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
using namespace __gnu_pbds;
#define int long long int
#define pb push_back
#define vec vector<int>
#define fo(i, n) for (int i = 0; i < n; i++)
#define foo(i, a, b) for (int i = a; i < b; i++)
#define mp make_pair
#define deb(x) cout << #x << " --> " << x << endl;
#define deb1a(v) cout << #v << "--->" << endl; for (auto it : v)  cout << it << " "; cout << endl;
#define deb2a(v) cout << #v << "--->" << endl;for (auto it:v){for(auto it1 : it){cout << it1 << " ";}cout<< endl;}
#define deb3a(v) cout << #v << "-->" << endl; for(auto it:v){cout << it.fi << " " << it.se << endl;}
#define mod 29996224275833
#define so(v) sort(v.begin(),v.end())
#define fi first
#define se second
#define db1(x) cout<<#x<<"="<<x<<endl
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<endl
int power(int x, unsigned int y, int p){ int res = 1;x = x % p;while (y > 0)  { if (y & 1)res = (res*x) % p;y = y>>1;  x = (x*x)% p;} return res;}
// int mI(int a, int m)  {return power(a, m - 2, m);}
// vector<vector<int>> dir = {{1, 0}, {-1, 0}, {0, 1}, {0, -1},{1,1},{1,-1},{-1,1},{-1,-1}};



int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a, b, c,k;
    cin >> a >> b >> c >> k;
    int ans = 0;
    if(a>=k){
        cout << k;
    }
    else{
        int ans = a;
        k -= a;
        if(b>=k){
            cout << ans;
        }
        else{
            k -= b;
            cout << ans - k;
        }
    }
        
}
    


Measured memory_bytes: 3656
import sys
sys.setrecursionlimit(10**9)

H, W = map(int, input().split())
S = [input() for i in range(H)]

visited = set()
def dfs(x, y, c, white, black):
  global visited
  for dx, dy in [[1, 0], [0, 1], [-1, 0], [0, -1]]:
    xx = x + dx; yy = y + dy
    if 0<=xx<H and 0<=yy<W and (xx, yy) not in visited and S[xx][yy]!=c:
      cc = S[xx][yy]
      if cc == '.':
        white.add((xx, yy))
      else:
        black.add((xx, yy))
      visited.add((xx, yy))
      white, black = dfs(xx, yy, cc, white, black)
  return white, black

ans = 0
for x in range(H):
  for y in range(W):
    if (x, y) not in visited:
      visited.add((x, y))
      c = S[x][y]
      if c == '.':
        white = set(((x, y), )); black = set()
      else:
        white = set(); black = set(((x, y), ))
      white, black = dfs(x, y, c, white, black)
      ans += len(white) * len(black)

print(ans)

Measured memory_bytes: 262468