akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main(){
    int X,A,B;
    cin >> X >> A >> B;
    if (B-A<=0) cout << "delicious" << endl;
    if (B-A>0 && X>=B-A) cout << "safe" << endl;
    if (B-A>X) cout << "dangerous" << endl;
}


Measured memory_bytes: 256
#include<cstdio>
int v[105];
int solve(int st , int dr)
{
  int suma = 0 , s1 , s2, i;
  if(st == dr)
    return v[st];
  if(st > dr)
    return 0;
  for( i = st ; i <= dr ; i ++)
  {
    if(v[i] == 0)
    {
      s1 = solve(st , i - 1);
      s2 = solve(i + 1 , dr);
      break;
    }
  }
  if(i == dr + 1)
  {
    int ok = 1;
      while(ok == 1)
      {
        for( i = st; i <= dr ; i ++)
          v[i] --;
          suma ++;
        for( i = st ; i <= dr ; i ++)
          {
          if(v[i] == 0)
          {
            s1 = solve(st , i - 1);
            s2 = solve(i + 1 , dr);
            break;
          }
          }
        if(i != dr + 1)
          break;
      }
  }
  return s1 + s2 + suma;
}
int main()
{
  int n;
  scanf("%d" , &n);
  for(int i = 1; i <= n ; i ++)
  {
    scanf("%d" , &v[i]);
  }
  printf("%d", solve(1 , n));
}



Measured memory_bytes: 128
#include <iostream>
#include <string>

using namespace std;

int main()
{
	string S;
	cin >> S;
	
	string T;
	cin >> T;
	
	int N = 3;
	
	int answer = 0;
	for (int i = 0; i < N; i++)
	{
		string subS = S.substr(i, 1);
		string subT = T.substr(i, 1);
		
		if (subS == subT) {
			answer++;
		}
	}	
	
	cout << answer << endl;
	
	return 0;
}

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

using namespace std;

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

  vector<pair<int, int>> inc;
  vector<pair<int, int>> dec;

  for (int i = 0; i < N; ++i) {
    string s;
    cin >> s;

    int lowest_left = 0;
    int change_left = 0;
    for (int j = 0; j < s.size(); ++j) {
      if (s[j] == ')') {
        --change_left;
        lowest_left = min(lowest_left, change_left);
      } else {
        ++change_left;
      }
    }
    int lowest_right = 0;
    int change_right = 0;
    for (int j = s.size() - 1; j >= 0; --j) {
      if (s[j] == '(') {
        --change_right;
        lowest_right = min(lowest_right, change_right);
      } else {
        ++change_right;
      }
    }
    if (change_left >= 0) {
      inc.push_back(make_pair(-lowest_left, change_left));
    } else {
      dec.push_back(make_pair(-lowest_right, change_right));
    }
  }
  sort(inc.begin(), inc.end());
  sort(dec.begin(), dec.end());

  int left = 0;
  bool ok = true;
  for (int i = 0; i < inc.size(); ++i) {
    if (left - inc[i].first < 0) {
      ok = false;
    }
    left += inc[i].second;
  }
  int right = 0;
  for (int i = 0; i < dec.size(); ++i) {
    if (right - dec[i].first < 0) {
      ok = false;
    }
    right += dec[i].second;
  }
  if (ok && left == right) {
    cout << "Yes";
  } else {
    cout << "No";
  }
  cout << endl;
}

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

