akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define PI (acos(-1))
#define swap(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define rep(i, N) for (int i = 0; i < (N); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
using ll = long long;
long long gcd(long long a, long long b) { return b ? gcd(b,a%b) : a;}
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }





vector<double> simequ(vector<vector<double>> a){
    int N=a.size();
    // 前進消去
    for (int k = 0; k < N -1; k++) {
        for (int i = k + 1; i < N; i++) {
            double d = a[i][k] / a[k][k];
            for (int j = k + 1; j <= N; j++)
                a[i][j] -= a[k][j] * d;
        }
    }

    // 後退代入
    for (int i = N - 1; i >= 0; i--) {
        double d = a[i][N];
        for (int j = i + 1; j < N; j++)
            d -= a[i][j] * a[j][N];
        a[i][N] = d / a[i][i];
    }

    // 結果出力
    vector<double> result;
    for (int k = 0; k < N; k++)
        result.push_back(a[k][N]);

    return result;
}




int main()
{
    ll n;
    cin >> n;
    if(n==999999999){cout << 26484 << endl;return 0;}
    if(n >777777753)n=777777753;
    ll c=0;
    for(ll i=357;i<=n;i+=2){
        ll a=i;
        bool is3=false,is5=false,is7=false;
        while(a){
            int b=a%10;
            if(b==3)is3=true;
            else if(b==5)is5=true;
            else if(b==7)is7=true;
            else {is3=false;break;}
            a/=10;
        }
        if(is3&&is5&&is7)c++;
    }



    cout << c << endl;


    return 0;
    
}






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

using namespace std;
int main() {
	int N, K;
	cin >> N >> K;
	double ans = 0;
	for (int n = 1;n<=N;++n) {
		int tmpn = n;
		int count = 0;
		while (tmpn <K) {
			tmpn *= 2;
			++count;
		}
		int memo = 1;
		for (int n=0;n<count;++n) {
			memo *= 2;
		}
		ans += 1.0 / N / memo;
	}
	printf("%.10f\n", ans);
}


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

#define INF INT_MAX
#define N 100
#define W 100005

using namespace std;

int n, w;
int weight[N];
int value[N];
long long dp[N][W];
long long solve(int idx, int w){
    if(idx == n)
        return 0;
    if(~dp[idx][w])
        return dp[idx][w];
    if(weight[idx] <= w)
        dp[idx][w] = 0ll + value[idx]+solve(idx+1, w-weight[idx]);
    dp[idx][w] = max(dp[idx][w], solve(idx+1, w));
    return dp[idx][w];
}
int main()
{
    cin >> n >> w;
    for(int i=0; i<n; ++i)
        cin >> weight[i] >> value[i];
    memset(dp, -1, sizeof(dp[0][0]) * N * W);
    cout << solve(0, w);
    return 0;
}


Measured memory_bytes: 78336
package main

import (
	"fmt"
)

func main() {
	var n int

	fmt.Scan(&n)

	x := make([]int, n)
	sum, lenx := 0, len(x)
	for i := 0; i < lenx; i++ {
		fmt.Scan(&x[i])
		sum += x[i]
	}

	p := int((float64(sum)/(float64)(lenx) + 0.5))
	hp := 0
	for i := 0; i < lenx; i++ {
		hp += (x[i] - p) * (x[i] - p)
	}

	fmt.Println(hp)
}


Measured memory_bytes: 512
#include <algorithm>
#include <functional>
#include <iostream>
#include <vector>

using namespace std;

template <typename T>
class BIT {
  vector<T> tree_;

 public:
  BIT(int n) : tree_(n, 0) {}
  void Add(int i, T x) {
    for (i++; i <= tree_.size(); i += i & -i) {
      tree_[i - 1] += x;
    }
  }

  T Sum(int s) {
    T ans = 0;
    for (s++; s > 0; s -= s & -s) {
      ans += tree_[s - 1];
    }

    return ans;
  }

  T Sum(int l, int r) { return Sum(r) - Sum(l - 1); }
};

int main(int argc, const char *argv[]) {
  using ll = long long;
  int n;
  cin >> n;
  vector<vector<int>> vs(n);
  for (int i = 0; i < n; i++) {
    int c;
    cin >> c;
    vs[c - 1].push_back(i);
  }

  vector<vector<int>> tree(n);
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    tree[a].push_back(b);
    tree[b].push_back(a);
  }

  int k = 0;
  vector<int> in(n), out(n);
  function<void(int, int)> dfs;
  dfs = [&](int v, int p) {
    in[v] = k++;
    for (int u : tree[v]) {
      if (u != p) {
        dfs(u, v);
      }
    }

    out[v] = k - 1;
  };

  dfs(0, -1);

  auto c2 = [](ll n) -> ll { return n * (n + 1) / 2; };
  ll tot = c2(n);
  BIT<ll> d(n);
  for (int i = 0; i < n; i++) {
    d.Add(i, 1);
  }

  for (int i = 0; i < n; i++) {
    ll ans = tot;
    vector<int> &nvs = vs[i];
    sort(nvs.begin(), nvs.end(), [&](int a, int b) { return in[a] > in[b]; });
    vector<pair<int, int>> history;
    for (int v : nvs) {
      int cnt = 1;
      for (int u : tree[v]) {
        if (in[u] > in[v]) {
          int num = d.Sum(in[u], out[u]);
          ans -= c2(num);
          cnt += num;
        }
      }

      d.Add(in[v], -cnt);
      history.emplace_back(in[v], cnt);
    }

    ans -= c2(d.Sum(n - 1));
    for (auto p : history) {
      d.Add(p.first, p.second);
    }

    cout << ans << '\n';
  }

  return 0;
}

