akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair

using namespace std;

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

const int MOD = 1000000007;

vector<vector<int> > c;
int counter[200000];
int ans[200000];

void walk(int i, int p) {
    p += counter[i];
    ans[i] = p;
    for(int j : c[i]) {
        walk(j, p);
    }
}

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

    rep(i, n) {
        vector<int> v;
        c.pb(v);
    }

    rep(i, n - 1) {
        int a, b;
        cin >> a >> b;
        c[a - 1].pb(b - 1);
    }

    rep(i, n) {
        counter[i] = 0;
    }
    rep(i, q) {
        int p, x;
        cin >> p >> x;
        counter[p - 1] += x;
    }
    walk(0, 0);

    rep(i, n) {
        if(i != 0) cout << " ";
        cout << ans[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 21996
import java.util.HashMap;
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);

		int n = scanner.nextInt();
		HashMap<Integer, String> a = new HashMap<Integer, String>();

        for(int i = 0; i < n; i++){
        	a.put(scanner.nextInt(),null);
        }
		int o = scanner.nextInt();
		int count =0;
        for(int i = 0; i < o; i++){
        	if(a.containsKey(scanner.nextInt())) {
        		count++;
        	}
        }
		scanner.close();
        System.out.println(count);
	}
}



Measured memory_bytes: 92172
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;
#define int ll

template<class T>
bool chmax(T &a, T b){if(a < b){a = b; return true;} return false;}
template<class T>
bool chmin(T &a, T b){if(a > b){a = b; return true;} return false;}

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    ll n,m,x; cin >> n >> m >> x;
    vector<ll> c(n);
    vvl a(n, vl(m));
    rep(i,n) {
        cin >> c[i];
        rep(j,m)cin >> a[i][j];
    }
    ll ans = INF;
    rep(i, 1LL << n){
        vector<ll> temp(m);
        ll sum = 0;
        rep(j,n){
            if((i >> j) & 1){
                rep(k,m)temp[k] += a[j][k];
                sum += c[j];
            }
        }
        bool ok = true;
        rep(k,m)ok &= temp[k] >= x;

        if(ok)chmin(ans, sum);
    }

    cout << (ans != INF ? ans : -1) << endl;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define sz(s)               (int)s.size()
using namespace std;
int main()
{
 
 
		string s; cin >> s;
	int l = 0, r = sz(s)- 1;
	int f = 0;
	while (l<r)
	{
		if (s[l] != s[r])f = 1;;
		l++; r--;
	}
 
	l = 0;	r = ((sz(s) - 1) / 2)-1;
	//cout << l << " " << r << endl;
	while (l <r)
	{
		if (s[l] != s[r])f = 1;
		l++; r--;
	}
	l = ((sz(s) + 3)/2)-1;	r = sz(s) - 1;
//cout << l << " " << r << endl;
	while (l < r)
	{
		if (s[l] != s[r])f = 1;
			
		l++; r--;
	}
	if (f == 1)cout << "No";
	else
	cout << "Yes";
 
	 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
typedef __int128 ll;
//typedef long long ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
#define MOD 1000000007LL
#define endl "\n"
const ll UNDEF = -1;
const ll INF=1e9+5;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
#define fst first
#define snd second
const ll mn=1e5+2;
ll a[mn];
ll b[mn];
const ll lim=1000*1000*1000;
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
	long long _n; scanf("%lld",&_n);
	ll n=_n;
	ll sumall=0;
	for (ll i=0;i<n;i++) {
		long long x; scanf("%lld",&x);
		a[i]=x;
		sumall+=x;
	}
	ll tdiv=((n+1)*n)/2;
	ll t=sumall/tdiv;
	for (ll l=0;l<n;l++) {
		ll r=l+1;
		if (r==n) r=0;
		ll d=a[r]-a[l];
		ll k=(t-d)/n;
		if (!(0<=k&&k<=t)) {printf("NO\n");return 0;}
		ll b0inc=k*((r==0)?1ll:n+1-r);
		ll brinc=(r==0)?0ll:-k*n;
		//printf("r:%lld k:%lld b0:%lld br:%lld\n",r,k,b0inc,brinc);
		b[0]+=b0inc;
		b[r]+=brinc;
	}
	ll sum=0;
	for (ll x=0;x<n;x++) {
		sum+=b[x];
		//printf("x:%lld b:%lld sum:%lld\n",x,b[x],sum);
		if (sum!=a[x]) {printf("NO\n");return 0;}
		sum+=t;
	}
	printf("YES\n");
}


Measured memory_bytes: 3456
while True:
    a, op, b = input().split()
    if op == '?':
        break
    a = int(a)
    b = int(b)
    if op == '+':
        ans = a + b
    elif op == '-':
        ans = a - b
    elif op == '*':
        ans = a * b
    elif op == '/':
        ans = a // b

    print(ans)




Measured memory_bytes: 5596
import java.util.Scanner;

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

		String ans = "No";
		if ( S.charAt(2) == S.charAt(3) && S.charAt(4) == S.charAt(5) ) {
			ans = "Yes";
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a, b, k;
    cin >> a >> b >> k;

    int count = 0;
    int ans = 1;
    for (int i = 100; i > 0; i--) {
        if (a % i == 0 && b % i == 0) {
            count++;
        }

        if (count == k) {
            ans = i;
            break;
        }
    }

    cout << ans;

    return 0;
}

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

int n;

