akhauriyash/Code-Regression huggingface dataset:
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

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

#ifdef _DEBUG
#include "../../library/library/debug_template.cpp"
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

struct init {
	init() {
		cin.tie(nullptr); ios::sync_with_stdio(false);
		cout << fixed << setprecision(10);
	}
} init_;

int main() {

	int N, K;
	cin >> N >> K;

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


	auto judge = [&](auto idx) {
		lint sum = 0;
		for (int i = 0; i < N; i++) sum += (A[i] - 1) / idx;
		return sum <= K;
	};

	auto binary_search = [&](auto f) {

		auto ng = 0;
		auto ok = INF;

		while (abs(ok - ng) > 1) {
			auto mid = (ok + ng) / 2;

			if (f(mid)) ok = mid;
			else ng = mid;
		}

		return ok;
	};

	cout << binary_search(judge) << "\n";

	return 0;
}



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

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

	vector<int> P;
	for (int i = 0; i < N; i++) {
		int p;
		cin >> p;
		P.push_back(p);
	}

	sort(P.begin(), P.end());

	int total = 0;
	for (int i = 0; i < K; i++) {
		total += P[i];
	}

	cout << total << endl;

}




Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
typedef     long long               ll;
typedef     vector<ll>              vll;
#define     meme(s)                 memset(s,0,sizeof(s))
#define     rall(s)                 s.rbegin(),s.rend()
#define     i(x)                    scanf("%lld",&(x))
typedef     unordered_map<ll,ll>    mll;
#define     pb                      push_back
#define     in2(x,y)                i(x),i(y)
#define     EL                      cout<<'\n'
#define     fio                     ios_base::sync_with_stdio(false),cin.tie(NULL)
#define     all(s)                  s.begin(),s.end()
typedef     unordered_map<ll,vll>   circuit;
typedef     unordered_map<ll,bool>  is;
const ll    MOD=                    1e9+7;
#define     no                      cout<<"NO\n"
#define     yes                     cout<<"YES\n"
#define     fr(n,x)                 for(int n=0;n<x;n++)
#define     pf(x)                   printf("%lld\n",(x))
#define     fp(x)                   printf("%lld ",(x))
const ll    mx=                     2e7;
#define     segtree                 ll L=2*node,R=L+1,mid=(l+r)/2
#define     cs(n)                   printf("Case %lld: ",(n))
typedef     pair<ll,ll>             pll;
typedef     set<ll>                 sll;
#define     X                       first
#define     Y                       second
#define T(j) ll t;cin>>(t);for(ll j=1;j<=t;j++)



void solve()
{
    ll x;
    i(x);
    ll xr=0;
    vll s(x);
    fr(n,x)
    {
    	i(s[n]);
    	xr=(xr^s[n]);
    }
    for(auto j:s)cout<<(j^xr)<<' ';
    
}
int main() {
    //T(n)
        //cs(n),
        solve();

}

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

#define pb push_back
#define vi vector < int >
#define ii pair < int, int >
#define vii vector < pair < int, int > >
#define vvi vector < vector < int > >
#define ll long long
#define X first
#define Y second
#define mp make_pair
#define FOR( i, lo, hi ) for( int i = (lo);i < (hi);i++ )
#define DFOR( i, hi, lo ) for( int i = (hi);i >= (lo);i-- )
#define pqueue priority_queue

using namespace std;

const long long int MOD = 1e9 + 7;

ll ADD( ll a, ll b )
{
	return ( ( a % MOD ) + ( b % MOD ) ) % MOD;
}

ll SUB( ll a, ll b )
{
	return ( ( a % MOD ) - ( b % MOD ) + MOD ) % MOD;
}

ll MUL( ll a, ll b )
{
	return ( ( a % MOD ) * ( b % MOD ) ) % MOD;
}

ll POT( ll n, ll k )
{
	if ( k == 0 )
		return 1;

	ll ret = POT( n, k / 2 );
	ret = MUL( ret, ret );

	if ( k % 2 )
		return MUL( ret, n );
	return ret;
}

ll DIV( ll a, ll b )
{
	return MUL( a , POT( b, MOD - 2 ) );
}

bool isPrime( ll x )
{
	for ( ll i = 2;i <= sqrt( x ) + 1; ++i )
		if ( x % i )
			return false;
	return true;
}

const int MAXN = 1e5 + 10;

int n;
ii A[ MAXN ];

int main()
{
	cin >> n;
	FOR( i, 0, n )
	{
		cin >> A[ i ].X;
		A[ i ].Y = i;
	}
	
	sort( A, A + n );
	FOR( i, 0, n )
	{
		cout << A[ i ].Y + 1 << " ";
	}
	cout << "\n";
	return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 9999999999999999;
using ll = long long;
int main(){
  int N;
  cin>>N;
  vector <vector <int>> a(N+1,vector<int>(2));
  for(int i = 1;i<=N;i++){
    cin>>a[i][0];
    a[i][1] = i;
  }
  sort(a.begin(),a.end());
  for(int i = 1;i<=N;i++){
    cout << a[i][1] << endl;
  }
  return 0;
}

Measured memory_bytes: 6272
#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;
ll INF = 1145141919454519;


int main() {

    string S;
    cin >> S;

    ll ans = 700;

    if(S[0] == 'o') ans += 100;
    if(S[1] == 'o') ans += 100;
    if(S[2] == 'o') ans += 100;

    cout << ans << endl;
}

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

int min(int a, int b) {
	return a < b ? a : b;
}

int a(int k) {
	return - min(k, -k);
}
int dist(int p, int q, int X, int Y) {
	return min(q - p, a(p - X) + a(q - Y) + 1);
}
int main() {
	int N, X, Y;
	cin >> N >> X >> Y;

	vector<int> v(N);
	for (int i = 0; i < N; i++) {
		v.at(i) = 0;
	}

	int d;
	for (int i = 1; i <= N; i++) {
		for (int j = i + 1; j <= N; j++) {
			d = dist(i, j, X, Y);
			v.at(d) += 1;
		}
	}

	for (int k = 1; k <= N - 1; k++) {
		cout << v.at(k) << endl;
	}
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 9)

INF = float('inf')


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


def rec(i: int):
    if dp[i] < INF:
        return dp[i]

    if i == 0:
        return 0

    res = INF
    res = min(res, rec(i - 1) + abs(h[i] - h[i - 1]))
    if i > 1:
        res = min(res, rec(i - 2) + abs(h[i] - h[i - 2]))

    dp[i] = res

    return dp[i]


N = int(input())
h = LIST()

h.extend([0] * 2)

dp = [INF] * (N + 2)

print(rec(N - 1))


Measured memory_bytes: 93716
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = a;i < n;i++)
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

