akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define lli long long int
using namespace std;
#define S second
#define F first
#define pb push_back
#define M1 1000000007
#define M2 998244353
#define pint pair<int,int>
#define setit set<int>::iterator seti
#define mapit map<int,int> ::iterator mapi
#define MP make_pair
#define MT make_tuple
#define PI 3.14159265358979323846
// map      iterator->first  iterator.first
// map      mp[key]=value
// set      *s.begin()
// vector   v[j]=value
// pair     p.first p.second
// vector of pairs v[j].first v[j].second
// tuple    get<index>(tuple_name)
// vector of tuples get<index>(v[j])  sort(v.begin(),v.end())
//priority queue .top() .pop() .push()
// __gcd(x,y)
#define mini(x,y) (y + ((x - y) & ((x - y) >>(sizeof(int) * CHAR_BIT - 1))))
#define maxi(x,y) (x - ((x - y) & ((x - y) >> (sizeof(int) * CHAR_BIT - 1))))
#define fr(j,a,b) for(j=a;j<b;j++)

int power(int x, unsigned int y, int p)
{   int res = 1;
    x = x % p;
    if (x == 0) return 0;
    while (y > 0)
    {   if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}

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

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


    int t, i, j, n,  x, a, b;
    cin>>a>>b;
    cout<<a*b;
}

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

#define int long long

using namespace std;

#ifdef LOCAL 
#include "/media/brayand/BrayanD/debugger.h"
#else
#define db(...) false
#define dbl(...) false
#define dbg(...) false
#endif

const int MAXN = 1e5 + 100;

bool mk[MAXN];

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

    int N, X, M;
    cin >> N >> X >> M;

    int cont = 0;

    int sum = 0;

    int pt = X;

    for(int i = 1 ; i <= min(N, M) ; i++)
    {
    	if(mk[pt])
    	{
    		break;
    	}

    	mk[pt] = true;

    	sum += pt;
    	cont++;

    	pt = pt*pt % M;
    }

    N -= cont;

    db(pt);
    db(sum);
    db(cont);

    for(int i = 0 ; i < MAXN ; i++)
    {
    	mk[i] = false;
    }

    int sumtemp = 0;
    cont = 0;

    for(int i = 1 ; ; i++)
    {
    	if(mk[pt])
    	{
    		break;
    	}

    	mk[pt] = true;

    	sumtemp += pt;
    	cont++;

    	pt = pt*pt % M;
    }

    sum += (N/cont)*sumtemp;

    N %= cont;

    for(int i = 0 ; i < MAXN ; i++)
    {
    	mk[i] = false;
    }

    for(int i = 1 ; i <= N; i++)
    {
    	if(mk[pt])
    	{
    		break;
    	}

    	mk[pt] = true;

    	sum += pt;

    	pt = pt*pt % M;
    }

    cout << sum << '\n';

    return 0;
}

Measured memory_bytes: 3748
#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 <math.h>
#include <cstdlib>
#define rep(i,n) for(int i = 0;i<(n);i++);
#define all(a) (a).begin(),(a).end()
using namespace std;
using ld = long double;
using ll = long long;
const ll INF = 100100100;
typedef pair<ll, ll> P;
ll gcd(ll a, ll b) {//a>b
	if (a < b)swap(a, b);
	if (a % b == 0) return b;
	else return gcd(b, a % b);
}
int main() {
	ll n;
	cin >> n;
	vector<ll> num(n);
	for (int i = 0; i < n; i++)cin >> num[i];
	vector<ll> ans(n);
	if (n % 2 == 0) {
		for (int i = 0; i < n; i++) {
			if (i % 2 == 0)ans[n / 2 + i / 2] = num[i];
			else ans[n / 2 - 1 - i / 2] = num[i];
		}
	}
	else {
		for (int i = 0; i < n; i++) {
			if (i % 2 == 0)ans[n / 2 - i / 2] = num[i];
			else ans[n / 2 + i / 2 + 1] = num[i];
		}
	}
	for (int i = 0; i < n; i++)cout << ans[i] << " ";
	cout << endl;
}

