akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long int
using namespace std;
template<typename T,typename U> using P=pair<T,U>;
template<typename T> using V=vector<T>;
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}
#define DUMP(x)  cerr<<#x<<" = "<<(x)<<endl;

struct edge { int to, cost; };

const int INF = 1e18;
const int MOD = 1e9+7;

signed main()
{
   int L, N; cin >> L >> N;
   V<int> x(N);
   for (int i = 0; i < N; i++) {
      cin >> x[i];
   }

   V<int> rx(N);
   for (int i = 0; i < N; i++) {
      rx[i] = L - x[N-1-i];
   }

   V<int> sum(N+1), rsum(N+1);
   for (int i = 0; i < N; i++) {
      sum[i+1] = sum[i] + x[i];
      rsum[i+1] = rsum[i] + rx[i];
   }

   int ans = 0;
   for (int k = 0; k < 2; k++) {
      for (int i = 0; i < N; i++) {
         int l = i + (N-1-i)/2;
         int r = N-2-l;
         int s = 2 * (sum[l+1] - sum[i] + rsum[r+1]);
         if ((N + i) % 2 == 1) {
            s -= x[l];
         } else {
            s -= rx[r];
         }
         chmax(ans, s);
      }
      swap(sum, rsum);
      swap(x, rx);
   }
   cout << ans << endl;

   return 0;
}


Measured memory_bytes: 6528
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;
int ans[1005][1005]={0};
int main()
{ios_base::sync_with_stdio(false);
int n,h,w,a[100005];
cin>>h>>w>>n;
rep(i,1,n)cin>>a[i];
int x=1,y=1,f=1,ptr=1,cnt=0;
while(1)
{
	if(a[ptr]==0)ptr++;
	a[ptr]--;
	if(cnt==h*w)break;
	cnt++;
	ans[x][y]=ptr;
	if(y==w&&f==1)
	{
		x++;
		f=1-f;
	}
	else if(y==1&&f==0)
	{
		x++;
		f=1-f;
	}
	else
	{
		if(f==1)y++;
		else y--;
	}
}
rep(i,1,h)
{
	rep(j,1,w)
	{
		ol(ans[i][j]);os;
	}
	on;
}
return 0;
}



Measured memory_bytes: 768
N = int(input())
H = list(map(int,input().split()))
c = 0
ans = 0
if N == 1:
    print(0)
else:
    for i in range(N-1):
        if H[i+1] <= H[i]:
            c += 1
        else:
            ans = max(c,ans)
            c = 0
    ans = max(c,ans)
    print(ans)

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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

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

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll n, k; cin >> n >> k;
    ll ans = min(n % k, k - (n % k));
    cout << ans << endl;
}


Measured memory_bytes: 256
import bisect

def main():
  N,M = map(int,input().split())
  pref = [[] for i in range(N)]
  id = [[]] * M
  
  for i in range(M):
    p,y = map(int,input().split())
    id[i] = [p,y]
    pref[p - 1].append(y)
    #pref[p - 1] = sorted(pref[p - 1])
  
  for i in range(N):
    pref[i] = sorted(pref[i])
  
  orders = [0] * N
  
  for i in range(M):
    p = id[i][0] - 1
    y = id[i][1]
    order = str(bisect.bisect_left(pref[p],y) + 1)
    city = str(p + 1)
    ID = ""
    ID += "0" * (6 - len(city)) + city + "0" * (6 - len(order)) + order
    print(ID)

if __name__ == '__main__':
  main()

