akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const int INF = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;
template<typename T> inline bool chmin(T& a, T b) {if(a>b) {a=b; return true;} return false;}
template<typename T> inline bool chmax(T& a, T b) {if(a<b) {a=b; return true;} return false;}


int main() {
  string s; cin >> s;
  int n = s.size();
  VV dp(n+1, V(13));
  dp[n][0] = 1;

  int rem = 1;
  rep(i, n) {
    char x = s[n-i-1];
    rep(j, 10) rep(k, 13) {
      if (x == '?' || x - '0' == j) {
        int kk = (rem * j + k) % 13;
        dp[n-i-1][kk] += dp[n-i][k];
        dp[n-i-1][kk] %= MOD;
      }
    }
    rem *= 10;
    rem %= 13;
  }
  cout << dp[0][5] << endl;
  return 0;
}


Measured memory_bytes: 9088
import collections

n = int(input())

ans_s = collections.Counter(input())
for i in range(1, n):
    loss_key = list(ans_s.keys())
    s = collections.Counter(input())
    key = s.keys()
    for k in key:
        ans_s[k] = min(ans_s[k], s[k])
        if k in loss_key:
            loss_key.remove(k)
    for k in loss_key:
        ans_s[k] = 0

ans = ""
for key in ans_s.keys():
    ans += key * ans_s[key]
print("".join(sorted(ans)))

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

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

  sort(a, a+n);
  int bob = 0, alice = 0;

  for(int i = n-1; i >= 0; i -= 2){
    alice += a[i];
  }

  bob = w - alice;
  cout << alice - bob << endl;


}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define int long long
#define pi 3.141592653589793238462643383279502
#define M 998244353
#define F first
#define S second
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)

bool isPowerOfTwo(int n)
{
   if(n==0)
   return false;

   return (ceil(log2(n)) == floor(log2(n)));
}
int power(int x, unsigned int y)
{
    if (y == 0)
        return 1;
    else if (y % 2 == 0)
        return power(x, y / 2) * power(x, y / 2);
    else
        return x * power(x, y / 2) * power(x, y / 2);
}
signed main()
{
int n;
cin>>n;
vector<pair<int,int>>v;
vector<pair<int,int>>w;
for(int i=1;i<=n;i++)
{
    int q=i;
    vector<int>x;
    while(q>0)
    {
        x.push_back(q%10);
        q/=10;
    }
    v.push_back({x[x.size()-1],x[0]});
    w.push_back({x[0],x[x.size()-1]});
    x.clear();
}
map<pair<int,int>,int>m;
for(int i=0;i<w.size();i++)
m[{w[i].first,w[i].second}]++;
int ans=0;
for(int i=0;i<v.size();i++)
{
    int a=v[i].first;
    int b=v[i].second;
    ans+=m[{a,b}];
}
cout<<ans<<endl;
    }



Measured memory_bytes: 9396
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    int x,a,b;cin>>x>>a>>b;
    int A=abs(x-a),B=abs(x-b);
    if(A<B)cout<<"A"<<endl;
    else cout<<"B"<<endl;
}

Measured memory_bytes: 3612
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back
#define REP(i,a,b) for(int i=a; i<=b; i++)
#define MOD 1000000007

void solve(int test_case) {//209
	int n,m;
	cin>>n>>m;
	vi balls(n);
	REP(i,0,n-1)balls[i]=1;
	vector<bool> red(n,0);
	red[0]=1;
	while(m--) {
		int x,y;
		cin>>x>>y;
		x--,y--;
		balls[y]++;
		balls[x]--;
		if(red[x])red[y]=1;
		if(balls[x]==0)red[x]=0;
	}
	int cnt=0;
	REP(i,0,n-1)if(red[i])cnt++;
	cout<<cnt;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	//prefill();
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3704
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> //tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <numeric>
using namespace std;

int cal_dist(int p, int x) {
    int dist = (p < x) ? x - p : p - x;
    return dist * 2; // 往復
}

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> x(N);
    for (int i = 0; i < N; i++) {
        cin >> x.at(i);
    }

    int dist_a, dist_b, min_dist = 0;
    for (int i = 0; i < N; i++) {
        dist_a = cal_dist(0, x.at(i));
        dist_b = cal_dist(K, x.at(i));
        min_dist += (dist_a <= dist_b) ? dist_a : dist_b;
    }

    cout << min_dist << endl;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  int A = 0;
  vector<int> K(N);
  for(int i = 0; i < N; i++){
      cin >> K.at(i);
  }
  sort(K.begin(),K.end());
  reverse(K.begin(),K.end());

    A = K.at(0)-K.at(M-1);

  for(int i = 1; i < N-(M-1); i++){
    A = min(A,K.at(i)-K.at(i+(M-1)));
  }
  cout << A << endl;

}

