akhauriyash/Code-Regression huggingface dataset:
//https://atcoder.jp/contests/abc134/tasks/abc134_e
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
struct Dat{
    ll v;
    ll pos;
};
int main() {
#if LOCAL&01
    std::ifstream in("./test/sample-1.in"); //input.txt
    std::cin.rdbuf(in.rdbuf());
#endif
    ll N; cin>>N;
    vector<Dat> an(N);
    for(ll i=0;i<N;++i){
        cin>>an[i].v;
        an[i].pos=i;
    }
#if 1
    multiset<ll> tbl;
    for(auto& a:an){
        //multiset<ll>::iterator it=lower_bound(tbl.begin(),tbl.end(),a.v);
        auto it=tbl.lower_bound(a.v);
        if(it==tbl.begin()){
        } else{
            --it;
            tbl.erase(it);
        }
        tbl.insert(a.v);
    }
#else
    vector<Dat> tbl;
    tbl.reserve(N);
    for(auto& a:an){
        //いれるところ探索
        ll pt=-1;
        ll df=INT64_MAX;
        for(ll i=0;i<tbl.size();++i){
            auto&& t=tbl[i];
            if(t.v<a.v){
                ll dff=a.v-t.v;
                if(df>dff){
                    df=dff;
                    pt=i;
                }
            }
        }
        if(pt<0){
            tbl.push_back(a);
        }else{
            tbl[pt]=a;
        }
    }
#endif
    cout<<tbl.size()<<endl;
    return 0;
}

Measured memory_bytes: 6528
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

def error():
    print(-1)
    quit()

n = inp()
a = inpl()
if n == 0 and sum(a) == 1:
    print(1)
    quit()
can = [0] * (n+1); can[0] = 1
b = [0] * (n+1)
res = [0] * (n+1)

if a[0] != 0:
    error()

for i in range(n):
    can[i+1] = can[i]*2 - a[i+1]
    if can[i+1] < 0:
        error()
can[-1] = 0
b[-1] = 0
res[-1] = a[-1]
for i in range(n)[::-1]:
    b[i] = min(res[i+1], can[i])
    res[i] = a[i] + b[i]
print(sum(res))

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

int m, n, p, q;
string s;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> m >> n >> p >> q;
    for (int i = 0; i < p; i++) {
        s.push_back('0');
    }
    for (int i = p; i < n; i++) {
        s.push_back('1');
    }
    for (int i = 0; i < q; i++) {
        cout << s << '\n';
    }
    for (int i = 0; i < n; i++) {
        s[i] = '0' ^ '1' ^ s[i];
    }
    for (int i = q; i < m; i++) {
        cout << s << '\n';
    }
}


Measured memory_bytes: 1280
import java.util.Scanner;
class Main{
    public static void main(String args[]){
    
        Scanner scan = new Scanner(System.in);

        int coinA = scan.nextInt();

        int coinB = scan.nextInt();


        int coinC = scan.nextInt();



  
        if (coinA + coinB  >= coinC ){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    

    }
}

Measured memory_bytes: 22740
N,K = map(int,input().split())
P   = list(map(int,input().split()))

ans=0
for i in range(K):
  ans+=(P[i]+1)/2
l=ans

for i in range(0,N-K):
  l=l-((P[i]+1)/2)+((P[i+K]+1)/2)
  ans=max(ans,l)
  
print(ans)
    
  

Measured memory_bytes: 72012
/* code by AbhiTaker  */
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
typedef unsigned long long ull;
#define M 1000000007
#define N 1000016
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define f first
#define s second
#define inf 9000000000000000000

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll n,i,y,x,z,p,j,k, f = 0;
    cin>>n>>p;
    p /= 1000;

    for(i=0; i<=n; i++)
    {
        if(i>p)
            break;
        for(j=0; i+j<=n; j++)
        {
            if(i + 5*j > p || i+j>n)
                break;
            for(k=0; i+j+k<=n; k++)
            {
                if(i + 5*j + 10*k > p)
                    break;

                if(i + 5*j + 10*k == p  && i+j+k==n)
                {
                    cout<<k<<" "<<j<<" "<<i<<"\n";
                    f = 1;
                    break;
                }

            }

            if(f)
                break;

        }
        if(f)
            break;
    }

    if(!f)
        cout<<"-1 -1 -1\n";




    return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func caclTmp(t, x int) float64 {
	return float64(t) - float64(x)*0.006
}

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()
	t := nextInt()
	a := nextInt()

	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}

	point := 0
	min := math.Inf(0)

	for p, h := range slice {
		res := caclTmp(t, h)

		abs := math.Abs(res - float64(a))
		// fmt.Println(abs)
		if abs < min {
			min = abs
			point = p + 1
			// fmt.Printf("point:%d, min:%f", point, min)
		}
	}

	fmt.Println(point)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
const double PI = acos(-1.0);
#define MOD 1000000007LL
#define endl "\n"

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll A, B, M;
  cin >> A >> B >> M;
  vll a(A), b(B);
  ll amin = INF, bmin = INF;
  for(int i = 0; i < A; i++){
    cin >> a.at(i);
    chmin(amin, a.at(i));
  }
  for(int i = 0; i < B; i++){
    cin >> b.at(i);
    chmin(bmin, b.at(i));
  }
  ll ans = amin + bmin;
  for(int i = 0; i < M; i++){
    ll x, y, c;
    cin >> x >> y >> c;
    x--; y--;
    ll p = a.at(x) + b.at(y) - c;
    chmin(ans, p);
  }
  cout << ans << endl;
}

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define all(x) (x).begin(),(x).end()
#define S(x) (int)(x).size()
#define L(x) (int)(x).length()

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int , null_type , less<int> , rb_tree_tag , tree_order_statistics_node_update> ordered_set;