int main(){
  	ll n,m,memo = 0;
  	cin >> n >> m;
  
  	rep(i,1,sqrt(m)+1){
     	if(m % i == 0 && m/i >= n){
         	memo = max(memo,(ll)i);
          	if(i >= n){
              memo = max(memo,(ll)m/i);
            }
        }
    }
  
  	cout << memo << endl;
  
 	return 0; 
}


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

typedef long long int ll;
typedef vector<long long>lve;
typedef vector<pair<ll,ll> > lvp;
typedef vector<vector<int> > ivve;

#define sp         ' '
#define endl       '\n'
#define F          first
#define S          second
#define pp         pop_back`
#define pb         push_back
#define mp         make_pair 
#define GCD(x,y)   __gcd(x,y)
#define lb         lower_bound
#define up         upper_bound
#define setp       setprecision
#define bs         binary_search
#define all(x)     x.begin(),x.end()
#define LCM(x,y)   ((x*y)/__gcd(x,y))
#define spc(x)     cout<<fixed<<setp(x)

const   long long  inf = 1e18;
const   long long  cs =  200005;
const   long long  mod = 1000000007;
const   double     PI =  2 * acos(0.0);
ll v1[cs],v2[cs];
void solve()
{
    ll t,n,m,a,b,c,d,e,i,j,k,x,y,z,cnt=0,cnt1=0;
    bool flag = false;   
    cin>>n;
    if(n&1)
    {
        x=(n-1)/2;
        y=++x;
        spc(6);
        cout<<(y*1.0/n)<<endl;
    }
    else {
        spc(6);
        cout<<(1.0/2)<<endl;
    }

}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);    cout.tie(NULL);

    // freopen ("input.txt","r",stdin);
    // freopen ("output.txt","w",stdout);

    // int32_t tc;
    // cin>>tc;
    // while(tc--)
    solve();

    return 0;
}


Measured memory_bytes: 3820
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
ll W,H,x,y;
  cin>>W>>H>>x>>y;
  if(W*H%2!=0) {
cout<<W*H/2+0.5<<" ";
  }
  else {
cout<<W*H/2<<" ";
  }
  if(W%2!=0||H%2!=0) {
cout<<0<<endl;
    return 0;
  }
  else if(W/2==x&&H/2==y) {
cout<<1<<endl;
  }
  else {
cout<<0<<endl;
  }
}
  
  
  
  
  
  

  
  


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int k,s;
  cin >> k >> s;
  int cnt=0;
  for(int i=0;i<=k;i++){
    for(int j=0;j<=k;j++){
      if(0<=s-i-j&&s-i-j<=k){
        cnt++;
      }
    }
  }
  cout << cnt << endl;
}


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

string ask(int x){
    cout<<x<<endl;
    string res;
    cin>>res;
    if(res == "Vacant") exit(0);
    return res;
}

int main(void){
    int n;
    cin>>n;
    string ls = ask(0);
    // if(ls == "Vacant") return 0;
    string rs = ask(n-1);
    // if(rs == "Vacant") return 0;
    string ms = ask(n/2);
    int l=0,r=n-1,m=n/2;
    while(true){
        // if(ms == "Vacant") break;
        if(((m-l)%2==0 && ms==ls) || ((m-l)%2==1 && ms!=ls)){
            l = m;
            ls = ms;
        }else{
            r = m;
            rs = ms;
        }
        m = (l+r)/2;
        ms = ask(m);
    }
    return 0;
}


Measured memory_bytes: 852
S = raw_input()
flag = 0
S = S[:-1]
while(len(S) > 0):
  if len(S) % 2 == 1:
     S = S[:-1]
  else:
     a = S[:len(S)/2]
     b = S[len(S)/2:]
     if a == b:
        ans = S
        break
     S = S[:-1]
print len(S)

Measured memory_bytes: 2568
#include<iostream>
#include<cstdio>
//#include<cmath>
#include<algorithm>
//#include<cstring>
//#include<map>
using namespace std;
inline int read()
{
    int p=0,f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-') f=-1;c=getchar();}
    while(c>='0'&&c<='9'){p=p*10+c-'0';c=getchar();}
    return f*p;}
int n,a[107],ans;
int main()
{
	n=read();
	for(int i=1;i<=n;i++)
	    a[i]=read();
	sort(a+1,a+1+n);
	ans=a[n];
	n--;
	int f=0;
	while(n>=1)
	     {
	       	if(!f){f=1;ans-=a[n];}
	       	else{f=0;ans+=a[n];}
	       	n--;
	     }
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
    ll n, m, k;
    cin >> n >> m >> k;
    vector<ll> a(n), b(m);
    REP(i, n) cin >> a[i];
    REP(i, m) cin >> b[i];
    vector<ll> a_ac(n+1), b_ac(m+1);
    ll now = 0;
    REP(i, n) {
        a_ac[i] = now;
        now += a[i];
    }
    a_ac[n] = now;
    now = 0;
    REP(i, m) {
        b_ac[i] = now;
        now += b[i];
    }
    b_ac[m] = now;
    ll target = m;
    ll ans = 0;
    REP(i, n+1) {
        ll rest = k - a_ac[i];
        if (rest < 0) {
            break;
        }
        while (rest < b_ac[target]) {
            target -= 1;
        }
        ans = max(ans, target + i);
    }
    cout << ans << endl;
}

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

