akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;
using ll = long long;

unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    ll a;
    cin >> a;
    ll y = 100;
    ll aa = 0;
    for (int i = 0; i < 100000; i++) {
        if (a <= y) {
            aa = i; break;
        }
        y *= 1.01;

    }
    cout << aa << endl;
}

Measured memory_bytes: 3624
#include "bits/stdc++.h"

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;

int main(){

    ll K, S; cin >> K >> S;

    ll ans = 0;
    for(ll i = 0; i <= min(K, S); i++){
        if(i > K){
            break;
        }
        for(ll j = 0; j <= min(K, S); j++){
            if(i + j > S){
                break;
            }
            if(S - (i + j) <= K){
                ans++;
            }  
        }       
    }

    cout << ans << endl;

}

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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
// cout << fixed << setprecision(20);

int N,M;
int P[110000],Y[110000];
vector<pint> vec[110000];
int ans1[110000],ans2[110000];
signed main() {
    cin>>N>>M;
    for(int i=0;i<M;i++){
        cin>>P[i]>>Y[i];
        vec[P[i]].push_back(pint(Y[i],i));
    }
    for(int i=1;i<=N;i++){
        sort(vec[i].begin(),vec[i].end());
        for(int j=0;j<vec[i].size();j++){
            ans1[vec[i][j].second]=i;
            ans2[vec[i][j].second]=j+1;
        }
    }
    for(int i=0;i<M;i++){
        printf("%06lld%06lld\n",ans1[i],ans2[i]);
    }
}


Measured memory_bytes: 10368
N, W = map(int, input().split())
objects = [tuple(map(int, input().split())) for i in range(N)]

dp = {(N, j):0 for j in range(W + 1)}

for i in reversed(range(N)):
    for	j in range(W+1):
        if j < objects[i][1]:
            dp[(i, j)] = dp[(i+1, j)]
        else:
            dp[(i, j)] = max(dp[(i + 1), j], dp[(i + 1), (j - objects[i][1])] + objects[i][0])

print(dp[(0, W)])


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

int main()
{
	int c1,c2,c3;
	bool C[10];
	while(cin >> c1 >> c2 >> c3){
		for(int i = 0; i < 10; ++i) C[i] = true;
		C[c1-1] = C[c2-1] = C[c3-1] = false;
		int count = 0;
		for(int i = 0; i < 10; ++i){
			if(C[i]){
				if(c1 + c2 + i + 1 <= 20){
					count++;
				}
			}
		}
		cout << ((count / 7.0) >= 0.5 ? "YES" : "NO") << endl;
	}
}

Measured memory_bytes: 1152
/*
*author : alfarelzaki
*created : 27.04.2019
*/
#include <bits/stdc++.h>
using namespace std;

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

	int n, sum=0;
	cin >> n;
	int arr1[n], arr2[n];
	for (int i=0; i<n; i++){
		cin >> arr1[i];
	}

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

	for (int i=0; i<n; i++){
		sum+=max(arr1[i]-arr2[i],0);
	}

	cout << sum << "\n";
}

Measured memory_bytes: 256
#!/usr/bin/env python3
n = int(input())
a = list(map(int, input().split()))
a.sort()
parent = [a[-1]]
rest = a[:-1]
for _ in range(n):
    next_parent = []
    next_rest = []
    for p in parent[::-1]:
        while rest:
            x = rest.pop()
            if x < p:
                next_parent.append(x)
                break
            else:
                next_rest.append(x)
                continue
    parent += next_parent
    parent.sort()
    rest = rest + next_rest[::-1]

if len(parent) == 2**n:
    ans = 'Yes'
else:
    ans = 'No'
print(ans)


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

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
// #define exit(a, b) return cout << a, b;

#define PB push_back
#define MP make_pair

#define sd(n) scanf("%lld", &n)
#define pdn(n) printf("%lld\n", n);
#define pds(n) printf("%lld ", n);
#define endl '\n'

#define forn(a, b, i) for (int i = a; i < b; i += 1)
#define all(v) v.begin(), v.end() 

#define print(stuff) cout << stuff << endl
#define len(stuff) (int) stuff.size()

#define int long long
// #define float long double 
#define ll long long
#define ld long double

using vi = vector<int>;
using vb = vector<bool>;
using pii = pair<int, int>;
using mii = map<int, int>;