int main(void){
  int n;
  int a[200];

  cin >> n;

  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  for(int i = n - 1; i >= 0; i--){
    cout << a[i];
    if(i != 0){ cout << " "; }
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

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

int main(){
    ll n, sum=0;
    cin >> n;
    vector<ll> cnt(n+1, 0);
    for(ll i=1;i<n+1;i++){
        // ll cnt=0;
        // for(ll j=1;j*j<=i;j++){
        //     if(i%j==0){
        //         if(j*j==i){
        //             cnt++;
        //         }else{
        //             cnt += 2;
        //         }
        //     }
        // }
        ll x = i;
        while(x<n+1){
            cnt[x]++;
            x += i;
        }
        sum += i * cnt[i];
    }
    cout << sum << endl;
    return 0;
}

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

int main(){
  long long N;
  cin>>N;
  long long minans=10e12;
  for(long long i=1;i*i<=N;i++){
    if(N%i==0){
      long long j=N/i;
      minans=min(minans,i+j-2);
    }
  }
  cout<<minans<<endl;
  return 0;
}

 

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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

const lli e5 = 1 << 20;
const lli mod = 1000000007;
const lli e3 = 1 << 13;
const lli INF = 1ll << 62;

lli h,w;
string a[e3];
graph g;
graph r;
lli idx_w[e5];
lli idx_h[e5];
lli s,t;
lli vis[e5];
lli ans = 0;

lli dfs(lli x,lli c){
  vis[x]++;
  if(x == t) return c;
  for(auto y : g[x]){
    if(vis[y.first] == 1) continue;
    if(y.second == 0) continue;
    lli z = dfs(y.first, min(c,y.second));
    if(z > 0){
      g[x][y.first] -= z;
      r[y.first][x] += z;
      return z;
    }
  }
  for(auto y : r[x]){
    if(vis[y.first] == 1) continue;
    if(y.second == 0) continue;
    lli z = dfs(y.first, min(c,y.second));
    if(z > 0){
      r[x][y.first] -= z;
      g[y.first][x] += z;
      return z;
    }
  }
  return 0;
}

int main(){
  cin >> h >> w;
  for(lli i = 0;i < h;i++) cin >> a[i];
  lli idx = 1;
  for(lli i = 0;i < w;i++){
    idx_w[i] = idx;
    idx++;
  }
  for(lli i = 0;i < h;i++){
    idx_h[i] = idx;
    idx++;
  }
  s = 0;
  t = idx;
  for(lli i = 0;i < h;i++){
    for(lli j = 0;j < w;j++){
      if(a[i][j] != 'o') continue;
      g[idx_h[i]][idx_w[j]] = 1;
      r[idx_w[j]][idx_h[i]] = 0;
      g[idx_w[j]][idx_h[i]] = 1;
      r[idx_h[i]][idx_w[j]] = 0;
    }
  }
  lli mem_x,mem_y;
  for(lli i = 0;i < h;i++){
    for(lli j = 0;j < w;j++){
      if(a[i][j] != 'S') continue;
      mem_x = j;
      mem_y = i;
      g[s][idx_w[j]] = e5;
      r[idx_w[j]][s] = 0;
      g[s][idx_h[i]] = e5;
      r[idx_h[i]][s] = 0;
    }
  }
  for(lli i = 0;i < h;i++){
    for(lli j = 0;j < w;j++){
      if(a[i][j] != 'T') continue;
      if(i == mem_y || j == mem_x){
        cout << -1 << endl;
        return 0;
      }
      g[idx_w[j]][t] = e5;
      r[t][idx_w[j]] = 0;
      g[idx_h[i]][t] = e5;
      r[t][idx_h[i]] = 0;
    }
  }
  for(;;){
    fill(vis,vis+(idx+1),0ll);
    lli z = dfs(s, INF);
    // cerr << z << endl;
    if(z <= 0) break;
    ans += z;
  }
  cout << ans << endl;
}


Measured memory_bytes: 6400
import sys

n, we = map(int, input().split())

cf=[(0, 0)]*(n+1)

for i in range(1, n+1):
    cf[i] = tuple( map(int, sys.stdin.readline().split()) )

dp=[0]*(we+1)

best=0

for i in range(1, n+1):
    for j in reversed(range(cf[i][0], we+1)):
        dp[j]=max( dp[j], dp[j-cf[i][0]]+ cf[i][1] )
        
    best=max(best, dp[we])


print(best)

# for i in range(1, n+1): print( dp[i], '\n' )

Measured memory_bytes: 42988
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return (b);
    }
    else
    {
        return (gcd(b, a % b));
    }
}

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

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;
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------


int main(){
    std::cout << std::fixed << std::setprecision(10);
ll n;
cin>>n;
vector<ll> a(n);
for(int i=0;i<n;i++){
    cin>>a[i];
}
sort(a.begin(),a.end());
double sum=a[0];
for(int i=1;i<n;i++){
    sum=(sum+a[i])/2;
}
cout<<sum<<endl;
}





Measured memory_bytes: 256
#include  <bits/stdc++.h> 
using namespace std;
 
#define ll long long
#define ar array
 
void solve(){
	int n,d,ans=0;
	cin>>n>>d;
  	double x[n],y[n];
  	for(int i=0;i<n;i++){
      	cin>>x[i]>>y[i];
    }
  	for(int i=0;i<n;i++){
      	if(sqrt(x[i]*x[i]+y[i]*y[i])<=d){
         	ans++; 
        }
    }
  	cout<<ans<<endl;
}
 
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
    solve();
	return 0;
}

Measured memory_bytes: 6992
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323
#define ll long long int
#define vi vector <int>
#define vl vector <ll>
#define all(v) (v).begin(),(v).end()
#define pb push_back
 
ll power(ll a, ll b){//a^b
    ll res=1;
    while(b>0){
        if(b&1){res=(res*a);b--;}
        a=(a*a);
        b>>=1;
    }
    return res;
}
 
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
 
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll h,w;
	cin>>h>>w;
	ll k;
	cin>>k;
	char a[h][w];
	ll b=0;
	for(ll i=0;i<h;i++)
		for(ll j=0;j<w;j++){
			cin>>a[i][j];
			if(a[i][j]=='#')
				b++;
		}
	if(k>b){
		cout<<"0\n";
		return 0;
	}
	ll ans=0;
	for(ll i=0;i<(1<<h)-1;i++){
		for(ll j=0;j<(1<<w)-1;j++){
			ll c=0;
			for(ll ii=0;ii<h;ii++){
				for(ll jj=0;jj<w;jj++){
					if((i&(1<<ii))||(j&(1<<jj))){
						if(a[ii][jj]=='#')
							c++;
					}
				}
			}
			if(b-c==k)
				ans++;
		}
	}
	cout<<ans<<"\n";
}

Measured memory_bytes: 3652
#include <iostream>
#define mod 1000000007
using namespace std;
long long dp[100005][2];
int head[100005],cnt;
struct edge
{
	int v,n;
}e[200005];
inline void add(int u,int v)
{
	e[++cnt]={v,head[u]};
	head[u]=cnt;
}
inline void dfs(int u,int f)
{
	dp[u][0]=dp[u][1]=1;
	for(int i=head[u];i;i=e[i].n)
	{
		if(e[i].v==f) continue;
		dfs(e[i].v,u);
		dp[u][0]=(dp[u][0]*(dp[e[i].v][0]+dp[e[i].v][1]))%mod;
		dp[u][1]=(dp[u][1]*dp[e[i].v][0])%mod;
	}
}
int main(int argc, char** argv) {
	int n;
	cin >> n;
	for(int i=1;i<n;i++)
	{
		int u,v;
		cin >> u >> v;
		add(u,v),add(v,u);
	}
	dfs(1,0);
	cout << (dp[1][0]+dp[1][1])%mod; 
	return 0;
}