int main(){
  int n;
  cin >> n;
  int a[n];
  int dp[n];
  dp[0]=0,dp[1]=0;
  int t1,t2;
  for(int i=0;i<n;i++) cin >> a[i];
 for(int i=2;i<=n;i++){
  if(i==2){
    t1=abs(a[i-1]-a[i-2]);
    dp[i]=abs(t1-dp[i-1]);
  }
      else{
        t1=abs(a[i-1]-a[i-2]);
   t2=abs(a[i-1]-a[i-3]);
    dp[i]=min(t1+dp[i-1],t2+dp[i-2]);
      }
 }
  cout << dp[n] << endl;
  return 0;
}

Measured memory_bytes: 4364
#include <iostream>
//#include <iomanip>
using namespace std;

int main(){

	int n;
	cin >> n;

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

	int j = 0;
	int min = a[j];
	int max = a[j];
	long sum = a[j];
	j++;

	for(; j < n; j++){
		if(min > a[j]){
			min = a[j];
		}
		if(max < a[j]){
			max = a[j];
		}
		sum = sum + a[j];
	}

	cout << min << " " << max << " " << sum << endl;

	return 0;
}

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

 
int main() {

    string s;
    cin >> s;

    cout<<s[0]<<s[1]<<s[2]<<endl;
    

 return 0;
}

Measured memory_bytes: 3596
//KEYENCE String

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a / __gcd(a, b) * b
#define range(a) (a).begin(),(a).end()
const int inf = 2147483647;

