akhauriyash/Code-Regression huggingface dataset:
S = input()
N = len(S)

A = [0] * (N + 1)
left = 0

while left < N and S[left] == '<':
    A[left + 1] = A[left] + 1
    left += 1

while left < N:
    mid = left + 1
    while mid < N and S[mid] == '>':
        mid += 1

    right = mid
    while right < N and S[right] == '<':
        right += 1

    for l in range(left, mid)[:: -1]:
        A[l] = max(A[l], A[l + 1] + 1)
    for r in range(mid + 1, right + 1):
        A[r] = max(A[r], A[r - 1] + 1)
    left = right

ans = sum(A)
print(ans)

Measured memory_bytes: 23352
al=[chr(ord('a') + i) for i in range(26)]
s=input()
N=len(s)
K=int(input())

for i in range(N):
  if i<N-1:
    a=26-al.index(s[i])
    if K>=a and s[i]!="a":
      K -= a
      s=s[0:i]+al[(al.index(s[i])+a)%26]+s[i+1:]
  else:
    K %= 26
    p= (K+al.index(s[i]))% 26
    s=s[0:N-1]+al[p]
    K=0
    
print(s)

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

void solve(string s, string t){
    int m = s.size(), n = t.size();
    vector<vector<int>> dp(m+1, vector<int>(n+1, 0));
    
    // Filling the dp table
    for(int i = m-1 ; i >= 0 ; i--){
        for(int j = n-1 ; j >= 0 ; j--){
            if(s[i] == t[j]){
                dp[i][j] = 1 + dp[i+1][j+1];
            }
            else{
                dp[i][j] = max(dp[i+1][j], dp[i][j+1]);
            }
        }
    }
    
    // Printing the LCS
    vector<char> res(dp[0][0], NULL);
    int i = 0, j = 0, idx = 0;
    while(i < m && j < n){
        if(s[i] == t[j]){
            res[idx] = s[i];
            i++; j++; idx++;
        }
        else if(dp[i+1][j] > dp[i][j+1]){
            i++;
        }
        else{
            j++;
        }
    }
    
    for(int i = 0 ; i < dp[0][0] ; i++){
        cout << res[i];
    }
}

int main(){
    // INPUT
    string s, t;
    cin >> s;
    cin >> t;
    
    // OUTPUT
    solve(s, t);
}