Measured memory_bytes: 5888
#include <stdio.h>

int main(){
    int N;
    scanf("%d",&N);
    int count = 0;
    for(int i=1;i<=N;i++){
        if(i>=1&&i<10)count++;
        if(i>=100&&i<1000)count++;
        if(i>=10000 && i<100000)count++;
    }
    printf("%d",count);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <deque>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <fstream>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  ll a,b,c;
  cin>>a>>b>>c;
  ll ans;
  if(a + b >= c) {
    ans = b + c;
  } else {
    ans = a + b + b + 1;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>

using std::cout;
using std::cin;

void oneCase () {
    int a, b;
    cin >> a >> b;
    if (a < 10 && b < 10) {
        cout << a * b << "\n";
    } else {
        cout << -1 << "\n";
    }
}


int main() {
    int k = 1;
//    cin >> k;
    for (int i = 0; i < k; ++i) {
        oneCase();
    }

    return 0;
}

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

typedef long long int ll;
typedef long double ld;

//****************************************************                
#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll,ll> 
#define vpll vector<pll>
#define all(X) X.begin(),X.end()
#define endl "\n" //comment it for interactive questions
#define trace1(a) cerr << #a << ": " << a << endl;
#define trace2(a,b) cerr << #a << ": " << a << " " << #b << ": " << b << endl;
#define trace3(a,b,c) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << endl;
#define trace4(a,b,c,d) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << #d << ": " << d << endl;
#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
        //*******************************************************
//Some Functions

const ll MOD = (ll)1e9+7; //change it for other mods

ll powmod(ll a,ll b)
{
   ll res = 1;
   while(b > 0) {
      if(b & 1) res = (res * a) % MOD;
      a = (a*a)%MOD;
      b = b >> 1; 
  }
  return res % MOD;
}

void solve(ll testnum)
{
    string s;
    cin >> s;
    ll cnt = 0;
    ll ans = 0;
    for(ll i=0; i<s.size(); i++) {
    	if(s[i] == 'R') {
    		cnt++;
    		ans = max(ans, cnt);
    	} else {
    		cnt = 0;
    	}
    }
    cout << ans << "\n";
}

int main()
{
    FAST_IO;
    #ifdef STIO 
      freopen("input.txt" , "r", stdin);
      freopen("output.txt" , "w", stdout);
    #endif
    ll t = 1;
    // cin >> t;
    for (ll i = 1; i <= t; i++) {
        // cout << "Case #" << i << ": ";
        solve(i);
    }
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define File freopen("in.in","r",stdin);freopen("out.out","w",stdout)
#define ll long long
ll a[(int)1e5+200]={0};
ll dp[(int)1e5+200];
ll n,k;
ll solve(int i){
    if(i+1==n)return 0;
    if(i>n)return 1e9;
    ll &re = dp[i];
    if(re!=-1)return re;
    for(int j = 1 ; j <= k ; j++)
    re = min(abs(a[i]-a[i+j])+solve(i+j),re==-1?(int)1e9:re);
    return re;
}
int main(){
    fastIO;
    //File;
    int _(1);
    //cin >> _;
    while (_--){
        memset(dp,-1,sizeof dp);
        cin>>n>>k;
        memset(a,0,sizeof a);
        for(int i = 0 ; i < n ; i++)cin>>a[i];
        cout<<solve(0)<<endl;
    }
}


Measured memory_bytes: 8064
def resolve():
    X = int(input())
    dp = [0 for _ in range(X + 110)]
    dp[0] = 1
    for i in range(X + 1):
        if dp[i] == 0:
            continue
        dp[i + 100] = 1
        dp[i + 101] = 1
        dp[i + 102] = 1
        dp[i + 103] = 1
        dp[i + 104] = 1
        dp[i + 105] = 1
    print(dp[X])


resolve()


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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<int> VECINT;
typedef vector<ll> VECLL;

int main() {
  int N;cin>>N;
  VECINT AS(N);
  REP(i,N) cin>>AS[i];
  sort(ALL(AS), greater<int>());
  int alice=0, bob=0;
  REP(i,N) {
    if (i%2==0) alice += AS[i];
    else bob += AS[i];
  }
  OUT(alice-bob);

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

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

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int n,a,b,acnt,bcnt,B=1;
string s;

int main(){
  cin>>n>>a>>b;
  cin>>s;
  for(int i=0;i<s.size();i++){
    if(s[i]=='b'&&acnt+bcnt<a+b&&B<=b){
      cout<<"Yes"<<endl;
      B++;
      bcnt++;
    }
    else if(s[i]=='a'&&acnt+bcnt<a+b){
      acnt++;
      cout<<"Yes"<<endl;
    }else cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 896
s = input()
t = ['A', 'T', 'G', 'C']

ans = []
for i in range(len(s)):
  c = 0
  for j in range(i, len(s)):
    if s[j] in t:
      c += 1
    else:
      break
  ans.append(c)

print(max(ans))


Measured memory_bytes: 2940
n = int(input())
s = [0] * n
for i in range(n):
    s[i] = input()

ac = 0
wa = 0
tle = 0
re = 0
for i in range(n):
    if s[i] == 'AC':
        ac += 1
    elif s[i] == 'WA':
        wa += 1
    elif s[i] == 'TLE':
        tle += 1
    else:
        re += 1

print('AC x', ac)
print('WA x', wa)
print('TLE x', tle)
print('RE x', re)


Measured memory_bytes: 78328
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <sstream>
#include <set>
using namespace std;
using ll = long long;

class range {private: struct I{int x;int operator*(){return x;}bool operator!=(I& lhs){return x<lhs.x;}void operator++(){++x;}};I i,n;
public:range(int n):i({0}),n({n}){}range(int i,int n):i({i}),n({n}){}I& begin(){return i;}I& end(){return n;}};

ll dp[60][6000];
const int B = 3000;

int main() {
  int N, A;
  while (cin >> N >> A) {
    vector<int> xs(N);
    for (int i : range(N)) {
      cin >> xs[i];
      xs[i] -= A;
    }

    memset(dp, 0, sizeof(dp));
    dp[0][B + 0] = 1LL;

    for (int idx : range(N)) {
      for (int sum : range(-3000, 3000)) {
        if (dp[idx][B + sum] == 0) continue;
        int j = B + sum + xs[idx];
        assert(0 <= j && j < 6000);
        dp[idx + 1][B + sum + xs[idx]] += dp[idx][B + sum];
        dp[idx + 1][B + sum] += dp[idx][B + sum];

        //cout<<idx+1<<" " <<j<<" "<<dp[idx + 1][B + sum + xs[idx]]<<endl;
      }
    }

    cout << (dp[N][B + 0] - 1LL) << endl;
  }
}


Measured memory_bytes: 3072
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <iomanip>
#include <cassert>
#include <numeric>
using namespace std;
 
#define ff first
#define ss second
#define pb push_back 
 
using LL = long long int;
using VL = vector<LL>;
using VI = vector<int>;
using VVL = vector<VL>;
using PLL = pair<LL,LL>;
using PII = pair<int ,int>;
 
#ifdef DEBUG
void _print()
{
  cout << endl;
}
template<typename T, typename... Args >
void _print(const T first_elem, const Args... args)
{
  cout << first_elem << " ";
  _print(args...);
}
#else
void _print()
{
}
template<typename T, typename... Args >
void _print(const T first_elem, const Args... args)
{
}
#endif
 
 
// NOTE: Please dont implement _print() as function in your program. It is reserved
// for debug purpose.

int main()
{
    ios::sync_with_stdio(false);
    LL t = 1;
    while (t--) {
        LL n, k;
        cin >> n >> k;
        VL a(n);
        for (int i = 0; i < n; i++) {
            cin >> a[i];
        }

        sort(a.begin(), a.end());
        LL sum = 0;
        for (int i = 0; i < k ;i++) {
            sum += a[i];
        }

        cout << sum << endl;

    }
    return 0;
    
}

Measured memory_bytes: 3548
N,K = map(int, input().split())
D = set(list(map(int, input().split())))

ans = 0

for i in range(N, 10*N+1):
    res = i
    while res > 0:
        digit = res % 10
        
        if digit in D:
            break
        
        res //= 10
        
    if res <= 0:
        ans = i   
        break

print(ans)

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

#define all(v) v.begin(), v.end()

using namespace std;


int main (void) 
{

  /* Variable_Proclamation */
  int N, L;    // input
  string ans;  // output

  int i;    // subscript


  /* Input, Array_Proclamation */
  cin >> N >> L;
  vector<string> s(N);


  for(i=0; i<N; i++)
  {
    cin >> s.at(i);
  }


  /* Initialize */
  ans = "";


  /* Calculation */
  sort( all(s) );

  for(i=0; i<N; i++)
  {
    ans += s.at(i);
  }
  

  /* Output */
  cout << ans << endl;


  return 0;

}


Measured memory_bytes: 256
// Amsal Shoma Ro Gaedan Ye Amal Pasandidas !
#include <bits/stdc++.h>

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " : " << x << '\n'

using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;

const ll Mod = 998244353;
const int N = 3e2 + 10;
const ll Inf = 2242545357980376863LL;
const ll Log = 30;

ll dp[N][N][N];

vector<int> V;
ll ps[N];
ll p[N][N];
int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	str s;
	cin >> s;
	ll k;
	cin >> k;
	int cnt = 0;
	for(auto c : s){
		if(c == '1') cnt ++;
		else {
			V.pb(cnt);
			cnt = 0;
		}
	}
	V.pb(cnt);
	ll n = s.size(), m = V.size();
	ps[0] = V[0];
	for(int i = 1; i < m; i++) ps[i] = ps[i - 1] + V[i];

	for(int C = V[0]; C <= n; C++) dp[0][0][C] = 1;

	ll al = 0, st, en;
	for(int i = 1; i < m; i++){
		memset(p, 0, sizeof p);
		for(int j = 0; j <= n; j++){
			p[j][0] = dp[i - 1][j][0];
			for(int k = 1; k <= n; k++) p[j][k] = (p[j][k - 1] + dp[i - 1][j][k]) % Mod;
		}
		for(int j = 0; j <= n; j++){
			for(int k = 0; k <= n; k++){
				if(k >= (V[i] + 1))
					dp[i][j][k] += p[j][k - (V[i] + 1)];
			}
		}
		memset(p, 0, sizeof p);
		for(int j = 0; j <= n; j++){
			for(int k = 0; k <= n; k++){
				p[j][k] = dp[i - 1][j][k];
				if(j) (p[j][k] += p[j - 1][k + 1]) %= Mod;
			}
		}
		al = V[i];
		for(int k = 0; k <= n; k++){
			for(int s = 0; s <= n; s++){
				st = k - al;
				st = max(st, 0ll);
				
				en = k;
				if(s - al < 0) en += s - al;
				if(en < st) continue;
				dp[i][k][s] += p[en][s+k-al - en] - p[st][s+k-al - st] + dp[i - 1][st][s+k-al - st] + Mod;
				dp[i][k][s] %= Mod;
			}
		}
		for(int k = 0; k <= n; k++)
			for(int s = 0; s < ps[i]; s++)
				dp[i][k][s] = 0;
	}
	ll ans = 0;
	for(int i = 0; i <= min(n, k); i++) ans += dp[m - 1][i][ps[m - 1]];
	cout << ans % Mod << '\n';
	return 0;
}


Measured memory_bytes: 222624
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int arr[n];
  for(int i=0;i<n;i++)
    cin>>arr[i];
  long int sum=0;
  for(int i=0;i<n-1;i++)
  {
    if(arr[i]>arr[i+1])
    {
      int d=arr[i]-arr[i+1];
      arr[i+1]=arr[i];
      sum=sum+d;
      
      
      
      
    }
    else
      continue;
    
  }
  cout<<sum<<endl;
  
  
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
 
int main() {
  int N;
	cin>>N;
	vector<int> d(N);
	rep(i,N) cin>>d[i];
	sort(d.begin(),d.end());
	int ans=0;
	int r=0;
	rep(i,N){
		if (r!=d[i])ans+=1;
		r=d[i];
	}
	cout<<ans<<"\n";
}


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

int main()
{
  int n;
  cin >> n;
  int ans = 0;
  int tem = 0;
  
  vector<int> vec(n);
  for(int i = 0; i < n; i++) {
    cin >> vec.at(i);
    if(i == 0) {
      ans += vec.at(i);
    }
    else {
      if(vec.at(i - 1) <= vec.at(i)) {
        ans += vec.at(i) - vec.at(i - 1);
      }
    }
  }
  
  cout << ans << endl;
    

  return 0;
}


Measured memory_bytes: 256
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)
	A, B, C := getInt(), getInt(), getInt()
	K := getInt()
	k := 1
	for i := 0; i < K; i++ {
		k *= 3
	}

	if A < B && B < C {
		out("Yes")
		return
	}

	for i := 0; i < k; i++ {
		n := i
		a, b, c := A, B, C
		for j := 0; j < K; j++ {
			sel := n % 3
			switch sel {
			case 0:
				a *= 2
			case 1:
				b *= 2
			case 2:
				c *= 2
			}
			n /= 3
			if a < b && b < c {
				out("Yes")
				return
			}
		}
	}
	out("No")
}


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

using namespace std;

#define ll long long




void solve() {

	int n, d;
	cin >> n >> d;
	d = d * 2 + 1;
	cout << ceil(n / (double)d);

	




	
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	solve();

	return 0;
}

Measured memory_bytes: 3784
#include <iostream>
#include <cstring>
#include <map>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

map<string,int> m;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    vector<string>pret;

    int n;
    cin >>n;
    for(int i=0;i<n ;i++){
        string s;
        cin >> s;
        m[s]++;
    }
    int ret = 0;
    for(auto x:m){
        ret = max(ret,x.second);
    }
    for(auto x:m){
        if(x.second==ret)pret.push_back(x.first);
    }
    sort(pret.begin(),pret.end());
    for(auto x:pret)cout << x << '\n';
}

Measured memory_bytes: 25584
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace ConsoleApplication2 {
    class Program {
        static void Main(string[] args) {

            TextReader input = Console.In;

            string str = "";

            while((str = input.ReadLine()) != null) {
                int cnt = 0;
                int n = 0;
                if (!int.TryParse(str, out n)) {
                    continue;
                }
                int a, b, c, d;
                for (int ii = 0; ii < 10; ii++) {
                    a = ii;
                    for (int jj = 0; jj < 10; jj++) {
                        b = jj;
                        for (int kk = 0; kk < 10; kk++) {
                            c = kk;
                            for (int ll = 0; ll < 10; ll++) {
                                d = ll;
                                if (a + b + c + d == n) {
                                    cnt++;
                                    //Console.WriteLine(string.Format("Hitt{0} {1} {2} {3} = {4}",a,b,c,d,n));
                                }
                            }
                        }
                    }
                }
                Console.WriteLine(cnt);
            }
        }
    }
}

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

int main(){
  ll a,b,q;
  cin >>a >>b >>q;
  vector<ll>s(a),t(b),x(q);
  for(ll i=0;i<a;i++)cin >> s[i];
  for(ll i=0;i<b;i++)cin >> t[i];
  for(ll i=0;i<q;i++)cin >> x[i];
  for(ll i=0;i<q;i++){
    ll ans=LLONG_MAX;
    auto iter1=lower_bound(s.begin(),s.end(),x[i]);
    auto iter2=lower_bound(t.begin(),t.end(),x[i]);
    ll slength=distance(s.begin(),iter1);
    ll tlength=distance(t.begin(),iter2);
    cerr<<slength <<" "<<tlength<<endl;
    
    for(ll j=max(slength-1,(ll)0);j<=min(slength,a-1);j++){
      for(ll k=max(tlength-1,(ll)0);k<=min(tlength,b-1);k++){
        ll sansa=abs(s[j]-t[k])+abs(t[k]-x[i]);
        ll tansa=abs(s[j]-t[k])+abs(s[j]-x[i]);
        ans=min(ans,min(sansa,tansa));
      }
    }
    cout <<ans<<endl;
  }
}

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

int main()
{
  long a,b,k;
  
  cin>>a>>b>>k;
  
  if(k>=a)
  {
    k=k-a;
    a=0;
    if(k>=b)
    {
      k=k-b;
      b=0;
    } 
    else
    b=b-k;  
  }
  else
  a=a-k;
  
  cout<<a<<" "<<b;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
cnt = [ 0 for i in range(n) ]
for i in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    cnt[a] += 1
    cnt[b] += 1
for i in cnt:
    print(i)    


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define FOR(I,X,Y) for(int I=X;I<Y;I++)
#define REP(I,X,Y) for(int I=Y-1;I>=X;I--)
#define INF 1000000007
using namespace std;

int main(){
  int N,a,m=0;
  cin >> N;
  set<int> s;
  FOR(i,0,N){
    cin >> a;
    if(a < 3200)s.insert(a/400);
    else m++;
  }
  int ssize = s.size();
  if(s.size())cout << ssize << " " << ssize+m << endl;
  else cout << 1 << " " << m << endl;
}


Measured memory_bytes: 256
#![allow(unused)]

use std::cmp;
use std::io::{self, BufRead};
use std::iter;

macro_rules! destruct_ {
  ($e: expr, ()) => (
    assert!($e.next().is_none())
  );
  ($e: expr, ($arg: ident, $( $args: ident, )*)) => (
    $arg = $e.next().unwrap();
    destruct_!($e, ($($args,)*))
  );
  ($e: expr, ($arg: ident $(, $args: ident )*)) => (
    $arg = $e.next().unwrap();
    destruct_!($e, ($($args,)*))
  );
}

macro_rules! into {
  ($e: expr, $($name: ident)*) => {
    let mut iter = $e.into_iter();
    destruct_!(iter, ($($name)*));
  }
}

macro_rules! get {
  ($i: ident) => (
    let stdin = io::stdin();
    let mut $i = Vec::new();
    for line in stdin.lock().lines() {
      $i.push(
        line.unwrap().parse().unwrap()
      );
    }
  )
}

macro_rules! p {
  ($a: expr) => (
    println!("{}", $a);
  )
}

macro_rules! pp {
  ($a: expr) => (
    println!("{:?}", $a);
  )
}

fn main() {
  let mut args: Vec<i32>;
  get!(args);
  args.remove(0);

  args.sort();

  let n: i32 = args.iter().sum();
  if n % 10 != 0 {
    p!(n);
  }
  else {
    for i in 0 .. args.len() {
      let mut s = args.clone();
      s.remove(i);
      let n: i32 = s.iter().sum();
      if n % 10 != 0 {
        p!(n);
        return;
      }
    }

    p!(0);
  }
}


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

#define int long long 

void read(int &x) {
    x=0;int f=1;char ch=getchar();
    for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-f;
    for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';x*=f;
}

void print(int x) {
    if(x<0) putchar('-'),x=-x;
    if(!x) return ;print(x/10),putchar(x%10+48);
}
void write(int x) {if(!x) putchar('0');else print(x);putchar('\n');}

#define lf double
#define ll long long 

#define pii pair<int,int >
#define vec vector<int >

#define pb push_back
#define mp make_pair
#define fr first
#define sc second

#define data asd09123jdf02i3h

#define FOR(i,l,r) for(int i=l,i##_r=r;i<=i##_r;i++)

const int maxn = 1e6+10;
const int inf = 1e12;
const lf eps = 1e-8;
const int mod = 1e9+7;

int head[maxn],tot=1,n,s,t,max_cost;

struct edge{int to,nxt,w,c;}e[maxn<<1];

void add(int u,int v,int w,int c) {e[++tot]=(edge){v,head[u],w,c},head[u]=tot;}
void ins(int u,int v,int w,int c) {add(u,v,w,c),add(v,u,0,-c);}

int dis[2040],pre[maxn],id[maxn],vis[maxn];

int gao() {
    memset(dis,-63,sizeof dis);
    dis[s]=0;queue<int > q;q.push(s);
    while(!q.empty()) {
        int x=q.front();q.pop();vis[x]=0;
        for(int i=head[x],v;i;i=e[i].nxt)
            if(e[i].w&&dis[v=e[i].to]<dis[x]+e[i].c) {
                dis[v]=dis[x]+e[i].c;
                pre[v]=x,id[v]=i;
                if(!vis[v]) vis[v]=1,q.push(v);
            }
    }

    if(dis[t]==dis[0]) return 0;
    int mn=inf,x=t;
    while(x!=s) mn=min(e[id[x]].w,mn),x=pre[x];
    x=t;
    while(x!=s) {
        max_cost+=e[id[x]].c*mn;
        e[id[x]].w-=mn,e[id[x]^1].w+=mn;
        x=pre[x];
    }
    return 1;
}

signed main() {
    read(n);s=n*2+1,t=s+1;
    int p1=t+1,p2=t+2,p3=t+3,p4=t+4;
    for(int i=1;i<=n;i++) {
        int c,x,y;read(x),read(y),read(c);
        ins(s,i,c,0);
        ins(i,p1,c,x+y);
        ins(i,p2,c,x-y);
        ins(i,p3,c,-x+y);
        ins(i,p4,c,-x-y);
    }
    for(int i=1;i<=n;i++) {
        int c,x,y;read(x),read(y),read(c);
        ins(i+n,t,c,0);
        ins(p1,i+n,c,-x-y);
        ins(p2,i+n,c,-x+y);
        ins(p3,i+n,c,x-y);
        ins(p4,i+n,c,x+y);
    }
    while(gao());
    write(max_cost);
    return 0;
}


Measured memory_bytes: 8448
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define REPW(i,n) for(i=0;i<(int)(n);++i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)   // c++14
#define SZ(c) ((int)c.size())
#define EXIST(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : "\n"); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
    }
} before_main_function;
//------------------------------------------------------------------------------

signed main() {
    int n;
    string s;
    cin>>n>>s;
    // ( : +1
    // ) : -1
    // 部分的に負にならない
    int add=0;
    int cnt=0;
    REP(i,n) {
        if(s[i]=='(') cnt++;
        else if(s[i]==')') cnt--;
        if(cnt<0) add++, cnt=0;
    }
    REP(i,add) cout<<'(';
    cout<<s;
    REP(i,cnt) cout<<')';
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	boolean ans;
	int a, b;
	int [] data;
	private void dfs(int deep){
		if(deep == 10){
			ans = true;
			return;
		}
		if(data[deep] > a){
			int temp = a;
			a = data[deep];
			dfs(deep+1);
			a = temp;
		}
		if(data[deep] > b){
			int temp = b;
			b = data[deep];
			dfs(deep+1);
			b = temp;
		}
	}
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		while(n-- > 0){
			data = new int[10];
			for(int i = 0; i < 10; i++){
				data[i] = sc.nextInt();
			}
			a = -1;
			b = -1;
			ans = false;
			dfs(0);
			if(ans){
				System.out.println("YES");
			}
			else{
				System.out.println("NO");
			}
		}
	}

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

Measured memory_bytes: 12000
<?php

    $line = trim(fgets(STDIN));
    
    kaibun($line);
    
    $line_1 = substr($line,0,((strlen($line)-1)/2));
    $line_2 = substr($line,((strlen($line)+1)/2),strlen($line)-1);

    kaibun($line_1);    
    kaibun($line_2);
    echo "Yes";

    // print_r($line_1);
    // print_r($line_2);
    
    function kaibun($line){
            //回文であることの確認
        $num_line = strlen($line);
        
        for($i=0;$i<(($num_line-1)/2);$i++){
            // echo $i."\n";
            if($line[$i] != $line[$num_line-$i-1]){
                echo "No";
                exit;
            }
        }
        
    }

?>

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

int main() {
  ll n;cin>>n;
  ll ans=1,x=1e18;
  bool ng=false;
  rep(i,n){
    ll a;cin>>a;
    if(a==0){
      cout<<0<<endl;
      return 0;
    }
    if(x/a<ans)ng=true;
    ans*=a;
  }
  if(ng)cout<<-1<<endl;
  else cout<<ans<<endl;
}

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

int mysum(vector<int> a){
  int result=0;
  for(auto x: a) result += x;
  return result;
}

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> a(H, vector<char> (W, '.'));
  for (int i=0; i<H; i++){
    for (int j=0; j<W; j++){
      cin >> a[i][j];
    }
  }
  vector<int> rowGood(H, 0), colGood(W, 0);
  for (int i=0; i<H; i++){
    int isGood = 0;
    for (int j=0; j<W; j++){
      if (a[i][j] != '.') isGood = 1;
    }
    rowGood[i] = isGood;
  }
  for (int j=0; j<W; j++){
    int isGood = 0;
    for (int i=0; i<H; i++){
      if (a[i][j] != '.') isGood = 1;
    }
    colGood[j] = isGood;
  }
  vector<vector<char>> b(mysum(rowGood), vector<char> (mysum(colGood), '.'));

  for (int i=0, ib = 0; i<H; i++){
    if (rowGood[i]) {
      for (int j=0, jb=0; j<W; j++){
        if(colGood[j]) {
          b[ib][jb] = a[i][j];
          jb ++;
        }
      }
      ib++;
    }
  }

  for (int i=0; i< b.size(); i++){
    for (int j=0; j< b[i].size(); j++){
      cout << b[i][j];
      if (j == b[i].size() - 1) cout << endl;
    }
  }
}