Measured memory_bytes: 5248
function main(input){
  const lines = input.split('\n');
  const N=parseInt(lines[0]);
  const Hs=lines[1].split(' ').map(x => parseInt(x));

  var result = 0;
  const highest = Math.max(...Hs);
  for(var j=1;j<=highest;j++){
    var previous_high = 0;
    for(var i=0;i<N;i++){
      var current_high = Hs[i];
      if(current_high>=j && previous_high<j){
        result++;
      }
      previous_high=current_high;
    }
  }

  console.log(result);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 9420
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);
//cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll inf=1000000000000000000;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
int main(){
    int n;cin>>n;
    int w[n];
    int sum=0;
    rep(i,0,n){
        cin>>w[i];
        sum+=w[i];
    }
    int ans=1000000000;
    int now=0;
    rep(i,0,n-1){
        now+=w[i];
        ans=min(ans,abs(now-(sum-now)));
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
//typedef long long ll;
int main(void){
  long long ans;
long long n,a,b;
  scanf("%lld%lld%lld",&n,&a,&b);
  if((a-b)%2==0){
    long long ave=(a+b)/2;
     ans=llabs(ave-a);
    
  }
  else{
   /* if(a>b){         //1<<<<||<<<<<<n
      				 //  b	    a	
      long long da=n-a;
      long long  db=b-1;
      if(da>db)  {   //1<<<<||<<<<<<n
        			//  b  a         aと1の距離が答え
      ans=a-1;}
      else         {       //   b a
      ans=n-b;}
  }*/
               //1<<<<||<<<<<<n
      				//    a    b
   long long  da=a-1;
   long long  db=n-b;
      if(da>db){ans=n-b+1;		//bが端まで行って1回分稼ぐ
                a+=ans;
                b=n;
                ans+=(a+b)/2-a;
               }
      else {  ans=a;
            b-=ans;
            a=1;
            ans+=(a+b)/2-a;
        }
    }
  
  printf("%lld",ans);
      
         
         return 0;
         }
     

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

string s;

int main(void){
    
    cin >> s;
    
    int ans = INT_MAX;
    for(int i = 0; i < s.size() - 1; ++i) if(s[i] != s[i + 1]) ans = min(ans, max(i + 1, (int)s.size() - i - 1)); 
	if(ans == INT_MAX) printf("%d\n", (int)s.size());
	else printf("%d\n", ans);
	
    return 0;
}


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

int main()
{
    int n,i;
    string s;
    cin>>n;
    cin>>s;
    if (s.size()<=n)
    cout<<s;
    else {
    for(i=0;i<n;i++){
    cout<<s[i];
    }
    cout<<"..."<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
    int n,a[100000],i,j,now = 1;

    scanf("%d",&n);
    for (i = 0; i < n; i++)
    {
        scanf("%d",&a[i]);
    }
    
    for (i = 0; i < n; i++)
    {
        now = a[now - 1];
        if(now == 2)break;
    }
    printf("%d",i == n ? -1 : i + 1);
}

Measured memory_bytes: 512
using System;
using System.Linq;
class GFG
{
    public static void Main()
    {
        //var input = Console.ReadLine().Split(' ');

        //var x = int.Parse(input[0]);
        //var a = int.Parse(input[1]);
        //var b = int.Parse(input[2]);

        var n = int.Parse(Console.ReadLine());
        // var ss = str.ToCharArray().OrderBy(x => x).ToArray();
        var s1 = Console.ReadLine();
        var s2 = Console.ReadLine();

        ColoringDominos(n, s1, s2);
    }

    static void ColoringDominos(int n, string s1, string s2)
    {

        long mod = 1000000007;
        int i = 0;
        long ans = 1;
        int start = 0;
        int partern = 0;
        if (s1[0] == s2[0])
        {
            ans = ans * 3;
            partern = 1;
            i = 1;
        }
        else
        {
            ans = ans * 6;
            partern = 2;
            i = 2;
        }

        while (i < n)
        {
            if (s1[i] == s2[i])
            {
                i++;
                if (partern == 1)
                {
                    ans = ans * 2;

                }
                else
                {
                    partern = 1;
                }
                ans = ans % mod;

            }
            else
            {
                i += 2;
                if (partern == 1)
                {
                    ans = ans * 2;
                    partern = 2;
                }
                else
                {
                    ans = ans * 3;
                }
                ans = ans % mod;
            }
        }
        Console.Write(ans);
    }



}




Measured memory_bytes: 13140
from itertools import combinations as cmb
bookN, algoN, score = map(int, input().split())

Books = []
for i in range(bookN):
  Book = list(map(int, input().split()))
  Books.append(Book)

money = 12 * 10 ** 5 + 1
for k in range(1, bookN +1):
  for books in cmb(Books, k):
    price_algo = [0] * (algoN +1)
    for book in books:
      for item in range(len(book)):
        price_algo[item] += book[item]
    for item_ in range(1, algoN +1):
      if price_algo[item_] < score:
        break
    else:
      if price_algo[0] < money:
        money = price_algo[0]

if money == 12 * 10 ** 5 + 1:
  money = -1
print(money)

Measured memory_bytes: 9076
#include <stdio.h>
int main(void){
    int i, len;
  char s[4096];
  for(;;) {
    int ans = 0;
    scanf("%s", s);
    len = strlen(s);
    for(i = 0; i < len; i++) {
       ans += s[i]-'0';
    }      if(ans==0)break;
    printf("%d\n",ans);
  }

  }



Measured memory_bytes: 2040
import  math

a = 3.0
b = 1.0
x = 8.0

inp = input().split()
a = int(inp[0])
b = int(inp[1])
x = int(inp[2])

if a*a*b/2 >= x:
    A = 2.0*x/(b*a)
    print(math.atan2(b, A)*180/math.pi)
else:
    x = a*a*b - x
    B = 2.0*x/(a*a)
    print(math.atan2(B, a)*180/math.pi)


Measured memory_bytes: 3060
#include<cstdio>
#include<queue>
#define mk make_pair
using namespace std;
typedef pair<int,int> pr;
const int N=200005;

int n,cnt;
int a[N],b[N];
long long ans;
priority_queue<pr>Q;
int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=n;i++) {
		scanf("%d",&b[i]);
		if(b[i]!=a[i])
			Q.push(mk(b[i],i));
	}
	b[0]=b[n]; b[n+1]=b[1];
	while(!Q.empty()) {
		pr now=Q.top(); Q.pop();
		int p=now.second;
		int dir=(b[p]-a[p])/(b[p-1]+b[p+1]);
		if(dir<=0) {
			printf("-1\n");
			return 0;
		}
		b[p]=b[p]-dir*(b[p-1]+b[p+1]);
		if(p==1) b[n+1]=b[p];
		if(p==n) b[0]=b[p];
		ans+=dir;
		if(b[p]!=a[p])
			Q.push(mk(b[p],p));
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
using vi=vector<ll>;
using vvi=vector<vi>;
using vp=vector<P>;
const ll inf=1001001001001001001;
const ll mod=1000000007;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}

int main(){
    ll n;cin>>n;
    vi dp(n,inf);
    priority_queue<P,vector<P>,greater<P>> pq;
    REP(i,1,10)if(chmin(dp[i%n],i))pq.emplace(dp[i%n],i);
    while(!pq.empty()){
        auto t=pq.top();pq.pop();
        if(dp[t.se]!=t.fi)continue;
        rep(i,10)if(chmin(dp[(t.se*10+i)%n],t.fi+i))pq.emplace(dp[(t.se*10+i)%n],(t.se*10+i)%n);
    }
    out(dp[0]);
}

Measured memory_bytes: 7152
#include <bits/stdc++.h>
#define rep(i,n) for (ll i=0; i<(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
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; }

int main(){
    string S; cin >> S;
    ll ans=0; //白と黒の境目の個数
    rep(i,S.size()-1) if (S[i]!=S[i+1]) ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
n, p = map(int, input().split())
s = input()
sum_count = 0
if p in {2, 5}:
    for right in range(n):
        if int(s[right]) % p == 0:
            sum_count += (right + 1)
else:
    modp_count = [0] * p
    modp_count[0] = 1
    subs_modp, pow = 0, 1
    for si in s[::-1]:
        subs_modp += ((int(si)*pow) % p)
        subs_modp %= p
        modp_count[subs_modp] += 1
        pow = (pow*10) % p
        
    for count in modp_count:
        sum_count += count*(count - 1) // 2
print(sum_count)

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

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

  int N, K;
  cin >> N >> K;
  vint T(N);
  rep(i, N) cin >> T[i];
  vint vec;
  rep(i, N-1) vec.push_back(T[i+1]-T[i]);
  sort(all(vec));
  int sum = N;
  rep(i, N-K) sum += vec[i]-1;
  cout << sum << endl;

  return 0;
}



Measured memory_bytes: 4636
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cmath>
#include <map>
using namespace std;

int main() {
  int64_t N, A, B;
  cin >> N >> A >> B;
  if (A>B) {
    cout << 0 << endl;
  }
  else {
    if (N!=1) {
      cout << (B-A)*(N-2)+1 << endl;
    }
    else {
      if (A!=B) {
        cout << 0 << endl;
      }
      else {
        cout << 1 << endl;
      }
    }
  }
}

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

int main(void) {

  char s[100001];
  scanf("%s", s);
  long length = strlen(s);
  for (long i = 1; i < length; i++) {
    if (s[i] == s[i-1]) {
      printf("%ld %ld\n", i, i+1);
      return 0;
    }
    if (i != 1 && s[i] == s[i-2]) {
      printf("%ld %ld\n", i-1, i+1);
      return 0;
    }
  }
  printf("-1 -1\n");

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string.h>
#include<math.h>
#include<cstring>
#include<algorithm>
using namespace std;
#define INF 10000000
int route[10][10],d[10],n,sum;
int min(int a,int b){
	if(a<b){
		return a;
	}else{
		return b;
	}
}
void dijkstra(int a){
	int s[10],k,num,i,j;
	sum=0;
	for(i=0;i<10;i++){
		s[i]=0;
		d[i]=INF;
	}
	d[a]=0;
	for(i=0;i<10;i++){
		k=INF;
		for(j=0;j<10;j++){
			if(s[j]==0){
				if(k>d[j]){
					k=d[j];num=j;
				}
			}
		}
		s[num]=1;
		for(j=0;j<10;j++){
			if(route[num][j]!=INF){
				d[j]=min(d[j],d[num]+route[num][j]);
			}
		}
	}
	
	for(i=0;i<10;i++){
		if(s[i]==1){
			sum+=d[i];
		}
	}
	if(sum==0)sum=INF;
	return;

}

int main(){
	while(1){
		int i,j,a,b,c,ans,min=INF;
		cin>>n;
		if(n==0)break;
		for(i=0;i<10;i++){
			for(j=0;j<10;j++){
				route[i][j]=INF;
			}
		}
		for(i=0;i<n;i++){
			cin>>a>>b>>c;
			route[a][b]=c;
			route[b][a]=c;
		}
		for(i=0;i<10;i++){
			dijkstra(i);
			if(sum<min){
				min=sum;ans=i;
			}
		}
		cout<<ans<<' '<<min<<endl;
	}
    return 0;
}

Measured memory_bytes: 1160
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>		//UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>		//do setprecision
#include <ctime>
#include <complex>
#include <chrono>
#include<unordered_map>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)
#define ALL(u) (u).begin(),(u).end()

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

typedef pair<int, int> PII;

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const LL inf = 1e18;

map<LL, LL> d;
LL go(LL N, int A, int B, int C, int D)
{
	LL res = inf;
	if (N*(__int128)D < res)
		res = N * D;
	if (!N)
		return 0;
	auto it = d.find(N);
	if (it != d.end())
		return it->second;

	auto K = { MP(2,A),MP(3,B),MP(5,C) };
	for (const auto &p : K)
	{
		{
			LL v = N / p.first;
			auto tmp = go(v, A, B, C, D);
			res = min(res, D*(N%p.first) + p.second + tmp);
		}
		{
			LL v = N / p.first + (N % p.first ? 1 : 0);
			if (v == N || v == N / p.first)
				continue;
			auto tmp = go(v, A, B, C, D);
			res = min(res, D*(p.first - N % p.first) + p.second + tmp);
		}
	}

	return d[N] = res;
}

int main()
{
	int T;
	scanf("%d", &T);
	REP(xxx, T)
	{
		LL N;
		int A, B, C, D;
		scanf("%lld%d%d%d%d", &N, &A, &B, &C, &D);

		printf("%lld\n", go(N, A, B, C, D));
		d.clear();
	}

	return 0;
}

// FOR GNU C++ use the following pattern:
// Uncomment the code below and change your main into main2
// It does not build in MS C++
// But it does increase the stack size from 256 MB on CF and uses GNU C++

//#include <Processthreadsapi.h>
//#include <iostream>
//#include <Synchapi.h>
//#include <windows.h>
//#include <process.h>
//
//DWORD WINAPI MyThreadFunction(LPVOID lpParam) {
//    main2(nullptr);
//    return 0;
//}
//int main() {
//    auto h = CreateThread(nullptr, 1024 << 20, MyThreadFunction, nullptr, STACK_SIZE_PARAM_IS_A_RESERVATION, nullptr);
//    WaitForSingleObject(h, INFINITE);
//}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
#define maxn 17

using namespace std;

typedef long long ll;

int n;
int x[maxn], y[maxn], p[maxn];
int xx[maxn], yy[maxn];
int xxx[1 << maxn][maxn], yyy[1 << maxn][maxn];
ll ans[maxn];

int a[maxn], b[maxn];
int mn = maxn;

inline bool cmp1(int i, int j){
	return x[i] < x[j];
}

inline bool cmp2(int i, int j){
	return y[i] < y[j];
}

int main(){
	scanf("%d", &n);
	for(register int i = 1;i <= n;i++) scanf("%d%d%d", &x[i], &y[i], &p[i]), xx[i] = i, yy[i] = i;
	sort(xx + 1, xx + 1 + n, cmp1);
	sort(yy + 1, yy + 1 + n, cmp2);
	for(register int i = (1 << n) - 1;~i;i--){
		for(register int j = 1;j <= n;j++){
			if(!(i & (1 << (j - 1)))) xxx[i][j] = yyy[i][j] = min(abs(x[j]), abs(y[j]));
		}
		int k = 0;
		for(register int j = 1;j <= n;j++){
			if(i & (1 << (xx[j] - 1))) k = j;
			else if(k) xxx[i][xx[j]] = min(xxx[i][xx[j]], x[xx[j]] - x[xx[k]]);
		}
		k = 0;
		for(register int j = n;j;j--){
			if(i & (1 << (xx[j] - 1))) k = j;
			else if(k) xxx[i][xx[j]] = min(xxx[i][xx[j]], x[xx[k]] - x[xx[j]]);
		}
		k = 0;
		for(register int j = 1;j <= n;j++){
			if(i & (1 << (yy[j] - 1))) k = j;
			else if(k) yyy[i][yy[j]] = min(yyy[i][yy[j]], y[yy[j]] - y[yy[k]]);
		}
		k = 0;
		for(register int j = n;j;j--){
			if(i & (1 << (yy[j] - 1))) k = j;
			else if(k) yyy[i][yy[j]] = min(yyy[i][yy[j]], y[yy[k]] - y[yy[j]]);
		}
	}
	int sup = (int)pow(3, n) - 1;
	memset(ans, 0x3f, sizeof(ans));
	for(register int i = 0;i <= sup;i++){
		memset(a, 0, sizeof(a));
		register int cnt = 0, xbit = 0, ybit = 0;
		for(register int j = i, k = 1;j;k++){
			a[k] = j % 3, j /= 3;
			if(a[k] == 1) xbit += 1 << (k - 1), cnt++;
			else if(a[k] == 2) ybit += 1 << (k - 1), cnt++;
		}
		if(cnt >= mn){
			ans[cnt] = 0;
			continue;
		}
		/*for(register int j = 1;j <= n;j++){
			if(!a[j]) b[j] = min(abs(x[j]), abs(y[j]));
			//else b[j] = 0;
		}
		int k = 0;
		for(register int j = 1;j <= n;j++){
			if(a[xx[j]] == 1) k = j;
			else if(!a[xx[j]] && k) b[xx[j]] = min(b[xx[j]], x[xx[j]] - x[xx[k]]);
		}
		k = 0;
		for(register int j = n;j;j--){
			if(a[xx[j]] == 1) k = j;
			else if(!a[xx[j]] && k) b[xx[j]] = min(b[xx[j]], x[xx[k]] - x[xx[j]]);
		}
		k = 0;
		for(register int j = 1;j <= n;j++){
			if(a[yy[j]] == 2) k = j;
			else if(!a[yy[j]] && k) b[yy[j]] = min(b[yy[j]], y[yy[j]] - y[yy[k]]);
		}
		k = 0;
		for(register int j = n;j;j--){
			if(a[yy[j]] == 2) k = j;
			else if(!a[yy[j]] && k) b[yy[j]] = min(b[yy[j]], y[yy[k]] - y[yy[j]]);
		}*/
		register ll sum = 0;
		for(register int j = 1;j <= n;j++) if(!a[j]) sum += 1ll * p[j] * min(xxx[xbit][j], yyy[ybit][j]);
		ans[cnt] = min(ans[cnt], sum);
		if(ans[cnt] == 0) mn = min(mn, cnt);
	}
	for(register int i = 0;i <= n;i++) printf("%lld\n", ans[i]);
}

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

long long i,j,sum[1000005],total,n;
bool a[1000005];


int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	
	for(i=2; i<1000000; i++){
//		cout<<i<<'\n';
		if(a[i]==false){
			j=i*i;
			while(j<1000000){
				a[j]=true;
				j+=i;
			}
		}
	}
	
	a[1]=true;
	total=0;
	for(i=1; i<1000000; i++){
		if(a[i]==false){
			total++;
		}
		sum[i]=total;
	}
	while(cin>>n){
		cout<<sum[n]<<'\n';
	}
	
return 0;
}

Measured memory_bytes: 11832
N, Q = map(int, input().split())
S = input()
t= [0]*(N+1)
for i in range(N):
  t[i+1] = t[i] +(1 if S[i:i+2]=='AC' else 0)
for i in range(Q):
  l, r = map(int, input().split())
  print(t[r-1]-t[l-1])


Measured memory_bytes: 51032
#include<bits/stdc++.h>
#define endl '\n'
#define mod 1000000007
typedef long long int ll;
using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    while(t--){
	    int n;
	    cin>>n;
	    int x = ceil((float)n/1000);
	    //cout<<x<<endl;
	    cout<<((x*1000) - n);

    
    }
    return 0;
} 