Measured memory_bytes: 38544
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N, l, r;
    cin >> N;
    
    int ans = 0;
    for (int i=0; i<N ; i++) {
        cin >> l >> r;
        ans += r-l+1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=1000005,INF=1<<30;

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

int main(){
    
    ll A,B;cin>>A>>B;
    ll C=gcd(A,B),D=C;
    
    ll ans=1;
    
    for(ll i=2;i*i<=D;i++){
        bool did=false;
        while(C%i==0){
            did=true;
            C/=i;
        }
        if(did) ans++;
    }
    
    if(C!=1) ans++;
    
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <atcoder/all>
#define ll long long int
#define MOD 1000000007
#define P pair<ll,ll>
#define INF 1000000000000000000

//using namespace atcoder;
using namespace std;

int main(void){
  char c; cin >> c;

  if ('A' <= c && c <= 'Z')
    cout << "A" << endl;
  else
    cout << "a" << endl;

  return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
  int N;
  cin >> N;
  vector<int64_t> vec(N);
  rep(i, N) {
    cin >> vec.at(i); 
  }
  int64_t X = 0;
  rep(i, N - 1) {
    if(vec.at(i) >= vec.at(i + 1)) {
      X += vec.at(i) - vec.at(i + 1);
      vec.at(i + 1) = vec.at(i);
    }
  }
  cout << X << endl;
}

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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
  os << p.first << " " << p.second;
  return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}
/*
   typedef __int128_t Int;
   std::ostream &operator<<(std::ostream &dest, __int128_t value) {
   std::ostream::sentry s(dest);
   if (s) {
   __uint128_t tmp = value < 0 ? -value : value;
   char buffer[128];
   char *d = std::end(buffer);
   do {
   --d;
 *d = "0123456789"[tmp % 10];
 tmp /= 10;
 } while (tmp != 0);
 if (value < 0) {
 --d;
 *d = '-';
 }
 int len = std::end(buffer) - d;
 if (dest.rdbuf()->sputn(d, len) != len) {
 dest.setstate(std::ios_base::badbit);
 }
 }
 return dest;
 }

 __int128 parse(string &s) {
 __int128 ret = 0;
 for (int i = 0; i < s.length(); i++)
 if ('0' <= s[i] && s[i] <= '9')
 ret = 10 * ret + s[i] - '0';
 return ret;
 }
 */

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main(signed argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int N, T; cin >> N >> T;
  int ans=INF;
  rep(i,0,N){
    int c, t; cin >> c >> t;
    if(t<=T){
      chmin(ans,c);
    }
  }
  if(ans==INF){
    cout<<"TLE"<<endl;
  }
  else{cout<<ans<<endl;}

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    string s,t;
    string x;
    cin>>s>>t;
    x=s;
    int value=-1;
    for(int i=0;i<s.size()-t.size()+1;i++){
        bool flag = true;
        for(int j=0;j<t.size();j++){
            if(s[i+j]==t[j]||s[i+j]=='?'){continue;}
            else{flag = false;break;}
        }
        if(flag){
            value = i;
        }
    }
    if(value==-1){
            cout<<"UNRESTORABLE"<<endl;
    }else{
        for(int j=0;j<t.size();j++){
                    x[value+j] = t[j];
            }
            for(int m=0;m<x.size();m++){
                if(x[m]=='?'){
                    x[m] = 'a';
                }
            }
        cout << x << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define llt long long int
using namespace std;
const int mod = 1e9 + 7;
llt power(llt a, llt b)
{
	llt res = 1;
	a = a%mod;
	if(a==0)
	{
		return 0;
	}
	while(b > 0)
	{
		if(b&1)
		{
			res = (res * a)%mod;
		}
		b = b >> 1;
		a = (a * a)%mod;
	}
	return res;
}
int main()
{
  	llt a;
  	scanf("%lld",&a);
  	llt ans = power(10, a);
  	ans-= 2ll * power(9, a);
  	ans+= 1ll* power(8,a);
  	ans%=mod;
  	if(ans < 0)
  	{
  		ans+=mod;
  	}
  	printf("%lld",ans);
}


Measured memory_bytes: 3780
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <iomanip>
#include <string>

using namespace std;

int main() {
    int n,ans=0;
    cin>>n;
    for(int i=1;i<n;++i){
      if(i!=(n-i) && (n-i)<n) ans++;
    }
    cout<<ans/2<<endl;

   return 0;
 }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define MAX 510000
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

//cout << fixed << setprecision(10);//
//最小公倍数//
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y%x, x);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

//べき//
ll squ(ll n, ll p, ll m){
	if(p==0) return 1;
	if(p%2==0){
		ll t=squ(n, p/2, m);
		return t*t%m;
	}
	return n*squ(n,p-1,m);
	
}


//逆元mod(mを法とするaの逆元)//
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
ll COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//nが大

ll com(ll n,ll m){
	if(n<=0 || m<=0 || n==m){
		return 1;
	}
	if(n<m){
		return 0;
	}
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}

	return k;
}


//


////////////////////////////////////////////////////////////////////




int main() {
ll d,n;
cin>>d>>n;
ll ans=0;
if(n!=100){
ans=pow(100,d)*n;
}
if(n==100){
	ans=pow(100,d)*101;
}

cout<<ans<<endl;
return 0;

}



Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>

int main(void) {
    char S[100];
    char T[100];
    char check[200];

    scanf("%s", S);
    scanf("%s", T);

    strcpy(check, S);
    strcat(check, S);

    if (strstr(check, T) != NULL) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ul unsigned long int
#define ld long double
#define f(t) for(ll i =0;i<t;i++)
#define vi vector<int>
#define vl vector<ll>
#define pri pair<int,int>
#define mpi map<int,int>
#define prl pair<ll,ll>
#define mp make_pair
#define mpl map<ll,ll>
#define umpl unordered_map<ll,ll>
#define pb push_back
#define ff first
#define ss second
#define MOD 1000000007
#define inf 2e18
#define EPS 1e-3
#define PI 3.1415926535897932385
#define display(v) f(v.size())cout << v[i]<<" "
const double h = 1e-6;
const int MAX_  = 100005;

inline ll mul(ll a, ll b){ return (a * 1ll * b) % MOD; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += MOD; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > MOD) c -= MOD; return c; }
 //////////////////////*********CODE***********/////////////////////
 //////////////////////////////////////////////////////////////////

int main()
 {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;  cin>>n;
    string str;   cin>>str;
    set<int> ocr[26];
    for(int i =0;i<n;i++)
    {
      ocr[str[i] -'a'].insert(i);
    }
    int q;
    cin>>q;
    while(q--)
    {
      int a;
       cin>>a;
       if(a == 1)
       {
          int b; cin>>b;  b--;
          char ch;   cin>>ch;
          int nw = ch - 'a';
          int wh = str[b] - 'a';
          ocr[wh].erase(ocr[wh].find(b));
          ocr[nw].insert(b);
          str[b] = ch;
        }
        else
        {
          int b,c;    cin>>b>>c; b--,c--;
          int ans  = 0;
          for(int i =0;i<26;i++)
          {
             auto it = ocr[i].lower_bound(b);
             if(it == ocr[i].end()){}
             else if((*it) <= c) ans++;
          }
          cout << ans << "\n";
        }
        
    }


    
    
    return 0;
 }

Measured memory_bytes: 24348
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
using namespace std;
int main()
{
	int a, b;
	cin >> a >> b;
	int ans = 0;
	if (a > b) {
		ans += a;
		a--;
	}
	else {
		ans += b;
		b--;
	}

	if (a > b) {
		ans += a;
		a--;
	}
	else {
		ans += b;
		b--;
	}
	cout << ans;
	return 0;
}

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

int main(){
  float a;
  float b;
  
  cin >> a >> b;

  for(int i = 0 ; i < 1250 ; i++)
  {
    if(floor(i*8/100) == a && floor(i*10/100) == b) {
      cout << i << endl;
      return 0;
    }
  }

  cout << "-1" << endl;
  return 0;
}

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

int main(){
  string S, T;
  cin >> S >> T;

  sort(S.begin(), S.end());
  sort(T.begin(), T.end(),greater<char>());
  
  cout << ((S<T) ? "Yes" : "No") << endl;


}
  
  

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

#define debug(x) cout<<#x<<"="<<x<<endl
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int) (x).size())
#define pii pair<int,int>
#define PQ priority_queue
#define sqr(x) (x)*(x)
#define ll long long
#define pb push_back
#define mp make_pair
#define re return