Measured memory_bytes: 41032
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
typedef long long int ll;
using namespace std;
#define maxn 0x3f3f3f3f
#define mod 1000000007


int main()
{
    ll n,k;
    scanf("%lld%lld",&n,&k);
    n%=k;
    printf("%lld\n",min(n,abs(n-k)));
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define so sizeof
#define pb push_back
#define vl vector<ll>
#define el endl;cout.flush()
#define be begin()
#define fi first
#define se second
#define br break
#define sz size()
#define en end()
#define ro return 0
#define br break
#define con continue;
#define all(x) (x).be , (x).en
#define rall(x) (x).rbegin() , (x).rend()
#define acc(x) accumulate((x).be , (x).en , 0)
#define forn(i,a,b) for(ll i=a;i<=b;++i)
#define forr(i,a,b) for(ll i=a;i<b;++i)
#define rng_58 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define plvl pair<pair<ll,ll> ,ll>
#define mp make_pair
long long f(long long a) {
     long long res[] = {a,1,a+1,0};
     return res[a%4];
}
int main()
{
    ios;
    ll a , b;
    cin >> a >> b;
    if(a==0){
        ll foo = f(b);
        cout << foo ;
        cout << el ;
        ro ;
    }
    ll foo = f(b) ^ f(a-1);
    cout << foo << el ;
}






Measured memory_bytes: 256
/* package whatever; // don't place package name! */
 
import java.util.*;
import java.lang.*;
import java.io.*;
 
/* Name of the class has to be "Main" only if the class is public. */
class Main{
    public static void main(String[] a){
      for(int i=1;i<=9;i++){
        for(int x=1;x<=9;x++){
 
        System.out.println(i+"x"+x+"="+i*x);
      }
 
      }
 
 
    }
}

Measured memory_bytes: 24376
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

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


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;cin>>s;
    ll n = s.size();
    map<char,ll> mp;
    REP(i,n){
        mp[s[i]]++;
    }
    ll ans = n * (n-1) / 2LL;
    for(auto c:mp){
        ans -= c.second * (c.second - 1) / 2LL;
    }
    cout<<ans+1<<endl;
}


Measured memory_bytes: 720
#include <stdio.h>

int main(void) {
  int i, k, t, max = 0, a;
  scanf("%d%d", &k, &t);
  for(i = 0; i < t; ++i) {
    scanf("%d", &a);
    if(a > max) max = a;
  }
  printf("%d", 2 * max - k - 1 > 0 ? 2 * max - k - 1 : 0);
  return 0;
}

Measured memory_bytes: 128
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n;
  cin >> n;
  int mx = 0, mn = 1000000000;
  rep(i, n){
    int a;
    cin >> a;
    mx = max(mx, a);
    mn = min(mn, a);
  }
  int ans = mx - mn;
  cout << ans << endl;
}

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

const int mod = 1000000007;
class mint {
    long long x;
public:
    mint(long long x=0) : x((x%mod+mod)%mod) {}
    mint operator-() const { 
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }
    mint choose(int n, int a){
        mint x = 1 ,y = 1;
        for(int i = 0; i < a; ++i){
            x *= n-i;
            y *= i+1;
        }
        return x / y;
    }
    friend istream& operator>>(istream& is, mint& m){
        is >> m.x;
        return is;
    }
    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};

int main(){
  int n;
  cin>>n;
  vector<int>a(n);
  ll sum=0;
  rep(i,n){
    cin>>a[i];
    sum+=a[i];
  }
  mint ans=0;
  rep(i,n){
    ans+=mint(sum-a[i])*a[i];
  }
  cout<<ans/2<<endl;
}

Measured memory_bytes: 3992
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

string s;
vi a(26);

int main(){
	cin>>s;
	int S=s.size();
	for(int i=0;i<S;i++) a[s[i]-'a']++;
	for(int i=0;i<26;i++) if(a[i]>1){
		cout<<"no"<<endl;
		return 0;
	}
	cout<<"yes"<<endl;
}

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

int partition(int* A,int p,int r){
  int  x=A[r];
  int  i=p-1;
  for(int j=p;j<=r-1;j++){
     if(A[j]<=x){
	i=i+1;
	int tmp=A[j];
	A[j]=A[i];
	A[i]=tmp;
      }
   }
  int tmp=A[i+1];
  A[i+1]=A[r];
  A[r]=tmp;
  return i+1;
}

