akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
const double eps=1e-9;
const int inf=1e9;
typedef pair<int,int> P;
struct Point
{
  double x,y;
  Point(){x=0;y=0;}
  Point(double d_x,double d_y){x=d_x,y=d_y;}
  double operator*(Point obj){return obj.x*x+obj.y*y;}
  double operator%(Point obj){return obj.y*x-obj.x*y;}
  Point operator*(double b){Point tmp;tmp.x=x*b;tmp.y=y*b;return tmp;}
  Point operator/(double b){Point tmp;tmp.x=x/b;tmp.y=y/b;return tmp;}
  Point operator+(Point obj){Point tmp;tmp.x=x+obj.x;tmp.y=y+obj.y;return tmp;}
  Point operator-(){Point tmp;tmp.x=-x;tmp.y=-y;return tmp;}
  Point operator-(Point obj){Point tmp;tmp.x=x-obj.x;tmp.y=y-obj.y;return tmp;}
  Point operator-=(Point obj){x-=obj.x;y-=obj.y;return *this;}
  Point operator+=(Point obj){x+=obj.x;y+=obj.y;return *this;}
  Point operator/=(double b){x=x/b;y=y/b;return *this;}
  Point operator*=(double b){x=x*b;y=y*b;return *this;}
  double size(){return hypot(x,y);}
  Point unit(){return Point(x/size(),y/size());}
  Point normal(){return Point(y,-x);}
  double atan(){return atan2(y,x);}
};

bool operator<(Point a,Point b){return a.x!=b.x?a.x<b.x:a.y<b.y;}
bool operator>(Point a,Point b){return b<a;}
bool operator<=(Point a,Point b){return !(b<a);}
bool operator>=(Point a,Point b){return !(a<b);}
bool operator==(Point a,Point b){return (a-b).size()<eps;}
bool operator!=(Point a,Point b){return !(a==b);}

bool equal(double a,double b){return abs(a-b)<eps;}
double cross(Point a,Point b){return a%b;}
double dot(Point a,Point b){return a*b;}

int ccw(Point a,Point b,Point c)
{
  b=b-a;
  c=c-a;
  if(b%c>0) return +1;
  else if(b%c<0)return -1;
  else if(b*c<0) return +2;
  else if(b.size()<c.size()) return -2;
  else return 0;
}

int w,h;
vector<string> board;
vector<vector<string> > memo;
int dx[]={1,0};
int dy[]={0,1};

inline bool outrange(int x,int y)
{
  return (x<0 || x>=w || y<0 || y>=h);
}

string cmp(string a,string b)
{
  if(a.size()>b.size()) return a;
  if(b.size()>a.size()) return b;
  return max(a,b);
}

string dfs(int x,int y)
{
  if(outrange(x,y)) return "";
  if(!isdigit(board[y][x])) return "";
  if(memo[y][x]!="") return memo[y][x];
  
  string res="";
  for(int d=0;d<2;d++)
    {
      res=cmp(res,board[y][x]+dfs(x+dx[d],y+dy[d]));
    }
  memo[y][x]=res;
  return res;
}

int main(int argc,char const* argv[])
{
  ll dp[15][1505];
  memset(dp,0,sizeof(dp));
  dp[0][0]=1;
  int n,s;
  for(int k=0;k<=100;k++)
    {
      for(int i=10;i>=1;i--)
	{
	  for(int j=k;j<=1000;j++)
	    {
	      dp[i][j]+=dp[i-1][j-k]; 
	    }
	}
    }
  while(cin >> n >> s && n)
    {
      cout << dp[n][s] << endl;
    }
  return 0;
}



Measured memory_bytes: 3276
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 2147483647;
const ll LLINF = 9223372036854775807;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	int n; cin >> n;
	string s = "", t = "", v = "";
	char p;
	REP(i, n) {
		cin >> p;
		s += p;
	}
	REP(i, n) {
		cin >> p;
		t += p;
	}
	REP(i, n)v += '1' + i;
	int ns = 0, nt = 0, i = 1;
	do {
		if (s == v)
			ns = i;
		if (t == v)
			nt = i;
		i++;
	} while (next_permutation(ALL(v)));
	cout << abs(ns - nt) << endl;
}

Measured memory_bytes: 256
# ABC133C - Remainder Minimization 2019
def main():
    L, R = list(map(int, input().rstrip().split()))
    MOD = 2019
    if (R // MOD) - (L // MOD) > 0:  # L <= 2019n <= R
        print(0)
    else:  # R - L <= 2018 -> max: 2018 * 2017 patterns
        ans = float("inf")
        L, R = L % MOD, R % MOD
        for i in range(L, R):
            for j in range(i + 1, R + 1):
                ans = min(ans, (i * j) % MOD)
        print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <stdio.h>

int main() {
	char c;
	scanf ("%c",&c);
	if (c=='a') {
	printf("vowel\n");
	} else if (c=='e') {
	  printf ("vowel\n");
	} else if (c=='i') {
	  printf ("vowel\n") ;
	} else if (c=='o') {
		printf("vowel\n"); }
		else if (c=='u') {
		printf("vowel\n");
		} else  {
		printf ("consonant\n");
		 }
		return 0;
 }    


Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
    int n;
    int x, y, h, w;
    int sum;
    int ookisa;
    int i;
    
    while (1){
        scanf("%d", &n);
        if (n == 0) break;
        
        sum = 0;
        for (i = 0; i < n; i++){
            scanf("%d %d %d %d", &x, &y, &h, &w);
            if (x + y + h <= 60 && w <= 2){
                sum += 600;
            }
            else if (x + y + h <= 80 && w <= 5){
                sum += 800;
            }
            else if (x + y + h <= 100 && w <= 10){
                sum += 1000;
            }
            else if (x + y + h <= 120 && w <= 15){
                sum += 1200;
            }
            else if (x + y + h <= 140 && w <= 20){
                sum += 1400;
            }
            else if (x + y + h <= 160 && w <= 25){
                sum += 1600;
            }
        
        }
        printf("%d\n", sum);
    }
    
    return (0);
}

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

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

