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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define ll long long

int main(){
	ll n;
	cin >> n;
	float ans = 0;
	REP(i, n){
		float val;
		string cur;
		cin >> val >> cur;
		if (cur == "JPY"){ans += val;}
		else {ans += 380000 * val;}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<cstdio>
int main(){for(int n,a,c,r,t;c=0,r=scanf("%d",&n),n;printf("%d\n",r))for(char d[]="123456",s[9];n--;r+=*d-48)scanf("%s",s),*s%6-4?a=(*s-78?*s%5-1:0)+c&3,a=a+1+(1-a%2*2)*(a/2),t=*d,*d=d[a],d[a]=d[5],d[5]=d[5-a],d[5-a]=t:c+=*s+3;}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long       ll;
typedef pair<int,int>   pii;
typedef vector<int>     vi;
typedef long double     ld;
#define MOD         1000000007
#define pb          push_back
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define endl        '\n'
#define PI          3.14159265359d
#define sz(x)       (int)x.size()
int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    ll t,res=1,g;
    cin>>n;
    while(n--)
    {
        cin>>t;
        g=__gcd(res,t);
        res=(res/g)*t;
    }
    cout<<res;
    return 0;
}


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

using namespace std;

typedef pair<int, int> P;

int main() {
	int H, W, N;
	cin >> H >> W >> N;
	vector<P> px(N), py(N);
	for (int i = 0; i < N; i++) {
		int a, b;
		cin >> a >> b;
		px[i] = P(a, b);
		py[i] = P(b, a);
	}

	sort(px.begin(), px.end());
	sort(py.begin(), py.end());
	vector<int> mpx(N), mpy(N);
	mpx[N - 1] = px[N - 1].second;
	for (int i = N - 2; i >= 0; i--) {
		mpx[i] = max(mpx[i + 1], px[i].second);
	}
	mpy[N - 1] = py[N - 1].second;
	for (int i = N - 2; i >= 0; i--) {
		mpy[i] = max(mpy[i + 1], py[i].second);
	}
	int ans = 114514;
	for (int i = 0; i < N; i++) {
		if (i + 1 != N)
			ans = min(ans, px[i].first + mpx[i + 1]);
		else
			ans = min(ans, px[i].first);
	}
	for (int i = 0; i < N; i++) {
		if (i + 1 != N)
			ans = min(ans, py[i].first + mpy[i + 1]);
		else
			ans = min(ans, py[i].first);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 5160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;



int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while(true){
        c -= b;
        if(c <= 0){
            cout << "Yes" << endl;
            return 0;
        }
        a -= d;
        if(a <= 0){
            cout << "No" << endl;
            return 0;
        }
    }

   

}

Measured memory_bytes: 3576
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	scanner.Scan()

	r, err := strconv.Atoi(scanner.Text())
	if err != nil {
		log.Fatal(err)
	}

	fmt.Println(r * r)
}


Measured memory_bytes: 1832
#include <iostream>
#include <algorithm>
#include <climits>
#include <bitset>
#include <cmath>
using namespace std;

int main(){
  int d, g; cin >> d >> g;
  int p[d], c[d];
  for(int i=0; i<d; i++){
    cin >> p[i] >> c[i]; 
  }
    
  int q = 1 << d;

  int ans = INT_MAX;
  for(int i=0; i < q; i++){
    int rest = g;
    int cnt = 0;
    int h = -1;

    bitset<10> b(i);
    for(int j = 0; j < d; j++){
      if(b[j]){
        rest -= (j+1) * p[j] * 100 + c[j];
        cnt += p[j];
      }
      else{
        h = max(h, j);
      }
    }

    if(rest > 0){
      if((h+1) * p[h] * 100 < rest) continue;
      cnt += (int)ceil(rest * 1.0 / ((h+1) * 100));
    }

    ans = min(ans, cnt);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
def pow(mat, k, mod):
    n = len(mat)
    if k == 0:
        return [[1 if i == j else 0 for i in range(n)] for j in range(n)]
    if k % 2 == 0:
        sqrt_mat = pow(mat, k // 2, mod)
        # calculate 'sqrt_mat * sqrt_mat'
        ret = [[0 for _ in range(n)] for _ in range(n)]
        for i in range(n):
            for j in range(n):
                v = 0
                for k in range(n):
                    v += sqrt_mat[i][k] * sqrt_mat[k][j]
                    v %= mod
                ret[i][j] = v
        return ret
    else:
        powmat = pow(mat, k - 1, mod)
        # calculate 'mat * powmat'
        ret = [[0 for _ in range(n)] for _ in range(n)]
        for i in range(n):
            for j in range(n):
                v = 0
                for k in range(n):
                    v += mat[i][k] * powmat[k][j]
                    v %= mod
                ret[i][j] = v
        return ret


def main():
    MOD = 10 ** 9 + 7
    N, K = list(map(int, input().split(' ')))
    A = [list(map(int, input().split(' '))) for _ in range(N)]
    D = pow(A, K, MOD)
    ans = 0
    for i in range(N):
        for j in range(N):
            ans += D[i][j]
            ans %= MOD
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 46044
/**
 * Title: C - Sequence
 * Url: https://atcoder.jp/contests/abc059/tasks/arc072_a
 */
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<numeric>
#include<functional>
#include<sstream>
#include<iomanip>

using namespace std;

#define ll long long

int main() {
    int n; cin >> n;
    vector<ll> a(n);
    vector<ll> s_odd(n, 0);
    vector<ll> s_even(n, 0);
    for(int i=0; i<n; i++) cin >> a[i];
    ll ans_even = 0, ans_odd = 0;
    for(int i=0; i<n; i++) {
        // s[2m] > 1 & s[2m+1] < -1 のパターン
        if(i%2==0) {
            if(i==0) {
                if(a[0]>=1) {
                    s_even[i] = a[i];
                } else {
                    ans_even += abs(a[i]-1);
                    s_even[i] = 1;
                }
            } else {
                ll tmp = s_even[i-1] + a[i];
                if(tmp>=1) {
                    s_even[i] = tmp;
                } else {
                    ans_even += abs(tmp-1);
                    s_even[i] = 1;
                }
            }
        } else {
            ll tmp = s_even[i-1] + a[i];
            if(tmp<=-1) {
                s_even[i] = tmp;
            } else {
                ans_even += abs(tmp+1);
                s_even[i] = -1;
            }
        }
        // s[2m] < -1 & s[2m+1] > 1 のパターン
        if(i%2==0) {
            if(i==0) {
                if(a[0]<=-1) {
                    s_odd[i] = a[i];
                } else {
                    ans_odd += abs(a[i]+1);
                    s_odd[i] = -1;
                }
            } else {
                ll tmp = s_odd[i-1] + a[i];
                if(tmp<=-1) {
                    s_odd[i] = tmp;
                } else {
                    ans_odd += abs(tmp+1);
                    s_odd[i] = -1;
                }
            }
        } else {
            ll tmp = s_odd[i-1] + a[i];
            if(tmp>=1) {
                s_odd[i] = tmp;
            } else {
                ans_odd += abs(tmp-1);
                s_odd[i] = 1;
            }
        }
    }
    cout << min(ans_even, ans_odd) << endl;

    return 0;
}

Measured memory_bytes: 2560
import sys
from collections import defaultdict

N = int(sys.stdin.readline())
A = defaultdict(int)
for _ in range(N):
    s = sys.stdin.readline().strip()
    A[s] += 1

max_cnt = max(A.values())
ans = []
for key in A:
    if A[key] == max_cnt:
        ans.append(key)
ans.sort()
[print(s) for s in ans]


Measured memory_bytes: 32732
#include <bits/stdc++.h>
#define fio     ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define pi      3.14159265
#define ll      long long
#define repe    ll tc,cas=0;cin>>tc;while(tc--)
#define op      freopen("output.txt", "w", stdout);

#define maxn 10000010
using namespace std;
int cnt[2000+5];
int main()
{
    fio;

    int n,x,y;
    cin>>n>>x>>y;

    memset(cnt,0,sizeof cnt);

    for(int i=1;i<=n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            int dis;
            if(j<=x or y<=i)
                dis=j-i;
            else if(i<=x)
                dis=min(j-i,(x-i+1+abs(y-j)));
            else
                dis=min(j-i,abs(y-j)+abs(x-i)+1);
            cnt[dis]++;
            //3 1 3cout<<dis<<endl;
        }
    }

    for(int i=1;i<n;i++)
        cout<<cnt[i]<<endl;

    return 0;
}


Measured memory_bytes: 3592
/*Coded by::
    **Avinash Tiwary**
    **BE/10298/2015**
    **Production Engineer**
    **Producing <code>**
*/
#include<bits/stdc++.h>
#define buf ios_base::sync_with_stdio (0), cin.tie (0)
typedef long long ll;
typedef double dob;
#define MAX 50010
#define M5 200009
#define M6 2000009
#define M 1000000007
#define INF 1e18
using namespace std;
typedef vector<ll> V;
typedef queue<ll > Q;
typedef stack<ll> S;
typedef pair<ll,ll> P;
#define f first
#define s second
#define mp make_pair
#define mt make_tuple
#define pb push_back
ll fac[M6],not_prime[M6],ar[M5];
ll power(ll x,ll n)
{   if(n==0||x==0) return 1;
    else if(n%2 == 0) return power((x*x),n/2);
    else return (x*power((x*x),(n-1)/2));
}
void fact(){
    fac[0]=1;
    for(ll i=1;i<M6;i++) fac[i]=(i*fac[i-1])%M;
}
void sieve(){
    not_prime[1]=1; not_prime[0]=1;
    for(ll p=2;p*p<M6;p++){
        if(!not_prime[p]){
            for(ll i=p*2;i<=MAX;i+=p) not_prime[i]=1;
        }
    }
}
ll modi(ll a, ll m){
    ll m0 = m, t, q; ll x0 = 0, x1 = 1;
    if (m == 1) return 0;
    while (a > 1){  q = a / m; t = m; m = a % m, a = t;t = x0;x0 = x1 - q * x0; x1 = t;}
    if (x1 < 0) x1 += m0;return x1;
}
ll pred(ll i,ll a,ll b){
    return (i/a)+(i/b)-(i/(a*b));
}
int main(){
    buf; 
    //sieve(); 
    //fact();
    ll i,j,k,n,a,b,l,r,ans,test,sum;
    test=1;
    while(test--){
        cin>>n;
        map<ll,ll> mv,vis;
        for(i=1;i<=n;i++){
            cin>>ar[i]; mv[ar[i]]++;
        }
        ans=0;
        for(i=1;i<=n;i++){
            if(mv[ar[i]]%2&&vis[ar[i]]==0){
                ans++; vis[ar[i]]=1;
            }
        }
        cout<<ans;
    }
    return 0;
}

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


int main()
{
    int n;
    cin>>n;
    string s=to_string(n);
    if(s[0]=='7' || s[1]=='7' || s[2]=='7'){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3692
#include <stdio.h>
#include <math.h>

typedef enum {
    FALSE,
    TRUE
} bool_t;

// --a b-> x --b c->
double crossvec ( double* a, double* b, double* c )
{
    double a_b[2] = { b[0] - a[0], b[1] - a[1] };
    double b_c[2] = { c[0] - b[0], c[1] - b[1] };
    return ( ( a_b[0] * b_c[1] ) - ( a_b[1] * b_c[0] ) );
}

// point が start と end を含む直線上にあれば TRUE になります
bool_t isOnside ( double* start, double* end, double* point )
{
    double abstructDragon[2] = { end[0] - start[0], end[1] - start[1] };
    double subDragon[2] = { point[0] - start[0], point[1] - start[1] };

    if ( ( abstructDragon[0] / subDragon[0] ) == ( abstructDragon[1] / subDragon[1] ) )
        return TRUE;
    else
        return FALSE;
}

bool_t isPositive ( double input )
{
    if ( input >= 0.0 )
        return TRUE;
    else
        return FALSE;
}

int main ( void )
{
    double a[2], b[2], c[2], p[2], cross[3];
    while ( scanf( "%lf %lf %lf %lf %lf %lf %lf %lf",
                   &a[0], &a[1], &b[0], &b[1], &c[0], &c[1], &p[0], &p[1] ) != EOF )
    {
        cross[0] = crossvec( c, a, p );
        cross[1] = crossvec( b, c, p );
        cross[2] = crossvec( a, b, p );

        if ( ( isPositive(cross[0]) != isPositive(cross[1]) )
              || ( isPositive(cross[0]) != isPositive(cross[2]) ) )
            puts("NO"); // outside
        else if ( isOnside( a, b, p )
                    || isOnside( a, c, p )
                    || isOnside( b, c, p ) )
            puts("NO"); // onside
        else
            puts("YES"); // inside
    }
    return 0;
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
using namespace std;
#define ll          long long int
#define pb          push_back
#define pll         pair<ll,ll>
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mode        998244353
#define mod         1000000007
#define inf         1000000000000000000LL
#define vl          vector<ll>
#define F           first
#define S           second
#define db          long double
#define sz(x)       (ll)x.size()
#define fix(n)      cout<<fixed<<setprecision(n)
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define all(x)      x.begin(),x.end()
#define mset(x)     memset(x,0,sizeof x)
#define pi          3.14159265358979323

const int N = 1e5+5;

ll n, val[101], w[101], wt, dp[101][N];

void solve()
{
       cin>>n>>wt;
       rep(i, 1, n+1) cin>>w[i]>>val[i];
       for(ll i=1; i<=n; i++){
              for(ll j=1; j<=wt; j++){
                     //if(i==0 || j==0) dp[i][j]=0;
                     if(w[i] > j) dp[i][j] = dp[i-1][j];
                     else {
                            dp[i][j] = max(dp[i-1][j], val[i] + dp[i-1][j-w[i]] );
                     }
              }
       }
       cout<<dp[n][wt];
}


int main() {
	ll T = 1;
	speed_up
	//cin>>T;
	while(T--)
	    solve();
	return 0;
}


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

count = 0

for i in range(len(L)):
  for j in range(i+1,len(L)):
    for k in range(j+1,len(L)):
      if L[i]+L[j]>L[k] and L[j]+L[k]>L[i] and L[i]+L[k]>L[j]:
        if L[i]!=L[k] and L[j]!=L[k] and L[i]!=L[j]:
          count += 1
        
print(count)

Measured memory_bytes: 9224
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

void solve() {
  int n; cin >> n;
  outl(int(pow(2, int(log2(n)))));
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 1016
n = int(input())
dp = [10 ** 5 for _ in range(n + 1)]

dp[0] = 0
for i in range(1, n + 1):
    for num in [6, 9]:
        power = 1
        while power <= i:
            dp[i] = min(dp[i], dp[i - power] + 1)
            power *= num

print(dp[n])

Measured memory_bytes: 3864
N = int(input())
A = list(map(int, input().split()))
dictA = {}

cnt = 0

for a in A:
    if a not in dictA:
        dictA[a] = 0
    dictA[a] += 1


for k, v in dictA.items():
    if k > v:
        cnt += v
    else:
        cnt += v - k

print(cnt)


Measured memory_bytes: 68264
#include<cstring>
#include<cstdio>
using namespace std;
int main()
{
	char s[105];
	gets(s);
	bool f1 = 0, f2 = 0;
	for(int i=0; i<strlen(s); ++i)
	{
		if(s[i] == 'C')
			f1 = 1;
		if(f1 && s[i]=='F')
			f2 = 1;
		if(f1 && f2)
		{
			printf("Yes");
			return 0;
		}
	}
	printf("No");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
// #define int long long
#define float long double
#define M 1000000007



int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int t=1;
	int m,d;cin>>m>>d;
	int c=0;
	for(int i=1;i<=m;i++){
		for(int j=1;j<=d;j++){
			int d1=j%10;
			int d2=(j/10)%10;
			if(d1>=2 && d2>=2 && (d1*d2==i)){
				c++;
			}
		}
	}
	cout<<c<<endl;

	





	


	return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner((os.Stdin))

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

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

func main() {
	sc.Split(bufio.ScanWords)
  	N, A := nextInt(), [][]int{{},{}}

 	for i := 0; i < 2; i++ {
		for j := 0; j < N; j++ {
			A[i] = append(A[i], nextInt())
		}
	}

	fmt.Printf("%d\n", ABC090C(A))
}

// ABC090C ...
func ABC090C(A [][]int) int {
	res := 0

	sum2 := 0
	for i := 0; i < len(A[1]); i++ {
		sum2 += A[1][i]
	}

	sum1tmp, sum2tmp := 0, sum2
	for i := 0; i < len(A[0]); i++ {
		sum1tmp += A[0][i]
		sumtmp := sum1tmp + sum2tmp
		if res < sumtmp {
			res = sumtmp
		}
		sum2tmp -= A[1][i]
	}

	return res
}


Measured memory_bytes: 1788
import numpy as np
def make_prime(U):
    is_prime = np.zeros(U,np.bool)
    is_prime[2] = 1
    is_prime[3::2] = 1
    M = int(U**.5)+1
    for p in range(3,M,2):
        if is_prime[p]:
            is_prime[p*p::p+p] = 0
    return is_prime.nonzero()[0] #, is_prime

primes = make_prime(10 ** 5 + 10000)
n = int(input())
i = np.where(primes >= n)[0][0]
print(primes[i])

Measured memory_bytes: 12632
#include <stdio.h>

int main(void)
{
		int a,b,c;
	
	scanf("%d %d %d",&a,&b,&c);
	if((a<b)&&(b<c)){
			printf("Yes\n");
	}
	else{
			printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 580
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;


class union_find
{
private:
	std::vector<int>parent;
	std::vector<int>rank;
	std::vector<int>clump;
public:
	union_find(int siz)
	{
		parent.resize(siz);
		rank.resize(siz);
		clump.resize(siz);
		for (int i = 0; i < siz; ++i)
		{
			parent[i] = i;
			rank[i] = 0;
			clump[i] = 1;
		}
	}
	void unite(int x, int y)
	{
		int xr = find(x);
		int yr = find(y);
		if (xr == yr)return;
		if (rank[xr] > rank[yr])
		{
			parent[yr] = xr;
			clump[xr] += clump[yr];
		}
		else if (rank[yr] > rank[xr])
		{
			parent[xr] = yr;
			clump[yr] += clump[xr];
		}
		else if (xr != yr)
		{
			parent[yr] = xr;
			clump[xr] += clump[yr];
			++rank[xr];
		}
	}
	int find(int x)
	{
		if (parent[x] == x)
		{
			return x;
		}
		else
		{
			return parent[x] = find(parent[x]);
		}
	}
	bool check(int x, int y)
	{
		return find(x) == find(y);
	}
	int size(int x)
	{
		return clump[find(x)];
	}
};



struct edge
{
	int to;
	long long cost;
	edge(int to_, long long cost_) :
		to(to_), cost(cost_) {}
	bool operator< (const edge& o)const
	{
		return cost < o.cost;
	}
};


//戻り値＝最小全域木の合計コスト
//グラフは有向辺でも無向として判定
//最小全域木自体はソースを少し改良して
long long krustkal(vector<edge>graph_[], int n_)
{
	vector<pair<int, edge> >vec;
	for (int i = 0; i < n_; ++i)
	{
		for (int j = 0; j < graph_[i].size(); ++j)
		{
			vec.push_back({ i, graph_[i][j] });
		}
	}
	sort(vec.begin(), vec.end(), [](const pair<int, edge>& e1, const pair<int, edge>&e2)
	{
		return e1.second < e2.second;
	});
	union_find uf(n_);
	long long res = 0;
	for (int i = 0; i < vec.size(); ++i)
	{
		int a = vec[i].first;
		int b = vec[i].second.to;
		LL cost = vec[i].second.cost;
		if (!uf.check(a, b))
		{
			uf.unite(a, b);
			res += cost;
		}
	}
	return res;
}

int N;
int A[333][333], B[333][333];
vector<edge>graph[333];

int main(void)
{
	cin >> N;
	for (int i = 0; i < N; ++i)
	{
		for (int j = 0; j < N; ++j)
		{
			cin >> A[i][j];
			B[i][j] = A[i][j];
		}
	}
	for (int k = 0; k < N; ++k)
		for (int i = 0; i < N; ++i)
			for (int j = 0; j < N; ++j)
				B[i][j] = min(B[i][k] + B[k][j], B[i][j]);
	LL ans = 0;
	for (int i = 0; i < N; ++i)
	{
		for (int j = 0; j < N; ++j)
		{
			if (A[i][j] != B[i][j])
			{
				cout << "-1\n";
				return 0;
			}
			ans += A[i][j];
		}
	}

	for (int i = 0; i < N; ++i)
		for (int j = 0; j < N; ++j)
		{
			bool flag = false;
			for (int k = 0; k < N; ++k)
			{
				if (i == j || j == k || i == k)continue;
				if (A[i][j] >= A[i][k] + A[k][j])
				{
					flag = true;
					break;
				}
			}
			if(flag)
				ans -= A[i][j];
		}
	cout << ans / 2 << endl;
	return 0;
}


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

#define endl '\n'
#define rep(n)      for (int i = 0 ; i < n ; i++)
#define all(a)      a.begin(),a.end()
#define NumofDigits(n)    ((long long)log10(n)+1)
#define Unique(n)         (n).erase(unique(all(n)), (n).end())

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

void readFromText ()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
#endif // ONLINE_JUDGE
}

const double Pi = acos(-1.0);

int main()
{
    quick();
//    readFromText();
    string s ; cin >> s; 
    if (s=="ABC")cout << "ARC" ;
    else if (s=="ARC")cout << "ABC" ;
    return 0;
}

unsigned long long pow(long long base, long long power){
    if(power==0)
        return 1;
    if(power==1)
        return base;
    unsigned long long ans = pow(base, power/2);
    ans *= ans;

    if(power&1)
        return ans*base;
    return ans;
}


Measured memory_bytes: 3572
import sys
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda x: [na() for _ in range(x)]
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

t, x = na()
print(t / x)

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);//高速化、endlは使わない

  int N,K;

  cin >> N >> K;

  int answer;

  if (N % K == 0) answer=0;
  else answer = 1;
  cout << answer << "\n";
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N+2];
		A[0] = 0;
		A[N+1] = 0;
		int max = 0;

		for(int i=1; i<N+1; i++) {
			A[i] = sc.nextInt();
			max += Math.abs(A[i] - A[i-1]);
		}
		max += Math.abs(A[N]);
		//System.out.println(max);
		for(int k=1; k<N+1; k++) {
			System.out.println(max-Math.abs(A[k]-A[k-1])
					-Math.abs(A[k+1]-A[k])
					+Math.abs(A[k+1]-A[k-1]));
		}

	}

}


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

typedef long long ll;
int MOD = 1000000007;

int main() {
  int S; cin >> S;
  
  vector<ll> dp(2010, 0);
  
  dp[0] = 1;
  for (int i = 1; i <= 2010; i++) {
    for (int j = 0; j <= i-3; j++) {
      dp[i] += dp[j];
      dp[i] %= MOD;
    }
  }
  
  cout << dp[S] << endl;
}

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

using namespace std;

int main()
{
    int arr[3];
    cin >> arr[0] >> arr[1] >> arr[2];
    sort(arr, arr+3);
    if (arr[0] == 5 && arr[1] == 5 && arr[2] == 7)
        cout << "YES";
    else
        cout << "NO";
}

Measured memory_bytes: 256
def solve(s, ws):
    while True:
        find_w = False
        for w in ws:
            if s.startswith(w):
                s = s[len(w):]
                find_w = True
                break
        if not s:
            return "YES"
        elif not find_w:
            return "NO"
    return None


S = input()[::-1]
WS = [w[::-1] for w in['dream', 'dreamer', 'erase', 'eraser']]
print(solve(S, WS))

Measured memory_bytes: 3316
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
ans=B[A[0]-1]
for i in range(1,N):
    ans+=B[A[i]-1]
    if A[i-1]+1==A[i]:
        ans+=C[A[i-1]-1]
print(ans)

Measured memory_bytes: 3064
n = int(input())
s = [int(_) for _ in input().split()]
q = int(input())
t = [int(_) for _ in input().split()]
ans = 0
for i in t:
    if s[0] == i or s[n-1] == i:
        ans += 1
        continue
    l, r = 0, n-1
    while r-l > 1:
        m = (l+r)//2
        if s[m] == i:
            ans += 1
            # print(i)
            break
        if s[m] < i:
            l = m
        else:
            r = m

print(ans)



Measured memory_bytes: 16900
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

typedef long long ll;
ll MOD = 1e9 + 7;
ll dp[100010][13];

int main(void)
{
    string s;
    cin >> s;
    int n = s.length();
    long long ans = 0;
    REP(i, n)
    {

        if (i > 0)
        {
            ll tmp[13];
            REP(j, 13)
            {
                int next = (j * 10) % 13;
                tmp[next] = dp[i - 1][j];
            }
            if (s[i] == '?')
            {
                REP(j, 10)
                {
                    REP(k, 13)
                    {
                        int next = (j + k) % 13;
                        dp[i][next] = (dp[i][next] + tmp[k]) % MOD;
                    }
                }
            }
            else
            {
                REP(j, 13)
                {
                    int next = ((s[i] - '0') + j) % 13;
                    dp[i][next] = tmp[j];
                }
            }
        }
        else
        {
            if (s[i] == '?')
            {
                REP(j, 10)
                {
                    dp[0][j] = 1;
                }
            }
            else
            {
                dp[0][s[i] - '0'] = 1;
            }
        }
    }
    cout << dp[n - 1][5] << endl;
}

Measured memory_bytes: 10624
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
int n;
int a[100005];
 
long long ans = 0;
 
int main() {
    ios_base::sync_with_stdio(false);
    cin >> n;
    int no_neg = 0;
    int nin = 1000000000;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
        no_neg += (a[i] < 0);
        ans += abs(a[i]);
        nin = min(nin, abs(a[i]));
    }
 
    if(no_neg % 2) ans -= nin * 2LL;
    cout << ans;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
using namespace std;

int N;
vector<int> u, v, w;
vector<vector<pair<int, int>>> G;
vector<int> color;

void dfs(int i, int col = 0)
{
  color[i] = col;
  for (auto next_i : G[i])
  {
    if (color[next_i.first] != -1)
      continue;

    if (next_i.second == 0)
      dfs(next_i.first, col);
    else if (next_i.second == 1)
      dfs(next_i.first, 1 - col);
  }
}

int main()
{
  cin >> N;
  u.resize(N);
  v.resize(N);
  w.resize(N);
  for (int i = 0; i < N - 1; i++)
  {
    cin >> u[i] >> v[i] >> w[i];
    u[i]--;
    v[i]--;
  }

  G.resize(N);
  for (int i = 0; i < N - 1; i++)
  {
    G[u[i]].emplace_back(v[i], w[i] % 2);
    G[v[i]].emplace_back(u[i], w[i] % 2);
  }
  color.resize(N, -1);
  dfs(0);

  for (int i = 0; i < N; i++)
    cout << color[i] << " "s << endl;
}

Measured memory_bytes: 8576
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
const long long INF = 1LL << 60;
using ll = long long;

int main() {
  string S; cin>>S;
  ll N=S.size();
  vector<ll> O(N);
  vector<ll> L(N);
  ll countB=0;
  for(ll i=0; i<N; i++){
    if(S.at(i)=='B'){ //黒
      O.at(i)=0;
      countB++;
    }
    else{
      O.at(i)=1; //白
    }
    L.at(i)=countB;
  }
  ll count=0;
  for(ll i=0; i<N; i++){
    if(O.at(i)==1){
      count+=L.at(i);
    } 
  }
  cout<<count<<endl;
}


Measured memory_bytes: 3716
#include <stdio.h>
#include <math.h>
#define X_MAX 20
#define H_MAX 20

int arr[2 * H_MAX];

int* heights = arr + H_MAX;
int r;

int check(double time)
{
    int x;

    for(x = -r; x < 0; x++)
        if(heights[x] < sqrt(r * r - (x + 1) * (x + 1)) - r + time)
            return 0;

    for(x = 0; x < r; x++)
        if(heights[x] < sqrt(r * r - x * x) - r + time)
            return 0;

    return 1;
}

int main(void)
{
    int n, xl, xr, h;
    double upper, lower, mean;

    while(scanf("%d%d", &r, &n), r + n)
    {
        for(xl = -X_MAX; xl < X_MAX; xl++)
            heights[xl] = 0;

        while(n--)
        {
            scanf("%d%d%d", &xl, &xr, &h);
            for(; xl < xr; xl++)
                if(heights[xl] < h) heights[xl] = h;
        }

        upper = H_MAX;
        lower = 0;
        mean = (upper + lower) / 2;
        while(upper - lower > 0.001)
        {
            if(check(mean)) lower = mean;
            else upper = mean;
            mean = (upper + lower) / 2;
        }

        printf("%lf\n", mean);
    }

    return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
#define P(a,b) make_pair(a,b);
ll MOD = 1000000007;
//ll INF = 21474836470000000;
ll INF = 1001001001001001001;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<pair<ll,ll>>>;

int main(){
    ll N,K;
    cin >> N >> K;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];
    ll ans = INF;
    vector<ll> B(N);
    rep(i,(1LL<<N)){
        rep(i,N) B[i] = A[i];
        if(__builtin_popcountll(i) == K){
            bitset<5> S(i);
            ll res = 0;
            ll M = 0;
            rep(j,N){
                if((i >> j) & 1){
                    res += max(0LL,M - A[j]+1);
                    M = max(M+1,A[j]);
                }
                M = max(M,A[j]);
            }
            ans = min(ans,res);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
fun main(args: Array<String>) = ABC165B.main()

object ABC165B {
    fun log(message: Any?) {
        println(message)// TODO: ←消す
    }

    fun main() {
        val X = readLong()

        var current = 100L
        var year = 0
        while (current<X) {
            current = next(current)
            year++
        }
        println(year)
    }

    fun next(money: Long): Long = money + money / 100


    /*####################################################################################*/

    fun readString() = readLine()!!
    fun readStrings() = readLine()!!.split(" ")
    fun readInt() = readLine()!!.toInt()
    fun readInts() = readLine()!!.split(" ").map { it.toInt() }
    fun readLong() = readLine()!!.toLong()
    fun readLongs() = readLine()!!.split(" ").map { it.toLong() }
    fun readMatrixRows(height: Int) = (1..height).map { readLine()!!.toList() }

    fun Boolean.yesOrNo() = if (this) "Yes" else "No"
    fun Double.toNaturalExpr() = println("%f".format(this))
}

Measured memory_bytes: 34568
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
		String s = f.readLine();
		if(s.startsWith("YAKI")) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 21204
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <typeinfo>
#include <math.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    ll r;

    cin >> r;

    cout << M_PI * 2 * r << endl;
}

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

int main(){
  int n;
  cin >> n;
  long long ans=1;
  int i;
  for(int j=0;j<n;j++){
    i=j;
    long long  a;
    cin >> a;
    if(ans>1000000000000000000/a){
      ans=-1;
      j=n;
    }
    else ans*=a;
  }
  for(i;i<n;i++){
    long long  a;
    cin >> a;
    if(a==0)
      ans*=0;
  }
  cout << ans << endl;
}

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

int main(){

  int n; cin >> n;

  // if(n / 100 == 9) n = n-800;
  // if(n / 100 == 9) n = n-800;

  int a, b, c;
  a = n/100;
  b = (n - a*100)/10;
  c = (n - a*100 - b*10);
  // cout << a << "\t" <<  b << "\t" << c << endl;

  if(a == 1) a = 9;
  else if(a == 9) a = 1;

  if(b == 1) b = 9; 
  else if(b == 9) b = 1;

  if(c == 1) c = 9;
  else if(c == 9) c = 1;

  cout << a << b << c << endl;


}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

class Main {
    public static void main (String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.nextLine();
        Card[] cards = new Card[n];
        String[] input;
        for (int i = 0; i < n; i++) {
            input = sc.nextLine().split(" ");
            cards[i] = new Card(input[0], Integer.parseInt(input[1]), i);
        }

        quickSort(cards, 0, n - 1);

        StringBuilder sb = new StringBuilder("");
        if (isStable(cards)) sb.append("Stable\n");
        else sb.append("Not stable\n");

        for (int i = 0; i < n; i++) {
            sb.append(cards[i].getSuit()).append(" ").append(cards[i].getNum()).append("\n");
        }
        System.out.print(sb);

    }

    public static int partition(Card[] cards, int left, int right) {
        Card x = cards[right];
        int i = left;
        Card temp;
        for (int j = left; j < right; j++) {
            if (cards[j].getNum() <= x.getNum()) {
                temp = cards[i];
                cards[i] = cards[j];
                cards[j] = temp;
                i++;
            }
        }
        temp = cards[i];
        cards[i] = cards[right];
        cards[right] = temp;
        return i;
    }

    public static void quickSort(Card[] cards, int left, int right) {
        if (left < right) {
            int pivot = partition(cards, left, right);
            quickSort(cards, left, pivot - 1);
            quickSort(cards, pivot + 1, right);
        }
    }

    public static boolean isStable(Card[] cards) {
        for (int i = 1; i < cards.length; i++) {
            if (cards[i - 1].getNum() == cards[i].getNum() && cards[i - 1].getInitialIndex() > cards[i].getInitialIndex()) {
                return false;
            }
        }
        return true;
    }
}

class Card {
    private String suit;
    private int num;
    private int initialIndex;

    public Card(String suit, int num, int initialIndex) {
        this.suit = suit;
        this.num = num;
        this.initialIndex = initialIndex;
    }

    public String getSuit() {
        return suit;
    }

    public int getNum() {
        return num;
    }

    public int getInitialIndex() {
        return initialIndex;
    }
}

Measured memory_bytes: 151788
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N;
	cin >> N;

	cout << (N - 1)*(1 + (N - 1)) / 2 << endl;
	return 0;
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer tokenizer = null;
    int totalCases, testNum;

    PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

    void solve() throws IOException {

    }

    void execute() throws IOException {
        int n = ni();
        int[] h = new int[n];
        int[] dp = new int[n];
        for (int i = 0; i < n; i++) {
            h[i] = ni();
        }
        dp[0] = 0;
        dp[1] = Math.abs(h[1] - h[0]);
        for (int i = 2; i < n; i++) {
            dp[i] = Math.min(dp[i - 1] + Math.abs(h[i] - h[i - 1]), dp[i - 2] + Math.abs(h[i] - h[i - 2]));

        }
        out.print(dp[n - 1]);

        out.close();
    }

    public static void main(String[] args) throws IOException {
        new Main().execute();
    }

    void debug(Object... os) {
        System.out.println(Arrays.deepToString(os));
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String ns() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(br.readLine());
        }
        return tokenizer.nextToken();
    }

    String nline() throws IOException {
        tokenizer = null;
        return br.readLine();
    }

    boolean input() throws IOException {
        return true;
    }

}


Measured memory_bytes: 36820
# if true

# include <iostream>
# include <vector>
# include <algorithm>

int main()
{
    int N; std::cin >> N;
    std::vector<int> ds(N);
    for (auto& d : ds)std::cin >> d;

    std::sort(ds.begin(), ds.end());

    std::cout << ds[N / 2] - ds[N / 2 - 1];

    return 0;
}


# endif

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

int main(void) {
  int a, b, c;
  int rectangle = 0;
  int rhombus = 0;
  
  while(scanf("%d,%d,%d", &a, &b, &c) != EOF) {
    if(c*c == a*a + b*b) {
      ++rectangle;
    } else if(a == b) {
      ++rhombus;
    }
  }
  cout << rectangle << endl
       << rhombus << endl;
}


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

int main(){
  int N,fn=0;
  cin >> N;

  int tmp = N;
  for(int i  = 0; i < 8; i++){

    fn += tmp%10;
    tmp /= 10;
  }
  if(N%fn == 0) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;

}

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a, b) accumulate(all(a), b)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
typedef unsigned long long ull;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
ll const INF = 1e18;

template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



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

    vector<ll> v(n);
    for(auto& i : v) cin >> i;

    sort(all(v));

    ll sum = v.back();
    v.pop_back();

    auto itr = upper_bound(all(v), 0);
    if(itr == v.begin()) itr++;
    vector<pair<ll,ll>> ans;

    while(itr != v.end()){
        ans.push_back(make_pair(v[0], *itr));
        v[0] -= *itr;
        v.erase(itr);
    }

    for(auto i : v){
        ans.push_back(make_pair(sum, i));
        sum += i * (-1);
    }

    cout << sum << endl;
    for(auto i : ans){
        cout << i.first << " " << i.second << endl;
    }



    return 0;
}


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

using namespace std;

typedef long long llint;
typedef pair <int, int> pi;

int n, k;
string s;

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> s >> k;
    n = s.size();
    for (int i = 0; i < n; i++) {
        int val = ('z' - s[i] + 1) % 26;
        if (k >= val) {
            s[i] = 'a';
            k -= val;
        }
    }
    s[n - 1] += k % 26;
    if (s[n - 1] > 'z') s[n - 1] -= 26;
    cout << s;
    return 0;
}


Measured memory_bytes: 3784
N,K= map(int,input().split())
list1 = []

for i in range(1,N+1):
    list1.append(i)

for j in range(K):
    d =int(input())
    lista = list(map(int,input().split()))
    for l in lista:
        for h in list1:
            if (l==h):
                list1.remove(h)

print(len(list1))

Measured memory_bytes: 9024
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int n;
    cin >> n;
    long a[n];

    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    long ans = -1000000000000;
    long Min = a[0];
    for(int i = 1; i < n; i++){
        ans = max(ans, a[i]-Min);
        Min = min(Min, a[i]);
    }
    cout << ans <<endl;    
    return 0;
}





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

int main(){

  int M, D; cin >> M >> D;
  
  int count = 0;
  for(int i=1; i<=M; i++){
    
    for(int j=1; j<=D; j++){
      int d1 = j%10;
      int d10 = j/10;
      
      if(d1*d10 == i && d1 >= 2 && d10 >= 2){
        count++;
      }
    
    }
  
  }
  cout << count << endl;
}


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

string s;
int dp[200010][5];

signed main()
{
	ios::sync_with_stdio(false);
	cin>>s;
	for(int i=0;i<s.size();i++){
		if(i>=0){
			if(i>=1) dp[i][1]=max(dp[i-1][2],max(dp[i-1][3],dp[i-1][4]));
			if(i>=1&&s[i]!=s[i-1]) dp[i][1]=max(dp[i][1],dp[i-1][1]);
			dp[i][1]++;
		}
		if(i>=1){
			if(i>=2) dp[i][2]=max(dp[i-2][1],max(dp[i-2][3],dp[i-2][4]));
			if(i>=2){
				if(i>=3){
					if(s.substr(i-1,2)==s.substr(i-3,2)){
						dp[i][2]=max(dp[i][2],dp[i-2][2]);
					}
				}
				else{
					dp[i][2]=max(dp[i][2],dp[i-2][2]);
				}
			}
			dp[i][2]++;
		}
		if(i>=2){
			if(i>=3) dp[i][3]=max(dp[i-3][1],max(dp[i-3][2],dp[i-3][4]));
			if(i>=3){
				if(i>=5){
					if(s.substr(i-2,3)==s.substr(i-5,3)){
						dp[i][3]=max(dp[i][3],dp[i-3][3]);
					}
				}
				else{
					dp[i][3]=max(dp[i][3],dp[i-3][3]);
				}
			}
			dp[i][3]++;
		}
		if(i>=3){
			if(i>=4) dp[i][4]=max(dp[i-4][1],max(dp[i-4][2],dp[i-4][3]));
			if(i>=4){
				if(i>=7){
					if(s.substr(i-3,4)==s.substr(i-7,4)){
						dp[i][4]=max(dp[i][4],dp[i-4][4]);
					}
				}
				else{
					dp[i][4]=max(dp[i][4],dp[i-4][4]);
				}
			}
			dp[i][4]++;
		}
	}
	int maxv=0;
	for(int i=1;i<=4;i++) maxv=max(maxv,dp[s.size()-1][i]);
	cout<<maxv<<endl;
	return 0;
}

Measured memory_bytes: 4500
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int n, a;
    cin >> n >> a;
    cout << ((n % 500 <= a ? "Yes" : "No")) << endl;

    return 0;
}


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