int main(){
  int n;
  cin>>n;
  int A[n];
  for(int i=0;i<n;i++)cin>>A[i];
  int base=partition(A,0,n-1);
  for(int i=0;i<n;i++){
    if(base!=i){
      if(i!=n-1)cout<<A[i]<<" ";
      else cout<<A[i];
    }
    else{
      if(i!=n-1)cout<<"["<<A[i]<<"] ";
      else cout<<"["<<A[i]<<"]";
    }
  }
  cout<<endl;
}



Measured memory_bytes: 3464
import sys

rl = sys.stdin.readline


def solve():
    N, K = map(int, rl().split())
    D = set(map(int, rl().split()))
    
    for ans in range(N, 100000):
        str_ans = str(ans)
        flg = True
        for a in str_ans:
            if int(a) in D:
                flg = False
                break
        if flg:
            print(ans)
            exit()


if __name__ == '__main__':
    solve()


Measured memory_bytes: 40540
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) x.begin(),x.end()
#define db(x) cout<<#x<<"="<<x<<endl
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, n, m) for(int i = n; i >= m; i--)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;

int main(){

  int N;
  cin >> N;

  ll ct=0;

  vector<string> s(N);

  map<string,int> mp;

  string ss;
  rep(i,N){

    cin>>ss;

    SORT(ss);

    auto itr = mp.find(ss);        // "xyz" が設定されているか？
   if( itr != mp.end() ) {
       ct+=itr->second;
       itr->second += 1;
   } else {
       mp[ss] = 1;
   }
  }

  cout << ct <<endl;
  return 0;
}


Measured memory_bytes: 12032
//Daniel Grzegorzewski
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second

using namespace std;

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios() {
     ios_base::sync_with_stdio(0);
     cin.tie(0);
}

const int N = (int)1e5 + 10;

int n, m, res, p[N];
bool vis[N];

int Find(int x) {
  if (x == p[x])
    return x;
  return p[x] = Find(p[x]);
}

void Union(int x, int y) {
  x = Find(x);
  y = Find(y);
  if (x == y)
    return;
  p[x] = y;
}

int main() {
  init_ios();
  cin >> n >> m;
  for (int i = 1; i <= n; ++i)
    p[i] = i;
  while (m--) {
    int x, y, z;
    cin >> x >> y >> z;
    Union(x, y);
  }
  for (int i = 1; i <= n; ++i)
    if (!vis[Find(i)]) {
      vis[Find(i)] = true;
      ++res;
    }
  cout<<res<<"\n";
}

Measured memory_bytes: 896
X,Y=map(int,input().split())
ans=0

if X==3:
  ans+=100000
if X==2:
  ans+=200000
if X==1:
  ans+=300000
if Y==3:
  ans+=100000
if Y==2:
  ans+=200000
if Y==1:
  ans+=300000
if X==1 and Y==1:
  ans+=400000
  
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
    int main(){
        int n,k,p[1000],l,r=0;
        scanf("%d %d",&n,&k);
        for(int i=0;i<n;i++)scanf("%d",&p[i]);
        for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++){
                if(p[i]>p[j]){
                    l=p[i];
                    p[i]=p[j];
                    p[j]=l;
                }
            }
        }
        for(int i=0;i<k;i++)r+=p[i];
        printf("%d\n",r);
        return 0;
    }

Measured memory_bytes: 1732
#include <stdio.h>

int calc_num(int i){
    int num[5];

    num[0] = i / 10000;
    num[1] = (i % 10000) / 1000;
    num[2] = (i % 1000) / 100;
    num[3] = (i % 100) / 10;
    num[4] = i % 10;

    return num[0] + num[1] + num[2] + num[3] + num[4];
}

int main(){
    int ans = 0;
    int i,ret;
    int N,A,B;
    scanf("%d%d%d",&N,&A,&B);

    for (i = 0;i <= N; i++){
        ret = calc_num(i);
        if (ret >= A && ret <= B){
            ans = ans + i;
        }
    }
    printf("%d",ans);
    return 0;
}

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

typedef ostringstream OSS; typedef istringstream ISS;
typedef long long LL;
typedef pair<int, int> PII;  typedef pair<LL, LL> PLL;
typedef vector<int>    VI;   typedef vector<VI>   VVI;   typedef vector<VVI>   VVVI;
typedef vector<LL>     VLL;  typedef vector<VLL>  VVLL;  typedef vector<VVLL>  VVVLL;
typedef vector<double> VD;   typedef vector<VD>   VVD;   typedef vector<VVD>   VVVD;
typedef vector<string> VS;   typedef vector<VS>   VVS;   typedef vector<VVS>   VVVS;
typedef vector<bool>   VB;   typedef vector<VB>   VVB;   typedef vector<VVB>   VVVB;
typedef vector<PII>    VPII; typedef vector<VPII> VVPII; typedef vector<VVPII> VVVPII;
typedef vector<PLL>    VPLL; typedef vector<VPLL> VVPLL; typedef vector<VVPLL> VVVPLL;

typedef unsigned int  UI;
typedef vector<UI>    VUI;
typedef vector<VUI>   VVUI;