const ll MOD = 1000000007;
const long double EPS = 10e-10;

int not_prime[300000];
ll fact[300000], rfact[300000];

vector<ll> factorize(ll n){
    vector<ll> ret;
    ll i = 2, rt = sqrt(n);
    while(n != 1 && i <= rt){
        if(not_prime[i]){
            i++;
            continue;
        }
        ll j = i;
        while(j <= rt){
            not_prime[j] = 1;
            j += i;
        }

        while(n % i == 0){
            n /= i;
            ret.push_back(i);
        }

        i++;
    }
    if(n != 1){
        ret.push_back(n);
    }
    return ret;
}

ll perm(ll n, ll r){
    return (fact[n] * rfact[r]) % MOD;
}

ll comb(ll n, ll r){
    return (perm(n, r) * rfact[n-r]) % MOD;
}

void init(ll n){
    fact[0] = fact[1] = 1;
    rfact[0] = rfact[1] = 1;
    reppp(i, 2, n+1){
        fact[i] = (fact[i-1] * (ll)i) % MOD;
        rfact[i] = 1;
        ll k = MOD-2;
        ll a = fact[i];
        while(k > 0){
            if(k & 1){
                rfact[i] *= a;
                rfact[i] %= MOD;
            }
            a *= a;
            a %= MOD;
            k  >>= 1;
        }
    }
}

