akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  
  int a;
  map<int,int> x;
  for(int i=0; i<n; i++) {
    cin >> a;
    x[a]++;
  }
  
  vector<int> y;
  for(auto p : x) y.push_back(p.second);
  sort(y.rbegin(), y.rend());
  
  int ans = 0;
  int b = y.size();
  for(int i=0; i<b; i++) {
    if(y.size()>k) {
      ans += y[y.size()-1];
      y.pop_back();
    }
    else break;
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 13416
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
 
typedef long long ll;
typedef pair<int, int> ii;

int main() {
	
	ll n, m;
	while(cin >> n >> m, n){
		vector<ll> h(n);
		vector<ll> w(m);
		map<ll, ll> mp_h, mp_w;
		rep(i, n){
			cin >> h[i];
			mp_h[h[i]]++;
		}
		rep(i, m){
			cin >> w[i];
			mp_w[w[i]]++;
		}
		
		rep(i, n){
			ll tmp = h[i];
			for(int j = i + 1; j < n; j++){
				tmp += h[j];
				mp_h[tmp]++;
			}
		}
		
		rep(i, m){
			ll tmp = w[i];
			for(int j = i + 1; j < m; j++){
				tmp += w[j];
				mp_w[tmp]++;
			}
		}
		
		ll ans = 0;
		for(auto it : mp_h){
			ans += (it.second * mp_w[it.first]);
		}
		cout << ans << endl;
	}
	
	return 0;
}


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

int c[27], s[366][27], t[366], last[27];
int main()
{
    int D; cin>>D;
    for(int i=1; i<=26; ++i) cin>>c[i];
    for(int i=1; i<=D; ++i)
        for(int j=1; j<=26; ++j)
            cin>>s[i][j];

    auto calc_score=[&](){
        long score=0;
        for(int i=1; i<=26; ++i) last[i]=0;
        for(int d=1; d<=D; ++d) {
            score+=s[d][t[d]];
            last[t[d]]=d;
            for(int i=1; i<=26; ++i) score-=c[i]*(d-last[i]);
        }
        return score;
    };

    for(int i=1; i<=D; ++i) {
        long bestscore=-(1L<<60), typ=1;
        for(int j=1; j<=26; ++j) {
            t[i]=j;
            auto score=calc_score();
            t[i]=0;
            if (bestscore<score) {
                bestscore=score;
                typ=j;
            }
        }
        t[i]=typ;
    }

    mt19937 engine;
    uniform_int_distribution<> rndT(1, 26), rndD(1, 365), rndR(0, 1);
    auto bestscore=calc_score();

    for(int A=200000; A--; ) {
        if (rndR(engine)) {
            int d=rndD(engine);
            int q=rndT(engine);
            int x=t[d];
            t[d]=q;
            auto score=calc_score();
            if (bestscore<score) {
                bestscore=score;
            }
            else {
                t[d]=x;
            }
        }
        else {
            int a=rndD(engine);
            int b=rndD(engine);
            swap(t[a], t[b]);
            auto score=calc_score();
            if (bestscore<score) {
                bestscore=score;
            }
            else {
                swap(t[a], t[b]);
            }
        }
    }
    for(int i=1; i<=D; ++i) cout<<t[i]<<endl;
    //cout<<bestscore<<endl;
}


Measured memory_bytes: 3692
#include <bits/stdc++.h>
 
using namespace std;
#define int long long
 
int32_t main()
{
    int n,W,s = 0;
    cin >> n >> W;
    vector<int>w(n),c(n);
    for(int i = 0;i < n;i++)
    {
        cin >> w[i] >> c[i];
        s += c[i];
    }
    vector<int>dp(s + 1,INT_MAX);
    dp[0] = 0;
    for(int i = 0;i < n; i++)
    {
        for(int j = s - c[i]; j >= 0; j--)
        {
            dp[j + c[i]] = min(dp[j + c[i]],dp[j] + w[i]);
        }
    }
    int ans = 0;
    for(int i = 0; i <=s; i++)
    {
        if(dp[i] <= W)
        {
            ans = i;
        }
    }
    cout <<ans;
    return 0;
}

Measured memory_bytes: 4060
#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 MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(pi c, pi d){
	return c.S < d.S;
}

int main() {
	int H, W;
	cin >> H >> W;
	char c[H][W];
	char m;
	REP(i, 0, H){
		REP(j, 0, W){
			cin >> m;
			c[i][j] = m;
		}
	}
	string ans = "Yes";
	REP(i, 0, H){
		REP(j, 0, W){
			if(c[i][j] == '#'){
				if(i == 0){
					if(j== 0){
						if(c[i][j+1] != '#' && c[i+1][j] != '#'){
							ans = "No";
							break;
						}
					}
					else if(j == W-1){
						if(c[i][j-1] != '#' && c[i+1][j] != '#'){
							ans = "No";
							break;
						}
					}
					else{
						if(c[i][j+1] != '#' && c[i+1][j] != '#' && c[i][j-1] != '#'){
							ans = "No";
							break;
						}
					}
				}
				else if(i == H-1){
					if(j== 0){
						if(c[i][j+1] != '#' && c[i-1][j] != '#'){
							ans = "No";
							break;
						}
					}
					else if(j == W-1){
						if(c[i][j-1] != '#' && c[i-1][j] != '#'){
							ans = "No";
							break;
						}
					}
					else{
						if(c[i][j+1] != '#' && c[i-1][j] != '#' && c[i][j-1] != '#'){
							ans = "No";
							break;
						}
					}
				}
				else{
					if(j== 0){
						if(c[i][j+1] != '#' && c[i+1][j] != '#' && c[i-1][j] != '#'){
							ans = "No";
							break;
						}
					}
					else if(j == W-1){
						if(c[i][j-1] != '#' && c[i+1][j] != '#' && c[i-1][j] != '#'){
							ans = "No";
							break;
						}
					}
					else{
						if(c[i][j+1] != '#' && c[i+1][j] != '#' && c[i][j-1] != '#' && c[i-1][j] != '#'){
							ans = "No";
							break;
						}
					}
				}
			}
		}
		if(ans == "No") break;
	}
	cout << ans;
	
	

}


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

