akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<math.h>
#include<stdlib.h>

int main(){
  long n = 0;
  long a[100000] = {};
  long i=0;
  long sum = 0;
  long suma = 0;
  scanf("%ld",&n);
  for(i=0;i<n;i++){
    scanf("%ld",&a[i]);
  }
  
  for(i=1;i<n;i++){
    sum += labs(a[i]-a[i-1]);
  }
  //printf("%ld",sum);
  for(i=0;i<n;i++){
    suma = sum;
    if(i != 0 && i != n-1){
      suma = sum - labs(a[i-1] - a[i]) -labs(a[i+1] - a[i]) + labs(a[i-1]-a[i+1]);
      suma += labs(a[n-1]) + labs(a[0]);
    }else if(i == 0){
      suma = sum - labs(a[1] - a[0]);
      suma += labs(a[n-1]) + labs(a[1]);
    }else{
      suma = sum - labs(a[n-1]-a[n-2]);
      suma += labs(a[n-2]) + labs(a[0]);
    }
    printf("%ld\n",suma);
  }                                                               
  return 0;
}

  

Measured memory_bytes: 1920
//control+option+n to run!
#include <iostream>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include <math.h>
#include <fstream>
using namespace std;
//10^8 operations per second
//greatest int is 2,147,483,647
//greates long long is 9.22337204e18
int main()
{
    long long s, w;
    cin >> s >> w;
    if (s > w)
    {
        cout << "safe";
    }
    else
    {
        cout << "unsafe";
    }
}

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

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

    int k, n;
    cin >> k >> n;
    vector<int> as(n);
    for (int i = 0; i < n; i++) cin >> as[i];
    int nax = k - as.back() + as.front();
    for (int i = 1; i < n; i++) {
        nax = max(nax, as[i] - as[i - 1]);
    }
    cout << k - nax << endl;
}


Measured memory_bytes: 1152
n, m = map(int, input().split())
INF = 10**10
d = [[INF]*n for _ in range(n)]
for _ in range(m):
    a, b, c = map(int, input().split())
    d[a-1][b-1] = c
    d[b-1][a-1] = c
nxt = [[[i] for i in range(n)] for _ in range(n)]
for k in range(n):
    for i in range(n):
        for j in range(n):
            if i==j:
                continue
            if d[i][k]+d[k][j] < d[i][j]:
                d[i][j] = d[i][k]+d[k][j]
                nxt[i][j] = nxt[i][k][:]
            elif d[i][k]+d[k][j] == d[i][j]:
                nxt[i][j] += nxt[i][k]
s = set()
for start in range(n):
    for goal in range(n):
        if start==goal:
            continue
        def DFS(i):
            for j in nxt[i][goal]:
                s.add((i, j))
                if j!=goal:
                    DFS(j)
        DFS(start)