const int INF=0x7ffff;

int n,d[100003],x;
deque <int> q;

int main(){
	fill(d,d+100000,INF);
	cin>>n;
	q.pb(1);
	d[1]=1;
	while (q.size()){
		x=q.front();
		q.pop_front();
		if (d[x]<d[x*10%n]){
			d[x*10%n]=d[x];
			q.push_front(x*10%n);
		}
		if (d[x]+1<d[(x+1)%n]){
			d[(x+1)%n]=d[x]+1;
			q.pb((x+1)%n);
		}
	}
	cout<<d[0];
	return 0;
}

Measured memory_bytes: 896
function Main(input) {
    var P = parseInt(input[0], 10);
    var Q = parseInt(input[1], 10);
    var R = parseInt(input[2], 10);

    var sum = P + Q + R;

    var max = Math.max(P, Q, R);

    sum -= max;
    console.log(sum);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));

Measured memory_bytes: 21064
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

using namespace std;

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

    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    int m = a[a.size() - 1];
    double hm = (double)m / 2;
    int na = -1;
    double nd = m;
    for (auto t : a) {
        if (abs(t - hm) < nd) {
            na = t;
            nd = abs(t - hm);
        }
    }
    cout << m << " " << na << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define rrep(i,a) for(int i=(int)a-1;i>=0;--i)
#define REP(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RREP(i,a,b) for(int i=(int)a-1;i>=b;--i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;
typedef std::vector<long long> vl;
typedef std::vector<std::vector<long long>> vvl;
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}


ll gcd(ll n, ll m) {
    ll tmp;
    while (m!=0) {
        tmp = n % m;
        n = m;
        m = tmp;
    }
    return n;
}
 
ll lcm(ll n, ll m) {
    return abs(n) / gcd(n, m)*abs(m);//gl=xy
}

using namespace std;

ll x;

bool f(ll a,ll b){
  if(a*a*a*a*a-b*b*b*b*b==x){
    return true;
  }
  else
    return false;
}

void solve()
{
  cin >> x;
  for(ll i=-1000;i<=1000;++i){
    for(ll j=-1000;j<=1000;++j){
      if(f(i,j)){
        cout << i << " " << j;
        return;
      }
    }
  }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(15);
    solve();
    return 0;
}



Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

bool poor(int a, int b, int c)
{
    return a == b && b != c;
}

