akhauriyash/Code-Regression huggingface dataset:
// #include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
using namespace std;
// using namespace __gnu_pbds;
// template <class c, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}
typedef long long int ll;
const ll mod =1e9+7;
const int maxn = 300002;
#define endl '\n'
#define ld long double
#define int ll
#define all(x)  (x).begin(),(x).end()
ll t[4*maxn+5];
ll lazy[4*maxn+5];
int cnt[maxn];
const ll md = (ll) 998244353;
 
inline ll add(ll a, ll b) {
  a += b;
  if (a >= md) a -= md;
  return a;
}
 
inline ll sub(ll a, ll b) {
  a -= b;
  if (a < 0) a += md;
  return a;
}
 
inline ll mul(ll a, ll b) {
  return (ll) ((long long)((a%md) * (b%md)) % md);
}
 
inline ll power(ll a, long long b) {
  ll res = 1;
  while (b > 0) {
    if (b & 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}
 
inline ll inv(ll a) {
  a %= md;
  if (a < 0) a += md;
  ll b = md, u = 0, v = 1;
  while (a) {
    ll t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += md;
  return u;
}

void push(ll id,ll l,ll r){

    if(!lazy[id]) return;
    t[id] = mul(cnt[(r-l+1)],lazy[id]);
    if(l!=r){
      lazy[id<<1] = lazy[id];
      lazy[id<<1|1] = lazy[id];
    }
    lazy[id]=0; 
}
 
void build(ll id,ll l,ll r){
  if(l==r){
    t[id] = 1;
    lazy[id]=0;
    return;
  }
  ll mid=(l+r)>>1;
  build(id<<1,l,mid);
  build(id<<1|1,mid+1,r);
  t[id] = add(mul(t[id<<1],power(10,(r - (mid+1) + 1))),t[id<<1|1]);
  lazy[id] = 0;
}
 
void update(ll id,ll l,ll r,ll lq,ll rq,ll val){
  push(id,l,r);
  if(l>r||lq>r||l>rq)return;
  if(lq<=l&&r<=rq){
    lazy[id]=val;
    push(id,l,r);
    return;
  }
  ll mid=(l+r)>>1;
  update(id<<1,l,mid,lq,rq,val);
  update(id<<1|1,mid+1,r,lq,rq,val);
  t[id] = add(mul(t[id<<1],power(10,(r - (mid+1) + 1))),t[id<<1|1]);
}
int32_t main(){

  IOS

  
  int n, q;
  cin >> n >> q;
  for(int i = 1;i<=n;i++){
    cnt[i] = add(cnt[i-1],power(10,i-1));
    
  }
  build(1,1,n);
  
  while(q--){
    int l, r, d;
    cin  >> l >> r >> d;
    update(1,1,n,l,r,d) ;
    cout << t[1] << endl;
  }


  

  
    
}



Measured memory_bytes: 13424
N = int(input())
p = list(map(int, input().split()))

def swap(i, j, lis):
    tmp = lis[i]
    lis[i] = lis[j]
    lis[j] = tmp

length = len(p)
cnt = 0
for i in range(1, length):
    l = p[i - 1]
    if l == i:
        swap(i-1, i, p)
        cnt += 1

r = p[-1]

if r == i + 1:
    swap(i-1, i, p)
    cnt += 1

print(cnt)
        
        


Measured memory_bytes: 14004
//#pragma GCC optimize("Ofast")
#include <set>
#include <map>
#include <stack>
#include <cmath>
#include <queue>
#include <bitset>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <tr1/unordered_map>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define bql 2147483647
#define ll long long
#define ull unsigned long long
using namespace std::tr1;
using namespace std;
const int N=2e5+5;
const int mod=998244353;
const int fx[5]={0,-1,0,1,0};
const int fy[5]={0,0,-1,0,1};
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while (ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while (ch>='0' && ch<='9'){x=(x<<3)+(x<<1);x+=(ch-'0');ch=getchar();}
    return x*f;
}

void write(int x)
{
    if (x<0) putchar('-'),x=-x;
    if (x>10) write(x/10);
    putchar(x%10+'0');
}

int n,x;
int main()
{
  fast;
  cin>>n;
  for (int i=1;i<=n;++i)
  {
    cin>>x;
    if (x%2==0 && x%3!=0 && x%5!=0)
    {
      cout<<"DENIED\n";
      return 0;
    }
  }
  cout<<"APPROVED\n";
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<string.h>
using namespace std;
#define ll long long
int d[55];
int main()
{
    int N;
    scanf("%d",&N);
    for(int i=0;i<N;i++)
    {
        scanf("%d",&d[i]);
    }
    ll ans=0;
    for(int i=0;i<N-1;i++)
    {
        for(int j=i+1;j<N;j++)
        {
            ans=ans+d[i]*d[j];
        }
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
#include <numeric>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<P> vp;
typedef vector<bool> vb;
#define rep(i, a, n) for (ll i = (a); i < (n); ++i)
#define rrep(i, a, n) for (ll i = (a); i > (n); --i)
#define erep(i, a, n) for (ll i = (a); i <= (n); ++i)
#define rerep(i, a, n) for (ll i = (a); i >= (n); --i)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define max(X) *max_element(all(X))
#define min(X) *min_element(all(X))
#define print(X) cout << (X) << "\n"
#define _ << " " <<
#define Yes print("Yes")
#define No print("No")
static const int INF = 1e+9+7;

int main(){
  ll x1, x2, y1, y2;
  cin >> x1 >> y1 >> x2 >> y2;

  ll cos = 0;
  ll sin = 1;
  ll X1 = -cos * (x1-x2) + sin * (y1-y2) + x2;
  ll Y1 = -sin * (x1-x2) - cos * (y1-y2) + y2;
  ll X2 = cos * (x2-x1) - sin * (y2-y1) + x1;
  ll Y2 = sin * (x2-x1) + cos * (y2-y1) + y1;

  cout << X1 _ Y1 _ X2 _ Y2 << "\n";


  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 1000000000
#define InfLL 1000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=(n-1);(i)>=(0);(i)--)
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	int N;
	cin >> N;
	string atmp;
	cin >> atmp;
	N--;
	vi a(N);
	rep(i, N)
		a[i] = abs(atmp[i] - atmp[i + 1]);
	vl pow2(1100000);
	pow2[0] = 0;
	rep(i, 1100000 - 1) {
		pow2[i + 1] = pow2[i];
		int n = i + 1;
		while (1) {
			if (n % 2 == 1)
				break;
			pow2[i + 1]++;
			n /= 2;
		}
	}
	int anstmp = 0;
	rep(i, N) {
		int anstmptmp = (pow2[N - 1] - pow2[N - 1 - i] - pow2[i] == 0) ? 1 : 0;
		anstmp += a[i] * anstmptmp;
		anstmp %= 2;
	}
	int ans = 1;
	if (anstmp == 0) {
		bool any1 = false;
		rep(i, N) {
			if (a[i] == 1)
				any1 = true;
		}
		if (any1)
			ans = 0;
		else {
			int anstmp2 = 0;
			rep(i, N) {
				int anstmptmp = (pow2[N - 1] - pow2[N - 1 - i] - pow2[i] == 0) ? 1 : 0;
				anstmp2 += (a[i] / 2) * anstmptmp;
				anstmp2 %= 2;
			}
			if (anstmp2 == 0)
				ans = 0;
			else
				ans = 2;
		}
	}


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

Measured memory_bytes: 13828
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;

//#define int long long
//using ll = boost::multiprecision::cpp_int;
using ll = long long;
//constexpr int INF = 1e9;//INT_MAX=(1<<31)-1=2147483647
constexpr ll INF = (ll)1e18;//(1LL<<63)-1=9223372036854775807
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-9;
constexpr int dx[4]={1,0,-1,0};
constexpr int dy[4]={0,1,0,-1};
#ifdef LOCAL_ENV
	#define debug(var) std::cout<<#var" = "<<var<<std::endl
#else
	#define debug(var)
#endif
#define p(var) std::cout<<var<<std::endl
#define rep(i, n)   for(ll i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(ll i=1, i##_length=(n); i<=i##_length; ++i)
#define all(a) (a).begin(), (a).end()
#define PI (acos(-1))
template<typename T> inline T power(T x, T n){ return n ? power(x*x%MOD,n/2)*(n%2?x:1)%MOD : 1; }
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b; }
template<typename T1, typename T2>inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	for (int i = 0, len = v.size(); i < len; ++i){
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
	for (int i = 0, len = vv.size(); i < len; ++i){
		s << vv[i] << endl;
	}
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
	s << "{" << endl;
	for (typeof(m.begin()) itr = m.begin(); itr != m.end(); ++itr){
		s << "\t" << (*itr).first << " : " << (*itr).second << endl;
	}
	s << "}" << endl;
	return s;
}

/*-----8<-----8<-----*/

template<typename T>
vector<T> divisor(T n){
	vector<T> div;
	div.push_back(1);
	div.push_back(n);
	for(T i=2 ; i*i<=n ; ++i){
		if(n%i == 0){
			div.push_back(i);
			if(i*i!=n){
				div.push_back(n/i);
			}
		}
	}
	sort(all(div),greater<ll>());
	return div;
}

constexpr ll N_MAX = 500;
constexpr ll A_I_MAX = 1000000;
constexpr ll K_MAX = 1000000000;

ll N, K;
vector<ll> a;
void input() {
	cin>>N>>K;
	a.assign(N,0);
	rep(i,N)cin>>a[i];
}

void solve() {
	ll sum=accumulate(all(a),0LL);
	vector<ll> divlist=divisor(sum);
	rep(i,divlist.size()){
		ll div=divlist[i];
		vector<ll> amari(N,0);
		rep(j,N){
			amari[j]=a[j]%div;
		}
		sort(all(amari));
		ll amarisum=accumulate(all(amari),0LL);
		ll amaricount=amarisum/div;
		ll count=0;
		rep(k,amaricount){
			count+=div-amari[N-1-k];
		}
		if(count<=K){
			p(div);
			return;
		}
	}
}

signed main() {
	input();
	solve();
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
using ll=long long;
ll MOD=1e9+7;

ll mod_pow(ll a,ll n){
    ll ret=1;
    while(n>0){
        if(n & 1){
            ret=ret*a%MOD;
        }
        a=a*a%MOD;
        n>>=1;
    }
    return ret;
}
ll mod_inv(ll x){
    return mod_pow(x,MOD-2);
}
int main(){
    ll N,A,B;
    cin>>N>>A>>B;
    ll sum=mod_pow(2,N)-1;
    ll bunbo=1;
    ll bunshi=1;
    for(int i=0;i<A;i++){
        bunshi*=N-i;
        bunshi%=MOD;
        bunbo*=i+1;
        bunbo%=MOD;
    }
    bunbo=mod_inv(bunbo);
    sum-=(bunshi*bunbo)%MOD;
    if(sum<0){
        sum+=MOD;
    }
    bunbo=1;
    bunshi=1;
    for(int i=0;i<B;i++){
        bunshi*=N-i;
        bunshi%=MOD;
        bunbo*=i+1;
        bunbo%=MOD;
    }
    bunbo=mod_inv(bunbo);
    sum-=(bunshi*bunbo)%MOD;
    if(sum<0){
        sum+=MOD;
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
l=[0]*9
for i in a:
    if i>=3200:
        l[-1]+=1
    for j in range(8):
        if 400*j<=i<400*(j+1):
            l[j]=1

max_=sum(l)
    
if sum(l[:-1])==0:
    min_=1
else:
    min_=sum(l[:-1])
    
print(min_,max_)

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

int main(){
  int N,count=0;
  cin >> N;
  vector<int> H(N);
  for(int i=0;i<N;i++){
    cin >> H.at(i);
  }
  for(int i=0;i<N;i++){
    bool a=false;
    for(int j=0;j<i;j++){
      if(H.at(j)>H.at(i)){
        a=true;
      }
    }
    if(!a){
      count++;
    }
  }
  cout << count << endl;
} 

Measured memory_bytes: 3632
DICT = {
  'C' => 0, 'C#' => 1, 'D' => 2, 'D#' => 3, 'E' => 4, 'F' => 5,
  'F#' => 6, 'G' => 7, 'G#' => 8, 'A' => 9, 'A#' => 10, 'B' => 11,
}

def check(stairs, music, k)
  music.size.downto(1) do |i|
    return false unless 1 <= k && k <= stairs.size && k <= i * 2
    tone = music[i - 1]
    stair = stairs[k - 1]
    case (tone - stair) % 12
    when 1
      k -= 2
    when 0
      k -= 1
    when 11
      k += 1
    else
      return false
    end
  end
  k == 0
end

def work(stairs, music)
  check(stairs, music, stairs.size - 1) || check(stairs, music, stairs.size)
end

s = STDIN.gets.to_i
s.times do
  STDIN.gets
  stairs = STDIN.gets.split.map!{|x| DICT[x]}
  music = STDIN.gets.split.map!{|x| DICT[x]}
  puts work(stairs, music) ? 'Yes' : 'No'
end

Measured memory_bytes: 17380
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define endl "\n"
#define mod 1000000007
#define INF 1e18
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define w(x) int x; cin >> x; while (x--)

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void rwf()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int xpowery(int x, int y)
{
	int ans = 1;
	while (y)
	{
		if (y & 1)
			ans = (ans * x) % mod;
		x = (x * x) % mod;
		y = y / 2;
	}
	return ans;
}

int32_t main()
{
	IOS;
	//rwf();

	int n, m;
	cin >> n >> m;

	int a[n], b[m], c[m];

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

	for (int i = 0; i < m; i++)
		cin >> b[i] >> c[i];

	vector<pair<int, int>> v;

	for (int i = 0; i < m; i++)
		v.pb(mp(c[i], b[i]));

	sort(all(v));

	sort(a, a + n);

	int k = 0;
	for (int i = m - 1; i >= 0; i--)
	{
		int p = v[i].fi, q = v[i].se;

		for (int j = 0; j < q; j++)
		{
			if (a[k] < p)
			{
				a[k] = p;
				k++;

				if (k == n)
					break;
			}
			else
				break;
		}
	}

	int val = 0;

	for (int i = 0; i < n; i++)
		val += a[i];

	cout << val;

	return 0;
}

Measured memory_bytes: 4852
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
ll bpow(ll,ll,ll);
typedef vector<int> vec;
typedef vector<vec> mat;
mat mul(mat &A,mat &B);
mat pow(mat A,ll n);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
bool dp[5001];
vector<ll> a(0);
ll N,K,res=0;
bool solve(int mid){

  fill(dp,dp+5001,false);
  dp[0] = true;
  for(int j=0;j<a.size();j++){
    if(j == mid)
      continue;
    for(int d=5000;d>=0;d--){
      if(d-a[j] >= 0)
        if(dp[d-a[j]])
          dp[d] = true;
    }
  }
  for(int k=K-1;k>=K-a[mid];k--){
    if(dp[k]){
      return true;
      break;
    }
  }
  return false;
}
int main()
{
  
  cin >> N >> K;
  a =  vector<ll>(N,0);
  REP(i,N){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  int ok = a.size()-1;
  int ng = 0;
  while(abs(ok-ng) > 1){
    int mid=(ok+ng)/2;
    if(solve(mid)){
      ok = mid;
    }else
      ng = mid;
  }
  if(solve(ng)){
    cout << ng << endl;
  }else if(solve(ok))
    cout << ok << endl;
  else
    cout << N << endl;
  
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}

ll bpow(ll a, ll n,ll mod){
  int i = 0;
  ll res=1;
  while(n){
    if(n & 1)
      res = (res*a) % mod;
    a = (a*a) % mod;
    n >>= 1;
  }
  return res;
}
const int MOD = 1000000007;
mat mul(mat &A, mat &B){
  mat C(A.size(),vec(B[0].size()));
    REP(i,A.size())REP(k,B.size())REP(j,B[0].size()){
    C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % MOD;
  }
  return C;
}

mat pow(mat A,ll n)
{
  mat B(A.size(),vec(A.size()));
  REP(i,A.size()){
    B[i][i] = 1;
  }
  while(n > 0){
    if ( n & 1) B = mul(B,A);
    A = mul(A,A);
    n >>= 1;
  }
  return B;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<62;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	string s;
	cin >>s;
	string ans="";
	for(int i=0;i<s.size();i++){
		switch(s[i]){
			case '0':
			ans+='0';
			break;
			case '1':
			ans+='1';
			break;
			case 'B':
			if(ans.size()!=0){
				ans.erase(ans.size()-1);
				break;
			}
		}
	}
	cout<<ans<<endl;
}

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var l = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int n = l[0], x = l[1];
            var a = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var total = 0L;
            for (var i = 1; i < n; i++)
            {
                var sum = a[i] + a[i - 1];
                if (sum > x)
                {
                    total += sum - x;

                    if (sum - x > a[i])
                        a[i] = 0;
                    else
                        a[i] -= sum - x;
                }
            }

            Console.WriteLine(total);
        }
    }
}


Measured memory_bytes: 28252
#include<bits/stdc++.h>
#include<string>
using namespace std;
int N;
void dfs(string s,char x){
    if(s.length() == N) printf("%s\n", s.c_str());
    else
        for(char c= 'a'; c <= x; c++)
            dfs(s+c,((c == x) ?(char)(x + 1): x));
}
int main(){
    cin >> N;
    dfs("", 'a');
    return 0;
}

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

int main(){
    int L,R;
    cin >> L >> R;
    int c;
    int prec;
    int n,m;
    for(int i=L;i<R;i++){
        for(int j=1;j<R-i+1;j++){
            n = i%2019;
            m = (i+j)%2019;
            c = (n*m)%2019;
            if((i==L)&&(j==1)){
                prec = c;
            }
            else{
                if(c < prec){
                    prec = c;
                }
            }
            if(prec == 0)break;
        }
        if(prec == 0)break;
    }
    cout << prec << endl;
}

Measured memory_bytes: 256
import java.util.*;
// warm-up
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		boolean ok = true;
		int[] c = new int[256];
		for (char ch : sc.next().toCharArray()) {
			c[ch]++; 
			if (c[ch]>1) ok=false;
		}
		System.out.println(ok ? "yes" : "no");
		sc.close();		
	}

	public static void main(String args[]) {
		solve();
	}

}

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

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

  int N1, N2, N3, N4;
  N1 = N/1000;
  N2 = (N/100)%10;
  N3 = (N/10)%10;
  N4 = N%10;

  if ((N1 == N2) && (N2 == N3)) {
    cout << "Yes" << endl;
  }
  else if ((N2 == N3) && (N3 == N4)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int nowday = 1;
		for (int i = 1; i < 1000; i++) {
			if (i % 3 == 0)
				nowday += 20 * 10;
			else
				nowday += 20 * 5 + 19 * 5;
		}
		for (int i = 0; i < n; i++) {
			int y = sc.nextInt();
			int m = sc.nextInt();
			int d = sc.nextInt();
			int birthday = 0;
			for (int j = 1; j < y; j++) {
				if (j % 3 == 0)
					birthday += (20 * 10);
				else
					birthday += (20 * 5 + 19 * 5);
			}
			for (int j = 1; j < m; j++) {
				if (y % 3 != 0) {
					if (j % 2 == 0)
						birthday += 19;
					else
						birthday += 20;
				} else
					birthday += 20;
			}
			birthday += d;
			System.out.println(nowday - birthday);
		}
		sc.close();
	}
}

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

using namespace std;

typedef long long ll;

#ifdef DEBUG
#define dbg(arg) (printf arg)
#define LOG cout << "line:" << __LINE__ << ":" << endl;
#else
#define dbg(arg)
#define LOG
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(15);
    int N;
    cin >> N;
    cout << ((N+110) / 111) * 111;
    cout << endl;
    return 0;
}



Measured memory_bytes: 256
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use std::cmp::*;
use std::collections::*;
use std::mem::*;

fn main() {
    let (r, w, e) = (std::io::stdin(), std::io::stdout(), std::io::stderr());
    let mut io = IO::new(r.lock(), w.lock(), e.lock());
    let (n, m): (usize, usize) = (io.read(), io.read());

    match n % 2 {
        0 => {
            let mut l = 1;
            let mut r = n - 1;
            let mut flg = false;

            while l <= m {
                if !flg && (r - l) <= n / 2 {
                    r -= 1;
                    flg = true;
                }
                println!("{} {}", l, r);
                r -= 1;
                l += 1;
            }
        }
        _ => {
            for i in 1..m + 1 {
                let j = n - i;
                // 1,3,5,...
                println!("{} {}", i, j);
            }
        }
    }
}

static MOD: i64 = 1000000007;
// IO
use std::io::*;
struct IO<R: Read, W: Write, E: Write> {
    Read: R,
    Write: BufWriter<W>,
    Error: BufWriter<E>,
}
impl<R: Read, W: Write, E: Write> IO<R, W, E> {
    fn new(r: R, w: W, e: E) -> IO<R, W, E> {
        IO {
            Read: r,
            Write: BufWriter::new(w),
            Error: BufWriter::new(e),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let next: String = self
            .Read
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        next.parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>()
    }
    fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.readn(m)).collect()
    }
    fn write<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
    }
    fn writeln<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
        self.Write.write(b"\n");
    }
    fn debug<S: std::fmt::Debug>(&mut self, val: S) {
        writeln!(self.Error, "(debug) {:?}", &val);
    }
    fn debug2<S: std::fmt::Debug, T: std::fmt::Debug>(&mut self, val1: S, val2: T) {
        writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2);
    }
    fn debug3<S: std::fmt::Debug, T: std::fmt::Debug, U: std::fmt::Debug>(
        &mut self,
        val1: S,
        val2: T,
        val3: U,
    ) {
        writeln!(
            self.Error,
            "(debug3) {:?} -> {:?} -> {:?}",
            val1, val2, val3
        );
    }
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
int dp[300005];
int main()
{
    string s;
    int n;
    cin>>n;
    cin>>s;
 
    for(int i = 1; i<n; i++)
    {
        if(s[i]=='E')
            dp[0]++;
    }
 
    for ( int i = 1; i < n; i++)
    {
        if( s[i-1] != 'E' )
            dp[i]++;
        if( s[i] == 'E')
            dp[i]--;
        dp[i] += dp[i-1];
    }
 
    int ans = INT_MAX;
    for( int i = 0; i< n; i++)
    {
        ans =  min (dp[i],ans);
    }
    cout<<ans;
    return 0;
}

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