Measured memory_bytes: 3644
#include <algorithm>
#include <string>
#include <iostream>

using namespace std;

int main() {
    string sN;
    cin >> sN;

    unsigned long long N = stoull(sN);
    unsigned long long sumN = 0;
    for (unsigned long long i = 0; i < sN.length(); i++) {
        sumN += stoull(sN.substr(i, 1));
    }

    cout << (N % sumN == 0 ? "Yes" : "No") << 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 rep2(i, m, n) for(int i = (int)m; i < (int)n; i++)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;

int n, m, i, input_a;
/*FUNCs=================================================*/


/*MAIN==================================================*/
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化

    cin >> n >> m;
    set<int> a;
    rep(i, m){
        cin >> input_a;
        a.insert(input_a);
    }
    vi walk(n + 1);                  // 1-origin DP-table

    for(int i = 1; i < n + 1; i++){
        if(a.find(i) != a.end())  walk[i] = 0; // you can't step on ,so 'walk[i] == 0'
        else{
            if(i == 1) walk[i] = 1;
            else if(i == 2) walk[i] = walk[1] + 1;
            else walk[i] = (walk[i-1] + walk[i-2]) % 1000000007;
        }
    }
    cout << walk[n] << '\n';
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n;
    cin >> n;
    vector<queue<int32>> quev(n);
    REP(i,n){
        REP(j,n-1){
            int32 a;
            cin >> a;
            quev[i].push(a-1);
        }
    }
    int32 d = 0;
    while(true){
        bool fin = true;
        bool match = false; //試合が行われたかどうか
        vector<bool> tired(n, false);
        REP(i,n){
            if(quev[i].empty())continue;
            fin = false;
            int32 enemy = quev[i].front();
            if(quev[enemy].front() == i && !tired[i] && !tired[enemy]){
                quev[i].pop();
                quev[enemy].pop();
                match = true;
                tired[i] = true;
                tired[enemy] = true;
            }
        }
        if(fin)break;
        if(!match){
            cout << -1 << endl;
            return 0;
        }
        d++;
    }
    ANS(d);
    return 0;
}