void CountingSort(int A[], int B[], int k){
  int* C; C = new int[k+1];
  for(int i = 0; i < k+1; i++) C[i] = 0;

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

int main(){
  cin >> n;
  int *A, *B;
  int k = 0;
  A = new int[n+2]; B = new int[n+2];
  for(int i = 0; i < n; i++){
    cin >> A[i+1];
    k = max(k, A[i+1]);
  }
  CountingSort(A, B, k);
  for(int i = 1; i < n; i++){
    cout << B[i] << " ";
  }
  cout << B[n] << endl;
  return 0;
}

Measured memory_bytes: 18724
#include<cstdio>
int main(){
int n;
scanf("%d",&n);
long long int a[n+1]={};
a[0]=2;
a[1]=1;
for(int i=2;i<=n;i++){
a[i]=a[i-1]+a[i-2];
}
printf("%lld\n",a[n]);
return 0;
}

Measured memory_bytes: 128
N, M = map(int,input().split())

Ls, Rs = [0 for _ in range(M)],  [0 for _ in range(M)]

for i in range(M):
    L, R = map(int,input().split())
    Ls[i] = L
    Rs[i] = R
    
L_prime = max(Ls)
R_peime = min(Rs)

if L_prime > R_peime:
    print(0)
else:
    print(R_peime - L_prime + 1)

Measured memory_bytes: 11008
n = int(input())
a = []
for i in range(n):
    a.append(input().split()) #二重リスト作成

b = 1
for j in a: #★レストランの番号をindex2に付与
    j.append(b)
    b += 1

for k in a: #★点数をpopで取り出し-1を乗じてinsert→降順にソートするため
    x=k.pop(1)
    k.insert(1,int(x)*-1)

a.sort()

for m in a: #index2を取り出す
    print(m[2]) 


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    set<int>s;
    for(int i=0;i<k;i++)
    {
        int d;
        cin>>d;
        while(d--)
        {
            int x;
            cin>>x;
            s.insert(x);
        }
    }
    cout<<n-s.size();
    return 0;
}


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

int main()
{
    long long int a, b;
    
    cin >> a >> b;
    
    if((a * b) <= 0) {
        cout << "Zero\n";
    } else if((a > 0) || ((b - a) % 2 == 1)){
        cout << "Positive\n";
    } else {
        cout << "Negative\n";
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int i;
	int n,k;
	int pattern;

	scanf("%d %d",&n,&k);
	pattern=k;
	for (i=1;i<n;++i)
	{
		pattern*=(k-1);
	}
	printf("%d\n",pattern);

	return 0;
}



Measured memory_bytes: 128
#include <stdio.h>

int main(void) {

  long n;
  scanf("%ld", &n);
  long name[14];
  for (long i = 0; i < 14; i++) {
    name[i] = -1;
  }
  name[0] = n-1;
  for (long i = 1; i < 14; i++) {
    name[i] += name[i-1]/26;
    name[i-1] %= 26;
  }
  char c;
  for (long i = 13; i >= 0; i--) {
    if (name[i] == -1) {
      continue;
    }
    c = 'a'+name[i];
    printf("%c", c);
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 1660
/* Author : Prasuk Jain */
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define int              long long int
#define ull              unsigned long long
#define ld               long double
#define ull              unsigned long long
#define fo(i, n)         for(int i=0; i<n; i++)
#define FOR(i, a, b)     for(int i=a; i<b; i++)
#define rfor(i, n)       for(int i=n-1; i>=0; i--)
#define RFOR(i, a, b)    for(int i=b-1; i>=a; i--)
#define tr(it, v)        for(auto it=a.begin(); it!=a.end(); it++)
#define vi               vector<int>
#define mp               make_pair
#define pb(x)            push_back(x)
#define pii              pair<int,int>
#define vi               vector<int>
#define mii              map<int,int>
#define pqb              priority_queue<int>
#define pqs              priority_queue<int,vi,greater<int>>
#define hcf(x, y)        __gcd(x, y)
#define lcm(x, y)        boost::math::lcm(x,y)
#define setpre(x, y)     fixed << setprecision(y) << x
#define setbits(x)       __builtin_popcountll(x)
#define zerolead(x)      __builtin_clzll(x)
#define zerotrail(x)     __builtin_ctzll(x)
#define all(x)           x.begin(), x.end()
#define sortall(x)       sort(all(x))
const int  mod = 1e+7;
const int inf = 1e18;
bool isprime(int a){if(a <=1)return false;for(int i=2;i*i<=a;i++)
{if(a%i==0)return false;}return true;}

//*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!//

void coderprasukj(){ 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

int32_t main() {
    //coderprasukj();
    double t, n, k, x, y;
    cin >> t;
    cout << 2*3.14*t << "\n";
    
    return 0;
}



Measured memory_bytes: 3788
#include<iostream>
using namespace std;
long long memo[87]={};

long long L(int n){
	if(n==0) return 2;
	if(n==1) return 1;
	if(memo[n]!=0) return memo[n];
	else return memo[n] = L(n-1)+L(n-2);
}

int main(){
	int n;
	cin >> n;
	long long ans;
	ans=L(n);
	cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);

        int[] dice = new int[6];
        int[][] table = new int[100][4];
        for(int i = 0; i < 6; i++)dice[i] = scanner.nextInt();

        table[dice[0]][0] = dice[1];
        table[dice[0]][1] = dice[2];
        table[dice[0]][2] = dice[4];
        table[dice[0]][3] = dice[3];

        table[dice[1]][0] = dice[0];
        table[dice[1]][1] = dice[3];
        table[dice[1]][2] = dice[5];
        table[dice[1]][3] = dice[2];

        table[dice[2]][0] = dice[0];
        table[dice[2]][1] = dice[1];
        table[dice[2]][2] = dice[5];
        table[dice[2]][3] = dice[4];

        table[dice[3]][0] = dice[0];
        table[dice[3]][1] = dice[4];
        table[dice[3]][2] = dice[5];
        table[dice[3]][3] = dice[1];

        table[dice[4]][0] = dice[0];
        table[dice[4]][1] = dice[2];
        table[dice[4]][2] = dice[5];
        table[dice[4]][3] = dice[3];

        table[dice[5]][0] = dice[1];
        table[dice[5]][1] = dice[3];
        table[dice[5]][2] = dice[4];
        table[dice[5]][3] = dice[2];
        int q = scanner.nextInt();
        for(int i = 0; i < q; i++){
            int top = scanner.nextInt();
            int fnt = scanner.nextInt();
            for(int j = 0; j < 4; j++){
                if(table[top][j] == fnt){
                    System.out.println(table[top][(j+1)%4]);
                    break;
                }
            }
        }
    }
}


Measured memory_bytes: 26432
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,b,n) for(int i=b;i<n;i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int n,m;
const int MAX_N =120;
const int MAX_M =120;
double dp[MAX_N][MAX_M];//dp[i][j]:=直前にjを与え、i回目に肥料を与えたときの最大の成長
double memo[MAX_N][MAX_N];
int main(){
	while(1){
		cin>>n>>m;
		if(n==0&&m==0){
			break;
		}
		for(int i =0;i <MAX_N;i++){
			for(int j =0;j <MAX_N;j++){
				dp[i][j] =0;
				memo[i][j]=0;
			}
		}
		rep(i,n){
			rep(j,n){
				cin>>memo[i][j];
			}
		}
		rep(i,n)dp[1][i] =1.00;

		double ans =0;
		for(int i =1;i <m;i++){
			for(int j =0;j <n;j++){//直後
				for(int k =0;k <n;k++){//直前
					dp[i+1][j] =max(dp[i+1][j],dp[i][k]*memo[k][j]);
				}
			}
		}
		rep(i,n)ans=max(ans,dp[m][i]);
		/*
		ans +=0.005;
		ans =ans*100;
		ans =(int)ans;
		ans =(double)ans/100;
		 */
		printf("%.2lf\n",ans);
	}
	return 0;
}

Measured memory_bytes: 1468
#include <stdio.h>
#include <stdlib.h>

int main(void){
    // Your code here!
    char s[10000];
    int i;

    scanf("%s", s);
    i = 0;
    while (s[i])
        write(1, s + i++, 1);
    if (s[i - 1] == 's')
        printf("es");
    else
        printf("s");
}


Measured memory_bytes: 1744
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define rev(i,s,e) for(i64 (i) = (s);(i) --> (e);)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) noexcept {
  return std::vector<T>(n, std::forward<T>(val));
}

template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) noexcept {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}