const int mod = 1e9+7;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;

void solve()
{
	int n;
	cin>>n;
	if(n%1000)
	cout<<(1000-n%1000)<<'\n';
	else cout<<0<<'\n';
}

int main()
{
	IOS
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 3612
import Data.Char
import Data.List
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector as V
import qualified Data.IntMap as IM
main=putStrLn.solve.map(unfoldr$B.readInt.B.dropWhile isSpace).B.lines=<<B.getContents
solve([n,q]:abpx)=unwords.map show.IM.elems$f 0 0 0 IM.empty where
  (ab,px)=splitAt(n-1)abpx
  f x p v m=foldr(f y v)(IM.insert v y m).filter(/=p)$g V.! v where y=x+xs V.! v
  g=V.accum(flip(:))(V.replicate n[])$concatMap(\[a,b]->[(a-1,b-1),(b-1,a-1)])ab
  xs=V.accum(+)(V.replicate n 0)$map(\[p,x]->(p-1,x))px

Measured memory_bytes: 121428
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

#define rep(i,n) for(int i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;

int main() {
	string s, t, u;
  int a, b;
  cin >> s >> t;
  cin >> a >> b;
  cin >> u;
  if(u==s) a--;
  if(u==t) b--;

  cout << a << ' ' << b << endl;


  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    long long N, n, h, w;
    scanf("%lld", &N);
    int flag = 0;
    for(n = 1; n <= 3500; n++)
    {
        for(h = 1; h <= 3500; h++)
        {
            long long u = N * n * h;
            long long d = 4 * h * n - N * h - N * n;
            if(d > 0 && u % d == 0)
            {
                w = u / d;
                flag = 1;
                break;
            }
        }
        if(flag)
            break;
    }
    printf("%lld %lld %lld\n", h, n, w);
    return 0;
}


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


def main():
    s_length = int(raw_input())
    s = [int(x) for x in raw_input().strip().split(' ')]
    t_length = int(raw_input())
    t = [int(x) for x in raw_input().strip().split(' ')]

    counter = 0
    for value in t:
        if value in s:
            counter += 1

    print counter 

if __name__ == '__main__':
    main()

Measured memory_bytes: 6992
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define dd double
#define MOD1 1000000007
#define MOD2 998244353
#define nl cout<<endl
#define rt ll Q[100005]={0}
#define mp make_pair
#define test() ll t;cin>>t;while(t--)
#define pb push_back
#define ff first    
#define ss second
#define all(v) v.begin(),v.end()
#define s(ar,n) sort(ar,ar+n)
#define rs(ar,n) sort(ar, ar+n, greater<ll>()) 
#define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define ov(a,n) for(ll i=n-1;i>=0;i--)cout<<a[i]<<" ";nl
#define ovp(a,n) for(ll i=0;i<n;i++)cout<<a[i].ff<<" "<<a[i].ss<<endl;
#define maxa(ar,N) *max_element(ar,ar+N)
#define mina(ar,N) *min_element(ar,ar+N)
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef pair<ll,ll> pii;
ll powe(ll n,ll m){if(m==0)return 1;ll t=powe(n,m/2);if(m%2==0)return (t*t);return (((t*t))*n);}
ll mpowe(ll n,ll m,ll MOD){if(m==0)return 1;ll t=mpowe(n,m/2,MOD);t%=MOD;if(m%2==0)return (t*t)%MOD;return (((t*t)%MOD)*n)%MOD;}
ll logtwo(ll n){if(n==1)return 0;if(n==0) return -1;return logtwo(n/2)+1;}
int main()
{
    fastio();
   
    ll d,t,s;
    cin>>d>>t>>s;
    ll x = (d+s-1)/s;
    if(x<=t)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}

Measured memory_bytes: 3644
D = int(input())
c = list(map(int, input().split()))
s = []
for i in range(D):
  s.append(list(map(int, input().split())))
  
sdictlist = []
sdictlistsorted = []
for i in range(D):
  onedict = {}
  for j in range(26):
    onedict[j] = s[i][j]
  sdictlist.append(onedict)
  onesorteddict = sorted(onedict.items(), key=lambda x:x[1], reverse=True)
  sdictlistsorted.append(onesorteddict)

lenpastmax = 20 #26まで設定できる
#26 -> 145419
#25 -> 18657778
#24 -> 40796238
#23
pastlist = []
for i in range(D):
  j = 0
  while(sdictlistsorted[i][j][0] in pastlist):
    j += 1
  print(sdictlistsorted[i][j][0]+1)
  pastlist.append(sdictlistsorted[i][j][0])
  if(len(pastlist)==lenpastmax):
    pastlist.pop(0)


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

int main(){
	for(int n;;){
		cin>>n;
		if(!n)break;
		vector<pair<int,int>> w;
		w.push_back(make_pair(0,0));
		int xmx=0,xmn=0,ymx=0,ymn=0;
		for(int a,b;--n;){
			cin>>a>>b;
			if(b==0){
				xmn = min(xmn,w[a].first-1);
				w.push_back(make_pair(w[a].first-1,w[a].second));
			}else if(b==1){
				ymx = max(ymx,w[a].second+1);
				w.push_back(make_pair(w[a].first,w[a].second+1));
			}else if(b==2){
				xmx = max(xmx,w[a].first+1);
				w.push_back(make_pair(w[a].first+1,w[a].second));
			}else{
				ymn = min(ymn,w[a].second-1);
				w.push_back(make_pair(w[a].first,w[a].second-1));
			}
		}
		cout<<(xmx-xmn+1)<<" "<<(ymx-ymn+1)<<endl;
	}
}

Measured memory_bytes: 3088
#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;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

// template from zscoder

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
    string a,b,c;
    cin >> a >> b >> c;
    cout << a[0] << b[1] << c[2] << endl;
}

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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

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

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll N;
    cin >> N;

    vector<int> d(N);
    REP(i,N){
        cin >> d[i];
    }
    sort(d.begin(), d.end());

    cout << d[N/2] - d[N/2-1]  << endl;
}


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