int main (){
    string s;cin>>s;
    bool flag = false;
    rep(i,0,s.size()){
        rep(j,0,s.size()){
            string ss = s;
            ss = ss.erase(i,j);
            if(ss=="keyence")flag = true;
        }
    }
    cout <<(flag ? "YES" : "NO")<< endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

int main()
{
  const int INF = 1 << 30;

  int n, m, W;
  while (~scanf("%d %d %d", &n, &m, &W)) {
    vector<int> w, floor(n, 0);
    int top = 0, cnt = 0;
    for (int i = 0; i < n; ++i) {
      int k;
      scanf("%d", &k);
      for (int j = 0; j < k; ++j) {
	int tmp;
	scanf("%d", &tmp);
	w.push_back(tmp);
	floor[i] |= 1 << cnt;
	++cnt;
	top = i;
      }
    }

    if (floor[0] == (1 << cnt)-1) {
      puts("0");
      continue;
    }

    vector<int> sum(1 << cnt, 0);
    for (int S = 0; S < (1 << cnt); ++S) {
      for (int i = 0; i < cnt; ++i) {
	if (S & (1 << i))
	  sum[S] += w[i];
      }
    }

    vector<int> dp(1 << cnt, INF);
    dp[0] = 0;
    for (int S = 0; S < (1 << cnt); ++S) {
      for (int T = S; T != 0; T = (T-1)&S) {
	if (sum[T] <= W)
	  dp[S] = min(dp[S], dp[S^T]+1);
      }
    }

    --m;
    int ans = abs(top - m);
    for (int i = top; i > 0; --i) {
      ans += 2 * dp[floor[i]] - 1;
      floor[i-1] |= floor[i];
    }
    printf("%d\n", ans);
  }
  return 0;
}

Measured memory_bytes: 1036
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    int x, y;
    cin >> x >> y;
    map<int, int> mp = {
        {1, 0},
        {3, 0},
        {5, 0},
        {7, 0},
        {8, 0},
        {10, 0},
        {12, 0},
        {4, 1},
        {6, 1},
        {9, 1},
        {11, 1},
        {2, 2},
    };
    cout << (mp[x] == mp[y]?"Yes":"No");
    return 0;
}

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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    string s;
    cin >> s;

    char prev = '.';
    vll v;

    rep(i, s.size())
    {
        if (s[i] == '<')
        {
            if (prev == s[i])
            {
                ++v.back();
            }
            else
            {
                v.pb(1);
            }
            prev = '<';
        }
        else
        {
            if (prev == s[i])
            {
                --v.back();
            }
            else
            {
                v.pb(-1);
            }
            prev = '>';
        }
    }

    ll ans = 0;
    ll prev2 = 0;
    rep(i, v.size())
    {
        if (prev2 > 0 && v[i] < 0)
        {
            ans -= min(abs(v[i - 1]), abs(v[i]));
        }
        ans += (abs(v[i]) * (abs(v[i]) + 1)) / 2;
        prev2 = v[i];
    }
    cout << ans << endl;
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3352
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] arr = new long[N+1];
        Arrays.fill(arr, 1);
        for (int i = 2; i < arr.length; i++) {
        	int num = i;
        	while (num < arr.length) {
        		arr[num]++;
        		num += i;
        	}
        }
        long count = 0;
        for (int i = 1; i < arr.length; i++) {
        	count += i*arr[i];
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 116712
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
string ma[514];
bool ta[514],yo[514];
int n;
int cal(int x){
	if(ta[x]){
		int ret=n;
		rep(i,n){
			if(yo[i]) ret--;
		}
		return ret;
	}
	int f=1,ret=0;
	rep(i,n){
		if(ma[i][x]=='#') f=0;
	}
	//if(f<1) return 114514;
	rep(i,n){
		if(ma[x][i]=='.') ret++;
	}
	ret+=n;
	rep(i,n){
		if(yo[i]) ret--;
	}
	return ret+f;
}
int main()
{
	int out=114514,f=0;
	cin>>n;
	string fu(n,'#');
	rep(i,n) cin>>ma[i];
	rep(i,n) ta[i]=yo[i]=true;
	rep(i,n) rep(j,n){
		if(ma[i][j]=='.'){
			ta[i]=yo[j]=false;
		}
		else f=1;
	}
	if(f<1){
		cout<<-1<<endl;return 0;
	}
	rep(i,n){
		out=min(out,cal(i));
	}
	if(out>=114514) cout<<-1<<endl;
	else cout<<out<<endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define pri_que priority_queue
#define vint vector<int>
#define vvint vector<vector<int>>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vs vector<string>
#define vvc vector<vector<char>>
#define vc vector<char>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define show(x) cout<<#x<<"="<<x<<endl;
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e15;
const long long MOD = 1e9+7;

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

    int n,x; cin >> n >> x;
    vi m(n);
    rep(i,n) cin >> m[i];
    
    int res=n;
    x-=SUM(m);
    cout<<floor((ld)x/MIN(m))+res<<endl;

}

Measured memory_bytes: 3784
a = [list(map(int, input().split())) for i in range(3)]
n = int(input())
for i in range(n):
	x = int(input())
	for h in range(3):
		for w in range(3):
			if a[h][w] == x:
				a[h][w] = 0
for i in range(3):
	if a[i][0] == a[i][1] == a[i][2] == 0:
		print("Yes")
		exit()
	elif a[0][i] == a[1][i] == a[2][i] == 0:
		print("Yes")
		exit()
if a[0][0] == a[1][1] == a[2][2] == 0:
	print("Yes")
elif a[2][0] == a[1][1] == a[0][2] == 0:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 38384
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#define N 100005
using namespace std;

typedef long long ll;
ll n, m, k, x, go, cnt, c, ans, l, r, md, a[N], ta[N], s[200005];
vector<ll> b;
ll f(ll p) {
	ll r = 0;
	while (p >= 1) {
		r += s[p];
		p -= (p & -p);
	}
	return r;
}

void g(ll p) {
	while (p <= n * 2 + 1) {
		s[p]++;
		p += (p & -p);
	}
}
int main()
{
	ll i;
	cin >> n;
	for (i = 1; i <= n; i++) {
		scanf ("%lld", &a[i]);
		ta[i] = a[i];
	}
	sort(ta + 1, ta + n + 1);
	for (i =1; i <= n; i++) {
		if (ta[i] != ta[i - 1]) b.push_back(ta[i]);
	}
	l = 0;
	r = b.size();
	go = (n * (n + 1) / 2) / 2 + 1;
	while (l < r) {
		md = (l + r) / 2;
		x = b[md];
		memset(s, 0, sizeof(s));
		c = 0;
		cnt = 0;
		g(n + 1);
		for (i =1; i <= n; i++) {
			if (a[i] <= x) cnt++;
			else cnt--;
			g(n + 1 + cnt);
			c += f(n + cnt);
		}
		if (c >= go) {
			r = md;
			ans = x;
		} else {
			l = md + 1;
		}
	}
	cout << ans;
    return 0;
}


Measured memory_bytes: 4340
#include <stdio.h> 
#include <math.h>
  
int main(void)
{   
    int n, x[1000], y[1000],i;
    double p1 = 0, p2 = 0, p3 = 0, p = 0;
  
    scanf("%d",&n);
  
    for(i=0; i<n; i++)
    {
        scanf("%d", &x[i]);
    }
  
    for(i=0; i<n; i++)
    {
        scanf("%d", &y[i]);
    }
  
    for(i=0; i<n; i++)
    {
        if(x[i] < y[i])
        {
            p1 = p1 + y[i] - x[i];
            p3 = p3 + (y[i] - x[i]) * (y[i] - x[i]) * (y[i] - x[i]);
        }
        if(x[i] > y[i])
        {
            p1 = p1 + x[i] - y[i];
            p3 = p3 + (x[i] - y[i]) * (x[i] - y[i]) * (x[i] - y[i]);
        }
  
        p2 = p2 + (x[i] - y[i]) * (x[i] - y[i]);
  
        if(x[i] < y[i])
        {
            if(p < y[i] - x[i])
            {
                p = y[i] - x[i];
            }
        }
        if(x[i] > y[i])
        {
            if(p < x[i] - y[i])
            {
                p = x[i] - y[i];
            }
        }
    }
  
    printf("%f\n%f\n%f\n%f\n", p1, sqrt(p2), pow(p3, 1.0/3.0), p);
    return 0;
}


Measured memory_bytes: 2108
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

struct Node {
    int key;
    Node* next;
    Node* prev;
};

Node* nil;

Node* listSearch(int key) {
    Node* cur = nil->next;
    while (cur != nil && cur->key != key) {
        cur = cur->next;
    }
    return cur;
}

void init() {
    nil = (Node*)malloc(sizeof(Node));
    nil->next = nil;
    nil->prev = nil;
}

void printList() {
    Node* cur = nil->next;
    int isf = 0;
    while (1) {
        if (cur == nil) break;
        if (isf++ > 0) printf(" ");
        printf("%d", cur->key);
        cur = cur->next;
    }
    printf("\n");
}

void deleteNode(Node* t) {
    if (t==nil) return;
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}

void deleteFirst() {
    deleteNode(nil->next);
}

void deleteLast() {
    deleteNode(nil->prev);
}

void deleteKey(int key) {
    deleteNode(listSearch(key));
}

void insert(int key) {
    Node* x = (Node*)malloc(sizeof(Node));
    x->key = key;
    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
}

int main(void){
    int key, n, i;
    int size = 0;
    char com[20];
    int np = 0, nd = 0;
    scanf("%d", &n);
    init();
    for (i = 0; i < n; i++) {
        scanf("%s%d", com, &key);
        if (com[0] == 'i') {insert(key); np++; size++;}
        else if (com[0] == 'd') {
            if (strlen(com) > 6) {
                if (com[6] == 'F') deleteFirst();
                else if (com[6] =='L') deleteLast();
            }
            else {
                deleteKey(key); nd++;
            }
            size--;
        }
    }
    
    printList();
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}



Measured memory_bytes: 33940
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t N;
int32_t av, bv, cv;
int32_t func(int a, int b, int c, int32_t min = 0)
{
	if (a == 0 && b == 0 && c == 0) {
		return 1;
	}
	int32_t res = 0;
	for (int32_t i = 0, aa = 1; i <= a && aa <= N; i++, aa*= av)
		for (int32_t j = 0, bb = 1; j <= b && bb <= N; j++, bb *= bv)
			for (int32_t k = 0, cc = 1; k <= c && cc <= N; k++, cc *= cv) {
		auto vv = aa * bb*cc;
		if (min >= vv) { continue; }
		if (vv > N) { break; }
		res += func(a - i, b - j, c - k, vv);
	}
	return res;
}

int num[200];
int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N;
	bool prime[500] = {};
	for (int32_t i = 2; i <= N; i++)
	{
		bool ng = false;
		for (int32_t j = 2; j*j <= i; j++)
		{
			ng |= ((i%j) == 0);
		}
		prime[i] = !ng;
	}
	prime[1] = false;

	for (int32_t i = 1; i <= N; i++)
	{
		int tmp = i;
		for (int32_t j = 2; j <= N && tmp > 1; j++)
		{
			if (!prime[j]) { continue; }
			while (tmp % j == 0) {
				tmp /= j;
				++num[j];
			}
		}
	}

	int32_t res = 0;
	for (int32_t i = 1; i <= N; i++)
	{
		if (!prime[i]) { continue; }
		if (num[i] >= 74) { ++res; }
		for (int32_t j = 1; j <= N; j++)
		{
			if (i == j) { continue; }
			if (!prime[j]) { continue; }
			if (num[i] >= 3-1 && num[j] >= 25 - 1) { ++res; }
			if (num[i] >= 5 - 1 && num[j] >= 15 - 1) { ++res; }
			for (int32_t k = 1; k <= N; k++)
			{
				if (i == k) { continue; }
				if (k == j) { continue; }
				if (!prime[k]) { continue; }
				if (k < j && num[i] >= 3 - 1 && num[j] >= 5 - 1 && num[k] >= 5 - 1) { ++res; }
			}
		}
	}

	//int32_t count = 0;
	//int32_t res = 0;
	//for (int32_t i = 1; i <= N; i++) {
	//	if (!prime[i]) { continue; }
	//	av = i;
	//	if (func(74, 0, 0)) {
	//		++res;
	//	}
	//	for (int32_t j = 1; j <= N; j++)
	//	{
	//		if (i == j) { continue; }
	//		if (!prime[j]) { continue; }
	//		bv = j;
	//		if (func(4, 14, 0)) { 
	//			++res;
	//		}
	//		if (func(2, 24, 0)) {
	//			++res;
	//		}
	//		if (i <= j) {
	//			for (int32_t k = 1; k <= N; k++) {
	//				if (i == k) { continue; }
	//				if (j == k) { continue; }

	//				if (!prime[k]) { continue; }
	//				if((i*k <= N || k*k <= N) && (j*k <= N || j * j <= N || i*i * j <= N))++count;
	//				cv = k;
	//				if (func(4, 4, 2)) {
	//					++res;
	//				}
	//			}
	//		}
	//	}
	//}
	out << res << endl;

	return 0;
}
#endif


Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;