int main() {
  i64 N;
  cin >> N;
  vector<i64> A(N);
  rep(i,0,N) cin >> A[i];
  sort(all(A));
  A.erase(unique(begin(A), end(A)), end(A));
  if(N == A.size()) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}


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

int convert(char x,char y){
    return (x-'0')*10+y-'0';
}
int solve(int n){
    vector<string> date(n);
    vector<int> t(n);
    vector<char> op(n);
    vector<string> id(n);
    for(int i=0;i<n;i++){
        string buf;
        cin>>date[i]>>buf>>op[i]>>id[i];
        t[i]=convert(buf[0],buf[1])*60+convert(buf[3],buf[4]);
    }

    map<string,int> res;
    map<string,vector<int>> events;
    for(int i=0;i<n;i++) events[date[i]].push_back(i);

    for(auto &kvp:events){
        auto event=kvp.second;
        stack<tuple<string,int,int>> outer;
        map<string,int> inner;
        int gin=0;
        for(int idx:event){
            if(id[idx]=="000"){
                if(op[idx]=='I'){
                    gin=t[idx];
                }
                else{
                    for(auto &e:inner){
                        res[e.first]+=t[idx]-max(gin,e.second);
                    }
                    while(!outer.empty()){
                        auto tmp=outer.top(); outer.pop();
                        res[get<0>(tmp)]+=max(get<2>(tmp)-max(get<1>(tmp),gin),0);
                    }
                }
            }
            else{
                if(op[idx]=='I'){
                    inner[id[idx]]=t[idx];
                }
                else{
                    outer.push(make_tuple(id[idx],inner[id[idx]],t[idx]));
                    inner.erase(id[idx]);
                }
            }
        }        
    }
    int ret=0;
    for(auto &e:res) if(e.first!="000") ret=max(ret,e.second);
    return ret;
}
    
int main(){
    int n;
    while(cin>>n,n){
        cout<<solve(n)<<endl;
    }
    return 0;
}



Measured memory_bytes: 3332
N, Y = map(int, input().split())
answer = [-1,-1,-1]
for a in range(N + 1):
    for b in range(N + 1 - a):
        if a * 10000 + b * 5000 + (N - b - a) * 1000 == Y:
            answer = [a, b, N - b - a]
            break
    else:
        continue
    break
print(str(answer[0]) + ' ' + str(answer[1]) + ' ' + str(answer[2]))


Measured memory_bytes: 3064
import collections

n,k = map(int,input().split())
a = list(map(int,input().split()))


a = collections.Counter(a)

a = a.most_common()
if k<len(a):
	x = 0
	for i in range(k,len(a)):
		x += a[i][1]

	print(x)
else:
	print(0)


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