int main(){
    init(300000);

    ll n,m;
    cin >> n >> m;

    vector<ll> mfact = factorize(m);
    map<ll, ll> mpfact;
    for(ll x: mfact) mpfact[x]++;

    ll ans = 1LL;
    for(auto itr=mpfact.begin(); itr!=mpfact.end(); ++itr){
        ll a = itr->first, b = itr->second;
        ans *= comb(n+b-1, b);
        ans %= MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <cstring>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <stack>
using namespace std;
#define ll long long
#define pb push_back
#define pp pair<long long,long long>
#define ppp pair<pair<long long,long long>,long long>
#define f first
#define s second
#define pd pair<double,long long>
ll M=1e9+7;
ll dp[5050];
ll solve(ll sum) {
	if (sum==0)
		return 1;
	if (dp[sum]!=-1)
		return dp[sum];
	ll i,ans=0;
	for (i=3;i<=sum;i++) {
		ans=ans+solve(sum-i);
		ans%=M;
	}
	dp[sum]=ans;
	return ans;
}
int main() {
	ll t,n,i,j,k,l,m;
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	ll p;
	t=1;
	//cin>>t;
	while (t--) {
		cin>>n;
		memset(dp,-1,sizeof(dp));
		cout<<solve(n)<<'\n';
	}
	return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <iomanip>
using namespace std;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }

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

  int n;
  cin >> n;
  vector <ii> v(n);
  for(int i = 0; i < n; i++){
    cin >> v[i].first;
    v[i].second = i;
  }
  sort(all(v));
  for(int i = 0; i < n; i++){
    cout << v[i].second + 1 << " ";
  }
}

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

int main() {
    int N;
    cin >> N;
    vector<int>A(N);
    rep(i,N)cin >> A[i];
    int aS = A.size();
    sort(A.begin(),A.end());
    A.erase(std::unique(A.begin(), A.end()), A.end());
    if(aS==A.size())cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#define MAX 100000

int A[MAX],n;

int partition(int p,int r){
  int x,i,j,t;
  x = A[r];
  i=p-1;

  for(j=p;j<r;j++){
    if(A[j] <= x){
      i++;
      t = A[i]; A[i] = A[j]; A[j] = t;
    }
  }
  t = A[i+1]; A[i+1] = A[r]; A[r] = t;
  return i+1;
}

int main(){
  int i,q;

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

  q = partition(0,n-1);

  for(i=0;i<n;i++){
    if(i) printf(" ");
    if(i == q) printf("[");
    printf("%d",A[i]);
    if(i == q) printf("]");
  }
  printf("\n");
  return 0;
}



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

unsigned long long kaijou(unsigned long long a, unsigned long long b){
    if(a==b) return a;
    return b*kaijou(a,b-1);
}

int main() {

    int N;
    cin >>N;
    cout <<(N%2+1)*N;

    return 0;    
}


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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;

void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    int a, b;
    cin >> a >> b;
    cout << max(a * b, max(a - b, a + b));
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>

using namespace std;

int Atoi(const char);

int main(){
  int i, j, n, m, count;
  string str, _str, buttom[9];

  buttom[0] = "',.!?";
  buttom[1] = "abcABC";
  buttom[2] = "defDEF";
  buttom[3] = "ghiGHI";
  buttom[4] = "jklJKL";
  buttom[5] = "mnoMNO";
  buttom[6] = "pqrsPQRS";
  buttom[7] = "tuvTUV";
  buttom[8] = "wxyzWXYZ";

  while(cin >> str){
    i = 0;
    j = 1;
    count = 0;
    while(1){
      if(j == str.size()){
	n = Atoi(str[i]) - 1;
        m = count % buttom[n].size();
        _str.push_back(buttom[n][m]);
        break;
      }else if(str[i] != str[j]){
	n = Atoi(str[i]) - 1;
        m = count % buttom[n].size();
        _str.push_back(buttom[n][m]);

        if(str[j] == '0'){
          for(i=j+1; str[i]=='0'; ++i) _str.push_back(' ');
          j = i+1;
        }else{
          i = j;
          j = i+1;
        }
	count = 0;
      }else{
        ++j;
	++count;
      }
    }

    cout << _str << endl;
    _str.clear();
  }

  return 0;
}

int Atoi(const char c){
  int x;
  x = c - 48;
  return x;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;


int main(){
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    ll positive_sum = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(a[i] > 0){positive_sum += a[i];}
    }
    ll sub_positive_sum = 0;
    ll sub_negative_sum = 0;
    for(int i = 0; i < k; i++){
        if(a[i]>0){sub_positive_sum += a[i];}
        if(a[i]<0){sub_negative_sum += a[i];}
    }
    ll min_sub_positive_sum = sub_positive_sum;
    ll max_sub_negative_sum = sub_negative_sum;
    for(int i = k; i < n; i++){
        if(a[i]>0){sub_positive_sum += a[i];}
        if(a[i]<0){sub_negative_sum += a[i];}
        if(a[i-k]>0){sub_positive_sum -= a[i-k];}
        if(a[i-k]<0){sub_negative_sum -= a[i-k];}
        if(sub_positive_sum < min_sub_positive_sum){
            min_sub_positive_sum = sub_positive_sum;
        }
        if(sub_negative_sum > max_sub_negative_sum){
            max_sub_negative_sum = sub_negative_sum;
        }
    }

    ll ans = positive_sum - min(min_sub_positive_sum, -1*max_sub_negative_sum);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<string>
#include <vector>

using namespace std;

int main(){

	int n,a,b,c,d[1000],ans;
	int sum=0;

	cin>>n;
	cin>>a>>b;
	cin>>c;

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

	sort (d, d+n, greater<int>());
	ans=c/a;

	for(int i=0;i<n;i++){
		sum=sum+d[i];
		ans=max(ans,(sum+c)/(a+b*(i+1)));
	}

	cout<<ans<<endl;
}

Measured memory_bytes: 3144
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int d;
    cin >> d;
    vector<int> c(26);
    rep(i, 26)cin >> c[i];
    vector<vector<int>> s(d, vector<int>(26));
    rep(i, d)rep(j, 26)cin >> s[i][j];
    vector<int> t(d);
    rep(i, d){
        cin >> t[i];
        t[i]--;
    }
    int m;
    cin >> m;
    vector<P> q(m);
    rep(i, m){
        cin >> q[i].first >> q[i].second;
        q[i].first--;
        q[i].second--;
    }

    vector<set<int>> last(26);
    rep(i, 26){
        last[i].insert(-1);
        last[i].insert(d);
    }
    rep(i, d)last[t[i]].insert(i);
    int sum = 0;
    rep(i, d){
        sum += s[i][t[i]];
        rep(j, 26){
            if(last[j].find(i) == last[j].end()){
                auto itr = lower_bound(last[j].begin(), last[j].end(), i);
                itr--;
                int day = i - *itr;
                sum -= c[j] * day;
            }
        }
    }

    rep(i, m){
        int cont;
        rep(j, 26){
            if(last[j].find(q[i].first) != last[j].end()){
                cont = j;
                break;
            }
        }
        sum += s[q[i].first][q[i].second] - s[q[i].first][cont];
        auto itr1 = last[cont].find(q[i].first);
        auto itr2 = lower_bound(last[q[i].second].begin(), last[q[i].second].end(), q[i].first);
        int x = *itr1;
        int y = *itr2;
        int dx = q[i].first - *(--itr1);
        int dy = q[i].first - *(--itr2);
        itr1++; itr1++;
        itr2++;
        sum -= c[cont] * dx * (*itr1 - q[i].first);
        sum += c[q[i].second] * dy * (*itr2 - q[i].first);
        cout << sum << endl;
        last[cont].erase(q[i].first);
        last[q[i].second].insert(q[i].first);
    }
    
}

Measured memory_bytes: 3900
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

#ifndef _DEBUG
#define main_ main
#endif
#define FOR(i,s,e) for (int i = int(s); i != int(e); i++)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<bool> vb;
typedef vector<string> vs;

template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
	return left.second > right.second;
}

bool P[8][8];
int N, M;

void init_global() {
	FOR(i, 0, 8) {
		FOR(j, 0, 8) {
			P[i][j] = false;
		}
	}
}

void dfs(int i, vb& v, ll& cnt) {
	bool all_visited = true;
	FOR(j, 0, N) {
		if (!v[j]) all_visited = false;
	}

	if (all_visited) {
		cnt++;
		return;
	}

	FOR(j, 0, N) {
		if (!P[i][j] || v[j]) continue;
		v[j] = true;
		dfs(j, v, cnt);
		v[j] = false;
	}
}

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

	cin >> N >> M;
	int a, b;
	FOR(i, 0, M) {
		cin >> a >> b;
		a--; b--;
		P[a][b] = P[b][a] = true;
	}

	ll ans=0;
	vb v(N, false);
	v[0] = true;
	dfs(0, v, ans);

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>

#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)

typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;

using namespace std;
int a1[110], b1[110];
void solve(){
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        a1[i + 1] = a1[i] + x;
    }
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        b1[i + 1] = b1[i] + x;
    }
    
    int ans = 0;
    
    for(int i = 1; i <= n; i++){
        int sum1 = a1[i];
        int sum2 = b1[n] - b1[i - 1];
        ans = max(sum1 + sum2, ans);
    }
    cout << ans;
}

int main(){
    barsik;
    int q = 1;
    //cin >> q;
    while(q--) solve();
}