int main()
{
    long a, b, c;

    std::cin >> a >> b >> c;

    std::cout << (poor(a, b, c) || poor(b, c, a) || poor(c, a, b) ? "Yes" : "No") << std::endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <queue>
#include <cassert>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const int iINF = 1001001001;
const long long llINF = 1LL << 60;
const ll mod = 1000000007;
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号

    UnionFind(int N) : par(N) { // 最初は全てが根であるとして初期化
        for (int i = 0; i < N; ++i) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る
        if (par[x] == x) return x;
        return par[x] = root(par[x]); // 経路圧縮
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(int x, int y) { // 2つのデータx,yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};
int main()
{
    /*int d, t, s; cin >> d >> t >> s;
    if (d <= t * s) cout << "Yes" << endl;
    else cout << "No" << endl;
    */

    /*string s, t; cin >> s >> t;
    int mx = 0;
    rep(i, s.size()) {
        int tmp = 0;
        if (s.size() < i + t.size()) continue;
        rep(j, t.size()) {
            if (s[i + j] == t[j]) tmp++;
        }
        mx = max(mx, tmp);
    }
    cout << t.size() - mx << endl;
    */

    /*int n; cin >> n;
    vector<ll> a(n);
    vector<ll> sum(n + 1, 0);
    sum[0] = 0;
    rep(i, n) {
        cin >> a[i];
        sum[i + 1] = a[i] + sum[i];
        sum[i + 1] %= mod;
    }
    ll ans = 0;
    rep(i, n) {
        ll s = sum.back() - sum[i + 1];
        s %= mod;
        if (s < 0) s += mod;
        ans += a[i] * s;
        ans %= mod;
    }
    cout << ans << endl;
    */

    int n, m; cin >> n >> m;
    UnionFind tree(n);
    rep(i, m) {
        int x, y; cin >> x >> y;
        tree.unite(x - 1, y - 1);
    }
    int ans = 0;
    vector<int> cnt(n, 0);
    rep(i, n) {
        cnt[tree.root(i)]++;
    }
    rep(i, n) {
        ans = max(ans, cnt[i]);
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (ll i=(ll)from; i<(ll)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  ll N; cin >> N;
  ll result = N;
  repr(i,1,N) {
    ll A = i, B = N-i;
    ll sum = 0;
    while (A) { sum+=A%10; A/=10; }
    while (B) { sum+=B%10; B/=10; }
    result = min(result, sum);
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3612
N = gets.to_i
as = N.times.map{gets.to_i}

ans = 0
N.times do |i|
    ans += as[i] / 2
    as[i] %= 2
    if i < N-1 && as[i] > 0 && as[i+1] > 0
        ans += 1
        as[i+1] -= 1
    end
end

puts ans

Measured memory_bytes: 4732
import java.util.Arrays;
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();

		int[] A=new int[N];
		int[] B=new int[N];
		int[] C=new int[N];

		for(int i=0; i<N; i++) {
			A[i]=sc.nextInt();
		}

		for(int i=0; i<N; i++) {
			B[i]=sc.nextInt();
		}

		for(int i=0; i<N; i++) {
			C[i]=sc.nextInt();
		}
		Arrays.sort(A);
		Arrays.sort(B);
		Arrays.sort(C);
		long kotae=0;
		long[] sita=new long[N];

		for(int i=0; i<N; i++) {
			sita[i]=upperBound(C,B[i]);
			if(sita[i]!=-1) {
				sita[i]=N-sita[i];
			}
			else if(sita[i]==-1) {
				sita[i]=0;
			}
		}
		for(int i=N-1; i>0; i--) {
			sita[i-1]=sita[i-1]+sita[i];
			//System.out.println(sita[i-1]);
		}
		for(int i=0; i<N; i++) {
			int ub=upperBound(B,A[i]);
			if(ub!=-1) {
				kotae+=sita[ub];
			}
			else if(ub==-1) {
				//
			}
		}
		System.out.println(kotae);
	}
	public static final int upperBound(final int[] arr, final int value) {
		int low = 0;
		int high = arr.length;
		int mid;
		while (low < high) {
			mid = ((high - low) >>> 1) + low;    //(low + high) / 2 (オーバーフロー対策)
			if (arr[mid] <= value) {
				low = mid + 1;
			} else {
				high = mid;
			}
		}
		if(low<arr.length) {
			return low;
		}
		else {
			return -1;
		}
	}
}

Measured memory_bytes: 93336
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	const initialBufSize = 4096
	const maxBufSize = 1000000
	scanner.Buffer(make([]byte, initialBufSize), maxBufSize)
	scanner.Split(bufio.ScanWords)
	var K int64
	scanner.Scan()
	K, _ = strconv.ParseInt(scanner.Text(), 10, 64)
	var A int64
	scanner.Scan()
	A, _ = strconv.ParseInt(scanner.Text(), 10, 64)
	var B int64
	scanner.Scan()
	B, _ = strconv.ParseInt(scanner.Text(), 10, 64)
	fmt.Println(solve(K, A, B))
}
func solve(K int64, A int64, B int64) string {
	for i := A; i <= B; i++ {
		if i%K == 0 {
			return "OK"
		}
	}
	return "NG"
}


Measured memory_bytes: 1752
import itertools
n = int(input())
p,f = [],[]

for i in range(n):
    f.append(list(map(int,input().split())))
for i in range(n):
    p.append(list(map(int,input().split())))

a = [0,1]
ans = -10**15
for v in itertools.product(a,repeat = 10):
    if sum(v) != 0:
        s = []
        for a in range(n):
            k = 0
            for b in range(10):
                if f[a][b] == v[b] and v[b] == 1:
                    k += 1
            s.append(k)

        x = 0
        for a in range(n):
            x += p[a][s[a]]
        if x > ans:
            #print(v,s,x)
            ans = x

print(ans)

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

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n; cin >> n;
    int sum, mx;
    sum = mx = 0;
    while(n--){
        int aux; cin >> aux;
        mx = max(aux, mx);
        sum += aux;
    }
    cout << sum - (mx / 2) << "\n";
    return 0;        
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
// https://atcoder.jp/contests/abc081/tasks/abc081_b

int solver(int allNumber,vector<int> numbers){
    int solverAns=0;
    bool evenFlag=true;
    while(true){
        for(int j=0;j<allNumber;j++){
            int mods;
            mods = numbers.at(j)%2;
            if(mods !=0)evenFlag=false;
        }
        if(evenFlag==true){
            // すべて2で割る
            for(int j=0;j<allNumber;j++){
                numbers.at(j) = numbers.at(j) / 2;    
            }
            solverAns = solverAns+1;
        }
        else{
            break;// そのまま終了
        }
    }
    return solverAns;
}
int main(void){
    int N;
    cin >> N ;
    vector<int> A(N+10,0);
    for(int j=0;j<N;j++){
        cin >> A.at(j);
    }
    int answer = solver(N,A);
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

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

int main(void) {
    int H1, M1, H2, M2, K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;

    int a = H1 * 60 + M1;
    int b = H2 * 60 + M2;
    cout << b - K - a << endl;
}


Measured memory_bytes: 3676
/*
author: Apoorv Singh
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds;

typedef vector <int> vi;
typedef vector <long long> vl;
typedef pair <int, int> pii;
typedef pair <long long, long long> pll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

#define ll long long
#define pb push_back   
#define all(c) c.begin(), c.end()
#define watch(x) cout << (#x) << " " << (x) << endl;
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = a; i > b; --i)
#define um unordered_map
#define F first
#define S second

ll modulo = 1e9 + 7;

template <class X>

void printarr(X arr[], int n)
{
    for (int i = 0; i < n; ++i)
        cout << arr[i] << " ";
    cout << endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int arr[3];
    FOR(i,0,3)
        cin >> arr[i];
    sort(arr, arr+3);
    cout << arr[2]*10 + arr[1] + arr[0] << endl;

    return 0;
}

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

using namespace std;
#define ll long long
#define mp make_opair
#define pb push_back
pair<ll,ll> dp[20001][2];
int main(){

int i,j,k;
int n,z,w;
cin>>n>>z>>w;
ll a[n];
for(i=n;i>=1;i--)
    cin>>a[i];
    if(n==1){

        cout<<abs(a[1]-w)<<endl;
        return 0;

    }
    dp[1][0].first=0;
    dp[1][0].second=a[1];
    dp[1][1].first=1e18;
    dp[1][1].second=a[1];
    for(i=2;i<=n;i++)
    {

        dp[i][0].first=0;
        dp[i][1].first=1e18;
    }

for(i=0;i<2;i++)
{

    for(j=2;j<=n;j++)
    {

        for(k=1;k<=j;k++){

           if(i==0)
           {
               if(j!=k){
                    if((j-k)==1){
                             dp[j][0].first=abs(a[j-k+1]-a[1]);

                    }
                    else{
             dp[j][0].first=max(dp[j][0].first,dp[j-k][1].first);

                dp[j][0].first=max(dp[j][0].first,abs(a[j-k+1]-dp[j-k][1].second));}

               }
               else
               {

                   dp[j][0].second=a[1];

               }

           }
           else{


            if(j!=k){
                    if((j-k)==1){
                         dp[j][1].first=abs(a[j-k+1]-a[1]);
                    }
                    else{
             dp[j][1].first=min(dp[j][1].first,dp[j-k][0].first);

                dp[j][1].first=min(dp[j][1].first,abs(a[j-k+1]-dp[j-k][0].second));

               }}
               else
               {

                   dp[j][0].second=a[1];

               }







           }





        }



    }






}
ll ans=max(dp[n][0].first,abs(w-a[1]));

cout<<ans<<endl;


return 0;}


Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll n,k;
ll a[100010][3];
ll dp[100010][3];
int main(){
	scanf("%lld",&n);
	rep(i,0,n)scanf("%lld%lld%lld",&a[i][0],&a[i][1],&a[i][2]);
	rep(i,0,n)rep(j,0,3){
		rep(k,0,3)if(j!=k)dp[i+1][k]=max(dp[i+1][k],dp[i][j]+a[i][k]);
	}
	printf("%lld\n",max(dp[n][0],max(dp[n][1],dp[n][2])));
	return 0;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define bit(k) (1LL<<(k))
typedef long long ll;

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

const int INF = 1e9;
const ll INFLL = 1e18;
const ll MOD = 1e9+7;
const double PI = acos(-1.0);

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

/*------------------------------------/
for library*/

/*------------------------------------*/

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

    int A[3] = {0,0,0};
    int a,b;
    cin>>a>>b;
    a--;b--;
    A[a] = A[b] = 1;
    rep(i,3){
        if(A[i] == 0)cout<<i + 1<<endl;
    }
}

Measured memory_bytes: 256
N, K, Q = map(int, input().split())
point = [K - Q for i in range(N)]
A = [int(input()) for j in range(Q)]

for num in A:
    point[num-1] += 1

for num in point:
    if num > 0:
        print('Yes')
        continue
    print('No')
    

Measured memory_bytes: 11796
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

int main(void){
  int n;
  scanf("%d",&n);
  char s[n][11],list[n][11];
  for(int i=0;i<n;i++){
    scanf("%s",s[i]);
      qsort(s[i],10,sizeof(char),strcmp);
  // printf("%s\n",s[i]);
    }
	qsort(s,n,sizeof(s[0]),strcmp);
  
  
  
  long long count=1,sum=0;
 for(int i=0;i<n-1;i++){
if(strcmp(s[i],s[i+1])==0){
//  printf("%s %sが等しい\n",s[i],s[i+1]);
count++;
}
   else {
sum+=count*(count-1)/2;
  //   printf("count=%lld sum=%lld\n",count,sum);
     count=1;
   }
 }
  sum+=count*(count-1)/2;
   printf("%lld\n",sum);
           return 0;
           }
 

Measured memory_bytes: 2300
using System;

class Atcoder49
{
    public static void Main()
    {
        string[] input = Console.ReadLine().Split(' ');
        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);
        int c = int.Parse(input[2]);

        int difab = b - a;
        int difbc = c - b;

        if (difab == difbc)
            Console.WriteLine("YES");
        else
            Console.WriteLine("NO");
    }
}

Measured memory_bytes: 13140
// ABC078_B
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <tuple>  // std::tuple std::get
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define REPN(i, n) for (ll i=1; i <= n; i++)  // 1 ~ n
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0LL)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
#define zero_pad(num) setfill('0') << std::right << setw(num)
#define space_pad(num) setfill(' ') << std::right << setw(num)

typedef long long ll;

const ll MOD7 = 1000000007;  // 1 000 000 007
const ll MOD9 = 1000000009;  // 1 000 000 009

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

    // input
    ll X, Y, Z;
    cin >> X >> Y >> Z;
    
    // calculation
    cout << (X-Z)/(Y+Z) << "\n";
    
    return 0;
}


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

using namespace std;

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    long long a,b,k;
    cin>>a>>b>>k;
    if(a>=k)
    {
        a=a-k;
    }
    else
    {
        k=k-a;
        a=0;
        if(b>=k)
        {
            b=b-k;
        }
        else
        {
            b=0;
        }
    }
    cout<<a<<" "<<b<<endl;
    return 0;
}


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


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

    vector<int> x(n);
    int l = 100, r = 1;
    for (int i = 0; i < n; i++)
    {
        cin >> x[i];

        if (x[i] < l)
        {
            l = x[i];
        }
        
        if (x[i] > r)
        {
            r = x[i];
        }
    }
    
    int min_cost = INT_MAX;
    for (int p = l; p <= r; p++)
    {
        int cost = 0;
        for (int j = 0; j < n; j++)
        {
            const int dist = x[j] - p;
            cost += dist * dist;
        }
        
        if (cost < min_cost)
        {
            min_cost = cost;
        }
    }
    
    cout << min_cost << endl;
}


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