int main() {
int x,a,b;
cin >> x >> a >> b;

if(a>=b){
      cout << "delicious"; return 0;
}
if(b-a<=x){
    cout << "safe"; return 0;
}
else{
    cout << "dangerous"; return 0;
}

return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
     
using namespace std;
 
const int MAX = 310000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
 
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
int main() {
	COMinit();
	int n; cin >> n;
	vector<long long> a(n);
	for (auto& e : a) cin >> e;
	long long sum = 0;
	int cnt[60] = {};
	for (int i = 0; i < n; ++i) (sum += ((n - 1) * (a[i] % MOD))% MOD) %= MOD;
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < 60; ++j)
			if (a[i] & (1LL << j)) cnt[j]++;
	long long mul = 1;
	for (int i = 0; i < 60; ++i) {
		if (cnt[i] > 1) sum -= ((mul * COM(cnt[i], 2) % MOD) * 2) % MOD;
		sum = (sum % MOD + MOD) % MOD;
		(mul *= 2) %= MOD;
	}
	cout << sum << endl;
 
	return 0;
}


Measured memory_bytes: 9856
#include <bits/stdc++.h>
using namespace std;
int ct[100005];
int main(){
 	int n,m;
    scanf("%d%d",&n,&m);
    for (int i = 0; i < m; i++){
        int x,y;
        scanf("%d%d",&x,&y);
        ct[x]++; ct[y]++;
    }
    for (int i = 1; i <= n; i++){
        if (ct[i] & 1){
            printf("NO");
            return 0;
        }
    }
    printf("YES");


}


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

int main(){
    string b;
    cin >> b ;
    if (b == "A"){
        cout << "T" <<endl;
    }
    if (b == "T"){
        cout << "A" <<endl;
        
}
    if (b == "G"){
        cout << "C" << endl;
    }
    if (b == "C"){
        cout << "G" << endl;
    }
}

Measured memory_bytes: 256
N=int(input())
S=list(map(int,input().split()))

searchmin=10**4
pos=0
start=0
end=0
lenS=len(S)
count=0

def startendsearch():
    atta=False
    start=0
    end=0
    for i in range(lenS):
        if S[i]!=0 and atta==False:
            start=i
            atta=True
        if S[i]!=0 and atta==True:
            end=i
        if S[i]==0 and atta==True:
            break
    
    if atta==True:
        return start,end
    else:
        return 200,200
while sum(S)>0:
    s,e= startendsearch()
    
    #print(s,e)
    for i in range(s,e+1):
        S[i]-=1
        
    #print(S)
    count+=1
print(count)

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