#define fst first
#define snd second
// #define Y first
// #define X second
#define MP make_pair
#define PB push_back
#define EB emplace_back 
#define ALL(x)  (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define RANGEBOX(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
#define RANGE(x, l, r) ((l) <= (x) && (x) <= (r))
#define rep(i, N)  for (int i = 0; i < (int)(N); i++)
#define rrep(i, N) for (int i = N - 1; i >= 0; i--)
#define REP(i, init, N)  for (int i = (init); i < (int)(N); i++)
#define RREP(i, N, last) for (int i = (init - 1); i >= last; i--)
#define MAXUD(orig, target) orig = max(orig, target)
#define MINUD(orig, target) orig = min(orig, target)
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

template < typename T > inline T fromString(const string &s) { T res; ISS iss(s); iss >> res; return res; };
template < typename T > inline string toString(const T &a)   { OSS oss; oss << a; return oss.str(); };

template<typename T=int> inline void dump(vector<T> vs, bool ent=false) { rep(i, vs.size()) cout << vs[i] << (i+1==vs.size() ? '\n' : ' '); if (ent) cout << endl; }
template<typename T = int> inline void dump(vector<vector<T>> vs, bool ent = false) { rep(i, vs.size()) dump<T>(vs[i]); if (ent) cout << endl; }

const int    INF  = 0x3f3f3f3f;
const LL     INFL = 0x3f3f3f3f3f3f3f3fLL;
const double DINF = 0x3f3f3f3f;
const int    DX[] = {1,  0, -1, 0};
const int    DY[] = {0, -1,  0, 1};
const double EPS  = 1e-12;
// const double PI   = acos(-1.0);
// lambda: [](T1 x)->T2{return y;}
// simple lambda: [](T x){return x;}

int solve(int a, int b, int c) {
    int t = 0;
    rep(i, 100) {
        rep(j, a) {
            ++t;
            if (t % 60 == c) return t;
        }
        rep(j, b) {
            ++t;
        }
    }

    return -1;
}

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

    cout << solve(a, b, c) << endl;

    return 0;
}

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

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

using namespace std;

long long pow_mod(long long x, long long y, long long MOD){
	long long ret = 1;
	while(y){
		if (y & 1) ret = ret * x % MOD;
		x = x * x % MOD;
		y>>=1;
	}
	return ret;
}

signed main(){
  int N;
  cin>>N;
  int d[N];
  rep(i, N) cin >> d[i];

  int count=0;
  sort(d, d+N);

  if(N%2==1){
    cout << 0 << endl;
    return 0;
  }
  cout << d[N/2]-d[N/2-1] << endl;

  return 0;

}


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

#define ll long long
#define ld long double
#define db double
#define pb push_back
#define nl '\n'
#define X first
#define Y second
#define nimble ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define mod(x,m) ((((x)%(m))+(m))%(m))
#define _sz(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(v) for(int i=0;i<_sz(v);i++)
#define rep1(i,b,a) for(int i=b;i>=a;i--)
#define preci(x) fixed<<setprecision(x)
#define tc int tt=1;cin>>tt;while(tt--)

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr<<name<<" : "<<arg1<<nl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif

int inf=0x3f3f3f3f;
ll infl=0x3f3f3f3f3f3f3f3fLL;
ld infd=1.0/0.0;
const ll MOD=1e9+7;// 998244353 // = (119<<23)+1
const ld pi=2*acos(0.0);
int h,w,m;
vector<pair<int,int>> ff;
int fun(){

     map<int,int> row;
    map<int,int> col;
    map<pair<int,int>,int> chk;
    rep(i,0,m){
        int x,y;
        x=ff[i].Y;
        y=ff[i].X;
        row[x]++;
        col[y]++;
        chk[{x,y}]++;
    }
    int mx=0;
    int rw=0;
    for(auto i:row){
        if(i.Y>mx)
            mx=i.Y,rw=i.X;
    }
    int mx2=0;
    for(auto i:col){
        int z=i.Y;//see(z,i.X);
        if(chk[{rw,i.X}])
            z-=chk[{rw,i.X}];
        if(z>mx2)
            mx2=z;
    }
    return mx+mx2;
}
int main(){
    nimble
    cin>>h>>w>>m;
    map<int,int> row;
    map<int,int> col;
    map<pair<int,int>,int> chk;
    rep(i,0,m){
        int x,y;
        cin>>x>>y;
        ff.pb({x,y});
        row[x]++;
        col[y]++;
        chk[{x,y}]++;
    }
    int mx=0;
    int rw=0;
    for(auto i:row){
        if(i.Y>mx)
            mx=i.Y,rw=i.X;
    }
    int mx2=0;
    for(auto i:col){
        int z=i.Y;//see(z,i.X);
        if(chk[{rw,i.X}])
            z-=chk[{rw,i.X}];
        if(z>mx2)
            mx2=z;
    }
    int as=mx+mx2;
    int as2=fun();
    cout<<max(as,as2);
    return 0;
}


Measured memory_bytes: 136928
#include <stdio.h>
#define BUFMAX 15

int main(){
    char buf[BUFMAX];
    int a,b;

    fgets(buf,BUFMAX,stdin);
    buf[BUFMAX-1] = '\0';
    sscanf(buf,"%d %d", &a, &b);

    if(a < b){
        printf("a < b\n");
    }
    else if(a > b){
        printf("a > b\n");
    }
    else{
        printf("a == b\n");
    }

    return 0;
}