int main(){
  while(1){
  int N,M,Q;
  cin>>N>>Q;
  if(N+Q==0) break;
  int D[51][101]={};
  int T[101]={};
  for(int i=0;i<N;i++){
    cin>>M;
    for(int j=0;j<M;j++){
      cin>>D[i][j];
      T[D[i][j]]++;
    }
  }
 
  int ans=0;
  for(int i=100;i>0;i--){
    if(Q<=T[i]){
      ans=i;
      Q=T[i];
    }
  }
  cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1184
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 4005;
const int mod = 1000000007;

unordered_map<char, int> mp = {{'R', 0}, {'G', 1}, {'B', 2}};
int c[maxn][3];

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  string s;
  int n;
  cin>>n>>s;
  for(int i=0;i<n;i++){
    int cur = mp[s[i]];
    if(i) {
      for (int j = 0; j < 3; j++)c[i][j] += c[i - 1][j];
    }
    c[i][cur]++;
  }
  ll ret = 0;
  for(int i=1;i<n;i++)
    for(int j=i+1;j<n;j++){
      if(s[i]==s[j])continue;
      int tt = 3 - (mp[s[i]] + mp[s[j]]);
      ret += c[i-1][tt];
      int pos = i - (j-i);
      if(pos>=0&&mp[s[pos]]==tt)ret--;
    }
  cout<<ret<<endl;
  return 0;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=1e5+5;

int n;
int a[N];
map<int, int> m[2];
vector<pair<int, int> > v[2];

int32_t main()
{
	IOS;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		m[i%2][a[i]]++;
	}
	for(int i=0;i<2;i++)
	{
		for(auto &it:m[i])
			v[i%2].push_back({it.second, it.first});
	}
	for(int i=0;i<2;i++)
		sort(v[i].rbegin(), v[i].rend());
	int sz=n/2;
	int ans=n;
	for(int i=0;i<min((int)v[0].size(), 5LL);i++)
	{
		for(int j=0;j<min((int)v[1].size(), 5LL);j++)
		{
			int cur=n;
			if(v[0][i].second==v[1][j].second)
				cur-=max(v[0][i].first, v[1][j].first);
			else
				cur-=(v[0][i].first + v[1][j].first);
			ans=min(ans, cur);
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 9592
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = s; i < n; i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define all_acc(x) (x).begin(), (x).end(), 0LL
#define int long long
#define double long double
#define absSort(v) sort(a.begin(), a.end(), [](int i, int j) -> bool { return abs(i) < abs(j); });
using namespace std;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
using ll = long long;
double pi=3.14159265359;

//出力するよ
void output(vector<string> s){
    int n = s.size();
    for (int i = 0; i < n; i++){
        //if(i!=0) cout<<" ";
        cout << s[i]<<endl;
    }
    //cout << endl;
}

void koch(int d,pair<double,double> p1,pair<double,double> p2){

    if(d==0){
        cout<<p1.first<<" "<<p1.second<<endl;
        if(p2.first==100.0 && p2.second==0) cout<<p2.first<<" "<<p2.second<<endl;
    }
    else{
        pair<double,double> s,t,u;
        s=make_pair((p1.first*2.0+p2.first)/3.0,(p1.second*2.0+p2.second)/3.0);
        t=make_pair((p1.first+p2.first*2.0)/3.0,(p1.second+p2.second*2.0)/3.0);

        double ux=s.first+(t.first-s.first)*cos(pi/3.0)-(t.second-s.second)*sin(pi/3.0);
        double uy=s.second+(t.first-s.first)*sin(pi/3.0)+(t.second-s.second)*cos(pi/3.0);
        u=make_pair(ux,uy);
        //cout<<u.first<<" "<<u.second<<endl;     

        koch(d-1,p1,s);
        koch(d-1,s,u);
        koch(d-1,u,t);
        koch(d-1,t,p2);
    }
}

signed main(){
    int n; cin>>n;
    cout<<fixed<<setprecision(8);
    koch(n,make_pair(0,0),make_pair(100,0));
}


Measured memory_bytes: 3576
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000000
#define VMAX 10000

void CountingSort(unsigned short A[],unsigned short B[]);

int C[VMAX + 1];
int n;

int main(){
  unsigned short *A,*B;
  int i;

  scanf("%d",&n);

  A = malloc(sizeof(short) * n + 1);
  B = malloc(sizeof(short) * n + 1);

  for(i = 0;i < n;i++){
    scanf("%hu",&A[i + 1]);
  }

  CountingSort(A,B);

  for(i = 1;i <= n;i++){
    if(i > 1){
      printf(" ");
    }
    printf("%u",B[i]);
  }
  printf("\n");

  free(A);
  free(B);

  return 0;
}

void CountingSort(unsigned short A[],unsigned short B[]){
  int i,j;
  
  for(i = 0;i <= VMAX;i++){     
    C[i] = 0;
  }
  for(j = 1;j <= n;j++){                     /*C[i]にiの出現数を記録する*/
    C[A[j]]++;
  }
  for(i = 1;i <= VMAX;i++){      /*i以下の数の出現数を記録する*/
    C[i] = C[i] + C[i-1];
  }
  for(j = 1;j <= n;j++){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

}



Measured memory_bytes: 9200
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <numeric>
#include <queue>
using namespace std;

int64_t min(int64_t a,int64_t b) {
    if (a > b)
    {
        return b ;
    }else
    {
        return a ;
    }
}

int main(){
    int n ;
    int64_t d ;
    cin >> n >> d ;
    int64_t x,y ;
    int ans = 0 ;
    for (size_t i = 0; i < n; i++)
    {
        cin >> x >> y ;
        if (x*x + y*y <= d*d)
        {
            ans ++ ;
        }
        
    }
    cout << ans << endl ;
}


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

int main(){
  int n;
  cin >>n;
  string s;
  cin >>s;
  int cnt = 0;
  int curMax = 0;
  rep(i,n){
    if(s[i]=='I') cnt++;
    if(s[i]=='D') cnt--;
    curMax = max(curMax, cnt);
  }
  cout << curMax << endl;
  return 0;
}

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

int min(p,o){
  if(p<o) return p;
  else return o;
}

int main(){
  int n,p[101],m[101][101];
  scanf("%d",&n);
  int i;
  for(i=1;i<=n;i++){
    scanf("%d %d",&p[i-1],&p[i]);
  }
  for(i=1;i<=n;i++){
    m[i][i]=0;
  }
  int j;
  int k;
  int l;
  for(j=2;j<=n;j++){
    for(i=1;i<=n-j+1;i++){
      l = i + j - 1;
      m[i][l] = 2147483647;
      for (k=i;k<=l-1;k++){
        m[i][l]=min(m[i][l],m[i][k] + m[k+1][l] + p[i-1]*p[k]*p[l]);
      }
    }
  }
  printf("%d\n",m[1][n]);
  return 0;
}

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

int main()
{
	int n, x;
	int num[101];
	int count = 0;
	int sum = 0;

	scanf("%d %d", &n, &x);

	for (int i = 0; i < n; i++)
	{
		scanf("%d", &num[i]);
		sum += num[i];
		if (sum > x)
			break;
		count++;
	}

	printf("%d", count+1);

	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>


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


int N;
int C[100][100];
bool D[100][100] = {0};
bool from[100] = {0};
bool to[100] = {0};

int main() {
    cin >> N;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            cin >> C[i][j];
        }
    }

    vector<P> v;
    for (int i = 0; i < N; ++i) {
        for (int j = i + 1; j < N; ++j) {
            v.push_back(P(C[i][j] - C[j][i], make_pair(i, j)));
            v.push_back(P(C[j][i] - C[i][j], make_pair(j, i)));
        }
    }

    sort(v.begin(), v.end(), greater<P>());

    ll ans = 0;
    int cnt = 0;
    //cout << v.size() << endl;
    for (P p : v) {
        //if (cnt == N - 1) break;
        int i = p.second.first;
        int j = p.second.second;
        //cout << i << " " << j << "  " << p.first;
        if (!from[i] && !to[j] && cnt < N - 1 && !D[i][j]) {
            from[i] = true;
            to[j] = true;
            ans += C[j][i];
            
            cnt++;
           // cout << " " << "*";
        } else if (!D[i][j]){
            ans += min(C[j][i], C[i][j]);
            //cnt++;
        }
        D[i][j] = true;
        D[j][i] = true;
    }
    //cout << cnt << endl;

    //for (int i = 0; i < N; ++i) {
    //    for (int j = i + 1; j < N; ++j) {
    //        if (!D[i][j]) {
    //            ans += min(C[i][j], C[j][i]);
    //            cnt++;
    //        }
    //    }
    //}

    //cout << cnt << endl;

    cout << ans << endl;


}


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

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORTASC(c) sort((c).begin(),(c).end())
#define SORTDESC(c,t) sort((c).begin(),(c).end(), std::greater<t>());
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define VMAX(a) *max_element(ALL(a))
#define VMIN(a) *min_element(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double PI  = acos(-1.0);

using ll = long long;
using namespace std;

int main() {
    ll n, a, b;

    cin >> n >> a >> b;

    ll ct = 0;
    ll diff = b-a;
    if (diff%2 == 0){
        ct = diff/2;
    } else if (a-1 < n-b){
        ct = a + diff/2;
    } else {
        ct = n-b+1 + diff/2;
    }

    cout << setprecision(20) << ct << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Map;
import java.util.HashMap;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.nextInt();
            Map<Integer, Integer> rc = new HashMap<>();

            for (int i = 0; i < n; i++) {
                int r = in.nextInt() / 400;
                rc.put(r, rc.getOrDefault(r, 0) + 1);
            }

            int min = 0;
            int max = 0;

            for (int r : rc.keySet()) {
                if (r < 8)
                    min++;
                else
                    max += rc.get(r);
            }

            max += min;
            min = min == 0 ? 1 : min;
            out.printf("%d %d\n", min, max);
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (bufPointer >= bufLength) {
                if (bufLength == -1)
                    throw new InputMismatchException();

                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (bufLength <= 0)
                    return -1;
            }
            return buffer[bufPointer++];
        }

        private static boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public long nextLong() {
            long n = 0;

            int b = readByte();
            while (isSpaceChar(b))
                b = readByte();

            boolean minus = (b == '-');
            if (minus)
                b = readByte();

            while (b >= '0' && b <= '9') {
                n *= 10;
                n += b - '0';
                b = readByte();
            }

            if (!isSpaceChar(b))
                throw new NumberFormatException();

            return minus ? -n : n;
        }

        public int nextInt() {
            long n = nextLong();

            if (n < Integer.MIN_VALUE || n > Integer.MAX_VALUE)
                throw new NumberFormatException();

            return (int) n;
        }

    }
}



Measured memory_bytes: 21460
#include<stdio.h>
int main() {
	int i = 1;
	int x, y;

	for (i = 1; 1; i++) {
		scanf("%d %d", &x, &y);
		if (x == 0 && y == 0) break;

		int temp;
		if (x > y) {
			temp = y;
			y = x;
			x = temp;
		}
		printf("%d %d\n", x, y);

	}
	return 0;

}

Measured memory_bytes: 596
#include <stdio.h>
#include <math.h>
double gradient(double a[], double b[]) {
	if (a[0] - b[0] == 0.0)
		return FP_INFINITE;
	return (a[1] - b[1]) / (a[0] - b[0]);
}
int main() {
	double p[8];
	int n;
	scanf(" %d", &n);
	while (n--) {
		scanf(" %lf %lf %lf %lf %lf %lf %lf %lf",
				&p[0], &p[1], &p[2], &p[3], &p[4], &p[5], &p[6], &p[7]);
		
		if (gradient(p, p + 2) == gradient(p + 4, p + 6))
			puts("YES");
		else
			puts("NO");
	}
	return 0;
}

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

using namespace std;

typedef long long ll;

int main(){
	ll t;
    t=1;
  	while(t--){
      ll a,b;
      cin>>a>>b;
      if(a>b){
        for(int i=0;i<a;i++){
        	cout<<b;
        }
      }else{
        for(int i=0;i<b;i++){
        	cout<<a;
        }
      }
      cout<<endl;
    }
    return 0;
}

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

using ll = long long;
using namespace std;
constexpr ll inf = 1e15;
constexpr ll mod = 1e9+7;

#define MAX 100001
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;
    }
}