Measured memory_bytes: 256
program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils,Classes;
var
  a,h,w,i,j,count,x,y,sw,m,n,b,c,soeji,sum,max,k,min:Integer;
  l:array of Integer;
  s,s123,s1,s2,s3:string;
  tf:Boolean;
  nyu:TStringList;
begin
  try
    { TODO -oUser -cConsole Main : ここにコードを記述してください }
    Read(n);
    Readln(k);
    SetLength(l,n);
    for i := 0 to n - 1 do
      Read(l[i]);
 
    for i := 0 to n-1 do begin
      min := i;
      for j := i+1 to n-1 do begin
        if l[j] < l[min] then
        min := j;
      end;
      sw:=l[i];
      l[i]:=l[min];
      l[min]:=sw;
    end;

    sum:=0;
    for i := n-1 downto n-k do
      sum:=sum+l[i];
    Writeln(sum);
    Readln;
    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.

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

//template
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
template<typename T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
//end

template<unsigned mod=998244353>struct fp {
   int v; static unsigned get_mod(){return mod;}
   int inv() const{
      int tmp,a=v,b=mod,x=1,y=0;
      while(b)tmp=a/b,a-=tmp*b,swap(a,b),x-=tmp*y,swap(x,y);
      if(x<0){x+=mod;} return x;
   }
   fp():v(0){}
   fp(ll x):v(x>=0?x%mod:mod+(x%mod)){}
   fp operator-()const{return fp(-v);}
   fp pow(ll t){fp res=1,b=*this; while(t){if(t&1)res*=b;b*=b;t>>=1;} return res;}
   fp& operator+=(const fp& x){if((v+=x.v)>=(int)mod)v-=mod; return *this;}
   fp& operator-=(const fp& x){if((v+=mod-x.v)>=(int)mod)v-=mod; return *this;}
   fp& operator*=(const fp& x){v=ll(v)*x.v%mod; return *this;}
   fp& operator/=(const fp& x){v=ll(v)*x.inv()%mod; return *this;}
   fp operator+(const fp& x)const{return fp(*this)+=x;}
   fp operator-(const fp& x)const{return fp(*this)-=x;}
   fp operator*(const fp& x)const{return fp(*this)*=x;}
   fp operator/(const fp& x)const{return fp(*this)/=x;}
   bool operator==(const fp& x)const{return v==x.v;}
   bool operator!=(const fp& x)const{return v!=x.v;}
}; using Fp=fp<>;

Fp dp[310][310][620];
//dp[i][j][k]:=i-th '0',j-th '1',k-th operations

int main(){
   string s; int K; cin>>s>>K;
   int n=s.size(); chmin(K,n);
   dp[0][0][0]=1;
   int c1=0,c2=0;
   vector<int> ones(n),rui(n+1); int cont=0;
   rep(i,0,n){
      if(s[i]=='0'){
         ones[c1]=cont; c1++;
         cont=0;
      }
      else{
         c2++;
         cont++;
      }
   }
   ones[c1]=cont; c1++;
   rep(i,0,c1)rui[i+1]=rui[i]+ones[i];
   rep(i,0,c1)rep(j,0,c2+1)rep(k,0,K*2+1){
      for(int add=c2-j;add>=0 and rui[i+1]<=add+j;add--){
         dp[i+1][min(c2+1,j+add)][min(K*2+1,k+abs(ones[i]-add))]+=dp[i][j][k];
      }
   }
   Fp res;
   rep(k,0,K+1){
      res+=dp[c1][c2][k*2];
   }
   cout<<res.v<<endl;
   return 0;
}

Measured memory_bytes: 236324
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define bged(v) (v).begin(),(v).end()
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
typedef long long ll;
const int Imx=2147483647;
const ll Lbig=2e18;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it,len;
	fastio(){it=len=0;}
	inline char get()
	{
		if(it<len)return s[it++];it=0;
		len=fread(s,1,100000,stdin);
		if(len==0)return EOF;else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while(c==' '||c=='\n')c=get();
		if(it>0)it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0;bool ng=0;char c;c=_buff.get();
	while(c!='-'&&(c<'0'||c>'9'))c=_buff.get();
	if(c=='-')ng=1,c=_buff.get();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();
	return ng?-r:r;
}
template<class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline char getreal(){char c=_buff.get();while(c<=32)c=_buff.get();return c;}
ll qpow(ll x,ll k){return k==0?1:1ll*qpow(1ll*x*x%mod,k>>1)*(k&1?x:1)%mod;}
int n,a[200111];
int main()
{
	geti(n);
	for(int i=1;i<=n;i++)geti(a[i]);
	bool ok=a[1]==0;
	ll ans=0;
	for(int i=2;i<=n;i++)
	{
		ok&=a[i-1]+1>=a[i];
	}
	for(int i=2;i<=n;i++)
	{
		if(i==n||a[i]+1!=a[i+1])
		{
			ans+=a[i];
		}
	}
	if(ok)cout<<ans<<endl;
	else cout<<-1<<endl;
	return 0;
}


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

#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ones(x) (ll) __builtin_popcount(x);1
#define fs first
#define sc second
#define pb push_back
#define po pop_back
#define mp make_pair	
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ller ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

using namespace std;
typedef long long ll;
typedef long double ld;	
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;
	 
const ll MAX = 10000000;
const ll inf = 5e18-1;
	
int main() {
	fastio;
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	while(1){
		if(c>0) c-=b;
		else{
			yes;
			return 0;
		}
		if(a>0) a-=d;
		else{
			no;
			return 0;
		}
	}
	return 0;
	}