const int inf = (int) 1e16;
const int upper = (int) 2e5 + 50;
const int M = (ll) 1e9 + 7;
const int mod = (ll) 998244353;
const double eps =  1e-8;
int n, m;
bool vis[(int) 1e5 + 1] = {0};
int cnt = 0;
vector<int> adj[upper];
void dfs (int v) {
	vis[v] = true;
	for (auto i: adj[v]) {
		if (!vis[i]) dfs(i);
	}
}
signed main () {
	start_routine();
	speed();
	#ifdef LOCAL
	freopen("input.txt", "r", stdin);	 
	// freopen("output.txt", "w", stdout);
	// freopen("errlog.txt", "w", stderr);
	#endif	
	cin >> n >> m;
	for (int i = 1; i <= m; i++) {
		int a, b, c; cin >> a >> b >> c;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	for (int i = 1; i <= n; i += 1) {
		if (!vis[i]) {
			cnt++;
			dfs(i);
		}
	}
	cout << cnt;
 	end_routine();		
}

Measured memory_bytes: 11520
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstring>

using namespace std;

int const N = 1e5 + 41;
char s[N];
int n, rem;

int main(){
	scanf("%s",&s);
	n = strlen(s);
	if(s[0] == s[n-1]){
		rem = 1;
	}else{
		rem = 0;
	}
	if((n - rem) % 2 == 1){
		printf("First\n");
	}else{
		printf("Second\n");
	}







	return 0;
}

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

using namespace std;

int main(void) {
  int n;
  cin >> n;
  int a[n];
  int odd = 0;
  for(int i = 0; i < n; i++) {
    cin >> a[i];
    if(a[i] % 2 != 0) {
      odd++;
    }
  }

  if(odd % 2 != 0) {
    cout << "NO" << endl;
  }
  else {
    cout << "YES" << endl;
  }

  
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using lld = int64_t;
static constexpr int N = 200000 + 5;
static constexpr int MOD = 1000000007;

inline int add( int x, int y ) {
	return x + y >= MOD ? x + y - MOD : x + y;
}
inline int sub( int x, int y ) {
	return x - y < 0 ? x - y + MOD : x - y;
}
inline int mul( lld a, lld b ) {
	return static_cast< int >( a * b % MOD );
}
inline int qPow( int a, lld k ) {
	int ret = 1;
	while ( k ) {
		if ( k & 1 ) ret = mul( ret, a );
		k >>= 1; a = mul( a, a );
	}
	return ret;
}

int base[ N ], arr[ N ];
int cnt[ N ], dp[ N ];

int main() {
	ios_base::sync_with_stdio( false );
	cin.tie( nullptr );
	int n; cin >> n;
	for ( int i = 0 ; i < n ; ++ i )
		cin >> base[ i ];
	int pt = 0; arr[ pt ++ ] = base[ 0 ];
	for ( int i = 1 ; i < n ; ++ i ) {
		if ( base[ i ] != arr[ pt - 1 ] )
			arr[ pt ++ ] = base[ i ];
	}
	n = pt; dp[ 0 ] = 1; cnt[ arr[ 0 ] ] = 1;
	for ( int i = 1 ; i < n ; ++ i ) {
		cnt[ arr[ i ] ] = add( cnt[ arr[ i ] ], dp[ i - 1 ] );
		dp[ i ] = cnt[ arr[ i ] ];
//		cout << "dp[ " << i << " ] = " << dp[ i ] << '\n';
	}
	cout << dp[ n - 1 ] << '\n';
	return 0;
}

/*
dp[ i ] := [1, i]共有幾種方法數
dp[ i ] := \sum_{ arr[ j ] = arr[ i ] } dp[ j - 1 ]
*/

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int a[100001][3];
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int z,x,y;
		cin>>z>>x>>y;
		a[i][0]=z;
		a[i][1]=x;
		a[i][2]=y;
		if(x+y>z)
		{
			cout<<"No";
			return 0;
		}
		if(x+y-a[i-1][1]-a[i-1][2]>a[i][0]-a[i-1][0]&&i!=1)
		{
			cout<<"No";
			return 0;
		}
		if((x+y)%2!=z%2)
		{
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
}

Measured memory_bytes: 1408
s=int(input())
ans=0
import math
for i in range(1,1+s//3):
    t=math.factorial(s-2*i-1)
    u=math.factorial(s-3*i)
    v=math.factorial(i-1)
    w=t//(u*v)
    ans+=w
print(ans%(10**9+7))



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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define all(x) begin(x), end(x)
#define loop(i,n) for(int i=0; i<n; i++)
#define rep(i,a,b,c) for(int i=a; i<b; i+=c)
#define brep(i,a,b,c) for(int i=a; i>b; i-=c)
#define tc(t) int t; cin>>t; while(t--)
#define sz(v) int((v).size())
#define pb push_back


using namespace std;

void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {std::cout << x;}
void __print(unsigned x) {std::cout << x;}
void __print(unsigned long x) {std::cout << x;}
void __print(unsigned long long x) {std::cout << x;}
void __print(float x) {std::cout << x;}
void __print(double x) {std::cout << x;}
void __print(long double x) {std::cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i : x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
template <typename T> inline void inp(T &any) {cin >> any;} template <typename T, typename... U>inline void inp(T &a, U &...b) {cin >> a; inp(b...);}
#define rin(args...) ll args; inp(args);
#ifndef ONLINE_JUDGE
#define debug(x...) cout << "[" << #x << "] = ["; _print(x)
#define matdeb(mat,row,col) cout << #mat << "::" << endl; printmat(mat,row,col); printpartition;
#define debugv(v,n) cout << #v << ":" << endl; printv(v,0,n-1); printpartition;
#else
#define debug(x...)
#define matdeb(mat,row,col)
#define debugv(v,n)
#endif

const int maxm = 1000000000 + 7;

const ll MOD = 1e9 + 7;
const int INF = 55;
ll dp [INF] [INF * INF];

double startTime;
double getCurrentTime() {
  return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}


//----------->CODE BEGINS --------------->

bool ispal(int i)
{
  
  string j = to_string(i);

  int start = 0;
  int end = j.length() - 1;

  while (start < end)
  {
    if (j[start] != j[end])
    {
      return false;
    }
    start++;
    end--;
  }
  return true;
}


int main()
{

#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  IOS;

  int a, b;
  cin >> a >> b;

  int ans = 0;

  for (int i = a; i <= b; i++)
  {
    if (ispal(i))
    {
      ans++;
    }
  }

  cout << ans << endl;


}


Measured memory_bytes: 3772
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<bitset>

using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E12;/*10^12*/
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
////////////////////////////////////////

struct x{
    int a,b,c,d;
};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h,w;cin>>h>>w;
    int a[h+1][w+1];rep(i,1,h)rep(j,1,w)cin>>a[i][j];
    
    vector<x>ans;
    rep(i,1,h){
        rep(j,1,w-1){
            if(a[i][j]%2==1){
                a[i][j]--;
                a[i][j+1]++;
                x t;
                t.a=i;t.b=j;t.c=i;t.d=j+1;
                ans.pb(t);
            }
        }
    }
    rep(i,1,h-1){
        if(a[i][w]%2==1){
            a[i][w]--;
            a[i+1][w]++;
            x t;
            t.a=i;t.b=w;t.c=i+1;t.d=w;
            ans.pb(t);
        }
    }
    cout<<ans.size()<<endl;
    for(auto q:ans){
        cout<<q.a<<" "<<q.b<<" "<<q.c<<" "<<q.d<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 5232
K = int(input())
L = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(L[K-1])


Measured memory_bytes: 38256
#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#include<cmath>
#include<stack>
#include<algorithm>
#define rg register
#define ll long long
#define LDB long double
#define ull unsigned long long
#define view(i,x) for(rg int i=hd[x];i!=-1;i=e[i].nt)
#define go(i,x,a) for(rg int i=a;i<x;i++)
#define inf 0x3f3f3f3f
#define INF 0x7fffffff
using namespace std;

const int maxn=2*1e5+5;
int h,w,n,tt,a[maxn];
struct edd{
	int x,y;
}p[maxn];

inline int rd(){
	int ret=0,af=1; char gc=getchar();
	while(gc < '0' || gc > '9'){ if(gc=='-') af=-af; gc=getchar(); }
	while(gc >= '0' && gc <= '9') ret=ret*10+gc-'0',gc=getchar();
	return ret*af;
}

int main(){
	h=rd(); w=rd(); n=rd(); int x,y,ansq=h;
	memset(a,63,sizeof(a));
	go(i,n+1,1){
		x=rd(); y=rd(); if(x < y) continue;
		p[++tt].x=x; p[tt].y=y;
		a[x-y]=min(a[x-y],x);
	}
	go(i,h+1,1){
		if(a[i] > a[i-1]) continue;
		if(a[i]-1 < ansq) ansq=a[i]-1;
	}
	printf("%d",ansq);
	return 0;
}//Faze


Measured memory_bytes: 2304
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#include<bitset>
#include<iomanip>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int N,M,R;
int d[201][201],color[201][201];
vpint adj[201];
void dijkstra(int s){
	priority_queue<pint> PQ;
	rep(i,N){
		d[s][i]=INF;
		color[s][i]=0;
	}
	d[s][s]=0;
	color[s][s]=1;
	PQ.push(mp(0,s));
	while(!PQ.empty()){
		pint f=PQ.top();
		PQ.pop();
		int u=f.second;
		color[s][u]=2;
		if(d[s][u]< -f.first) continue;
		rep(j,adj[u].size()){
			int v=adj[u][j].first;
			if(color[s][v]==2) continue;
			if(d[s][v]>d[s][u]+adj[u][j].second){
				d[s][v]=d[s][u]+adj[u][j].second;
				PQ.push(mp(-d[s][v],v));
				color[s][v]=1;
			}
		}
	}
}
int main(){
	int r[10];
	scan(N);scan(M);scan(R);
	rep(i,R){
		scan(r[i]);
		r[i]--;
	}
	rep(i,M){
		int a,b,c;
		scan(a);scan(b);scan(c);
		a--; b--;
		adj[a].push_back(mp(b,c));
		adj[b].push_back(mp(a,c));
	}
	rep(i,R){
		dijkstra(r[i]);
	}
	vint junban;
	rep(i,R){
		junban.push_back(i);
	}
	int ans=INF;
	do{
		int from,to;
		int pathsum=0;
		rep(i,R-1){
			from=r[junban[i]],to=r[junban[i+1]];
			pathsum+=d[from][to];
		}
		ans=min(ans,pathsum);
	}while(next_permutation(junban.begin(),junban.end()));
	prin(ans);
	return 0;
}


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

int main() {
  string s;
  cin >> s;
  int n = s.size();
  
  int ans = 0;
  for ( int i = 0; i < n/2; i++ ) {
    if ( s[i] != s[n-i-1] ) {
      ans++;
    }
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    double a, b, x, y, z;
    int h, m;
    cin >> a >> b >> h >> m;
    x = 30.0 * h + m / 2.0;
    y = 6.0 * m;
    cout << setprecision(15);
    z =  max(x, y) - min(x, y);
    z *= pi / 180;
    cout << sqrt(a*a + b*b - 2.0 * a * b * cos(z)) << endl;
}


Measured memory_bytes: 4168
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 30;
// clang-format on
int A, B;

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> A >> B;

  vector<int> candidate = {1, 2, 3};

  for (int c : candidate) {
    if (A != c && B != c) {
      cout << c << endl;
    }
  }

  return 0;

  return 0;
}


Measured memory_bytes: 256
// D - Grid Repainting
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using VC = vector<char>;
using VVC = vector<VC>;
using PII = pair<int,int>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)

int bfs(int H, int W, VVC &S){
	int dx[4]={0,-1,0,1}, dy[4]={-1,0,1,0};
	vvi dist(H+1, vi(W+1, -1));
	dist[1][1] = 0;
	queue<PII> q;
	q.push({1, 1});
	while(!q.empty()){
		int i,j; tie(i,j)= q.front(); q.pop();
		if(S[i][j] == '_') continue;
		S[i][j] = '_';
		if(i==H && j==W) break;
		rpz(k, 4){
			int y = i + dy[k], x = j + dx[k];
			if(S[y][x] != '.') continue;
			dist[y][x] = dist[i][j] + 1;
			q.push({y, x});
		}
	}
	return dist[H][W];
}

int main(){
	int H,W; cin>>H>>W;
	VVC S(H+2,VC(W+2, '#'));
	int white = 0;
	rpz(i, H){
		string s; cin>>s;
		rpz(j, W){
			if(s[j] == '.') white++;
			S[i+1][j+1] = s[j];
		}
	}
	int dist = bfs(H, W, S);
	cout<< (dist<0? -1: white - dist - 1) <<endl;
}

Measured memory_bytes: 256
N,W=map(int,input().split()) 
#0で初期化されたj*iの二次元配列を作る 
DP= [[0 for j in range(W+1)] for i in range(N+1)]
v=[0]*(N+1)
w=[0]*(N+1)
for i in range(1,N+1):
    v[i],w[i]=map(int,input().split())
for i in range(1,N+1):
    for j in range(1,W+1):
        if j-w[i]<0:
            DP[i][j]=DP[i-1][j]
        else:
            if v[i]+DP[i-1][j-w[i]]>DP[i-1][j]:
                DP[i][j]=v[i]+DP[i-1][j-w[i]]
            else:
                DP[i][j]=DP[i-1][j]        
print(DP[N][W]) 


Measured memory_bytes: 25944
import random

def main():
    D = int(input())
    c_list = list(map(int, input().split()))
    s_list = [list(map(int, input().split())) for _ in range(D)]
    
    basic_bad = sum(c_list)

    # 初期解生成は必要っぽい
    res = 0
    bad = 0
    last_open = [0] * 26
    t_list = [0] * D

    max_res = -1
    max_t_list = [0] * D

    # loop
    for m in range(10**4):
        t_list = [random.randint(0,25) for i in range(D)]
        res = 0
        bad = 0
        last_open = [0] * 26
        for i in range(D):
            t = t_list[i]
            
            res += s_list[i][t]
            bad += basic_bad - (i+1 - last_open[t]) * c_list[t]
            last_open[t] = i+1

            res -= bad
            
        if max_res == -1 or max_res < res:
            max_res = res
            max_t_list = t_list.copy()

    for t in max_t_list:
        print(t+1)

if __name__ == "__main__":
    main()


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

int main() {

	ll n; cin >> n;
	int num_four = 0;
	int num_two = 0;
	for (ll i = 0; i < n; i++) {
		ll a; cin >> a;
		if (a % 4 == 0) num_four++;
		else if (a % 2 == 0) num_two++;
	}
	int num_result = n - num_four - num_two;
	bool can = false;
	if (n % 2 != 0) {
		if (num_result - num_four <= 1) {
			can = true;
		}
		else {
			can = false;
		}
	}
	else { // n % 2 == 0
		if (num_result - num_four <= 0) {
			can = true;
		}
		else {
			can = false;
		}
	}
	if (can) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3644
#include<stdio.h>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<iterator>
#include<iomanip>
#include<string>
using namespace std;

int main()
{
    double l;
    cin>>l;
    cout<<fixed<<setprecision(10)<<l*l*l/27;
    return 0;
}

Measured memory_bytes: 3708
N = int(input())
A = list(map(int, input().split()))
pre = 0
sumall = 0

for i in range(N):
   sumall += abs(A[i] - pre)
   pre = A[i]

sumall += abs(A[i])
pre = 0
for i in range(N-1):
    ans = sumall - abs(A[i] -pre) - abs(A[i+1] - A[i]) + abs(A[i+1] -pre)
    pre = A[i]
    print(ans)
print(sumall - abs(A[N-1] -A[N-2]) - abs(A[N-1]) + abs(A[N-2]))   

Measured memory_bytes: 14172
N=int(input())
A=list(map(int,input().split()))
B=sorted(A)+[0]
cnt=1
n=0
dict={}
for i in range(N):
  if B[i+1]==B[i]:
    cnt+=1
  else:
    n+=cnt*(cnt-1)//2
    dict[B[i]]=cnt
    cnt=1
for i in A:
  print(n-(dict[i]-1))

Measured memory_bytes: 26092
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <iomanip>
#pragma region Macros
#define int long long
#define double long double
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
int GCD(int a, int b) // assuming a,b >= 1
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
	return  a * b / GCD(a, b);
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min, int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}

using namespace std;
#pragma endregion
signed main() {
	int N,b=0,c=1;
	cin >> N;
	vector <int>a(N);
	rep(i, N) {
		cin >> a[i];
		if (a[i] == 1)
			b++;
	}
	if (b == 0)
		cout << -1;
	else {
		rep(i, N) {
			if (a[i] == c)
				c++;
		}
		cout << N - c+1;
	}
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(void){

  float a,b;
  scanf("%f %f",&a,&b);

  float kagen = b/0.1;
  float jogen = (b+1.0)/0.1;

  int answer = -1;
  int start = kagen/1;
  if (start*10/100 != b) {
    start++;
  }
  for (int i = start; i < jogen; i++) {
    if (i*8/100 == a) {
      answer = i;
      break;
    }
  }

  printf("%d\n", answer);

  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;

int main(){
  int N,cnt = 0,num = 1;
  cin >> N;
  for(int i = N; i >= 1; i--){
    for(int j = 1; j < 7; j++){
      if(i % (1<<j) == 0){
        if(cnt < j){
          cnt = j;
          num = i;
        }
      }
    }
    //cout << num << " " << cnt << endl;
  }

  cout << num << endl;
}


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

int main(){
	string s1, s2;
	stack<int> sum;
	int tmp, carry, n, len1, len2;

	cin>>n;
	while(n--){
		tmp = carry = 0;
		while(!sum.empty())sum.pop();
		cin>>s1>>s2;
		len1 = s1.length()-1;
		len2 = s2.length()-1;
		reverse(s1.begin(), s1.end());
		reverse(s2.begin(), s2.end());

		for(int i=0; i<81; i++){
			tmp = carry;
			if(i<=len1) tmp += s1[i]-'0';
			if(i<=len2) tmp += s2[i]-'0';
			sum.push(tmp%10);
			carry = tmp/10;
		}
		if(sum.top() != 0)cout<<"overflow\n";
		else{
			for(int i=0; i<80; i++){
				if(sum.top()==0)sum.pop();
				else break;
			}
			while(!sum.empty()){cout<<sum.top(); sum.pop();}
			cout<<"\n";
		}
	}	
	return 0;
}

Measured memory_bytes: 1208
#include<stdio.h>
int main(void){
    int a,b;
    scanf("%d %d", &a,&b);
    
    int seki;
    double s;
    
    seki=a*b;
    s=seki/3.305785;
    
    printf("%f\n",s);
    
    return 0;
}


Measured memory_bytes: 2056
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,x) for(int i=1;i<=x;i++)
#define put(ans)    cout << ans << endl;
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}
//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

int main(){
    int n,m,ans(0);
    cin >> n >> m;
    rep(i,m){
        int a;
        cin >> a;
        ans += a;
    }
    if(ans>n){
        put(-1);
    }
    if(ans==n){
        put(0);
    }
    if(ans<n){
        put(n-ans);
    }
    return 0;
}

Measured memory_bytes: 3624
#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(){
	string s,t;
	cin>>s>>t;
	int ans=0;
	rep(i,s.size())if(s[i]==t[i])ans++;
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

int main(void){
	while( true ){
		int digits[10] = {0,};
		for(int i = 0; i < 10; i++){
			char c;

			cin >> c;
			if( cin.eof() ) return 0;
			digits[i] = c - '0';
		}
		cin.ignore();
		for(int i = 0; i < 10; i++){
			for(int j = 0; j < 9 - i; j++){
				digits[j] = (digits[j] + digits[j + 1]) % 10;
			}
		}
		cout << digits[0] << endl;
	}
	return 0;
}

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

int main() {
  int n;
  cin>>n;
  vector<long long> a(n);
  for(long long &x: a) cin>>x;
  long long ans_1=0,ans=0;
  long long sum_1=a[0],sum=a[0];
  while(sum_1<=0) {sum_1++; ans_1++;}
  while(sum>=0) {sum--; ans++;}
  for(int i=1;i<n;i++){
    sum_1+=a[i];
    if(i%2==1){
      while(sum_1>=0) {sum_1--; ans_1++;}
    }
    if(i%2==0){
      while(sum_1<=0) {sum_1++; ans_1++;}
    }
  }
  for(int i=1;i<n;i++){
    sum+=a[i];
    if(i%2==1){
      while(sum<=0) {sum++; ans++;}
    }
    if(i%2==0){
      while(sum>=0) {sum--; ans++;}
    }
  }
    cout<<min(ans_1,ans)<<endl;
}

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

#define infint 0x7fffffff //32-bit int
#define ninfint 0x80000000
#define EPS 1e-9

#define mp(A,B) make_pair(A,B)
#define pb push_back
#define pque priority_queue

#define isOn(S, j) (S & (1 << j))
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define lowBit(S) (S & (-S))
#define setAll(S, n) (S = (1 << n) - 1)

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;

#define endl '\n'

int N;
int H[100000], dp[100000];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N;
    for (int i = 0; i < N; ++i) {
        cin >> H[i];
    }
    dp[0] = 0; dp[1] = abs(H[1]-H[0]);
    for (int i = 2; i < N; ++i) {
        if (dp[i-1]+abs(H[i]-H[i-1]) < dp[i-2]+abs(H[i]-H[i-2])) {
            dp[i] = dp[i-1]+abs(H[i]-H[i-1]);
        } else {
            dp[i] = dp[i-2]+abs(H[i]-H[i-2]);
        }
    }
    cout << dp[N-1] << endl;

    return 0;
}


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

long long int amari=1000000007;

long long int kaizyou(long long int n){
  if(n==1){
    return 1;
  }
  return ((n*kaizyou(n-1))%amari);
}

main(){
  long long int n,m,ans;
  cin >> n >> m;
  if(n>m+1 || m>n+1){
    cout << "0" <<endl;
  }else{
    ans=kaizyou(n);
    ans*=kaizyou(m);
    if(n==m){
      ans*=2;
    }
    ans%=amari;
    cout << ans << endl;
  }
}


Measured memory_bytes: 1792
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    n, x = rli()
    ll = rli()
    ans = 1
    d = 0
    for l in ll:
        d += l
        if d <= x:
            ans += 1
    print(ans)



if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define ppll pair<ll,pll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = 1 << 29;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const int MAX_V = 500;
const ll mod = 998244353;
const ll MAX = 2100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



void solve() {

    ll k;
    cin>>k;
    rep(i,k){
        cout<<"ACL";
    }
    cout<<endl;

}



signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);


    ll t=1;
    
    // cin>>t;

    rep(i,t){
        solve(); 
    }

    return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int mod = 1e9+7;
const int MAX = 510000;
const int V = 100005;
ll dy[8] = {1,0,-1,0,1,-1,1,-1};
ll dx[8] = {0,1,0,-1,1,-1,-1,1};
const double pi = acos(-1);
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
#define INT_MAX 1e9+7

int main(){
    ll n; cin >> n;
    vl d(n);
    vl cnt(13,0);
    rep(i,n){
        cin >> d[i];
        cnt[d[i]]++;
    }
    ll ans = inf;
    ll ch = 0;
    vvl v(2);
    rep(i,12){
        if(cnt[i]==0) continue;
        ans = min(ans, i);
        if(cnt[i]>=3){
            puts("0");
            return 0;
        }
        if(cnt[i]==2){
            v[0].push_back(i);
            v[1].push_back(i);
            ans = min(ans, min(i,12-i)*2);
        }else{
            v[ch].push_back(i);
            ch = 1 - ch;
        }
    }
    if(cnt[12]>=2){
        puts("0");
        return 0;
    }else if(cnt[12]==1){
        v[0].push_back(12);
        v[1].push_back(12);
    }
    rep(i,2){
        if(v[i].empty()) continue;
        rep(j,v[i].size()-1){
            ans = min(ans, v[i][j+1] - v[i][j]);
        }
    }
    cout << ans << endl;
}

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define EPS 1e-6
#define INF 1000000000
#define LLINF 1000000000000000000
#define MOD 1000000007

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

bool noPrime[100011];

int main(){
	
	vector<int> primeList;
	for(int i = 2;i < 100011;i++){
		if(!noPrime[i]){
			primeList.PB(i);
			for(int j = i;j < 100011;j += i)noPrime[j] = true;
		}
	}
	
	int n;cin >> n;
	ll ans = 0;
	
	vector<pair<ll,ll>> v;
	REP(i,n){
		ll s;cin >> s;
		ll now = 1;
		ll ref = 1;
		for(int i = 0;primeList[i] <= 11111;i++){
			int cou = 0;
			while(s % primeList[i] == 0){
				cou = (cou + 1) % 3;
				s /= primeList[i];
			}
			if(cou){
				REP(j,cou)now *= primeList[i];
				REP(j,3-cou)ref *= primeList[i];
			}
			if(ref > 1e11)break;
		}

		if(ref * s > 1e11){
			ans++;
		}
		else {
			ll sq = sqrt(s);
			if(sq*sq != s){
				if(s > 100000)ans++;
				else v.PB(MP(now*s,ref*s*s));
			}
			else v.PB(MP(now*s,ref*sq));
		}
	}	
	
	set<ll> s;
	map<pair<ll,ll>,pair<ll,ll>> mp;
	
	REP(i,v.size()){
		ll a = max(v[i].FI, v[i].SE);
		ll b = min(v[i].FI, v[i].SE);
		if(v[i].FI > v[i].SE)mp[MP(a,b)].FI++;
		else mp[MP(a,b)].SE++;
	}
		
	for(auto it = mp.begin();it != mp.end();it++){
		if(it->FI.FI == it->FI.SE)ans++;
		else ans += max(it->SE.FI, it->SE.SE);
	}
	
	cout << ans << endl;
		
		
	return 0;
}

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

int main() {
  int A, B;
  cin >> A >> B;
  
  int sum = A * B;

  if (sum % 2 == 0) {
    cout << "Even" << endl;
  } else {
    cout << "Odd" << endl;
  }
}

Measured memory_bytes: 256
import java.io.*;  
public class Main {
    public static void main(String[] args) throws IOException {
	                                         
    	
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String buf = br.readLine();
    String[] x = buf.split(" ",0);

    	int a = Integer.parseInt(x[0]);
    	int b = Integer.parseInt(x[1]);

    	while (a!=0 || b!=0){
    	if ((0 <= a && a <= 10000)&&(0 <= b &&  b <=10000))
    		{
    		if(a>b){
    		int temp = a;
    		    a = b;
    		    b =temp;
    		}
    		System.out.println(a + " " + b); 
    		buf = br.readLine();
    		x = buf.split(" ",0);

    		a = Integer.parseInt(x[0]);
    		b = Integer.parseInt(x[1]);
    	}
    		
    	}
    
	}
}

Measured memory_bytes: 26732
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <tuple>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(perm),end(perm)
#define showall(obj) for(auto x:obj)cout<<x<<endl;
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
typedef vector<int> vint;
typedef vector<ll> vll;
const int inf = 100100100;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
    string s,t;cin>>s>>t;
    rep(i,s.size()+t.size()){
        cout<<((i%2==0)?s[i/2]:t[(i-1)/2]);
    }
}


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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

bool is_no_need(int num, vector<int>& A, int K)
{
  int ix = num - 1;
  int n = A.size();
  vector<bool> dp(K + 5, 0);
  dp[0] = 1;
  for (int i = 0; i < n; ++i) {
    if (i == ix) { continue; }
    for (int sum = K; sum >= 0; --sum) {
      if (sum >= A[i] and dp[sum - A[i]]) {
        dp[sum] = true;
      }
    }
  }
  for (int sum = max(0, K - A[ix]); sum < K; ++sum) {
    if (dp[sum]) { return false; }
  }
  return true;
}


// bool is_no_need(int num, vector<int>& A, int K)
// {
//   int ix = num - 1;
//   int n = A.size();
//   vector<vector<int>> dp(n + 5, vector<int>(K + 5, 0));
//   dp[0][0] = 1;
//   for (int i = 0; i < n; ++i) {
//     for (int sum = 0; sum <= K; ++sum) {
//       dp[i + 1][sum] = dp[i][sum];
//       if (i != ix and sum >= A[i]) {
//         dp[i + 1][sum] |= dp[i][sum - A[i]];
//       }
//     }
//   }
//   for (int sum = max(0, K - A[ix]); sum < K; ++sum) {
//     if (dp[n][sum]) { return false; }
//   }
//   return true;
// }

// bool is_no_need(int num, vector<int>& A, int K)
// {
//   int ix = num - 1;
//   int n = A.size();

//   vector<int> v(A.begin(), A.begin() + ix);
//   copy(A.begin() + ix + 1, A.end(), back_inserter(v));

//   vector<vector<int>> dp(n, vector<int>(K + 5, false));
//   dp[0][0] = 1;
//   int M = v.size();
//   for (int i = 0; i < M; ++i) {
//     for (int sum = 0; sum <= K; ++sum) {
//       dp[i + 1][sum] = dp[i][sum];
//       if (sum - v[i] >= 0) {
//         dp[i + 1][sum] |= dp[i][sum - v[i]];
//       }
//     }
//   }
//   bool ret = true;
//   for (int sum = max(0, K - A[ix]); sum < K; ++sum) {
//     if (dp[M][sum]) {
//       ret = false;
//       break;
//     }
//   }
//   return ret;
// }

int main()
{
  int N, K; scanf("%d %d", &N, &K);
  vector<int> A(N);
  for (int i = 0; i < N; ++i) {
    scanf("%d", &A[i]);
  }

  sort(A.begin(), A.end());
  int high = N + 1, low = 0;
  while (high - low > 1) {
    int mid = (high + low) / 2;
    if (is_no_need(mid, A, K)) { low = mid; }
    else { high = mid; }
  }

  int ans = low;
  printf("%d\n", ans);
  return 0;
}


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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		char []c = sc.next().toCharArray();
		
		int n = c.length;
		
		int count = 0;
		
		for(int i = 0; i < n-1 ; i++) {
			if(c[i] != c[i+1]) {
				count++;
			}
		}
		System.out.println(count);

	}

}