// 二項係数計算
long long 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;
}

ll Perm(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % mod;
}

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

    COMinit();

    int N, M;
    cin>>N>>M;
    if (abs(N - M) >= 2) cout<<0<<endl;
    else if (N == M) {
        ll p = fac[N];
        cout<<(2*p*p)%mod<<endl;
    } else cout<<(fac[N]*fac[M])%mod<<endl;
    
    return 0;
}

Measured memory_bytes: 2560
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>

#define N 100005
#define M 6000005

#define ls tree[t].l
#define rs tree[t].r
#define mid ((l+r)>>1)

#define pb push_back

using namespace std;

long long ans;

int n,F,Rank[N*2],G[N],sa[N],High[N],i,j,k,m,sum[N],trk[N],p,tot,bl[N];

char s[N*2];

void Sort()
{
	int i;
	memset(sum,0,sizeof(sum));
	for (i=1;i<=n;++i) sum[Rank[i+j]]++;
	for (i=1;i<N;++i) sum[i]+=sum[i-1];
	for (i=n;i;--i) G[sum[Rank[i+j]]--]=i;
	memset(sum,0,sizeof(sum));
	for (i=1;i<=n;++i) sum[Rank[i]]++;
	for (i=1;i<N;++i) sum[i]+=sum[i-1];
	for (i=n;i;--i) sa[sum[Rank[G[i]]]--]=G[i];
}