Measured memory_bytes: 11008
# 75数を列挙して、N!を割り切れるかどうかで判定
from math import factorial, sqrt


def comb(n, r):  # n個からr個選ぶ場合の数
    if n < r:
        return 0
    else:
        return factorial(n)//(factorial(r) * factorial(n-r))


N = int(input())
fact = [0]*(N+1)
# それぞれを素因数分解
for i in range(2, N + 1):
    for j in range(2, i+1):
        while i % j == 0:
            i //= j
            fact[j] += 1
over4 = 0
over2 = 0
over24 = 0
over14 = 0
over74 = 0
for f in fact:
    if f >= 2:
        if f >= 4:
            over4 += 1
            if f >= 14:
                over14 += 1
            if f >= 24:
                over24 += 1
            if f >= 74:
                over74 += 1
        else:
            over2 += 1
ans = (comb(over4, 2) * over2) + comb(over4, 3) * 3 + \
    (over14) * (over4 - 1) + over24 * ((over4 - 1) + (over2)) + over74

print(ans)


Measured memory_bytes: 38512
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<ll>())
#define vfind(v, target) find(v.begin(), v.end(), target)
#define notFound(v, target) (vfind(v, target) == v.end())
#define ll long long
#define rep(i, s, g) for (ll i = (s); i < (g); i++)
#define MOD 1000000007
using namespace std;