ll x[100000], y[100000], tx[100000], ty[100000], sum1[100001], sum2[100001];
#define dist(x,y)(abs(i-x)+abs(j-y))
int main() {
	ll w, h, n; scanf("%lld%lld%lld", &w, &h, &n);
	rep(i, n) {
		scanf("%lld%lld", &x[i], &y[i]);
		tx[i] = x[i]; ty[i] = y[i];
	}
	sort(x, x + n); sort(y, y + n);
	rep(i, n) {
		sum1[i + 1] = sum1[i] + x[i];
		sum2[i + 1] = sum2[i] + y[i];
	}
	unordered_set<ll>ax, ay;
	ll mx = LLONG_MAX, my = LLONG_MAX;
	rep(i, n) {
		ll a = ((x[i] * i - sum1[i]) + (sum1[n] - sum1[i] - x[i] * (n - i))) * 2;
		if (mx > a)mx = a, ax.clear();
		if (mx == a)ax.insert(x[i]);
		a = ((y[i] * i - sum2[i]) + (sum2[n] - sum2[i] - y[i] * (n - i))) * 2;
		if (my > a)my = a, ay.clear();
		if (my == a)ay.insert(y[i]);
	}
	ll ansx, ansy, ans = LLONG_MAX;
	for (ll i : ax)for (ll j : ay)rep(k, n) {
		ll d = mx + my - dist(tx[k], ty[k]);
		if (ans > d) {
			ans = d;
			ansx = i; ansy = j;
		}
		else if (ans == d) {
			if (ansx > i)ansx = i, ansy = j;
			else if (ansx == i&&ansy > j)ansx = i, ansy = j;
		}
	}
	printf("%lld\n%lld %lld\n", ans, ansx, ansy);
}