Measured memory_bytes: 256
#include <atcoder/mincostflow>
#include <iostream>

using namespace std;
using namespace atcoder;

const long long BIG = 1'000'000'000;

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

    /**
     * generate (s -> row -> column -> t) graph
     * i-th row correspond to vertex i
     * i-th col correspond to vertex n + i
     **/
    mcf_graph<int, long long> g(2 * n + 2);
    int s = 2 * n, t = 2 * n + 1;

    // we can "waste" the flow
    g.add_edge(s, t, n * k, BIG);

    for (int i = 0; i < n; i++) {
        g.add_edge(s, i, k, 0);
        g.add_edge(n + i, t, k, 0);
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            long long a;
            cin >> a;
            g.add_edge(i, n + j, 1, BIG - a);
        }
    }

    auto result = g.flow(s, t, n * k);
    cout << 1LL * n * k * BIG - result.second << endl;

    vector<string> grid(n, string(n, '.'));
    auto edges = g.edges();
    for (auto e : edges) {
        if (e.from == s || e.to == t || e.flow == 0) continue;

        grid[e.from][e.to - n] = 'X';
    }

    for (int i = 0; i < n; i++) {
        cout << grid[i] << endl;
    }
    return 0;
}


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

int main(){
  int n;
  cin>>n;
  int a=n%10;
  if(a==3) cout<<"bon"<<endl;
  else if(a==0||a==1||a==6||a==8) cout<<"pon"<<endl;
  else cout<<"hon"<<endl;
}


