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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    int n;
    string s;
    cin >> n;
    cin >> s;
    int ans = 0;
    map<char, int> fo, la;
    rep(i, 26) fo[char('a' + i)] = 0, la[char('a' + i)] = 0;
    rep(i, n) la[s[i]]++;
    rep(i, n - 1)
    {
        int cnt = 0;
        fo[s[i]]++;
        la[s[i]]--;
        rep(i, 26) if (fo[char('a' + i)] > 0 && la[char('a' + i)] > 0)
            cnt++;
        ans = max(ans, cnt);
    }
    OP(ans);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
using ll = long long;
int main(){
  int n, y;
  cin >> n >> y;
  for(int i = 0; i <= n; i++){
    for(int j = 0; j <= n - i; j++){
      if(i * 10000 + j * 5000 + (n - i - j) * 1000 == y){
        cout << i << " " << j << " " << n - i - j << endl;
        return 0;
      }
    }
  }
  cout << -1 << " " << -1 << " " << -1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>

#define X first
#define Y second
#define vsort(v) sort((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())


//INT_MAX
//INT_MIN
//LLONG_MAX
//LLONG_MIN
//DBL_MIN
//DBL_MAX
//LDBL_MIN
//LDBL_MAX

// A-Z: 65~90
// a-z: 97~122
// |a-z| = 26

using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    string w;
    cin >> w;
    int cnt[26] = {};
    for (int i = 0; i < w.length(); i++) {
        cnt[w[i]-97]++;
    }
    bool flag = true;
    for (int i = 0; i < 26; i++) {
        if (cnt[i] % 2 != 0) {
            flag = false;
            break;
        }
    }
    if (flag) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import Counter
 
 
stdin = open(0)
 
N = int(stdin.readline())
S = stdin.read().split()
 
counter = Counter(S)
max_cnt = max(counter.values())
names = [name for name, cnt in counter.items() if cnt == max_cnt]
names.sort()
 
print(*names, sep='\n')

Measured memory_bytes: 38476
#include<bits/stdc++.h>
using namespace std;
char C[505][505];
int N;
int main(){
  cin>>N;
  for(int i=0;i<N;i++){
    string s;cin>>s;
    for(int j=0;j<N;j++)
      C[i][j]=s.at(j);
  }
  vector<int>A(N);
  vector<int>B(N);
  for(int i=0;i<N;i++){
int a=0;
    for(int j=0;j<N;j++)
      if(C[i][j]=='#')a++;
    A[i]=a;
  }
  for(int j=0;j<N;j++){
int b=0;
    for(int i=0;i<N;i++)
      if(C[i][j]=='#')
        b++;
    B[j]=b;
  }int ans=N+1;
    for(int i=0;i<N;i++){
    int d=N-A[i];
      if(B[i]==0)d++;
      if(d<ans)ans=d;
    }for(int j=0;j<N;j++)
      if(B[j]!=N)ans++;
  if(ans==2*N+1)
    cout<<-1<<endl;
  else
    cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3876
n=int(input())
dp=[float('inf')]*(n+1)
dp[1]=1
i=0
while 9**i<=n:
    dp[9**i]=1
    i+=1
j=0
while 6**j<=n:
    dp[6**j]=1
    j+=1
for i in range(2,n+1):
    for j in range(1,8):
        if i-6**j>=1 and i-9**j>=1:
            dp[i]=min(dp[i],min(dp[i-1],dp[i-6**j],dp[i-9**j])+1)
        elif i-6**j>=1:
            dp[i]=min(dp[i],min(dp[i-1],dp[i-6**j])+1)
        else:
            dp[i]=min(dp[i],dp[i-1]+1)
print(dp[n])


Measured memory_bytes: 47696
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
using namespace std;
typedef double  dbl;
typedef long long int lld;
#define PI 3.14159265358979323
#define foi(i,n) for(i = 0; i < n; i+=1)
#define fod(i,n) for(i=n-1; i >=0; i-=1)
#define MAX std::numeric_limits<lld>::max()
#define MIN std::numeric_limits<lld>::min()
#define FastIO  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main ()
{
	FastIO
	lld a, b;
	cin >> a;
	cin >> b;
	lld c = 0;
	lld outlet = 1;
	while (outlet < b){
		outlet--;
		outlet += a;
		c+=1;
	}
	cout<< c;
	return 0;
}

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

using namespace std;

int main()
{
  string s, ans;

  cin >> s;

  for (int i = 0; i < s.size(); i++)
  {
    if (s[i] == '0')
    {
      ans += '0';
    }
    else if (s[i] == '1')
    {
      ans += '1';
    }
    else if (s[i] == 'B' && ans.size() > 0)
    {
      ans.pop_back();
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 using namespace std;
 typedef long long ll;
 ll mod=1e9+7; ll mod_pow(ll a,ll b){
 ll res=1; for(int i=0;i<60;i++){ 
if(b>>i&1){ res=res*a%mod; } a=a*a%mod;
 } 
return res; 
} 
int main(){
 ll m,n; cin>>m>>n;
 cout<<mod_pow(m,n)<<endl; 
return 0;

 } 


Measured memory_bytes: 3116
#include <iostream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <tuple>
#include <math.h>
#include <set>
#include <stack>
#include <bitset>
#include <map>
#include <queue>
#include <random>
#include <unordered_set>
#include <unordered_map>
#define DEBUG
#define fi first
#define se second
#define pqueue priority_queue
#define pb(x) push_back(x)
// #define endl '\n'
#define all(x) x.begin(), x.end()
#define int long long
#define mk(a, b) make_pair(a, b)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ull> vull;
typedef vector<ll> vll;
// typedef tuple<int, int, int> tiii;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector< vector<int> > vvi;
typedef vector<char> vc;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1000000007;
const int MAXN = 3e5;
//const ld eps = 1e-6;
const ld eps2 = 1e-9;
const int MOD2 = 998244353;
const int dosz = 5e5;
const int SZ = (1<<18);
const ld PI = atan2l(0, -1);


void fast_io(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#ifdef DEBUG
        // freopen("a.in", "r",stdin);
#else
       // freopen("mxnl.in", "r", stdin);
       // freopen("mxnl.out", "w", stdout);
#endif
}

void solve(){ 
    vs ans;
    int k;
    cin >> k;
    queue<string> q;
    for(int i=1; i<10; i++){
        q.push(to_string(i));
        ans.pb(to_string(i));
    }
    while(ans.size()<=k){
        string kek = q.front(); q.pop();
        if(kek.back()=='0'){
            q.push(kek + "0");
            ans.pb(kek+"0");
            q.push(kek + "1");
            ans.pb(kek+"1");
        } else if(kek.back()=='9'){
            q.push(kek + "8");
            ans.pb(kek+"8");
            q.push(kek + "9");
            ans.pb(kek+"9");
        } else{
            q.push(kek + (char)(kek.back()-1));
            ans.pb(kek + (char)(kek.back()-1));
            q.push(kek + (char)(kek.back()));
            ans.pb(kek + (char)(kek.back()));
            q.push(kek + (char)(kek.back()+1));
            ans.pb(kek + (char)(kek.back()+1));
        }
    }
    cout << ans[k-1] << endl;

}

signed main() {
    fast_io();
    int q = 1;
    // cout << fixed << setprecision(6);
    // cin >> q;
    // cout << 1 << endl;
    while(q--){
        solve();
    }
    return 0;
}



Measured memory_bytes: 12276
#include <iostream>

int main(){
	int x,y,a,b,s;
	std::cin>>s;
	x=s/3600;
	a=s%3600;
	y=a/60;
	b=a%60;
	std::cout<<x<<":"<<y<<":"<<b<<std::endl;
	return 0;
}

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

using ll = long long;
using namespace std;
const int INFint = 1e9+1;
const ll INFll = (ll)1e18+1;
ll MOD=1e9+7;

int main(){
  int N;
  cin>>N;
  if(N > 26){
    cout << 0 << endl;
    return 0;
  }
  vector<int> D(N);
  map<int,int> m;
  vector<int> base;
  base.push_back(0);
  for(int i(0);i<N;i++){
    cin>>D[i];
    m[D[i]]++;
    if(D[i] == 0){
      cout << 0 << endl;
      return 0;
    } else if(D[i] == 12){
      if(m[D[i]] == 2){
        cout << 0 << endl;
        return 0;
      }
      base.push_back(D[i]);
    } else if(m[D[i]] == 2){
      base.push_back(D[i]);
      base.push_back(24-D[i]);
    } else if(m[D[i]] >= 3){
      cout << 0 << endl;
      return 0;
    }
  }

  vector<int> p;
  for(auto mi:m){
    if(mi.second == 1 && mi.first != 0 && mi.first != 12) p.push_back(mi.first);
  }

  int num = int(p.size());
  int ans(0);
  for(int bit(0);bit<(1<<num);bit++){
    vector<int> kouho = base;
    int tmp(INFint);
    for(int i(0);i<num;i++){
      if (((bit>>i) & 1)){
        kouho.push_back(p[i]);
      }else{
        kouho.push_back(24-p[i]);
      }
    }
    for(int i(0);i<N+1;i++){
      for(int j(i+1);j<N+1;j++){
        int zisa = min(24 - abs(kouho[i]-kouho[j]),abs(kouho[i]-kouho[j]));
        tmp = min(tmp,zisa);
      }
    }
    ans = max(ans,tmp);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>

using namespace std;

int main() {
    int n, l;
    int m, s;

    scanf("%d", &n);
    m = s = 0;
    for (int i = 0; i < n; i++) {
        scanf("%d", &l);
        s += l;
        m = max(m, l);
    }

    printf("%s\n", (m < s-m) ? "Yes" : "No");

    return 0;
}


Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/stack:200000000")
#include <cstdio>
#include <cstring>
#include <string>
#include <string.h>
#include <cmath>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <list>
#include <stack>
#include <bitset>
#include <fstream>
#include <sstream>
#include <assert.h>
#include <unordered_map>
#define eps 1e-7
#define SIZE 300010
#define rep(i, a, b) for (long long i = a; i <= b; ++i)
#define pi acos(-1.0)
#define mp make_pair
#define ll long long
using namespace std;
void io() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); }
ll n, m, t, k;
ll a[SIZE];
ll pa[SIZE][2], pb[SIZE][2], pc[SIZE][2];

void debug(int n, int m) {
	rep(i, 1, n) cout << pa[i][0] << ' ';
	puts("");
	rep(i, 1, m) cout << pa[i][1] << ' ';
	puts("");
	rep(i, 1, n) cout << pb[i][0] << ' ';
	puts("");
	rep(i, 1, m) cout << pb[i][1] << ' ';
	puts("");
	rep(i, 1, n) cout << pc[i][0] << ' ';
	puts("");
	rep(i, 1, m) cout << pc[i][1] << ' ';
	puts("");
}

int main() {
	io(); cin >> n >> k;
	if (n == 1) {
		if (k == 1) cout << "1 2 3";
		else cout << "-1";
		return 0;
	}
	int p1 = 0, p2 = 0;
	//rep(i, k, (k + 3 * n - 1)) a[i] = i;
	rep(i, k, (n + k - 1)) {
		if ((k & 1) == (i & 1)) pa[++p2][1] = i;
		else pa[++p1][0] = i;
	}
	int x1 = 0, x2 = 0; //cout << p1 << ' ' << p2 << endl;
	for (ll i = p1; i; --i) {
		pb[++x1][0] = p1 + n + k - i;
		pc[x1][0] = p1 + n + n + k - i;
	}
	x1 = 0, x2 = 0;
	for (ll i = p2; i; --i) {
		pb[++x2][1] = n + n + k - i;
		pc[x2][1] = n + n + n + k - i;
	}
	rep(i, 1, (p1 / 2))
		swap(pb[i][0], pb[p1 - i + 1][0]);

	rep(i, 1, (p2 / 2))
		swap(pb[i][1], pb[p2 - i + 1][1]);
	//debug(p1, p2);
	vector<tuple<ll, ll, ll> > vec;
	rep(i, 1, p1) {
		if (pc[i][0] < pb[i][0] + pa[i][0]) { cout << "-1"; return 0; }
		vec.emplace_back(tuple<int, int, int>(pa[i][0], pb[i][0], pc[i][0]));
	}
	rep(i, 1, p2) {
		if (pc[i][1] < pb[i][1] + pa[i][1]) { cout << "-1"; return 0; }
		vec.emplace_back(tuple<int, int, int>(pa[i][1], pb[i][1], pc[i][1]));
	}
	rep(i, 0, (vec.size() - 1)) {
		cout << get<0>(vec[i]) << ' ' << get<1>(vec[i]) << ' ' << get<2>(vec[i]) << '\n';
	}
	return 0;
}


Measured memory_bytes: 10096
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, L;
	cin >> N >> L;

	vector<int> a(N);
	for (int i = 0; i < N; i++) cin >> a[i];
	DMP(a);

	bool ok = false;
	int memo = -1;
	for (int i = 0; i < N; i++) {
		if (a[i] + a[i + 1] >= L) {
			ok = true;
			memo = i;
			break;
		}
	}

	if (ok) {
		cout << "Possible" << "\n";
		for (int i = 0; i < memo; i++) cout << i + 1 << "\n";
		for (int i = N - 1; i > memo + 1; i--) cout << i << "\n";
		cout << memo + 1 << "\n";
	}
	else cout << "Impossible" << "\n";

	return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>

#define rep(i,a) for(int i = 0 ; i < a ; i ++)
#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define vi vector<int>
#define vs vector<strinx>
#define pii pair<int, int>
#define f first
#define s second
#define pb push_back
using namespace std;
long long int MOD = 1e9 + 7;

long long int f(long long int p){
	long long int re;
	for (re = 1; p > 0; re = re * p-- % MOD);
	return re;
}

long long int g(long long int  p) {
	return p > 0 ? p : -p;
}

int main(void){
	long long int n, m;
	cin>>n>>m;
	cout << f(n) * f(m) * max(0LL, 2 - g(n - m)) % MOD << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int A, A1, A2, A3, A4, A5, B, count = 0;
  cin >> A >> B;
  for (int i = 0; i < B - A + 1; i++)
  {
    A5=(A+i)/10000;
    A4=(A+i-A5*10000)/1000;
    A3=(A+i-A5*10000-A4*1000)/100;
    A2=(A+i-A5*10000-A4*1000-A3*100)/10;
    A1=(A+i-A5*10000-A4*1000-A3*100-A2*10);

    if(A1==A5&&A2==A4)
      count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#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};
/*Binary-indexed-Tree*/
const int MAX_N = 100000;
//i????????????????????即???a1+a2+a3+?????????ai????即??????????
//i??即x????????????????????即???ai+=x??即?????????
//1-indexed
//[l,n]
ll bit[MAX_N+1],n;

int sum(int i){
	int s = 0;
	while(i > 0){
		s +=bit[i];
		i -= i&-i;

	}
	return s;
}

void add(int i,int x){
	while(i <=n){
		bit[i] +=x;
		i += i&-i;
	}
}


int main(){
	int q;
	cin>>n>>q;
	REP(i,1,n){
		add(i,0);
	}
	rep(i,q){
		int com,x,y;
		cin>>com>>x>>y;
		if(com==0){
			add(x,y);
		}else{
			int ans = sum(y)-sum(x-1);
			cout <<ans<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1948
import math
def standard_deviation() :
	while True :
		n = input()
		if n==0 :
			break
		s_d = [0]*n
		average = 0
		standard = 0
		s_d= map(float,raw_input().split())
		for i in range(n):
			average += s_d[i]
		average /= float(n)
		for i in range(n):
			standard += pow(s_d[i]-average,2) / float(n)
		print(math.sqrt(standard))
standard_deviation()

Measured memory_bytes: 6492
#include<bits/stdc++.h> 
#define fo(i,a,b) for(i=a;i<=b;i++)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)
typedef long long ll;
using namespace std;
const int maxn=105,mo=1e9+7;
int i,j,k,n,l,num,s,n2,ad,k2,a[maxn],d1[maxn],d2[maxn];
int f[maxn][maxn][maxn],ans;
int main(){
	scanf("%d",&n);
	n2=n*2-1;
	fo(i,1,n2) scanf("%d",&a[i]);
	sort(a+1,a+1+n2);
	fd(i,n-1,1) if (a[i]!=a[i+1]) d1[n-i+1]++;
	fo(i,n+1,n2) if (a[i]!=a[i-1]) d2[i-n+1]++;
	f[1][1+d1[2]+d2[2]][1+d1[2]]=1;
	fo(i,2,n){
		num=d1[i+1]+d2[i+1];
		fo(j,1,n2)
		fo(k,1,j) if (f[i-1][j][k]){
			s=f[i-1][j][k];
			fo(l,1,j) {
				ad=max(abs(l-k)-1,0),k2=l+d1[i+1]-(l>k?ad:0);
				(f[i][j+num-ad][k2]+=s)%=mo;
			}
		}
	}
	fo(j,1,n2)
	fo(k,1,j) (ans+=f[n][j][k])%=mo;
	printf("%d\n",ans);
}

Measured memory_bytes: 3328
function Main(input) {
  input = input.split("\n");
  const N = parseInt(input[0], 10);
  const K = parseInt(input[1], 10);
  const X = parseInt(input[2], 10);
  const Y = parseInt(input[3], 10);

  var sum = 0;
  for (var i = 1; i <= N; i++) {
    if (i <= K) {
      sum += X;
    } else if (i > K) {
      sum += Y;
    }
  }
  console.log(sum);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include<stdio.h>
int main(){
	int a;
	int b;
	int c;
	int sum;
	
	scanf("%d %d %d",&a,&b,&c);
	sum=a+b+c;
	if(sum<=21){
		printf("win");
	}
	else{
		printf("bust");
	}
	
	return 0;
}

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

#define N 110
int n, m;
vector < vector <int> > vec;
int p[N], a[20];

int main() {
	while (scanf("%d%d", &n, &m) != EOF) {
		vec.clear();
		vec.resize(n + 1);
		for (int i = 1, k; i <= m; ++i) {
			scanf("%d", &k);
			for (int j = 1, x; j <= k; ++j) {
				scanf("%d", &x);
				vec[x].push_back(i);
			}
		}
		for (int i = 1; i <= m; ++i) {
			scanf("%d", p + i);
		}
		int res = 0;
		for (int i = 0; i < (1 << n); ++i) {
			memset(a, 0, sizeof a);
			for (int j = 0; j < n; ++j) {
				if ((i >> j) & 1) {
					for (auto it : vec[j + 1]) {
						a[it] ^= 1;
					}
				}
			}
			bool F = 1;
			for (int i = 1; i <= m; ++i) {
				if ((p[i] ^ a[i]) == 1) {
					F = 0;
					break;
				}
			}
			res += F;
		}
		printf("%d\n", res);
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vi vector<ll>
#define pi pair<ll,ll>
#define vp vector<pi>
#define mp map<ll,ll>
#define pb push_back
#define endl '\n'
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
vector<vector<ll>> dp(101, vector<ll> (100001,-1));
 
ll knapsack(ll n,ll W,vi wv[])
{
    if(n<=0 || W<=0)
    return 0;
    else if(dp[n][W]!=-1)
    return dp[n][W];
    else
    {
        if(W>=wv[n-1][0])
        dp[n][W] = max(knapsack(n-1,W,wv),knapsack(n-1,W-wv[n-1][0],wv)+wv[n-1][1]);
        else
        dp[n][W] = knapsack(n-1,W,wv);
     return dp[n][W];
    }
        
}
 
int32_t main(){
    fast;
    
     ll n,W,a,b;
     cin>>n>>W;
     vi wv[n];
     
     for(ll i=0;i<n;i++)
     {
         cin>>a>>b;
         wv[i].pb(a);
         wv[i].pb(b);
     }
     
     cout<<knapsack(n,W,wv);
     
    
    return 0;
    
}

Measured memory_bytes: 80256
#include<bits/stdc++.h>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define ri(x) scanf("%d",&(x))
#define ri2(x,y) scanf("%d %d",&(x),&(y))
#define ri3(x,y,z) scanf("%d %d %d",&(x),&(y),&(z))
#define rll(x) scanf("%lld",&(x))
#define rll2(x,y) scanf("%lld %lld",&(x),&(y))
#define rll3(x,y,z) scanf("%lld %lld %lld",&(x),&(y),&(z))
#define gc(x) ((x) = getchar())
using namespace::std;

const long double PI = acos(-1);
const long long MOD = 1000000000 +7;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> tll;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<tll> vtll;
typedef vector<string> vs;
typedef set<int> si;
typedef set<ii> sii;
typedef set<iii> siii;

ll gcd(ll a, ll b){ return b==0?a:gcd(b,a%b);}

ll add(ll a, ll b, ll m = MOD){
	if(a >= m) a %= m;
	if(b >= m) b %= m;
	if(a < 0) a += m;
	if(b < 0) b += m;
	ll res = a+b;
	if(res >= m or res <= -m) res %= m;
	if(res < 0) res += m;
	return res;
}

ll mul(ll a, ll b, ll m = MOD){
	if(a >= m) a %= m;
	if(b >= m) b %= m;
	if(a < 0) a += m;
	if(b < 0) b += m;
	ll res = a*b;
	if(res >= m or res <= -m) res %= m;
	if(res < 0) res += m;
	return res;
}

ll pow_mod(ll a, ll b, ll m = MOD){
	ll res = 1LL;
	a = a%m;
	while(b){
		if(b&1) res = mul(res,a,m);
		b >>= 1;
		a = mul(a,a,m);
	}
	return res;
}

ll fastexp(ll a, ll b){
	ll res = 1LL;
	while(b){
		if(b&1) res = res*a;
		b >>= 1;
		a *= a;
	}
	return res;
}

int gcdExtendido(int a, int b, int *x, int *y){
	if(a == 0){
		*x = 0;
		*y = 1;
		return b;
	}
	int x1, y1;
	int gcd = gcdExtendido(b%a,a,&x1,&y1);
	
	*x = y1-(b/a)*x1;
	*y = x1;
	return gcd;
}

int modInverso(int a, int m){
	int x, y;
	int g = gcdExtendido(a,m,&x,&y);
	if(g!=1) return -1;
	else return (x%m + m)%m;
}

/****************************************
*************P*L*A*N*T*I*L*L*A************
*****************************************/

ll x, k, d;

int main(){
	rll3(x, k, d);
	ll need = abs(x) / d;
	if(need >= k){
		if(x < 0) x += k * d;
		else x -= k * d;
	}
	else{
		if(x < 0) x += need * d;
		else x -= need * d;
		k -= need;
		k &= 1;
		if(k){
			if(x < 0) x += d;
			else x -= d;
		}
	}
	printf("%lld\n", abs(x));
	return 0;
}


Measured memory_bytes: 3708
#include <stdio.h>
#include <algorithm>
#include <climits>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define REP(i,b) FOR(i,0,b)
int a[100000];
int b[100000];
int amn=INT_MAX,amx=INT_MIN,bmn=INT_MAX,bmx=INT_MIN,n,c,d,ow=INT_MIN,oh = INT_MIN;
int main(){
	scanf("%d",&n);
	REP(i,n){
		scanf("%d %d",&c,&d);
		a[i] = c+d;
		b[i] = c-d;
		amn = min(amn,a[i]);
		amx = max(amx,a[i]);
		bmn = min(bmn,b[i]);
		bmx = max(bmx,b[i]);
	}
	REP(i,n){
		ow = max(ow,min(max(a[i]-amn,b[i]-bmn),max(amx-a[i],bmx-b[i])));
		oh = max(oh,min(max(a[i]-amn,bmx-b[i]),max(amx-a[i],b[i]-bmn)));
	}
	printf("%d\n",min(ow,oh));
}

Measured memory_bytes: 1808
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int n;
  cin >> n;
  int64_t a = 0;
  int64_t b = 0;
  if(n == 0) cout << 2 << endl;
  else if(n==1) cout << 1 << endl;
  else if(n==2) cout << 3 << endl;
  else{
    a = 2;
    b = 1;
    for(int i=2; i<=n;i++){
      int64_t num = b;
      b += (int64_t)a;
      a = (int64_t)num;
    }
    cout << b << endl;
 }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <queue>

int main() {
	int N;
	std::cin >> N;
	int64_t ans = 0;
	for (int A = 1; A < N; ++A) {
		ans+=(N - 1) / A;
	}
	std::cout << ans << std::endl;
	return 0;
}


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

int n, ans, countN;
string s;
bool leftstr, rightstr;

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

	for(int i=1; i<n; i++){
		countN=0;
		for(char ele='a'; ele<='z'; ele++){
			leftstr = false;
			rightstr = false;
			for(int j=0; j<i; j++){
				if(s[j] == ele){
					leftstr = true;
					break;
				}
			}

			for(int j=i; j<n; j++){
				if(s[j] == ele){
					rightstr = true;
					break;
				}
			}

			if(leftstr&&rightstr){
				countN++;
			}
		}
		ans = max(ans, countN);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
from itertools import product


def solve(string):
    h, w, k, *c = string.split()
    h, w, k = map(int, [h, w, k])
    ans = 0
    for f in product([True, False], repeat=h + w):
        count = 0
        for _f, _c in zip(f, c):
            if _f:
                continue
            count += sum(1 if __f and v == "#" else 0 for __f, v in zip(f[h:], _c))
        ans += 1 if count == k else 0
    return str(ans)

    pass


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Measured memory_bytes: 9144
import java.util.*;
import java.lang.*;


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		long amari = x % 11;
		if (amari == 0) {
			System.out.println(x / 11 * 2);
		} else if (amari <= 6) {
			System.out.println(x / 11 * 2 + 1);
		} else {
			System.out.println(x / 11 * 2 + 2);
		}
	}
}

Measured memory_bytes: 22612
def lscan; gets.split.map(&:to_i);end
n = lscan
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)

ans = 0
(0..b.length - 1).each do |i|
  if a[i] > b[i]
    ans += b[i]
  elsif a[i] <= b[i]
    ans += a[i]
    b[i] = b[i] - a[i]
    if a[i+1] <= b[i]
      ans += a[i+1]
      a[i+1] = 0
    elsif a[i+1] > b[i]
      ans += b[i]
      a[i+1] = a[i+1] - b[i]
    end
  end
end

puts ans

Measured memory_bytes: 15388
// Problem : C - Traveling Salesman around Lake
// Contest : AtCoder Beginner Contest 160
// URL : https://atcoder.jp/contests/abc160/tasks/abc160_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define pb push_back
#define mp make_pair
#define y1 y114514
#define y2 y1919810
typedef pair <int, int> PII;
#define all(x) (x.begin(),  x.end())
#define lsh(i) (1 << (i))
#define lshll(i) (1LL << (i))
#define repn(i, n) for (int i = 1; i <= (int)n; i++)
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define range(i, s, t)  for (int i = s; i <= (int)t; i++)
const int INF = 0x3f3f3f3f;
const long double EPS = 1e-6;
long long qread() {
	char c = getchar();
	int neg = 1;
	long long val = 0;
	while (c != '-' && !isdigit(c)) c = getchar();
	if (c == '-') c = getchar(), neg = -1;
	while (isdigit(c)) val = (val << 3) + (val << 1) + c - '0', c = getchar();
	return neg * val;
}
vector <int> a;
int main() {
	int n = qread(), k = qread();
	rep(i, k) a.pb(qread()); a.pb(n + a[0]);
	int mx = -1;
	repn(i, k) mx = max(mx, a[i] - a[i - 1]);
	cout << n - mx << endl;
	return 0;
}


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

int main(){
  long long int n, s;
  cin >> n >> s;
  if(s > n){
    cout << -1 << endl;
    return 0;
  }else if(s == n){
    cout << n+1 << endl;
    return 0;
  }
  long long int d = n - s, ans = -1;
  for(long long int i = 1; i*i <= d; ++i){
    if(d%i) continue;
    long long int b = i + 1, n_ = n, t = n;
    while(n_ > 0){
      n_ /= b;
      t -= n_*(b-1);
    }
    if(t == s){
      cout << b << endl;
      return 0;
    }
    long long int b_ = d/i + 1;
    n_ = n;
    t = n;
    while(n_ > 0){
      n_ /= b_;
      t -= n_*(b_-1);
    }
    if(t == s){
      ans = b_;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<cmath>
using namespace std;
void arraycout(int *arrayy,int n){
    for(int u=0;u<n;u++){//出力
        if(u==n-1){
            cout<<arrayy[u]<<endl;
        }else{
            cout<<arrayy[u]<<' ';
        }
    }
    
}


void insertionSort(int* sou,int n){//挿入ソート
    for(int i=0;i<n;i++){

        int v=sou[i];
        int j=i-1;
        while(j>=0&&v<sou[j]){
            sou[j+1]=sou[j];
            j--;
        }
        sou[j+1]=v;
                arraycout(sou,n);
        
    }
    
    
}

int main(){
    
    int n;
    cin>>n;
    int sou[n];
    for(int i=0;i<n;i++){
        cin>>sou[i];
    }
    insertionSort(sou,n);
   // arraycout(sou,n);
    
    return 0;
}


Measured memory_bytes: 3108
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int n;
    cin >> n;
    vector<int> v{3, 5, 7};
    int ans = 0;
    for (int i = 0; i < 8; ++i) {
        vector<int> u;
        for (auto &&j : v) {
            u.emplace_back(j*10+3);
            u.emplace_back(j*10+5);
            u.emplace_back(j*10+7);
        }
        for (auto &&j : u) {
            int a = 0, b = 0, c = 0;
            int x = j;
            while (x){
                if(x % 10 == 3) a++;
                if(x % 10 == 5) b++;
                if(x % 10 == 7) c++;
                x /= 10;
            }
            if((a&&b&&c) && (j <= n)) ans++;
        }
        v = u;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 512
/*

*/
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <iomanip>
#include <set>
#include <map>
#include <stack>
#include <deque>
 
#define ll long long
#define cint const int
#define ld long double
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
 
using namespace std;
 
typedef vector <long long> vll;
typedef vector <string> vs;
typedef vector <char> vc;
typedef set <int> si;
typedef set <string> ss;
typedef pair <int, int> pi;
typedef pair <long long, long long> pll;
typedef pair <int, long long> pil;
typedef pair <int, string> pis;
typedef pair <int, char> pic;
typedef pair <long long, int> pli;
typedef pair <long long, string> pls;
typedef pair <long long, char> plc;
typedef pair <string, int> psi;
typedef pair <string, long long> psl;
typedef pair <string, char> psc;
typedef pair <char, int> pci;
typedef pair <char, long long> pcl;
typedef pair <char, string> pcs;

int n, a[100005], m;
ll s = 0;

int main () {
	cin >> m >> n;
	for (int i = 1; i <= n; ++i) {
	    cin >> a[i];
	    s += a[i];
	}
	if (s < m) {
	    cout << "No";
	    return 0;
	}
	cout << "Yes";
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int n,m;
int a[100010],b[100010];
vector<int> PAR[100010];
int dep[100010];
void dfs(int v){
	dep[v] = 0;
	for(int u: PAR[v]){
		if(dep[u] == -1)dfs(u);
		dep[v] = max( dep[v] , dep[u]+1 );
	}
}

int main(){
	scanf("%d%d",&n,&m);
	rep1(i,n-1+m){
		scanf("%d%d",&a[i],&b[i]);
		PAR[b[i]].pb(a[i]);
	}
	rep1(i,n)dep[i] = -1;
	rep1(i,n)dfs(i);
	rep1(i,n){
		if(PAR[i].size() == 0)printf("0\n");
		else {
			for(int j: PAR[i]){
				if(dep[j] == dep[i]-1)printf("%d\n",j);
			}
		}
	}
}



Measured memory_bytes: 10368
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
  int n,l;
  cin>>n>>l;
  string s[n];
  for(int i=0;i<n;i++)
    cin>>s[i];
  sort(s,s+n);
  for(int i=0;i<n;i++)
    cout<<s[i];
  return 0;
}

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

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 1e9
using namespace std;
template <class T = int>
T in() {
  T x;
  cin >> x;
  return (x);
}

typedef long long ll;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}

#pragma endregion

int main() {
  int n = in(), m = in(), c = in();
  vector<int> b(m);
  rep(i, m) { b[i] = in(); }
  int ans = 0;
  rep(i, n) {
    int sum = 0;
    rep(j, m) {
      int a = in();
      sum += a * b[j];
    }
    if (sum + c > 0) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
sK = "keyence"

sS = input().rstrip()
if sS == sK or sS.startswith(sK) or sS.endswith(sK):
    print("YES")
else:
    for i in range(1,len(sK)):
        if sS.startswith(sK[:i]) and sS.endswith(sK[i:]):
            print("YES")
            exit()
    print("NO")


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

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

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

int main() {
	int n, k; cin >> n >> k;
	vector<int> h(n + k, 0);
	vector<int>data(n + k, INT_MAX);
	data.at(0) = 0;
	for (int i = 0; i < n; i++) {
		cin >> h.at(i);
	}

	for (int i = 0; i < n; i++) {
		for (int j = 1; j <= k; j++) {
			chmin(data.at(i + j), data.at(i) + abs(h.at(i) - h.at(i + j)));
		}
	}

	cout << data.at(n - 1) << endl;

	return 0;
}

Measured memory_bytes: 1024
/*
    हॉंजी । की हाल चाल?
    बड़ीया सब?
*/

#include<bits/stdc++.h>
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             unordered_map<int,int>
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define MOD             998244353
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
#define EPS             1e-9

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

int32_t main()
{
    gogeta();
    int k; cin >> k;
    string ans;
    while (k--) {
        ans += "ACL";
    }
    cout << ans << endl;
}


Measured memory_bytes: 3652
// myfirstatcoder.cpp : アプリケーションのエントリ ポイントを定義します。

#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,cc,n) for(int i=cc;i<(n);++i)
#define drep(i,cc,n) for(int i=cc;i>(n);--i)
#define llrep(i,cc,n) for(long long i=cc;i<(n);++i)
using namespace std;
using ll = long long;

double Permutation(int N, vector<int> a, vector<int> b)
{
	double count = 0;

	// node = {0,1,2,3,...n-1} とする
	vector<int> node(N);
	iota(node.begin(), node.end(), 0);

	int num = 0;
	do // 順列の最後になるまで one_case を並び替えながらループ O(N!)
	{
		double sum = 0;
		reps(i, 1, N)
			sum += pow(pow(a[node[i]] - a[node[i - 1]], 2) + pow(b[node[i]] - b[node[i - 1]], 2), 0.5f);
		count += sum;
		++num;
	} while (next_permutation(node.begin(), node.end()));
	return count / num;
}

int main()
{
	int N;
	cin >> N;
	vector<int> x(N), y(N);
	vector<vector<int>> side(N);
	reps(i, 0, N)
	{
		cin >> x[i] >> y[i];
	}

	cout << fixed << setprecision(10) << Permutation(N, x, y) << endl;
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <climits>
#include <iomanip>
#include <deque>
#include <limits>
#include <map>
#include <set>
#include <functional>

using namespace std;

int main()
{
  int x[5];
  cin >> x[0] >> x[1] >> x[2] >> x[3] >> x[4];

  for (int i = 0; i < 5; i++) {
    if (x[i] == 0) {
      cout << i + 1 << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 3592
public class Hello
{    
    public static void Main()
    {      
        // 1 行に複数の入力値がある場合の例       
        string [] inputs = System.Console.ReadLine().Split(' ');   
        int a = int.Parse(inputs[0]);     
        int b = int.Parse(inputs[1]);        
        int c = (a * b);   
        int d = (a + b) * 2;       
        System.Console.WriteLine(c + " " + d);  
    }
}


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

int main() {
  int a, b, c, x, ans = 0;
  cin >> a >> b >> c >> x;
  
  for (int i = 0; i <= a; i++) {
    for (int j = 0; j <= b; j++) {
      for (int k = 0; k <= c; k++) {
        if (i*500 + j*100 + k*50 == x) ans += 1;
      }
    }
  }  
  cout << ans << endl;
}

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

#define rng(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define urng(i, a, b) for(int i = int(b) - 1; i >= int(a); i--)
#define urep(i, b) urng(i, 0, b)
#define pb push_back
#define eb emplace_back
#define F first
#define S second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed

main() {
  int n, a, b, ans = 0;
  //string s;
  cin >> n >> a;
  //vector<int> v(n), c(n);
  if(n == a) cout << "Yes" << endl;
  else cout << "No" << endl;
  //for(int i = 0; i < n; i++){}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
  using namespace std;
  typedef long long int ll;
  #define mod 1000000007
  #define all(v)  v.begin(),v.end()
  #define pb push_back
  #define size(v)  (int) v.size()
  #define fast ios_base:: sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
  ll power_mod(ll a,ll x){if(x==0) return 1;ll y=power_mod(a,x/2);ll ans=(y*y)%mod; if(x%2) ans=(ans*a)%mod;return ans;}
  ll inv(ll a){return power_mod(a,mod-2);}
  ll power(ll a, ll x){ if(x==0) return 1; ll y= power(a,x/2); ll ans=(y*y); if(x%2) ans*=a; return ans;}




  int main()
  {
      fast;
      
      int n;
      cin>>n;
      int a[n+1];      // a[i]= height of stone i
      for(int i=1;i<=n;i++) cin>>a[i];
      int min_cost[n+1]; // min_cost[i] -> minimum cost to reach at position i	
      for(int i=1;i<=n;i++) min_cost[i]=1e9;
      min_cost[1]=0;
      min_cost[2]=abs(a[2]-a[1]);
      for(int i=3;i<=n;i++)
      {
      	  min_cost[i]=min(min_cost[i-1]+abs(a[i]-a[i-1]),min_cost[i-2]+abs(a[i]-a[i-2]));
      }
      
      cout<<min_cost[n]<<endl;	
  }




Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> B(N);
    for(int i=0;i<N;i++){
        cin >> A[i];
        B[i] = A[i] - i-1;
    }
    sort(B.begin(),B.end());
    int m = N/2;
    long long sum1= 0;
    long long sum2= 0;
    for(int i=0;i<N;i++){
        sum1+= abs(A[i] - B[m] - i-1) ;
        sum2+= abs(A[i] - B[m-1] - i-1) ;
    }
    cout << min(sum1,sum2) << endl;
    return 0;
}

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

int main()
{
 
  int n;
  cin >> n;
  vector<int> a,b,c;
  for (int i = 0;i < n;i++)
  {
    int tmp;
    cin >> tmp;
    a.push_back(tmp);
  }
  for (int i = 0;i < n;i++)
  {
    int tmp;
    cin >> tmp;
    b.push_back(tmp);
  }
  for (int i = 0;i < n-1;i++)
  {
    int tmp;
    cin >> tmp;
    c.push_back(tmp);
  }
  
  int sum = 0;
  for (int i = 0;i < n-1; i++)
  {
	sum += b[a[i]-1];
    if ((a[i+1] -  a[i]) == 1)
    {
      sum += c[a[i]-1];
    }
  }
  cout << sum+b[a[n-1]-1] << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;


public class Contest
{
	public static void Main()
	{

/*
		int n = a[0];
		int[][] e = new int[n][];
		for(int i=0; i<n; i++) MyIO.ReadArray(out e[i]);

		int[] a;
		MyIO.ReadArray(out a);

        long a,b,c,d,e,f;
        MyIO.ReadMulti(out a, out b, out c, out d, out e, out f);

		MyIO.WriteArray(ans);
*/

        int n,k;
		MyIO.ReadMulti(out n, out k);
		int[] a;
		MyIO.ReadArray(out a);

		int sum = 0;
		List<int> dn = new List<int>();

		for(int i=0;i<n; i++) sum += a[i];
		for(int i=1;i<(int)Math.Sqrt(sum)+1; i++) {
			if(sum%i==0)dn.Add(i);
		}
		int dc = dn.Count;
		for(int i=0; i<dc; i++){
			if(dn[dc-i-1]!=sum/dn[dc-i-1])dn.Add(sum/dn[dc-i-1]);
		}
		int[] da = dn.ToArray();

		int ans = 0;
		for(int i=da.Length-1; 0<=i; i--){
			int sm = 0;
			int[] am = new int[n];
			for(int j=0; j<n; j++) {
				am[j] = a[j]%da[i];
				sm += am[j];
			}
			Array.Sort(am);
			int fi = sm / da[i];
			int ks = 0;
			for(int j=0; j<n-fi; j++) ks += am[j];
			if(ks<=k){
				ans = da[i];
				break;
			}
		}

		Console.WriteLine(ans);
	}


}

public static class MyIO
{
	private static bool eq<T, U>() => typeof(T).Equals(typeof(U));
	private static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
	private static T cv<T>(string s) => eq<T, int>()    ? ct<T, int>(int.Parse(s))
	                                  : eq<T, long>()   ? ct<T, long>(long.Parse(s))
	                                  : eq<T, double>() ? ct<T, double>(double.Parse(s))
	                                  : eq<T, char>()   ? ct<T, char>(s[0])
	                                                    : ct<T, string>(s);
	public static string[] ReadArray<T>(out T[] a) {		
		var ar = Console.ReadLine().Split(new char[] {' '}, StringSplitOptions.RemoveEmptyEntries); 												
		a = System.Array.ConvertAll(ar, new Converter<string,T>(cv<T>));
		return ar;
	}										
	public static string[] ReadMulti<T>(out T a) {
		var ar = Console.ReadLine().Split(new char[] {' '}, StringSplitOptions.RemoveEmptyEntries); 
		a = cv<T>(ar[0]);
		return ar;
	}
	public static string[] ReadMulti<T, U>(out T a, out U b) {
		var ar = ReadMulti<T>(out a); 
        b = cv<U>(ar[1]);
		return ar;
	}
	public static string[] ReadMulti<T, U, V>(out T a, out U b, out V c) {
		var ar = ReadMulti<T, U>(out a, out b); 
        c = cv<V>(ar[2]);
		return ar;
	}
	public static string[] ReadMulti<T, U, V, W>(out T a, out U b, out V c, out W d) {
		var ar = ReadMulti<T, U, V>(out a, out b, out c); 
        d = cv<W>(ar[3]);
		return ar;
	}
	public static string[] ReadMulti<T, U, V, W, X>(out T a, out U b, out V c, out W d, out X e) {
		var ar = ReadMulti<T, U, V, W>(out a, out b, out c, out d); 
        e = cv<X>(ar[4]);
		return ar;
	}
	public static string[] ReadMulti<T, U, V, W, X, Y>(out T a, out U b, out V c, out W d, out X e, out Y f) {
		var ar = ReadMulti<T, U, V, W, X>(out a, out b, out c, out d, out e); 
        f = cv<Y>(ar[5]);
		return ar;
	}

	public static void WriteArray<T>(T[] a) {
		Console.WriteLine(string.Join(" ", Array.ConvertAll(a, x => x.ToString())));
	}


}




Measured memory_bytes: 15408
package main

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

var sc = NewScanner(os.Stdin, 1000000)

func main() {
	N := sc.readInt()
	var A []int
	minA := 10000000000
	for i := 0; i < N; i++ {
		a := sc.readInt()
		A = append(A, a)
		if minA > a {
			minA = a
		}
	}
	newMinA := minA
	for {
		firstMinAExecuted := false
		newA := []int{}
		for i := 0; i < len(A); i++ {
			if A[i] == minA && firstMinAExecuted == false {
				firstMinAExecuted = true
				newA = append(newA, A[i])
			} else {
				if rest := A[i] % minA; rest > 0 {
					newA = append(newA, rest)
					if newMinA > rest {
						newMinA = rest
					}
				}
			}
		}
		A = newA
		minA = newMinA

		if len(A) == 1 {
			break
		}
	}
	fmt.Println(A[0])
}

type Scanner struct {
	*bufio.Scanner
}

func (scn *Scanner) readInt() int {
	scn.Scanner.Scan()
	i, _ := strconv.Atoi(scn.Scanner.Text())
	return i
}

func NewScanner(r io.Reader, bufSize int) *Scanner {
	buf := make([]byte, bufSize)
	scn := bufio.NewScanner(r)
	scn.Buffer(buf, bufSize)
	scn.Split(bufio.ScanWords)
	return &Scanner{scn}
}


Measured memory_bytes: 7424
<?php
  list($n) = explode(" ", trim(fgets(STDIN)));

  $l = [];
  $l[0] = 2;
  $l[1] = 1;
  for ($i=2; $i<=$n; $i++) {
    $l[$i] = $l[$i-1]+$l[$i-2];
  }

  echo $l[$n];

Measured memory_bytes: 16036
//Problem Y

#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define endl "\n"

const ll mx = 1000000000000001;
 
int main ()
{
  
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  #define int ll
  
  int n;
  cin >> n;
  //n--;
  string answer = "";
  
  while (n > 0){
    int digit = n%26;
    if (digit == 0){
        
        n = n/26 - 1;
        answer += 'z';
    }
    else{
        n = n/26;
        answer += (digit - 1 + 'a');
    }
    
  }

  reverse(answer.begin(), answer.end());
  cout << answer << endl;

  
  return 0;
  
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

#define rep(i,n) for(int i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;

// 深さ優先探索．
void dfs(Graph &G, int p, int v, vector<int> &ans, priority_queue<int> &c) {
	// 探索した順位，cから大きいものを割り当てていく．
	ans[v] = c.top();
	c.pop();

	for(auto nv : G[v]) {
		if(nv==p) continue;
		dfs(G, v, nv, ans, c);
	}
}

int main() {
	int N;
	cin >> N;
	Graph tree(N);
	rep(i, N-1) {
		int a, b;
		cin >> a >> b;
		tree[a-1].push_back(b-1);
		tree[b-1].push_back(a-1);	
	}
	priority_queue<int> c;
	int c_max = 0;
	int c_sum = 0;
	rep(i, N) {
		int tmp;
		cin >> tmp;
		c.push(tmp); // 降順
		if(c_max<tmp) c_max = tmp;
		c_sum += tmp;
	}
	
	vector<int> ans(N);

	dfs(tree, -1, 0, ans, c); // 深さ優先探索

	// 問題文では，
	// 　　各辺に、2つの端点に書き込まれた整数のうち小さい方を書き込む。
	// とあるが，正確には，「大きくない方」だと思われる．
	// よって M は cの合計 - cの最大　
	cout << (c_sum - c_max) << endl;
	
	rep(i, N) {
		cout << ans[i] << ' ';
	}
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 1792
from collections import deque
K=int(input())
table=[[] for i in range(K)]
for i in range(K):
    table[i].append([1,(i+1)%K])
    t = (10*i)%K
    if t!=i:
        table[i].append([0,t])
dij=deque()
visit=[False]*K
val=[10**9]*K
val[1]=0
dij.append([0,1])
while dij:
    d,x=dij.popleft()
    if val[x]<d:
        continue
    for q,y in table[x]:
        if val[y]>val[x]+q:
            val[y]=val[x]+q
            if q==1:
                dij.append([val[y],y])
            else:
                dij.appendleft([val[y],y])
print(val[0]+1)

Measured memory_bytes: 46964