Measured memory_bytes: 26440
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
char str[210000];
char in[210000];
int q[910000];
int n;
int sa_k;
int rank[910000];
int tmp[910000];
int sa[910000];
bool compare_sa(int i,int j){
	if(rank[i]!=rank[j])return rank[i]<rank[j];
	else{
		int ri=i+sa_k<=n?rank[i+sa_k]:-1;
		int rj=j+sa_k<=n?rank[j+sa_k]:-1;
		return ri<rj;
	}
}
void construct_sa(){
	for(int i=0;i<=n;i++){
		sa[i]=i;
		rank[i]=i<n?str[i]:-1;
	}
	for(sa_k=1;sa_k<=n;sa_k*=2){
		sort(sa,sa+n+1,compare_sa);
		tmp[sa[0]]=0;
		for(int i=1;i<=n;i++){
			tmp[sa[i]]=tmp[sa[i-1]]+(compare_sa(sa[i-1],sa[i])?1:0);
		}
		for(int i=0;i<=n;i++){
			rank[i]=tmp[i];
		}
	}
}
int K;
int segtree[2][524288];
void update(int a,int b){
	a+=262144;
	while(a){
		segtree[0][a]=min(segtree[0][a],b);
		segtree[1][a]=max(segtree[1][a],b);
		a/=2;
	}
}
int lb(){
	int left=0;
	int right=n+1;
	while(left+1<right){
		int M=(left+right)/2;
		bool ok=true;
		int at=sa[M];
		while(at<n){
			if(at-sa[M]>=K){
				ok=false;break;
			}
			if(str[at]!=in[at-sa[M]]){
				if(str[at]>in[at-sa[M]])ok=false;
				break;
			}
			at++;
		}
		if(ok)left=M;
		else right=M;
	}
	return right;
}
int query(int a,int b,int c,int d,int e,int f){
	if(d<a||b<c||c>d){
		if(f)return -1;
		else return 999999999;
	}
	if(c<=a&&b<=d){
		return segtree[f][e];
	}
	if(f)return max(query(a,(a+b)/2,c,d,e*2,f),query((a+b)/2+1,b,c,d,e*2+1,f));
	else return min(query(a,(a+b)/2,c,d,e*2,f),query((a+b)/2+1,b,c,d,e*2+1,f));
}
int main(){
	scanf("%s",in);
	n=strlen(in);
	for(int i=0;in[i];i++)str[i]=in[i];
	str[n++]='~';
	construct_sa();
	int a;scanf("%d",&a);
	for(int i=0;i<524288;i++){
		segtree[0][i]=999999999;
		segtree[1][i]=-999999999;
	}
	for(int i=0;i<=n;i++){
		update(i,sa[i]);
	}
	for(int i=0;i<a;i++){
		scanf("%s",in);
		int len=strlen(in);
		int hz=len;
		K=len;
		int L1=lb();
		in[len-1]++;
		int R1=lb();
		scanf("%s",in);
		len=strlen(in);
		K=len;
		int L2=lb();
		in[len-1]++;
		int R2=lb();
		int lm=query(0,262143,L1,R1-1,1,0);
		int rm=query(0,262143,L2,R2-1,1,1);
		if(lm>rm||lm+hz>rm+len)printf("0\n");
		else printf("%d\n",rm-lm+len);
	}
}

