akhauriyash/Code-Regression huggingface dataset:
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
T[] RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[][] RDA2(T = long)(size_t n, T[] fix = []) { auto r = new T[][](n); foreach (i; 0..n) { r[i] = readln.chomp.split.to!(T[]); foreach (j, e; fix) r[i][j] += e; } return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

struct UnionFind
{
	void init(int n) { par = new int[](n); foreach (i; 0..n) par[i] = i; cnt = new int[](n); fill(cnt, 1); }
	int root(int i) { return par[i] == i ? i : (par[i] = root(par[i])); }
	bool same(int i, int j) { return root(i) == root(j); }
	void unite(int i, int j) { i = root(i); j = root(j); if (i == j) return; par[i] = j; cnt[j] += cnt[i]; }
	int size(int i) { return cnt[root(i)]; }
	int[] par, cnt;
}

void main()
{
	auto H = RD!int;
	auto W = RD!int;
	auto s = new string[](H);
	foreach (i; 0..H)
		s[i] = RD!string;

	UnionFind uf;
	uf.init(H*W);
	foreach (y; 0..H)
	{
		int id = y * W;
		foreach (x; 0..W-1)
		{
			if (s[y][x] != s[y][x+1])
				uf.unite(id+x, id+x+1);
		}
		if (y != H-1)
		{
			foreach (x; 0..W)
			{
				if (s[y][x] != s[y+1][x])
					uf.unite(id+x, id+x+W);
			}
		}
	}

	auto cnt = new long[][](H*W, 2);
	foreach (y; 0..H)
	{
		foreach (x; 0..W)
		{
			auto r = uf.root(y*W+x);
			auto pos = s[y][x] == '#' ? 1 : 0;
			++cnt[r][pos];
		}
	}

	long ans;
	foreach (i; 0..cnt.length)
	{
		ans += cnt[i][0] * cnt[i][1];
	}

	writeln(ans);
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 11388
#include <iostream>
#include <queue>

using namespace std;

const int MAXN=2e5+2+5;
int N;
string A;

int nxt[MAXN][26],par[MAXN];
bool seen[MAXN];

void build_next() {
        int last[26];
        for (int i=0; i<26; i++)
                last[i] = 0;

        for (int i=1; i<=N; i++) {
                int c=A[i-1]-'a';
                for (int j=last[c]; j<i; j++)
                        nxt[j][c] = i;
                last[c] = i;
        }
}

void do_out(int cur) {
        if (cur == 0)
                return;
        if (par[cur] != 0)
                do_out(par[cur]);
        cout << A[cur-1];
}

int main() {
        cin >> A;
        N = A.size();

        build_next();

        queue<int> q;
        q.push(0);
        seen[0] = true;
        while (q.size() > 0) {
                int cur=q.front();
                q.pop();
                for (int i=0; i<26; i++) {
                        if (nxt[cur][i] == 0) {
                                do_out(cur);
                                cout << char(i+'a') << "\n";
                                return 0;
                        }

                        if (!seen[nxt[cur][i]]) {
                                par[nxt[cur][i]] = cur;
                                q.push(nxt[cur][i]);
                                seen[nxt[cur][i]] = true;
                        }
                }
        }
}

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

int solve(vector<int> p, vector<int> c,int depth, vector<bool> use,int g){
  if (depth == use.size()){
    ll points = 0;
    int count = 0;
    rep(i,depth) if(use[i]){
      points += c[i] + p[i] * 100 * (i+1);
      count += p[i];
    }
    if (points < g) return MOD;
    int ans = count;
    rep(i,depth){
      int buf = count;
      int buff = points;
      if(!use[i]) continue;
      buff -= 100*(i+1) + c[i];
      if(buff < g) continue;
      buf--;
      rep(s,p[i]-1){
        buff -= 100*(i+1);
        if (buff < g) break;
        buf--;
      }
      ans = min(buf,ans);
    }
    return ans;
  }
  int ans = MOD;
  use[depth] = true;
  ans = min(ans,solve(p,c,depth+1,use,g));
  use[depth] = false;
  ans = min(ans,solve(p,c,depth+1,use,g));
  return ans;
}

int main(){
  int d,g;
  cin >> d >> g;
  vector<int> p(d), c(d);
  vector<bool> use(d);
  rep(i,d) cin >> p[i] >> c[i];
  cout << solve(p,c,0,use,g) << endl;
}



Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(b<=a && c<=a){
		printf("%d\n",a*10+b+c);
	}
	else if(a<=b && c<=b){
		printf("%d\n",b*10+a+c);
	}
	else{
		printf("%d\n",c*10+a+b);
	}
	return 0;
}

Measured memory_bytes: 128
char t[1121];
int p[187];
int s[15][1121];
void createtable(){
  int i=2,j;
  for(;i<=1120;i++)
    if(!t[i])
      for(j=i*2;j<=1120;j+=i)
        t[j]=1;
  for(i=2,j=0;i<=1120;i++)
    if(!t[i])p[j++]=i;
}
void createsum(){
  int i=0,k,n;
  s[0][0]=1;
  for(;i<187;i++)
    for(k=14;k;k--)
      for(n=p[i];n<1121;n++)
        s[k][n]+=s[k-1][n-p[i]];
}
int main(){
  int n,k;
  createtable();
  createsum();
  while(scanf("%d%d",&n,&k)&&n)printf("%d\n",s[k][n]);
  return 0;
}

Measured memory_bytes: 668
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

//みなさん天才的ですよね

ll num[858200];
const int ma = (1 << 19) - 1;
bool query(ll n) {
	int n2 = (n & ma) + 1;
	while (num[n2]) {
		if (num[n2] == n + 1) return 1;
		n2 = n2 * 9 % 858101;
	}
	return 0;
}
void add(ll n) {
	int n2 = (n & ma) + 1;
	while (num[n2]) {
		if (num[n2] == n + 1) {
			return;
		}
		n2 = n2 * 9 % 858101;
	}
	num[n2] = n + 1;
}

int KH[300001], KW[300001];
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);


	int H, W, M;
	cin >> H >> W >> M;

	rep(i, M) {
		int h, w;
		cin >> h >> w;

		KH[h]++;
		KW[w]++;
		add(ll(h) * W + w);
	}

	int saidaih = -1;
	int hh[300001], h = 0;
	rep1(i, H) {
		if (saidaih < KH[i]) {
			saidaih = KH[i];
			h = 1;
			hh[0] = i;
		}
		else if (saidaih == KH[i]) {
			hh[h++] = i;
		}
	}
	int saidaiw = -1;
	int ww[300001], w = 0;
	rep1(i, W) {
		if (saidaiw < KW[i]) {
			saidaiw = KW[i];
			w = 1;
			ww[0] = i;
		}
		else if (saidaiw == KW[i]) {
			ww[w++] = i;
		}
	}

	if (ll(h) * w > M) {
		co(saidaih + saidaiw);
		return 0;
	}
	int atta = 0;
	rep(i, h) rep(j, w) {
		if (!query(ll(hh[i]) * W + ww[j])) {
			atta = 1;
			break;
		}
	}

	if (atta) co(saidaih + saidaiw);
	else co(saidaih + saidaiw - 1);

	Would you please return 0;
}

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