public class Main {

	Scanner sc = new Scanner(in);
	
	void run() {
		int[] ref = new int[100];
		int[][] cost = new int[100][100];
		int[][] refc = new int[100][100];
		int[] dis = new int[100];
		boolean[] used = new boolean[100];
		int INF = Integer.MAX_VALUE/2;
		while (true) {
			int n = sc.nextInt(), m = sc.nextInt(), l = sc.nextInt(), k = sc.nextInt(), a = sc.nextInt(), h = sc.nextInt();
			if (n == 0) break;
			ref[0] = a;
			ref[1] = h;
			for (int i = 2; i < l+2; i++)
				ref[i] = sc.nextInt();
			for (int i = 0; i < n; i++)
				Arrays.fill(cost[i], INF);
			for (int i = 0; i < k; i++) {
				int x = sc.nextInt(), y = sc.nextInt(), t = sc.nextInt();
				cost[x][y] = cost[y][x] = t;
			}
			
			for (int c = 0; c < n; c++)
				for (int i = 0; i < n; i++)
					for (int j = 0; j < n; j++)
						cost[i][j] = min(cost[i][j], cost[i][c] + cost[c][j]);
			
			for (int i = 0; i < l+2; i++) {
				for (int j = 0; j < l+2; j++) {
					refc[i][j] = (cost[ref[i]][ref[j]] > m) ? INF : cost[ref[i]][ref[j]];
				}
			}
			
			for (int i = 0; i < l+2; i++) {
				dis[i] = INF;
				used[i] = false;
			}
			dis[0] = 0;
			
			while (true) {
				int v = -1;
				for (int i = 0; i < l+2; i++) {
					if (!used[i] && (v == -1 || dis[i] < dis[v])) v = i;
				}
				if (v == -1) break;
				used[v] = true;
				
				for (int i = 0; i < l+2; i++) {
					dis[i] = min(dis[i], dis[v] + refc[v][i]);
				}
			}
			
			if (dis[1] == INF) out.println("Help!");
			else {
				out.println(dis[1]+max(0, dis[1]-m));
			}
			
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}

}

Measured memory_bytes: 95912
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)