Measured memory_bytes: 3652
N,M=map(int,input().split())
AB=[list(map(int,input().split())) for i in range(M)]
r=0
for m in range(M):
    c=[[] for i in range(N)]
    for i,(a,b) in enumerate(AB):
        if i!=m:
            c[a-1].append(b-1)
            c[b-1].append(a-1)
    q=[0]
    v=[1]+[0]*(N-1)
    while q:
        p=q.pop()
        for n in c[p]:
            if v[n]==0:
                v[n]=1
                q.append(n)
    if 0 in v:
        r+=1
print(r)

Measured memory_bytes: 9160
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define D(x) cerr << #x << " = " << (x) << ", "
template <typename T> ostream& operator<<(ostream& _o_, const vector<T>& _v_){ \
 if(!_v_.empty()){_o_<<'[';copy(_v_.begin(),_v_.end(),ostream_iterator<T>(_o_,", "));_o_<<"\b\b]";}return _o_;}
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
typedef unsigned int uint;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef unsigned char uchar;
struct secure_hash {
 static uint64_t splitmix64(uint64_t x) {
  x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31); }
 size_t operator()(uint64_t x) const {
  static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM); } };
template<typename T> using V = vector<T>;
template<typename T, typename U> using umap = unordered_map<T,U,secure_hash>;
template<typename T> using uset = unordered_set<T,secure_hash>;
template<typename T> using min_heap = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using max_heap = priority_queue<T>;

int n;
V<int> a;
V<V<ll>> dp;

ll f(int i, int j)
{
    if (i > j or i < 0 or j >= n) return 0;
    ll& ans = dp[i][j];
    if (ans == -1) {
        bool turn = (j-i+1) % 2 == n % 2;
        if (turn) {
            ans = max(f(i+1, j) + a[i], f(i, j-1) + a[j]);
        }
        else {
            ans = min(f(i+1, j) - a[i], f(i, j-1) - a[j]);
        }
    }
    return ans;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    a.resize(n);
    rep(i,0,n) cin >> a[i];
    dp.resize(n, V<ll>(n, -1));
    cout << max(f(1,n-1)+a[0], f(0,n-2)+a[n-1]) << endl;
}


Measured memory_bytes: 70912
#include <iostream>
#include <bits/stdc++.h>
#define MOD 998244353
#define pb push_back
#define ll long long int
using namespace std;