int main(){

    string s;
    cin >> s;

    ll ans=0;

    rep(i,s.size()){
        if(s[i]=='p') ans--;
    }

    ans+=(s.size()/2);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
process.stdin.resume();
process.stdin.setEncoding('utf8');

process.stdin.on('data', function (chunk) {
   var line = chunk.toString().trim().split('\n').map(Number);
    
    
for (var i = 0; i < line.length; i++){
 if(line[i] === 0){break;}

 console.log('Case ' + (i + 1) + ': ' + line[i]);   
}
});

Measured memory_bytes: 20664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int mod=1000000007;
const double PI = 3.14159265359;
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define INF 1000000000000
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define FOR(i,n) for(int i=0;i<(n);i++)
#define FORA(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define count_1(n)  __builtin_popcountll(n)
#define parity(n)   __builtin_parityll(n)   //Even parity 0 as output
void show    (int a[], int arraysize) { for (int i = 0; i < arraysize; ++i)  {cout << a[i] << " ";}	cout<<endl;}
int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b);}
void sieve(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p])
          cout << p << " ";
}
int main()
{FAST
int x,n,k,l,ans;
cin>>x>>n;
k=x,l=x;
int a[n];
FOR(i,n)
{
	cin>>a[i];
}
sort(a,a+n);

if(n==0)
{
	cout<<x<<endl;
}
else
{
	FOR(i,n)
{
	if(binary_search(a,a+n,k))
	{
		k--;
	}
	else
	{
		ans=k;
		break;
	}
	
	if(binary_search(a,a+n,l))
	{
		l++;
	}
	else
	{
		ans=l;
		break;
	}
}
cout<<ans<<endl;
}

return  0;
}