Measured memory_bytes: 3632
#include<stdio.h>
int main(){
  int h,w,i,j,b;
  char s[50][50];
  scanf("%d %d",&h,&w);
  for(i=0;i<h;i++){
    scanf("%s", s[i]);
  }

  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      if(s[i][j]=='#'){
        b=0;
        if(i>0)if(s[i-1][j]=='#')b=1;
        if(i<h)if(s[i+1][j]=='#')b=1;
        if(j>0)if(s[i][j-1]=='#')b=1;
        if(j<w)if(s[i][j+1]=='#')b=1;
        if(b==0){
          puts("No");
          return 0;
        }
      }
    }
  }
  puts("Yes");
  return 0;
}

Measured memory_bytes: 128
/*
 ***
 Question Name:
 ***
 Question Link:
 ***
 Idea:
 */

#include <memory.h>
#include <ctime>
#include <random>
#include <iomanip>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <numeric>
#include <sstream>
#include <fstream>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cstdio>
#include <vector>
#include <cmath>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>

#define REP(i,s,n) for(int (i)=s; (i)<(int)(n);(i)++)
#define RIT(it,c) for(__typeof(c.begin()) it = c.begin();it!=c.end();it++)
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int)(x).size()
#define MSET(m,v) memset(m,v,sizeof(m))