Measured memory_bytes: 640
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<iostream>
#define rep(i,s,t) for(register int i=s;i<=t;++i)
using namespace std;
const int N=1e6+11;
int n,tag,ans,tail=N-1,head=N-1,q[N];
char s[N],t[N];
int main(){
	//freopen("game.in","r",stdin);
	//freopen("game.out","w",stdout);
	scanf("%d%s%s",&n,s+1,t+1);
    if(!strcmp(s+1,t+1)){
		puts("0");
		return 0;
	}
	for(int l=n+1,r=n,pl=n+1,pr=n+1;r;r=l-1){
        for(;t[l-1]==t[r];--l);
        for(pr=pl-1;s[pl-1]==s[pr];--pl);
        for(;(pl>l||s[pr]!=t[r])&&pr;)
            for(pr=pl-1;s[pl-1]==s[pr]&&pr;--pl);
        if(!pr){
			puts("-1");
			return 0;
		}
        pl=max(pl,min(l,pr));
        for(;tail-head&&q[tail-1]+tag>r;--tail);
        --tag;q[--head]=pl-tag;
        ans=max(ans,tail-head);
    }
    printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 6144
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

const int mod = 1'000'000'007;
vector<long> fact;
vector<long> ifact;

int mpow(int x, int y) {
    if (y==0) return 1;
    long a = mpow(x,y>>1);
    (a*=a) %= mod;
    if(y&1) (a*=x) %= mod;
    //cout << "x " << x << "  y " << y << "  a " << a << endl;
    return a;
}

void init(int n) {
    fact[0] = 1;
    for(int i=1; i<=n; ++i) fact[i] = fact[i-1]*i %mod;
    ifact[n] = mpow(fact[n], mod-2) % mod;
    for(int i=n; i>0; --i) ifact[i-1] = ifact[i]*i % mod;
}

long nPr(int n, int r) {
    if ( r<0 || n<r ) return 0;
	return fact[n] * ifact[n-r] % mod;
}


void dfs(long& ans, const int k, vector< vector <int> >& g, const int now, const int p){
    // cout << "now1 : " << now << "\t ans : " << ans << endl;
    if ( p != 0 && g[now].size() <= 1 ) return;
    if (p == 0) (ans *= nPr(k-1, g[now].size())) %= mod;
    else (ans *= nPr(k-2, g[now].size() - 1)) %= mod;
    // cout << "now2 : " << now << "\t ans : " << ans << endl;
	
	for(auto child: g[now]){
        if (child == p) continue;
        dfs(ans, k, g, child, now);
	}
}


int main() {
	int n, k;
	cin >> n >> k;
    --n;
	vector< vector<int> > g(n+5);
    fact = vector<long>(k+2);
    ifact = vector<long>(k+2);
    init(k);
    // cout << "init fin" << endl;

	for(int i=0; i<n; ++i) {
		int a,b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    // cout << "input fin" << endl;

    long ans = k;
    dfs(ans, k, g, 1, 0);
    // cout << "dfs fin" << endl;
    cout << ans << endl;
}


Measured memory_bytes: 10368
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;

int main(){
  string S;
  cin >> S;
  int size = S.size();
  string tmp = S;
  for(int i = 0; i < size; i++) S[i] = tmp[size-1-i];

  ll dp[size][13];
  for(int i = 0; i < size; i++){
    for(int j = 0; j < 13; j++){
      dp[i][j] = 0;
    }
  }

  if(S[0] == '?') for(int i = 0; i < 10; i++) dp[0][i] = 1;
  else  dp[0][(int)S[0]-48] = 1;

  int rest = 1;
  for(int i = 1; i < size; i++){
    rest = (rest*10)%13;
    int diff;
    if(S[i] == '?'){
      for(int j = 0; j < 10; j++){
        diff = (rest * j)%13;
        for(int k = 0; k < 13; k++) dp[i][(k+diff)%13] = (dp[i][(k+diff)%13] + dp[i-1][k])%MOD;
      }
      
    }else{
      diff = (rest * ((int)S[i] - 48))%13;
      for(int j = 0; j < 13; j++) dp[i][(j+diff)%13] += (dp[i][(j+diff)%13] + dp[i-1][j])%MOD;
    }
  }

  /**
  for(int i = 0; i < size; i++){
    for(int j = 0; j < 13; j++)
      cout << dp[i][j] << " ";
    cout << "\n";
  }
  **/

  cout << dp[size-1][5] << "\n";
  return 0;
}

Measured memory_bytes: 10624
#include <iostream>
#include <cmath>
#include <climits>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string.h>
#include <iomanip>
#include <ctype.h>

#define ll          long long int
#define ull         unsigned long long int
#define pb          push_back
#define pii         pair<int,int>
#define F           first
#define S           second
#define vi          vector<int>
#define vli          vector<ll>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define M_PI        3.14159265358979323846
#define mp          make_pair
#define sz(x)       (int)x.size()
//#define hell        1000000007
#define matrix      vector<vector<ll>>
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define eps 0.000000001
#define all(a)      (a).begin(),(a).end()
const long long INF = (long long) 1e7+1;
const long long mod = (long long) 998244353;
const long long hell = (long long) 1000000007;

using namespace std;
#include <stdio.h>

ll power(ll x,ll y)
{
  ll res=1;
  while(y>0)
  {
    if(y%2) res=(x%mod*res%mod)%hell;
    x=(x%mod*x%mod)%mod;
    y=y/2;
  }
  return res%mod;
}

ll modinv(ll x){
  return power(x,mod-2);
}

void solve();


void fastIO() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}

int main(){
   fastIO();
    solve();
}
//void sieve();
ll pw(ll k,ll x);
ll gcd(ll x,ll y);

/*
  For freq or prime factors

for(auto pri:prime){
  while(k%pri==0){
    pcnt[pri]++;
    k/=pri;
  }
}*/



void solve(){
  int test;
  //cin>>test;
  test=1;
  while(test--){
       ll n,a,b;
       cin>>n>>a>>b;
 
       if(a>b)
       swap(a,b);
       

       ll ans=min(b-1,n-a);
       if((b-a)%2==0)
       ans=min(ans,(b-a)/2);
       
       if((b-a)&1){    
          ll x=a-1+(b-a+1)/2;
          ll y=(n-b)+(b-a+1)/2;
          ans=min({ans,x,y});
       }
       
       cout<<ans;
  }
}




/*bool issafe(int x,int y){
  return (x>=0 && y>=0 && x<n && y<m);
}*/

///Before submit=>
///    *check for integer overflow,array bounds
///    *check for n=1

ll gcd(ll x,ll y){
  if(x==0)
  return y;
  else
  return gcd(y%x,x);
}


ll pw(ll k,ll x){
  if(x==0)
  return 1;
  if(x&1)
  return ((pw(k,x-1))*k);
  else
  return ((pw(k,x/2))*(pw(k,x/2)));
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
typedef long long ll;

#define MAX(x, y)	(((x) > (y))? (x) : (y))
#define MIN(x, y)	(((x) < (y))? (x) : (y))
#define ABS(x)		(((x) < 0)? (-1*(x)) : (x))
#define REPI(x,y)	for (i=(x);i<(y);i++)
#define REPJ(x,y)	for (j=(x);j<(y);j++)
#define MEMCLR(X)	memset((X),0,sizeof((X)))

using namespace std;
int i,j,k,X,A,B,C,x;

int main() {
	cin >> A;
	cin >> B;
	cin >> C;
	cin >> X;
	
	for (i=0;i<=A;i++)
	for (j=0;j<=B;j++)
	for (k=0;k<=C;k++)
	if ( (500*i+100*j+50*k) == X )x++;
	
	cout << x << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;

template<class _T> static void getval(_T& a) {
	std::cin >> a;
}
template<class _T> static void getval(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void getval(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}
template <class _T> static _T tp_abs(_T a) {
	if (a < (_T)0) {
		a *= (_T)-1;
	}
	return a;
}
template <class _T> static void tp_swap(_T& right, _T& left) {
	//	usage:  tp_swap<type name>(a, b);
	_T tmp = right;
	right = left;
	left = tmp;
}

static void exec();

int main()
{
	exec();
	fflush(stdout);
	return 0;
}

static void exec()
{
	int N;
	getval(N);

	int rate;
	int color = 0;
	std::vector<int> members(9, 0);
	for (int i = 0; i < N; i++) {
		getval(rate);
		int upper = 399;
		bool freeCol = true;
		for (int col = 0; col < 8; col++) {
			if (rate <= upper) {
				members[col]++;
				freeCol = false;
				break;
			}
			upper += 400;
		}
		if (freeCol) {
			members[8]++;
		}
	}

	int min = 0, max = 0;
	for (int i = 0; i < 8; i++) {
		if (members[i]) {
			min++;
		}
	}
	max = min;
	if (members[8]) {
		max = min + members[8];
		if (min == 0) min++;
	}
	printf("%d %d\n", min, max);
}


Measured memory_bytes: 3704
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;cin>>N;
  vector<long long>L(N);
  for(int X=0;X<N;X++){
    cin>>L[X];
  }
  sort(L.begin(),L.end());
  int U=0;
  for(int X=0;X<N-2;X++){
    for(int Y=X+1;Y<N-1;Y++){
      for(int Z=Y+1;Z<N;Z++){
        if(L[X]+L[Y]>L[Z]&&L[X]!=L[Y]&&L[X]!=L[Z]&&L[Y]!=L[Z]){
          U++;
        }
      }
    }
  }
  cout<<U<<endl;
}

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

long long gcd(long long a, long long b) {
	if(b == 0) return a;
  else return gcd(b, a%b);
}

int main() {
  long long a, b;
  while(cin >> a >> b) {
    long long g = gcd(a, b);
    long long  l = a*b / g;
    cout << g << ' ' << l << endl;
  }
}

Measured memory_bytes: 1156
N,L=map(int,input().split())

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


for i in range(1,len(a)):
    if a[i]+a[i-1]<L:
        pass
    else:
        print("Possible")
        for j in range(1,i):
            print(j)
        for k in range(len(a)-i-1):
            print(len(a)-1-k)
        print(i)
        exit()
print("Impossible")

Measured memory_bytes: 14052
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<math.h>
#include<map>
#include<iterator>
#include<set>
#include<queue>

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

using namespace std;

long long sumup(long long n){
	return n*(n+1)/2;
}

int main(){
	long long n; cin >> n;
	long long sum = n;
	rep(i,n){
		long long  nowpoint = n - i;
		if(sumup(nowpoint - 1) < sum){
			cout << nowpoint << endl;
			sum -= nowpoint;
		}
	}
}

Measured memory_bytes: 384
//"I'll live the focused life, because it's the best kind there is" - Winifred Gallagher
#include<bits/stdc++.h>
using namespace std;
#define debug(a) cout << #a << ": " << a << endl
using namespace std;
#define ll long long
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int> pii;
#define sz(a) int(a.size())
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) (v).begin(),(v).end()
#define fast cin.tie(0); ios::sync_with_stdio(false);
int main(){
	int a, b, c; cin>>a>>b>>c;
	cout<<(b - a == c - b ? "YES" : "NO") <<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n, x, ans = 0;
  int a, b, c;
  while (1) {
    scanf("%d %d", &n, &x);
    if (n == 0 && x == 0) {
      break;
    }
    for (a = 1; a <= n; a++) {
      for (b = a + 1; b <= n; b++) {
        c = x - a - b;
        if (b < c && c <= n) {
          ans++;
        }
      }
    }
    printf("%d\n", ans);
    ans = 0;
  }
}

Measured memory_bytes: 2580
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(void)
{
	char z[201];
	int a,s,d,f,g,h,i,j;
	scanf("%s",z);
	a=strlen(z);
	s=0;
	while(1){
		a--;
		if(a==0) break;
		if(a%2==0){
			for(i=0;i<a/2;i++){
			//	printf("%c %c\n",z[i],z[a/2+i]);
				if(z[i]!=z[a/2+i]){
					s=0;
					break;
				}
				s=a;
			}
		//	printf("\n\n");
		}
		if(s>0) break;
	}
	printf("%d\n",s);
	return 0;
}

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

int c[3][3], a[3], b[3];
bool check = true;

int main(){
	for(int i=0; i<3; i++){
		for(int j=0; j<3; j++){
			cin >> c[i][j];
		}
	}

	a[0] = 0;
	b[0] = c[0][0];
	b[1] = c[0][1];
	b[2] = c[0][2];
	a[1] = c[1][0]-b[0];
	a[2] = c[2][0]-b[0];
	for(int i=0; i<3; i++){
		for(int j=0; j<3; j++){
			if(a[i]+b[j]!=c[i][j]){
				check = false;
				break;
			}
		}
	}
	if(check){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
}


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

int main(){
  long A, B;
  int K;
  cin >> A >> B >> K;
  if(A+K-1 >= B-K+1){
    for(int i=A; i<=B; i++){
      cout << i << endl;
    }
    return 0;
  }
  for(int i=A; i<A+K; i++){
    cout << i << endl;
  }
  for(int i=B-K+1; i<=B; i++){
    cout << i << endl;
  }
  return 0;
}

Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
#include <cassert>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

void cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
int main(void){
    ll n, m;
    cin >> n >> m;
    ll dist[110][110];
    rep(i, 110) rep(j, 110) dist[i][j] = INF;
    rep(i, 110) dist[i][i] = 0;
    vector<pair<pair<ll,ll>,ll>> e;
    rep(i, m){
        ll a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        dist[a][b] = min(dist[a][b], c);
        dist[b][a] = min(dist[b][a], c);
        e.push_back({{a, b}, c});
    }
    rep(via, n){
        rep(i, n){
            rep(j, n){
                dist[i][j] = min(dist[i][j], dist[i][via] + dist[via][j]);
            }
        }
    }
    ll ans = 0;
    rep(i, m){
        bool use = false;
        rep(j, n){
            rep(k, n){
                if(dist[j][e[i].first.first] + e[i].second + dist[e[i].first.second][k] == dist[j][k]){
                    use = true;
                }
                
            }
        }
        if(use) ans++;
    }
    cout << m - ans << endl;
}


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

#define ll long long
#define ld long double
#define pb push_back
#define mod 1000000007
#define mk make_pair
#define sz size

ll find(ll x,vector<ll> &root){
    while(root[x]!=x){
        root[x]=root[root[x]];
        x=root[x];
    }
    return x;
}

ll union_find(ll x,ll y,vector<ll>&root,vector<ll> &arr){
    ll r1=find(x,root);
    ll r2=find(y,root);
    if(arr[r1]>arr[r2]){
        root[r2]=r1;
    }else if(arr[r1]<arr[r2]){
        root[r1]=r2;
    }
}

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

    ll i,n;
    cin>>n;
    ll ctr=0;
    for(i=1;i<=n;i++)
    if(i%2==1)ctr++; 
    cout<<std::setprecision(10)<<(ld)ctr/(ld)n;
    return 0;  
}

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

int main(){

	int sum=0,Min=100000;

	int n,l;	cin>>n>>l;
	for(int i=0;i<n;i++){
		Min=min(abs(Min),abs(i+l));
		if(i+l<0)Min*=-1;
		sum+=l+i;
	}

	cout<<sum-Min<<endl;


	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;
ll f(ll n){
    return (n*n + 4) / 8;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,K;
    cin >> N >> K;
    ll ans = 1;
    rep(i,0,N){
        if(ans*2 > ans+K){
            ans += K;
        }else{
            ans *= 2;
        }
    }
    print(ans);

}

Measured memory_bytes: 256
//  RAKSHIT KADAM
//ALWAYS USE &IT FOR ITERATING USING AUTO ...
//USE COUNT(STARTING ADDRESS, ENDING ADRESS ,VALUE) FOR FINDING THE COUNT IN THE RESPECTIVE DATA STRUCTURE
//NOTE THAT MEMSET CANNOT ASSIGN A VALUE OF 10^18 IT WILL ASSIGN A LOWER VALUE THAN THAT!!!
//NOTE THAT MEMSET CANT FILL THE DOUBLE VALUES;
//ACCUMULATE DOES NOT WORK PROPERLY IF VALUES START SUMMING BEYOND 1E9...
 #include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree< int ,  null_type ,  less<int> ,  rb_tree_tag ,  tree_order_statistics_node_update>
#warning !!!check the size of arrayss!!!

// NUMERIC DEFINITIONS :
    #define INF 2000000000000000005
    #define MOD  1000000007
    #define newMOD  998244353
    #define MAX 300006
    #define pi 3.1415926535897932384626433832795
#define ld long double
 #define ll long long
 #define int long long

 #define P(gg) for(auto rax:gg){cout<<rax<<" ";}cout<<endl;
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll t; cin>> t; while(t--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define endl "\n"
 #define x first
 #define y second
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define forci(i,n) for(ll i=0;i<n;i++)
 #define vi vector<ll>
 #define Endl endl
 #define lb lower_bound
 #define ub upper_bound
#define pii pair<ll,ll>

 #define input freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout)
 #define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;

ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
int power(int x, unsigned int y, unsigned int m){ if (y == 0) return 1;int p = power(x, y/2, m) % m;  p = (p * p) % m;                                                  return (y%2 == 0)? p : (x * p) % m;}
ll modInverse(int a, int m){int g = gcd(a, m); { return power(a, m-2, m);}}
const int maxn= 500004;

void solve()
{
    ll a,b;cin>>a>>b;
    cout<<a*b<<endl;
   
        
}
signed main()
{
   Need_for_speed(activated);
    
//satisfy
//    {
//   solve();
//   }

    solve();
    return 0;
}



Measured memory_bytes: 3640
#include<iostream>
using namespace std;
int main(){
  	int x,a,b;
  	cin >> x >> a >> b;
  	a=x-a;
  	if(a<0)
      	a=-a;
  	b=x-b;
  	if(b<0)
      	b=-b;
  	if(a<b)
      	cout << "A" << endl;
 	else
      	cout << "B" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

struct Combination{
  const int MOD = 1e9+7;

  vector<int> fact; //　fact[i] = iの階乗
  void init(int n){
    fact.resize(n+1);
    fact[0] = fact[1] = 1;
    for(int i = 2; i <= n; i++){
      fact[i] = i * fact[i-1] % MOD;
    }
  }

  int nCr(int n, int r){ // nCr = n!/r!(n-r)!
    if(n < r) return 0;
    return fact[n] * mod_pow(fact[r]*fact[n-r]%MOD, MOD-2) % MOD;
  }

  int mod_pow(int n, int p){ // a/n ≡ a*n^(p-2) nとpは互いに素
    int r = 1;
    for(; p > 0; p >>= 1){
      if(p & 1LL) r = (r * n) % MOD;
      n = (n * n) % MOD;
    }
    return r; // r = n^p % MOD
  }

}comb;
const int MOD = 1e9 + 7;

signed main(){

  int n; cin >> n;
  vector<vector<int>> G(n);
  for(int i = 0; i < n-1; i++){
    int a, b; cin >> a >> b;
    a--, b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  comb.init(2e6);
  vector<int> num(n, 0), dp(n, 1);
  auto dfs1 = [&](auto&& dfs1, int u, int p)->void{
    for(int v : G[u]){
      if(v == p) continue;
      dfs1(dfs1, v, u);
      num[u] += num[v];
      dp[u] = dp[u] * dp[v]%MOD * comb.nCr(num[u], num[v]) % MOD;
    }
    num[u]++;
  };
  dfs1(dfs1, 0, -1);

  vector<int> ans(n);
  auto dfs2 = [&](auto&& dfs2, int u, int p, int res)->void{
    ans[u] = dp[u] * res%MOD * comb.nCr(n-1, n-num[u]) % MOD;
    for(int v : G[u]){
      if(v == p) continue;
      res = ans[u] * comb.mod_pow(dp[v], MOD-2)%MOD * comb.mod_pow(comb.nCr(n-1, num[v]), MOD-2) % MOD;
      dfs2(dfs2, v, u, res);
    }
  };
  dfs2(dfs2, 0, -1, 1);

  for(int p : ans){
    cout << p << endl;
  }

  return 0;
}


Measured memory_bytes: 35440
#include"iostream"
#include"vector"
using namespace std;
int main(void) {
	int long a, b;
	int cnt = 0,max=9999999999999;
	vector<int> v;
	cin >> a;

	for (int i = 0; i < a; i++) {
		cin >> b;
		v.push_back(b);
	}

	for (int long x : v) {
		if (x < max) {
			max = x;
			cnt++;
		}
	}
	cout << cnt;

}

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

using namespace std;

typedef long long LL;

int N,M;
int fa[200010],d[200010];

int find(int x)
{
	if (x == fa[x]) return x;
	int tmp = find(fa[x]);
	d[x] += d[fa[x]];
	fa[x] = tmp;
	return tmp;
}

int main()
{
	scanf("%d%d",&N,&M);
	for (int i=1;i<=N;i++)fa[i] = i, d[i] = 0;
	bool ok = true;
	for (int i=1;i<=M;i++)
	{
		int L,R,D;
		scanf("%d%d%d",&L,&R,&D);
		if (find(L) == find(R))
		{
			if (d[L] - d[R] != D) ok = false;
		}
		else
		{
			int fl = find(L), fr = find(R);
			d[fl] = D + d[R] - d[L];
			fa[fl] = fr;
		}
	}
	if (ok)
		puts("Yes");
	else
		puts("No");
	
}

Measured memory_bytes: 1024
i =input()

a=-1

for x in range(0,len(i)):
  if a==-1 and (i[x:x+1]!='R' and i[x:x+1]!='U' and i[x:x+1]!='D'):
    print('No')
    exit()
  if a==1 and (i[x:x+1]!='L' and i[x:x+1]!='U' and i[x:x+1]!='D'):
    print('No')
    exit()
  a*=-1
print('Yes')
  


Measured memory_bytes: 3060
n = int(input())
code = input()
f = 0
total = 0
for i in range(0,1000):
  s = str(i)
  if i< 10:
    s = '00' + s
  elif i < 100:
    s = '0' + s
  idx = -1
  for dig in range(3):
    idx = code.find(s[dig], idx+1) 
    if idx == -1:
      break
  if idx != -1:
    total += 1
print(total)
        
      
  

Measured memory_bytes: 3060
using System;
using static System.Console;
using System.Linq;

namespace AC
{
   public class shiokara
   {
      static void Main(string[] args)
      {
         string n = ReadLine();
         if(n[0] == '7' || n[1] == '7' || n[2] == '7'){
             WriteLine("Yes");
         }else{
             WriteLine("No");
         }
      }
   }
}

Measured memory_bytes: 25800
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5, mod = 1e9 + 7;

ll n, k, a[N];

bool tmam(ll x){
    ll c = 0;
    if(x == 0){
        int idx0 = lower_bound(a, a + n, 0) - a;
        int idx1 = lower_bound(a, a + n, 1) - a;
        ll pos = n - idx1;
        ll zeroes = idx1 - idx0;
        ll neg = n - (pos + zeroes);
        c = neg * zeroes + neg * pos + zeroes * pos + zeroes * (zeroes - 1) / 2;
        return c >= k;
    }
    for(int i = 0; i < n; i++){
        if(x > 0){
           if(a[i] == 0) c += n - 1 - i;
           else if(a[i] > 0){
            int idx = upper_bound(a + i + 1, a + n, x / a[i]) - a;
            c += idx - i - 1;
           }
           else{
            int idx = lower_bound(a + i + 1, a + n, x / a[i]) - a;
            c += n - idx;
           }
        }
        else{
            if(a[i] >= 0) break;
            int idx = lower_bound(a + i + 1, a + n, x / a[i] + (x % a[i] != 0)) - a;
            c += n - idx;
        }
    }
    return c >= k;
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n >> k;
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);
    ll low = -1e18, high = 1e18, mid, ans;
    while(high >= low){
        mid = low + high >> 1;
        if(tmam(mid)){
            ans = mid;
            high = mid - 1;
        }
        else low = mid + 1;
    }
    cout << ans;

    return 0;
}


Measured memory_bytes: 5172
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll=long long;
using ld=long double;
using Graph=vector<vector<int>>;
const int mod=1e9+7;
const int mxN=2e6+3;
vector<int> x_vec={-1,1,0,0};
vector<int> y_vec={0,0,-1,1};

int main(void){
    int n;
    cin>>n;
    int d1[110];
    int d2[110];
    rep(i,n)cin>>d1[i]>>d2[i];
    rep(i,n){
        if(d1[i]==d2[i]){
            if(i<n-1&&d1[++i]==d2[i]){
                if(i<n-1&&d1[++i]==d2[i]){
                    cout<<"Yes"<<endl;
                    return 0;
                }
            }
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (ll i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (ll i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (ll i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (ll i = x.size()-1; i >= 0; i--)
#define REPITR(itr,x) for (auto itr = (x).begin(); itr != (x).end(); itr++)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define CHMAX(a,b) a = max(a,b)
#define CHMIN(a,b) a = min(a,b)
#define debug(x) cerr<<__LINE__<<": "<<(#x)<<" = "<<(x)<<endl;
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define e1 first
#define e2 second
#define newline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;
const double pi = 3.141592653589793;
const VI dx = {1, 0, -1, 0};
const VI dy = {0, 1, 0, -1};



int main()
{
    ll n;
    cin>>n;
    VLL y(n+1,2);
    y[1] = 1;
    for (ll i = 2; i <= n / 2 + 1; ++i) {
        for (ll j = 2; j * i <= n ; ++j) {
            y[i*j] += 1;
        }
    }
    ll ans = 0ll;
    FOR(i,1,n+1) {
        //cout<<i<<" "<<y[i]<<endl;
        ans += i * y[i];
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 81392
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.IO;
using System.Threading.Tasks;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static void Main(string[] args)
        {
            string S = Read();
            int N = S.Length;
            int min = N;
            for (int i = 1; i < N; ++i)
            {
                if (S[i - 1] != S[i])
                {
                    min = Math.Min(Math.Max(i, N - i), min);
                }
            }
            Console.WriteLine(min);
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using pq = priority_queue<int>;
template<class T>
using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int under = (1 << 31);
int upper = under - 1;
ll UNDER = (1LL << 63);
ll UPPER = UNDER - 1;
const int MOD = 1e9 + 7;
const long double pi = 3.141592653589793;
int main() {
	int n;
	cin >> n;
	V a(n + 1);
	rep1(i, n) {
		cin >> a[i];
	}
	sort(all(a));
	VL sum(n + 1, 0);
	rep1(i, n) {
		sum[i] = sum[i - 1] + a[i];
	}
	int streak = 1;
	rep1(i, n - 1) {
		if (sum[i] * 2 >= a[i + 1]) streak++;
		else streak = 1;
	}
	cout << streak << endl;
	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>
#include <cctype>
#include <map>
#include <queue>

using namespace std;

const int mod = 1000000007;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ll long long

int main()
{
    string s,t;
    cin >> s >> t;

    vector<char> vecS(s.size());
    for (int i = 0; i < s.size(); i++)
    {
        vecS[i] = s[i];
    }
    sort(vecS.begin(), vecS.end());
    
    vector<char> vecT(t.size());
    for (int i = 0; i < t.size(); i++)
    {
        vecT[i] = t[i];
    }
    sort(vecT.begin(), vecT.end(), greater<char>());

    string ansS;
    for (int i = 0; i < s.size(); i++)
    {
        ansS += vecS[i];
    }
    
    string ansT;
    for (int i = 0; i < t.size(); i++)
    {
        ansT += vecT[i];
    }

    cout << ((ansS < ansT) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

int n, a[100];

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	long double val = 0;
	for(int i = 0; i < n; i++){
		long double a;
		cin >> a;
		val += 1 / a;
	}
	cout << 1 / val << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <sstream>
#include <complex>
#include <ctime>
#include <cassert>
#include <functional>

using namespace std;

typedef long long ll;
typedef vector<int> VI;
typedef pair<int, int> PII;

#define REP(i,s,t) for(int i=(s);i<(t);i++)
#define FILL(x,v) memset(x,v,sizeof(x))

using namespace std;
string is_valid_triangle(int a, int b, int c){
    string out = "NO";
    if (pow(a, 2) == pow(b,2) + pow(c,2) || pow(b, 2) == pow(a, 2) + pow(c, 2) || pow(c, 2) == pow(a, 2) + pow(b, 2)){
        out = "YES";
    }
    return out;
}
int main() {
    int l;
    cin >> l;
    REP(i, 0, l){
        int a, b, c;
        cin >> a >> b >> c;
        cout << is_valid_triangle(a, b, c) << endl;
    }
    return 0;
}

Measured memory_bytes: 3144
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int[] spade = new int[13];
        int[] heart = new int[13];
        int[] club = new int[13];
        int[] diamond = new int[13];

        for(int i=0;i<n;i++){
            String mark = sc.next();
            int number = sc.nextInt();

            switch(mark){
                case "S":
                    spade[number-1]++;
                    break;
                case "H":
                    heart[number-1]++;
                    break;
                case "C":
                    club[number-1]++;
                    break;
                case "D":
                    diamond[number-1]++;
                    break;
            }
        }
        for(int i=0;i<13;i++){
           if(spade[i]==0) {System.out.println("S " + (i+1));}
        }for(int i=0;i<13;i++){
            if(heart[i]==0) {System.out.println("H " + (i+1));}  
        }for(int i=0;i<13;i++){
            if(club[i]==0) {System.out.println("C " + (i+1));}
        }for(int i=0;i<13;i++){
            if(diamond[i]==0) {System.out.println("D " + (i+1));}
        }
    }
}


Measured memory_bytes: 26268
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;
    
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>
#define pq priority_queue<ll>
#define rpq priority_queue<ll,vector<ll>,greater<ll>>
#define p_b push_back
    
ll n,cnt,ans,a[ohara],b[ohara],d,tmp,tmpp,m,h,w,x,y,sum,pos,k,q;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
ll dp[1500][6000];
V c[2000];
    
//------ Believe yourself as a genius!!!!!! ------
    
int main(void){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>n>>m;
    rep(i,m){
        cin>>a[i]>>b[i];
        rep(j,b[i]){
            cin>>d;
            d--;
            c[i].p_b(d);
        }
    }
    rep(i,1200){
        rep(j,6000){
            dp[i][j]=LINF;
        }
    }
    dp[0][0]=0;
    rrep(i,1,m+1){
        tmp=0;
        rep(j,b[i-1]){
            tmp|=(1LL<<c[i-1][j]);
            //cout<<c[i-1][j]<<" ";
        }
        //cout<<tmp<<"\n";
        //cout<<"\n";
        rep(j,5000){
            dp[i][j]=min(dp[i][j],dp[i-1][j]);
        }
        rep(j,5000){
            if((j | tmp)>=5000)continue;
            dp[i][(j | tmp)]=min({dp[i-1][(j | tmp)],dp[i][(j | tmp)],dp[i-1][j]+a[i-1]});
        }
    }
    tmp=0;
    rrep(i,0,n)tmp|=(1LL<<i);
    if(dp[m][tmp]==LINF)Cout(-1);
    else Cout(dp[m][tmp]);
    return 0;
}

Measured memory_bytes: 61824
#include <bits/stdc++.h>
#define X first
#define  Y second
#define mp make_pair
using namespace std;
typedef long long ll;
const int N = 200010;
int n,k,a[N],c[N];
int main(){
	scanf("%d%d",&n,&k);
	for(int i =1;i<=n;i++) {
		int x;
		scanf("%d",&x);
		c[x]++;
	}
	sort(c+1,c+n+1,greater<int>());
	int tot =0;
	for(int i =1;i<=k;i++) tot+=c[i];
	printf("%d\n",n-tot);
	return 0;
}

Measured memory_bytes: 1024
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.typecons;
import std.numeric, std.math;
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; }
bool minimize(T)(ref T x, T y) { if (x > y) { x = y; return true; } else { return false; } }
bool maximize(T)(ref T x, T y) { if (x < y) { x = y; return true; } else { return false; } }

long mod = 10^^9 + 7;
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; }

void main()
{
	auto X = RD;
	long ans, pos;
	foreach (i; 1..X+1)
	{
		pos += i;
		if (pos >= X)
		{
			ans = i;
			break;
		}
	}
	writeln(ans);
	stdout.flush();
}

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

int main()
{
    int a, b, sum = 0, i;

    cin>>a>>b;

    for(i=0; i<2; i++)
    {
        if(a>b)
        {
            sum = sum + a;
            a--;
        }
        else{
            sum = sum + b;
            b--;
        }
    }

    cout<<sum;
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
   ll n;cin>>n;
   vector<ll>a(n);
   vector<ll>b(n);
    for (int i = 0; i < n; ++i) {
        cin >>a[i];
    }
    for (int i = 0; i < n; ++i) {
        cin >>b[i];
    }
   vector<ll>d(n);
    ll sum=0;
    for (int i = 0; i < n; ++i) {
        d[i]=a[i]-b[i];
        sum+=d[i];
    }
   if(sum<0)cout <<-1<<endl;
   else {
       vector<bool>ch(n,true);
       ll ans=0;
       sort(all(d));
       ll k=n-1;
       for (int i = 0; i < n; ++i) {
           if(d[i]<0){
               if(ch[i])ans++;
               ch[i]=false;
               while(1) {
                   if (d[k] + d[i] < 0) {
                       if (ch[k]) {
                           ans++;
                           ch[k] = false;
                       }
                       d[i] += d[k];
                       d[k] = 0;
                       k--;
                   }
                   else {
                       if(ch[k]){
                           ans++;
                           ch[k]=false;
                       }
                       d[k]+=d[i];
                       d[i]=0;
                       break;
                   }
               }
           }
       }
       cout <<ans <<endl;
   }
   return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<cstdio>
#include<cstring>
#include <algorithm> 
using namespace std;
int n,m,q,ansv,ansf,v[2005][2005],f[2005][2005],l[2005][2005],h[2005][2005],a[2005][2005];
int x1,x2,y1,y2;
char c;
int main()
{
	int i,j;
	cin>>n>>m>>q;
	for (i=1;i<=n;i++)
		for (j=1;j<=m;j++)
		{
			c=getchar();
			while (c!='0'&&c!='1') c=getchar();
			a[i][j]=c-'0';
			f[i][j]=f[i-1][j]+f[i][j-1]-f[i-1][j-1];
			if (a[i][j]==1) f[i][j]++;
			h[i][j]=h[i][j-1];
			if (a[i][j]==1&&a[i][j-1]==1) h[i][j]++;
			l[i][j]=l[i-1][j];
			if (a[i][j]==1&&a[i-1][j]==1) l[i][j]++;
			v[i][j]=v[i][j-1]+v[i-1][j]-v[i-1][j-1];
			if(a[i][j]==1&&a[i-1][j]==1) v[i][j]++;
			if(a[i][j]==1&&a[i][j-1]==1) v[i][j]++;
		}
	//for (i=1;i<=n;i++)
	//	for (j=1;j<=m;j++)
	//	cout<<" "<<f[i][j]<<" "<<l[i][j]<<" "<<h[i][j]<<" "<<v[i][j]<<endl;
	for (i=1;i<=q;i++)
	{
	scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
	ansf=f[x2][y2]-f[x2][y1-1]-f[x1-1][y2]+f[x1-1][y1-1];
	ansv=v[x2][y2]-v[x1][y2]-v[x2][y1]+v[x1][y1]+l[x2][y1]-l[x1][y1]+h[x1][y2]-h[x1][y1];
	printf("%d\n",ansf-ansv);	
	}
	return 0;
}

Measured memory_bytes: 80256
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

int N, K;
int R[5010], C[5010];
int A[10010], B[10010];
vector<int> G[5010];
int dis[5010][5010];

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

    cin >> N >> K;
    REP(i, N) cin >> R[i] >> C[i];
    REP(i, K) {
        cin >> A[i] >> B[i];
        --A[i]; --B[i];
        G[A[i]].push_back(B[i]);
        G[B[i]].push_back(A[i]);
    }
    memset(dis, 0x3f, sizeof(dis));
    dis[0][N + 1] = 0;
    using P = tuple<int, int, int>;
    priority_queue<P, vector<P>, greater<P>> que;
    que.emplace(0, 0, N + 1);
    while (!que.empty()) {
        int dd, v, c;
        tie(dd, v, c) = que.top();
        que.pop();
        if (dis[v][c] < dd) continue;
        if (c == N + 1) {
            if (dis[v][C[v]] > dis[v][c] + C[v]) {
                dis[v][C[v]] = dis[v][c] + R[v];
                que.emplace(dis[v][C[v]], v, C[v]);
            }
        } else if (c == 0) {
            if (dis[v][N + 1] > dis[v][c]) {
                dis[v][N + 1] = dis[v][c];
                que.emplace(dis[v][N + 1], v, N + 1);
            }
        } else if (c > 0) {
            for (int& nv : G[v]) {
                if (dis[nv][c - 1] > dis[v][c]) {
                    dis[nv][c - 1] = dis[v][c];
                    que.emplace(dis[nv][c - 1], nv, c - 1);
                }
            }
            if (dis[v][N + 1] > dis[v][c]) {
                dis[v][N + 1] = dis[v][c];
                que.emplace(dis[v][N + 1], v, N + 1);
            }
        }
    }
    cout << dis[N - 1][N + 1] << endl;
}


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

using namespace std;
long long a[220000];
long long sum[220000];
map<long long,int>t;
int main()
{
    int n;
    long long ans = 0;
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    cin>>a[0];
    sum[0] = a[0];
    t[sum[0]] = 1;
    if(sum[0]==0) ans++;
    for(int i=1;i<n;i++){
        cin>>a[i];
        sum[i] = sum[i-1] + a[i];
        if(sum[i]==0) ans++;
        if(t.find(sum[i])!=t.end()){
            ans += t[sum[i]];
            t[sum[i]] ++;
        }else t[sum[i]] = 1;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 15872
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        int ac = 0;
        int bc = 0;
        int cc = 0;

        for(int i = 0; i<s.length();i++){
            if(s.charAt(i)=='a'){
                ac++;
            }else if(s.charAt(i)=='b'){
                bc++;
            }else{
                cc++;
            }
        }

        if(ac ==1 && bc == 1 && cc == 1){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }

    }

}


Measured memory_bytes: 21972