int main() {
    int n, k;
    cin >> n >> k;
    int h[n];
    int dp[n];
    const int INF = 1001001001;
    rep(i,n) {
        cin >> h[i];
        dp[i] = INF;
    }
    dp[0] = 0;
    // 配るDPの練習
    rep(i,n) {
        for (int j = 1; j <= k && i+j < n; j++) {
            dp[i+j] = min(dp[i] + abs(h[i] - h[i+j]), dp[i+j]);
        }
    }
    int ans = dp[n-1];
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <map>
#include <algorithm>

using namespace std;

template< typename T>
void print(const vector<T> &data) {
	if (data.empty()) return;
	for (int i = 0; i < data.size(); ++i) {
		cout << data[i];
		if (i != data.size() - 1) cout << " ";
		else cout << endl;
	}
}

void bSort(vector<string> &data){
	int n = data.size();
	for (int i = 0; i < n; ++i){
		int count = 0;
		for (int j = n - 1; j > i; --j){
			if (data[j][1] < data[j - 1][1]){
				swap(data[j], data[j - 1]);
				count++;
			}
		}
		if (0 == count) break;
	}
}


void selSort(vector<string> &data){
	int n = data.size();
	for (int i = 0; i < n; ++i){
		int idx = i;
		for (int j = i; j < n; ++j)
			if (data[j][1] < data[idx][1]) idx = j;
		swap(data[idx], data[i]);
	}
}


void insSort(vector<string> &data){
	int n = data.size();
	for (int i = 0; i < n; ++i){
		string tmp = data[i];
		int j = i - 1;
		while ( j >= 0 && (data[j][1] > tmp[1])){
			data[j + 1] = data[j];
			--j;
		}
		data[j + 1] = tmp;
		print(data);
	}
}


int main(){
	int n; cin >> n;
	vector<string> v(n);
	for (int i = 0; i < n; ++i) cin >> v[i];
	vector<string> v1(v); bSort(v1); print(v1); cout << "Stable" << endl;
	vector<string> v2(v); selSort(v2); print(v2);
	
	string res = "Stable";
	for (int i = 0; i < v1.size(); ++i) {
		if (v1[i] != v2[i]) {
			res = "Not stable";
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	string s;
	cin>>s;
	if(s=="AAA"||s=="BBB"){
		cout << "No";
	}
	else{
		cout << "Yes";
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
// DP F

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

typedef long long ll;

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; }
const int INF = (1 << 29);
const long long INFL = 1LL<<60;

void dump(const vector<pair<int, int>>& a)
{
  for (auto v : a) {
    cerr << v.first << " " << v.second << endl;
  }
}

////////////////////////////////////////////////////

static const int MMAX = 20;
static const int NMAX = 50000;

int main()
{
  int n, m;
  int C[MMAX + 1];
  int T[NMAX + 1];

  cin >> n >> m;

  for (int i = 1; i <= m; i++) {
    cin >> C[i];
  }

  for (int i = 0; i <= NMAX; i++) {
    T[i] = INF;
  }
  T[0] = 0;
  for (int i = 1; i <= m; i++) {
    for (int j = 0; j + C[i] <= n; j++) {
      T[j + C[i]] = min(T[j + C[i]], T[j] + 1);
    }
  }

  cout << T[n] << endl;

  return 0;
}



Measured memory_bytes: 3284
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <numeric>

using namespace std;

template<class T>
using vv = vector<vector<T>>;

template<class T>
using vp = vector<pair<T, T>>;

#define rep(i,n) for(int i = 0; i < (n); i++)

const auto INF = 1e9;
const auto EPS = 1e-9;

int main()
{
	int N;
	cin >> N;
	cout << "ABC" << to_string(N) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rkc ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
#define fl(i,a,b) for(ll i=a;i<b;i++)
#define rfl(i,a,b) for(ll i=a;i>b;i--)
#define pb push_back
#define mp make_pair
#define test ll t;cin>>t;while(t--)
#define lld long double
#define vpp vector<pair<ll,ll>>
#define ff first
#define ss second
const ll M = 1e9 + 7;
const double pi  =3.141592653589793238463;
ll factorial(ll n) 
{ 
    // single line to find factorial 
    return (n==1 || n==0) ? 1: n +factorial(n - 1);  
} 
int main()
{
    rkc;
    ll n,c=1,ans=0;
    cin>>n;
    vector<string> v;
    vector<ll> v1;
    set<string> ss;
    fl(i,0,n)
    {
        string s;
        cin>>s;
        sort(s.begin(),s.end());
        v.pb(s);
    }
    /*fl(i,0,v.size())ss.insert(v[i]);
    if(v.size()!=ss.size())
    cout<<v.size()-ss.size()+1;
    else cout<<0;
    */
    sort(v.begin(),v.end());
    //fl(i,0,v.size())cout<<v[i]<<" ";
    //cout<<endl;
    fl(i,0,v.size()-1)
    {
        if(v[i]==v[i+1])c++;
        else
        {
            v1.pb(c);c=1;
        }
    }
    v1.pb(c);
    //fl(i,0,v1.size())cout<<v1[i]<<" ";
    //cout<<endl;
    fl(i,0,v1.size())
    {
        if(v1[i]!=1)
        ans+=factorial(v1[i]-1);
    }
    cout<<ans;
}

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

using namespace std;

const int N = 3e5+5;

typedef long long ll;

int n;
int ar[N];

int main(){
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> ar[i];
    }
    int ans = 0;
    while(true){
        int cnt = 0;
        for(int i = 1; i <= n; i++){
            cnt += (ar[i] % 2 == 0);
        }
        if(cnt == n){
            ans++;
            for(int i = 1; i <= n; i++){
                ar[i] >>= 1;
            }
        } else {
            break;
        }
    }
    cout << ans << "\n";
}


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, a, b) for(int i = a; i >= (b); --i)
#define trav(a, x) for(auto &a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;



int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  int n, k; cin >> n >> k;
  vi v(n);
  rep(i,0,n) cin >> v[i];

  vi dp(n,INT_MAX);
  dp[0] = 0;
  for (int i = 1; i < n; i++) {
    for (int j = i - 1; j >= 0 && i - j <= k; j--) {
      dp[i] = min(dp[j] + abs(v[i] - v[j]), dp[i]);
    }
  }
  cout << dp[n - 1];
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define MOD2 998244353
#define INF MOD
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

int main() {
    int n, x, t;
    cin >> n >> x >> t;
    int ans = (n + x - 1) / x * t;
    cout << ans << endl;  
}

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

void printarray(int A[], int len) {
	for (int i = 0; i < len - 1; i++) {
		cout << A[i] << " ";
	}
	cout << A[len - 1] << endl;
}

int main() {
	int N;
	cin >> N;
	int A[N];
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	int cnt = 0;
	for (int i = 0; i < N; i++) {
		int minj = i;
		for (int j = i; j < N; j++) {
			if (A[minj] > A[j]) {
				minj = j;
			}
		}
		if (i != minj) {
			swap(A[i], A[minj]);
			cnt++;
		}
	}
	printarray(A, N);
	cout << cnt << endl;
	return 0;
}



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

int main()
{
	int n;
	cin >> n;
	int cnt = 0;
	for (int i = 1; i <= n; i++)
	{
		int x;
		cin >> x;
		if (x > i)cnt++; 
	} 
	if (cnt > 1)
		puts("NO");
	else
		puts("YES");
	return 0;
}


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


int main(){
      string s;
      int d;
      
      cin>>s>>d;
      int len=s.length();
      vector<vector<int>>dp(d, vector<int>(2, 0));

      dp[0][0] = 1;

      for(int where = 0; where < len; where++){
            
            vector<vector<int>>new_dp(d, vector<int>(2, 0));
            
            for(int sum = 0; sum < d; sum++){
                  
                  for(bool sm_already: {false, true}){
                        
                        for(int digit = 0; digit < 10; digit++){
                              
                              if((digit > s[where] - '0') && !sm_already){
                                    break;
                              }
                              //add_self(new_dp[(sum + digit)%d][sm_already || (digit < (s[where] - '0'))], dp[sum][sm_already]);
                              new_dp[(sum + digit)%d][sm_already || (digit < s[where] - '0')] = (new_dp[(sum + digit)%d][sm_already || (digit < (s[where] - '0'))] + dp[sum][sm_already])%mod;
                              //new_dp[(sum + digit)%d][sm_already || (digit < s[where] - '0')] = (new_dp[(sum + digit)%d][sm_already || (digit < (s[where] - '0'))] + dp[sum][sm_already])%mod;
                        }
                  }
            }
            dp = new_dp;
      }
      int ans=dp[0][1]+dp[0][0];
      ans--;
      ans%=mod;
      //ans%=mod;
      if(ans<0){ans=mod-1;ans--;}
      cout<<ans;
}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
signed main(){
  int n,m;cin>>n>>m;
  if(n==m)cout<<"Yes";
  else cout<<"No";
  cout<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		List<Integer> X = new ArrayList<>();
		for(int i=0;i<N;i++) {
			X.add(sc.nextInt());
		}

		List<Integer> t = new ArrayList<>(X);
		Collections.sort(t);
		int median_high = t.get(N/2);
		int median_low  = t.get(N/2 - 1);

		for(int i=0;i<N;i++) {
			int x = X.get(i);
			if(median_high == median_low) {
				System.out.println(median_high);
			}else if(x < median_high) {
				System.out.println(median_high);
			}else {
				System.out.println(median_low);
			}
		}
	}
}


Measured memory_bytes: 94604
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <limits.h>
#include <string>
#include <string.h>
#include <sstream>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <stack>
#include <queue>

using namespace std;

typedef long long ll;

int main(){
  int time;
  cin >> time;
  int hour = time/3600;
  time %= 3600;
  int minute = time/60;
  int sec = time % 60;

  printf("%d:%d:%d\n", hour, minute, sec);
  return 0;
}

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

int main() {
  int a,b,c;cin>>a>>b>>c;
  if(a==b && b==c) cout << 1 << endl;
  else if(a!=b && a!=c && b!=c) cout << 3 << endl;
  else cout << 2 << endl;
}


Measured memory_bytes: 256
package main

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

func main() {
	sc := NewScanner()

	n := sc.ReadInt()
	m := sc.ReadInt()
	h := make([]int, n+1)
	for i := 1; i <= n; i++ {
		h[i] = sc.ReadInt()
	}
	canVisit := make([]map[int]bool, n+1)
	for i := 0; i < m; i++ {
		a := sc.ReadInt()
		b := sc.ReadInt()
		if canVisit[a] == nil {
			canVisit[a] = make(map[int]bool)
		}
		canVisit[a][b] = true
		if canVisit[b] == nil {
			canVisit[b] = make(map[int]bool)
		}
		canVisit[b][a] = true
	}

	cnt := 0
	for i := 1; i <= n; i++ {
		ih := h[i]
		iCanVisit := canVisit[i]
		good := true
		for key := range iCanVisit {
			if ih <= h[key] {
				good = false
				break
			}
		}
		if good {
			cnt++
		}
	}

	fmt.Println(cnt)
}

// util
// *   math/simple

func Abs(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func Min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func Max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func Pow(base int, exponent uint) int {
	answer := 1
	for i := uint(0); i < exponent; i++ {
		answer *= base
	}
	return answer
}

// *   io

type Scanner struct {
	bufScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	bufSc.Buffer(nil, 100000000)
	return &Scanner{bufSc}
}

func (sc *Scanner) ReadString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *Scanner) ReadInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}


Measured memory_bytes: 23168
#!/usr/bin/python

def main():
    N = [int(i) for i in str(input())]
    for i in range(len(N)):
        if N[i] == 9:
            N[i] = 1
        else:
            N[i] = 9
    print(''.join(str(n) for n in N))

if __name__ == '__main__':
    main()

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

int main(){
	int n,m;
	string s[10];
	cin>>n>>m;
	for(int i=0;i<n;i++) cin>>s[i];
	int f=0,jj=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			if(s[i][j]=='#'){
				if(j<jj) f=1;
				jj=j;
			}
			if(f) break;
		}
		if(f) break;
	}
	if(f) cout<<"Impossible"<<endl;
	else {
		cout<<"Possible"<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 384
//============================================================================
// Name        : atcoder.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;
int N,anssize=0;
string str,ans="";
int main() {
	cin>>str;
	for(int i=0;i<str.size();++i){
		if(str[i]=='B'){
			if(anssize>0)anssize--;
		}
		else {

			ans[anssize]=str[i];
			anssize++;
		}
	}
	for(int i=0;i<anssize;++i){
		cout<<ans[i];
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

int main() {
    int h,w;
    cin >> h >> w;
    REP(j,w+2){
        cout << "#";
    }
    cout << endl;
    REP(i,h){
        cout << '#';
        REP(j,w){
            char a;
            cin >> a;
            cout << a;
        }
        cout << "#" << endl;
    }
    REP(j,w+2){
        cout << "#";
    }
    cout << endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    if(a[0] % 2 == a[1] % 2 && a[0] % 2 == a[2] % 2)
    {
        sort(a,a + 3);
        cout << (a[2] - a[1]) / 2 + (a[2] - a[0]) / 2;
    }
    else if(a[0] % 2 != a[1] % 2 && a[1] % 2 == a[2] % 2)
    {
        a[1] += 1;
        a[2] += 1;
        sort(a,a + 3);
        cout << (a[2] - a[1]) / 2 + (a[2] - a[0]) / 2 + 1;
    }
    else if(a[0] % 2 != a[1] % 2 && a[0] % 2 == a[2] % 2)
    {
        a[0] += 1;
        a[2] += 1;
        sort(a,a + 3);
        cout << (a[2] - a[1]) / 2 + (a[2] - a[0]) / 2 + 1;
    }
    else
    {
        a[0] += 1;
        a[1] += 1;
        sort(a,a + 3);
        cout << (a[2] - a[1]) / 2 + (a[2] - a[0]) / 2 + 1;
    }

    return 0;
}

Measured memory_bytes: 256
n=int(input())
a=[]
j=k=0
def s(a):
    return a[0]+a[1]
def ss(a):
    return a[0]-a[1]
for i in range(n):
    f=list(map(int,input().split()))
    a.append(f)
aa=min(map(s,a))
b=max(map(s,a))
c=min(map(ss,a))
d=max(map(ss,a))
print(max(abs(d-c),abs(b-aa)))

Measured memory_bytes: 45360
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll INF=10000000000000000LL;

ll mul(ll a,ll b){
  if(a>INF/b)return INF;
  return a*b;
}

ll n,m,a,b,p,q;

void dfs(ll x,ll sum,vector<ll> &t,vector<ll> &T){
  if(x==(int)t.size()){
    T.push_back(sum);
  }else{
    dfs(x+1,sum,t,T);
    dfs(x+1,min(INF,sum+t[x]),t,T);
  }
}

ll solve(){
  ll MAX=1000000000000LL;
  
  assert( 1<= n &&n <= MAX );
  assert( 1<= m &&m <= MAX );
  assert( 1<= a &&a <= MAX );
  assert( 1<= b &&b <= MAX );
  assert( 1<= p &&p <= MAX );
  assert( 1<= q &&q <= MAX );


  if(a==1 && b==1){
    ll d=p+q;
    ll total=mul(d,n);
    if(total <= m)return m-total;
    return min(m%d,d-m%d);
  }
  
  vector<ll> t, u;
  ll ak=1,bk=1;


  for(int i=0;i<n;i++){
    if(i&1)t.push_back( mul(ak,p) + mul(bk,q) );
    else   u.push_back( mul(ak,p) + mul(bk,q) );
    ak=mul(ak,a);
    bk=mul(bk,b);
    if( i==40 )break;
  }
  
  vector<ll> T,U;
  dfs(0,0,t,T);
  dfs(0,0,u,U);
    
  sort(T.begin(),T.end());
  sort(U.begin(),U.end());
  
  ll res=m;
  for(int i=0;i<(int)T.size();i++){
    ll target=m-T[i];
    int index=lower_bound(U.begin(),U.end(),target)-U.begin();
    for(int j=index-2;j<=index+2;j++){
      if(0<=j && j<(int)U.size()){
        ll c=T[i]+U[j];
        res=min( res,  abs(m-c) );      
      }
    }
  }
  return res;
}

int main(){
  cin>>n>>m>>a>>b>>p>>q;
  cout<<solve()<<endl;
  return 0;
}

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


#define PI 3.14159265358979323846264338327

int min(int x, int y)  
{  
    return (x < y)? x: y;  
      
}  

double cal_cos(double n) 
{ 
    double accuracy = 0.001, x1, denominator, cosx, cosval; 
  
    // Converting degrees to radian 
    n = n * (PI / 180.0); 
  
    x1 = 1; 
  
    // Maps the sum along the series 
    cosx = x1; 
  
    // Holds the actual value of sin(n) 
    cosval = cos(n); 
    int i = 1; 
    do { 
        denominator = 2 * i * (2 * i - 1); 
        x1 = -x1 * n * n / denominator; 
        cosx = cosx + x1; 
        i = i + 1; 
    } while (accuracy <= fabs(cosval - cosx)); 
  
    return cosx; 
} 
  
  
double calcAngle(double h, double m)  
{  
   
  
    if (h == 12) h = 0;  
    if (m == 60) m = 0;  
  
    // Calculate the angles moved  
    // by hour and minute hands  
    // with reference to 12:00  
    double hour_angle = 0.5 * (h * 60 + m);  
    double minute_angle = 6 * m;  
  
    // Find the difference between two angles  
    double angle = abs(hour_angle - minute_angle);  
  
  
    // Return the smaller angle of two possible angles  
    angle = min(360 - angle, angle);  
  
    return angle;  
}  

int main()
{
    double a,b,h,m;
    cin>>a>>b>>h>>m;
    
    double angle = calcAngle(h,m);
     // cout<<"angle : "<<angle<<endl;
      //cout<<cos(angle*PI/180.0)<<endl;
  //  double theta = cal_cos(angle);
    double ans = sqrt((a*a) + (b*b) -(2*a*b*cos((angle/180.0)*PI)));
    // cout<<ans<<"----> "<<(int)ans<<endl;
    // if(ans == (int)ans)
    //     cout<<ans<<endl;
    // else
    cout<<fixed<<setprecision(21)<<ans<<endl;
    
}


Measured memory_bytes: 4228
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define in(x, l, r) (ll)(l) <= (x) && (x) < (ll)(r)

int main() {
    int a;
    cin >> a;
    cout << a + a*a + a*a*a << endl;
}

Measured memory_bytes: 3652
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int[] a = new int[5];
        for (int i = 0; i < 5; i++) {
            a[i] = scan.nextInt();
        }

        Arrays.sort(a);
        boolean s = true;
        for (int i = 0; i < a.length; i++) {
            if(i != a[i]){
                System.out.println(i);
                s = false;
                break;
            }
        }

        if(s) System.out.println(5);
    }
}

Measured memory_bytes: 35728
use std::io::Read;
use std::collections::HashMap;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();

    let mut problems: HashMap<usize, usize> = HashMap::new();
    for _ in 0..n {
        let d: usize = iterator.next().unwrap().parse().unwrap();
        *problems.entry(d).or_insert(0) += 1;
    }

    let m: usize = iterator.next().unwrap().parse().unwrap();

    let mut required: HashMap<usize, usize> = HashMap::new();
    for _ in 0..m {
        let t: usize = iterator.next().unwrap().parse().unwrap();
        *required.entry(t).or_insert(0) += 1;
    }

    for (key, value) in required {
        let default = 0;
        let count = problems.get(&key).unwrap_or(&default);
        if *count < value {
            return String::from("NO");
        }
    }

    return String::from("YES");
}