int main() {
    string s;
    cin >> s;
    ll n = s.size();
    vector<vector<ll>> next(26);
    REP(i, n){
        next[s[i] - 'a'].push_back(i);
    }
    vector<ll> dp(n + 1);
    ll cnt = 1;
    vector<bool> used(26);
    for(ll i = n - 1; i >= 0; i--){
        used[s[i] - 'a'] = true;
        bool f = true;
        REP(j, 26){
            if(!used[j]){
                f = false;
                break;
            }
        }
        if(f){
            cnt++;
            REP(j, 26){
                used[j] = false;
            }
        }
        dp[i] = cnt;
    }
    string ans;
    ll p = 0;
    REP(i, dp[0]){
        REP(j, 26){
            ll idx = lower_bound(next[j].begin(), next[j].end(), p) - next[j].begin();
            if(idx == next[j].size()){
                if(dp[0] - i - 1 == 0){
                    ans += (char)('a' + j);
                    break;
                }
                continue;
            }
            ll t = next[j][idx];
            if(dp[t + 1] == dp[0] - i - 1){
                ans += (char)('a' + j);
                p = t + 1;
                break;
            }
        }
    }
    cout << ans << endl;
}


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

int main(){
    int N;
    cin >> N;
    vector<int> length(N);
    for (int i = 0; i < N; i++){
        cin >> length.at(i);
    }
    int c = length.at(0);
    for (int i = 1; i < N; i++){
        c = max(c,length.at(i));
    }
    int sam = 0;
    for (int i = 0; i < N; i++){
        sam += length.at(i);
    }
    if (c * 2 < sam){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    
}


Measured memory_bytes: 256
import sys
#import string
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

def solve():
    #n = int(stdin.readline().rstrip())
    n,m,k = map(int, stdin.readline().rstrip().split())
    #l = list(map(int, stdin.readline().rstrip().split()))
    #numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
    #word = [stdin.readline().rstrip() for _ in range(n)]
    #number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
    #zeros = [[0] * w for i in range(h)]
    for i in range(n+1):
        for j in range(m+1):
            if k == i*(m-j) + j*(n-i):
                print("Yes")
                exit()
    print("No")



if __name__ == '__main__':
    solve()


Measured memory_bytes: 9184
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int field[510][510];
int main() {
	int N;
	cin >> N;
	int a[10][110];
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < N; j++) {
			cin >> a[i][j];
		}
	}
	int ans=-1;
	for (int i = 0; i < N; i++) {
      	int k=0;
		for (int j = 0; j <= i; j++) {
			k += a[0][j];
		}
		for (int j = i; j < N; j++) {
			k += a[1][j];
		}
		ans = max(ans, k);
	}
	cout << ans << endl;
}

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

int main()
{
   int N,Y,x,y,z;
   cin >> N >> Y;
   int check = 0;
   for(x=0;x<=N;x++){
      for(y = 0;y <=N;y++){
         z = N-x-y;
         if(z >= 0 && Y == 10000*x+5000*y+1000*z){
            check = 1;
            break;
         }
      }
      if(check)break;
   }
   if(check){
      cout << x << " " << y << " " << z << endl;
   }else{
      cout << -1 << " " << -1 << " " << -1 << endl;
   }
   

   return 0;
}


Measured memory_bytes: 3560
from math import ceil

n=int(input())
lst=[]
ans=[]

for i in range(n-1):
    x,y,z=map(int,input().split())
    lst.append([x,y,z])


for i in range(n-1):
    pin=0
    for c,s,f in lst[i:]:
        xxx=max(ceil((pin-s)/f),0)
        pin=s+xxx*f+c
    
    ans.append(pin)


for i in ans:
    print(i)

print(0)

Measured memory_bytes: 73880
def main():
    C1n = list(map(int, input().split()))
    C2n = list(map(int, input().split()))
    C3n = list(map(int, input().split()))

    C = [C1n, C2n, C3n]

    for i in range(3):
        for j in range(3):
            if (not (C[i][j] - C[(i+1)%2][j]) == (C[i][(j+1)%2] - C[(i+1)%2][(j+1)%2])) or (not (C[i][j] - C[i][(j+1)%2]) == (C[(i+1)%2][j] - C[(i+1)%2][(j+1)%2])):
                print("No")
                return

    print("Yes")

main() 
        



Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define int long long
#define x first
#define y second
#define pb push_back

#define speed ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;


signed main()
{ 
    speed
    int n;cin>>n;
    if(n%2==0)
    {
        cout<<(n/2)-1;
    }
    else
    {
        cout<<n/2;
    }
}

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

int main() {
  string sa, sb, sc;
  cin >> sa >> sb >> sc;
  int ai=-1, bi=-1, ci=-1, next=0;
  while (true) {
    if (next==0) {
      if (++ai==sa.size()) {cout << 'A' << endl; break; }
      else next=sa.at(ai)-'a';
    } else if (next==1) {
      if (++bi==sb.size()) {cout << 'B' << endl; break; }
      else next=sb.at(bi)-'a';
    } else {
      if (++ci==sc.size()) {cout << 'C' << endl; break; }
      else next=sc.at(ci)-'a';
    }
  }
}

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

//始点を決めると、終点は必ず一意に決まる(なぜなら、下に行ける時は下に行き、いけない時は右に行くのが最善だから)
//すると、各高さについて、dp[高さ][終点]というように終点の数のデータで管理できる
//しかし、これではO(H * W)になってしまう、、、
//よく考えると、高さを+1するとき、下に障害物がある部分しか終点の情報が変わらないことが分かる
//下に障害物がある時、終点をBi + 1に更新し、元の終点のデータを削除する
//こうすると、見るべきデータは下に障害物があるものだけであり、しかもそのデータは削除されるのでO(H + W)になるということが分かる
//データの管理をsetでおこなうと、全体の計算量はO((H + W) * log(H + W))

int main(void)
{
  int h, w;
  cin >> h >> w;
  set<pair<int, int>> dest_and_start;
  multiset<int> value;
  vector<int> a(h);
  vector<int> b(h);
  for (int i = 0; i < h; i++) cin >> a[i] >> b[i];
  for (int i = 1; i <= w; i++)
  {
    dest_and_start.insert({i, i});
    value.insert(0);
  }
  for (int i = 0; i < h; i++)
  {
    int start = -1;
    auto obstacle = dest_and_start.lower_bound({a[i], -1});
    while (obstacle != dest_and_start.end() && (*obstacle).first <= b[i])
    {
      if (b[i] != w && start < (*obstacle).second)
        start = (*obstacle).second;
      value.erase(value.find((*obstacle).first - (*obstacle).second));
      obstacle = dest_and_start.erase(obstacle);
    }
    if (start != -1)
    {
      dest_and_start.insert({b[i] + 1, start});
      value.insert(b[i] + 1 - start);
    }
    if (value.size() == 0)
      cout << -1 << endl;
    else
      cout << *value.begin() + i + 1 << endl;
  }
}