int main()
{
  ll n, left, right; cin >> n;
  vector<ll> a(n);
  vector<double> diff(n);
  rep(i, 0, n) cin >> a[i];
  rvsort(a);
  cout << a[0] << " ";
  double mid = a[0] / 2.0;
  rep(i, 1, n) {
  	diff[i] = abs(mid - a[i]);
  }
  cout << a[min_element(diff.begin() + 1, diff.end()) - diff.begin()] << endl;
}

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

short dp[3003][3003];
int main() {
  string s, t;
  cin >> s >> t;
  int ss, ts;
  ss = s.size();
  ts = t.size();
//  int dp[ss+1][ts+1];
  rep(i, ts+1) dp[0][i] = 0;
  rep(i, ss+1) dp[i][0] = 0;
  rep(i, ss) {
    rep(j, ts) {
      if ((s[i] == t[j]) && (dp[i][j] == dp[i][j+1]) && (dp[i][j] == dp[i+1][j])) {
        dp[i+1][j+1] = dp[i][j] + 1;
      } else {
        dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
      }
    }
  }
  if (dp[ss][ts] == 0) cout << "" << endl;
  else {
    string ans = "";
    for (int i = ss, j = ts; (i > 0) && (j > 0);) {
//      cout << ss-si << "," << ts-ti << endl;
      if (dp[i][j] == dp[i-1][j]) i--;
      else if (dp[i][j] == dp[i][j-1]) j--;
      else {ans = t[j-1] + ans; i--; j--;}
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 17920
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>

using namespace std;

typedef long long ll;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n) REP(i,0,n)

bool attend[40];
void solve(){

}
int main(){
  fill(attend, attend+31,false);
  for(int i=0;i<28;i++){
    int x;
    cin >> x;
    attend[x]=true;
  }
  for(int i=1;i<31;i++){
    if(!attend[i]){
      cout << i <<endl;
    }
  }
    
  return 0;
}

Measured memory_bytes: 0
from sys import stdin
from fractions import gcd
def main():
    #入力
    readline=stdin.readline
    N=int(readline())
    A=list(map(int,readline().split()))

    for i in range(N-1):
        if i==0:
            g=gcd(A[i],A[i+1])
        else:
            g=gcd(g,A[i+1])
        if g==1:
            print(1)
            break
    else:
        print(g)

if __name__=="__main__":
    main()

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

using namespace std;

int cdiv(int a, int b){
  return (a+b-1)/b;
}

int main(){
 int n, d; cin >> n >> d;
 d = 2*d + 1;
 cout << cdiv(n, d) << "\n";
 return 0; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
ll a[10000000], d[10000000];

signed main() {

    ll i, j, k, l, n, b, c, test;
    cin >> n >> k;
    
    for (i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n, greater<ll>());
    ll sum = 0;
    for (i = k; i < n; i++) sum += a[i];
    cout << sum;
}

Measured memory_bytes: 2432
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {

            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }






        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);


            var abc = Reads();
            var a = abc.Max();
            var b = abc.Min();
            var c = abc.Sum()-a-b;

            if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) Console.WriteLine(0);
            else Console.WriteLine(b * c);



                Console.Out.Flush();
        }
    }
}