Measured memory_bytes: 25904
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext()) {
			long kaijyou = 1;
			int n = sc.nextInt();
			long k = n;
			if( n  == 0){
				System.out.println("1");
				break;
			}
			for (int i = 0; i < n; i++) {
				kaijyou = kaijyou * k;
				k--;
			}
			System.out.println(kaijyou);
		}
	}
}

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

#define INF ((1<<30)-1)
#define LLINF (1LL<<60)
#define EPS (1e-10)

map<string, int> cnt;

int main() {
    int n;
    cin >> n;
    rep(i, n) {
        string s;
        cin >> s;
        cnt[s]++;
    }
    cout << "AC x " << cnt["AC"] << endl;
    cout << "WA x " << cnt["WA"] << endl;
    cout << "TLE x " << cnt["TLE"] << endl;
    cout << "RE x " << cnt["RE"] << endl;
}


Measured memory_bytes: 3556
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,flag=0;double i;
	cin>>a>>b;
	for(i=max(a,b);i<10001;i++)
	{
		if(floor(i*0.08)==min(a,b) && floor(i*0.1)==max(a,b))
		{
			flag=1;break;
		}
	}
	if(flag==1) cout<<floor(i)<<endl;
	else cout<<-1<<endl;
	return 0;
	return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main{
    public static void main(String[] args){
        FastScanner fsc=new FastScanner();
        int n=fsc.nextInt();
        String s=fsc.next();
        fsc.close();
        char[] c=s.toCharArray();
        int l=c.length;
        char now=c[0];
        int res=1;
        for(int i=1;i<l;i++){
            if(c[i]!=now){
                res++;
                now=c[i];
            }
        }
        System.out.println(res);
    }
    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte(){
            if(ptr<buflen) return true;
            else{
                ptr = 0;
                try{
                    buflen = in.read(buffer);
                }
                catch(IOException e){
                    e.printStackTrace();
                }
                if(buflen<=0) return false;
            }
        return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) throw new NumberFormatException();
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }
                else if(b == -1 || !isPrintableChar(b)) return minus ? -n : n;
                else throw new NumberFormatException();
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
        public void close(){
            try{in.close();}
            catch(IOException e){e.printStackTrace();}
        }
    }
}