Measured memory_bytes: 33556
var obj = init();
Main();
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");}
function init(){
  var inputFile = myin();
  var returnObj = {
    "list" : inputFile, "index" : 0, "max" : inputFile.length,
    "hasNext" : function(){return (this.index < this.max);},
    "next" : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var N = nextInt();
  var list = nextIntArray();
  var plus = new Array(N);
  var minus = new Array(N);
  var count = {};
  for(var i = 0; i < N; i++){
    plus[i] = list[i] + 1;
    minus[i] = list[i] - 1;
    if(count[list[i]] != null){
      count[list[i]]++;
    }else{
      count[list[i]] = 1;
    }
    if(count[plus[i]] != null){
      count[plus[i]]++;
    }else{
      count[plus[i]] = 1;
    }
    if(count[minus[i]] != null){
      count[minus[i]]++;
    }else{
      count[minus[i]] = 1;
    }
  }
  
  var keys = Object.keys(count);
  var max = 0;
  for(var i = 0; i < keys.length; i++){
    max = Math.max(max, count[keys[i]]);
  }
  myout(max);
}

Measured memory_bytes: 34264
#include<stdio.h>

#define MAX 2000000

int H,A[MAX+1];


void maxheap(int i){
  int l,r,lg,w;
  l = 2*i;
  r = 2*i+1;

  if(l<= H&&A[l]>A[i]) lg = l;
  else lg =i;
  if( r<= H && A[r]>A[lg]) lg = r;

  if(lg!=i){
    w  = A[i];
    A[i] = A[lg];
    A[lg] = w;
    maxheap(lg);
  }
}


int main(){
  int i;
  scanf("%d",&H);

  for(i = 1;i<=H;i++)
    scanf("%d",&A[i]);

  for(i = H/2;i>=1;i--)
    maxheap(i);

  for(i = 1;i<=H;i++){
    printf(" %d",A[i]);
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 3740
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

#define mod 1000000007

int main() {
	int n, m = 10e6;
	cin >> n >> m;
	vector<int> f(n + 1, 0);

	for (int i = 0; i < m; i++) {
		int temp;
		cin >> temp;
		f[temp] = -1;
	}

	f[0] = 1;

	if (f[1] != -1)
		f[1] = 1;
	else
		f[1] = 0;

	for (int i = 2; i < n + 1; i++) {
		if (f[i] != -1)
			f[i] = (f[i - 1] + f[i - 2]) % mod;
		else
			f[i] = 0;
	}
	cout << f[n] << endl;

}

Measured memory_bytes: 640
#include<bits/stdc++.h>            
using namespace std;               
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++) 
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
                                   
#define pb push_back               
#define PII pair<int,int>          
                                   
#define VS vector<string>          
#define VI vector<int>             
#define ll long long int           
#define debug(x) cout << x << " :" <<#x << endl  
int main(void) {                   
    ll a,b,c; cin >> a >> b >> c;  
    ll i=0,j=0,k=0;                
    int ans = 0;                   
    if(a == b && b == c && a%2 == 0) {                                                                                          
        cout << -1 << endl;        
    } else {                       
        while(1) {                 
            if(a%2 or b%2 or c%2) break;
            i = b/2 + c/2;         
            j = a/2 + c/2;         
            k = a/2 + b/2;         
            a=i;b=j;c=k;           
            ans++;                 
        }                          
        cout << ans << endl;       
    }                              
} 

Measured memory_bytes: 764
import math
n = int(input())
tx,ty = 0,0
x,y = [],[]

for i in range(n):
  tx,ty = map(int,input().split())
  x.append(tx)
  y.append(ty)


cx = 0
cy = 0
rad = 0
jud = 0
diffr = 0
maxdist = 0
sx,sy = [],[]


# 任意2点間の距離を算出し最大距離を出す。
for i in range(n-1):
  for j in range(i+1,n):
    if rad < math.sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])):
      rad = math.sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]))
      cx = (x[i]+x[j])/2
      cy = (y[i]+y[j])/2

if rad >= max([math.sqrt((cx-x[i])*(cx-x[i])+(cy-y[i])*(cy-y[i])) for i in range(n)])*2:
  jud = 1
#

if jud == 1:
  rad = rad/2
else:
  p,sx,sy = n,x,y
  rad = 800
  for i in range(0,p-2):
    for j in range(i+1,p-1):
      for k in range(j+1,p):
        a = sx[i]
        b = sy[i]
        c = sx[j]
        d = sy[j]
        e = sx[k]
        f = sy[k]
        aa = 2*(c-a)
        bb = 2*(d-b)
        cc = c*c-a*a+d*d-b*b
        dd = 2*(e-a)
        ee = 2*(f-b)
        ff = e*e-a*a+f*f-b*b
        z = bb*dd-aa*ee
        if z != 0:
          cx = (bb*ff-cc*ee)/z
          cy = (cc*dd-aa*ff)/z
          maxdist = max([math.sqrt((cx-sx[m])*(cx-sx[m])+(cy-sy[m])*(cy-sy[m])) for m in range(p)])
          diffr = math.sqrt((cx-a)*(cx-a)+(cy-b)*(cy-b))
          if maxdist <= diffr and diffr < rad:
            rad = diffr

print(rad)


Measured memory_bytes: 3192
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    if(abs(a-c) <= d) {
        out("Yes");
        re0;
    }

    if(abs(a-b) <= d && abs(c-b) <= d) {
        out("Yes");
        re0;
    }
    
    out("No");
    re0;
}

Measured memory_bytes: 256
// RAKSHIT KADAM
 
//  -- Declare array globally...
 #include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree< int ,  null_type ,  less<int> ,  rb_tree_tag ,  tree_order_statistics_node_update>
// find_by_order returns iterator to  element present at that index...
// order_of_key returns no. of elements having value stricktly less than that given in the order_of_key();
#warning !!!check the size of arrayss!!!
 
// NUMERIC DEFINITIONS :
    #define INF 100000000000000005
    #define inf 1000000003
    #define MOD  1000000007
    #define newMOD  998244353
    #define MAX 200006
    #define pi 3.1415926535897932384626433832795