using namespace std;

typedef long double ld;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<int,int> ii;
typedef pair<long, long> ll;
typedef unordered_set<int> ui;

class IntegerotS{
    unordered_map<int, long> cnt;
    int K;
    void init(){
        int N;
        cin>>N>>K;
        for(int i=0;i<N;++i){
            int a,b;
            cin>>a>>b;
            if(a<=K) cnt[a] += (long)b;
        }
    }
    long pass(int nk){
        long ans = 0;
        for(auto p:cnt) if(!(p.first & nk)) ans += p.second;
        return ans;
    }
public:
    long solve(){
        init();
        int NK = (-1)^K;
        long ans = pass(NK);
        for(int j=0;j<32;++j){
            if(((NK>>j)&1) == 0){
                NK |= (1<<j);
                ans = max(ans, pass(NK));
            }
            NK &= NK-1;
        }
        return ans;
    }
};

int main(){
    std::ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cout<<IntegerotS().solve()<<endl;
    return 0;
}

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

typedef long long ll;

#define INF 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> ab[100010];
  map<int, int, std::greater<int>> mp;
  priority_queue<ll> que;
  rep(i, n) {
    int a, b;
    cin >> a >> b;
    ab[a].push_back(b);
  }
  
  ll ans = 0;
  for (int i = 1; i <= m; ++i) {
    // cout << i << endl;
    for (int j = 0; j < ab[i].size(); ++j) {
      que.push(ab[i][j]);
    }
    if (!que.empty()) {
      ans += que.top();
    que.pop();
  
    }
  }  

  cout << ans << endl;

}