print(m-len(s)//2)

Measured memory_bytes: 4516
#include <bits/stdc++.h>
using namespace std;
int ans[10001];
int main()
  {int N; cin >> N;
  for (int x = 1; x * x <= N; ++x) for (int y = 1; y * y <= N; ++y) for (int z = 1; z * z <= N; ++z)
    {auto n = x * x + y * y + z * z + x * y + y * z + z * x; if (n <= 10000) ++ans[n];}
  for (int n = 1; n <= N; ++n) cout << ans[n] << "\n";}

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

int main() {
   int a,b,c;
  string s;
  cin>>a;
  c=1;
  int count=0;
  double l;
  double sum=0;
  // a*2-1 times cout
  for(int i=0;i<a;i++){
    cin>>l;
    sum += 1.0/l; 
  }
  
  cout<<1.0/sum<<endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
an = []
an = [int(x) for x in input().split()]
bn = []
bn = [int(x) for x in input().split()]

sum = 0
rem = an[n]
for i in range(0, n):
    j = (n - 1) - i
    if rem + an[j] <= bn[j]:
        sum += rem + an[j]
        rem = 0
    else:
        sum += bn[j]
        rem = rem + an[j] - bn[j]
        if rem > an[j]:
            rem = an[j]

print(sum)






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

#define ll long long
#define vi vector<int>
#define pb push_back
#define P pair<int,int>
#define PP pair<P,int>
#define fi first
#define se second
#define INF (1<<30)
#define MOD 1000000007
#define all(a) (a).begin(),(a).end()
#define FOR(k,m,n) for(int(k)=(m);(k)<(m);(k)++)
#define REP(k,n) FOR((k),0,(n))

signed main(){
    string s;
    cin>>s;
    int ans=0;
    for(int i=0;i<s.length();i++){
        for(int j=i+1;j<s.length();j++){
            if(s[i]=='C'&&s[j]=='F'){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10; //1e-9?
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    string s; int d; cin >> s >> d;
    int n = s.length();
    VI k(n);
    FOR(i, 0, n)k[i] = s[i] - '0';

    auto dp = vec<ll>(n + 1, 2, d);
    dp[0][0][0] = 1;
    FOR(i, 0, n)FOR(small, 0, 2)eFOR(x, 0, (small ? 9 : k[i]))FOR(m, 0, d) {
        (dp[i + 1][small | (x < k[i])][(m + x) % d] += dp[i][small][m]) %= mod;
    }
    
    cout << (dp[n][0][0] + dp[n][1][0] - 1 + mod) % mod << "\n";
}

Measured memory_bytes: 17152
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

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

    for(;;){
        char ope;
        int a;
        cin >> ope >> a;

        if(ope == '='){
            cout << ret << endl;
            return 0;
        }

        if(ope == '+')
            ret += a;
        else if(ope == '-')
            ret -= a;
        else if(ope == '*')
            ret *= a;
        else
            ret /= a;
    }
}

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

ll N;
vector<ll> L;
ll l;
ll cn = 0;

int main(){
  cin >> N;

  for(int i = 0; i < N; i++){
    cin >> l; L.push_back(l);
  }

  sort(L.begin(), L.end());
  
  for(int i = 0; i < N; i++){
    for(int j = i+1; j < N; j++){
      int ite = (lower_bound(L.begin(), L.end(), L[i]+L[j]) - L.begin());
      cn += (ite-j-1);
    }
  }

  cout << cn << endl;
  return 0;
}
    

Measured memory_bytes: 256
n = int(input())
s = input()

def check(ox, l, m, r):
    if l == r:
        if (m == 'S' and ox == 'o') or (m == 'W' and ox == 'x'):
            return True
        else:
            return False
    else:
        return not check(ox, l, m, l)

for one in 'SW':
    for two in 'SW':
        a = one + two
        for i in range(2, n):
            if check(s[i-1], a[i-2], a[i-1], 'S'):
                a += 'S'
            else:
                a += 'W'
        if check(s[n-1], a[n-2], a[n-1], a[0]) and check(s[0], a[n-1], a[0], a[1]):
            print(a)
            exit()
print(-1)

Measured memory_bytes: 3444
a,b=map(int,input().split())
board=[['.']*100 for _ in range(100)]
pos=0
for i in range(0,(a-1)//50):
  for j in range(0,100,2):
    board[2*i][j+1]='#'
    board[2*i+1][j]='#'
    board[2*i+1][j+1]='#'
pos=2*((a-1)//50)
for j in range(0,2*((a-1)%50),2):
  board[pos][j+1]='#'
  board[pos+1][j]='#'
  board[pos+1][j+1]='#'
pos+=3
for i in range(0,(b-1)//50):
  for j in range(0,100,2):
    board[2*i+pos+1][j+1]='#'
pos+=2*((b-1)//50)
for j in range(0,2*((b-1)%50),2):
  board[pos+1][j+1]='#'
pos+=3
if a==1:
  board[pos+1][1]='#'
print(100,100)
for row in board:
  print(''.join(map(str,row)))

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

#define int long long

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

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

	priority_queue<int> pq;

	pq.push(a*c);
	pq.push(a*d);
	pq.push(b*c);
	pq.push(b*d);
	cout<<pq.top();

	return 0;
}

Measured memory_bytes: 3652
let readInt () = stdin.ReadLine() |> int

let next x = (10.0 ** (float x) |> int)

let rec solve c v =
    v
    |> string
    |> String.length
    |> fun x ->
        if x = 1 then
            c + v
        else if x % 2 = 0 then
            x
            - 1
            |> next
            |> fun z -> solve c (z - 1)
        else
            x
            - 1
            |> next
            |> fun z -> solve (c + v - z + 1) (z - 1)

() |> readInt |> solve 0 |> printfn "%d"


Measured memory_bytes: 30336
#include<iostream>
#include<string>
#include <bits/stdc++.h>
#include<vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <math.h>
#include <iomanip>
using namespace std;
using ll = long long;

int main(){
  int x;
  cin >> x;
  if(x == 0){
    cout << "1" << endl;
  }else{
    cout << "0" << endl;
  }

}


Measured memory_bytes: 3632
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.answer"
int main() {
	while (1) {
		int N, M; cin >> N >> M;
		if (!N)break;
		vector<vector<int>>edges(N);
		for (int i = 0; i < M; ++i) {
			int a, b; cin >> a >> b;
			a--; b--;
			edges[a].push_back(b);
			edges[b].push_back(a);
		}
		vector<int>comes(N);
		for (auto e : edges[0]) {
			comes[e] = true;
		}
		vector<int>friends(N);
		for (int i = 1; i < N; ++i) {
			if (comes[i]) {
				friends[i] = true;
				for (auto e : edges[i])friends[e] = true;
			}
		}
		int ans = count(friends.begin() + 1, friends.end(), 1);
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3252
N=int(input())
maxrank=10**5+1
minrank=0
minpoint=10**9+1
for i in range(N):
  a,b=map(int,input().split())
  maxrank=min(maxrank,a)
  minrank=max(minrank,a)
  minpoint=min(minpoint,b)
print((minrank-maxrank+1)+(maxrank-1)+minpoint)

Measured memory_bytes: 3064
#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
using base = complex<double>;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define M 1000000007
#define M2 998244353
#define ll long long
#define pll pair<long, long>
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
#define ff first
#define ss second
#define pb push_back
#define db pop_back
#define mp make_pair
#define mt make_tuple
#define g(a, b) get<a>(b)
#define INF (ll)1e18 + 100
#define vl vector<ll>
#define vi vector<int>
#define vll vector<pair<ll, ll>>
#define vii vector<pair<int, int>>
#define all(v) v.begin(), v.end()
#define bset(a, p) ((a) | (1ll << (p)))
#define bchk(a, p) ((a) & (1ll << (p)))
#define bxor(a, p) ((a) ^ (1ll << (p)));
#define brem(a, p) (bchk(a, p) ? (bxor(a, p)) : (a))
#define INT_SIZE 32
/*SOME BITMASK KNOWLEDGE
1)x & (x - 1):sets the last one bit of x to zero
power of two exactly when x & (x − 1) = 0.
2)x & -x:sets all the one bits to zero, except last one bit
3)x | (x - 1):inverts all the bits after the last one bit*/
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl

#define o_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define o_setll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set
ll powM(ll x, ll y, ll m)
{
	ll ans = 1, r = 1;
	x %= m;
	while (r > 0 && r <= y)
	{
		if (r & y)
		{
			ans *= x;
			ans %= m;
		}
		r <<= 1;
		x *= x;
		x %= m;
	}
	return ans;
}
ll modI(ll a, ll m)
{
	ll m0 = m, y = 0, x = 1;
	if (m == 1)
		return 0;
	while (a > 1)
	{
		ll q = a / m;
		ll t = m;
		m = a % m;
		a = t;
		t = y;
		y = x - q * y;
		x = t;
	}
	if (x < 0)
		x += m0;
	return x;
}

ll logint(ll x, ll y)
{
	ll ans = 0;
	ll a = 1;
	for (ll i = 0; i <= x; i++)
	{
		if (x < a)
		{
			return ans;
		}
		ans++;
		a *= y;
	}
	return -1;
}
ll extended(ll a, ll b, ll &x, ll &y)
{
	if (a == 0)
	{
		x = 0;
		y = 1;
		return b;
	}
	ll x1, y1;
	ll d = extended(b % a, a, x1, y1);
	x = y1 - (b / a) * x1;
	y = x1;
	return d;
}
void solve() {
	string s;
	cin>>s;
	REP(i,0,3){
		cout<<s[i];
	}

}



int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	// freopen("input.txt", "r", stdin);
	// freopen("input.txt", "w", stdout);
	ll ntc;
	// cin >> ntc;
	ntc = 1;
	REP(tc, 1, ntc + 1)
	{
		// cout << "Case #" << tc << ": ";
		solve();
	}
}

Measured memory_bytes: 3616
#include <stdio.h>

int main(){
  int X,Y,Z;
  scanf("%d %d %d",&X,&Y,&Z);
  int T;
  T=X;
  X=Y;
  Y=T;
  T=X;
  X=Z;
  Z=T;
  printf("%d %d %d\n",X,Y,Z);
  return 0;
}

Measured memory_bytes: 1724
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
	const int MOD = 10000;
	int pasta[3][3] = {0}; // 0d = 昨日パスタ, 1d = 今日パスタ
	int n, k;	// 桜乃かわいいよ桜乃
	vector<int> sc;	// スケジュール
	
	scanf("%d%d", &n, &k);
	sc.resize(n);
	for(int i = 0; i < k; ++i) {
		int a, b;
		scanf("%d%d", &a, &b);
		sc[a - 1] = b;
	}
	
	for(int i = 0; i < 3; ++i) {
		for(int j = 0; j < 3; ++j) {
			
			if(sc[0] == 0 || sc[0] == i + 1)
				if(sc[1] == 0 || sc[1] == j + 1)
					pasta[i][j] = 1;
		}
	}
	
	for(int day = 2; day < n; ++day) {
		
		int next[3][3] = {0};
		
		for(int i = 0; i < 3; ++i) {
			for(int j = 0; j < 3; ++j) {
				
				if(sc[day] == 0 || sc[day] == j + 1) {
					for(int p = 0; p < 3; ++p)
						if(!(p == i && i == j))
							next[i][j] += pasta[p][i];
				}
			}
		}
		
		for(int i = 0; i < 3; ++i)
			for(int j = 0; j < 3; ++j)
				pasta[i][j] = next[i][j] % MOD;
	}
	
	int sum = 0;
	for(int i = 0; i < 3; ++i)
		for(int j = 0; j < 3; ++j)
			sum += pasta[i][j];
			
	printf("%d\n", sum % MOD);
	
	return 0;
}

Measured memory_bytes: 1028
def examC():
    St = S()
    N = len(St)
    cur = int(0)
    ansC = [0]*(2**(N-1))
    for i in range(2**(N-1)):
        k = int(0)
        cur = int(0)
        for j in range(N-1):
            if (i>>j)%2==1:
#                print(St[k:j+1],i,j)
                cur += int(St[k:j+1])
                k = j+1
        cur += int(St[k:])
        ansC[i] = cur

    print(sum(ansC))

import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examC()


Measured memory_bytes: 39280
#include<cstdio>

char s[400000];
int main()
{
	int i=0,n,k;bool f=false;
	scanf("%d%d%s",&n,&k,s);
	while(i<n&&k--)
		if((s[i]=='A')^f)s[i]=f?'A':'B';
		else f^=1,s[n+i++]=f?'B':'A';
	if(++k)
	{
		if(n&1)putchar((s[i]=='A')^f^(k&1)?'B':'A');
		for(i=0;i<n>>1;i++)
			putchar('B'),putchar('A');
	}
	else
		if(f)
			for(int j=0;j<n;j++)
				putchar(s[i+j]=='A'?'B':'A');
		else
			puts(s+i);
}

Measured memory_bytes: 896
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
signed main(){
  init_io();
  ll n;
  string s;
  cin >> n >> s;
  vector<ll> a(n,0);
  for(int x=0;x<2;x++){
    for(int y=0;y<2;y++){
      a[0] = x;
      a[1] = y;
      for(int i=1;i<n-1;i++){
        //sheep
        if(a[i]==0){
          if(s[i]=='o'){
            a[i+1] = a[i-1];
          }else{
            a[i+1] = !a[i-1];
          }
        //wolf
        }else{
          if(s[i]=='o'){
            a[i+1] = !a[i-1];
          }else{
            a[i+1] = a[i-1];
          }
        }
      }
      bool is_ans=true;
      if(a[0]==0){
        if(s[0]=='o'&&a[1]!=a[n-1]){
          is_ans = false;
        }else if(s[0]=='x'&&a[1]==a[n-1]){
          is_ans = false;
        }
      }else{
        if(s[0]=='o'&&a[1]==a[n-1]){
          is_ans = false;
        }else if(s[0]=='x'&&a[1]!=a[n-1]){
          is_ans = false;
        }
      }
      if(a[n-1]==0){
        if(s[n-1]=='o'&&a[n-2]!=a[0]){
          is_ans = false;
        }else if(s[n-1]=='x'&&a[n-2]==a[0]){
          is_ans = false;
        }
      }else{
        if(s[n-1]=='o'&&a[n-2]==a[0]){
          is_ans = false;
        }else if(s[n-1]=='x'&&a[n-2]!=a[0]){
          is_ans = false;
        }
      }
      if(is_ans){
        for(int i=0;i<n;i++){
          if(a[i]==0) cout <<"S";
          else cout <<"W";
        }
        cout << endl;
        return 0;
      }
    }
  }
  cout << "-1\n";
}


Measured memory_bytes: 1360
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long int N,T,ans=0;
  cin >> N >> T;
  long long int t[N];
  for(int i=0; i<N; i++){
    cin >> t[i];
  }
  for(int i=0; i<N-1; i++){
    if(t[i]+T>t[i+1]){
      ans+=t[i+1]-t[i];
    }else{
      ans+=T;
    }
  }
  cout << ans+T << endl;
}

Measured memory_bytes: 1792
import java.util.HashSet;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		HashSet<Integer> set = new HashSet<>();

		for (int i = 0; i < n; i++) {
			set.add(sc.nextInt());
		}
		System.out.println(set.size());

	}
}


Measured memory_bytes: 22868
#include<stdio.h>

int main(){
    int R;
    scanf("%d",&R);
    if(R < 1200){
        printf("ABC\n");
        return 0;
    }
    if(R < 2800){
        printf("ARC\n");
        return 0;
    }

    printf("AGC\n");
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
//#include <tuple>
//#include <array>

// BEGIN CUT HERE
#ifdef _MSC_VER
#include <agents.h>
#endif
// END CUT HERE 

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) begin(v), end(v)
#define REV(v) rbegin(v), rend(v)
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define MP make_pair
#define MT make_tuple
#define X first
#define Y second

using namespace std;

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

const int MOD = 11;

int main(){
	string s;
	while (cin >> s, s != "0"){
		int ans = 0;
		vector<int> cnt(MOD);

		rep(i, s.size()){
			int x = s[i] - '0';
			vector<int> nxt(MOD);
			rep(j, MOD) nxt[(j*10 + x) % MOD] = cnt[j];
			cnt.swap(nxt);
			if(x) ++cnt[x];
			ans += cnt[0];
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1320
#include<iostream>
#include<algorithm>
#include<stdio.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define pi 3.14159265358979
int main() {
	double r;
	cin >> r;
	double x, y;
	x = r * r * pi;
	y = r * 2 * pi;
	printf("%.8f %.8f \n", x, y);
	return 0;
}


Measured memory_bytes: 3292
word = input()
q = int(input())

for _ in range(q):
    od = list(map(str, input().split()))

    if od[0] == "print":
        print(word[int(od[1]): int(od[2]) + 1])

    elif od[0] == "reverse":
        if int(od[1]) == 0:
            word = "{}{}{}".format(word[: int(od[1])], word[int(
                od[2])::-1], word[int(od[2]) + 1:])
        else:
            word = "{}{}{}".format(word[: int(od[1])], word[int(
                od[2]): int(od[1]) - 1:-1], word[int(od[2]) + 1:])

    elif od[0] == "replace":
        word = "{}{}{}".format(
            word[: int(od[1])], od[3], word[int(od[2]) + 1:])



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


// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

#define int               long long
#define endl              '\n'
#define ff                first
#define ss                second
#define mp                make_pair
#define pb                push_back
#define vii               vector<int> 
#define pii               pair<int,int>
#define vpii              vector< pii >
#define all(v)            v.begin(),v.end()
#define loop(i,s,e)       for(int i=s;i<e;i++)
#define rloop(i,e,s)      for(int i=e;i>=s;i--)
#define mset(a,f)              memset(a,f,sizeof(a))
#define M                 1000000007
#define fastio            ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define prvec(v)          loop(i_u_j,0,v.size())cout << v[i_u_j] <<" "; cout << endl;
#define prarr(arr,n)      loop(i_u_j,0,n)cout << arr[i_u_j] << " "; cout << endl;
#define bug(...)        __f (#__VA_ARGS__, __VA_ARGS__)


template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //
const int N = 403;
int n;
int arr[N], dp[N][N];
const int INF = 1e18L;

int sum(int l, int r)
{
      int s= 0 ;
      loop(i,l, r+1) s+= arr[i];
      return s;
}
void solve()
{
      cin >> n;
      loop(i,0,n) cin >> arr[i];
      rloop(i,n-1,0)
      {
            loop(j,i,n)
            {     
                  if( i == j ) dp[i][j] = 0;
                  else dp[i][j] = INF;

                  int s = sum(i,j);
                  for(int k = i; k <= j; k++)
                  {
                        dp[i][j] = min( dp[i][j], dp[i][k] + dp[k+1][j] + s);
                  }
            }
      }
      cout << dp[0][n-1];

}

int32_t main() {
    fastio;

  int t = 1; 
  //cin>>t;
  
  while(t--) solve();
  
  


}


// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //















Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
 
int main(){
string SA,SB,SC;
  cin >> SA >> SB >> SC;
char ima = 'a';
bool z = true;
  
for(int i = 0;i < 305;i++){
  if((ima == 'a') && (SA.size() == 0)){ z = false; cout << "A" << endl; break;}
  if((ima == 'b') && (SB.size() == 0)){ z = false; cout << "B" << endl; break;}
  if((ima == 'c') && (SC.size() == 0)){ z = false; cout << "C" << endl; break;}
    
    if(z){
      if(ima == 'a'){ima = SA.at(0); SA.erase(0,1);}
      else if(ima == 'b'){ima = SB.at(0); SB.erase(0,1);}
      else if(ima == 'c'){ima = SC.at(0); SC.erase(0,1);} 
    }
  }
}

Measured memory_bytes: 256
main=do
 [a,b,c,d]<-map read.words<$>getLine
 putStrLn$(f(c-a)(d-b))++"LULU"++(f(c-a)(d-b))
f x y=(take y$repeat 'U')++(take(x+1)$repeat 'R')++(take(y+1)$repeat 'D')++(take x$repeat 'L')

Measured memory_bytes: 1020
class UnionFind:
    def __init__(self, N):
        """
        N:要素数
        root:各要素の親要素の番号を格納するリスト.
             ただし, root[x] < 0 ならその頂点が根で-root[x]が木の要素数.
        rank:ランク
        """
        self.N = N
        self.root = [-1] * N
        self.rank = [0] * N

    def __repr__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

    def find(self, x):
        """頂点xの根を見つける"""
        if self.root[x] < 0:
            return x
        else:
            while self.root[x] >= 0:
                x = self.root[x]
            return x

    def union(self, x, y):
        """x,yが属する木をunion"""
        # 根を比較する
        # すでに同じ木に属していた場合は何もしない.
        # 違う木に属していた場合はrankを見てくっつける方を決める.
        # rankが同じ時はrankを1増やす
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        elif self.rank[x] > self.rank[y]:
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if self.rank[x] == self.rank[y]:
                self.rank[y] += 1

    def same(self, x, y):
        """xとyが同じグループに属するかどうか"""
        return self.find(x) == self.find(y)

    def count(self, x):
        """頂点xが属する木のサイズを返す"""
        return - self.root[self.find(x)]

    def members(self, x):
        """xが属する木の要素を列挙"""
        _root = self.find(x)
        return [i for i in range(self.N) if self.find == _root]

    def roots(self):
        """森の根を列挙"""
        return [i for i, x in enumerate(self.root) if x < 0]

    def group_count(self):
        """連結成分の数"""
        return len(self.roots())

    def all_group_members(self):
        """{ルート要素: [そのグループに含まれる要素のリスト], ...}の辞書を返す"""
        return {r: self.members(r) for r in self.roots()}


import sys
input = sys.stdin.readline
n, q = map(int, input().split())
ans = [0, 1]
uf = UnionFind(n)
for i in range(q):
    t, u, v = map(int, input().split())
    if t:
        print(ans[uf.same(u, v)])
    else:
        uf.union(u, v)


Measured memory_bytes: 77304
#include <iostream>		//cin, cout
#include <algorithm>	//max()
#include <cmath>		//abs()
using namespace std;

int d, n;
int t[200];
int a[200], b[200], c[200];
int dp[201][200];			//dp[day][fuku] = sum????????§???
int ans = -1145141919;		//??????

//dp????????????????????¨?????????????????´??°??§????????°???ans????±?????????????
void makeAns(){
	int day, fuku, i;
	
	//?????????
	for( day = 0; day < d + 1; day++ ){
		for( fuku = 0; fuku < n; fuku++ )
			dp[day][fuku] = -114514;
	}
	for( fuku = 0; fuku < n; fuku++ ){
		if( a[fuku] <= t[0] && t[0] <= b[fuku] )
			dp[1][fuku] = 0;	//0??\?????????fuku???????????´???
	}
	
	//dp???????????´??°
	for( day = 1; day < d; day++ ){
		for( fuku = 0; fuku < n; fuku++ ){
			//day??\?????????????±???????(????§?)
			for( i = 0; i < n; i++ ){
				if( a[i] <= t[day] && t[day] <= b[i] ){
					//day??\?????????i?????????
					dp[day + 1][i] = max(dp[day + 1][i], dp[day][fuku] + abs(c[fuku] - c[i]));
				}
			}
		}
	}
	
	//??????????¨??????????
	for( i = 0; i < n; i++ ){
		ans = max(ans, dp[d][i]);
	}
}

int main()
{
	int i, j;
	cin >> d >> n;
	for( i = 0; i < d; i++ ) cin >> t[i];
	for( i = 0; i < n; i++ ) cin >> a[i] >> b[i] >> c[i];
	makeAns();
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1320
#include <functional>
#include <algorithm>
#include <stdexcept>
#include <iostream>
#include <sstream>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <cctype>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <queue>
#include <stdint.h>
#include <stdio.h>
#include <stack>
#include <ctime>
#include <list>
#include <map>
#include <set>
#include <tuple>
#include <unordered_set>
#include <assert.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define TR(i,x) for(__typeof(x.begin()) i=x.begin();i!=x.end();i++)
#define ALL(x) x.begin(),x.end()
#define SORT(x) sort(ALL(x))
#define CLEAR(x) memset(x,0,sizeof(x))
#define FILL(x,c) memset(x,c,sizeof(x))

using namespace std;

#define PB push_back
#define MP make_pair

typedef map<int,int> MII;
typedef map<string,int> MSI;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<long double> VD;
typedef pair<int,int> PII;
typedef long long int64;
typedef long long LL;
typedef unsigned int UI;
typedef long double LD;
typedef unsigned long long ULL;

const int N = 101;

LL dp[N][N][N * 3];

int main() {
    int n, w;
    cin >> n >> w;
    VI value(n), weight(n);
    REP(i, n) cin >> weight[i] >> value[i];
    REP(i, n) {
        REP(j, n + 1) {
            REP(k, 3 * n + 1) {
                dp[i + 1][j][k] = max(dp[i + 1][j][k], dp[i][j][k]);
                int dw = weight[i] - weight[0];
                if (j < n && k + dw <= 3 * n) {
                    dp[i + 1][j + 1][k + dw] = max(dp[i + 1][j + 1][k + dw], dp[i][j][k] + value[i]);
                }
            }
        }
    }
    LL ans = 0;
    REP(j, n + 1) REP(k, 3 * n + 1) {
        if (j * (LL) weight[0] + k <= w) {
            ans = max(ans, dp[n][j][k]);
        }
    }
    cout << ans << endl;
    return 0;
}

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

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;
  cin >> N;
  ll a = 1, b = N;
  for (ll i = 1; i * i <= N; ++i) {
    if (N % i == 0) a = i, b = N / i;
  }
  cout << (a - 1) + (b - 1) << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

void caluc(int buf[], int a[], int n)
{
    int i;

    for (i = 1; i < n; i++) {
        a[buf[i]]++;
    }
}

int main()
{
    int n, i;
    int buf[200000];
    int a[200001] = {0};

    scanf("%d", &n);

    for (i = 1; i < n; i++) {
        scanf("%d", &buf[i]);
    }
    caluc(buf, a, n);
    for (i = 0; i < n; i++) {
        printf("%d\n", a[i+1]);
    }

    return 0;
}

Measured memory_bytes: 3296
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>

using namespace std;



int main(){

	int count = 0;
	int arr[250000];
	int N;

	while(1){
		count = 0;
		scanf("%d",&N);

		if(N == 0){
			return 0;
		}
		if(N == 1){
			count = 1;
			goto loop;
		}
		for(int i = 0; i < 2*N; i++){
			arr[i] = 1;
		}
		for(int i = 2; i < sqrt(2*N); i++){
			if(arr[i]){
				for(int j = 0; i * (j + 2) < 2*N; j++){
					arr[i *(j + 2)] = 0;
				}
			}
		}
		for(int i = 2; i < 2*N; i++){
			if(arr[i]){
				if(i > N){
					count++;
				}
			}
		}

	loop:
		printf("%d\n",count);
	}
}

Measured memory_bytes: 2160
r,c = [ int(s) for s in input().split() ]
sheet = [ [0]*(c+1) for i in range(r+1) ]
total_row = [0]*(c+1)

for i in range(r):
    row = [ int(s) for s in input().split() ]
    sheet[i][:c+1] = row + [sum(row)]
    total_row[:c+1] = [ total_row[j] + sheet[i][j] for j in range(c+1) ]

sheet[r][:c+1] = total_row

for i in range(r+1):
    print(*sheet[i])


Measured memory_bytes: 6212
N = int(input())
W = list(map(int, input().split()))

ans = sum(W)
for T in range(N): # Tは0からN-1
    s_1 = 0
    for i in range(T): # iは0からT-1
        s_1 += W[i]
    s_2 = sum(W) - s_1
    ans = min(ans, abs(s_1 - s_2))

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll N=1e5+5;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    string s;cin>>s;

    ll a=0,b=0,c=0,d=0;
    for(ll i=0;i<s.size();i++){
        if(s[i]=='N')a++;
        else if(s[i]=='S')b++;
        else if(s[i]=='E')c++;
        else d++;
    }

    bool f1=0,f2=0;
    if(a==0 && b==0)f1=1;
    if(c==0 && d==0)f2=1;
    if(a>0 && b>0)f1=1;
    if(c>0 && d>0)f2=1;

    cout<<(f1&&f2?"Yes":"No");
}



Measured memory_bytes: 256
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 998244353


n = INT()
d = MAP()

if d[0]!=0 or not all(d[1:]):
    print(0)
    exit(0)

l = [0]*(max(d)+1)
for i in d:
    l[i]+=1

ans=1
for i in range(1,max(d)+1):
    ans*=pow(l[i-1],l[i],MOD)
    ans %= MOD
print(ans)

Measured memory_bytes: 14396
/*
          ,     \    /      ,
         / \    )\__/(     / \
        /   \  (_\  /_)   /   \
   ____/_____\__\@  @/___/_____\____
  |             |\../|              |
  |              \VV/               |
  |        ------hoi-------         |
  |_________________________________|
   |    /\ /      \\       \ /\    |
   |  /   V        ))       V   \  |
   |/     `       //        '     \|
   `              V                '
*/

#include <bits/stdc++.h>

#define ull unsigned long long
#define ll long long
#define pb push_back
#define f first
#define se second
#define mp make_pair
#define Speedforce boost();

using namespace std;

void boost(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

const int N = 1e6;
const int inf = 1e9 + 7;

int n;
int a[205];

int main() {
    Speedforce
    cin >> n;
    for(int i = 1;i <= 2 * n;i ++){
        cin >> a[i];
    }
    int sum = 0;
    sort(a + 1, a + 1 + 2 * n);
    for(int i = 2 * n - 1;i >= 1;i -= 2){
        sum += a[i];
    }
    cout << sum;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>

using namespace std;
typedef long long ll;


vector<vector<pair<ll, ll > > > G;
//行きがけ順番を記憶
vector<ll > pre;
//頂点から到達しうる最小の頂点
vector<ll > low;
vector<pair<ll, ll > > ans;
//カウンター
ll dfs(ll idx, ll from = -1, ll pre_count = -1){
    /*
    if(pre[idx] == -1){
        pre[idx] = pre_count;
        low[idx] = pre[idx];
        pre_count++;
    }
    */

    pre[idx] = pre_count++;
    low[idx] = pre[idx];


    for(ll i = 0; i < G[idx].size(); i++){
        //cout << idx << endl;
        //次の行き先は？
        ll to = G[idx][i].first;
        
        if(pre[to] == -1){
            low[idx] = min(low[idx], dfs(to, idx, pre_count));
            //dfs(to, idx, pre_count);
            //low[idx] = min(low[idx], low[to]);
            if(low[to] == pre[to]){
                ans.push_back(make_pair(idx, to));
            }
        }else{
            
            if(from == to){
                continue;
            }

            low[idx] = min(low[idx], low[to]);
        }
 
    }

    return low[idx];
}


int main(){
    ll N, M;
    cin >> N >> M;
    
    //初期化
    G.assign(N, vector<pair<ll, ll > >());
    //ns.assign(N, 0);
    pre.assign(N, -1);
    low.assign(N, -1);
 
    //グラフ入力
    for(ll i = 0; i < M; i++){
        ll u, v;
        //重みは今回は0
        ll w = 0;
        cin >> u >> v;
        u--;
        v--;
        //双方向に貼りましょうね
        G[u].push_back(make_pair(v, w));
        G[v].push_back(make_pair(u, w));
    }

    dfs(0);
    cout << ans.size() - 1<< endl;
    /* 
    for(ll i = 0; i < N; i++){
        cout << pre[i] << "," << low[i] << endl;
    }
    */

}

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

using namespace std;
int main()
{
	int x,n,k=0,l,c=0,i,u;
cin>>x>>n;
l=x;
u=x;
int p[n];

for(i=0;i<n;i++)
cin>>p[i];
x:
for(i=0;i<n;i++)
{
	if(p[i]==x)
	{
		x--;
		goto x;
		break;
	}
}
y:
for(i=0;i<n;i++)
{
	if(p[i]==l)
	{
		l++;
		goto y;
		break;
	}
}
if(abs(u-x)>abs(u-l))
cout<<l;
else 
cout<<x;
}

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

#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define ll long long
#define all(x) (x).begin(),(x).end()

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

	vector<int> h(n);
	rep(i, n){
		cin >> h[i];
	}

	int ans = 1;
	int buf = h[0];
	rept(i, 1, n){
		buf = max(buf, h[i]);
		if(buf <= h[i]){
			ans++;
		}
	}

	cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
////////////////////////// Author
////////////////////////// Nasim Hossain Rabbi
////////////////////////// JU-CSE28
////////////////////////// CF - imnasim3.1415
////////////////////////// UVA - imnasim3.1415
////////////////////////// Mail - imnasim3.1415@gmail.com
#include<bits/stdc++.h>
using namespace std;
#define E end()
#define B begin()
#define sz size()
#define EM empty()
#define fi first
#define se second
#define cl clear()
#define sqr(a) (a*a)
#define mk make_pair
#define pb push_back
string en="\n";
string sp=" ";
string t="hello";
string Y="YES\n";
string N="NO\n";
#define rep(i,n) for(i=0;i<n;i++)
#define Rep(i,n) for(i=1;i<=n;i++)
#define per(i,n) for(i=n-1;i>=0;i--)
#define peR(i,n) for(i=n;i>0;i--)
#define mem(a,b) memset(a,b,sizeof(a))
#define all(cont) cont.begin(),cont.end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define pi 3.1415926535897932384626433832795
#define vi vector<long long>
#define vs  vector<string>
#define MX LLONG_MAX
#define MN LLONG_MIN
#define MOD 1000000007
#define vp(vi,x) cin>>x; vi.pb(x);
#define bsearch(a,x) binary_search(all(a),x)
#define LB(a,x) (lower_bound(all(a),x)-a.B)
#define UB(a,x) (upper_bound(all(a),x)-a.B)
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
bool isprm(LL a){for(LL i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
bool palin(string a){for(int i=0;i<a.sz;i++){if(a.at(i)!=a.at(a.sz-i-1))return 0;} return 1;}
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
int toInt(string s){int sm;stringstream ss(s);ss>>sm;return sm;}
LL bpow(LL a,LL b){if(b==0)return 1;LL r=bpow(a,b/2);if(b%2)return r*r*a;else return r*r;}
LL binpow(LL a,LL b){LL r=1;while(b>0){if(b&1)r=r*a;a=a*a;b>>=1;}return r;}
LL binpow(LL a,LL b,LL m){a%=m;LL r=1;while(b>0){if(b&1) r=r*a%m;a=a*a%m; b>>=1;}return r;}
template<typename T>inline T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<typename T>inline T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
int main()
{
//    fast;
    LL i,j,k,n,m,l,s=0,x,y,tc=1,p,q,a,b,c=0;
    bool f=0,ff=0;
    string st;
    while(cin>>n>>l)
    {
        map<string,int>ss;
        while(n--)
        {
            cin>>st;
            ss[st]++;
        }
        string sss;
        for(auto it=ss.B;it!=ss.E;it++)
        {
            st=it->first;
            x=it->second;
            while(x--)sss+=st;
        }
        cout<<sss<<en;
    }
}




Measured memory_bytes: 3652
#include <iostream>
#include <queue>
#include <utility>
#include <functional>
#include <vector>
using namespace std;
int cost[100][100];
int prim(int n,int s){
	typedef pair<int,int> P;
	bool ischeck[n];
	int mincost = 0;
	priority_queue<P,vector<P>,greater<P> > pq;
	P p,tp;
	for(int i = 0;i < n;++i){
		ischeck[i] = false;
		if(cost[s][i] != -1){
			p.first = cost[s][i];
			p.second = i;
			pq.push(p);
		}
	}
	ischeck[s] = true;
	while(!pq.empty()){
		p = pq.top();
		pq.pop();
		if(ischeck[p.second]) continue;
		else{
			ischeck[p.second] = true;
			mincost += p.first;
			for(int i = 0;i < n;++i){
				if(cost[p.second][i] != -1){
					tp.first = cost[p.second][i];
					tp.second = i;
					pq.push(tp);
				}
			}
		}
	}
	return mincost;
}
int main(){
	int n;
	cin >> n;
	for(int i = 0;i < n;++i){
		for(int j = 0;j < n;++j){
			cin >> cost[i][j];
		}
	}
	cout << prim(n,0) << endl;
}

Measured memory_bytes: 1360
#include<iostream>
#include<cmath>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
	int n,cnt=0;cin>>n;
	char c;
	string a[110];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		int f=0;
		if(i>0)
		{
			for(int j=0;j<i;j++)
			{
				if(a[j]==a[i])f=1;
			}
		}
		if((i==0||a[i][0]==c)&&f==0)cnt++;
		c=a[i][a[i].length()-1];
	}
	if(cnt==n)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;	
}		

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define f first
#define s second
#define mp make_pair
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	string s;
	cin>>s;
	int a[26]={0};
	for(char it: s)
	{
		a[it-'a']++;
	}
	bool f =0;
	for(int i =0;i<26; i++)
		if(a[i]&1)
			f=1;
	if(f)
		cout<<"No"<<endl;
	else
		cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<unordered_set>
#include<unordered_map>
#include<random>
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

int N, K;
bool snuke[100] ={};

signed main(){
    cin >> N >> K;
    rep(i, K){
        int d;
        cin >> d;
        rep(j, d){
            int a;
            cin >> a;
            snuke[a-1] = true;
        }
    }

    int ans = 0;
    rep(i, N)
        if(!snuke[i]) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 3672
import java.util.*;
import java.awt.Frame;
import java.io.*;

public class Main {
	// static ArrayList<Integer>[] g;

	static pair[] a;
	static int[][] memo;

	static int dp(int l, int r) {
		if (l > r)
			return 0;
		if (memo[l][r] != -1)
			return memo[l][r];
		int ans = dp(l + 1, r);
		ans = Math.max(ans, dp(l, r - 1));
		for (int idx : startAt[l]) {
			if (a[idx].y >= r)
				continue;
			int inc = exist[a[idx].y + 1][r] ? 1 : 0;
			ans = Math.max(ans, 1 + dp(a[idx].x, a[idx].y) + inc + dp(a[idx].y + 1, r));
		}
		for (int idx : endAt[r]) {
			if (a[idx].x <= l)
				continue;
			int inc = exist[l][a[idx].x - 1] ? 1 : 0;
			ans = Math.max(ans, 1 + dp(a[idx].x, a[idx].y) + inc + dp(a[idx].y + 1, r));
		}

		return memo[l][r] = ans;
	}

	public static void main(String[] args) throws NumberFormatException, IOException, InterruptedException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(System.out);

		char[] s=br.readLine().toCharArray();
		char[] t=br.readLine().toCharArray();
		int min=Integer.MAX_VALUE;
		for (int i = 0; i+t.length <= s.length; i++) {
			int c=0;
			for (int j = 0; j <t.length ; j++) {
				if(t[j]!=s[i+j])
					c++;
			}
			min=Math.min(min, c);
		}
		pw.println(min);
		pw.flush();
		pw.close();

	}

	static ArrayList<Integer> primes;
	static int[] isComposite;

	static void sieve(int N) // O(N log log N)
	{
		isComposite = new int[N + 1];
		isComposite[0] = isComposite[1] = 1; // 0 indicates a prime number
		primes = new ArrayList<Integer>();

		for (int i = 2; i <= N; ++i) // can loop till i*i <= N if primes array is not needed O(N log log sqrt(N))
			if (isComposite[i] == 0) // can loop in 2 and odd integers for slightly better performance
			{
				primes.add(i);
				if (1l * i * i <= N)
					for (int j = i * i; j <= N; j += i) // j = i * 2 will not affect performance too much, may alter in
														// modified sieve
						isComposite[j] = 1;
			}
	}

	static long pow(long a, long e, int mod) // O(log e)
	{
		long res = 1;
		while (e > 0) {
			if ((e & 1) == 1) {
				res *= a;
				res %= mod;
			}
			a *= a;
			a %= mod;
			e >>= 1;
		}
		return res;
	}

	static int maxSize;
	static boolean[][] exist;
	static ArrayList<Integer>[] startAt, endAt;

	static void compress(pair[] arr) {
		TreeSet<Integer> tr = new TreeSet<>();
		for (int i = 0; i < arr.length; i++) {
			tr.add(arr[i].x);
			tr.add(arr[i].y);
		}
		tr.add(0);
		tr.add((int) 1e9);
		HashMap<Integer, Integer> hm = new HashMap<>();
		for (int x : tr)
			hm.put(x, hm.size());
		for (int i = 0; i < arr.length; i++) {
			arr[i].x = hm.get(arr[i].x);
			arr[i].y = hm.get(arr[i].y);
		}
		maxSize = hm.size();
	}

	static class pair implements Comparable<pair> {
		int x;
		int y;

		public pair(int d, int u) {
			x = d;
			y = u;
		}

		@Override
		public int compareTo(pair o) {
			// TODO Auto-generated method stub
			int x1 = y - x;
			int x2 = o.y - o.x;
			return x1 - x2;
		}

	}

}

Measured memory_bytes: 33048
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <utility>
#include <math.h>

using namespace std;

#define ll long long

int main(){
    ll N;
    cin >> N;
    ll d[N];
    multimap<ll, ll> mp;
    for(ll i = 0; i < N; i++){
        cin >> d[i];
        mp.insert(make_pair(d[i],i));
    }
    auto itr = mp.begin();
    for(ll i = 0; i < mp.size()/2 - 1; i++)itr++;
    ll K = -(itr->first);
    itr++;
    K += itr->first;
    cout << K << endl;
    return 0;
}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  string S;
  cin >> S;
  vector<int> alphabet(26);
  rep(i, S.size())
  {
    alphabet[S[i] - 'a']++;
  }
  int ans = 0;
  rep(i, 26)
  {
    if (alphabet[i] == 0)
    {
      char c = i + 'a';
      cout << S + c << endl;
      return 0;
    }
  }
  int N = S.size();
  rep(i, N)
  {
    int c = S.back() - 'a';
    alphabet[c]--;
    S.pop_back();
    for (int j = c + 1; j < 26; j++)
    {
      if (alphabet[j] == 0)
      {
        c = j + 'a';
        S += c;
        cout << S << endl;
        return 0;
      }
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 2000000

void inNumber(int[]);
int desideK(int[]);
void countingSort(int[],int[],int);

int n=0;
int B[N];

int main(){

  int k=0,i;
  int A[N];
  A[0]=0; 
  
  scanf("%d",&n);
  inNumber(A);
  k = desideK(A);
  countingSort(A,B,k);
  
  return 0;
}

void inNumber(int A[]){

  int i;

  for(i=1;i<=n;i++){
    scanf("%d",&A[i]);
  }  
}
int desideK(int A[]){
  int i,k=0;
  for(i=1;i<=n;i++){
    if(k<A[i]){
      k=A[i];
    }
  } 
  return k;
}
void countingSort(int A[],int B[],int k){

   int i,j;
   int C[k+1];
 
   for(i=0;i<=k;i++){
     C[i]=0;
   } 
 
   for(j=1;j<=n;j++){
     C[A[j]]++;
   }
 
   for(i=1;i<=k;i++){
     C[i]+= C[i-1];
   }

   for(j = n; j > 0; j--){
     B[C[A[j]]]=A[j];
     C[A[j]]--; 
   }
   // fprintf( stderr, "Check\n" );
   for(i=1;i<=n;i++){
     
     if(i > 1){
       printf(" ");
     }
     printf("%d",B[i]);
   }
   
   printf("\n");
}

Measured memory_bytes: 16268
#include <bits/stdc++.h>
using namespace std;
string s;
int main(){
    cin >> s;
    int n = s.size();
    if(n>=4){
        if(s[0]=='Y' && s[1]=='A' && s[2]=='K' && s[3]=='I'){
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");
    return 0;
}


Measured memory_bytes: 256