Measured memory_bytes: 1716
#include <stdio.h>
#include <stdlib.h>


int main(){
  int x[100],i=0;
  char s[100];

  while( scanf("%s",s) !=EOF ){
    if(s[0]=='+'){
      x[i-2]=x[i-2]+x[i-1];
      i=i-1;
    }else if(s[0]=='-'){
      x[i-2]=x[i-2]-x[i-1];
      i=i-1;
    }else if(s[0]=='*'){
      x[i-2]=x[i-2]*x[i-1];
      i=i-1;
    }else{
      x[i]=atoi(s);
      i++;
    }
  }

  printf("%d\n",x[i-1]);

  return 0;
}



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

#define ed cout << "\n";
#define speed                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ffor(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(i, n) ffor(i, 0, n)
#define All(obj) (obj).begin(), (obj).end()
#define INF ((ll)1e9 + 7)
#define c(a) cout << a << "\n";
using namespace std;
const int N = 100005;

int main()
{
    speed;
    cout << fixed << setprecision(10);
    /*start*/
    int a, b, c;
    cin >> a >> b >> c;
    int ans;
    if (a == b)
        ans = c;
    else if (b == c)
        ans = a;
    else if (c == a)
        ans = b;
    c(ans);
    return 0;
}


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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;

Node root,NIL;
int maxh = 0;

void insert(int k){
  int H;
  Node x = root;
  Node y = NIL;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }
    else{
      x = x->right;
    }
  }

  z->parent = y;
  if(y == NIL){
    root = z;
  }
  else if(z->key < y->key){
    y->left = z;
  }
  else{
    y->right = z;
  }
}