int main()
{   ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll i,j,n,m,k;
    ll t;
    cin>>k>>n;
 ll a[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        a[i]=a[i]%k;
    }
 ll ma=INT_MIN;
    sort(a,a+n);
    for(i=0;i<n-1;i++)
    {
        ma=max(ma,abs(a[i]-a[i+1]));
    }
    ma=max(ma,k-a[n-1]+a[0]);
    if(ma==INT_MIN)
        cout<<0;
    else
        cout<<k-ma;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<functional>
#include<map>
#include<iomanip>
#include<limits>
#include<unordered_set> 
#include<cmath>
using namespace std;
//long long p = 998244353;
long long p = 1000000007;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define qin pair<pin,int>
#define V vector
#define Endl endl
#define veb vector<bool>
#define fcout cout << fixed << setprecision(15)
#define rev(s) reverse(s.begin(),s.end())
#define lower(h,val) lower_bound(h.begin(),h.end(),val)-h.begin()
#define upper(h,val) upper_bound(h.begin(),h.end(),val)-h.begin()
int max_kai = 150000;
vel kai(max_kai, 1);
vel inv_kai;
int rui(int a, int n, int mod) {
    if (n == 0) { return 1 % mod; }
    int x = rui(a, n / 2, mod);
    x *= x; x %= mod;
    if (n % 2 == 1) { x *= a; x %= mod; }
    return x;
}
vel pa;
int root(int x) {
    if (pa[x] == -1) { return x; }
    int ans = root(pa[x]); pa[x] = ans;
    return ans;
}
void marge(int x, int y) {
    x = root(x);
    y = root(y);
    if (x != y) { pa[x] = y; }
}
int gcd(int x, int y) {
    if (x < y) { return gcd(y, x); }
    if (y == 0) { return x; }
    return gcd(y, x % y);
}
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
vel uni(vel x) {
    if (x.size() == 0) { return x; }
    sor(x);
    int n = x.size();
    vel ans(1, x[0]);
    for (int j = 1; j < n; j++) {
        if (x[j - 1] != x[j]) { ans.push_back(x[j]); }
    }
    x = ans;
    return x;
}
void pr(vel& v) {
    int n = v.size();
    if (n != 0) {
        cout << v[0];
        rep(i, n - 1) {
            cout << " " << v[i + 1];
        }
        cout << endl;
    }
}
signed main() {
    int n, k; cin >> n >> k;
    vel a(n + 1, 0);
    V<pin> x(n + 1,mkp(0,0));
    rep(i, n) {
        cin >> a[i + 1];
        a[i + 1]--;
        a[i + 1] += a[i]; a[i + 1] %= k;
        x[i + 1] = mkp(a[i + 1], i + 1);
    }
    sor(x);
    int ans = 0;
    rep(i,n+1) {
        pin y = x[i];
        y.second += k - 1;
        ans += (upper_bound(x.begin(), x.end(), y) - x.begin()) - i-1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
int main(){
    int A,B;
    cin>>A>>B;
    float x=A/0.08;
    float y=B/0.1;
    int z=max(round(x),round(y));
    int s=0;
    
    for(int i=1;i<=z;i++)
    {
        int p=i*0.08;
        int q=i*0.1;
        if(p==A && q==B)
        {cout<<i<<endl;
        s=1;
        break;}
        
    } 
    if(s==0)
    cout<<"-1"<<endl;
    
}

Measured memory_bytes: 256
def num(card):
    return int(card[2:])

def partition(A, p, r):
    x = num(A[r])
    i = p - 1
    for j in range(p, r):
        if num(A[j]) <= x:
            i += 1
            A[i], A[j] = A[j], A[i]
    A[i + 1], A[r] = A[r], A[i + 1]
    return i + 1

def quicksort(A, p, r):
    if p < r:
        q = partition(A, p, r)
        quicksort(A, p, q - 1)
        quicksort(A, q + 1, r)

n = int(input())
A = [input() for _ in range(n)]
B = sorted(A, key=num)
quicksort(A, 0, n - 1)

msg = "Stable"
for i in range(n):
    if A[i] != B[i]:
        msg = "Not stable"
        break

print(msg)
for card in A:
    print(card)

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


using namespace std;

int main () {

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);

    string s, t; cin >> s >> t;
    int N = s.size(), M = t.size();
    vector<vector<int>> dp(N+1, vector<int>(M+1));
    for (int i = 1; i < N+1; ++i) {
      for (int j = 1; j < M+1; ++j) {
        if (s[i-1] == t[j-1]) {
          dp[i][j] = 1 + dp[i-1][j-1];
        }else {
          dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
        }
      }
    }string ans = "";
     int i = N, j = M;
     while (i && j) {
       if (s[i-1] == t[j-1]) {
         ans += s[i-1]; --i; --j;
       }else if (dp[i-1][j] > dp[i][j-1]) {
         --i;
       }else {
         --j;
       }
     }
     reverse(ans.begin(), ans.end());
     cout << ans << '\n';

  
    return 0;
}




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

using namespace std;

using ll = int_fast64_t;
constexpr ll llmax = INT_FAST64_MAX; // std::numeric_limits<int_fast64_t>::max()
constexpr ll llmin = INT_FAST64_MIN; // std::numeric_limits<int_fast64_t>::min()
using ull = uint_fast64_t;
constexpr ull ullmax = UINT_FAST64_MAX; // std::numeric_limits<uint_fast64_t>::max()

#define FOR(i, b, e) for (int i = (b); i < (e); ++i)
#define RFOR(i, b, e) for (int i = ((e) - 1); (b) <= i; --i)
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define RREP(i, N) for (int i = ((N) - 1); 0 <= i; --i)
#define scanInt(x) int x; scanf("%d", &(x)); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &(x)); getchar();
#define scanVecInt(A, N) vector<int> A(N); REP(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); REP(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    scanInt(N); // 頂点の数
    const int M = N - 1;
    vector<unordered_map<int, ll>> edges(N); // 各頂点から出る辺
    REP(i, M){ // 辺の数はM
        scanInt(ai); --ai;
        scanInt(bi); --bi;
        scanInt(ci); // 辺の長さ
        edges[ai].emplace(bi, ci);
        edges[bi].emplace(ai, ci);
    }

    /* 木構造を作る */
    struct Node {
        int parent = -1; // 親ノードのi
        ll distance = -1; // 根からの距離
        vector<int> children; // 子ノード（複数）のi
        char color;
    };
    vector<Node> nodes(N); // 各ノード（木構造）
    function<void(int, ll)> makeTree = [&](int n, ll dist){ // 頂点n以下の木構造を作る
        nodes[n].distance = dist;
        nodes[n].color = '0' + dist % 2;
        for (auto& e : edges[n]){
            auto& next = e.first;
            if (next == nodes[n].parent) continue; // 親に戻らない
            // if (nodes[next].distance != -1 || 0 < nodes[next].children.size()) continue; // 余分な辺がある場合は、既に訪れた頂点を弾く処理をする
            nodes[n].children.emplace_back(next);
            nodes[next].parent = n;
            makeTree(next, dist + e.second);
        }
    };
    const int R = 0;
    nodes[R].parent = -1; // 根の親は適当に入れておく
    makeTree(R, 0); // 根（距離0）から始める

    REP(i, N){
        cout << nodes[i].color << endl;
    }
}


Measured memory_bytes: 26112
def e_strings_of_inpurity():
    from bisect import bisect
    S = input()
    T = input()

    char_appear = {ch: [] for ch in 'abcdefghijklmnopqrstuvwxyz'}
    for i, ch in enumerate(S):
        char_appear[ch].append(i)

    # editorial における二分探索を使うやり方
    p = -1  # 文字 t は S' の p (mod |S|) 番目に現れた
    loop = 0
    for t in T:
        if not char_appear[t]:
            return -1  # 文字tが存在しなかった
        idx = bisect(char_appear[t], p)
        if idx == len(char_appear[t]):
            loop += 1  # リストの右端を指したということは、次のSを指すことになる
            p = char_appear[t][0]
        else:
            p = char_appear[t][idx]
    return loop * len(S) + p + 1

print(e_strings_of_inpurity())

Measured memory_bytes: 7540
#include <cstdio>
#include <vector>

using namespace std;

int main()
{
  vector<int> h, w;
  short in_h, in_w;

  while(1)
  {
    scanf("%hd %hd", &in_h, &in_w);
    if(in_h == 0 && in_w == 0)break;
    h.push_back(in_h);
    w.push_back(in_w);
  }
  for(int i=0; i < h.size(); i++)
  {
    for (int j=0; j<h[i]; j++)
    {
      for(int k=0; k<w[i]; k++)
      {
        if(j != 0 && j != (h[i]-1) && k != 0 && k != (w[i]-1))
        {
          printf(".");
          continue;
        }
        printf("#");
      }
      printf("\n");
    }
    printf("\n");
  }

  return 0;

}


Measured memory_bytes: 2652
h,w=map(int,input().split())
a=[list(input()) for _ in range(h)]
ys,xs=set(),set()
for y in range(h):
	for x in range(w):
		if a[y][x] == "#":
			ys.add(y)
			xs.add(x)
for y in sorted(list(ys)):
	for x in sorted(list(xs)):
		print(a[y][x], end="")
	print("")


Measured memory_bytes: 4468
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int n,m;
int H[20][20];
int F[1<<15|1][17],Cost[1<<15|1][17];
int Cost2[1<<15|1],B[1<<15|1];
const int INF=0x7f7f7f7f;
void Init(){
	for(int s=0;s<(1<<n);++s)
		for(int i=0;i<n;++i)
			if(s>>i&1) for(int j=0;j<n;++j)
				if(!(s>>j&1)) Cost[s][j]+=H[i][j];
}
int main(){
	scanf("%d%d",&n,&m);
	int a,b,c;
	for(int i=1;i<=m;++i){
		scanf("%d%d%d",&a,&b,&c);
		--a; --b;
		H[a][b]=H[b][a]=c;
	}
	Init();
	int N=(1<<(n-1)),M;
	memset(F,0x7f,sizeof(F));
	F[1][0]=0;
	for(int s=0,t,i,x,j,s2;s<N;++s){
		t=(s<<1|1);
		for(i=0;i<n;++i){
			if(F[t][i]==INF) continue;
			if(!(t>>i&1)) continue;
			x=F[t][i];
			for(j=0;j<n;++j){
				if(!(t>>j&1)&&H[i][j]){
					F[t|(1<<j)][j]=min(F[t|(1<<j)][j],x+Cost[t^(1<<i)][j]);
				}
			}
			M=((1<<n)-1-t);
			for(j=0;j<n;++j)
				if(M>>j&1) Cost2[1<<j]=Cost[t^(1<<i)][j];
			for(s2=M,j=0;s2;s2=(s2-1)&M) B[j++]=s2;
			for(;~j;--j) if(B[j]&(B[j]-1)) Cost2[B[j]]=Cost2[B[j]&(B[j]-1)]+Cost2[B[j]&(-B[j])];
			for(s2=M;s2;s2=(s2-1)&M){
				F[t|s2][i]=min(F[t|s2][i],x+Cost2[s2]);
			}
		}
	}
	printf("%d\n",F[(1<<n)-1][n-1]);
	getchar(); getchar();
	return 0;
}
			


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

using namespace std;

#define llong long long int
#define ldouble long double
#define ternary(condition, x, y) ((condition) ? x : y) 
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) x.begin(), x.end()
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)