Measured memory_bytes: 13396
from collections import Counter

def main():
    N = int(input())
    As = list(map(int,input().split()))
    Cntr = Counter(As)

    ans0 = 0
    for i in Cntr:
        n = Cntr[i]
        ans0 += n*(n-1)//2
    
    for ai in As:
        ni = Cntr[ai]
        print(ans0-ni+1)

    return

if __name__ == "__main__":
    main()

Measured memory_bytes: 26780
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
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; }



int main() {
    int n; ll k; cin >> n >> k;
    vector<int> A(n);
    rep(i, n) cin >> A[i], A[i]--;

    vector<int> first_visited(200200, -1); //その町に最初に訪れた時にテレポーターを使った回数
    first_visited[0] = 0;
    vector<int> pass; pass.push_back(0); //同じ町に二度訪れるまでの経路

    //ループが始まるまでの経路を作成
    //rp:　pass内の閉路の長さ 　nrp: 閉路でない経路の長さ  cur: 現在地
    int rp = 0, nrp = 0, cur = 0; 
    for(int cnt=1; cnt<=k; cnt++){
        int to = A[cur]; 
        if(first_visited[to] == -1){ //次の街をまだ訪れていない場合は経路を追加してそこに移動する
            pass.push_back(to);
            first_visited[to] = cnt;
            cur = to;
        }else{ //同じ町を二度訪れる場合はループ終了 
            rp = cnt - first_visited[to];
            nrp = pass.size() - rp;
            break;
        }
    }
    if(rp == 0) rp = pass.size(); //閉路を見つける前にループが終わった場合の処理

    int ans = nrp + (k - nrp) % rp;
    cout << pass[ans] + 1 << ln;
}


Measured memory_bytes: 5748
def getN():
    return int(input())


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


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

n = getN()

varn = 0
for i in range(1000):
    if n == (i*(i-1))/2:
        varn = i
        break

if varn == 0:
    print("No")

vars = [[] for n in range(varn)]
k = 1
for i in range(varn):
    for j in range(i+1,varn):
        vars[i].append(k)
        vars[j].append(k)
        k += 1

if varn != 0:
    print("Yes")
    print(varn)
    for i in range(varn):
        print(varn-1, " ".join(map(str, vars[i])))