using namespace std;

int main() {
    string S, T;
    cin >> S >> T;
    int s[26] = {0}, t[26] = {0};
    for (int i = 0; i < (int)S.size(); ++i) {
        s[S[i] - 'a']++;
        t[T[i] - 'a']++;
    }
    sort(s, s + 26);
    sort(t, t + 26);
    for (int i = 0; i < 26; ++i) {
        if (s[i] != t[i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}
/*
 aaabb
 abaab
 */


Measured memory_bytes: 776
using System;

class Program {
    static void Main( string[] args )
    {
        while ( true ) {
            string[] line = Console.ReadLine().Split();

            int n = int.Parse( line[ 0 ] );
            int x = int.Parse( line[ 1 ] );

            if ( 0 == n + x ) {
                break;
            }

            int count = 0;
            int m = x / 3;

            for ( int a = 1; a < m; ++a ) {
                for ( int b = a + 1; b < n; ++b ) {
                    if ( x < a + b * 2 + 1 ) {
                        continue;

                    } else if ( x > a + b + n ) {
                        continue;
                    }

                    count += 1;
                }
            }

            Console.WriteLine( count );
        }
    }
}

Measured memory_bytes: 9160
N, M = gets.split.map(&:to_i)
S = N.times.map { gets.split.map(&:to_i) }.sort_by{|v| -v[1] }
ufs = Array.new(M + 1, &:itself) # a variant of Union Find Tree

class << ufs
  def next_empty_seq(l)
    loop do
      if l >= self.size
        return nil
      elsif l == self[l]
        return self[l]
      else
        l = self[l]
      end
    end
  end

  def extend_seq!(l)
    r = next_empty_seq(l)
    return nil unless r
    r_ = r + 1
    loop do
      break if l >= r_
      m = self[l]
      self[l] = r_
      l = m
    end
    r_
  end
end

puts S.inject(0){|s, (a, b)| ufs.extend_seq!(a) ? s + b : s }



Measured memory_bytes: 12664