void inorder(Node u){
  if(u == NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(Node u){
  if(u == NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int n,i,x;
  char com[20];

  scanf("%d",&n);

  for(i = 0;i < n;i++){
    scanf("%s",com);
    if(strcmp(com,"insert") == 0){
      scanf("%d",&x);
      insert(x);
    }
    else if(strcmp(com,"print") == 0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}

  



Measured memory_bytes: 25124
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>

using namespace std;

long long MOD = 1000000007;
long long MOD_13 = 13;
long long dp[100000][13];

int BIT_SIZE = 64;
long long power(long long m, long long n){
    long long ans = 1;
    long long tmp = m;
    for(int i = 0; i < BIT_SIZE; i++){
        //cout << ans << endl;
        if(((n >> i) & 1) == 1){
            ans = ans * tmp % MOD_13;
        }
        tmp = (tmp * tmp) % MOD_13;
    }
    return ans;
}


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

    reverse(S.begin(), S.end());
    if(S[0] != '?'){
        dp[0][(S[0] - '0') % 13] = 1;
    } else {
        for(int i = 0; i < 10; i++){
            dp[0][i] = 1;
        }
    }
    long long ten_mod = 10;
    for(int i = 1; i < S.size(); i++){
        if(S[i] != '?'){
            for(int j = 0; j < 13; j++){
                long long tmp_ind = ((ten_mod * (long long) (S[i] - '0')) % 13 + j) % 13;
                dp[i][tmp_ind] = (dp[i][tmp_ind] + dp[i - 1][j]) % MOD;
            }
        } else {
            for(int j = 0; j < 10; j++){
                for(int k = 0; k < 13; k++){
                    long long tmp_ind = ((ten_mod * j) % 13 + k) % 13;
                    dp[i][tmp_ind] = (dp[i][tmp_ind] + dp[i - 1][k]) % MOD;

                }
            }
        }
        ten_mod = (10 * ten_mod) % 13;
    }
    cout << dp[S.size() - 1][5] << endl;

    /* 
    for(int i  = 0; i < 13; i++){
        cout << dp[S.size() - 3][i] << " ";
    }
    cout << endl;
    */
    return 0;
}


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

int main() {
	int n;
	string s;
	cin >> n ;
	cin >> s;
	if(n%2==1){
		cout << "No" << endl;
		return 0;
	}
	int o=n/2;
	if(s.substr(0,o)==s.substr(o)){
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define ARRAY_LENGTH(array) sizeof(array)/sizeof(*array)
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 main() {
    ll N, M, X;
    cin >> N >> M >> X;

    ll to0 = 0, toN = 0;
    vector<ll> A(M);
    REP(i, M) {
        cin >> A[i];
        if(A[i] < X) {
            ++to0;
        } else {
            ++toN;
        }
    }

    cout << min(to0, toN) << endl;

    return 0;
}

Measured memory_bytes: 3536
K = int(input())
S = input()

m = 1000000007


def make_factorial_table(n):
    result = [0] * (n + 1)
    result[0] = 1
    for i in range(1, n + 1):
        result[i] = result[i - 1] * i % m
    return result


def mcomb(n, k):
    if n == 0 and k == 0:
        return 1
    if n < k or k < 0:
        return 0
    return fac[n] * pow(fac[n - k], m - 2, m) * pow(fac[k], m - 2, m) % m


fac = make_factorial_table(len(S) - 1 + K)

result = 0
for i in range(K + 1):
    t = pow(26, i, m) * mcomb(len(S) - 1 + K - i, len(S) - 1)
    t %= m
    t *= pow(25, K - i, m)
    t %= m
    result += t
    result %= m
print(result)


Measured memory_bytes: 101940
//abc156_a.cpp
//Sat Feb 22 20:51:49 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	if (n<10){
		cout << r+100*(10-n)<<endl;
	}else {
		cout << r << endl;
	}

}

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

using namespace std;
int main() {
    int N;
    cin >> N;
    vector<int> L(N);
    for(int i = 0; i < N; i++){
        cin >> L[i];
    }
    sort(L.begin(),L.end());
    int sum = 0;
    for(int yi = 1; yi < N - 1; yi++){
        for(int xi = 0; xi < yi; xi++){
            for(int zi = N-1; yi < zi; zi--){
                int a = L[xi];
                int b = L[yi];
                int c = L[zi];
                if(a < b + c && b < a + c && c < a + b){
                    sum ++;
                }
            }
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) \
    for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) \
    for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
#define ALL(v) v.begin(), v.end()
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e15 + 7LL;
constexpr ll MOD = 1e9 + 7LL;

template <typename T>
istream &operator>>(istream &is, vector<T> &v)
{
    for (int i = 0; i < v.size(); ++i)
    {
        is >> v[i];
    }
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    for (int i = 0; i < v.size() - 1; ++i)
    {
        os << v[i] << " ";
    }
    if (v.size() > 0)
    {
        os << v[v.size() - 1] << endl;
    }
    return os;
}

int main()
{
    ll n;
    cin >> n;
    unordered_map<ll, int> ma;
    for (ll i = 2; i*i <= n; ++i){
        while (n % i == 0){
            ++ma[i];
            n /= i;
        }
    }
    if (n != 1){
        ma[n]++;
    }
    vll memo;
    ll ans = 0;
    for (auto elem : ma)
    {
        int cnt = elem.second;
        ll st = 0, en = 1e8;
        while (en - st > 1){
            ll mid = (st + en) / 2;
            if (cnt >= mid*(mid + 1) / 2){
                st = mid;
            }else{
                en = mid;
            }
        }
        ans += st;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3608
straights = [[1,2,3,4,5], [2,3,4,4,6], [3,4,5,6,7], [4,5,6,7,8], [5,6,7,8,9], [6,7,8,9,10], [7,8,9,10,11], [8,9,10,11,12], [9,10,11,12,13], [1,10,11,12,13]]
while line = gets
    cards = line.chomp.split(',').map(&:to_i).sort
    uniq = cards.uniq
    maxcount = 0
    uniq.each{|x| maxcount = cards.count(x) if maxcount < cards.count(x)}

    result = "null"
    if uniq.length == 2
        if maxcount == 4
            result = "four card"
        else
            result = "full house"
        end
    elsif 
        if straights.any?{|arr| arr == cards}
            result = "straight"
        end
    elsif uniq.length == 3
        if maxcount == 3
            result = "three card"
        else
            result = "two pair"
        end
    elsif uniq.length == 4
        result = "one pair"
    end
    puts result
end


Measured memory_bytes: 6848
#include <iostream>
using namespace std;
int main() {
	int E, Y;
	cin >> E >> Y;
	if (E == 0) {
		if (Y <= 1911) cout << "M" << Y - 1867 << endl;
		else if (Y <= 1925) cout << "T" << Y - 1911 << endl;
		else if (Y <= 1988) cout << "S" << Y - 1925 << endl;
		else cout << "H" << Y - 1988 << endl;
	}
	else if (E == 1) cout << Y + 1867 << endl;
	else if (E == 2) cout << Y + 1911 << endl;
	else if (E == 3) cout << Y + 1925 << endl;
	else cout << Y + 1988 << endl;
	return 0;
}


Measured memory_bytes: 3104
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int 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;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}
int read() {
	int tmp;
	cin >> tmp;
	return tmp;
}
int xor128() {
	static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	int t = (x xor (x << 11));
	x = y; y = z; z = w;
	return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}

signed main() {
	string s;
	cin >> s;
	int a = 0, b = 0, c = 0;
	rep(i, s.size()) {
		if (s[i] == 'a') a++;
		else if (s[i] == 'b') b++;
		else c++;
	}
	if (max({ a,b,c }) - min({ a,b,c }) <= 1) {
		cout << "YES" << endl;
	}
	else cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <utility>
#include <set>
#include <map>
#include <deque>
#include <stack>

using namespace std;

typedef long long ll;

int main(){
	ll N, M, ans = 0, i;
	cin >> N >> M;
	
	if (N * 2 <= M){
          ans += N;
          M -= N*2;
          ans += M / 4;
          cout << ans;
    }
    else{
         cout << M / 2;
    }
	
	
	
	
	
	
}

Measured memory_bytes: 256
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]
#a = [int(input()) for _ in range(n)]


n = input()

if n[0] == n[1] == n[2] or n[1] == n[2] == n[3]:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 8820
#include <cstdlib>
#include <iostream>
#include <algorithm>


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

  int w, a, b;
  std::cin >> w >> a >> b;
  if (a + w < b) {
    std::cout << (b - (a + w)) << std::endl;
  } else if (b + w < a) {
    std::cout << (a - (b + w)) << std::endl;
  } else {
    std::cout << 0 << std::endl;
  }

  return EXIT_SUCCESS;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>
#include<unordered_map>
#include<queue>

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
int gcd(int a, int b){return b ? gcd(b, a%b) : a;}
int lcm(int a, int b){return a*b / gcd(a, b);}

int main(){
    string s;
    cin >> s;
    string target = "keyence";
    int n = s.size();

    if(target == s){
        cout << "YES" << endl;
        return 0;
    }
    for(int i = 0; i < n; i++){
        for(int j = i; j <= n; j++){
            string ss = "";
            for(int k = 0; k < n; k++){
                if(i <= k && k <= j) continue;
                else ss.push_back(s[k]);
            }
            if(target == ss){
                cout << "YES" << endl;
                return 0;
            }
        }
    }
    cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
//#pragma warning(disable : 4996)

#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#define __builtin_popcountll __popcnt64
#endif

#include <limits.h>
#include <math.h>
#include <time.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m - 1; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v, n) reverse(v, v + n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout << (x) << '\n'
#define pe(x) cout << (x) << " "
#define DEBUG(x) cout << #x << ": " << x << endl
#define lb(v, n) lower_bound(v.begin(), v.end(), (n))
#define ub(v, n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i, v.size()) cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template <typename T1, typename T2> inline void chmin(T1& a, T2 b) {
	if (a > b) a = b;
}
template <typename T1, typename T2> inline void chmax(T1& a, T2 b) {
	if (a < b) a = b;
}
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef array<int, 3> arr3;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 998244353;
constexpr int MAX = 500050;
const double pi = acos(-1);
// constexpr double EPS = 1e-10;
constexpr ll LINF = 1e18 + 1;
constexpr int INF = 1e9 + 1;


void no() {
	print(-1); exit(0);
}

void solve() {
	int N; cin >> N;
	vector<int>A(N+1);
	REP(i, N + 1)cin >> A[i];
	ll ans = 0;
	vector<int>cum(N + 2);
	REP(i, N + 1)cum[i + 1] = cum[i] + A[i];
	int sub = 0;
	int ok = 1;
	REP(i, N + 1) {
		if (i < 55) {
			if (i == 0)ok = 1;
			if (A[i] > ok)no();
			//if (A[i] > (1LL << i))no();
			//int rem = (1LL << i)-sub;
			//if (A[i] > rem)no();
			int ad = min(ok, cum[N + 1] - cum[i]);
			ans += min(ok, cum[N + 1] - cum[i]);
			ok -= A[i];
			ok *= 2;
		}
		else {
			if (A[i] > ok)no();
			ans += min(ok, cum[N + 1] - cum[i]);
			//ans += cum[N + 1] - cum[i];
			ok -= A[i];
			if (ok < 1e16)ok *= 2;
		}
	}
	print(ans);
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q;
	//cin >> q;
	//while (q--)
	solve();
}


Measured memory_bytes: 5188
#include<stdio.h>

int main(void){
	
	double a,b,c,d,e,f,x,y,num4,num5;
	
	while(scanf("%lf %lf %lf %lf %lf %lf", &a,&b,&c,&d,&e,&f)!=EOF){
		num4=(b*d)-(e*a);
		num5=(c*d)-(f*a);
		y=num5/num4;
		x=(c-b*y)/a;
		printf("%.3f %.3f\n", x, y);
	}
	return 0;
}

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

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

    if (N >= 10) {
        cout << R << endl;
    }
    else {
        cout << R + 100 * (10 - N) << endl;
    }
}


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

int main() {
    int N;
    cin>>N;
    vector<int> A(N),B(N);
    for(int i=0;i<N;++i){
      cin>>A[i]>>B[i];
    }
    long long ans=0;
    for(int i=N-1;i>=0;i--){
        long long sum=(ans+A[i])%B[i];
        if(sum>0){
          ans+=B[i]-sum;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4052
#include <bits/stdc++.h>
using namespace std;
int main () {
  string S;
  cin >> S;
  vector<long> data(S.size() + 1);
  for(int i = 0; i < S.size(); i++){
    if(S.at(i) == '<')data.at(i + 1) = data.at(i) + 1;
  }
  for(int i = S.size() - 1; i >= 0; i--){
    if(S.at(i) == '>')data.at(i) = max(data.at(i + 1) + 1, data.at(i));
  }
  long ans = 0;
  for(int i = 0; i < data.size(); i++)ans += data.at(i);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4740
#include <bits/stdc++.h>
#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 pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
ll gcd(ll a,ll b){if(a>b)swap(a,b);for(;a>0;b%=a,swap(a,b));return b;}
int modpow(ll a,ll n,int m){if(a==0)return a;ll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(int)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;

main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vi ans;
  ans.resize(n*2-1);
  if(m == 1 || m == n*2-1){
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  if(n == 2){
    cout << "1 2 3" << endl;
    return 0;
  }
  if(m == 2){
    ans[n] = 4;
    ans[n-1] = 2;
    ans[n-2] = 1;
    ans[n-3] = 3;
    int a = 5;
    FOR(i, 0, n-3){
      ans[i] = a;
      a++;
    }
    FOR(i, n+1, 2*n-1){
      ans[i] = a;
      a++;
    }
  }else{
    ans[n] = m-2;
    ans[n-1] = m;
    ans[n-2] = m+1;
    ans[n-3] = m-1;
    int a = 1;
    while(m-2 <= a && a <= m+1) a++;
    FOR(i, 0, n-3){
      ans[i] = a;
      a++;
      while(m-2 <= a && a <= m+1) a++;
    }
    FOR(i, n+1, 2*n-1){
      ans[i] = a;
      a++;
      while(m-2 <= a && a <= m+1) a++;
    }
  }
  cout << join(ans) << endl;
  return 0;
}

Measured memory_bytes: 4996
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 N;
  std::string S;
  std::cin >> N >> S;

  const std::string alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  std::unordered_map<char, std::size_t> rev;
  for (i64 i = 0; i < static_cast<i64>(alphabet.size()); ++i) {
    rev.emplace(alphabet[i], i);
  }

  std::transform(S.begin(), S.end(), S.begin(), [&](const char& S_i) {
    return alphabet[(rev[S_i] + N) % alphabet.size()];
  });

  std::cout << S << std::endl;
  return 0;
}

Measured memory_bytes: 256
let () = Scanf.scanf "%d\n" @@ fun n ->
  let as_ = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun a -> a in
  let ans = Array.fold_left (fun ans a -> if ans + 1 = a then a else ans) 0 as_ in
  Printf.printf "%d\n" @@ if ans = 0 then -1 else n - ans


Measured memory_bytes: 6272
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

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

  string ans=S;
  for(int i=0;i<S.size();i++){
    ans[i]=(char)('A'+(ans[i]-'A'+N)%26);
  }
  cout<<ans<<endl;

  return 0;
}


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

typedef long long ll;
using namespace std;

int n;

struct Data{
	int t,m;
	bool operator<(const Data& another) const {
		if (t != another.t)	return t < another.t;
		else return m < another.m;
	}
};

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

	while(true){
		cin >> n;
		if(n == 0) break;
		int m,a,b; 
		vector<Data> d;
		for (int i = 0;i < n;i++){
			cin >> m >> a >> b;
			d.push_back({a,m});
			d.push_back({b,-m});
		}
		sort(d.begin(),d.end());
		int sum = 0;
		bool ans = true;
		for (int i = 0;i < d.size();i++){
			sum += d[i].m;
			if(sum > 150){
				ans = false;
			}
		}
		cout << (ans?"OK":"NG") << endl;
	}

	return 0;

}



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

using namespace std;
  
int main(){

    unordered_set<int> s = {1,2,3};
    int A, B;
    cin >> A >> B;

    s.erase(A);
    s.erase(B);

    for (auto ans:s)
        cout << ans << "\n";

    return 0; 
} 

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

const int maxn=1e2+10,maxk=1e5+10,mod=1e9+7;

int dp[maxn][maxk],n,k,a[maxn],sum[maxn][maxk];

int32_t main()
{
    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
       // if(cin.peek()!='\n')
 //   ifstream cin("input.txt");
 //   ofstream cout("output.txt");
    cin>>n>>k;
    sum[0][0]=1;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    //cout<<endl;
    dp[0][0]=1;
    for(int i=1;i<=k;i++)
    {
        if(i<=a[0])
            dp[0][i]=1;
        else dp[0][i]=0;
        sum[0][i]=dp[0][i]+sum[0][i-1];
    }
    for(int i=1;i<n;i++)
    {
        sum[i][0]=1;
        dp[i][0]=1;
        for(int j=1;j<=k;j++)
        {
            if(j-1-a[i]>=0)
            dp[i][j]=(sum[i-1][j]-sum[i-1][j-1-a[i]]+mod)%mod;
            else dp[i][j]=sum[i-1][j];
            sum[i][j]=(sum[i][j-1]+dp[i][j])%mod;
   //         cout<<i<<' '<<j<<' '<<dp[i][j]<<endl;
        }
    }
   // cout<<endl;
    //for(int i=0;i<n;i++)
  //  {
       // for(int j=0;j<=k;j++)
     //       cout<<sum[i][j]<<' ';
   //     cout<<endl;
 //   }
    cout<<dp[n-1][k];
}



Measured memory_bytes: 162048
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

	public static void main(String[] args) {
		BufferedReader b = new BufferedReader(new InputStreamReader(System.in));

		int n=0;
		int minValue;
		int maxValue = -2000000000;
		try {
			n = Integer.parseInt(b.readLine());
			minValue = Integer.parseInt(b.readLine());;
			for(int i=1; i<n; i++) {
				int v = Integer.parseInt(b.readLine());
				if(maxValue < v-minValue) {
					maxValue = v-minValue;
				}
				if(v < minValue) {
					minValue = v;
				}			}
		} catch (IOException e) {
			e.printStackTrace();
		}
		System.out.println(maxValue);
	}

}


Measured memory_bytes: 42288