Measured memory_bytes: 23572
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pII;
#define pb push_back
#define mp make_pair
#define clr(x,y) memset(x,y,sizeof(x))
const int inf=0x3f3f3f3f;
const ll mod=1e9+7;
const int maxn=1e6+5;
//ll fmod(ll x,ll y){ll res=1;while(y){if(y&1)res=res*x%mod;y>>=1;x=x*x%mod;}return res;}
//ll gcd(ll x,ll y){return y==0?x:gcd(y,x%y);}
char s[105][105];
int main()
{
    int n,m;
    while(cin>>n>>m)
    {
        for(int i = 0; i < n; ++i)
        {
            scanf("%s", s[i]);
        }
        for(int i = 0; i < n; i++)
        {
            int have = 0;
            for(int j = 0; j < m; ++j)
            {
                if(s[i][j] == '#')
                {
                    have = 1;
                    break;
                }
            }
            if(!have)
            {
                for(int j = 0; j < m; ++j)
                    s[i][j] = '1';
            }
        }

        for(int i = 0; i < m; i++)
        {
            int have = 0;
            for(int j = 0; j < n; ++j)
            {
                if(s[j][i] == '#')
                {
                    have = 1;
                    break;
                }
            }
            if(!have)
            {
                for(int j = 0; j < n; ++j)
                    s[j][i] = '1';
            }
        }
        for(int i = 0; i < n; ++i)
        {
            int have = 0;
            for(int j = 0; j < m; ++j)
                {
                    if(s[i][j] == '1')continue;
               else
                {
                    cout<<s[i][j];
                    have = 1;
                }
                }
                //cout<<have<<endl;
                if(have)cout<<endl;
        }

    }

}
















Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i = 0; i < (n); ++i )
#define rep_rev(n,i) for(ll i = n; i >= 0; --i )
using namespace std;
using P = pair<int, int>;
const long long INF = 1LL << 60;

