akhauriyash/Code-Regression huggingface dataset:
//#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<iomanip>
#include<cmath>
#include<algorithm>
#include<vector>
#include<cstring>
#include<queue>
#include<map>
#include<string>
#include<stack>
#define fi first
#define se second
#define INF 0x3f3f3f3f
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pqueue priority_queue
#define NEW(a,b) memset(a,b,sizeof(a))
const double pi=4.0*atan(1.0);
const double e=exp(1.0);
const int maxn=1e5+8;
typedef long long LL;
typedef unsigned long long ULL;
const LL mod=1e9+7;
const ULL base=1e7+7;
using namespace std;
char s[5];
int main(){
    cin>>s;
    sort(s,s+4);
    if(s[0]==s[1]&&s[1]!=s[2]&&s[2]==s[3]){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}


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


int main() {
  int n;
  cin >> n;
  vector<int>a(n-1);
  vector<int>b(200200);
  int ans=0;
  rep(i,n-1){
    cin>>a.at(i);
    b.at(a.at(i))++;
  }
  rep2(i,1,n+1){
    cout<<b.at(i)<<endl;
  }
  
  
}







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

int main() {
	int n;
	cin>>n;
	string s;
	cin>>s;
	int cn=0;
	int v=0;
	for(int i=0;i<n;i++)
	{
	    if(s[i]=='R') cn++;
	    if(s[i]=='B') v++;
	    
	    
	}
	if(cn>v) cout<<"Yes"<<endl;
	    else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <queue>
#include <iomanip>

using namespace std;
int n, m, d;

int main() {
  cin >> n >> m >> d;
  double ans;

  if (n==1) {
    if (d==0) {
      cout << m-1 << endl;
      return 0;
    }
  }

  int s = 0;
  if (n-d < d+1 || d==0) {
    s = n;
  } else {
    s = n + ((n-d) - (d+1) + 1);
  }
  double base = (double)n*(double)n;
  double aa = (double)s*(double)(m-1);

  // cout << "aa: " << aa << endl;
  ans = aa/base;
  cout << setprecision(10) << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long LL;

LL n,k,ans = 0;

int main(){
	cin >> n >> k;
	while(n){
		ans ++;
		n /= k;
	}
	cout << ans << endl;
	return 0;
}
//

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(int argc, const char * argv[]) {
    string number;
    int sum=0; //合計値計算
    while(1){
        cin >> number;
        if (number[0] == '0') {
            break;
        }
    for ( int i = 0; i < number.size(); i++ ){ // 文字列の長さだけ繰り返す
        sum += number[i]-'0'; //ASCII code、数字に戻す
        //cout << number[i]; // char型配列と同じように扱う
    }
    cout << sum << endl;
        sum = 0;
    }
    return 0;
}


Measured memory_bytes: 3140
N = int(input())
A = list(map(int, input().split()))
ans = 1000
for i in range(len(A) - 1):
    stocks = 0
    if A[i] < A[i + 1]:
        stocks = ans // A[i]
        ans += (A[i + 1] - A[i]) * stocks
print(ans)

Measured memory_bytes: 9176
#include<bits/stdc++.h>
using namespace std;
const int M=1e5+10;
int n,m,H[M];
vector<int>g[M];
bool cv[M],mark[M];
vector<pair<int,int> >ans;
int dfs(int v,int par,int h)
{
  int up=h;
  mark[v]=true;
  H[v]=h;
  for(auto u:g[v])
    if(!mark[u])
      {
	int d=dfs(u,v,h+1);
	up=min(up,d);
	if(d>h)ans.push_back({min(u,v),max(u,v)});
      }
    else if(u!=par)
      up=min(up,H[u]);
  return up;
}
int main()
{
  cin>>n>>m;
  for(int i=0;i<m;i++)
    {
      int u,v;
      cin>>u>>v;
      u++,v++;
      g[u].push_back(v);
      g[v].push_back(u);
    }
  dfs(1,1,0);
  sort(ans.begin(),ans.end());
  for(auto p:ans)
    cout<<p.first-1<<" "<<p.second-1<<endl;
  return 0;
}

Measured memory_bytes: 7152
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<n;++i)
string s[1010];
int chy[10], chx[10]; //cheese
int d[1010][1010]; //min time
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
int h, w, n, ans;

void bfs(){
  REP(i,n){
    int sy = chy[i], sx = chx[i];
    int gy = chy[i+1], gx = chx[i+1];
    queue<int> qy, qx;
    
    qy.push(sy); qx.push(sx);
    REP(j,h) REP(k,w) d[j][k] = 1e9; //new check
    d[sy][sx] = 0; //first time

    while(!qy.empty()){
      int posy = qy.front(); qy.pop();
      int posx = qx.front(); qx.pop();
      if(posy == gy && posx == gx){
        ans += d[gy][gx];
        break;
      }
      REP(j,4){
        int y = posy + dy[j], x = posx + dx[j];
        if(y < 0 || h <= y || x < 0 || w <= x){ //not allowed range
          continue;
        }
        if(d[y][x] == 1e9 && s[y][x] != 'X'){
          d[y][x] = d[posy][posx] + 1; //previous time + 1
          qy.push(y); qx.push(x);
        }
      }
    }
  }
}
int main(){
  cin>>h>>w>>n;
  REP(i, h){
    cin>>s[i];
    
    REP(j, w){
      if(s[i][j] == 'S'){
        chy[0] = i;
        chx[0] = j;
      }else if('1' <= s[i][j] && s[i][j] <= '9'){
        chy[s[i][j] - '0'] = i;
        chx[s[i][j] - '0'] = j;
      }
    }
  }    
  bfs();
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 7956
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define lps(i,j,n) for(int i=j;i<n;i++)
#define fordebug int hoge;cin>>hoge;
#define DEKAI 1000000007;
#define INF (1LL<<60)
#define int long long
#define double long double
#define floot10 cout<<fixed<<setprecision(10)
#define Int long long

int min(int a,int b){
  if(a<b) return a;
  return b;
}
int max(int a,int b){
  if(a>b) return a;
  return b;
}

int gcd(Int a, Int b) {
  return b != 0 ? gcd(b, a % b) : a;
}
int lcm(Int a, Int b) {
  return a / gcd(a, b)*b;
}
// a x + b y = gcd(a, b)
int extgcd(Int a, Int b, Int &x, Int &y) {
  Int g = a; x = 1; y = 0;
  if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
  return g;
}

vector<int> g[100010];
int done[100010];



signed main(){
  int x,y,z;
  cin>>x>>y>>z;
  int ans=0;
  x-=(z*2+y);
  if(x<0)cout<<0<<endl;
  else{
    ans++;
    while(1){
      x-=y+z;
      if(x<0){
	cout<<ans<<endl;
	return 0;
      }
      ans++;
    }
  }
  return 0;
}
 


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef vector<int> vec1;
typedef vector<string> vec2;
typedef vector<double> vec3;

int main() {

  string s,t;
  cin >> s >> t;
  int n = s.size();
  for(int i = 0; i < n; i++) {
    if(s.at(i) == t.at(i)) {
      continue;
    } else {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;++i)
#define ocut cout
#define ouct cout
#define itn int

struct Union{
  vector<ll> par;
  Union(ll a){
  par=vector<ll>(a,-1);
  }
  ll find(ll a){
    if(par[a]<0){
      return a;
    }
    else{
      return par[a]=find(par[a]);
    }
  }
  bool same(ll a,ll b){
    return (find(a)==find(b));
  }
  ll size(ll a){
    return -par[find(a)];
  }
  void unite(ll a,ll b){
    ll c=find(a),d=find(b);
    if(c==d)
      return;
    if(size(c)<size(d)){
      swap(c,d);
    }
    par[c]+=par[d];
    par[d]=c;
  }
};
ll euclidean_gcd(ll a, ll b) {
  if(a < b) return euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
ll euclidean_lcm(ll a, ll b) {
  return a/euclidean_gcd(a,b)*b;
}

ll binary(ll bina){
    ll ans = 0;
    for (ll i = 0; bina>0 ; i++)
    {
        ans += bina%2;
        bina = bina/2;
    }
    return ans;
}
void revStr(char* str){
	int size = strlen(str);
	int i,j;
	char tmp = {0};
	
	for(i = 0, j = size - 1; i < size / 2; i++, j--){
		tmp = str[i];
		str[i] = str[j];
		str[j] = tmp;
	}
	return;	
}
int main(void){
  int n;
  cin >> n;
  if(n==1)cout << 0;
  else  cout << 1;
}

Measured memory_bytes: 3628
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 15;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

ll in[400050][2];
pii u[400050];
int rch[400050][2];
int getpos(int x) {
	return in[u[x].first][u[x].second];
}

bool chk[400050];
int main() {
	int N, i;
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%lld %lld", &in[i][0], &in[i][1]);
	for (i = 1; i <= N; i++) {
		u[i] = pii(i, 0);
		u[i + N] = pii(i, 1);
	}
	sort(u + 1, u + 2 * N + 1, [](pii a, pii b) {
		return in[a.first][a.second] < in[b.first][b.second];
	});
	for (i = 1; i <= 2 * N; i++) rch[u[i].first][u[i].second] = i;

	int mx2 = 1, tp;
	for (i = 2 * N; i >= 1; i--) {
		if (chk[u[i].first]) break;
		chk[u[i].first] = true;
	}
	tp = i;
	memset(chk, 0, sizeof(chk));

	chk[u[1].first] = true;
	mx2 = rch[u[1].first][1 ^ u[1].second];
	ll ans = LL_INF;
	for (i = 2; i <= 2*N; i++) {
		int mx1 = rch[u[i].first][1 ^ u[i].second];
		ans = min(ans, (ll)(getpos(max(mx1, tp)) - getpos(1)) * (getpos(2 * N) - getpos(i)));
		ans = min(ans, (ll)(getpos(2 * N) - getpos(1)) * (getpos(max(mx2, tp)) - getpos(i)));

		if (chk[u[i].first]) break;
		chk[u[i].first] = true;
		mx2 = max(mx2, rch[u[i].first][1 ^ u[i].second]);
	}
	return !printf("%lld\n", ans);
}

Measured memory_bytes: 10368
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

using namespace std;


int main()
{
	int n;
	cin >> n;
	int a[n]; 
	map <int, int> m;
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
		m[a[i]] = 1;
	}
	cout << m.size() << endl;
}



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

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

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define m0(x) memset(x, 0, sizeof(x))

int dx4[4] = {1, 0, -1, 0}, dy4[4] = {0, 1, 0, -1};

int main()
{
    ll n;
    cin >> n;
    ll ans = 0;
    for (ll i = 1; i <= n; i++)
    {
        ans+=i*(n/i)*(1+n/i)/2;
    }
    

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

Measured memory_bytes: 3628
#EDPC D

#dp[ i ][ sum_w ] := i-1 番目までの品物から重さが 
# sum_w以下となるときの、価値の総和の最大値

#dpのindexはややこしくなりがち

N,W=map(int,input().split())
w,v=[0],[0]#w,vのindexと品物の番号を合わせるため、頭に0を追加
def main():
  for _ in range(N):
      wi,vi=map(int,input().split())
      w.append(wi)
      v.append(vi)

  dp=[[0 for _ in range(W+1)] for _ in range(N+1)]


  for i in range(N):
      for sum_w in range(1,W+1):
          if sum_w-w[i+1]>=0:
              dp[i+1][sum_w]=max(dp[i][sum_w-w[i+1]]+v[i+1],dp[i][sum_w])
          else:
              dp[i+1][sum_w]=dp[i][sum_w]

  print(dp[N][W])
main()

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    int N; cin >> N;
    string S; cin >> S;
    string l;

    int cnt = 0;
    REP(i,N){
        if(cnt==0){
            if(S[i] == '(')cnt++;
            else l.push_back('(');
        }else if(cnt>0){
            if(S[i] == '(')cnt++;
            else cnt--;
        }
    }

    S = l+S;
    REP(i,cnt) S.push_back(')');
    cout << S << endl;
    return 0;
}

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

bool ismonth(string str){
  int v = stoi(str);
  return 1 <= v && v <= 12;
}

bool isyear(string str){
  return true;
}

int main(){
  string S; cin >> S;
  string former = S.substr(0, 2);
  string lator = S.substr(2, 2);

  bool former_ismonth = ismonth(former);
  bool lator_ismonth = ismonth(lator);

  if(former_ismonth && lator_ismonth){
    cout << "AMBIGUOUS" << endl;
  }else if(former_ismonth){
    cout << "MMYY" << endl;
  }else if(lator_ismonth){
    cout << "YYMM" << endl;
  }else{
    cout << "NA" << endl;
  }
}


Measured memory_bytes: 256
S = input()

ans = False
if S == 'keyence':
    ans = True
else:
    for i in range(len(S)):
        for j in range(i, len(S)):
            p1 = S[:i]
            b = S[i:j+1]
            p2 = S[j+1:]
            # print('--')
            # print(i, j)
            # print(p1, b, p2)
            # print(p1 + p2)
            if p1 + p2 == 'keyence':
                ans = True

if ans:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3060
#include<cstdio>
using namespace std;
int a[55];
int main()
{
	int n,k,x,min=0x7fffffff,tot=0,pos;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&x);
		if(tot<k)
		{
			a[++tot]=x;
			if(x<min)
			{
				pos=tot;
				min=x;
			}
			continue;
		}
		if(x<=min) continue;
		a[pos]=x;min=x;
		for(int i=1;i<=tot;i++)
		if(a[i]<min) {pos=i;min=a[i];}
	}
	int ans=0;
	for(int i=1;i<=k;i++) ans+=a[i];
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    string s;
    cin>>s;
    int a=INT_MAX,b=0;
    for(int i=0;i<s.length();i++){
        if(s[i]=='A')
            a=min(a,i);
        if(s[i]=='Z')
            b=max(b,i);
    }
    cout<<(b-a)+1<<endl;

    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define rdll(x) scanf("%lld",&x);
string str;
ll ans;
ll dp[205][15];
ll C[20][20];
ll calc(array<int,10>a){
	ll cc = 1;
	int zan = 0;
	rep(x,10){
		cc *= C[zan+a[x]][a[x]];
		zan += a[x];
	}
	return cc;
}
int main(){
	cin>>str;
	int sum = 0, n = str.size();
	ll M = 1;
	rep(i,n){
		sum += str[i]-'0';
		M *= (1+str[i]-'0');
	}
	dp[0][0] = 1;
	for(int j=0;j<n;j++){
		for(int i=0;i<150;i++){
			if(dp[i][j] == 0) continue;
			rep(x,10) dp[i+x][j+1] += dp[i][j];
		}
	}
	rep(i,20) rep(j,i+1) if(j==0||j==i)C[i][j]=1; else C[i][j]=C[i-1][j]+C[i-1][j-1];
	for(int S=0;S<sum;S++){
		ans += dp[S][n];
	}
	//sum ha equal
	int w = n+9;
	vector<pair<ll,array<int,10> > >hoge;
	rep(mask,(1<<w)){
		if(__builtin_popcount(mask) != 9) continue;
		int cur = 0;
		ll mul = 1;
		ll val = 1;
		int S = 0;
		array<int,10>num;
		rep(i,10) num[i] = 0;
		rep(i,w){
			if(((mask>>i)&1)){
				rep(u,cur){
					mul *= val;
					S += val-1;
				}
				num[val-1] = cur;
				val++;
				cur=0;
			}
			else cur++;
		}
		rep(u,cur){
			mul *= val;
			S += val-1;
		}
		if(S != sum) continue;
		if(mul > M) continue;
		num[val-1] = cur;
		hoge.pb(mp(mul,num));
	}
	vector<array<int,10> >same;
	for(int i=0;i<hoge.size();i++){
		if(hoge[i].fi > M) break;
		else if(hoge[i].fi < M){
			ll cc = 1;
			int zan = n;
			rep(x,10){
				cc *= C[zan][(hoge[i].sc)[x]];
				zan -= (hoge[i].sc)[x];
			}
			ans += cc;
		}
		else same.pb((hoge[i].sc));
	}
	for(int i=0;i<same.size();i++){
		array<int,10>zan = same[i];
		for(int j=0;j<str.size();j++){
			int x = str[j]-'0';
			for(int k=0;k<x;k++){
				if(zan[k] == 0) continue;
				zan[k]--;
				ans += calc(zan);
				zan[k]++;
			}
			if(zan[x] == 0) break;
			zan[x]--;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 4576
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
#include <string>
#include <ctype.h>
using namespace std;


int main()
{
   int n;
   cin>>n;
   if(n%2==0)
    cout<<n/2;
   else
    cout<<(n+1)/2;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int N,x,y,z;
	cin >> N;
	x = N/100;
	y = N/10 - 10*x;
	z = N %10;

	if(x == 7 || y == 7 || z == 7)
		cout << "\nYes";	
	else
		cout << "\nNo";

	return 0;
}

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

using namespace std;

#define pb push_back
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef pair <ll, ll> pi;

string x = "MARCH";
ll a[5], n, ans;
string inp;

int main() {
    fio;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> inp;
        for (int j = 0; j < 5; j++)
            if (inp[0] == x[j])
                a[j]++;
    }
    for (int i = 0; i < 5; i++)
        for (int j = i + 1; j < 5; j++)
            for (int k = j + 1; k < 5; k++)
                ans += a[i] * a[j] * a[k];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy[] = {0, 1, 1, 1, 0, -1, -1, -1};

vector<set<int>> frnd;
vector<set<int>> block;
vector<int> group;
vector<set<int>> groupNode;

void dfs(int node, int parentNode, int groupId){
    group[node] = groupId;
    groupNode[groupId].insert(node);
    for(int nextNode: frnd[node]){
        if (group[nextNode] != -1) continue;
        if (nextNode == parentNode) continue;
        dfs(nextNode, node, groupId);
    }
}

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

    frnd.resize(n);
    block.resize(n);
    group.resize(n, -1);

    rep(i,m){
        int a, b;
        cin >> a >> b;
        a--; b--;
        frnd[a].insert(b);
        frnd[b].insert(a);
    }

    rep(i,k){
        int a, b;
        cin >> a >> b;
        a--; b--;
        block[a].insert(b);
        block[b].insert(a);
    }

    groupNode.resize(n+1);
    int gropuId = 0;
    rep(i,n){
        if (group[i] == -1){
            dfs(i, -1, gropuId++);
        } 
    }

    rep(i,n){
        int id = group[i];
        int ans = groupNode[id].size() - frnd[i].size() - 1;
        for(int b : block[i]){
            if (groupNode[id].count(b) != 0) ans--;
        }
        cout << ans << " ";
    }
    cout << endl;
}

Measured memory_bytes: 42668
#include<iostream>
using namespace std;
int main(void){
  
  int N;
  
  cin >> N;
  
  int a[N];
  bool b[N];
  
  for(int i = 0; i < N; i++){
    cin >> a[i];
    b[i] = true;
  }
  
  int n = 1, count = 0;
  
  while(n != 2){
    n = a[n - 1];
    if(b[n - 1]){
      b[n - 1] = false;
    }else{
      n = -1;
      break;
    }
    count++;
  }
  
  if(n == 2){
    cout << count << endl;
  }else{
    cout << n << endl;
  }
  
  return 0;
}
    

Measured memory_bytes: 768
import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().split())
inl = lambda: list(map(int, input().split()))

h, n = inm()
a = sorted(inl(), reverse=True)
for i in a:
    h -= i
    if h <= 0:
        break
print("Yes" if h <= 0 else "No")

Measured memory_bytes: 19836
/*
sonu_verma1
*/
#include <bits/stdc++.h>
// For policy based data structure
/*#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> */
using namespace std;
/*using namespace __gnu_pbds; 
typedef tree<int, null_type, less<int>, rb_tree_tag, 
             tree_order_statistics_node_update> 
    new_data_set;*/
 
#define MD 1000000007
#define X first
#define Y second
#define pb push_back
#define debug(val, ch) cout <<val <<ch
#define FOR(i, st, en, ch) for(register int i = (st); i <= (en) ; i += (ch))
#define RFOR(i, st, en, ch) for(register int i = (st); i >= (en) ; i -= (ch))
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
 
typedef long long int ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<int, bool> pib;
typedef pair<bool, int> pbi;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
/*********************************************************************/

void test(int r)
{
	ll x,i,ans1;
	cin>>x;
	long double ans=100;
	for(i=1;;i++)
	{
		ans=ans+ans/100;
		ans1=ans;
		ans=ans1;
		// cout<<ans<<" ";
		if(ans>=x)
		{
			cout<<i;
			break;
		}
	}
}
/***********************************************************************/
int main()
{
	fast();
    int t=1,r;
    // cin>>t;
    for(r=1;r<=t;r++)
        test(r);
    return 0;
}

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

int main(){
    string s;
    while(1){
        cin >> s;
        if (s == "0") break;
		int sum = 0;
        for ( int i = 0; i < s.size(); i++){
			sum +=  s[i] - '0';
		}
		cout << sum << endl;
    }
}


Measured memory_bytes: 3168
# coding: utf-8
# Your code here!
n,d=map(int,input().split())
ans=0
a=[]
for i in range(n):
  e=list(map(int,input().split()))
  a.append(e)
a.sort()
for i in range(n):
  #print(a[i][0]**2+a[i][1]**2)
  if a[i][0]**2+a[i][1]**2<=d**2:
    ans+=1
print(ans)



Measured memory_bytes: 107736
#include <iostream>
#include <vector>
#include <algorithm>

int main(void){
	int num_veg,bag,price,sum_price;
	std::vector<int> price_veg;
	
	while(std::cin >> num_veg >> bag){
		if(num_veg == 0 && bag == 0) break;
		
		sum_price = 0;
		price_veg.clear();

		for(int i = 0; i < num_veg; ++i){
			std::cin >> price;
			price_veg.push_back(price);
		}

		//sort(greater)
		std::sort(price_veg.begin(), price_veg.end(), std::greater<int>());

		for(int j = 0; j < num_veg; ++j){
			if(j % bag != bag - 1) sum_price += price_veg[j];
		}

		std::cout << sum_price << std::endl;
	}
	return 0;
}

Measured memory_bytes: 1228
import java.io.*;
import java.util.Scanner;
import java.lang.*;

class Main{
	public static void main(String[] args){
		try{
			Scanner stdIn = new Scanner(System.in);
			while(true){
				String s = stdIn.nextLine();
				
				int l = s.length();
				int k = 0;
				for(int i = 0;i < l;i++){
					char a = s.charAt(i);
					int a2 = Character.getNumericValue(a);
					k += a2;
				}
				if(k == 0) break;
				System.out.print(k);
				System.out.println();
			}
		} catch(Exception e){
		}
	}
}			

Measured memory_bytes: 26540
#include<stdio.h>
#define NIL -1
int N[44];

int f(int n){
  int a;
  
  if(n == 0 || n == 1){
    N[n] = 1;
    return N[n];
  } 
  
  if(N[n] != NIL){
    return N[n];
  }

  a = f(n - 1) + f(n - 2);
  N[n] = a;
  return a;
}

int main(void){
  int i, n;
  
  scanf("%d",&n);
  
  for(i = 0; i <= n; i++){
    
    N[i] = NIL;
    
  }
  
  i = f(n);
  
  printf("%d\n",i);
  
  return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pb   push_back
#define T int time;        scanf("%d", &time); while(time--)
int main(){
   // T{
      string s;
      cin>>s;
      ll md=9;
      ll ans=0;
      for(ll i=0;i<s.size(); i++){
        ll save=s[i]-'0';
        ans+=save%md;
      }
      ans%=md;
      if(ans)cout<<"No"<<endl;
      else cout<<"Yes"<<endl;
 
}



Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    vector<ll> t(n + 1);
    vector<ll> s(n + 1);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        s[a[i]]++;
    }
    for (int i = 1; i <= n; i++) {
        t[i] = s[i];
        s[i] = s[i] * (s[i] - 1) / 2;
    }
    ll mx = accumulate(s.begin(), s.end(), 0LL);
    for (int k = 0; k < n; k++) {
        ll res = mx - s[a[k]];
        ll cnt = t[a[k]] - 1;
        res += cnt * (cnt - 1) / 2;
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 6656
using System;
using System.Collections.Generic;
using System.Linq;

namespace CSharpSample01
{
    
    class Program
    {

        

        static void Main(string[] args) 
        {
            string[] str = Console.ReadLine().Split(' ');
            int N = int.Parse(str[0]);
            int K = int.Parse(str[1]);
            int[] data = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            var dic = new Dictionary<int, int>();
            for(int i = 0; i < N; i++)
            {
                if (!dic.ContainsKey(data[i]))
                {
                    dic[data[i]] = 1;
                }
                else
                {
                    dic[data[i]]++;
                }
            }

            if(dic.Count <= K)
            {
                Console.WriteLine(0);
            }
            else
            {
                var dic_sort = dic.OrderBy(x => x.Value);               
                int k = dic.Count;
                int ans = 0;
                foreach(var s in dic_sort)
                {
                    ans += s.Value;
                    k--;
                    if(k <= K)
                    {
                        break;
                    }
                }
                Console.WriteLine(ans);
            }
            
        }
    }
}


Measured memory_bytes: 41680
#include<bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
ll MM = 1000000000; ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
int dh[4] = {-1, 0, 0, 1};
int dw[4] = {0, -1, 1, 0}; 
using P = pair<int, int>;
const double pi = acos(-1.0);

using Graph = vector<vector<ll>>;

int main(){
  int ma,mb,da,db;
  cin>>ma>>da>>mb>>db;
  if(ma!=mb)cout<<1<<endl;
  else cout<<0<<endl;
    
    
  return 0;
}


Measured memory_bytes: 3636
/**
*    created: 30.06.2020 14:00:18
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

// Template for ModInt
template <typename T> T pow(T a, long long n, T e = 1) {
    T ret = e;
    while (n) {if (n & 1) ret *= a; a *= a; n >>= 1;}
    return ret;
}

template <int mod> struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long x_) {if ((x = x_ % mod + mod) >= mod) x -= mod;}
    ModInt& operator+=(ModInt rhs) {if ((x += rhs.x) >= mod) x -= mod; return *this;}
    ModInt& operator-=(ModInt rhs) {if ((x -= rhs.x) < 0) x += mod; return *this;}
    ModInt& operator*=(ModInt rhs) {x = (unsigned long long)x * rhs.x % mod; return *this;}
    ModInt& operator/=(ModInt rhs) {x = (unsigned long long)x * rhs.inv().x % mod; return *this;}
    ModInt operator-() const {return -x < 0 ? mod - x : -x;}
    ModInt operator+(ModInt rhs) const {return ModInt(*this) += rhs;}
    ModInt operator-(ModInt rhs) const {return ModInt(*this) -= rhs;}
    ModInt operator*(ModInt rhs) const {return ModInt(*this) *= rhs;}
    ModInt operator/(ModInt rhs) const {return ModInt(*this) /= rhs;}
    bool operator==(ModInt rhs) const {return x == rhs.x;}
    bool operator!=(ModInt rhs) const {return x != rhs.x;}
    ModInt inv() const {return pow(*this, mod - 2);}
    friend ostream& operator<<(ostream& s, ModInt<mod> a) {s << a.x; return s;}
    friend istream& operator>>(istream& s, ModInt<mod>& a) {s >> a.x; return s;}
};

using mint = ModInt<MOD>;

// 素因数分解してmapに格納
map<int,int> mp;

void prime(int n) {
    if (n == 1) return;
    for (int i = 2; i*i<= n; i++) {
        if (n % i == 0) {
            prime(i);
            prime(n/i);
            return;
        }
    }
    mp[n]++;
    return;
}

signed main() {

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

    int n; cin >> n;
    rep2(i,1,n+1) prime(i);
    mint ans = 1;
    for (auto p : mp) ans *= p.second + 1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	int n;
	while(cin>>n)
	{
		cin>>s;
		n%=26;
		for(int i=0;i<s.size();i++)
		{
			if(s[i]+n>90)
			cout<<(char)(s[i]+n-26);
			else
			cout<<(char)(s[i]+n);
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int N;
    cin >> N;
    vector<int> A(N),B(N),C(N);
    rep(i,N) cin >> A[i];
    rep(i,N) cin >> B[i];
    rep(i,N) cin >> C[i];
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    sort(C.begin(),C.end());
    // 真ん中を決めて上下を二分探索
    ll ans = 0;
    rep(i,N){
        ll top = lower_bound(A.begin(),A.end(),B[i]) - A.begin();
        ll bottom = upper_bound(C.begin(),C.end(),B[i]) - C.begin();
        ans+=(top)*(N-bottom);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
#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;
//const int mod=998244353;
using P = pair<int,int>;
using Pll = pair<ll,ll>;
using ld=long double;
using V=vector<int>;
using Vl=vector<ll>;
using VV=vector<vector<int>>;
using VVl=vector<vector<ll>>;

// modint: mod 計算を int を扱うように扱える構造体
template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};
using mint = Fp<mod>;

int main(){
   int n;cin >>n;
   mint sum=0;
   mint si=0;
    for (int i = 0; i < n; ++i) {
        ll a;cin >>a;
        sum+=a;
        si+=(a*a);
    }
    mint ans=(sum*sum-si)/2;
    cout <<ans <<endl;
}



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

using namespace std;


int main() {
    set<char> s;
    int n;cin>>n;
    for (int i = 0; i < n; i++) {
        char c;cin>>c;
        s.insert(c);
    }
    if(s.size() == 3) {
        cout<<"Three"<<endl;
    } else cout<<"Four"<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cmath>
using namespace std;
int main(){
int n,t,k,ans=0;
  cin>>n>>t>>k;
  long double a[n],dif=10000000;
  for(int i=0;i<n;i++){
    int s;
    cin>>s;
    a[i]=t-s*0.006;
  }
  for(int i=0;i<n;i++){
    if(dif>abs(a[i]-k)){
      dif=abs(a[i]-k);
      ans=i+1;
  }
  }
  cout<<ans<<endl;
    return 0;
  }


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

using namespace std;


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int x;
    cin >> x;
    int cur = 100;
    int now = 0;
    while (cur < x) {
        cur += cur / 100;
        ++now;
    }
    cout << now;
    return 0;
}


Measured memory_bytes: 3648
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

int N;
ll H[100000];

int L[100000],R[100000];
stack<int> S;


int main(){

	scanf("%d",&N);
	for(int i = 0; i < N; i++)scanf("%lld",&H[i]);

	for(int i = 0; i < N; i++){
		while(S.empty() == false && H[S.top()] >= H[i])S.pop();
		if(S.empty()){
			L[i] = 0;
		}else{
			L[i] = S.top()+1;
		}
		S.push(i);
	}

	while(!S.empty())S.pop();

	for(int i = N-1; i >= 0; i--){
		while(S.empty() == false && H[S.top()] >= H[i])S.pop();
		if(S.empty()){
			R[i] = N-1;
		}else{
			R[i] = S.top()-1;
		}
		S.push(i);
	}

	ll ans = 0;
	for(int i = 0; i < N; i++)ans = max(ans,H[i]*(ll)(R[i]-L[i]+1));

	printf("%lld\n",ans);

	return 0;
}

Measured memory_bytes: 4932
#import numpy as np
#from numpy import*
#from scipy.sparse.csgraph import shortest_path #shortest_path(csgraph=graph) # dijkstra# floyd_warshall
#from scipy.sparse import csr_matrix
 
from collections import* #defaultdict Counter deque appendleft
from fractions import gcd
from functools import* #reduce
from itertools import* #permutations("AB",repeat=2) combinations("AB",2) product("AB",2) groupby accumulate
from operator import mul,itemgetter
from bisect import* #bisect_left bisect_right
from heapq import* #heapify heappop heappushpop
from math import factorial,pi
from copy import deepcopy
import sys
sys.setrecursionlimit(10**8)
#input=sys.stdin.readline  #危険！基本オフにしろ！
def divisor_enumetarion(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    
    return divisors
 
def main():
    n=int(input())
    x=[n//i+i for i in divisor_enumetarion(n)]
    print(min(x)-2)
    
    
    
    
    
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 5500
N = int(input())

total = 0
for i in range(N + 1):
	if i % 3 == 0 and i % 5 == 0:
		pass
	elif i % 3 == 0:
		pass
	elif i % 5 == 0:
		pass
	else:
		total += i
print(total)



Measured memory_bytes: 9160
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<iterator>
#include<math.h>
#include<cstring>
using namespace std;
void lets_play()

{

    int a,b,i;
    cin>>a>>b;
    if(a>=b)
    {
        for(i=1;i<=a;i++)
            cout<<b;
        cout<<endl;
    }
    else
    {
        for(i=1;i<=b;i++)
            cout<<a;
        cout<<endl;
    }
    }

int main()
{
        lets_play();

}


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

using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

int main(){
  int a, b, c;cin >> a >> b >> c;
  cout << min(min(a, b), c) << " " << max(max(a, b), c) << endl;
}


Measured memory_bytes: 3092
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
vector<int> dx = {-1, -1, -1, 0, 0, 1, 1, 1};
vector<int> dy = {-1, 0, 1, -1, 1, -1, 0, 1};

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

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
      assert(n < mod);
      fact[0] = 1;
      for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
      ifact[n] = fact[n].inv();
      for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
      if (k < 0 || k > n) return 0;
      return fact[n]*ifact[k]*ifact[n-k];
    }
  };

int main () {
    int k;
    string s;
    cin >> k >> s;
    int n = s.size();
    mint ans = 0;
    combination c(n+k);
    rep(i, k+1) {
        mint now = mint(26).pow(k-i);
        now *= mint(25).pow(i);
        now *= c(i+n-1, n-1);
        ans += now;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 35544
count = [0 for i in range(26)]
while True:
    try:
        s = input()
    except:
        break
    for i in range(len(s)):
        m = ord(s[i]) - ord("a")
        if(m >= 0 and m <= 26):
            count[m] += 1
        m = ord(s[i]) - ord("A")
        if(m >= 0 and m <= 26):
            count[m] += 1
for i in range(26):
    print(chr(i + ord("a")), ":", count[i])


Measured memory_bytes: 5568
def main():
    N, K, Q = map(int, input().split())
    A = [int(input()) for _ in range(Q)]
    
    A_dict = {}
    for a in A:
        if a in A_dict:
            A_dict[a] += 1
        else:
            A_dict[a] = 1
    
    for i in range(1, N+1):
        win = A_dict[i] if i in A_dict else 0
        if K - Q + win > 0:
            print('Yes')
        else:
            print('No')
main()

Measured memory_bytes: 16568
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M 1000000007
double dp[3002][3002];
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int main()
{
    IOS;
    int n; cin>>n;
    double prob[n+1];
    for(int i=1;i<=n;i++) cin>>prob[i];
    for(int j=2;j<=n;j++)
    {
        dp[1][j] = 0.0;
    }
    dp[0][0] = 1;
    for(int i=1;i<=n;i++)
    {
        dp[i][0] = dp[i-1][0]*(1-prob[i]);
    }
    dp[1][1] = prob[1];
    for(int i=2;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
             dp[i][j] = dp[i-1][j]*(1-prob[i]) + dp[i-1][j-1]*(prob[i]);
        }
    }
    /*for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=n;j++)
        {
             cout<<dp[i][j]<<" ";
        }
        cout<<endl;
    }*/
    double ans = 0;
    for(int j=n/2+1;j<=n;j++)
    {
        ans += dp[n][j];
    }
    cout<<setprecision(10)<<ans<<endl;
    return 0;
}

Measured memory_bytes: 70656
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,c,k,sum=0;
    cin >> a >> b >> c >> k;

    while(a>0 && k>0){
        sum += 1;
        a--; k--;
    }

    while(b>0 && k>0){
        b--; k--;
    }
  
    while(c>0 && k>0){
        sum -= 1;
        c--; k--;
    }
    cout << sum;
    return 0;
}


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

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

void dfs(vector<int> A){
    if(A.size() == N + 1){
        int tmp = 0;
        rep(i, Q){
            if(A.at(b.at(i)) - A.at(a.at(i)) == c.at(i)){
                tmp += d.at(i);
            }
        }
        ans = max(ans, tmp);
        return;
    }

    A.push_back(A.back());
    while(A.back() <= M){
        dfs(A);
        A.back()++;
    }
    return;
}

int main(){
    cin >> N >> M >> Q;
    rep(i, Q) cin >> a.at(i) >> b.at(i) >> c.at(i) >> d.at(i);
    vector<int> A(1,1);
    dfs(A);
    cout << ans << endl;
}

Measured memory_bytes: 3640
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  //d
  int n;
  cin >> n;
  vector<long long> in(n);
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    cin >> in[i];
    if (in[i] < 0) cnt++;
    in[i] = abs(in[i]);
  }
  cout <<  accumulate(in.begin(), in.end(), 0LL) - (cnt & 1 ? 2LL * *min_element(in.begin(), in.end()) : 0) << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
int main(void){
    int a, b, c, n, x, i;
    scanf("%d %d", &n, &x);
    
    
    while(n!=0 || x!=0){
        i=0;
        for(a=1; a<=n; a++){
            for(b=a+1; b<=n; b++){
                for(c=b+1; c<=n; c++){
                    if(a+b+c==x){
                        i++;
                    }
                }
            }
        }
        printf("%d\n", i);
        scanf("%d %d", &n, &x);
    }
    return 0;
    
}


Measured memory_bytes: 2056
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(p,a,b)    for(int p=a;p<b;p++)
#define INF 0x3f3f3f3f
#define N 100007


int main() {
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("o2.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    ll n,i,ans=0;
    map<ll,ll> m;

    cin>>n;
    vector<ll>h(n+1);
    for(i=1 ; i<=n ; i++)
    {
        cin>>h[i];
        m[i+h[i]]++;
    }

    for(i=1 ; i<=n ; i++)ans+=m[i-h[i]];
    cout<<ans;
    return 0;
}

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

int main(){
  
  int a,b;
  string s;
  cin >> a >> b >> s; 
  
  b--;
  
  if( s.at(b) == 'A' ){
    
    s.at(b) = 'a';
    
  }
  
  else if( s.at(b) == 'B' ){
    
    s.at(b) = 'b';
    
  }
  
  else if( s.at(b) == 'C' ){
    
    s.at(b) = 'c';
    
  }
  
    cout << s << endl;
  
}


Measured memory_bytes: 3592
#include<stdio.h>
int main(int argc, char const *argv[])
{
    long long int a,b,c,d,x,y,m;
    scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
    x=a;y=c;
    if(x>=a && x<=b && y>=c && y<=d)
    {
        m=x*y;
    }
    x=a;y=d;
    if(x>=a && x<=b && y>=c && y<=d)
    {
        if (m<x*y)
        {
           m=x*y;
        }
        
    }
    x=b;y=c;
    if(x>=a && x<=b && y>=c && y<=d)
    {
        if (m<x*y)
        {
           m=x*y;
        }
        
    }
    x=b;y=d;
    if(x>=a && x<=b && y>=c && y<=d)
    {
        if (m<x*y)
        {
           m=x*y;
        }
        
    }
    printf("%lld", m);
    return 0;
}


Measured memory_bytes: 1712
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>

using namespace std;

const int MAX = 110;

int data[MAX][MAX];
int rev = 0;

void make(string s){
  s+=',';
  int p = 0;
  int sum = 0;

  for(int i = 0; i < s.size(); i++){
    if(s[i] < '0' || s[i] > '9'){ 
      data[rev][p++] = sum;
      sum = 0;
    }else{
      sum *= 10;
      sum += s[i]-'0';
    }
  }
  rev++;
}

void solve(){
  for(int i = 0; i < rev/2; i++)
    for(int j = 0; data[i+1][j] != -1;j++)
      if(j-1>=0) data[i+1][j] += max(data[i][j],data[i][j-1]);
      else data[i+1][j] += data[i][j];


  for(int i = rev/2; i < rev; i++){
    for(int j = 0; data[i+1][j] != -1; j++)
      data[i+1][j] += max(data[i][j],data[i][j+1]);
  
  }
}


void print(){
  for(int i = 0; i < rev; i++){
    for(int j = 0; data[i][j] != -1; j++)
      cout << data[i][j] << " ";
    cout << endl;
  }

}
int main(){
  string in;
  memset(data,-1,sizeof(data));

  while(getline(cin,in)) make(in);
  solve();
  //print();
  cout << data[rev-1][0] << endl;
  return 0;
}

Measured memory_bytes: 1244
#include<bits/stdc++.h>
using namespace std;
double a[50+10]; 
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	double ssum=0.0;
	for(int i=1;i<n;i++){
		a[i]=(a[i]+a[i-1])/2.0;
		
		sort(a+i,a+n);
	}
	ssum = a[n-1];
	cout<<ssum<<endl;
	return 0;
}

Measured memory_bytes: 256