void get_sa()
{
	for (i=1;i<=n;++i) trk[i]=s[i];
	for (i=1;i<=n;++i) sum[trk[i]]++;
	for (i=1;i<N;++i) sum[i]+=sum[i-1];
	for (i=n;i;--i) sa[sum[trk[i]]--]=i;
	for (Rank[sa[1]]=1,p=1,i=2;i<=n;++i)
	{
		if (trk[sa[i-1]]!=trk[sa[i]]) ++p;
		Rank[sa[i]]=p;
	}
	for (j=1;j<=n;j<<=1)
	{
		Sort();
		trk[sa[1]]=1;
		for (i=2,p=1;i<=n;++i)
		{
			if (Rank[sa[i]]!=Rank[sa[i-1]]||Rank[sa[i]+j]!=Rank[sa[i-1]+j]) ++p;
			trk[sa[i]]=p; 
		}
		for (i=1;i<=n;++i) Rank[i]=trk[i];
	}
}

void get_high()
{
	int i,j;
	for (i=1,j=0;i<=n;++i)
	{
			if (Rank[i]==1) continue;
			while (s[i+j]==s[sa[Rank[i]-1]+j]) ++j;
			High[Rank[i]]=j;
			if (j) --j;
	}
}
inline int read()
{
	int x,f; char c;
	while (c=getchar(),(c<'0'||c>'9')&&c!='-');
	if (c=='-') f=1,c=getchar(); else f=0;
	x=c-'0';
	while (c=getchar(),c>='0'&&c<='9') x=(x<<1)+(x<<3)+c-'0';
	return f?-x:x;
}