Measured memory_bytes: 17728
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;
 
 
int main() {
    int a, b;
    cin >> a >> b;
    if (a < b){
        cout << 0 << endl;
    }else{
        cout << 10 << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
int main() {
	int n, q;
	std::cin >> n >> q;
	std::vector<std::priority_queue<int>> ques(n);
	for (auto i = 0; i < q; ++i) {
		int a, t, x;
		std::cin >> a;
		switch (a) {
		case 0: std::cin >> t >> x;
			ques[t].push(x);
			break;
		case 1: std::cin >> t;
			if (ques[t].size() != 0) {
				std::cout << ques[t].top() << std::endl;
			}break;
		default: std::cin >> t;
			if (ques[t].size() != 0) {
				ques[t].pop();
			}
		}
	}
}



Measured memory_bytes: 4080
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <utility>

using namespace std;

#define INPUT_NUM_MAX 1000000

void InsertSort(int* inputArray, int inputNum, int interval, int& swapCount);

int main()
{
	int inputNum = 0;

	scanf("%d", &inputNum);

	int* inputArray = new int[INPUT_NUM_MAX];
	for (int i = 0; i < inputNum; i++) {
		scanf("%d", &inputArray[i]);
	}

	int swapCount = 0;
	const int intervalMaxNum = 100;
	int intervals[intervalMaxNum] = { 0 };

	

	intervals[0] = 1;

	int nextInterval = 4;
	int intervalNum = 1;
	while (nextInterval < inputNum) {
		intervals[intervalNum] = nextInterval;
		intervalNum++;
		nextInterval += pow(3, intervalNum);
	}

	for (int i = intervalNum - 1; i >= 0; i--) {
		InsertSort(inputArray, inputNum, intervals[i], swapCount);
	}

	// 結果出力
	printf("%d\n", intervalNum);

	for (int i = intervalNum - 1; i >= 0; i--) {
		if (i != 0) {
			printf("%d ", intervals[i]);
		}
		else {
			printf("%d\n", intervals[i]);
		}
	}

	printf("%d\n", swapCount);

	for (int i = 0; i < inputNum; i++) {
		printf("%d\n", inputArray[i]);
	}

	delete[] inputArray;

	return 0;
}

void InsertSort(int* inputArray, int inputNum, int interval, int& swapCount)
{

	for (int i = interval; i < inputNum; i++) {
		int val = inputArray[i];
		int j = i - interval;

		while (j >= 0 && val < inputArray[j]) {
			inputArray[j + interval] = inputArray[j];
			j = j - interval;
			swapCount++;
		}
		inputArray[j + interval] = val;
	}
}



Measured memory_bytes: 6308
/** Author : Parth Prajapati
 * 	Institute : Pandit Deendayal Petroleum University
**/
#include<bits/stdc++.h>

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,m,i;
    cin>>n>>m;
    if(n < m)
    {
        int t = n;
        n = m;
        m = t;
    }
    for(i=0;i<n;++i)    cout<<m;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define x first
#define y second
#define ndl '\n'
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define bit __builtin_popcount
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;
using namespace __gnu_pbds;

template<typename T> using indexed_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<int, ull> piu;
typedef vector<vector<int>> matrix;

const ll INF = 1e18 + 123;
const ld EPS = 1e-9;
const int inf = 1e9 + 123;
const int MOD = 1e9 + 7;
const int N = 5e5 + 13;
const int M = 1e6 + 123;
const double pi = acos(-1.0);
const int dx[] = {0, 0, 1, -1};
const int dy[] = {1, -1, 0, 0};

int main(){
    #ifdef KAZAKH
        freopen("input.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll x;
    cin >> x;
    cout << x*x;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

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

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
ll digisum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}
ll countpow(ll a, ll b) {
	int ans = 0;
	if (b == 0)return -1;
	while (1) {
		if (a % b == 0) {
			a /= b;
			ans++;
		}
		else break;
	}
	return ans;
}


int main() {
	IOS;
	int x;
	cin >> x;
	string ans;
	if (x < 1200)ans = "ABC";
	else ans = "ARC";
	cout << ans << endl;
}



Measured memory_bytes: 256
#include<stdio.h>
inline void read(int&x)
{
	register char c=getchar();for(;c<'0'||'9'<c;c=getchar());
	for(x=0;'0'<=c&&c<='9';x=(x<<3)+(x<<1)+(c^48),c=getchar());
}
int n,k,a[200000],l,r,m;
inline bool jg()
{
	register int ans=0;
	for(register int i=0;i<n;++i)ans+=(a[i]-1)/m+1-1;
	return ans<=k;
}
main()
{
	read(n);read(k);for(register int i=0;i<n;++i)read(a[i]);
	for(l=1,r=1<<30;l<=r;)
	{
		m=l+r>>1;
		if(jg())r=m-1;
		else l=m+1;
	}
	printf("%d",l);
}

Measured memory_bytes: 2376
from operator import itemgetter
k, b = map(int, input().split())
a=[]
from heapq import heappush, heappop
for i in range(k):
    ta,tb = map(int, input().split())
    a.append([ta,tb])
a = sorted(a, key=itemgetter(0), reverse=False)
s=0
t = 0
ans = 0
i = 0
while s<b:
    s+=1
    if t<a[i][1]:
        ans+=a[i][0]
        t+=1
    else:
        i+=1
        ans+=a[i][0]
        t=1    

print(ans)


Measured memory_bytes: 22076