#define fr(i, a, b) for (long long i = a; i < b; ++i)
#define fr2(i, b, a) for (long long i = b; i >= a; --i)
#define pb push_back

#define set0(a) memset(a, 0, sizeof(a))
#define setneg(a) memset(a, -1, sizeof(a))
#define setinf(a) memset(a, 126, sizeof(a))
#define trace(a) cerr << #a << ": " << a << endl

#define N 1000000007
#define PI acos(-1.0)

typedef vector<long long> vll;
typedef vector<pair<long long, long long>> vllp;
typedef pair<long long, long long> llp;
typedef long long int ll;
typedef unsigned long long ull;

ll Npow(ll x, ll n, ll M = 1000000007)
{
	if (n == 0)
		return 1;
	else if (n % 2 == 0)
		return Npow((x * x) % M, n / 2, M);
	return (x * Npow((x * x) % M, (n - 1) / 2, M)) % M;
}
void print()
{
	;
}
template <typename T, typename... Types>
void print(T var1, Types... var2)
{
	cout << var1 << " ";
	print(var2...);
}

template <typename T>
void show(T *a, int size)
{
	int i;
	cout << endl
		 << "The array is ";
	fr(i, 0, size)
	{
		cout << a[i] << " ";
	}
	cout << endl;
}

template <typename T>
void show_vector(vector<T> v)
{
	cout << endl
		 << "The vector is ";
	int i;
	fr(i, 0, v.size())
	{
		cout << v[i] << " ";
	}
	cout << endl;
}
//GLOBAL
#define M 1000
//FUNCTIONS

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll n, k, s;
	cin >> n >> k >> s;
	fr(i, 0, k)
	{
		cout << s << " ";
	}
	ll num;
	if (s == 1000000000)
	{
		num = s - 1;
	}
	else
	{
		num = 1000000000;
	}
	fr(i, k, n)
	{
		cout << num << " ";
	}
	return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <math.h>