Measured memory_bytes: 7944
#include <bits/stdc++.h> 
#define int long long
#define deb(x) cout<<#x <<" = "<<x<<"\n";
using namespace std; 
signed main() 
{
	//freopen("input.txt", "r", stdin);
	
	string s; cin >> s;
	if( s == "AAA" || s == "BBB") cout << "No\n";
	else cout << "Yes\n";
	
	
	
	
	
}

Measured memory_bytes: 764
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>

using namespace std;

const int MAXN = 200000 + 10000;
const int INF = 0x1f1f1f1f;

int n;
long long ans = 0;
int mn = INF, mx = -INF;
pair<int, int> s[MAXN];

void calc1()
{
	int rmx = -INF, bmn = INF;
	for(int i = 1; i <= n; i++)
		rmx = max(rmx, s[i].first), bmn = min(bmn, s[i].second);
	ans = (long long)(rmx - mn) * (mx - bmn);
}

void calc2()
{
	static int smn[MAXN], smx[MAXN];
	smn[0] = INF, smx[0] = -INF;
	for(int i = 1; i <= n; i++)
		smn[i] = min(smn[i - 1], s[i].second), smx[i] = max(smx[i - 1], s[i].second);
	for(int i = 2; i <= n; i++)
		ans = min(ans, (long long)(mx - mn) * (max(s[n].first, smx[i - 1]) - min(s[i].first, smn[i - 1])));
}