Measured memory_bytes: 3644
#include<cmath>
#include<cstdio>
#include<bitset>
#include<iostream>
#include<vector>
#include<map>
#include<set>
using namespace std;
long long a,b,c;
int main()
{
	cin>>a>>b>>c;
	if(a+b>=c)
    {
    	puts("No");
    	return 0;
    }
	long long q=4*a*b;
	long long h =a*a + b*b + c*c + 2*a*b - 2*a*c - 2*b*c;
	if(q<h)
	{
		puts("Yes");
	}
	else
	{
		puts("No");
	}
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
#define INF 10e12
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;

vector<ll> kumiawase(ll s, ll N)
{
    vector<ll> ans;
    rep(i, N)
    {
        if (s & (1 << i))
            ans.push_back(i);
    }
    return ans;
}
int main(void)
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll vec[15][15];
    rep(i, N) rep(j, N) vec[i][j] = -1;
    rep(i, N)
    {
        ll k;
        cin >> k;
        rep(j, k)
        {
            ll a, b;
            cin >> a >> b;
            vec[i][a - 1] = b;
        }
    }
    //全探索
    ll ans = 0;
    rep(i, 1 << N)
    {
        bool flag = true;
        vector<ll> d(N);
        rep(j, N)
        {
            if (i >> j & 1)
                d[j] = 1;
        }
        rep(j, N)
        {
            if (d[j])
            {
                rep(k, N)
                {
                    if (vec[j][k] == -1)
                        continue;
                    if (vec[j][k] != d[k])
                        flag = false;
                }
            }
        }
        if (flag == true)
            ans = max(ans, ll(__builtin_popcountll(i)));
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
<?php

print(strval(cubic(read_num())) . "\n");

function read_num()
{
  if( fscanf(STDIN, "%d", $num) != 1 )
  {
    exit("invalid input");
  }
  return $num;
}

function cubic($num)
{
  return $num * $num * $num;
}

Measured memory_bytes: 6576
if __name__ == '__main__':
    
    s = input()
    if(s.count(s[0]) == 2):
        s2 = s[1:]
        idx = s2.index(s[0])
        if idx == 0:
            if(s2[1] == s2[2]):
                print('Yes')
            else:
                print('No')
        elif idx == 1:
            if (s2[0] == s2[2]):
                print('Yes')
            else:
                print('No')
        elif idx == 2:
            if (s2[0] == s2[1]):
                print('Yes')
            else:
                print('No')
        else:
            print('No')
    else:
        print('No')
    


Measured memory_bytes: 3064
n = int(input())
a = list(map(int, input().split()))
index = [[] for _ in range(n+1)]
for i in range(n):
	index[a[i]] = i

l = list(range(n))
r = list(range(n))

ans = 0
for i in range(n, 0, -1):
	m = index[i]
	ans += i * (r[m] - m + 1) * (m - l[m] + 1)
	if l[m] > 0:
		r[l[m] - 1] = r[m]
	if r[m] < n-1:
		l[r[m] + 1] = l[m]

print(ans)

Measured memory_bytes: 35820
#include <iostream>
#include <cmath>

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

	int a = 1;
	for( int i = std::sqrt( n ); i * i <= n; i++ ) {
		if( i * i > n ) {
			break;
		}
		a = i * i;
	}

	std::cout << a << std::endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main()
{
  int ac=0, wa=0, tle=0, re=0, n;
  cin >> n;
  for(int i = 0; i < n; ++i)
  {
    string tmp;
    cin >> tmp;
    if(tmp == "AC")
      ++ac;
    if(tmp == "WA")
      ++wa;
    if(tmp == "TLE")
      ++tle;
    if(tmp == "RE")
      ++re;
  }
  cout << "AC x " << ac << "\n";
  cout << "WA x " << wa << "\n";
  cout << "TLE x " << tle << "\n";
  cout << "RE x " << re << "\n";
  return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pint = pair<string,pair<int,int>>;

int main() {
    int N;cin >> N;
    pint X[N] = {};
    for (int i = 0;i < N;i++){
        cin >> X[i].first >> X[i].second.first;
        X[i].second.first *= -1;
        X[i].second.second = i + 1;
    }
    sort(X,X + N);
    for (int i = 0;i < N;i++){
        cout << X[i].second.second << endl;
    }
}

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

using namespace std;

int main(void)
{
    string S;
    cin >> S;
    string f2S;
    string s2S;
    for(int i=0; i<2; i++)
        f2S += S[i];
    for(int i=2; i<4; i++)
        s2S += S[i];
    
    int f2i = stoi(f2S);
    int s2i = stoi(s2S);

    if(1<= f2i && f2i <=12){
        if(1<= s2i && s2i <=12)
            cout << "AMBIGUOUS" << endl;
        else
            cout << "MMYY" << endl;
    }
    else {
        if(1<= s2i && s2i <=12)
            cout << "YYMM" << endl;
        else
            cout << "NA" << endl;
    }

    return 0;
}

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

using namespace std;

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

const int N = 1e5 + 5;

int x,y;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  cin >> x >> y;
  if (x == y)
    return cout << 0 << endl, 0;
  if (abs(x) <= abs(y))
    cout << abs(y) - abs(x) + (x < 0) + (y < 0) << "\n";
  else
    cout << abs(x) - abs(y) + (x > 0) + (y > 0) << "\n";
}

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

int main()
{
    int N,K;
    cin >> N >> K;

    int A[N];
    for(int i = 0;i < N;i++)
    {
        cin >> A[i];
    }

    cout << ((N - K) + ((K - 1) - 1)) / (K - 1) + 1 << endl;
}

Measured memory_bytes: 640
W,B=map(int,input().split())
U=['#']*1234
D=['.']*1234
for i in range(W-1):U[i*2]='.'
for i in range(B-1):D[i*2]='#'
print(80,51)
for x in range(20):print(''.join(U[x*51:-~x*51])+'\n'+'#'*51)
for x in range(20):print('.'*51+'\n'+''.join(D[x*51:-~x*51]))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, a, b) for (long long i = (a); i < (b); i++)
#define rep2(r, aa, bb) for (long long r = (aa)-1; r >= (bb); r--)

using namespace std;

void display(int a[], int n) 
{ 
    for (int i = 0; i < n; i++) { 
        cout << a[i] << "  "; 
    } 
    cout << endl; 
} 
  
int main()
{
    int n;
    cin >> n;
    int V1[n], V2[n], v[n];
    rep(i,0,n)cin >> V1[i];
    rep(i,0,n)cin >> V2[i];
    rep(i,0,n)v[i]=i+1;
    int o, t, c=0;
    do { 
        // display(v, n); 
        // cout << c << endl;
        c++;
        bool f = false;
        rep(i,0,n){
            if(v[i]!=V1[i]){
                f = true;
            }
        }
        if(!f){
            o = c;
        }
        bool ff = false;
        rep(i,0,n){
            if(v[i]!=V2[i]){
                ff = true;
            }
        }
        if(!ff){
            t = c;
        }
    } while (next_permutation(v, v + n)); 
    //cout << o << " " << t << endl;
    cout << abs(o - t) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<unordered_map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1e18;
#define Pint pair<ll, ll>
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rnr(i,a,b) for(int i=int(a);i>=int(b);i--)
#define rep(i,b) rng(i,0,b)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

int main() {
    ll A, V, B, W, T; cin >> A >> V >> B >> W >> T;
    if(A < B) {
        if(A + V * T >= B + W * T) {
            cout << "YES" << endl;
        }else {
            cout << "NO" << endl;
        }
    }else {
        if(A - V * T <= B - W * T) {
            cout << "YES" << endl;
        }else {
            cout << "NO" << endl;
        }
    }
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int maxi=0;
int ans[505][505];

void solve(int l,int r,int lev){
	if(l>=r){
		return;
	}
	maxi=max(maxi,lev);
	int mid=(l+r)/2;
	for(int i=l;i<=mid;i++){
		for(int j=mid+1;j<=r;j++){
			ans[i][j]=lev;
		}
	}
	solve(l,mid,lev+1);
	solve(mid+1,r,lev+1);
}


int main(void){
	int n;
	scanf("%d",&n);
	solve(0,n-1,1);
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			printf("%d%c",ans[i][j],(j+1)==n?'\n':' ');
		}
	}
	return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;

#define show(x) cerr << #x << " = " << x << endl
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "sz:" << v.size() << "\n[";
    for (const auto& p : v) {
        os << p << ",";
    }
    os << "]\n";
    return os;
}
template <typename S, typename T>
ostream& operator<<(ostream& os, const pair<S, T>& p)
{
    os << "(" << p.first << "," << p.second
       << ")";
    return os;
}


struct Edge {
    int from;
    int to;
    string s;
};
struct Graph {
    Graph(const int n) : edge(n) {}
    void addEdge(const int from, const int to, const string& s)
    {
        edge[from].push_back(Edge{from, to, s});
    }
    vector<vector<Edge>> edge;
};

int main()
{
    while (true) {
        int N, A, S, G;
        cin >> N >> A >> S >> G;
        if (N == 0 and A == 0 and S == 0 and G == 0) {
            break;
        }
        Graph g(N);
        g.addEdge(G, G, "");
        for (int i = 0; i < A; i++) {
            int x, y;
            string s;
            cin >> x >> y >> s;
            g.addEdge(x, y, s);
        }
        const string MAX = "{";
        const int TURN = 6 * N + 1;
        vector<vector<string>> dp(N);
        for (int i = 0; i < N; i++) {
            if (i == S) {
                dp[i] = vector<string>(g.edge[i].size(), "");
            } else {
                dp[i] = vector<string>(g.edge[i].size(), MAX);
            }
        }
        for (int i = 0; i <= TURN; i++) {
            vector<vector<string>> tmp(N);
            for (int j = 0; j < N; j++) {
                tmp[j] = vector<string>(g.edge[j].size(), MAX);
            }
            for (int j = 0; j < N; j++) {
                for (int k = 0; k < g.edge[j].size(); k++) {
                    if (dp[j][k] == MAX) {
                        continue;
                    }
                    const auto& e = g.edge[j][k];
                    const string s = dp[j][k] + e.s;
                    for (int l = 0; l < g.edge[e.to].size(); l++) {
                        if (tmp[e.to][l] + g.edge[e.to][l].s > s + g.edge[e.to][l].s) {
                            tmp[e.to][l] = s;
                        }
                    }
                }
            }
            dp = tmp;
        }
        const int MAXLEN = 6 * N;
        if (dp[G][0] == MAX or dp[G][0].size() > MAXLEN) {
            cout << "NO" << endl;
        } else {
            cout << dp[G][0] << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 3224
#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <math.h>
#include <cassert>
#include <unordered_map>
#include <chrono>
#include <random>
#include <ctime>
using namespace std;
#pragma warning(disable : 4996)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const ld PI = 3.14159265358979323846;
const ll MOD = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif
	srand(time(0));
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int h, w, k;
	cin >> h >> w >> k;
	vector<string> a(h);
	int ans = 0;
	for (int i = 0; i < h; i++)cin >> a[i];
	for (int i = 0; i < (1 << h); i++) {
		for (int j = 0; j < (1 << w); j++) {
			vector<int> banned_i(h), banned_j(w);
			for (int _i = 0; _i < h; _i++) {
				if ((i >> _i) & 1)banned_i[_i] = 1;
			}
			for (int _j = 0; _j < w; _j++) {
				if ((j >> _j) & 1)banned_j[_j] = 1;
			}
			int have = 0;
			for (int l = 0; l < h; l++) {
				for (int m = 0; m < w; m++) {
					if (!banned_i[l] && !banned_j[m] && a[l][m] == '#')have++;
				}
			}
			if (have == k)ans++;
		}
	}
	cout << ans;
}

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

int main(){
    int n;cin>>n;
    vector<unsigned long long> participants(3*n);for (int i=0;i<3*n;i++){cin>>participants[i];}

    sort(participants.begin(), participants.end(), greater<int>());

    unsigned long long acc = 0;
    for (int i=1;i<2 * n;i += 2){
        acc += participants[i];
    }
    cout << acc << endl;
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int A[MAXN];
char S[MAXN];

int main()
{
    int n,m,k,a,b,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;
    int tc;

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n;

    while(n){
        if((n%10)==7)cnt++;
        n/=10;
    }

    if(cnt)cout<<"Yes\n";
    else cout<<"No\n";

    return 0;
}


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

int main(){
	int A,B;
	cin >> A >> B;
	int count = 0;
	for (int i = A;i < (B+1);i++){
		if(i/10000 == i % 10 && i/1000 % 10 == i % 100 / 10){
			count+=1;
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
typedef long long LL;
LL mod=1e9+7;
LL ppower(LL s)
{
	LL r=1,a=2;
	while(s)
	{
		if(s&1) r=r*a%mod;
			a=a*a%mod;
			s=s>>1;
	}
	return r;
}
int main()
{
	LL a[100005],n,m,resu;
	while(~scanf("%ld",&n))
	{
		memset(a,0,sizeof(a));
		for(LL i=0;i<n;i++)
		{
			scanf("%ld",&m);
			a[m]++;
		}
		LL flag=0;
		if(n&1)
		{
			if(a[0]>1)
				flag=1;
			else 
			{
				for(LL i=1;i<n;i++)
				{
					if(a[i]>2||a[i]==1)
						flag=1;
					if(flag) 
						break;
				}		
			}
			if(!flag)
				resu=ppower(n/2) ;
		}
		else
		{
			if(a[0]>0)
				flag=1;
			else 
			{
				for(LL i=1;i<n;i++)
				{
					if(a[i]>2||a[i]==1)
						flag=1;
					if(flag) 
						break;
				}		
			}
			if(!flag)
				resu=ppower(n/2) ;
		}
		if(flag) printf("0\n");
		else printf("%lld\n",resu);
	}
	return 0;
}

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

int main() {
  ll A, B, K;
  cin >> A >> B >> K;

  if (K <= A) {
    cout << A - K << " " << B << endl;
  } else if (K - A <= B) {
    cout << 0 << " " << B - K + A << endl;
  } else {
    cout << 0 << " " << 0 << endl;
  }
}

Measured memory_bytes: 3528
using System;
using System.Linq;
namespace AGC010A
{
    class Program
    {
        static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            long[] a = Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
            string ans = (a.Sum() % 2 == 0) ? "YES" : "NO";
            Console.WriteLine(ans);
        }
    }
}

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

void solve() {
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    ll sum = 0;
    if(k <= a) {cout << k; return;}
    else {
        sum += a;
        k -= a;
        if(k <= b) {cout << sum; return;}
        else {
            k -= b;
            sum -= k;
            cout << sum;
        }
    }
}

int main() {
    ios_base :: sync_with_stdio(false); 
    cin.tie(NULL);
    int t = 1;
    //cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3640
n,U,c[20],R[20],a,i;S(k,s,A,m,b){b=s<U;b&k<n&&S(k+1,s,A,m)+S(k+1,s+c[k],A|1<<k,m+1);for(i=n*!b;i--;)b|=A&1<<i&&A&R[i]^R[i];m<a*!b?a=m:0;}main(k,t){for(;scanf("%d%d",&n,&U)*n;S(0,0,0,0),printf("%d\n",a))for(a=i=n;i--;)for(R[i]=!scanf("%d%d",c+i,&k);k--;R[i]|=1<<n-1-t)scanf("%d",&t);}

Measured memory_bytes: 408
import java.util.*;
import java.io.*;
public class Main {

	public static void main(String[] args) throws Exception{
		int num = 998244353;

		// TODO Auto-generated method stub
 		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
 		PrintWriter out = new PrintWriter(System.out);
 		int n = Integer.parseInt(bf.readLine());
 		StringTokenizer st = new StringTokenizer(bf.readLine());
 		int[] freq = new int[100001];
 		long sum = 0;
 		for(int i = 0;i<n;i++){
 			int a= Integer.parseInt(st.nextToken());
 			freq[a]++;
 			sum+=(long)(a);
 		} 		
 		int q = Integer.parseInt(bf.readLine());
 		
 		for(int i =0 ;i<q;i++){
 			StringTokenizer st1 = new StringTokenizer(bf.readLine());
 			int a = Integer.parseInt(st1.nextToken());
 			int b = Integer.parseInt(st1.nextToken());

 				sum = sum-(long)(a)*(long)(freq[a])+(long)(b)*(long)(freq[a]);
 				out.println(sum);
 				freq[b]+=freq[a];
 				freq[a] = 0;

 		}
 		out.close();
 		
 	}
}
 	

Measured memory_bytes: 45500
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    string str;
    cin >> str;
    int N = str.size();

    int ret = 0;

    for (int left = 0; left <= N; left++) {
        for (int right = 0; right <= N; right++) {
            if (left + right > N) continue;
            bool flag = false;

            for (int i = left; i < N - right; i++) {
                if (str[i] != 'A' && str[i] != 'C' && str[i] != 'G' && str[i] != 'T') {
                    flag = true;
                    break;
                }
            }

            if (flag) continue;
            ret = max(ret, N - (right + left));
        }
    }

    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    a%=b;
    if(a==0)return b;
    return gcd(a,b);
}
bool Solve(){
    ll a,b,c,d;cin>>a>>b>>c>>d;
    if(a<b)return 0;
    if(c>=b&&d>=b)return 1;
    if(d<b)return 0;
    ll g=gcd(b,d);
    //cout<<"#"<<b+a%g-g<<" "<<c+1<<" "<<"A:"<<a<<" B:"<<b<<" g:"<<g<<endl;
    return (b+a%g-g<c+1);
}
int main(){
    ll t;cin>>t;
    lol(i,t){
	cout<<(Solve()?"Yes":"No")<<endl;
    }
    return 0;
}


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

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

    int W, H, N;
    cin >> W >> H >> N;

    int xmin = 0, xmax = W;
    int ymin = 0, ymax = H;
    while (N--) {
        int x, y, a;
        cin >> x >> y >> a;
        switch (a) {
            case 1:
                xmin = max(xmin, x);
                break;
            case 2:
                xmax = min(xmax, x);
                break;
            case 3:
                ymin = max(ymin, y);
                break;
            case 4:
                ymax = min(ymax, y);
                break;
        }
    }

    cout << ((xmax <= xmin || ymax <= ymin) ? 0 : (xmax - xmin) * (ymax - ymin)) << endl;

    return 0;
}

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

using lint = long long;

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


	priority_queue<pair<lint, lint>, vector<pair<lint, lint>>, greater<pair<lint, lint>>> pq;


	for (int i = 0; i < n; i++) {
		lint a, b;
		cin >> a >> b;

		pq.push({b, a});
	}

	lint cur = 0;
	while (!pq.empty()) {
		auto p = pq.top();
		pq.pop();

		cur += p.second;
		if (cur > p.first) {
			cout << "No\n";
			return 0;
		}
	}

	cout << "Yes\n";
}

Measured memory_bytes: 6512
A, B = gets.split.map(&:to_i)

min = 10000000

(10000).times do |i|
  if (i * 0.08).to_i == A && (i * 0.1).to_i == B
    if i <= min
      min = i
    end
  end
end

if min == 10000000
  puts -1
else
  puts min
end

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
 
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
 
 
signed main(){
	int N;
	cin>>N;
	map<int,int>m;
	rep(i,N){
		int a;cin>>a;m[a]++;
	}	
	
	if(N%3){
		if(m[0]==N){
			cout<<"Yes"<<endl;
		}
		else{
			cout<<"No"<<endl;
		}
	}
	else{
		bool ok=true;
		int x=0;
		N/=3;
		for(auto p:m){
			if(p.se%N)ok=false;
			rep(i,p.se/N)x^=p.fi;
		}
		if(x)ok=false;
 
		if(ok)cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 8340
#include <stdio.h>
 
int main(void)
{
  int n = 0;
  int a[100];
  int i;
 
  scanf("%d", &n);
 
  for(i = 0; i < n; i++)
    scanf("%d", &a[i]);
 
  for(i = n - 1; i > 0; i--)
    printf("%d ", a[i]);
 
  printf("%d\n", a[i]);
 
  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#include <vector>
#include <string>
using namespace std;
#define FL(i,a,b) for(int i = a;i<b;i++)
typedef vector<int> vi;

const int inf = numeric_limits<int>::max();


int main(){   
    long int n;
    cin>>n;
    unordered_map <string,int> hasho;
    FL(i,1,n+1){
        string temp;
        cin>>temp;
        if(hasho.count(temp)){
            hasho[temp] += 1;
        }
        else{
            hasho[temp] = 1;
        }
    }
    long int count = 0;
    unordered_map<string,int>::iterator it;
    for(it = hasho.begin();it!=hasho.end();it++){
        count++;
    }
    cout<<count;
}

















Measured memory_bytes: 17648
#include<bits/stdc++.h>
using namespace std;
#define rt(i,n) for(int i=0;i<n;i++)
int main(){
  int h,w;cin>>h>>w;
  vector<string>a(1);
  cin>>a.at(0);
  if(h>1){
    rt(i,h-1){
      string s;cin>>s;
      int p=0;
      rt(j,w){if(s.at(j)=='#')p++;}
      if(p>0)a.push_back(s);
    }
  }
  h=a.size();
  int i=0;
  while(i<a.at(0).size()){
    int p=0;
    rt(j,h){if(a.at(j).at(i)=='#')p++;}
    if(p==0){
      rt(j,h)a.at(j)=a.at(j).erase(i,1);
      i--;
    }
    w=a.at(0).size();
    i++;
  }
  int k=0;
  rt(i,w){if(a.at(0).at(i)=='#')k++;}
  if(k>0){
    rt(i,h)cout<<a.at(i)<<endl;
  }
  else{
    for(int i=1;i<h;i++)cout<<a.at(i)<<endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <cmath>

using namespace std;

int main(void){
    string s;
    while (cin>>s && s != "#") {
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        a--, b--, c--, d--;
        
        int h = 1, w = 0;
        for (int i = 0; i < s.size(); i++) {
            if (s[i] == '/') h++;
            if (h <= 1) {
                if (s[i] == 'b') w++;
                else w += s[i]-'0';
            }
        }
        vector<string> g(h, string(w, '.'));
        
        int th = 0, tw = 0;
        for (int i = 0; i < s.size(); i++) {
            if (s[i] == '/') th++, tw = 0;
            else if (s[i] == 'b') g[th][tw] = 'b', tw++;
            else tw += s[i]-'0';
        }
        swap (g[a][b], g[c][d]);
        
        string ans;
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (g[i][j] == 'b') ans += 'b';
                else {
                    int cnt = 1;
                    while (j+1 < w && g[i][j+1] == '.') cnt++, j++;
                    ans += '0'+cnt;
                }
            }
            if (i < h-1) ans += '/';
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 3168
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef vector<int> vi;
typedef pair<int, int> pi;
#define SQ(a) (a) * (a)
#define mod 1000000007
#define w(x) int x; cin>>x; while(x--)
#define deb(x) cout << #x << " = " << x << '\n'
#define deb2(x, y) cout << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n"
 
set<int> adj[10000005];
vector<bool> visited(1000005);

int mx;
int dfs(int node,int d){
    visited[node]=true;
    int depth=1;
    for(int u:adj[node]){
        if(!visited[u]){
            depth += dfs(u,d);
        }
    }
    return depth;
}

void solve(){
    int n,m;
    cin>>n>>m;
    mx=0;
    for(int i=1;i<=n;i++){
        visited[i]=0;
    }
    while(m--){
        int u,v;
        cin>>u>>v;
        adj[u].insert(v);
        adj[v].insert(u);
    }   
    for(int i=1;i<=n;i++){
        if(!visited[i]){
            mx=max(mx,dfs(i,0));
        }
    }
    cout<<mx;


}
 
int main(int argc, char const *argv[])
{
 
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    solve();
    return 0;
}

Measured memory_bytes: 500536
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const int mod = 1e9+7;

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

  string s; cin >> s;
  auto n = s.size();
  int ans = 999;
  rep(i, n) {
    if (i+2 >= n) continue;
    int a = (s.at(i) - '0');
    int b = (s.at(i+1) - '0');
    int c = (s.at(i+2) - '0');
    int d = a*100+b*10+c;
    int e = abs(d-753);
    ans = min(e, ans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;

int main(){
    ll k;
    string s;
    cin>>k>>s;
    if(s.size()<=k) cout<<s<<endl;
    else{
        rep(i,k) cout<<s[i];
        cout<<"..."<<endl;
    }
    return 0;
}

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

signed main(void)
{
	string s, t;
	char c[26], d[26];

	cin >> s >> t;
	rep(i, 26) c[i] = -1;
	rep(i, 26) d[i] = -1;
	rep(i, s.size())
	{
		int a = s[i] - 'a';
		int b = t[i] - 'a';
		if (c[a] != -1 || d[b] != -1)
		{
			if (c[a] != b || d[b] != a)
			{
				cout << "No" << endl;
				return 0;
			}
		}
		else
		{
			c[a] = b;
			d[b] = a;
		}
	}
	cout << "Yes" << endl;
	return 0;
}


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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string S[] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
    string day; cin >> day;
    rep(i, 7){
        if(day == S[i]) cout << 7-i << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int n=s.size();
  for(int i=1;i<n;i++){
    if((n-i)%2==1)continue;
    string t1,t2;
    t1=s.substr(0,(n-i)/2);
    t2=s.substr((n-i)/2,(n-i)/2);
    if(t1==t2){
      cout<<n-i<<endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3624
import math
a,b,C=map(float,input().split())
s=((a*b)*math.sin(math.radians(C)))/2
S='{:.8f}'.format(s)
d=math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(C)))
L='{:.8f}'.format(a+b+d)
e=2*s/a
h='{:.8f}'.format(e)

print(S)
print(L)
print(h)


Measured memory_bytes: 5692
grid = []
3.times { grid << gets.split.map(&:to_i) }

a1 = 0
b1 = grid[0][0] - a1
b2 = grid[0][1] - a1
b3 = grid[0][2] - a1
a2 = grid[1][0] - b1
a3 = grid[2][0] - b1

a = [a1, a2, a3]
b = [b1, b2, b3]

res = 'Yes'
3.times do |i|
  3.times do |j|
    break res = 'No' if grid[i][j] != a[i] + b[j]
  end
end

puts res


Measured memory_bytes: 1916
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define N 1000000
map<ll,vector<ll> > a;
bool arr[N];
void dfs(ll n){
	arr[n]=true;
	for(auto x:a[n]){
		if (!arr[x]){
			dfs(x);
		}
	}
	}
 
int main(){
	ll n,e,cnt=0;
	cin>>n>>e;
	for(int i=1;i<=e;i++){
		ll x,y;
		cin>>x>>y;
		a[x].push_back(y);
		a[y].push_back(x);
	}
	for(int i=1;i<=n;i++){
		if (!arr[i]){
		dfs(i);
		cnt++;
		}
		}
	cout<<cnt-1;
	return 0;
}

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



using ll = long long;
const int INF = 1e9+5;

int main(){
    int n,k;
    cin>>n;
    vector<int> dp(3,0);
    
    for(int i=0; i<n; i++){
        vector<int> h(3);
        for(int j=0; j<3; j++) cin>>h[j];
        vector<int> dpn(3,0);
        for(int j=0; j<3; j++){
            for(int k=0; k<3; k++){
                if(j!=k) dpn[k]=max(dp[j]+h[k], dpn[k]);
            }
            //cout<<dpn[j]<<" ";
        }
        dp=dpn;
    }
    cout<<max(max(dp[0],dp[1]),dp[2]);
    

    
}

Measured memory_bytes: 3620
import java.util.*;
public class Main {

    static int result = Integer.MAX_VALUE;
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int K = scanner.nextInt();
        helper(0, 1, N, K);
        System.out.println(result);


    }

    private static void helper(int i, int ans, int N, int K) {
        if (i == N) {
            result = Math.min(ans, result);
            return;
        }

        helper(i + 1, ans + K, N, K);
        helper(i + 1, ans * 2, N, K);
    }

}


Measured memory_bytes: 20948
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using ull=unsigned long long int;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
int main(){
while(1){
int n,m;
cin>>n>>m;
if(n==0)return 0;
V<V<int>> a(n,V<int>(m));
int ans=0;
for(int i=0;i<n;i++)for(int j=0;j<m;j++)cin>>a[i][j];
    for(int i=3;i<=10;i++){//縦の長さ
      for(int j=3;j<=10;j++){//横の長さ
      for(int k=0;k<n;k++){
        for(int l=0;l<m;l++){
          if(k+i>n||l+j>m)continue;
          int ma=INT_MAX;
          for(int i2=k;i2<k+i;i2++){//縦枠最小
            chmin(ma,a[i2][l]);
            chmin(ma,a[i2][l+j-1]);
          }
          for(int j2=l;j2<l+j;j2++){//横枠最小
            chmin(ma,a[k][j2]);
            chmin(ma,a[k+i-1][j2]);
          }
          bool c=true;int sum=0;
          for(int i2=k+1;i2<k+i-1;i2++){//内枠が水で満たせるか確認　及び最大容量を計算
            for(int j2=l+1;j2<l+j-1;j2++){
              if(ma<=a[i2][j2])c=false;
              else sum+=ma-a[i2][j2];
            }
          }
          if(c)chmax(ans,sum);
        }
      }
  }
}
cout<<ans<<"\n";
}
}


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

#define ll long long int
#define mod 1000000007

using namespace std;


int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    ll p = 100ll;
    ll amount;
    cin >> amount;
    
    int cnt = 0;
    while(p < amount){
        p += p/100;
        cnt++;
    }
    cout << cnt;
}









Measured memory_bytes: 3652
# include <iostream>
# include <cstring>

using namespace std;
const int mod = 1e9 + 7;
# define ll long long

ll mul(ll a, ll b){
  return ((a%mod) * (b%mod)) % mod;
}

int main(){

  int n;
  cin >> n;
  string s;
  cin >> s;

  int occ[26];
  memset(occ, 0, sizeof(occ));
  for(char c : s) occ[c-'a']++;
  
  ll ans = 1;
  for(char c='a'; c<='z'; c++){
    ans = mul(ans, occ[c-'a']+1);
  }

  ans = (ans + mod - 1) % mod;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
import java.io.*;
import java.util.*;
import static java.lang.Math.*;

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

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();
        int N = scanner.nextInt();
        long[] list = new long[N];
        for (int i = 0; i < N; i++) {
            list[i] = scanner.nextLong() - i;
        }

        Arrays.sort(list);
        long mid = list[list.length/2];

        long ans = 0;
        for (int i = 0; i < N; i++) {
            ans += Math.abs(list[i] - (mid));
        }

        System.out.println(ans);
    }

    private long search(long v, long[] list) {
        long ans = 0;
        for (int i = 0; i < list.length; i++) {
            ans += Math.abs(v - list[i]);
            v++;
        }
        return ans;
    }

    private class MyScanner {
        String[] s;int i;BufferedReader br;String reg = " ";
        MyScanner () { s = new String[0];i = 0;br = new BufferedReader(new InputStreamReader(System.in)); }
        public String next() {
            try {
                if (i < s.length) return s[i++]; String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0); i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}


Measured memory_bytes: 50812
#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() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int r; cin >> r;
  cout << r * 2 * 3.1415926535 << endl;
}


Measured memory_bytes: 3804
#include <bits/stdc++.h>
const int N = 1e5 + 54;
typedef long long ll;

inline void up(int &x, int y) { x < y ? x = y : 0; }
inline void down(int &x, int y) { x > y ? x = y : 0; }
int n, m, a[N], f[N], ans;
int main() {
    std::cin >> n >> m;
    for (int i = 1; i <= n; ++i) std::cin >> a[i];
    while (m--) {
    	int x, y;
    	std::cin >> x >> y;
    	if (a[x] > a[y]) f[y] = 1;
    	if (a[x] < a[y]) f[x] = 1;
    	if (a[x] == a[y]) f[x] = f[y] = 1;
	}
	for (int i = 1; i <= n; ++i) ans += 1 - f[i];
	std::cout << ans << '\n';
	return 0;
}










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

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

typedef long long ll;
typedef long long int64;

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

  int n = floor(s.size()/2);

  if(s.size()%2 != 0){
    string s2 = s.substr(n+1);
    reverse(s2.begin(), s2.end());
    string s3 = s.erase(n);

    int ret = 0;
    for(int i=0; i<s2.size(); i++){
      if(s2[i] != s3[i]) ret++;
    }

    cout << ret << endl;
  } else {
    string s2 = s.substr(n);
    reverse(s2.begin(), s2.end());
    string s3 = s.erase(n);

    int ret = 0;
    for(int i=0; i<s2.size(); i++){
      if(s2[i] != s3[i]) ret++;
    }

    cout << ret << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll x[n];
    for(int i=0;i<n;i++)cin>>x[i];
    ll ans=1e18,num;
    for(ll i=1LL;i<=100;i++){
        num=0;
        for(int j=0;j<n;j++){
            num+=pow(x[j]-i,2);
        }
        ans=min(ans,num);
    }
    cout << ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};
int dx9[9]={0,1,0,-1,1,-1,1,0,-1};
int dy9[9]={0,1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int k;
string s;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> k >> s;
  if(s.length() <= k) cout << s << endl;
  else {
    REP(i, k) cout << s[i];
    cout << "..." << endl;
  }
}


Measured memory_bytes: 3652