#include <algorithm>
#include <queue>
#include <map>
#include <list>
//#include <bits/stdc++.h>


using namespace std;

#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
typedef long long ll;

int main(){
    int a, b, c, d;
    string ans = "";
    cin >> a >> b >> c >> d;
    while (true) {
        c -= b;
        if(c <= 0) {
            ans = "Yes";
            break;
        }
        a -= d;
        if(a <= 0) {
            ans = "No";
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<string>
using namespace std;
int main(){
string type;
int t[4]={0};
while(cin>>type){
type+=" ";
int i;
for(i=0;type[i]!=',';i++);
i++;
if(type[i]=='A'&&type[i+1]=='B'){
t[2]++;
}else if(type[i]=='A'){
t[0]++;
}else if(type[i]=='B'){
t[1]++;
}else if(type[i]=='O'){
t[3]++;
}
}
for(int i=0;i<4;i++){
cout<<t[i]<<endl;
}
}

Measured memory_bytes: 1180
import java.util.Scanner;

/*
 * テ、ツスツ陛・ツ崢榲ァツ崢ョテ」ツ?ョテヲツ篠「テァツエツ「テ」ツ?ァテヲツ敖・テ」ツ?淌」ツ?ョテ」ツ?凝」ツつ津・ツ?・テ」ツつ古」ツ?ヲテ」ツ?甘」ツ??
 * テ・ツ青古」ツ?佚・ツ崢榲ヲツ閉ーテァツ崢ョテ」ツ?ョテヲツ篠「テァツエツ「テ」ツ?ェテ」ツつ嘉」ツδォテ」ツδシテ」ツδ療」ツ?ァテ」ツ??ゥツ?陛」ツ??」ツ?ェテ」ツつ嘉」ツつづ」ツ??ヲツ猟「テ」ツ?ォテ」ツ?敕」ツ?ョテ」ツδォテ」ツδシテ」ツδ療」ツ?ッテ」ツつォテ」ツつヲテ」ツδウテ」ツδ暗ヲツクツ暗」ツ?ソ
 */
class E{
	int loop;
	int x;
	int y;
	
	E(int a,int b){
		loop=0;
		x=a;
		y=b;
	}
}
public class Main {
	E map[][];
	int count;//,sx,sy;
	public static void main(String[] args) {
		new Main().run();
	}
	void run(){
		Scanner sc=new Scanner(System.in);
		
		while(true){
			int n=sc.nextInt();
			if(n==0) break;
			map=new E[n][n];
			for(int i=0;i<n;i++){
				for(int j=0;j<n;j++){
					int a=sc.nextInt();
					int b=sc.nextInt();
					map[j][i]= new E(a,b);
				}
			}
			int c=1;//loop number
			count=0;
			for(int i=0;i<n;i++){
				for(int j=0;j<n;j++){
					if(map[j][i].loop==0){
						//sx=j;sy=i;
						solve(j, i, c);
						c++;//loop number
					}
				}
			}
			System.out.println(count);
		}
	}
	
	void solve(int mx,int my,int c){
//		System.out.println(mx+" "+my+"  "+map[mx][my].x+" "+map[mx][my].y);
		
		if(0<map[mx][my].loop){//テ」ツ?ゥテ」ツ?」テ」ツ?凝」ツ?ョテヲツ篠「テァツエツ「テ」ツ?ァテヲツ敖・テ」ツ?淌」ツ?禿」ツ?ィテ」ツ?古」ツ?づ」ツつ?
			if(c==map[mx][my].loop){//テ、ツサツ甘・ツ崢榲」ツ?ョloopテ」ツ??」ツ?」テ」ツ?淌」ツつ嘉」ツ??ヲツ鳴ーテ」ツ?療」ツ??oopテ」ツつ津ィツヲツ凝」ツ?、テ」ツ?妥」ツ?淌」ツ?ョテ」ツ?ァテ・ツ「ツ療」ツつ?」ツ??
				count++;
			}
				return;//テ」ツ?凖」ツ?ァテ」ツ?ォティツヲツ凝」ツ?、テ」ツ?妥」ツ?殕oopテ」ツ??」ツ?」テ」ツ?淌」ツつ嘉」ツ?ェテ」ツ?ォテ」ツつづ」ツ?療」ツ?ェテ」ツ??
		}
		
		int a=map[mx][my].x;//テァツァツサテ・ツ仰陛・ツ?暗」ツつ津」ツ??」ツつ古」ツつ?
		int b=map[mx][my].y;
		
		map[mx][my].loop=c;//テ、ツサツ甘・ツ崢榲」ツ?ョloop numberテ」ツつ津」ツ??」ツつ古」ツつ?
		
		solve(a, b, c);
	}

}

Measured memory_bytes: 62060
/*
If you want to shine like a sun, first burn like a sun.
*/

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define v2i vector<vector<int>>
#define v2l vector<vector<ll>>
#define ppi pair<int,int>
#define ppl pair<ll,ll>
#define vpi vector<ppi>
#define vpl vector<ppl>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define imx INT_MAX
#define imn INT_MIN
#define inf 9000000000000000000
#define minf -inf
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 
#define pre cout<<fixed<<setprecision(10);
#define umap unordered_map
#define uset unordered_set
#define pi 3.141592653589793
#define MAXN 100005
#define test1(x) cout << #x " = " << x << endl;
#define test2(x,y) cout << #x " = " << x << " " << #y " = " << y << endl;
const ll infinity = 9e18;

/*
#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int
*/

/*
bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
bool isprime(ll n){if(n < 2) return 0; ll i = 2; while(i*i <= n){if(n%i == 0) return 0; i++;} return 1;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/


int main()
{
    fast

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

        
	int n,m;
	cin>>n>>m;


	int mini = min(n,m);
	int maxi = max(n,m);

	string s;

	for(int i = 0; i < maxi; i++)
	{
		s += to_string(mini);
	}
	cout<<s;










    return 0;
}

Measured memory_bytes: 256
import itertools
n,x,m=map(int,input().split())
t=[list(map(int,input().split()))for _ in [0]*m]
a=[-1]
for b in itertools.product(range(x+1),repeat=n):
    for l,r,s in t:
        if s!=sum(b[l-1:r]):break
    else:
        if sum(a)<sum(b):a=b
print(*a)

Measured memory_bytes: 7688
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>
#include <cmath>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
//================================================

int a = 0, b = 0, c, d, n, k = 0;
string s, t;



int main()
{
	int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e>>k;
	bool x=true;
	if (e - a > k)x = false;
	if (x)cout << "Yay!" << endl;
	else cout << ":(" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
#define LL long long
#define P pair<int,int>
int N, H, W;
int main(){
	cin >> N;
	cin >> H >> W;
	cout << (N - W + 1) * (N - H + 1) << endl;
	return 0;
}

Measured memory_bytes: 764
import sys

sys.setrecursionlimit(500000)
def input():
    return sys.stdin.readline()[:-1]

def main():
    H,W = list(map(int,input().split()))

    A = [list(map(int,input().split())) for i in range(H)]
    B = [list(map(int,input().split())) for i in range(H)]

    C = [[abs(A[i][j]-B[i][j]) for j in range(W)] for i in range(H)]



    DP = [[[0]*(80*160+1) for j in range(W)] for i in range(H)]

    DP[0][0][C[0][0]] = 1

    for j in range(1,W):
        for k in range(80*160+1):
            if DP[0][j-1][k] == 1:
                DP[0][j][abs(k-C[0][j])] = 1
                DP[0][j][abs(k+C[0][j])] = 1

    for i in range(1,H):
        for k in range(80*160+1):
            if DP[i-1][0][k] == 1:
                DP[i][0][abs(k-C[i][0])] = 1
                DP[i][0][abs(k+C[i][0])] = 1


    for i in range(1,H):
        for j in range(1,W):
            for k in range(80*160+1):
                if DP[i][j-1][k] == 1 or DP[i-1][j][k] == 1:
                    DP[i][j][abs(k-C[i][j])] = 1
                    DP[i][j][abs(k+C[i][j])] = 1

    for i in range(80*160+1):
        if DP[H-1][W-1][i]==1:
            print(i)
            break

if __name__ == '__main__':
    main()


Measured memory_bytes: 677256
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops"
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 1000000007
#define MOD 998244353
#define inf 100000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first
#define s second
#define pb push_back
#define ar array
#define ld long double
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};
char c[4]={'D' , 'R' , 'U' , 'L'};
const ll maxN=2e5+5;

void solve(){
	ll D, T ,S ;
	cin>>D>>T>>S;
	if((T*S) >= D)
		cout<<"Yes"<<endl;
	else {
		cout<<"No"<<endl;
	}
}

int main(){
	// mahakal();
	fast;
	ll t =1 ;
	//cin>> t ; 
	while(t--)solve();
	//cerr << "\ntime taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl; 
	return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <map>
#include <queue>

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<pair<int, int>> X, Y;
  for (int i = 0; i < N; i++) {
    int x, y;
    cin >> x >> y;
    X.push_back(make_pair(x, i));
    Y.push_back(make_pair(y, i));
  }
  auto compare = [](const pair<int, int> &a, const pair<int, int> &b) {
                   if (a.first < b.first) {
                     return 1;
                   }else {
                     return 0;
                   }
                 };
  sort(X.begin(), X.end(), compare);
  sort(Y.begin(), Y.end(), compare);
  map<int, vector<pair<int, int>>> edges; // key: fr, value: (to, dist)                                                                                                                                                                                                                       
  for (int i = 0; i < N-1; i++) {
    edges[X[i].second].push_back(make_pair(abs(X[i].first-X[i+1].first), X[i+1].second));
    edges[Y[i].second].push_back(make_pair(abs(Y[i].first-Y[i+1].first), Y[i+1].second));
  }
  for (int i = 1; i < N; i++) {
    edges[X[i].second].push_back(make_pair(abs(X[i].first-X[i-1].first), X[i-1].second));
    edges[Y[i].second].push_back(make_pair(abs(Y[i].first-Y[i-1].first), Y[i-1].second));
  }
  // mst                                                                                                                                                                                                                                                                                      
  auto compare2 = [](const pair<int, int> &a, const pair<int, int> &b) {
                   if (a.first > b.first) {
                     return 1;
                   }else {
                     return 0;
                   }
                 };
  priority_queue<pair<int, int>, vector<pair<int, int>>, decltype(compare2)> q(compare2);
  int start = 0;
  for (pair<int, int> e : edges[start]) {
    q.push(e);
  }
  long ans = 0;
  int cnt = 0;
  vector<bool> in_tree(N, false);
  in_tree[start]=true;
  while (!q.empty() && cnt < N-1) {
    pair<int, int> e = q.top();
    q.pop();
    if (in_tree[e.second]) {
      continue;
    }
    ans += e.first;
    in_tree[e.second] = true;
    cnt++;
    for (pair<int, int> ee : edges[e.second]) {
      if (!in_tree[ee.second]) {
        q.push(ee);
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 20888
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll=long long;
int main(){
    ll h;
    cin>>h;
    ll ans =0;
    ll num =1;

    while(h>1){
        ans +=num;
        h /= 2;
        num *=2;
    }
    ans +=num;
    cout << ans;
}

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

#define int long long
#define fi first
#define se second
#define otp(n) cout << n;
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define ctv(v) rep(i,(v).size()) ct(v[i])
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define repv(i,v) for(int i=0;i<(v).size();i++)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);

int z;
string s,k={"keyence"};

main() {
    cin >> s;
    rep(i,7) {
        if (s[i]!=k[i]) break;
        if (i==6) {
            ct("YES")
            return 0;
        }
    }
    repm(i,s.size()) {
        if (s[i]!=k[i]) break;
        if (s.size()-i==7) {
            ct("YES")
            return 0;
        }
    }
    rep(i,s.size()) {
        if(s[i]!=k[i]) {
            for(int j=s.size()-1;j>=s.size()-8+i;j--) {
                if (s[j] != k[7-s.size()+j]) {
                    ct("NO")
                    return 0;
                }
                if (s.size()-j==7-i) {
                    ct("YES")
                    return 0;
                }
            }
        }
    }
    ct("NO")
}


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

int main(){
  ll k;
  cin >> k;
  ll a,b;
  cin >> a >> b;
  for(ll i=a;i<=b;++i){
    if( i%k == 0 ){
      cout << "OK" << "\n";
      return 0;
    }
  }
  cout << "NG" << "\n";
  return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>

using namespace std;
typedef long long ll;



int main() {
	int N, M, K;
	cin >> N >> M >> K;
	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= M; j++) {
			if (M * i + N * j - 2 * i * j == K) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
typedef long long ll;
typedef long double ld;
int main(){
    ll n;cin>>n;
    vector<ll> v(n);
    REP(i,n){
        cin>>v[i];
    }
    ll four=0, two=0, odd=0;
    REP(i,n){
        ll num=v[i];
        if(num%4==0){
            four++;
        }else if(num%2==0){
            two++;
        }else{
            odd++;
        }
    }
    bool is=true;
    if(two==0 && four+1<odd){
        is=false;
    }else if(two!=0 && four<odd){
        is=false;
    }

    if(is){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 4036
#include <iostream>
#include <algorithm>

using namespace std;

int n,k,w[100000];

bool enough(int p) {
	int t = 0;
	int remain = 0;
	for(int i = 0;i < n;i++) {
		if(w[i] > remain) {
			t++;
			remain = p;
		}
		remain -= w[i];
	}
	return t <= k;
}

int main() {
	int least=0,most=1000000001;
	cin >> n >> k;
	for(int i = 0;i < n;i++) {
		cin >> w[i];
		least = max(least,w[i]);
	}
	while(least != most) {
		int middle = (least + most) / 2;
		if(enough(middle)){
			most = middle;
		} else {
			least = middle + 1;
		}
	}
	cout << least << endl;
}



Measured memory_bytes: 3472
#include<stdio.h>
int main(){
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);

  for(int i=0;i<1000;i++){
    if((i*a)%b==c){
      printf("YES\n");
      return 0;
    }
  }
  printf("NO\n");
  return 0;
}

Measured memory_bytes: 128
process.stdin.resume();
process.stdin.setEncoding('utf8'); 
var lines = [];
var reader = require('readline').createInterface({
	input: process.stdin,
	output: process.stdout
});
 
reader.on('line', (line) => {
	lines.push(line);
});

reader.on('close', () => {
	"use strict"
	const N = +lines[0];
	const V = lines[1].split(" ").map(Number);
	const C = lines[2].split(" ").map(Number);
	
	let ans = V.reduce((acc, v, i) => acc + (v>C[i] && v-C[i]), 0);
	console.log(ans);
});

Measured memory_bytes: 7628
n,a,b,c,d=map(lambda x: int(x)-1,input().split())
n+=1
s=input()

def check(x,y,s): #O(n)
    if '##' in s[x:y+1]:
        return False
    return True

def solve():
    if c<d:
        return check(a,c,s) and check(b,d,s)
    t=list(s)
    t[b]='#'
    t=''.join(t)
    if check(a,c,t):
        return check(b,d,s)
    if c>d+1:
        if '...' in s[b:d+2]:
            return check(a,b,s)
    else:
        if '...' in s[b:d+1]:
            return check(a,b,s)
    
print('Yes' if solve() else 'No')

Measured memory_bytes: 56176
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

def bisearch_min(mn, mx, func):
    """ 条件を満たす最小値を見つける二分探索 """

    ok = mx
    ng = mn
    while ng+1 < ok:
        mid = (ok+ng) // 2
        if func(mid):
            # 下を探しに行く
            ok = mid
        else:
            # 上を探しに行く
            ng = mid
    return ok

N = INT()
A = LIST()
A.sort()

# m番目の大きさのやつが、最後の1匹になれるか
def calc(m):
    # 番兵代わり
    if m == -1:
        return False
    # まず自分以下は全部取り込める
    a = sum(A[:m+1])
    # 全て取り込んだ後で、その先に行ければ行く
    for i in range(m+1, N):
        b = A[i]
        # 自分の2倍まではいける
        if a*2 >= b:
            a += b
        else:
            # 途中で取り込めなくなったらNG
            return False
    # 最後まで行けるなら、最後の1匹になれる
    return True

print(N-bisearch_min(-1, N-1, calc))


Measured memory_bytes: 14480
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char* argv[])
{
  int N;
  cin >> N;
  int K = 3;
  vector< vector<int> > h(N);
  for (int i=0; i<N; i++) h[i].resize(K);
  for (int i=0; i<N; i++) {
    for (int j=0; j<K; j++) {
      cin >> h[i][j];
    }
  }
  
  vector< vector<int> > v(N);
  for (int i=0; i<N; i++) v[i].resize(K);
  
  for (int i=N-1; i >= 0; i--) {
    for (int j=0; j<K; j++) {
      int best = 0;
      for (int k=0; k<K; k++) {
        if (j == k) continue;
        int tmp = h[i][k];
        if (i < N-1) tmp += v[i+1][k];
        if (tmp > best) best = tmp;
      }
      v[i][j] = best;
    }    
  }  
  int best = 0;
  for (int j=0; j<K; j++) {
    if (v[0][j] > best) best = v[0][j];
  }
  cout << best << "\n";
  return 0;
}


Measured memory_bytes: 11136
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math
    #from math import gcd

    #inf = 10**17
    #mod = 10**9 + 7

    a = [int(input()) for _ in range(5)]
    b, res = 0, 0
    for i in range(5):
        temp = ((a[i]-1)//10+1)*10
        res += temp
        b = max(b, temp-a[i])
    print(res-b)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
# m-solutions2019D - Maximum Sum of Minimum
def bfs(start: int) -> None:
    q = [start]
    nodes[start] = C.pop()
    while q:
        v = q.pop(0)
        for u in T[v]:
            if not nodes[u]:
                nodes[u] = C.pop()
                q.append(u)


def main():
    global T, C, nodes
    N, *ABC = map(int, open(0).read().split())
    AB, C = ABC[:-N], ABC[-N:]
    C.sort()
    T = [[] for _ in range(N + 1)]
    for v, u in zip(*[iter(AB)] * 2):
        T[v].append(u), T[u].append(v)
    score, nodes = sum(C) - C[-1], [0] * (N + 1)  # max of C will not be used
    for i, t in enumerate(T[1:], 1):
        if len(t) == 1:
            start = i
            break
    bfs(start)
    print(score)
    print(" ".join(map(str, nodes[1:])))


if __name__ == "__main__":
    main()

Measured memory_bytes: 6460
#include<iostream>
#include<climits>
#include<vector>
using namespace std;
int main(){
    int n,m=0,min=INT_MAX;
    long sum=0L;
    bool f0=false;
    cin>>n;
    vector<int>a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++){
        if(!a[i])f0=true;
        if(a[i]<0)m++,a[i]*=-1;
        sum+=a[i];
        if(a[i]<min)min=a[i];
    }
    if(f0){cout<<sum<<endl;return 0;}
    if(m%2)cout<<sum-min*2<<endl;
    else cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 640
import copy

l = [int(n) for n in input().split()]
l_ = copy.copy(l)

for i in range(3):
    l_ = copy.copy(l)
    k = l_[i]
    del l_[i]
    if sum(l_) == k:
        print('Yes')
        break
    
else:
    print('No') 

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,m,i;
  cin >> n;
  cin >> m;
  
  int ans=0;
  
  while(n>1){
    n--;
    ans+=n;
  }
  while(m>1){
    m--;
    ans+=m;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256