void solve()
{
	for(int i = 1; i <= n; i++)
		if(s[i].first > s[i].second)
			swap(s[i].first, s[i].second);
	sort(s + 1, s + n + 1);
	mn = s[1].first;
	for(int i = 1; i <= n; i++)
		mx = max(mx, s[i].second);
	calc1();
	calc2();
}

int main()
{
	ios::sync_with_stdio(false);
	// freopen("1.in", "r", stdin);
	// freopen("1.out", "w", stdout);

	cin >> n;
	for(int i = 1; i <= n; i++)
		cin >> s[i].first >> s[i].second;

	solve();

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3456
#include<iostream>
using namespace std;
int main()
{
    int n,t,x,y;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>t>>x>>y;
        if(x+y>t)
        {
            cout<<"No\n";
            return 0;
        }
        if( (x+y)%2==0&&t%2==1 )
        {
            cout<<"No\n";
            return 0;
        }
        if( (x+y)%2==1&&t%2==0 )
        {
            cout<<" No\n";
            return 0;
        }
    }
    cout<<" Yes\n";
    return 0;
}

Measured memory_bytes: 768
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int x = sc.nextInt();
		sc.close();

		double d = 0;
		if (a * a * b / 2.0 >= x) {
			d = Math.atan(a * b * b / 2.0 / x) * 360.0 / (2.0 * Math.PI);
		} else {
			d = Math.atan(2.0 * (a * a * b - x) / a / a / a) * 360.0 / (2.0 * Math.PI);
		}
		System.out.println(d);
	}
}


Measured memory_bytes: 23124
//#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
//#include<queue>
//#include<time.h>
//#include<complex>
#include<algorithm>
#include<stdlib.h>
using namespace std;

int n;
#define maxn 1011
#define LL long long
int a[maxn],list[maxn],len=0,ans[maxn],lans=0;
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	LL ans1=0,ans2=0; bool flag1=0,flag2=0;
	for (int i=1;i<=n;i+=2) if (a[i]>0) ans1+=a[i],flag1=1;
	if (!flag1) {ans1=-1e18; for (int i=1;i<=n;i+=2) ans1=max(ans1,(LL)a[i]);}
	for (int i=2;i<=n;i+=2) if (a[i]>0) ans2+=a[i],flag2=1;
	if (!flag2) {ans2=-1e18; for (int i=2;i<=n;i+=2) ans2=max(ans2,(LL)a[i]);}
	if (ans1>ans2)
	{
		printf("%lld\n",ans1);
		if (flag1) {for (int i=1;i<=n;i+=2) if (a[i]>0) list[++len]=i;}
		else {for (int i=1;i<=n;i+=2) if (a[i]==ans1) {list[++len]=i; break;}}
	}
	else
	{
		printf("%lld\n",ans2);
		if (flag2) {for (int i=2;i<=n;i+=2) if (a[i]>0) list[++len]=i;}
		else {for (int i=2;i<=n;i+=2) if (a[i]==ans2) {list[++len]=i; break;}}
	}
	for (int i=1;i<list[1];i++) ans[++lans]=1;
	for (int i=1;i<len;i++)
	{
		for (int j=1,to=(list[i+1]-list[i])/2;j<to;j++) ans[++lans]=3;
		ans[++lans]=2;
	}
	for (int i=n-list[len];i;i--) ans[++lans]=1+i;
	printf("%d\n",lans);
	for (int i=1;i<=lans;i++) printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

int n;
vector<ll> dp;
bool match[30][30];

void solve(){
    cin >> n;
    dp.resize(pow(2,n),0);
    rep(i,n){
        rep(j,n){
            cin >> match[i][j];
        }
    }
    dp[0]=1;
    Rep(s,1,pow(2,n)){
        dp[s]=0;
        int num=0;
        rep(i,n) if (s&(1<<i)) num+=1;
        rep(i,n){
            if (s&(1<<i)) {
                dp[s]+=dp[s^(1<<i)]*match[num-1][i];
                dp[s]%=mod;
            }
        }

        //cout << s << " " << dp[s] << endl;
    }

    cout << dp[pow(2,n)-1] << endl;

}

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

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

using namespace std;

int main(){
  int K;
  string S;
  cin>> K>>S;
  if (S.size()<=K){
    cout<<S<<endl;
  }
    else{
	std::string substr = S.substr(0,K);
	 std::cout << substr <<"..."<<std::endl;
    }
  
  
}

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