const static llong MOD = 1000000000 + 7;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

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

    int ans_sum, ans_sugar;
    double max_concentration = -1, tmp_concentration;
    for (int i = 0; i <= f / (100 * a); ++i) {
        for (int j = 0; 100 * b * j <= f - 100 * a * i; ++j) {
            int water = 100 * a * i + 100 * b * j, sugar_can_be_dissolved = (a * i + b * j) * e;
            for (int k = 0; k <= min(sugar_can_be_dissolved / c, (f - water) / c); ++k) {
                for (int l = 0; d * l <= min(sugar_can_be_dissolved - c * k, (f - water) - c * k); ++l) {
                    tmp_concentration = ((double)k * c + l * d) / (water + k * c + l * d);
                    tmp_concentration *= 100;
                    if (tmp_concentration  >= max_concentration) {
                        ans_sum = water + k * c + l * d;
                        ans_sugar = k * c + l * d;
                        max_concentration = tmp_concentration;
                    }
                }
            }
        }
    }

    cout << ans_sum << " " << ans_sugar << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define PER(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define MOD ((LL)1e9+7) 
#define INF ((LL)1e9+7)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define BIT(x) (1LL << (x))
using namespace std;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

LL modpow(LL x, LL b){
	LL res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

LL modinv(LL x){
	return modpow(x, MOD-2);
}

int main(){
	int N;
	cin >> N;
	map<int, int> s;
	REP(i, N){
		int d;
		cin >> d;
		++s[d];
	}
	int sum = 0;
	foreach(i, s){
		if(i.second>1)sum+=i.second-1;
	}
	cout << N - (sum+1)/2*2 << endl;
}


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

int isPrime(int n) {
    for (int i = 2; i*i <= n; i++) {
        if (n%i==0) return 0;
    }
    return 1;
}

int main() {
    int x;
    cin >> x;

    while (isPrime(x) == 0) x++;

    cout << x << endl;

    return 0;
}



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

using namespace std;
typedef long long int ll;

int main(){

    ll N;
    cin >> N;

    //開店日 0と1で表されるので2進数から10進数になおしておく
    vector<ll > store_day;
    for(ll i = 0; i < N; i++){
        ll tmp = 0;
        for(ll j = 0; j < 10; j++){
            ll in; cin >> in;
            tmp += in * pow(2, j);
        }
        store_day.push_back(tmp);
    }

    //点数, 他の店と開店日が被ってない～すべて被っているがあるので入力は11個
    vector<vector<ll > > point;
    for(ll i = 0; i < N; i++){
        vector<ll > tmp;
        for(ll j = 0; j < 11; j++){
            ll in; cin >> in;
            tmp.push_back(in);
        }
        point.push_back(tmp);
    }    

    //全探査
    ll ans = -1 * INFINITY;
    
    //1日以上は回転していないとイケないので
    for(ll open_day = 1; open_day < pow(2, 10); open_day++){
        ll t_ans = 0;
        for(ll i = 0; i < N; i++){
            ll bit_num = __builtin_popcount(store_day[i] & open_day);
            //cout << bit_num << endl;
            t_ans += point[i][bit_num];
        }
        ans = max(ans, t_ans);
    }

    cout << ans << endl;

}

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

class Tree():
    def __init__(self,n,edge):
        self.n = n
        self.tree = [[] for _ in range(n)]
        for e in edge:
            self.tree[e[0]-1].append(e[1]-1)
            self.tree[e[1]-1].append(e[0]-1)

    def setroot(self,root):
        self.root = root
        self.parent = [None for _ in range(self.n)]
        self.parent[root] = -1
        self.depth = [None for _ in range(self.n)]
        self.depth[root] = 0
        stack = [root]
        while stack:
            node = stack.pop()
            for adj in self.tree[node]:
                if self.parent[adj] is None:
                    self.parent[adj] = node
                    self.depth[adj] = self.depth[node]+1
                    stack.append(adj)

    def construct_lca(self):
        L = (self.n-1).bit_length()
        self.k_parent = [self.parent]
        prev = self.parent
        for k in range(L):
            array = [0 for _ in range(self.n)]
            for i in range(self.n):
                if prev[i] == -1:
                    continue
                array[i] = prev[prev[i]]
            self.k_parent.append(array)
            prev = array

    def lca(self,u,v):
        d = self.depth[v]-self.depth[u]
        if d < 0: u,v,d = v,u,-d
        for k in self.k_parent:
            if d & 1: v = k[v]
            d >>= 1
        if u == v:
            return u
        for k in reversed(self.k_parent):
            pu,pv = k[u],k[v]
            if pu != pv: u,v = pu,pv
        return self.k_parent[0][u]

N = int(input())
E = []

for i in range(N):
    raw_input = list(map(int,input().split()))
    for j in range(raw_input[0]):
        E.append((i+1,raw_input[j+1]+1))

t = Tree(N,E)
t.setroot(0)
t.construct_lca()

Q = int(input())
A = []

for _ in range(Q):
    u,v = map(int,input().split())
    A.append(t.lca(u,v))

print(*A,sep='\n')


Measured memory_bytes: 58868
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int N, K;
int V[51];

int ans = 0;

int main(){
    cin >> N >> K;
    for(int i = 0; i < N; i++){
        cin >> V[i];
    }
    for(int l = 0; l < N; l++){
        for(int r = l; r <= N; r++){
            int pl = l + N - r;
            if(pl > K) continue;

            int sum = 0;
            vector<int> st;

            for(int k = 0; k < l; k++){
                sum += V[k];
                st.push_back(V[k]);
            }

            for(int k = N - 1; k >= r; k--){
                sum += V[k];
                st.push_back(V[k]);
            }
            sort(st.begin(), st.end());

            for(int k = 0; k + pl < K && k < (int)st.size(); k++){
                if(st[k] > 0) break;
                sum -= st[k];
            }

            ans = max(ans, sum);

        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import heapq

def dijkstra(s,edge):
    #始点sから各頂点への最短距離
    d = [10**20] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d

n,x,y = map(int,input().split())

edge = [[] for i in range(n)]
#edge[i] : iから出る道の[重み,行先]の配列
for i in range(n-1):
    edge[i].append([1,i+1])
    edge[i+1].append([1,i])
edge[x-1].append([1,y-1])
edge[y-1].append([1,x-1])

ans = [0 for _ in range(n)]
for i in range(n):
    #dijkstra(始点,edge)
    res = dijkstra(i,edge)
    for j in range(i+1,n):
        ans[res[j]] += 1

for i in range(1,n):
    print(ans[i])


Measured memory_bytes: 85724
n=int(input())
A=[int(i) for i in input().split()]

count=0

for i in range(0,n,1):
  minj=i
  for j in range(i+1,n,1):
    if A[minj] > A[j]:
      minj=j
  if i != minj:
    a= A[i]
    A[i]=A[minj]
    A[minj]=a
    count+=1
  
print(*A, sep=' ')
print(count)


Measured memory_bytes: 5612
import numpy as np

n = int(input())
a = list(map(int, input().split()))
t = 1

if any([i == 0 for i in a]):
    print('0')
else:
    for i in range(n):
        x = a[i]
        t = t * x
        if x == 0:
            break
        if t > 10**18:
            break

    if t > 10**18:
        print('-1')
    else:
        print(t)

Measured memory_bytes: 40216
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BGreedyTakahashi solver = new BGreedyTakahashi();
        solver.solve(1, in, out);
        out.close();
    }

    static class BGreedyTakahashi {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            long a = in.nextLong();
            long b = in.nextLong();
            long k = in.nextLong();
            out.println(Math.max(0, a - k) + " " + Math.min(Math.max(0, a + b - k), b));
        }

    }
}



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

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

struct UnionFind
{
	void init(long n) { par = new long[](n); foreach (i; 0..n) par[i] = i; }
	long root(long i) { return par[i] == i ? i : (par[i] = root(par[i])); }
	bool same(long i, long j) { return root(i) == root(j); }
	void unite(long i, long j) { i = root(i); j = root(j); if (i == j) return; par[i] = j; }
	long[] par;
}

void main()
{
	auto N = RD;
	auto M = RD;

	UnionFind uf;
	uf.init(N);
	foreach (i; 0..M)
	{
		auto x = RD-1;
		auto y = RD-1;
		auto z = RD;
		uf.unite(x, y);
	}
	foreach (i; 0..N)
	{
		uf.root(i);
	}

	auto uq = uf.par.sort().uniq;
	//debug writeln(uf.par);

	writeln(uq.array.length);
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 3964