Measured memory_bytes: 9076
#include<bits/stdc++.h>
#define int int64_t
using namespace std;
void print(const vector<int>&xs){
  for(auto&x:xs)cout<<x<<',';
  cout<<endl;
}
int N,K;
vector<int>x,n,cost;
main(){
  cin>>N>>K;
  x=n=cost=vector<int>(N+1,0x3f3f3f3f3f3f3f3f);
  for(int i=1;i<=N;++i)cin>>x[i];
  int n_count=0;
  for(int i=1;i<=N;++i){
    if(x[i]<0)continue;
    n[i]=++n_count;
  }
  n_count=0;
  for(int i=N;i>=1;--i){
    if(x[i]>0)continue;
    n[i]=++n_count;
  }
  for(int i=1;i<=N;++i){
    int right=i+K-1;
    if(right>N)break;
    if(n[i]>K)continue;
    if(n[right]>K)continue;
    int cost_left=0;
    if(x[i]<0)cost_left=abs(x[i]);
    int cost_right=0;
    if(x[right]>0)cost_right=x[right];
    int cost_lr=2*cost_left+1*cost_right;
    int cost_rl=1*cost_left+2*cost_right;
    cost[i]=min(cost_lr,cost_rl);
  }
  cout<<*min_element(cost.begin(),cost.end())<<endl;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
char in[120];
pair<pair<string,int>,int> p[110];
int main(){
int a;scanf("%d",&a);
for(int i=0;i<a;i++){
int t;scanf("%s%d",in,&t);
string tmp=in;
p[i]=make_pair(make_pair(in,-t),i);
}
std::sort(p,p+a);
for(int i=0;i<a;i++)printf("%d\n",p[i].second+1);
}

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

#define rep(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a);i>(b);i--)
#define all(a) (a).begin(),(a).end()
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

main(){
  int h,w; cin >> h >> w;
  vs s(h); rep(i,h) cin >> s[i];
  int dx[8]={1,0,-1,0,1,-1,-1,1};
  int dy[8]={0,1,0,-1,1,1,-1,-1};
  int x,y;
  int count;

  rep(i,h) rep(j,w){
    if(s[i][j]=='#') continue;
    count = 0;
    rep(k,8){
      x = j + dx[k];
      y = i + dy[k];
      //cout << x << " " << y << endl;
      if(x<0 || w<=x) continue;
      if(y<0 || h<=y) continue;
      if(s[y][x]=='#') count++;
    }
    //cout << count << endl;
    s[i][j]=(char)(count+'0');
  }
  rep(i,h) cout << s[i] << endl;;
}


Measured memory_bytes: 256
#include<vector>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#define rep(i,x,y) for(int i=x;i<=y;++i)

const int INF=1<<30;
using namespace std;

const int maxn=100000+10;

int p[maxn];
int findset(int x){return p[x]==x?x:p[x]=findset(p[x]);}
int merge(int a,int b)
{
	a=findset(a);b=findset(b);
	if(a==b) return 0;
	p[a]=b;return 1;
}

struct Edge{
	int u,v,w;
	Edge(int u=0,int v=0,int w=0):u(u),v(v),w(w){}
	inline bool operator < (const Edge &rhs)const{
		return w<rhs.w;
	}
};

int idx[maxn],idy[maxn],x[maxn],y[maxn];

bool cmpx(int a,int b){return x[a]<x[b];}
bool cmpy(int a,int b){return y[a]<y[b];}

vector<Edge>e;

int main()
{
	int n;cin>>n;
	rep(i,1,n) scanf("%d%d",x+i,y+i),idx[i]=idy[i]=i;
	sort(idx+1,idx+n+1,cmpx);
	sort(idy+1,idy+n+1,cmpy);

	rep(i,1,n-1)
	{
		e.push_back(Edge(idx[i],idx[i+1],x[idx[i+1]]-x[idx[i]]));
		e.push_back(Edge(idy[i],idy[i+1],y[idy[i+1]]-y[idy[i]]));
	}

	sort(e.begin(),e.end());

	rep(i,1,n) p[i]=i;

	int cnt=0;long long cost=0;
	for(int i=0;i<(int)e.size();++i)
	{
	//	printf("(%d,%d,%d)\n",e[i].u,e[i].v,e[i].w);
		if(merge(e[i].u,e[i].v))
		{
			cost+=e[i].w;
			if(--cnt==1) break;
		}
	}

	cout<<cost<<endl;
	return 0;
}


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

using namespace std;

int main()
{
   int x,y;
   cin>>x>>y;
   for(int i=0;i<=x;++i)
   {
      int j=x-i;
      if(2*i+4*j==y)
      {
         puts("Yes");
         return 0; 
      } 
   } 
   puts("No");
}


Measured memory_bytes: 3624
def union(parent,size,a,b):
    x=find(parent,a)
    y=find(parent,b)
    if x!=y:
        if size[x]<size[y]:
            parent[x]=y 
            size[y]=size[x]+size[y]
        else:
            parent[y]=x 
            size[x]=size[x]+size[y]
    return parent,size 
def find(parent, a):
    while a != parent[a]:
            parent[a]=parent[parent[a]]
            a=parent[a]
    return a
n,k,l=map(int,input().split())
parent=[i for i in range(n)]
size=[1]*n
for i in range(k): 
    a,b=map(int,input().split())
    a-=1 
    b-=1 
    parent,size=union(parent,size,a,b)
parent2=[i for i in range(n)]
size2=[1]*n  
for i in range(l): 
    a,b=map(int,input().split())
    a-=1 
    b-=1 
    parent2,size2=union(parent2,size2,a,b)
from collections import defaultdict 
d=defaultdict(int)
for i in range(n):
    d[(find(parent,i),find(parent2,i))]+=1 
for i in range(n):
    a,b=find(parent,i),find(parent2,i)
    print(d[a,b],end=' ')

Measured memory_bytes: 56076
#include <iostream>
#include <cmath>

using namespace std;

int main(){
 int flag=1,j,N,temp,c=0;
 cin >> N;
 int A[N];
 for (j=0;j<N;++j){
   cin >> A[j];
 }
 while(flag) {
   flag=0;
   for (j=N-1;j>0;--j){
     if (A[j]<A[j-1]) {
       temp=A[j];
       A[j]=A[j-1];
       A[j-1]=temp;
      flag=1;
      c++;
     }
   }
 }
 for (j=0;j<N;++j){
   cout << A[j];
   if (j<N-1) {
     cout << " ";
   } else {
     cout << endl;
   }
 }
 cout << c << endl;
 return 0;
}



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

int main (void){
  int n;
  cin >> n;
  int odd =0;
  for(int i = 1; i < n + 1; i++){
    if(i % 2 != 0){
      odd++;
    }
  }
  cout << static_cast<double>(odd) / static_cast<double>(n);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll r[10],c[10];
ll cntr[(1<<10)],cntc[(1<<10)];
string s[10];
bool rr[10],cc[10];
int main() {
    ll H,W,K;
    cin>>H>>W>>K;
    for(ll i=0;i<H;i++) cin>>s[i];
    ll sum=0;
    for(ll i=0;i<H;i++){
        for(ll j=0;j<W;j++){
            if(s[i][j]=='#'){
                sum++;
            }
        }
    }
    for(ll i=0;i<H;i++) {
        for (ll j = 0; j < W; j++) {
            if (s[i][j] == '#') {
                r[i]++;
            }
        }
    }
    for(ll i=0;i<W;i++){
        for(ll j=0;j<H;j++){
            if(s[j][i]=='#'){
                c[i]++;
            }
        }
    }
    ll limitr=(1<<H);
    for(ll i=0;i<limitr;i++){
        ll temp=i,now=0,k=0;
        while(temp){
            if(temp&1){
                now+=r[k];
            }
            k++;
            temp>>=1;
        }
        cntr[i]=now;
    }
    ll limitc=(1<<W);
    for(ll i=0;i<limitc;i++){
        ll temp=i,now=0,k=0;
        while(temp){
            if(temp&1){
                now+=c[k];
            }
            k++;
            temp>>=1;
        }
        cntc[i]=now;
    }
    ll ans=0;
    for(ll i=0;i<limitr;i++){
        for(ll j=0;j<limitc;j++){
            memset(cc,0,sizeof(cc));
            memset(rr,0,sizeof(rr));
            ll temp=i,k=0;
            while(temp){
                if(temp&1)  rr[k]=1;
                k++;
                temp>>=1;
            }
            temp=j,k=0;
            while(temp){
                if(temp&1)  cc[k]=1;
                k++;
                temp>>=1;
            }
            ll cnt=0;
            for(ll t=0;t<H;t++){
                if(rr[t]){
                    for(ll k=0;k<W;k++){
                        if(cc[k]){
                            if(s[t][k]=='#'){
                                cnt++;
                            }
                        }
                    }
                }
            }
            if(sum-cntr[i]-cntc[j]+cnt==K)  ans++;
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;
const long double EPS = 0.0000000001;
const long double PI = (acos(-1));
const ll MOD = 1e9 + 7;

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")


int main() {

    ll n,m; cin >> n >> m;
    ll ans = 0,count = 0;
    ll a,b;
    vector<vector<ll>> g(n+1);
    queue<ll> d;


    vector<bool>f(n+1,false);

    rep(i,m) {
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    for(ll i = 1; i <= n; i ++){
        count = 0;
        if(!f[i]){
            f[i] = true;

            d.push(i);
            count ++;
            while(!d.empty()){
                ll t = d.front();
                d.pop();
                rep(j,g[t].size()){
                    if(!f[g[t][j]]){
                        f[g[t][j]] = true;
                        d.push(g[t][j]);
                        count ++;
                    }
                }
            }
        }
        ans = max(ans,count);
    }

    cout << ans;
}


Measured memory_bytes: 16872
use proconio::marker::Chars;
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        s: Chars,
        t: Chars
    };

    let s: Vec<char> = s;
    let t: Vec<char> = t;

    let mut dp: Vec<Vec<usize>> = vec![vec![0; t.len() + 1]; s.len() + 1];
    let mut v: Vec<char> = vec!['@'; s.len()];

    for i in 1..=s.len() {
        for j in 1..=t.len() {
            let si = s[i - 1];
            let ti = t[j - 1];

            if si == ti {
                dp[i][j] = dp[i - 1][j - 1] + 1;
            } else {
                dp[i][j] = std::cmp::max(dp[i - 1][j], dp[i][j - 1]);
            }
        }
    }

    let mut len = dp[s.len()][t.len()];
    let mut i = s.len();
    let mut j = t.len();
    while len > 0 {
        if s[i - 1] == t[j - 1] {
            v[len - 1] = s[i - 1];
            len -= 1;
            i -= 1;
            j -= 1;
        } else if dp[i][j] == dp[i - 1][j] {
            i -= 1;
        } else {
            j -= 1;
        }
    }

    for i in v.iter() {
        if *i == '@' {
            break;
        } else {
            print!("{}", i);
        }
    }
}


Measured memory_bytes: 72568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	vector<int> a(10);
	rep(i,4){
		int b;cin >> b;
		a.at(b)++;
	}
	if(a[1] && a[4] && a[9] && a[7]) 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 < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define p(a,b) printf(a,b);
#define o(s) cout<< s << endl;
typedef long long LL;
template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

int main()
{
    int a,b; cin>>a>>b;
    o((b%a==0?a+b:b-a));
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int sum,i,type;
  while(1){
    int line[10]={0};
    scanf("%d",&sum);
    if(sum == 0)
      break;
    for(i=0;i<sum;i++){
      scanf("%d",&type);
      line[type]++;
    }
    for(i=0;i<10;i++){
      if(line[i] == 0)
	printf("-\n");
      else{
	while(line[i]){
	  printf("*");
	  line[i]--;
      }
	printf("\n");
      }
    }
  }
  return 0;
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    map<string,int64_t>S;
    for (int i=0; i < N; i++) {
        string op, name;
        cin >> op >> name;
        if (op == "insert") {
            S[name] = 1;
        } else {
            if (S.count(name) > 0) {
                cout << "yes" << endl;
            } else {
                cout << "no" << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 36444
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const int INF = 2e9;
template<class T> void print(const T& t){ cout << t << endl; }
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
    ll n, a, b;
    cin >> n >> a >> b;
    string s;
    cin >> s;
    ll counta = 0;
    ll countb = 0;
    rep(i, n)
    {
        if(s[i]=='a'){
          if(counta+countb<a+b){
              print("Yes");
              counta++;
          }
          else{
              print("No");
          }
        }
        else if(s[i]=='b'){
          if(counta+countb<a+b&&countb<b){
              print("Yes");
              countb++;
          }
          else{
              print("No");
          }
        }
        else{
            print("No");
        }
    }
}

Measured memory_bytes: 896
#include<stdio.h>
#include<string>
using namespace std;

int main(){
  int a, b, ans;
  char op;
  while(true){
    scanf("%d %c %d", &a, &op, &b);
    if (op=='+') ans = a + b;
    else if (op=='-') ans = a - b;
    else if (op=='*') ans = a * b;
    else if (op=='/') ans = a / b;
    else break;
    printf("%d\n",ans);
    continue;
  }
  return 0;
}



Measured memory_bytes: 2736
#include <bits/stdc++.h>
#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 FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
//const ll mod = 1000000007;
const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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 (a>b) { a=b; return 1; } return 0; }

ll dp[3030][3030];

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(25);

  ll a, b, c, d;
  cin >> a >> b >> c >> d;

  FOR(i, a, c + 1) {
    FOR(j, b, d + 1) {
      if (i == a && j == b) {
        dp[a][b] = 1;
        continue;
      }
      dp[i][j] = (dp[i - 1][j] * j + dp[i][j - 1] * i - dp[i - 1][j - 1] * (i - 1) * (j - 1) + mod * mod) % mod;
    }
  }
  cout << dp[c][d] << '\n';


  


  




  
  return 0;
}


Measured memory_bytes: 74468
s = int(input())
a = [s]
ans = 1

def f(n):
	if n % 2 == 0:
		return n // 2
	else:
		return 3 * n + 1

for i in range(1000000):
	ans += 1
	s = f(s)
	if s in a:
		break

	a.append(s)


print(ans)


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

int main() {
  char c;
  cin >> c;
  
  if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {
    cout << "vowel" << endl;
  } else {
    cout << "consonant" << endl;
  }
}


Measured memory_bytes: 3632