Measured memory_bytes: 21332
/*
 * main.c
 *
 *  Created on: 2019/12/29
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a > b ? b : a)
typedef long long int ll;

int main()
{
	char S[55] = {0};
	char A[] = "ABC";
	int N = 0, i = 0, ans = 0;
	scanf("%d", &N);
	scanf("%s", S);

	for (i = 0; i < N; i++) {
		if (strncmp(&A[0], &S[i], 3) == 0) {
			ans++;
		}
	}
	printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 128
N, K = map(int, input().split())

if K % 2 == 1: #Kが奇数
    count = N // K
    print (count ** 3)
else:
    count = N // K #Kの倍数の個数
    ans = count ** 3
    count = N // (K // 2) - N // K
    ans += count ** 3
    print (ans)

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

#define X first
#define Y second
#define ll long long
#define MP make_pair
#define PB push_back

using namespace std;

const int MAXN=1e5;

ll n,m;
ll br[MAXN+5];
ll dp[MAXN+5];
vector <ll> djc[MAXN+5];
ll rj;
queue <ll> q;
ll trn,dijete,a,b;

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

	cin>>n>>m;
	for(int i=0; i<m; i++){
		cin>>a>>b;
		br[b]++;
		djc[a].PB(b);
	}
	for(int i=1; i<=n; i++){
		if(br[i]==0){
			q.push(i);
		}
	}
	while(q.size()>0){
		trn=q.front();
		q.pop();
		rj=max(rj,dp[trn]);
		for(int i=0; i<djc[trn].size(); i++){
			dijete=djc[trn][i];
			br[dijete]--;
			dp[dijete]=max(dp[dijete],dp[trn]+1);
			if(br[dijete]==0){
				q.push(dijete);
			}
		}
	}
	cout<<rj;
	
	return 0;
}

Measured memory_bytes: 10496
#include <iostream>
#include <vector>
#include <algorithm>
#define REP(i, a, n) for(int i = ((int) a); i < ((int) n); i++)
using namespace std;

int M, N, K;
char S[550][550];
vector<int> y, x;
vector<char> c;
int dd[5] = { 0, 1, 0, -1, 0 };

bool isin(int y, int x) {
  return 0 <= y && y < M && 0 <= x && x < N;
}

int main(void) {
  cin >> M >> N;
  K = 0;
  REP(i, 0, M) REP(j, 0, N) cin >> S[i][j];

  int ans = 0;
  bool visited[256];
  REP(i, 0, 256) visited[i] = false;
  bool f = true;
  while(f) {
    f = false;
    REP(i, 0, M) REP(j, 0, N) {
      if(S[i][j] == '.' || visited[S[i][j]]) {
        int cnt[256];
        REP(k, 0, 256) cnt[k] = 0;
        REP(k, 0, 4) {
          int ny = i + dd[k], nx = j + dd[k + 1];
          while(isin(ny, nx)) {
            if(S[ny][nx] != '.' && !visited[S[ny][nx]]) {
              cnt[S[ny][nx]]++;
              if(cnt[S[ny][nx]] == 2) {
                visited[S[ny][nx]] = true;
                ans += 2;
                f = true;
              }
              break;
            }
            ny += dd[k];
            nx += dd[k + 1];
          }
        }
      }
    }
  }
  cout << ans << endl;

  return 0;
}

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

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
double const PI = 3.1415926535897932384626433;
using P = pair<int, int>;

int main() {
    int n;
    string s, t;
    cin >> n >> s >> t;
    rep(i, n) { cout << s[i] << t[i]; }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3580