using namespace std;

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

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

  for (int i = a; i <= b; ++i) {
    if (i < a+k || i > b-k) 
      cout << i << endl;
  }

  return 0;
}



Measured memory_bytes: 256
use std::io::*;

fn gcd(x: u32, y: u32) -> u32 {
  let (x, y) = (y, x % y);
  if y == 0 { x }
  else { gcd(x, y) }
}

fn main() {
  let (x, y) = {
    let stdin = stdin();
    let line = stdin.lock().lines().next().unwrap().unwrap();

    let mut iter = line.split_whitespace().map(|s| s.parse::<u32>().unwrap());

    (iter.next().unwrap(), iter.next().unwrap())
  };

  let (x, y) = if x < y { (y, x) } else { (x, y) };

  let ans = gcd(x, y);
  println!("{}", ans);
}


Measured memory_bytes: 5024
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 1; i <= (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#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)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2147483647 //int値の最大値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int two(int n){
	ll ans=1;
	rep(i,n){
		ans*=2;
	}
	return ans;
}
int waru(int n){
    int sum=0;
    while(n>0){
        sum+=n%10;
        n=n/10;
        //sum++;
    }
    return sum;
}
   


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

    int n;
    vector<int>a(101);
    cin>>n;
    rep(i,n)cin>>a.at(i);

    sort(ALL(a));
    reverse(ALL(a));
    int sum=0;
    int cnt=0;

    for(int i=0;i<n;i+=2){
        sum+=a.at(i);
    }
    for(int i=1;i<n;i+=2){
        cnt+=a.at(i);
    }
    cout<<sum-cnt<<endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define reptr(i,n) for(int (i)=(n);(i)>=0;--(i))
#define All(x) (x).begin(),(x).end()
const ll MOD=1e9+7;
const int nmax=8;
using namespace std;
bool graph[nmax+1][nmax+1];

int dfs(int v,int n,bool visited[]){
  //visitedが全てtrueの場合、探索完了
  bool all_visited=true;
  for(int i=1;i<=n;i++){
    if(visited[i]==false){
      all_visited=false;
      break;
    }
  }
  if(all_visited){
    return 1;
  }
  //点vからの総訪問回数sum
  int sum=0;
  for(int i=1;i<=n;i++){
    //直接つながっていないとき
    if(graph[v][i]==false) continue;
    //既に訪れているとき
    if(visited[i]) continue;
    //直接つながっていて、かつまだ訪れていない点のとき
    //点iからNまでの探索回数を足す
    visited[i]=true;
    sum+=dfs(i,n,visited);
    visited[i]=false;
  }
  return sum;
}
int main(){
  int N,M;
  cin >> N >> M;
  bool visited[nmax+1];
  rep(i,M){
    int a,b;
    cin >> a >> b;
    graph[a][b]=graph[b][a]=true;
  }
  for(int i=1;i<=N;i++){
    visited[i]=false;
  }
  //1は既に訪れている
  visited[1]=true;
  cout << dfs(1,N,visited) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector> 
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
using namespace std;

int main(){
    int A,B,C,D;
    cin>>A>>B>>C>>D;
    int t=0;
    int a=0;
    while(A>0){
        A=A-D;
        t++;
    }
    while(C>0){
        C=C-B;
        a++;
    }
    if(t>=a){
        cout<<"Yes";
    }else{
        cout<<"No";
    }

}

Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<queue>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;

map<ll,ll> nc;

int main() {
  ll N;
  cin >> N;
  int A[N];
  rep(i,N) {
    cin >> A[i];
    nc[A[i]] += 1;
  }

  ll all = 0;
  for(auto c : nc) {
    if (c.second < 2) continue;
    all += c.second*(c.second-1)/2;
  }
  rep(i,N) cout << all-(nc[A[i]]-1) << endl;
  return 0;
}



Measured memory_bytes: 12160
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

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


void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	/*#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif*/
}

int32_t main()
{
	c_p_c();
	int h, n; cin >> h >> n;
	int sm = 0;

	for (int i = 0; i < n; ++i)
	{
		int x; cin >> x;
		sm += x;
	}

	if (sm >= h)
		cout << "Yes\n";
	else
		cout << "No\n";
	return 0;
}

Measured memory_bytes: 256
s = input()
res_s0 = 0
res_s1 = 0

#print("s0")
for i in range(len(s)):
    #print(i, end="")
    if i % 2 == 0:
        if s[i] != "0":
            res_s0 += 1
            #rint("!")
    else:
        if s[i] != "1":
            res_s0 += 1
            #print("!")

#print()
#print("s1")

for i in range(len(s)):
    #print(i, end="")
    if i % 2 == 0:
        if s[i] != "1":
            res_s1 += 1
            #print("!")
    else:
        if s[i] != "0":
            res_s1 += 1
            #print("!")

#print("---")
#print(res_s0)
#print(res_s1)
print(min(res_s0, res_s1))

Measured memory_bytes: 3188