Measured memory_bytes: 5632
n,m=map(int,input().split())
edge=[[]for _ in range(n)]
for _ in range(m):
  l,r,d=map(int,input().split())
  l-=1
  r-=1
  edge[l].append((r,d))
  edge[r].append((l,-d))
ans=[10**20]*n
inf=10**20
for i in range(n):
  if ans[i]!=inf:continue
  stack=[i]
  visited={i}
  ans[i]=0
  for node in stack:
    for mode,d in edge[node]:
      if ans[node]+d!=ans[mode]!=inf:exit(print("No")) #ans[node]+d!=ans[mode] and ans[mode]!=inf
      if mode in visited:continue
      visited.add(mode)
      stack.append(mode)
      if ans[mode]==inf:
        ans[mode]=ans[node]+d
        #if ans[node]+d!=ans[mode]:exit(print("No"))
print("Yes")




Measured memory_bytes: 121264
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    from collections import Counter
    c = Counter(A)
    most = c.most_common()
    if most[0][1] >= 4:
        ans = []
        for k, v in most:
            if v >= 4:
                ans.append(k)
                ans.append(k)
            elif v >= 2:
                ans.append(k)
        ans.sort()
        print(ans[-1]*ans[-2])
    elif most[0][1] >= 2 and most[1][1] >= 2:
        ans = []
        for k, v in most:
            if v >= 2:
                ans.append(k)
        ans.sort()
        print(ans[-1]*ans[-2])
    else:
        print(0)