#define ld long doubles
 #define ll long long
 #define int long long
 
 #define P(gg) for(auto rax:gg){cout<<rax<<" ";}cout<<endl;
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll t; cin>> t; while(t--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define endl "\n"
 #define x first
 #define y second
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define forci(i,n) for(ll i=0;i<n;i++)
 #define vi vector<ll>
 #define Endl endl
 #define lb lower_bound
 #define ub upper_bound
#define pii pair<ll,ll>
 
 #define input freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout)
 #define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;
ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
int power(int x, unsigned int y, unsigned int m){ if (y == 0) return 1;int p = power(x, y/2, m) % m;  p = (p * p) % m;return (y%2 == 0)? p : (x * p) % m;}
ll modInverse(int a, int m){{ return power(a, m-2, m);}}
const int maxn = 200003;

void solve()
{
    ll n;cin>>n;
    ll a[n];
    for(ll i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    ll ans =0;
    
    if(n==1)
    {
        cout<<0<<endl;return;
    }
    if(n==2)
    {
        cout<<a[1]<<endl;return;
    }
    ans =a[n-1];
    ll k = n-2;
    for(ll i=n-2;i>=0;i--)
    {
        if(k){k--;ans+=a[i];}
        if(k){k--;ans+=a[i];}
    }
    cout<<ans<<endl;
}
signed main()
{
   Need_for_speed(activated);
 
//satisfy
//    {
//  solve();
//   }
//
    solve();
    return 0;
}


Measured memory_bytes: 5228
/* コードこちらに */
#include<bits/stdc++.h> //1 //1 //7
using namespace std;//2 //2 // 1
int solve(){    //3　//3　//2
    return 1333;} // 4 // 7 //3
int main(){//5 //1 //7
    int n,m,ei = solve(); //7 //2 // 1
    cin >> n >> m; cerr<<ei; // 8  //3 //2
    vector<pair<long long, long long>> ab(ei); // 1 //7 //3
    vector<pair<long long, long long>> cd(m); //2 // 1 //7
    for(int i=0; i<n; ++i){//3 //2 //1
        cin>>ab[i].second>>ab[i].first; // 4 これあってるのか？ //3 //2
    } //5 あってるきがします…！　//7  //3
    for(int i=0;i<m;++i){//7 // 1 //7
        cin>>(cd.begin() + i)->first>>(cd.begin() + i)->second; // 8 //2　//1
        swap(cd[i].first,cd[i].second);}ei=1640; // 1　//3//2
    for(int i=0;i<n;++i){//2 //7  //3
        int ans=-1,dist=1e9;//3 // 1 //7
        for(int_fast64_t j=0;j<m;++j) { // 4 //2 //1 
            if(abs(ab[i].first-cd[j].first)+abs(ab[i].second-cd[j].second)<dist){ //5 //3//2
                ans=j+ei,dist=abs(ab[i].first-cd[j].first)+abs(ab[i].second-cd[j].second);//7 //7 //3
            }; // 8 ifの} //1 //7
        }--ei; /*桃音モモは美少女*/// 1 ひゃ //2 // 1
        cout << ans-ei << endl;++ei;//えいをえいする//2　//3 //2
        if("true"=="true"){ //3 //7  //3
        }else{;} // 4 こらこら // 1　//7
    } return 0 & ei; //5 //2 // 1
cout<<"AC "<<"ぽれは自由だああああああ"<<endl;}//7 end//3 //2 end

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ini(a,i) memset(a,i,sizeof(a))
#define pb push_back
#define ll long long
#define inf LLONG_MAX

void solve()
{
	ll a,b,i;
	cin>>a>>b;

	cout<<a*b;
}


int main()
{
	std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//ll tt;	cin>>tt;	while(tt--)
	{
		solve();
 	}
	cerr<<" Execution : "<<(1.0*clock())/CLOCKS_PER_SEC<<"s \n";
		
		
return 0;
}

Measured memory_bytes: 3748
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define LOWER(a,x) lower_bound(ALL(a), x) - a.begin() - 1;
#define COUNT(a,x)  upper_bound(ALL(a), x) - lower_bound(ALL(a), x);
#define MCOUNT(a,x,y) upper_bound(ALL(a), y) - lower_bound(ALL(a), x);
#define INF 111111111111111111
#define MOD 1000000007
#define pb push_back
#define F first
#define S second
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, tmp = 0, ma = 0, mi = 0;
string s;
bool flag, ok;
ll dx[4] = { 1,-1,0,0 }, dy[4] = { 0,0,1,-1 };
ll ddx[8] = { 1,-1,0,0,1,1,-1,-1 }, ddy[8] = { 0,0,1,-1,1,-1,1,-1 };
#pragma endregion
#define MAX 111111

struct UnionFind {
  vll rank, par;

  void set(ll n) {
	rank.resize(n, 0);
	par.resize(n, 0);
	FOR(i, 0, n) {
	  par[i] = i;
	  rank[i] = 0;
	}
  }

  ll find(ll x) {
	if (x != par[x]) par[x] = find(par[x]);
	return par[x];
  }

  void unite(ll a, ll b) {
	ll x = find(a);
	ll y = find(b);
	if (rank[x] > rank[y]) {
	  par[y] = x;
	}
	else {
	  par[x] = y;
	  if (rank[x] == rank[y]) {
		rank[y]++;
	  }
	}
  }

  bool same(ll a, ll b) {
	return find(a) == find(b);
  }
};

int main(void) {
  priority_queue<ll,vll,greater<ll>> pq;
  UnionFind u, u2;
  map<ll, pll> mp;
  vll a;
  ll x, y, e, node;
  cin >> n >> m;
  u.set(n);
  FOR(i, 0, n) {
	cin >> tmp;
	a.pb(tmp);
  }
  FOR(i, 0, m) {
	cin >> x >> y;
	u.unite(x, y);
  }
  FOR(i, 0, n) {
	if (a[i] < mp[u.find(i)].F || mp[u.find(i)].F == 0) {
	  mp[u.find(i)].F = a[i];
	  mp[u.find(i)].S = i;
	}
  }

  if (mp.size() == 1) {
	cout << "0" << endl;
	return 0;
  }

  for (auto it : mp) ans += it.S.F;

  FOR(i, 0, n) {
	if (mp[u.find(i)].S != i) pq.push(a[i]);
  }

  e = n - 1 - m;
  node = 2 * e - mp.size();
  if (node > pq.size()) {
	cout << "Impossible" << endl;
	return 0;
  }

  FOR(i, 0, node) {
	tmp = pq.top(); pq.pop();
	ans += tmp;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 8820
#include<bits/stdc++.h>
using namespace std;
#define sz(a) int((a).size())
#define int long long
#define Int int32_t
#define all(c) c.begin(), c.end()
#define FAST ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define pii pair< int , int >
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define bitcnt(n) __builtin_popcountll(n)
#define setpre(n) cout << fixed << setprecision(n)
#define tr(c) for(auto x : c )cout << x << " ";
#define ol(c , s , e ) for(int pos=s; pos<e ; pos++) cout << c[pos] << " ";
#define inf 1e18;
#define PI acos(-1)
const int M = 1000000007;
const int N=1e5+5;

//#define rohit
#ifdef rohit
template<typename... T >
void bug(T... __VA_ARGS__) {
    ((cerr << __VA_ARGS__ << " ") , ...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", bug(__VA_ARGS__) , cerr << endl;
#endif


void solve() {
    int a , b , n;
    cin >> a >> b >> n;
    cout << (a*min(b-1 , n ) )/b << endl;

}

signed main()
{
    FAST;
    //TODO:  check test cases are there or not?
    int tc=1;
//    cin >> tc;
    for(int t = 1 ; t <= tc ; t++)
    {
        solve();
    }
}

Measured memory_bytes: 3640
#include <stdio.h>

int main(void){

	int W,H,x,y,r;
	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

	if(x>=r && x<=W-r && y>=r && y<=H-r){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
    return 0;
}

Measured memory_bytes: 584
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#define ll long long int
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
using namespace std;

int mx8[] = {0,0,1,-1,-1,1,-1,1};
int my8[] = {-1,1,0,0,-1,-1,1,1};
int mx4[] = {1,-1,0,0};
int my4[] = {0,0,-1,1};
const int MOD = 1000000007;

int main() {
    string s; cin >> s;
    int n = s.size();
    map<char,int> mp;
    rep(i,n){
        if(mp[s[i]]){
            cout << "no" << endl;
            return 0;
        }
        mp[s[i]]++;
    }
    cout << "yes" << endl;
}




Measured memory_bytes: 3568
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>
#include<deque>

using namespace std;
typedef long long int ll;

#define C cout<<
#define E <<endl

ll n,m,a,b,c,x,y,z,aa[200010],ab[200010],ac[100010];
bool r,ra,rb,rc;
string s,sa,sb,sc[1000];
char ca,cb,cc,cd[1000][1000];
vector<int> va,vb,vc;

void wi107(ll &nq){
    nq=nq%1000000007;
}

int main(){
    cin>>a>>b>>c;
    C (a+b==c or a+c==b or b+c==a ? "Yes":"No") E;
    
}

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

using namespace std;

int main() {
  int N;
  string A, B, C;
  cin >> N >> A >> B >> C;
  int x = 0;
  for (int i = 0; i < N; ++i) {
    if (A[i] == B[i] && B[i] == C[i]) {
      continue;
    }
    if (A[i] == B[i] || B[i] == C[i] || C[i] == A[i]) {
      ++x;
    } else {
      x += 2;
    }
  }
  cout << x << endl;
  return 0;
}

Measured memory_bytes: 256
n=int(input())
l= list((int(x) for x in input().split()))
beg=end=i=0
n-=1
while(i<=n):
	if(beg>end):
		end+=l[n]
		n-=1
	else:
		beg+=l[i]
		i+=1
print(abs(end-beg))

Measured memory_bytes: 26764
#include<bits/stdc++.h>
#define lint long long int
#define rep(i,n) for(int i=0;i<int(n);i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define arep(i,a,n) for(int i=a;i<n;i++)
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define fill(a,x) fill(a.begin(),a.end(),x)
#define eb(data) emplace_back(data)
#define pb(data) emplace_back(data)
#define mp make_pair
#define ALNUM 26
#define vint vector<int>
#define F first
#define S second
#define ALL(data) data.begin(),data.end()
using namespace std;
template<typename Rast>inline void out(Rast rast){cout<<rast<<"\n";return;}
template<typename Rast>inline void in(Rast& rast){cin>>rast;return;}
template<typename T>istream& operator >> (istream& is, vector<T>& vec){for(T& x: vec) is >> x;return is;}
template<typename First, typename... Rest>void in(First& first, Rest&... rest){cin >> first;in(rest...);return;}
template<typename First, typename... Rest>void out(First first, Rest... rest){cout << first<<" ";out(rest...);return;}
template<typename T>T gcd( T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<typename T1,typename T2>bool chmax(T1& a,T2 b){if(a<b){a=b;return true;}else{return false;}}
template<typename T1,typename T2>bool chmin(T1& a,T2 b){if(a>b){a=b;return true;}else{return false;}}
template<typename T>T lcm(T a, T b){return a * b / gcd(a, b);}
static const double pi = 3.141592653589793;
lint power(lint N, lint P, lint M){if(P==0) return 1;if(P%2==0){lint t = power(N, P/2, M);return t*t % M;}return N * power(N, P-1, M);}
lint MOD=pow(10,9)+7;
//lint MOD=998244353;
lint inf=pow(2,50);
int intinf=pow(2,30);
/**int dirx[]={1,0};int diry[]={0,1};//*///右、下
/**/int dirx[]={0,1,0,-1};int diry[]={-1,0,1,0};//*///四方位
/**int dirx[]={-1,0,1,1,1,0,-1,-1};int diry[]={-1,-1,-1,0,1,1,1,0};//*///八方位

class unionfind{
public:
	vector<int> table;
	vector<int> wod;
	void init(int size){
		table.resize(size);
		wod.resize(size);
		rep(i,size)table[i]=i,wod[i]=i;
	};
	int root(int index){
		if(table[index]==index)return index;
		else{
			int hoge=root(table[index]);
			table[index]=hoge;
			return hoge;
		}
	};
	bool same(int x,int y){
		return(root(x)==root(y));
	};
	int marge(int x,int y){
		int yroot=root(y);
		int xroot=root(x);
		if(xroot==yroot)return 0;
		table[yroot]=xroot;
		return 0;
	}
};

int main(){
	cin.tie(0);ios::sync_with_stdio(false);cout<<std::fixed<<std::setprecision(12);
	int a,b;
	in(a,b);
	if(a<b)out("a < b");
	if(a>b)out("a > b");
	if(a==b)out("a == b");
	return 0;
}



Measured memory_bytes: 3224
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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

int main() {
  int n;
  cin >> n;
  ll ans = 0;
  vector<int> a(n + 1);
  vector<int> b(n);
  rep (i, n + 1) cin >> a[i];
  rep (i, n) cin >> b[i];

  rep (i, n) {
    if (a[i] >= b[i]) {
      ans += b[i];
    } else {
      if (a[i + 1] >= b[i] - a[i]) {
        ans += b[i];
        a[i + 1] -= (b[i] - a[i]);
      } else {
        ans += a[i] + a[i + 1];
        a[i + 1] = 0;
      }
    }
  }
  P(ans);
  return 0;
}

Measured memory_bytes: 1024
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF (LLONG_MAX - 1e5)
#define fcout cout << fixed << setprecision(10)

using namespace std;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    vector<int> v(3);
    REP(i, 3) cin >> v[i];
    sort(v.begin(), v.end());

    cout << v[0] * v[1] / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var c1, c2 string
	fmt.Scan(&c1, &c2)
	if c1 == string(c2[2])+string(c2[1])+string(c2[0]) {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

Measured memory_bytes: 512
# run on python 3.4.3

from sys import stdin
from os import linesep


def main():
    h, w = map(int, stdin.readline().split())
    s = ['' for i in range(h)]
    for i in range(h):
        s[i] = list(stdin.readline())
    dy = [0, 0, 1, 1, 1, -1, -1, -1]
    dx = [-1, 1, -1, 0, 1, -1, 0, 1]
    for y in range(h):
        for x in range(w):
            if s[y][x] != '.':
                continue
            bombs = 0
            for d in range(8):
                py, px = y+dy[d], x+dx[d]
                if 0 > py or py >= h or 0 > px or px >= w:
                    continue
                bombs += 1 if s[py][px] == '#' else 0
            s[y][x] = str(bombs)
    print(linesep.join(map(''.join, s)))


main()


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define has(c,i) ((c).find(i) != end(c))
#define DBGDO(X) ({ if(1) cerr << "DBGDO: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll M, N, m, n;
	cin >> M >> N >> m >> n;
	
	if (M % m == 0 && N % n == 0) {
		cout << "No" << endl;
		return 0;
	}

	cout << "Yes" << endl;
	
	ll K = 1e9;

	vvl a(M,vl(N));
	for (ll i = 0; i < M; i += m) for (ll j = 0; j < N; j += n) a[i][j] = K-1;
	for (ll i = m-1; i < M; i += m) for (ll j = n-1; j < N; j += n) a[i][j] = -K;

	ll sum = 0;
	FOR(i,0,M) FOR(j,0,N) sum += a[i][j];
	assert(sum > 0);
	FOR(i,0,M) FOR(j,0,N) cout << a[i][j] << " \n"[j+1==N];
}



Measured memory_bytes: 4864
# -*- coding: utf-8 -*-
def main():
    N,L = map(int,input().split())
    taste = []
    ABS = []
    for i in range(N):
        taste.append(L+i+1-1)
        #print(taste)
    for j in taste:
        ABS.append(abs(j))
        #print(ABS)
    taste.pop(ABS.index(min(ABS)))
    print(sum(taste))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>
using namespace std;
//////////////////
// Aditya Kumar //
//  BITS H      //
//////////////////
#define mod 1000000007
#define ss second
#define ff first
#define endl '\n' 
#define FastIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define int long long
#define pb push_back


int32_t main() {
    FastIO;
    string s;
    cin>>s;
    for(int i=0;i<s.length() - 8; i++)cout<<s[i];
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
int main(){
 string s;
 cin>>s;
 int a=0;
 int z=s.size()-1;
 while(s[a]!='A')a++;
 while(s[z]!='Z')z--;
 cout<<z-a+1<<endl;

}

Measured memory_bytes: 640
#include <stdio.h>

int main(void){

  int i,j,n1,n2,key,cnt=0;
  int S[10000],T[500];

  scanf("%d",&n1);
  for(i = 0;i < n1;i++){
    scanf("%d",&S[i]);
  }

  scanf("%d",&n2);
  for(i = 0;i < n2;i++){
    scanf("%d",&T[i]);
  }

  for(i = 0;i < n2;i++){
    S[n1] =  T[i];
    j = 0;
    while(S[j] != S[n1]){
      j++;
    }
    if(j != n1){
      cnt++;
    }
		
  }
  
  printf("%d\n",cnt);

  return 0;
}




Measured memory_bytes: 2108
point = int(input())
if point>= 400 and point <= 599:
  print('8')
elif point >= 600 and point <= 799:
  print('7')
elif point >= 800 and point <= 999:
  print('6')
elif point >= 1000 and point <= 1199:
  print('5')
elif point >= 1200 and point <= 1399:
  print('4')
elif point >= 1400 and point <= 1599:
  print('3')
elif point >= 1600 and point <= 1799:
  print('2')
elif point >= 1800 and point <= 1999:
  print('1')

Measured memory_bytes: 9156
N, M = map(int,input().split())
a = []
b = []
for i in range(M):
    L, R = map(int,input().split())
    a.append(L)
    b.append(R)
a = sorted(a)
b = sorted(b)
A = a[M - 1]
B = b[0]
if A <= B:
    print(B - A + 1)
else:
    print(0)

Measured memory_bytes: 18008
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    n = int(input())
    people=[]
    d,x = map(int,input().split())
    people=list([int(input()) for _ in range(n)])
    chocolates=[]
    choco=1

    for human in people:
        for day in range(1,d+1):
            if d >= human * day +1:
                choco+=1
        chocolates.append(choco)
        choco=1
    print(sum(chocolates)+x)

if __name__=="__main__":
    main()

Measured memory_bytes: 9120
#include <bits/stdc++.h>
    using namespace std;
    #define pb push_back
    typedef long long ll;
    set<ll>v;
    map<ll,int> freq;
     
    ll pwr(ll a,ll b)
    {
        ll ans=1;
        while(b!=0)
        {
            if(b%2)
                ans*=a;
            a*=a;
            b/=2;
        }
        return ans;
    }
    int main()
    {
        ll n,p;
        cin>>n>>p;
        if(n>p) {cout<<1<<endl;return 0;}
        ll x = p;
        while(x%2==0)
        {
            x/=2;
            int pp=2;
            freq[pp]++;
            v.insert(pp);
        }
        for(int i=3;1LL*i*i<=x;i++)
        {
            while(x%i==0)
            {
                freq[i]++;
                x/=i;
                v.insert(i);
            }
        }
        if(x>2)
        {
            freq[x]++;
            v.insert(x);
        }
        set<ll>::iterator it = v.begin();
        ll ans=1;
        for(;it!=v.end();it++)
        {
            ll u = *it;
            ll ss = freq[u];
            ss/=n;
            ll ii=1;
            for(int i=0;i<ss;i++)
            {
                ii = ii*u;
            }
     
            ans = 1LL*ans*ii;
        }
        cout<<ans<<endl;
    }

Measured memory_bytes: 256
import collections
n = int(input())
a_lst = list(map(int, input().split()))

cs = collections.Counter(a_lst)
res = sum(a_lst)
q = int(input())
for i in range(q):
  b, c = map(int, input().split())
  if b in cs:
    res = res - b * cs[b] + c * cs[b]
    if c in cs:
      cs[c] += cs[b]
      cs[b] = 0
    else:
      cs[c] = cs[b]
      cs[b] = 0
  print(res)

Measured memory_bytes: 21204
S = input()
N = len(S) -1

ans = 0
for b in range(2 ** N):
    now = int(S[0])
    for i in range(N):
        if b&(2**i):
            ans += now
            now = int(S[i+1])
        else:
            now = 10 * now + int(S[i+1])
    ans += now

print(ans)

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

int dfs(vector<vector<int>>& adj, vector<int>& dp, int i) {
    if(dp[i] != -1)
        return dp[i];
    if(adj[i].size() == 0)
        return dp[i] = 0;
    int ans = dp[i];
    ans = 0;
    for(auto& node: adj[i])
        ans = max(ans, dfs(adj, dp, node));
    return dp[i] = ans + 1;
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> v(n);
    for(int i = 0; i < m; ++i) {
        int x, y;
        cin >> x >> y;
        --x, --y;
        v[x].push_back(y);
    }
    vector<int> dp(n, -1);
    for(int i = 0; i < n; ++i) {
        if(dp[i] == -1) {
            dfs(v, dp, i);
        }
    }
    // for(auto& i: dp)
    //     cout << i << " ";
    cout << *max_element(begin(dp), end(dp));
}

Measured memory_bytes: 8832
// A - Candy Distribution Again
// https://atcoder.jp/contests/agc027/tasks/agc027_a
//
#include <bits/stdc++.h>
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007      //10^9+7
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define Vec(K, L, N, S) vector<L> K(N, S)
#define rt sqrt
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vs = vector<string>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli b, c, h, k, n, w, x, ans = 0, count = 0, tmp = 0;
  string s, t;
  cin >> n >> x;
  vlli a(n);

  rep(i, 0, n)
  {
    cin >> a[i];
    ans += a[i];
  }
  SORT(a);
  tmp = ans;
  if (x == ans)
  {
    cout << n << endl;
    return 0;
  }
  else
  {
    rep(i, 0, n)
    {
      if (x >= a[i])
      {
        x -= a[i];
        count++;
      }
    }
    if (x != tmp && count == n)
      count--;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
class FiveAntennas
{
    static void Main(string[] args)
    {
        var antena = new int[5];
        for (int i = 0; i < 5; i++)
        {
            antena[i] = int.Parse(Console.ReadLine());
        }
        var k = int.Parse(Console.ReadLine());

        bool isYes = true;
        for (int i = 0; i < antena.Length; i++)
        {
            for (int j = 0; j < antena.Length; j++)
            {
                if (antena[j] - antena[i] > k)
                {
                    isYes = false;
                }
            }
        }
        if (isYes)
        {
            Console.WriteLine("Yay!");
        }
        else
        {
            Console.WriteLine(":(");
        }


    }
}

Measured memory_bytes: 11092
import bisect
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

a.sort()
b.sort()
c.sort()
cnt = 0
for i in range(n):
    cnt += bisect.bisect_left(a, b[i]) * (n - bisect.bisect(c, b[i]))

print(cnt)

Measured memory_bytes: 105536
import java.util.Scanner;


public class Main {
	static final long MOD = 1000000007;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long a = sc.nextLong();
		long b = sc.nextLong();
		sc.close();

		long nn = 0;
		long nCa = 0;
		long nCb = 0;
		nn = modpow(2, n, MOD);
		nCa = comb(n, a);
		nCb = comb(n, b);

		long ans = nn - 1 -nCa - nCb;
		while(ans < 0) {
			ans += MOD;
		}
		//System.out.println(nn);
		//System.out.println(nCa);
		//System.out.println(nCb);
		System.out.println(ans);

	}

	//フェルマーの小定理を利用して,pを法としてのaの逆元a^p-2を求める
	public static long MODinv(long a ,long p) {
		return modpow(a ,p-2 ,p);
	}

	//a^n (mod p)を二分累乗法で計算する
	public static long modpow(long a, long n, long p) {
		long ans = 1;
		while(n > 0) {
			if(n%2 == 1) {
				ans = ans * a % p;
			}
			n = n / 2;
			a = a * a % p;
		}
		return ans;
	}

	//nCrをMODを法として計算する
	static long comb(long n, long r) {
		if(n==0 && r==0) return 1;
		if(n<r || n<0) return 0;

		//分子を計算
		long numerator = 1;
		for(long i = n; i > n - r; i--) {
			numerator = numerator * i % MOD;
		}
		//System.out.println("numerator :" + numerator);
		
		long denominator = 1;
		for(long i = r; i > 0; i--) {
			denominator = denominator * i % MOD;
		}
		//System.out.println("denominator :" + denominator);
		
		//分母の逆元を計算
		long denominatorInv = MODinv(denominator, MOD);
		//System.out.println("denominatorInv :" + denominatorInv);

		return numerator * denominatorInv % MOD;
	}









}







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

typedef long long ll;
ll MOD = 1000000007;

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}


ll modpow(ll a,ll n,ll m){//modpow(a,n,m) := a ^ n (mod m)
  ll res = 1;
  while(n > 0){
    if(n & 1)res = res * a % m;
    a = a * a % m;
    n >>= 1;
  }
  return res;
}

ll modinv(ll a,ll p){//modinv(a,p) := pを法とするaの逆元(※pは素数でなければならない)
    ll res = modpow(a,p-2,p);
    return res;
}

int main(){
  int N;cin >> N;
  vector<string> S(N);
  int cnt[26];
  for(int i = 0;i < 26;i++){
    cnt[i] = 1000000;
  }
  for(int i = 0;i < N;i++){
    cin >> S[i];
  }
  for(int i = 0;i < N;i++){
    for(int j = 0;j < 26;j++){
      char q = 'a' + j;
      int a = count(S[i].begin(),S[i].end(),q);
      cnt[j] = min(a,cnt[j]);
    }
  }
  string ans = "";
  for(int i = 0;i < 26;i++){
    char p = 'a' + i;
    for(int j = 0;j < cnt[i];j++){
      ans = ans + p;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
from itertools import accumulate

n,k=map(int,input().split())
s=input()

i=0
if s[0]=='1':
    lst=[]
else:
    lst=[0]

while i<n:
    j=i
    cnt=0
    while j<n and s[i]==s[j]:
        cnt+=1
        j+=1
    
    lst.append(cnt)
    i=j

if 2*k+1>=len(lst):
    print(n)
    exit(0)

csum=list(accumulate(lst))
cur=csum[2*k]
ans=cur
for i in range(2,len(lst),2):
    right=min(i+2*k,len(lst)-1)

    ans=max(ans,csum[right]-csum[i-1])

print(ans)


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

int main() {
    int c[3], cnt = 0;
    for (int i=0; i<3; i++)
        cin >> c[i];
    sort(c, c+3);
    for (int i=0; i<3; i++) {
        if (c[i] != c[i+1])
            cnt++;
    }
    cout << cnt;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc163/tasks/abc163_e>
 問題文============================================================
 E - Active Infants
 =================================================================
 解説=============================================================
 
 
 https://atcoder.jp/contests/abc163/submissions/12219843
 
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll N; cin >> N;
    vector<ll> A(N); for(auto & in:A) cin >> in;
    
    vector<pll> B(N);
    for(int i = 0; i < N;i++){
        B[i] = pll(A[i],i);
    }
    sort(B.rbegin(),B.rend());
    
    auto dp = make_v<ll>(N+1,N+1);
    for(int i = 0; i < N;i++){
        ll a,n; tie(a,n) = B[i];
        for(int j = 0; j <= i;j++){
            dp[i+1][j+1] = max(dp[i+1][j+1],dp[i][j] + (n-j) * a);
        
            dp[i+1][j] = max(dp[i+1][j],dp[i][j] + ((N-(i-j)-1)-n)*a);
        }
    }
    for(int i = 0; i <= N;i++) res = max(res,dp[N][i]);
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 34588
#include<iostream>

using namespace std;

const int N = 13;

void func(bool a[],char c);

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

	bool S[N], H[N], C[N], D[N];
	for (int i = 0; i < N; i++)
	{
		S[i] = false;
		H[i] = false;
		C[i] = false;
		D[i] = false;
	}

	char c;
	int num;
	for (int i = 0; i < n; i++)
	{
		cin >> c >> num;

		switch (c)
		{
		case 'S' :
			S[num-1] = true;
			break;
		case 'H':
			H[num-1] = true;
			break;
		case 'C' :
			C[num-1] = true;
			break;
		case 'D' :
			D[num-1] = true;
			break;
		default:
			break;
		}
	}

	func(S, 'S');
	func(H, 'H');
	func(C, 'C');
	func(D, 'D');

}

void func(bool a[],char c)
{
	for (int i = 0; i < N; i++)
	{
		if (a[i] == false)
			cout << c << " " << i+1 << endl;
	}
}

Measured memory_bytes: 3100
#include <iostream>

using namespace std;

int main(){
	
	int n = 0;
	int count = 0;
	
	cin >> n;
	
	int p[n];
	
	for(int i = 0; i < n; i++){
		cin >> p[i];
	}
	
	for(int i = 1; i < n - 1; i++){
		if(p[i - 1] < p[i]){
			if(p[i + 1] > p[i]){
				count++;
				continue;
			}
		}
		if(p[i - 1] > p[i]){
			if(p[i + 1] < p[i]){
				count++;
				continue;
			}
		}
	}
	
	cout << count << endl;
	
	return 0;
}

Measured memory_bytes: 256
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
struct Combination{
private:
    ll N;
    vector<ll> fac, facinv;

public:
    Combination(ll n){
        N = n;
        fac.push_back(1); fac.push_back(1);
        rep(i,2,N+1) fac.push_back(fac[i-1] * i % MOD);
        rep(i,0,N+1) facinv.push_back(power(fac[i], MOD-2));
    }
    ll power(ll x, ll n){
        if(n == 0) return 1LL;
        ll res = power(x * x % MOD, n/2);
        if(n % 2 == 1) res = res * x % MOD;
        return res;
    }
    ll nck(ll n, ll k){
        if(k == 0 || n == k) return 1LL;
        return fac[n] * facinv[k] % MOD * facinv[n-k] % MOD;
    }
    ll npk(ll n, ll k){
        if(k == 0 || n == k) return 1LL;
        return fac[n] * facinv[n-k] % MOD;
    }
    ll get(ll x){return fac[x];};
    ll getinv(ll x){return facinv[x];};
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,M,K;
    cin >> N >> M >> K;
    ll ans = 0;
    Combination cb(200010);
    rep(i,1,N){
        ll p = (N - i) * M % MOD * M % MOD * i % MOD;
        ll p2 = cb.nck(N*M-2, K-2);
        ans += p * p2 % MOD;
        ans %= MOD;
    }
    swap(N,M);
    rep(i,1,N){
        ll p = (N - i) * M % MOD * M % MOD * i % MOD;
        ll p2 = cb.nck(N*M-2, K-2);
        ans += p * p2 % MOD;
        ans %= MOD;
    }

    print(ans);
    

}

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

#define ll long long
#define mod 1000000007
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define mem(x,y) memset(x,y,sizeof(x))
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sz(x) (int)x.size()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.14159265358979323846
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define endl '\n'

int main()
{
    

    int n,k;
    cin>>n>>k;
    ll ans=0;
    ll a[k];
    ffor(i,0,k) cin>>a[i];
    ffor(i,1,k) ans=max(ans,a[i]-a[i-1]);
    ans=max(ans,a[0]+n-a[k-1]);
    cout<<n-ans;
    
    return 0;
}



Measured memory_bytes: 1792
N = int(input())
a = list(map(int, input().split()))
cnt_4=0
cnt_2=0

for i in range(N):
    if a[i]%2==0:
        if a[i]%4==0:
            cnt_4+=1
        else:
            cnt_2+=1
if (cnt_4+cnt_2//2)>=int(len(a)/2):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 62576