typedef long long lint;
typedef pair<int, int> pii;

const int INF = 2e9;
const int MOD = 1e9+7;
const int MAX = 2e5+10;
const lint LNF = 2e18;

int n;
char S[MAX];
int W[MAX];

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

	cin>>n>>(S+1);

	for(int i=1; i<=n; i++) W[i] = W[i-1] + (S[i]=='.');

	int ans = n-W[n];

	for(int i=0; i<=n; i++){
		int now = i-W[i] + (W[n]-W[i]);
		ans = min(ans, now);
	}
	cout<<ans<<'\n';

	return 0;
}


Measured memory_bytes: 1280
#include<stdio.h>
int main()
{
    int temb,i,j,n,b,s=0;
    scanf("%d%d",&n,&b);
    for(;n>0;)
    {
        n=n/b;
        s=s+1;
    }
    printf("%d\n",s);
    return 0;
}


Measured memory_bytes: 128
from collections import deque

H, W = list(map(int, input().split()))
S = []
for _ in range(H):
    S.append(input())

ret = 0
for i in range(H):
    for j in range(W):
        s = S[i][j]
        queue = deque([(i,j,0)])
        footprint = [(i,j)]
        if s == '#':
            continue
        while True:
            x, y, d = queue.popleft()
            for p in [(x-1, y), (x, y-1), (x, y+1), (x+1, y)]:
                if p[0] >= 0 and p[0] < H and p[1] >=0 and p[1] < W and p not in footprint and S[p[0]][p[1]] != '#':
                        queue.append((p[0], p[1], d+1))
                        footprint.append(p)

            if len(queue) == 0:
                break
        if d > ret:
            ret = d

print(ret)

Measured memory_bytes: 45660
#include <stdio.h>
#include <math.h>
int main()
{
    long int N,i;
    scanf("%ld",&N);
    for(i=(long int)sqrt(N);i>0;i--) if(N%i==0) break;
    printf("%d\n",(int)log10(N/i)+1);
    return 0;
}

Measured memory_bytes: 384
A,B,C = map(int,input().split())
cnt = 0