int main(){
  int n,m,x; cin >> n >> m >> x;
  int C[n], A[n][m];
  rep(i,n){
    cin >> C[i];
    rep(j,m){
      cin >> A[i][j];
    }
  }
  ll ans = INF;
  for(int bit = 0; bit < (1 << n); ++bit){
    ll tmp = 0;
    int understand[m] = {0};
    for(int j = 0; j < n; ++j){

      if(bit & (1 << j)){
        tmp += C[j];
        for(int i = 0; i < m; ++i){
          understand[i] += A[j][i];
        }
      }
    }
    for(int i = 0; i < m; ++ i){
      if(x > understand[i]){
        tmp = INF;
        break;
      }
    }
    if(tmp < ans) ans = tmp;
  }
  if(ans == INF) ans = -1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
#define m 998244353

long long int fastexpo(long long int a, long long int b)
{
    long long int ans = 1;
    while (b)
    {
        if (b & 1)
            ans = (ans * a) % m;
        b = b / 2;
        a = (a * a) % m;
    }
    return ans;
}
int main()
{
    string str;
    cin >> str;
    ll dp[str.length()];
    int i;
    for (i = 0; i < str.length(); i++)
    {
        if (str[i] != '?')
            break;
    }
    // for (int j = i; j > 0; j--)
    // {

    //     if (str[j] == 'P')
    //         str[j - 1] = 'D';
    //     else
    //     {
    //         str[j - 1] = 'P';
    //     }
    // }
    // for (int j = i + 1; j < str.length(); j++)
    // {
    //     if (str[j] == '?')
    //         if (str[j - 1] == 'P')
    //             str[j] = 'D';
    //         else
    //         {
    //             str[j] = 'P';
    //         }
    // }
    for (int i = 0; i < str.length(); i++)
    {
        if (str[i] == '?')
            str[i] = 'D';
    }
    cout << str << "\n";

    return 0;
}

Measured memory_bytes: 3752
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#define rip(i,n) for(int i=0;i<n;i++)
#define ll long long
#define ld long double
#define set setprecision　//小数点以下何位まで知りたいか
#define mod 1000000007
#define pi 3.14159265
#include<numeric>
using namespace std;
int gcd(int a, int b)//最大公約数
{
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
int lcm(int a, int b)//最小公倍数
{
	return a * b / gcd(a, b);
}
ll pow(ll a, ll b) {
	ll k = b % 30000, h = b / 30000, s = 1;
	rip(i, 30000)s = (s * a) % mod; ll j = 1;
	if (h != 0)rip(i, h)j = j * s % mod;
	if (k != 0)rip(i, k)j = j * a % mod;
	return(j);
}
int  main() {
	int n;
	cin >> n;
	for (int i = n; i < 2 * n; i++) {
		int count = 0;
		for (int j = 2; j <= sqrt(i); j++) {
			if (i % j == 0)count++;
		}
		if (count == 0) {
			cout << i << endl;
			break;
		}
	}
}

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

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
using ll = long long;
using ull = unsigned long long;
constexpr int MOD = 1000000007;
using us = unsigned short;

int mod(int x){
	return x % MOD;
}

int main(void)
{
    IOS
    constexpr int A = 50;
    constexpr int N = 50 + 1;
    constexpr int X = 50;
    // dp[rep][平均]=組み合わせ数
    int n,a; cin >> n >> a;
    vector<map<ll,ll>> dp(n+1);
    REP(i,n+1) {
        FOR(j,-N*X,N*X+1) dp[i][j]=0;
    }

    vector<int> v(n+1);
    FOR(i,1,n+1) {
        cin >> v[i];
        v[i] -=a;
    }

    dp[1][v[1]] = 1;
    FOR(i,2,n+1) {
        //cerr << v[i] << endl;
        FOR(j,-X*A,X*A+1) {
            dp[i][j+v[i]] = dp[i-1][j] + dp[i-1][j+v[i]];
        }
        //cerr << dp[i][0] << endl;
        dp[i][v[i]]++;
    }
    

    cout << dp[n][0] << endl;

    return 0;
}


Measured memory_bytes: 16512
//Robs Code
/***********HEADER***************/
#include <iostream>
#include <bitset>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#include <list>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <set>
#include <queue>
#include <map>
/***********MACROS***************/
#define int long long int
#define fri(l,k) for (i=l;i<=k;i++)
#define frj(l,k) for (j=l;j>=k;j--)
#define fij(a,b,l,k) for(i=a;i<=b;i++) for(j=l;j<=k;j++)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define pii pair<int,int>
using namespace std;
int n,m,i,j,l,k,x,y,a,b,cnt[3],sum[3];
/***********MAIN**************/
const int M = ((int)1e9 + 7);
int power(int x, int y){
    x %= M;
    int ans = 1;
    while(y){
        if(y & 1)
            ans = (ans * x) % M;
        y >>= 1LL;
        x = (x * x) % M;
    }
    return ans;
}
int add(int a, int b){
    return((a % M + b % M) % M);
}
int sub(int a, int b){
    return((a % M - b % M + M) % M);
}
int mul(int a, int b){
    return(((a % M) * (b % M)) % M);
}
int divi(int a, int b){
    return(mul(a, power(b, M - 2)) % M);
}
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	int h,w;
	cin>>h>>w;
	string grid[h];
	for(int i=0;i<h;i++){
		cin>>grid[i];
	}
	int dp[h][w] = {0};
	bool flag = false;
	for(int i=0;i<w;i++){
		if(grid[0][i] == '#'){
			flag = true;
		}
		if(flag) dp[0][i] = 0;
		else dp[0][i] = 1;
	}
	flag = false;
	for(int i=0;i<h;i++){
		if(grid[i][0] == '#'){
			flag = true;
		}
		if(flag) dp[i][0] = 0;
		else dp[i][0] = 1;
	}
	for(int i=1;i<h;i++){
		for(int j=1;j<w;j++){
			if(grid[i][j] == '.'){
				dp[i][j] = add(dp[i-1][j] , dp[i][j-1]);
			}
		}
	}
	cout<<dp[h-1][w-1];
	return 0;
}
//.........

Measured memory_bytes: 9088
n = int(input())
lst = list(map(int, input().split()))

for i in range(n):
    v = lst[i]
    j = i - 1
    while j >=0 and lst[j] > v:
        lst[j + 1] = lst[j]
        j -= 1
    lst[j + 1] = v
    print(*lst) 



Measured memory_bytes: 5980
def resolve():
    N = int(input())
    import collections
    n_dict = collections.defaultdict(list)
    for i in range(N-1):
        u,v,w = map(int,input().split())
        n_dict[u-1].append((v-1,w))
        n_dict[v-1].append((u-1,w))

    color = [-1 for _ in range(N)]

    d = collections.deque()
    for i in range(N):
        if color[i] == -1:
            d.append((i,1))
        while d:
            j,c = d.pop()
            color[j] = c
            for n,w in n_dict[j]:
                if color[n] == -1:
                    d.append((n,c^1)) if w % 2 != 0 else d.append((n,c))
                else:
                    continue
        print(color[i])
resolve()

Measured memory_bytes: 81880
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    string s;
    cin >> s;
    ll iti=0,zero=0,s_size=s.size();

    for(ll i = 0;i < s_size;i++){
        if(s.at(i) == '1')
            iti++;
        else
            zero++;
    }

    if(iti >= zero)
        cout << zero * 2 << endl;
    else
        cout << iti * 2 << endl;
}

Measured memory_bytes: 3744
#include <stdio.h>  /*入出力*/
#include <stdlib.h> /*標準ライブラリ*/
#include <string.h> /*文字列*/
#include <math.h>   /*計算*/
#include <assert.h> /*確認*/
#include <ctype.h>  /*文字操作*/
#include <stdbool.h>/*bool型*/
#include <limits.h>/*限界*/

#define rep(i, n) for(int  i = 0; i < (n); i++)
#define max(a,b) ((a>b)?a:b)
#define ABS(a) (((a)>(0))?a:-(a))
#define LL long long
#define MOD 1000000007//10^9+7(素数)

int main(void)
{
  LL H;
  LL W;
  LL A;
  int f = 0;
  scanf("%lld %lld", &H, &W);
  if (H == 1) {
    printf("1");
    return 0;
  }
  if (W==1) {
    printf("1");
    return 0;
  }

  if (H%2==0) {
    H/=2;
    f = 1;
  }else if (W%2==0) {
    W/=2;
    f = 1;
  }


  if (f != 1) {
    H--;
    H/=2;
    A=H*W+ (W/2)+1;
  }else A = H*W;
  printf("%lld\n", A);
  return 0;
}


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

int main(){
    int n;
    cin>>n;
    int a[4][3][10]={};
    for(int i=0;i<n;i++){
        int b,f,r,v;
        cin>>b>>f>>r>>v;
        a[b-1][f-1][r-1]+=v;
    }
    
        
    for(int j=0;j<4;j++){
        for(int k=0;k<3;k++){
            for(int l=0;l<10;l++){
                cout<<' '<<a[j][k][l];
            }
            cout<<endl;
        }
        if(j!=3){
            cout<<'#'<<'#'<<'#'<<'#'<<'#'<<'#'<<'#'<<'#'<<'#'<<'#'<<'#'<<'#'<<'#'<<'#'<<'#'<<'#'<<'#'<<'#'<<'#'<<'#'<<endl;
        }
    }
}


Measured memory_bytes: 3088