if __name__ == '__main__':
    main()


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

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

typedef long long ll;
const ll MOD = 1e9 + 7;

bool is_done(std::string s, char c) {
  return s == std::string(s.length(), c);
}

int sim(std::string s, char c) {
  if(is_done(s, c)) return 0;
  std::string new_s(s);

  int ret = 0;
  bool flg = false;
  while(not flg) {
    for(int i = 0; i < new_s.length() - 1; ++i) {
      if(new_s[i] == c or new_s[i + 1] == c) {
        new_s[i] = c;
      }
    }
    new_s = new_s.substr(0, new_s.length() - 1);
    ++ret;
    flg = is_done(new_s, c);
  }
  return ret;
}

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

  int ans = 100;
  for(char c : s) {
    ans = std::min(sim(s, c), ans);
  }
  std::cout << ans << '\n';
}


Measured memory_bytes: 256
#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>;
 
const int INF = 1001001001;
 
int a[12][12];
 
int main() {
  int n, m, x;
  cin >> n >> m >> x;
  vector<int> c(n);
  rep(i,n) {
    cin >> c[i];
    rep(j,m) cin >> a[i][j];
  }
 
  int ans = INF;
  rep(s,1<<n) {
    int cost = 0;
    vector<int> d(m);
    rep(i,n) {
      if (s>>i&1) {
        cost += c[i];
        rep(j,m) d[j] += a[i][j];
      }
    }
    bool ok = true;
    rep(j,m) if (d[j] < x) ok = false;
    if (ok) ans = min(ans, cost);
  }
  if (ans == INF) cout << -1 << endl;
  else cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628
S = str(input())
N = len(S)
ans = N//2

while ans < N:
  K = ans+1
  start = N-K
  end = K-1
  leng = end-start+1
  C = str(S[start:end+1])
  #print(start,end,C,"0"*leng,"1"*leng)
  if C == "0"*leng or C == "1"*leng:
    ans += 1
  else:
    #print("unko")
    break
print(ans)

Measured memory_bytes: 108032