while(cnt<=10**6):
    if A%2==0 and B%2==0 and C%2==0:
        mm1 = (B//2+C//2)
        mm2 = (A//2+C//2)
        mm3 = (A//2+B//2)
        A,B,C = mm1,mm2,mm3
        cnt += 1
    else:
        break

if cnt==10**6+1:
    print(-1)
else:
    print(cnt)

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

#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define ll long long
#define bit __builtin_popcountll
#define sqr(x) (x) * (x)
#define forit(it,S) for(__typeof((S).begin()) it = (S).begin(); it != (S).end(); it++)
#define debug(x) cout << #x <<" = " << x << endl
#define forn(i, n) for(int i = 0 ; (i) < (n) ; ++i)
#define printvpair(v) for(int i = 0 ; (i) < (v.size()) ; ++i) cout << v[i].first  <<" " << v[i].second << endl;
#define printv(v) for(int i = 0 ; (i) < (v.size()) ; ++i) cout << v[i] << " "; cout << endl;

using namespace std;

typedef pair<int, int> pii;

const double eps = 1e-9;
const double pi = acos(-1.0);
const int INF = 1000000000;

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

const int N = 100001;
int a[N];
int main() {
	ios_base::sync_with_stdio(0);
	ll n,m;
	cin >> n >> m;
	ll ans = min(n,m / 2);
	n -= ans;
	m -= 2 * ans;
	cout << ans + m / 4  << endl;
  	return 0;
}


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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 24;

// (??´?????????????¢§?\????????????±????????????idx)
typedef pair<pii, int> State;

vi dx = { 1, 0,-1, 0};
vi dy = { 0,-1, 0, 1};

#define F first
#define S second

int main(void){
    for(int w, h; cin >> w >> h, w;){
        vs field(h);
        rep(y, h) cin >> field[y];

        pii s;
        int n_gomi = 0;
        vvi dic(h, vi(w, -1));

        rep(y, h) rep(x, w){
            if(field[y][x] == 'o'){
                s = mp(y, x);
                field[y][x] = '.';
            }
            if(field[y][x] == '*'){
                dic[y][x] = n_gomi;
                n_gomi++;
            }
        }

        // (cost, State)
        priority_queue<pair<int, State>, vector<pair<int, State>>, greater<pair<int, State>>> q;
        q.push(mp(0, mp(s, 0)));

        vector<vvi> minDist(h, vvi(w, vi(1 << n_gomi, inf)));

        int res = -1;
        while(!q.empty()){
            int cur_cost = q.top().F;
            pii cur_pos = q.top().S.F;
            int cur_d = q.top().S.S;
            q.pop();

            if(cur_d == (1 << n_gomi) - 1){
                res = cur_cost;
                break;
            }

            if(minDist[cur_pos.F][cur_pos.S][cur_d] != inf) continue;
            minDist[cur_pos.F][cur_pos.S][cur_d] = cur_cost;

            rep(i, 4){
                pii next_pos = mp(cur_pos.F + dy[i], cur_pos.S + dx[i]);

                if(next_pos.F < 0 || h <= next_pos.F ||
                   next_pos.S < 0 || w <= next_pos.S ||
                   field[next_pos.F][next_pos.S] == 'x') continue;

                int next_d = cur_d;
                int idx = dic[next_pos.F][next_pos.S];
                if(idx != -1){
                    next_d |= (1 << idx);
                }
                if(minDist[next_pos.F][next_pos.S][next_d] != inf) continue;

                q.push(mp(cur_cost + 1, mp(next_pos, next_d)));
            }
        }

        cout << res << endl;
    }

	return 0;
}

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

int main() {
	int x, y, tmp;
	while (cin >> x >> y, x + y) {
		if (x > y) {
			tmp = x;
			x = y;
			y = tmp;
		}
		cout << x << " " << y << endl;
	}
	return 0;
}

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std; 
int main()
{
    int n,m;
    scanf("%d %d",&n,&m);
char arr[n][n];
char arr1[m][m];
    for(int i=0; i<n; i++)
        scanf("%s",arr[i]);
    for(int i=0; i<m; i++)
        scanf("%s",arr1[i]);
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<n; j++)
        {
            int c=0;
            for(int a=0; a<m; a++)
            {
                for(int b=0; b<m; b++)
                {
                    if(arr1[a][b]==arr[i+a][j+b])
                        c++;
                }
            }
            if(c==(m*m))
            {
                printf("Yes\n");
                return 0;
            }
        }
    }
    printf("No\n");
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<49;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

#define N 100010
ll a[N], b[N];

int main(){
	ll n;
	cin>>n;
	vector<ll> d(3*n);
	rep(i, 3*n) cin>>d[i];
	{
		priority_queue<ll, vector<ll>, greater<ll> > q;
		ll s = 0;
		rep(i, 2*n){
			s += d[i];
			q.push(d[i]);
			if(i>=n){
				ll x = q.top(); q.pop();
				s -= x;
			}
			if(i>=n-1) a[i-n+1] = s;
		}
	}
	{
		priority_queue<ll, vector<ll>, less<ll> > q;
		ll s = 0;
		rep(i, 2*n){
			s += d[3*n-i-1];
			q.push(d[3*n-i-1]);
			if(i>=n){
				ll x = q.top(); q.pop();
				s -= x;
			}
			if(i>=n-1) b[2*n-i-1] = s;
		}
	}
	ll res = -INF;
	rep(i, n+1){
		res = max(res, a[i]-b[i]);
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 5992
#include <iostream>
#include <cstring>
#include <cstdio>
#define inf 0X3f3f3f3f
using namespace std;
const int M = 1e5 + 10;
typedef long long ll;
int a[M];
ll add[M] , del[M];
int main() {
    int n , m;
    scanf("%d%d" , &n , &m);
    for(int i = 1 ; i <= n ; i++) scanf("%d" , &a[i]);
    for(int i = 1 ; i < n ; i++) {
        int x = a[i] , y = a[i + 1];
        if(x < y) {
            add[1] += (y - x);
            add[x + 1] -= (y - x);
            del[x + 1]--;
            add[y + 1] += (y - x);
            add[x + 1] += y + 1;
            del[y + 1]++;
            add[y + 1] -= y + 1;
        }
        else if(x > y) {
            add[1] += y + 1;
            del[1]--;
            add[y + 1] -= y + 1;
            add[y + 1] += m - x + y;
            del[y + 1]++;
            add[x + 1] -= m - x + y;
            add[x + 1] += y + 1 + m;
            del[x + 1]--;
        }
    }
    add[0] = 0 , del[0] = 0;
    for(int i = 1 ; i <= m ; i++) {
        add[i] += add[i - 1];
        del[i] += del[i - 1];
    }
    ll ans = 1e12;
    for(int i = 1 ; i <= m ; i++) {
        ans = min(ans , add[i] + (ll)i * del[i]);
    }
    printf("%lld\n" , ans);
    return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
#define INF 99999999999 //10^12-1
#define dev 998244353 //tenka1
#define P pair<int,int>
#define prique priority_queue
int a,b,t;
signed main(){
    cin>>a>>b>>t;
    int x=(t+0.5)/a;
    cout<<x*b<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <utility>
#include <algorithm>
#include <string>
#include <cmath>
#define faster ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pii pair<int, int>
#define ppi pair<pair<int, int>, int>
#define mp make_pair
#define show(v) for(int i : v)cout << i << " ";cout << endl;

using namespace std;
typedef long long ll;
int inf = 1e9;
const int N = 1e7 + 5;
int d[N];
int main(){
    faster
    for(int i = 1;i < N;i++){
        for(int j = 1;j < N;j++){
            if(i * j >= N)break;
            d[i * j] += 1;
        }
    }
    int n; cin >> n;
    ll ans = 0;
    for(int i = 1;i <= n;i++)
        ans += ll(i * d[i]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 42220
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define mod 1000000007
typedef long long int ll;
int u(const void *a, const void *b){
    return *(ll*)a-*(ll*)b;
}
int d(const void *a, const void *b){
    return *(ll*)b-*(ll*)a;
}
int z(int a){
  if(a<1)a*=-1;
  return a;
}
int min(int a,int b){
  if(a>b)return b;
  return a;
}
int max(int a,int b){
  if(a>b)return a;
  return b;
}
int gcd(int a,int b){
  if(!b)return a;
  return gcd(b,a%b);
}
int kt(ll a){
  int sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
int ks(ll a){
  int sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
int main(void){
  ll a,b,c;
  scanf("%lld %lld %lld",&a,&b,&c);
  ll ans=b;
  ans+=min(c,a+b+1);
  PRL(ans);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;


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

    vector<int> a(n);
    rep(i,n) cin >> a[i];

    int l, q;
    cin >> l >> q;

    vector<int> dp[20];
    rep(i,20) dp[i] = vector<int>(100005);
    rep(i,n){
        dp[0][i] = distance(a.begin(), upper_bound(all(a), a[i] + l)) - 1;
        //cout << dp[0][i] << endl;
    }

    rep(k,20 - 1){
        rep(i,n){
            dp[k + 1][i] = dp[k][ dp[k][i] ];
        }
    }

    rep(i,q){
        int a, b;
        cin >> a >> b;
        a--; b--;
        if(a > b) swap(a,b);
        //show("JI")
        //cout << a << ' ' << b << endl;

        int ans = 0;
        for(int j = 19; j >= 0; j--){
            //cout << j << ' ' << (1 << j) << endl;
                //cout << a << ' ' <<b << ' ' <<  dp[j][a] << endl;


            if(dp[j][a] < b){ //移動可能
                a = dp[j][a];
                ans += 1 << j;
            }
        }
        cout << ans + 1 << endl;
    }
}


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

int main() {
  long int a,b;
  cin >> a >> b;
  if (a>0)
    cout << "Positive" << endl;
  else if (a<=0&&b>=0)
    cout << "Zero" << endl;
  else {
    if (abs(a+b)%2==0)
      cout << "Negative" << endl;
    else
      cout << "Positive" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define INF (1<<21)
#define MAX 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,M[MAX][MAX];

void kansu(){
  int minv,i,j,v,u;
  int d[MAX],color[MAX];
  for(i=0;i<n;i++){
    d[i]=INF;
    color[i]=WHITE;
  }

  d[0]=0;
  color[0]=GRAY;
  while (1) {
    minv=INF;
    u=-1;
    for(i=0;i<n;i++){
      if(minv>d[i] && color[i] != BLACK){
        u = i;
        minv = d[i];
      }
    }
    if (u == -1){
        break;
    }
    color[u]=BLACK;
    for(v=0;v<n;v++){
      if(color[v] != BLACK && M[u][v] !=INF){
        if( d[v] > d[u]+ M[u][v]){
          d[v] = d[u] + M[u][v];
          color[v] =GRAY;
        }
      }
    }
  }
  for(i=0;i<n;i++){
    printf("%d",i);
    if(d[i] == INF){
        printf(" -1\n");
    }
    else{
     printf(" %d\n",d[i]);
    }
  }
}

int main(){
  int i,j,v,c,u,k;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      M[i][j] = INF;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d %d",&v,&c);
      M[u][v] = c;
    }
  }

  kansu();

  return 0;
}





Measured memory_bytes: 2136
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

#include <vector>
#include <map>

using namespace std;

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

	int N;
	cin >> N;

	map<long long, int> count;
	vector<long long> unique_list;

	for (int i = 0; i < N; i++)
	{
		long long a;
		cin >> a;

		if (count[a] == 0)
		{
			unique_list.push_back(a);
		}
		count[a]++;
	}

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

	long long width = 0;
	for (int i = unique_list.size() - 1; i >= 0; i--)
	{
		if (count[unique_list[i]] >= 2)
		{
			count[unique_list[i]] -= 2;
			width = unique_list[i];
			break;
		}
	}

	long long height = 0;
	for (int i = unique_list.size() - 1; i >= 0; i--)
	{
		if (count[unique_list[i]] >= 2)
		{
			count[unique_list[i]] -= 2;
			height = unique_list[i];
			break;
		}
	}

	cout << width * height;

	return 0;
}


Measured memory_bytes: 7284
import java.util.*

fun gcd(an: Int, bn: Int): Int {
    var a = an
    var b = bn
    if (a > b) {
        val temp = a
        a = b
        b = temp
    }

    while (true) {
        val r = a % b
        if (r == 0) {
            return b
        }
        a = b
        b = r
    }
}

fun main(args: Array<String>){
	val cin = Scanner(System.`in`)
    val n = cin.nextInt()
    val k = cin.nextInt()
    
    val a = Array<Int>(n, { cin.nextInt() })

    var x = a[0]

    for (i in 1..n-1) {
        x = gcd(x, a[i])
    }

    var max = a[0]

    for (i in 1..n-1) {
        if (a[i] > max) {
            max = a[i]
        }
    }

    if (k % x == 0 && max >= k) {
        println("POSSIBLE")
    } else {
        println("IMPOSSIBLE")
    }
}

Measured memory_bytes: 51928
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
void Main(){
    char b;cin>>b;
    if(b=='A') cout<<'T'<<endl;
    if(b=='T') cout<<'A'<<endl;
    if(b=='G') cout<<'C'<<endl;
    if(b=='C') cout<<'G'<<endl;
    return ;
}
int main(){
    Main();
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(void){
  int n,i,j;
  scanf("%d",&n);
  double d[20];
  double dis;
  for (i=0;i<n;i++){
    for (j=0;j<6;j++){
      scanf("%lf",&d[j]);
    }
    dis = sqrt((d[0]-d[3])*(d[0]-d[3])+(d[1]-d[4])*(d[1]-d[4]));
    if (dis>d[2]+d[5]){
      printf("%d\n",0);
    }else if (dis<d[5]-d[2]){
      printf("%d\n",-2);
    }else if (dis<d[2]-d[5]){
      printf("%d\n",2);
    }else{
      printf("%d\n",1);
    }
  }
  return 0;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main()
{
	int n,m,k;
	cin>>k>>n>>m;
	int flag=0;
	for(int i=n;i<=m;i++)
	{
		if(i%k==0)
		{
			cout<<"OK";
			flag=1;
			break;
		}
	}
	if(flag==0)
	cout<<"NG";
}

Measured memory_bytes: 3100
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func abs(x float64) float64 {
	if x < 0 {
		return -1 * x
	}
	return x
}

func main() {
	sc.Split(bufio.ScanWords)

	n, t, a := nextInt(), nextInt(), nextInt()
	d := math.MaxFloat64
	ans := 0
	for i := 0; i < n; i++ {
		h := nextInt()
		tmp := float64(t) - 0.006 * float64(h)
		if d > abs(tmp - float64(a)) {
			d = abs(tmp - float64(a))
			ans = i+1
		}
	}
	fmt.Println(ans)
}

Measured memory_bytes: 640
import math

N,M=(int(x) for x in input().split())

def combinations_count(n, r):
    if n < 2:
        return 0
    else: 
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


print(combinations_count(N, 2)+ combinations_count(M, 2))


Measured memory_bytes: 2940
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <iostream>
#include <climits>
#include <cstring>
#include <functional>
#include <iomanip>

using namespace std;

//using ll = long long;
#define rep(i, N) for(int i = 0;i < (int)N;i++)
#define LARGE INT_MAX / 2
#define PI 3.1415926535897932384626433832795



int main() {
	double a;

	cin >> a;

	cout << fixed << setprecision(8);

	cout << PI * a * a << ' ' << 2 * PI * a << endl;

	return 0;
}


Measured memory_bytes: 3300
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E12;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll * pos,ll val){*pos=max(*pos,val);}//Max(&dp[i][j],dp[i-1][j]);
void Min(ll * pos,ll val){*pos=min(*pos,val);}
void Add(ll * pos,ll val){*pos=mod(*pos+val);}
const long double EPS=1E-8;
////////////////////////////////////////
#define N (ll)2E7+10
ll kai[N];
ll kai2[N];
ll po(ll i,ll p){
    if(p==0)return 1;
    else if(p==1)return mod(i);
    else if(p%2==0)return mod(po(mod(mod(i)*mod(i)),p/2));
    else  return mod(mod(i)*mod(po(i,p-1)));
}
void calc(){
    kai[0]=1;
    kai2[0]=1;
    for(int i=1;i<N;i++){
        kai[i]=kai[i-1]*i%i_7;
    }
    kai2[N-1]=po(kai[N-1],i_5);
    for(int i=N-2;i>=1;i--){
        kai2[i]=kai2[i+1]*(i+1)%i_7;
    }
}
ll comb(ll n,ll k){
    if(n==0){
        if(k==0)return 1;
        else return 0;
    }
    else if(n<k)return 0;
    else return mod(mod(mod(kai[n])*mod(kai2[n-k]))*mod(kai2[k]));
}
ll bunbo(ll n){
    return po(n,i_5);
}

int main(){
    calc();
    /*rep(i,1,5){
        cout<<kai[N-i]<<" "<<kai2[N-i]<<endl;
    }*/
    ll h,w,k;cin>>h>>w>>k;
    ll x[4];
    for(ll p=1;p<=min(3,k);p++){
        ll sum=0;
        for(ll i=max(0,p-w);i<=min(h,p);i++){
            ll res=(i+1)*(p-i+1)*comb(p,i)*comb(w+h-p,h-i);
            sum+=res;
        }//cout<<"sum:"<<sum<<endl;
        x[p]=sum;
    }
    ll ans=mod(mod(kai[h]*kai[w])*kai2[h+w-k]);
    if(k<=3){
        ll res=0;
        rep(i,1,k)res=mod(res+x[i]);
        cout<<mod(ans*res);
    }else{
        ll y1=x[2]-x[1];
        ll y2=x[3]-x[2];
        ll z=y2-y1;
        ll res=mod(x[1]*k)+mod(mod((y1-z)*k)*mod((k+1)*bunbo(2)))-mod((y1-z)*k)+mod(mod(k*(k+1))*mod(mod((2*k+1)*z)*bunbo(12)))-mod(mod(z*k)*mod((k+1)*bunbo(4)));
        cout<<mod(res*ans)<<endl;
    }
    return 0;
}







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

int main()
{
   int n, sum=0;
   cin >> n;
   int a[n], b[n], c[n];
  //食べた料理の番号
  rep(i, n) cin >> a[i];
  //得た満足度(番号順)
  rep(i, n) cin >> b[i];
  //最後の料理の満足度
  rep(i, n - 1) cin >> c[i];

  //足し算
  rep(i, n) sum += b[i];
  rep(i, n - 1){
    //もしaの次の要素との差が+1だったらcの合計にたす
    if((a[i] == a[i + 1] - 1)) sum += c[a[i] - 1];
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; 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;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
int N, K;
int d[200];
int A[200][200];
int snuke[200];

int main()
{
    cin >> N >> K;
    rep(i, 0, K)
    {
        cin >> d[i];
        rep(j, 0, d[i])
        {
            cin >> A[i][j];
            snuke[A[i][j]]++;
        }
    }

    int ans = 0;
    repe(i, 1, N)
    {
        if (snuke[i] == 0) {
            ans++;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3652
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

const int MX = 1e6 + 5;

struct UF
{
	int par[MX],rank[MX];

	void init(int n)
	{
		for(int i=0;i<n;i++)
		{
			par[i]=i;
			rank[i]=0;
		}
	}
	void rem(int i)
	{
		par[i]=i;
		rank[i]=0;
	}
	int find(int x)
	{
		if(x==par[x]) return x;
		return par[x]=find(par[x]);
	}
	void unite(int x,int y)
	{
		x=find(x);
		y=find(y);
		if(x==y) return;
		if(rank[x]<rank[y])
		{
			par[x]=y;
		}
		else
		{
			par[y]=x;
			if(rank[x]==rank[y]) rank[x]++;
		}
	}
	bool same(int x,int y)
	{
		return find(x)==find(y);
	}
}uf;

vector<int> G[MX];
int n, m;
vector<pair<int, int> > edge[MX];

bool vis[MX];
int id[MX];
int dp[MX];
int main(){
    cin >> n >> m;
    for(int i = 1;i <= m;i++){
        int p, q, c;
        scanf("%d%d%d", &p, &q, &c);
        edge[c].push_back(make_pair(p, q));
    }
    int sz = n;
    for(int i = 0;i < MX;i++){
        if(edge[i].size() == 0)
            continue;
        for(auto p : edge[i]){
            int u = p.first;
            int v = p.second;
            uf.rem(u);uf.rem(v);
            id[u] = id[v] = -1;
            vis[u] = vis[v] = false;
        }
        for(auto p : edge[i]){
            uf.unite(p.first, p.second);
        }
        for(auto p : edge[i]){
            int u = p.first;
            int v = p.second;
            if(!vis[u]){
                vis[u] = true;
                int r = uf.find(u);
                if(id[r] == -1) id[r] = ++sz;
                G[u].push_back(id[r]);
                G[id[r]].push_back(u);
            }
            if(!vis[v]){
                vis[v] = true;
                int r = uf.find(v);
                if(id[r] == -1) id[r] = ++sz;
                G[v].push_back(id[r]);
                G[id[r]].push_back(v);
            }
        }
    }
    queue<int > que;
    que.push(1);
    memset(dp, -1, sizeof(dp));
    dp[1] = 0;
    while(!que.empty()){
        int p = que.front(); que.pop();
        for(auto to : G[p]){
            if(dp[to] == -1){
                dp[to] = dp[p] + 1;
                que.push(to);
            }
        }
    }
    if(dp[n] == -1) puts("-1");
    else printf("%d\n", dp[n] / 2);
    return 0;
}


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

int main(){
  // 入力
  int N, R;
  cin >> N >> R;
  
  int result;
  if (N>=10) {
    result = R; 
  } else {
    result = R + 100*(10-N);
  }

  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc154/tasks/abc154_d

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll N, K;
  cin >> N >> K;

  V<double> ps(N);
  rep(i, N) cin >> ps[i];

  V<double> es(N);
  rep(i, N) { es[i] = (ps[i] + 1) / 2; }

  double res = 0;
  double cur = 0;

  rep(i, N) {
    cur += es[i];

    if (i + 1 > K) {
      cur -= es[i - K];
    }

    chmax(res, cur);
  }

  cout << fixed << setprecision(12) << res << endl;
}

void solve2() {
  ll N, K;
  cin >> N >> K;

  V<double> ps(N);
  rep(i, N) cin >> ps[i];

  V<double> es(N);
  rep(i, N) { es[i] = (ps[i] + 1) / 2; }

  ld res = 0;
  ld cur = 0;
  queue<ld> q;

  rep(i, N) {
    cur += es[i];
    q.push(es[i]);

    if (q.size() > K) {
      ld v = q.front();
      q.pop();
      cur -= v;
    }

    if (q.size() == K) {
      chmax(res, cur);
    }
  }

  cout << fixed << setprecision(12) << res << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

#ifndef TEST
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  try {
    solve2();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 6656
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	static int N;
	static int[] d;
	static int[] cnt;
	static int[] ans;
	static int L;
	static ArrayList<int[]> ansLis;

	void run() {
		Scanner sc = new Scanner(System.in);
		while (true) {
			N = sc.nextInt();
			if (N == 0)
				break;
			ans = new int[N];
			cnt = new int[401];
			Arrays.fill(ans, -1);
			d = new int[N * (N - 1) / 2];
			for (int i = 0; i < d.length; ++i) {
				d[i] = sc.nextInt();
				++cnt[d[i]];
			}
			L = d[0];
			ans[0] = 0;
			ans[N - 1] = L;
			--cnt[L];
			ansLis = new ArrayList<>();
			solve(0, N - 1);

			ansLis.sort(new Comparator<int[]>() {
				@Override
				public int compare(int[] o1, int[] o2) {
					for (int i = 0; i < o1.length; ++i) {
						if (o1[i] != o2[i])
							return Integer.compare(o1[i], o2[i]);
					}
					return 0;
				}
			});

			for (int i = 0; i + 1 < ansLis.size(); ++i) {
				while (i + 1 < ansLis.size() && sameArr(ansLis.get(i), ansLis.get(i + 1))) {
					ansLis.remove(i + 1);
				}
			}

			for (int i = 0; i < ansLis.size(); ++i) {
				for (int j = 0; j < N - 1; ++j) {
					System.out.print(ansLis.get(i)[j]);
					System.out.print(j + 1 == N - 1 ? "\n" : " ");
				}
			}
			System.out.println("-----");
		}
	}

	boolean sameArr(int[] arr1, int[] arr2) {
		for (int i = 0; i < arr1.length; ++i) {
			if (arr1[i] != arr2[i])
				return false;
		}
		return true;
	}

	void solve(int left, int right) {
		if (right - left == 1) {
			for (int v : cnt) {
				if (v != 0)
					return;
			}
			int[] arr = new int[N - 1];
			for (int i = 0; i + 1 < N; ++i) {
				arr[i] = ans[i + 1] - ans[i];
			}
			ansLis.add(arr);
		}
		for (int i = cnt.length - 1; i >= 0; --i) {
			if (cnt[i] == 0)
				continue;
			boolean f = true;
			for (int j = 0; j < ans.length; ++j) {
				--cnt[Math.abs(i - ans[j])];
				if (cnt[Math.abs(i - ans[j])] < 0) {
					f = false;
				}
				if (j == left)
					j = right - 1;
			}
			ans[right - 1] = i;
			if (f) {
				solve(left, right - 1);
			}
			ans[left + 1] = -1;
			for (int j = 0; j < ans.length; ++j) {
				++cnt[Math.abs(i - ans[j])];
				if (j == left)
					j = right - 1;
			}
			f = true;
			for (int j = 0; j < ans.length; ++j) {
				--cnt[Math.abs(L - i - ans[j])];
				if (cnt[Math.abs(L - i - ans[j])] < 0) {
					f = false;
				}
				if (j == left)
					j = right - 1;
			}
			ans[left + 1] = L - i;
			if (f) {
				solve(left + 1, right);
			}
			ans[right - 1] = -1;
			for (int j = 0; j < ans.length; ++j) {
				++cnt[Math.abs(L - i - ans[j])];
				if (j == left)
					j = right - 1;
			}
			break;
		}

	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}

Measured memory_bytes: 42244
#include <iostream>
#include <cmath>
using namespace std;
 
int D;
double V[16];
double interpolate(int n, int E){
    double sum = 0.0;
    for(int k=0;k<D+3; ++k){
        if(k == n || k == E) continue;
        double p = V[k];
        for(int i=0;i<D+3;++i){
            if(!(i == k || i == n || i == E))
                p *= (n-i)/(double)(k-i);
        }
        sum += p;
    }
    return sum;
}
 
bool outliner(int E){
    for(int i=0;i<D+3;++i){
        if(i==E) continue;
        double p = interpolate(i,E);
        if(abs(p-V[i]) > 0.1) return false;
    }
    return true;
}
 
int main(){
    while(cin >> D && D){
        for(int i=0;i<D+3;i++) cin >> V[i];
        for(int i=0;i<D+3;i++){
            if(outliner(i)){
                cout << i << endl;
                break;
            }
        }
    }
}


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

using namespace std;

typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli>> mat;

lli a,b;
string s;

void error(){
  cout << "No" << endl;
  exit(0);
}

int main(){
  cin >> a >> b;
  cin >> s;
  for(lli i = 0;i < a;i++){
    if(s[i] - '0' < 0 || s[i] - '0' > 9) error();
  }
  if(s[a] != '-') error();
  for(lli i = a+1;i < a+b+1;i++){
    if(s[i] - '0' < 0 || s[i] - '0' > 9) error();
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
        String S = sc.next();
        char[]ss = S.toCharArray();

        for(int i=0; i<19; i++){
        if(ss[i] == ','){
            ss[i] = ' ';
            }
}
            System.out.println(String.valueOf(ss));    
    }
}

Measured memory_bytes: 35472
let readIntArray _ =
    stdin.ReadLine().Split(" ") |> Array.map int

()
|> readIntArray
|> fun [| a; b; c; d |] ->
    if b <= c || d <= a then 0
    elif a <= c && d <= b then d - c
    elif c <= a && b <= d then b - a
    elif a <= c && b <= d then b - c
    else d - a
    |> printfn "%d"


Measured memory_bytes: 30036
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}

int main(void){
	int n, i;
	long a[100000];
	int b[100000];
	scanf("%d", &n);
	for(i=0; i<n; i++){
		scanf("%ld%d", a+i, b+i);
	}
	long ans=0;
	for(i=n-1; i>=0; i--){
		a[i]+=ans;
		ans+=(a[i]+b[i]-1)/b[i]*b[i]-a[i];
	}
	printf("%ld\n", ans);
}


Measured memory_bytes: 1280
N = int(input())
H = list(map(int, input().split()))

INF = float("inf")
dp = [INF] * (N + 1)
dp[0] = 0
dp[1] = abs(H[0] - H[1])
for i in range(2, N):
    dp[i] = min(dp[i - 1] + abs(H[i - 1] - H[i]), dp[i - 2] + abs(H[i - 2] - H[i]))

print(dp[-2])


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

int main(int argc, char const *argv[])
{
	int n;
	cin>> n;

	if(n%1000 == 0)
		cout<<0<<endl;
	else
		cout<<1000 - (n%1000) <<endl;
	return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

const double PI = acos(-1);
#define MOD 1000000007  ///1e9+7

#define pb push_back
#define F first
#define S second
#define test int tc; cin>>tc; while(tc--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) x.size()
#define el <<'\n'
#define sp <<' '

#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) abs((a)*(b))/gcd((a),(b))
#define sqr(a) (a)*(a)

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

///******************************** C o d e ********************************///



main()
{
    string a;
    cin>>a;
    cout<<(a=="ABC"? "ARC":"ABC");

}



///Thank you.



///Brainless_Loco Terminates Here!


Measured memory_bytes: 3588
#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>;
#define chmin(x,y) x=min(x,y)

const ll INF = 1e18;

ll dp[20][20];

vector<ll> calc(vector<P>& a) {
  int n = a.size();
  sort(a.begin(), a.end());
  rep(i,n+1) rep(j,n+1) dp[i][j] = INF;
  dp[0][0] = 0;
  rep(l,n) {
    for(int r = l+1;r <= n;++r){
      {
        ll now = INF;
        for(int k = l;k < r;++k){
          ll s = 0;
          for(int i = l;i < r;++i){
            s += abs(a[i].first-a[k].first)*ll(a[i].second);
          }
          chmin(now, s);
        }
        rep(j,n) chmin(dp[r][j+1], dp[l][j]+now);
      }
      {
        ll now = 0;
        for(int i = l;i < r;++i){
          now += abs(a[i].first)*ll(a[i].second);
        }
        rep(j,n+1) chmin(dp[r][j],dp[l][j]+now);
      }
    }
  }
  vector<ll> res(n+1,INF);
  rep(j,n+1) res[j] = dp[n][j];
  return res;
}

int main() {
  int n;
  cin>>n;
  vector<int> x(n),y(n),p(n);
  rep(i,n)cin >> x[i] >> y[i] >> p[i];
  vector<ll> ans(n+1, INF);
  rep(s,1<<n){
    vector<P> ax,ay;
    rep(i,n){
      if(s>>i&1)ax.emplace_back(x[i], p[i]);
      else ay.emplace_back(y[i], p[i]);
    }
    vector<ll> dx = calc(ax);
    vector<ll> dy = calc(ay);
    rep(i,dx.size())rep(j,dy.size())
    {


      ans[i+j] = min(ans[i+j], dx[i]+dy[j]);
    }
  }

  rep(i,n+1){
    cout << ans[i] <<endl;
  }
  return 0;
}


Measured memory_bytes: 3584
#include <stdio.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
#define invp(a,p)pom(a,p-2,p)

//階乗,二項係数
//*
ll fact[100010];
ll invfact[100010];
void makefact(int n,ll m){
	fact[0]=1;
	rep(i,0,n)fact[i+1]=fact[i]*(i+1)%m;
	invfact[n]=invp(fact[n],m);
	for(int i=n;i>0;i--)invfact[i-1]=invfact[i]*i%m;
}
ll choose(int n,int r,int m){return n<0||r<0||n-r<0?0:fact[n]*invfact[r]%m*invfact[n-r]%m;}
//*/

int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	makefact(2010,m);
	ll ans=0;
	rep(i,1,n){
		ll temp=0;
		rep(j,0,n-i){
			//赤がi個で、黒n-i個のうちj個が赤と繋がっていない
			ll aaa=pom(pom(2,(n-i-j),m)-1,i,m)*choose(n-i,j,m)%m;
			temp+=j%2?-aaa:aaa;
		}
		ans+=temp%m*pom(2,i*(i-1)/2,m)%m*pom(2,(n-i)*(n-i-1)/2,m)%m*choose(n,i,m)%m;
	}
	printf("%lld\n",(ans%m+m)%m);
}


Measured memory_bytes: 2144
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
a=[list(map(int,input().split())) for i in range(n)]
d=-1000
x=0
for i in range(n):
  d=0
  for j in range(m):
    d+=a[i][j]*b[j]
  if d+c>0:
    x+=1
print(x)

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define repll(i,n) for(ll i = 0; i < n; i++)
#define REPll(i,n) for(ll i = 1; i < n; i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define yesorno(a) printf(a ? "yes\n" : "no\n")
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define YESorNO(a) printf(a ? "YES\n" : "NO\n") 
#define endl "\n"
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}


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

  ll x, y;
  cin >> x >> y;
  ll cnt = 0;
  for(ll i = x; i <= y; i *= 2) cnt++;
  cout << cnt << endl;
}

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

using namespace std;
using ll = long long;

int main()
{
    ll n;
    cin >> n;
    vector<int> v(n);
    for (auto &a : v)
        cin >> a;
    ll max_till_now = 1;
    ll ans = 0;
    for (ll a : v)
    {
        if (a < max_till_now)
            ans += (max_till_now - a);
        max_till_now = max(max_till_now, a);
    }

    cout << ans << '\n';

    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << ": " << x << '\n'

typedef long long int ll;
typedef pair<int, int> P;

const long long INF = 3e18 + 12;
const int inf = 1e9;

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

  int a, b;
  cin >> a >> b;
  string c;

  cin >> c;

  bool flag = true;

  rep(i, a) {
    if (!isdigit(static_cast<unsigned char>(c[i]))) {
      flag = false;
      debug(flag);
    }
  }

  if (c[a] != '-') flag = false;

  repi(i, a + 1, a + b) {
    if (!isdigit(static_cast<unsigned char>(c[i]))) {
      flag = false;
    }
  }

  if (flag) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
h = [] * n

h[:] = map(int, input().split())
dic={}
for i in range(len(h)):
    dic[i+1] = h[i]

graph = [[] for _ in range(n)]

for i in range(m):
    a,b = map(int, input().split())
    graph[a-1].append(b)
    graph[b-1].append(a)


count = 0

for i in range(n):
    more = 0
    n_h = dic[i+1]
    next = graph[i]
    
    for n in next:
        o_h = dic[n]
        if o_h >= n_h:
            more+=1
    
    if more == 0:
        count+=1

print(count)
        

Measured memory_bytes: 106136
import sys
n, k = map(int, input().split())

bai = 1
k_arr = []
while bai * k <= n:
    k_arr.append(bai * k)
    bai += 1


if k % 2 == 0:
    bai2 = 1
    k_arr2 = []
    k_arr2_len = 0 - len(k_arr2)
    while bai2 * k/2 <= n:
        k_arr2.append(bai2 * k/2)
        bai2 += 1
        k_arr2_len = len(k_arr2) - len(k_arr)
    print(len(k_arr)*len(k_arr)*len(k_arr) + k_arr2_len*k_arr2_len*k_arr2_len)

else:
    print(len(k_arr)*len(k_arr)*len(k_arr))


Measured memory_bytes: 13336
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
using PLL = pair<LL, LL>;
using VI = vector<int>;
using VVI = vector<vector<int>>;
const int INF = 1e9;
const int MXN = 0;
const int MXV = 1e5 + 5;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define FOR(i, L, R) for (int i = L; i < (int)R; ++i)
#define FORD(i, L, R) for (int i = L; i > (int)R; --i)
#define IOS                                                                    \
    cin.tie(nullptr);                                                          \
    cout.tie(nullptr);                                                         \
    ios_base::sync_with_stdio(false);
vector<int> dp(MXV, 0), din(MXV, 0);
vector<int> G[MXV];

int main()
{
    IOS;
    int n, m;
    cin >> n >> m;
    FOR(i, 0, m)
    {
        int f, t;
        cin >> f >> t;
        G[f].PB(t);
        ++din[t];
    }
    deque<int> q;
    FOR(i, 1, n + 1) if (din[i] == 0) { q.push_back(i); }
    int ans = 0;
    while (!q.empty())
    {
        int u = q.front();
        q.pop_front();
        ans = max(ans, dp[u]);
        for (int v : G[u])
        {
            if (dp[v] < dp[u] + 1)
            {
                dp[v] = dp[u] + 1;
            }
            --din[v];
            if (din[v] == 0)
            {
                q.push_back(v);
            }
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 9496
s = input()
n = len(s)
s_1 = s[:(n-1)//2]
s_2 = s[(n-1)//2 +1:]
s_1_new = ''.join(list(reversed(s_1)))
s_2_new = ''.join(list(reversed(s_2)))
s_new = ''.join(list(reversed(s)))
if s == s_new and s_1 == s_1_new and s_2 == s_2_new:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3188