int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	get_sa(); 
	get_high();
	memset(sum,0,sizeof(sum));
	for (i=1;i<=n;++i) sum[High[i]]++;
	for (i=1;i<=n;++i) sum[i]+=sum[i-1];
		int ans=0;
	for (i=1;i<=n;++i) ans=max(ans,sum[i-1]-(i-1));
	printf("%d\n",ans);
}


Measured memory_bytes: 2816
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using ll = long long;
#define rep(i, n) for(ll i = 0; i < n; i++)
using namespace std;

const ll mod = 1000000007;
int main(){
  ll n, m;
  cin >> n >> m;
  vector<bool> a(n+1, true);
  rep(i, m){
    ll x;
    cin >> x;
    a[x] = false;
  }
  vector<ll> dp(n+1, 0);
  dp[0] = 1;
  rep(i, n){
    if (a[i+1]) dp[i+1] = (dp[i] + dp[i+1]) % mod;
    if (i == n-1) break;
    if (a[i+2]) dp[i+2] = (dp[i] + dp[i+2]) % mod;
  }
  cout << dp[n] << endl;
  
  return 0;
}

Measured memory_bytes: 4072
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    long a, v, b, w, t;
    long d, dv;
    cin >> a >> v >> b >> w >> t;

    d = abs(b - a);
    dv = v - w;
    if(dv <= 0 && a != b){
        cout << "NO" << endl;
    }else{
        if((double)d / dv <= t){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3632
L=[0]*10000
X=int(input())
for i in range(10000):
  L[i]=pow(i,5)
for i in range(10000):
  for j in range(10000):
    if L[i]-L[j]==X:
      print(i,j)
      exit()
    if L[i]+L[j]==X:
      print(i,-j)
      exit()
    


Measured memory_bytes: 9456
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <string>
#include <algorithm> 
#include <set>
#include <sstream>
#include <bit>
#include <time.h>
#include <bitset>
#include <iomanip>
#include <queue>
typedef long long int ll;
using namespace std;

int main() {
	string S; cin >> S;
	int n = S.length();
	int m = (n - 1) / 2;
	int l = m / 2;
	bool ans = true;
	for (int i = 0; i < m; i++) {
		if (S[i] == S[n - i - 1])continue;
		ans = false;
	}

	for (int i = 0; i < l; i++) {
		if (S[i] == S[m - i - 1])continue;
		ans = false;
	}
	if (ans) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 2988
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }
inline long long tonum(string s) {long long v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string tostr(T x) {ostringstream sout;sout<<x;return sout.str();}



int n, m;
string str;

int main() {
    while (cin >> n >> m) {
        if (n == 0) break;
        vint res(n);
        for (int i = 1; i <= n; ++i) res[i-1] = i;
        
        int mem = 0;
        for (int i = 1; i <= m; ++i, mem = (mem+1)%res.size()) {
            string ans = "";
            if (i % 3 == 0) ans += "Fizz";
            if (i % 5 == 0) ans += "Buzz";
            if (i % 3 != 0 && i % 5 != 0) ans = tostr(i);
            
            cin >> str;
            if (res.size() == 1) continue; 
            if (ans != str) res.erase(res.begin()+mem--);
        }
        for (int i = 0; i < res.size(); ++i) {
            cout << res[i];
            if (i != res.size()-1) cout << " ";
        }
        cout << endl;
    }
    
    return 0;
}


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

using i64 = long long;
using P = pair<i64, i64>;

#define overload3(_1, _2, _3, name, ...) name
#define rep1(i, n) for(i64 i = 0LL; i < (n); ++i)
#define rep2(i, a, b) for(i64 i = (a); i < (b); ++i)
#define rep(...) overload3(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define all(v) v.begin(), v.end()

i64 gcd(i64 a, i64 b){
    //
    if(a < b) swap(a, b);
    if(a % b == 0) return b;
    else return gcd(b, a % b);
}

void solve(long long N, std::vector<long long> A){
    vector<i64> g(N), c(N);
    g[0] = A[0]; c[N - 1] = A[N - 1];
    rep(i, 1, N) g[i] = gcd(g[i - 1], A[i]);
    for(int i = N - 2; i >= 0; --i) c[i] = gcd(c[i + 1], A[i]);
    i64 ans = max(g[N - 2], c[1]);
    rep(i, 1, N - 1) ans = max(ans, gcd(g[i - 1], c[i + 1]));
    cout << ans << endl;
}

struct IoSetup {
    IoSetup() {
        // cin.tie(nullptr);
        // ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 10000000000000009
//#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl


signed main(){
    string S;
    cin >> S;
    int N=S.size();
    int r=0,b=0;
    REP(i,N){
        if(S[i]=='0'){
            r++;
        }else{
            b++;
        }
    }
    int c=abs(r-b);
    cout << N-c << endl;
    return 0;
}

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

struct p {
	int c, num;

	bool operator<(const p& right)const {
		return c < right.c;
	}
};

int n, k, a[200000];
int num[200001], ans = 0;
vector<p> piar;

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

	for (int i = 1; i <= n; i++) {
		if (num[i]) {
			piar.push_back(p{ num[i], i });
		}
	}
	sort(piar.begin(), piar.end());

	for (int i = 0; i < piar.size();i++) {
		if (k >= piar.size() - i)break;
		ans += piar.at(i).c;
	}

	cout << ans << endl;
}

Measured memory_bytes: 3956
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val ab = (1..n).map { readLine()!!.split(" ").map { it.toLong() } }.reversed()

    var sum = 0L
    ab.map {
        val (a,b) = it
        val num = sum+a
        val inc = if(num%b==0L) 0 else b-num%b
        sum += inc
        inc
    }.sum().let { println(it) }
}

Measured memory_bytes: 65996
import re

class Solver:
    def __init__(self, num):
        self.n = num
        self.ans = 0

        # Case 0: 文字列中にABが含まれている
        self.case_0 = 0

        # Case 1: 文字列が"B***A"
        self.case_1 = 0

        # Case 2: 文字列が"B***-"
        self.case_2 = 0

        # Case 3: 文字列が"-***A"
        self.case_3 = 0

        # Case 4: 文字列が"-***-"
        # そもそもカウントする必要がない
        # self.case_4 = 0

        self.solve()
    
    def solve(self):
        for i in range(self.n):
            sen = input()
            if sen.find("AB") != -1:
                for m in re.finditer(r"AB", sen):
                    self.case_0 = self.case_0 + 1
            if sen[0] == "B" and sen[-1] == "A":
                self.case_1 = self.case_1 + 1
            elif sen[0] == "B" and sen[-1] != "A":
                self.case_2 = self.case_2 + 1
            elif sen[0] != "B" and sen[-1] == "A":
                self.case_3 = self.case_3 + 1
    

        if self.case_1 == 0:
            self.ans = self.ans + min(self.case_3, self.case_2)
        else:
            if self.case_3 + self.case_2 > 0:
                self.ans = self.ans + self.case_1 + min(self.case_3, self.case_2)
            elif self.case_3 + self.case_2 == 0:
                self.ans = self.ans + self.case_1 - 1

        self.ans = self.ans + self.case_0

        print(str(self.ans))

def main():
    n=int(input())
    Solver(n)



if __name__ == "__main__":
    main()

Measured memory_bytes: 3188
//To compile : type "$     g++ test.cpp -std=c++14 -I .    "
#include <atcoder/lazysegtree>
#include <bits/stdc++.h>
//#include <chrono>
//#pragma GCC optimize("Ofast")
using namespace std;
using namespace atcoder;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
//string S;
typedef pair<ll, ll> P;
const ll INF = (1LL<<60);
template <long long mod > class modint{
public:
    ll x;
    const static unsigned long long mod_plus = (LLONG_MAX / mod) * mod;
    constexpr modint(){x = 0;}
    constexpr modint(ll _x) : x(_x < 0 ? ((_x += mod_plus) < 0 ? _x + mod_plus : _x) : _x){
        if(x >= mod) x %= mod;
    }
    constexpr modint operator-(){
        return x == 0 ? 0 : mod - x;
    }
    constexpr modint& operator+=(const modint& a){
        if((x += a.x) >= mod) x -= mod;
        return *this;
    }
    constexpr modint operator+(const modint& a) const{
        return modint(*this) += a;
    }
    constexpr modint& operator-=(const modint& a){
        if((x -= a.x) < 0) x += mod;
        return *this;
    }
    constexpr modint operator-(const modint& a) const{
        return modint(*this) -= a;
    }
    constexpr modint& operator*=(const modint& a){
        (x *= a.x)%=mod;
        return *this;
    }
    constexpr modint operator*(const modint& a) const{
        return modint(*this) *= a;
    }
    constexpr modint pow(unsigned long long pw) const{
        modint res(1), comp(*this);
        while(pw){
            if(pw&1) res *= comp;
            comp *= comp;
            pw >>= 1;
        }
        return res;
    }
    //以下、modが素数のときのみ
    constexpr modint inv() const{
        return modint(*this).pow(mod - 2);
    }
    constexpr modint& operator/=(const modint &a){
        (x *= a.inv().x)%=mod;
        return *this;
    }
    constexpr modint operator/(const modint &a) const{
        return modint(*this) /= a;
    }
};
#define mod1 998244353
using mint = modint<mod1>;

ostream& operator<<(ostream& os, const mint& a){
    os << a.x;
    return os;
}
using vm = vector<mint>;

struct S {
	mint x;
	int n;
	S(mint _x = 0, int _n = 0) : x(_x), n(_n){}
};

struct F {
	mint a, b;
	F(mint _a = 1, mint _b = 0) : a(_a), b(_b){}
};

S op(S s, S t){
	return S(s.x + t.x, s.n + t.n);
}

S e(){ return S(); }

S mapping(F f, S s){
	return S(f.a * s.x + f.b * s.n, s.n);
}

F composition(F f, F g){
	return F(f.a * g.a, f.a * g.b + f.b);
}

F id(){ return F(); }

int main() {
	cin>>N>>Q;
	vector<S> a(N);
	rep(i, N){
		scanf("%lld", &A);
		a[i] = S(A, 1);
	}
	lazy_segtree<S, op, e, F, mapping, composition, id> seg(a);
	rep(_, Q){
		int t, l, r, b, c;
		scanf("%d%d%d", &t, &l, &r);
		if(t == 0){
			scanf("%d%d", &b, &c);
			seg.apply(l, r, F(b, c));
		}else{
			printf("%lld\n", seg.prod(l, r).x.x);
		}
	}
}

Measured memory_bytes: 35708
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PI 3.1415926535897932384626433832795
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
long long MOD = 1e9+7;
pair<int,int> dx[4] = {{1,0},{-1,0},{0,1},{0,-1}};
const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
struct chash {int operator()(int x) const { return x ^ RANDOM; }};
string toString(long long x){stringstream ss;ss << x;string str = ss.str();return str;}
long long fastpow(long long x,long long k){if(!k)return 1;if(k & 1)return ((x * fastpow(x,k-1) % MOD) % MOD) % MOD;
long long ans = fastpow(x,k/2);ans %= MOD;ans *= ans;ans %= MOD;return ans;}
long long sumF(long long x){int s = 0;while(x)s += x%10,x /= 10;return s;}
bool isS(char c){return (c >= 'a' && c <= 'z');}
bool isB(char c){return (c >= 'A' && c <= 'Z');}
bool isD(char c){return (c >= '0' && c <= '9');}
bool isSqrt(long long x){ long long f = sqrt((long double)x + 0.5); return f*f == x;}
bool isCubic(long long x) {long long f = cbrt((long double)x + 0.5); return f*f*f == x;}
long long lcm(long long a,long long b){return a * (b / __gcd(a,b));}
vector<long long> divVec(long long x){vector<long long> tmp;for(long long i = 2;1LL*i*i <= x;i++){if(x % i == 0){tmp.push_back(i);if(x / i != i)
tmp.push_back(x / i);}}sort(tmp.begin(),tmp.end());return tmp;}
long long countDiv(long long L,long long R,long long C){return ((R/C) - ((L-1)/C));}
int main()
{
    IO;
    int n;
    cin >> n;
    vector<pair<int,int> > myVec(n);
    for(int i = 0;i < n;i++)
        cin >> myVec[i].second >> myVec[i].first;
    sort(myVec.begin(),myVec.end());
    long long cur_time = 0;
    for(int i = 0;i < myVec.size();i++)
    {
        if(myVec[i].second + cur_time > myVec[i].first)
        {
            cout << "No";
            return 0;
        }
        cur_time += myVec[i].second;
    }
    cout << "Yes";
    return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] A = new int[N+1];	// i町の敵の数
    int[] B = new int[N];	// 各勇者の倒せる敵の数
    
    for(int i=0; i<N+1; i++){
      A[i] = sc.nextInt();
    }
    for(int i=0; i<N; i++){
      B[i] = sc.nextInt();
    }

    long cnt = 0;
    for(int i=0; i<N; i++){
      int rem1 = A[i] - B[i];
      if (B[i] > A[i]){
        cnt += A[i];
        B[i] -= A[i];
        int rem2 = A[i+1] - B[i];
        if (B[i] > A[i+1]){
          cnt += A[i+1];
          A[i+1] = 0;
        } else {
          cnt += B[i];
          A[i+1] = rem2;
        }
      } else {
      	cnt += B[i];
      }
    }
    
    System.out.print(cnt);
    sc.close();
		
  }
}

Measured memory_bytes: 65620
A,B=map(int, input().split())

# if A==B:
# 	print(A)
# 	exit(0)
# ans=A^(A+1)
# for i in range(A+2,B+1):
# 	ans=ans^i
# print(ans)

# A,B=0,456

# if A==B:
# 	print(A)
# 	exit(0)
# ans=A^(A+1)
# print(1, bin(ans))
# for i in range(A+2,B+1):
# 	ans=ans^i
# 	print(i, bin(ans))

if A==B:
	print(A)
	exit(0)

def func(c):
	if c%2==1:
		if c%4==1:
			return 1
		else:
			return 0
	else:
		if (c-1)%4==1:
			return 1^c
		else:
			return 0^c
print(func(A-1)^func(B))


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

vector<int> a(3);
vector<int> b(3);

vector<vector<int> > c(3, vector<int>(3, 0));

bool ans = true;

int main() {
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j)
        {
            cin >> c.at(i).at(j);
        }
    }

    a.at(0) = 0;

    for (int j = 0; j < 3; ++j)
    {
        b.at(j) = c.at(0).at(j) - a.at(0);
    }

    for (int i = 1; i < 3; ++i)
    {
        a.at(i) = c.at(i).at(0) - b.at(0);
        for (int j = 1; j < 3; ++j)
        {
            if (c.at(i).at(j) - b.at(j) != a.at(i)) ans = false;
        }
    }
    
    if (ans)
    {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

ll N;
ll *h;
ll ret = 0;

void input(){
    cin >> N;
    h = (ll *)(malloc(sizeof(ll) * N));
    for(ll i=0;i<N;i++){
        cin >> h[i];
    }
}

void solve(){
        bool flg;
        for(ll j=1;j<110;j++){
            flg = false;
            for(ll i=0;i<N;i++){
                if(flg){
                    if(h[i]<j){
                        ret++;
                        flg = false;
                    }
                }else{
                    if(h[i]>=j){
                        flg = true;
                    }
                }
            }
            if(flg){
                ret++;
            }
        }
}

int main(void){
    // Your code here!
    input();
    solve();
    cout << ret << endl;
}


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

using namespace std;

int main() {
	int n;
	ios::sync_with_stdio(0);
	cin >> n;
	int ans = 0;
	for(int i = 1 ; i < n ; i++) {
		int d = i;
		for(int j = 1 ; j * j <= d ; j++) {
			if(d % j == 0 ) {
				if(d / j == j) {
					ans++;
				}
				else ans += 2;
			} 
		}
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 3604