akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long int ll;
const ll N=50+10,inf=1e18;
ll n,m=50,k,ans,re=0,t[N],a[N],b[N],dp[N][N];
 
int main()
{
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    t[0]=1;
    for(int i=1; i<=m; i++) t[i]=2*t[i-1];
    for(int i=0; i<=m; i++)
        for(int j=0; j<=m; j++)
        {
            if(i==j) dp[i][i]=0;
            else
                dp[i][j]=inf;
            //cout << "Start " << i << ' ' << j << endl;
            for(int k=1; k<=m; k++)
            {
                dp[i][j]=min(dp[i][j],dp[i%k][j]+t[k]);
                //cout << "ch: " << dp[i%k][j] << ' ' << t[k] << endl;
            }
            //cout << i << ' ' << j << ' ' << dp[i][j] << endl;
        }
    cin >> n;
    for(int i=1; i<=n; i++)
        cin >> a[i];
    for(int i=1; i<=n; i++)
        cin >> b[i];
    for(int i=1; i<=n; i++)
    {
        if(2*b[i]>=a[i] && b[i]!=a[i])
        {
            cout << -1;
            return 0;
        }
        ans=max(ans,dp[a[i]][b[i]]);
    }
    while(ans)
    {
        k=0;
        //cout << "Start " << ans << ' ' << endl;
        for(int i=1; i<=50; i++)
            if(ans&t[i]) k=i;
        //cout << "so we find : " << k << endl;
        re+=t[k];
        t[k]=0;
        for(int i=0; i<=m; i++)
            for(int j=0; j<=m; j++)
            {
                if(i==j) dp[i][i]=0;
                else
                    dp[i][j]=inf;
                for(int k=1; k<=m; k++)
                    dp[i][j]=min(dp[i][j],dp[i%k][j]+t[k]);
            }
        ans=0;
        for(int i=1; i<=n; i++)
            ans=max(ans,dp[a[i]][b[i]]);
    }
    cout << re;
}

Measured memory_bytes: 256
/*
*          Name : chaitanya
*
*     Institute : ANITS,Visakhapatnam
*
*/
#include<cstdio>
#include<iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include<cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define inf  1000000000
#define all(x) begin(x),end(x)
#define ll long long int
#define ff first
#define ss second
#define pb push_back
const ll mod = 1000000007;
#pragma GCC optimization ("O3")
const int N = 100005;
using namespace std;

int main()
{
 
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n,c = 0;
  cin >> n;
  vector <int> v(n);
  for (int i = 0; i < n; ++i)
  {
    cin >> v[i];
  }
  sort(v.begin(),v.end());
  for (int i = n-1; i >= 1; i--)
  {
    int l =0,r = i-1;
    while(l < r)
    {
      if(v[l] + v[r] > v[i])
      {
        c += r-l;
        r--;
      }
      else
        l++;
    }
  }
  cout << c;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.Collections;
public class Program {
  public static void Main() {
    int[] NMC = ReadIntArray();
    int[] B = ReadIntArray();
    int res = 0;
    for (int i = 0; i < NMC[0]; i++) {
      int[] A = ReadIntArray();
      int temp = 0;
      for (int j = 0; j < NMC[1]; j++) {
        temp += A[j] * B[j];
      }
      temp += NMC[2];
      if (temp > 0) {
        res++;
      }
    }
    Console.WriteLine(res);
  }

  private static string ReadStr() { return Console.ReadLine(); }
  private static int ReadInt() { return int.Parse(Console.ReadLine()); }
  private static double ReadDouble() { return double.Parse(Console.ReadLine()); }
  private static long ReadLong() { return long.Parse(Console.ReadLine()); }
  private static char ReadChar() { return Console.ReadLine()[0]; }
  private static string[] ReadStringArray() { return Console.ReadLine().Split(' '); }
  private static int[] ReadIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
  private static double[] ReadDoubleArray() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
  private static long[] ReadLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
  private static char[] ReadCharArray() { return Console.ReadLine().ToArray(); }
  private static string[] ReadCharStringArray() { return Console.ReadLine().ToCharArray().Select(c => c.ToString()).ToArray(); }
}


Measured memory_bytes: 13268
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (2e9)
#define INFL (2e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
using vint=vector<int>;
using vll=vector<ll>;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
    int k, s; cin >> k >> s;
    int ans = 0;
    rep(x, k+1){
        rep(y, k+1){
            if(s - x - y >= 0 && s - x - y <= k) ans++;
        }
    }

    pr(ans);
    return 0;}

Measured memory_bytes: 3684
k,n=map(int,input().split())
a=list(map(int,input().split()))
d=0
for i in range(n):
    if i==0:
        res=abs(a[0])+k-a[n-1]
        #print(d)
    if 1<=i:
        d=abs(a[i]-a[i-1])
        #print(d,res)
        res=max(d,res)

print(k-res)

Measured memory_bytes: 26444
#define max(x,y)((x)>(y)?(x):(y))
D[1000][1000],a[1000][1000];
n,h,r;
main(){
	for(;scanf("%d",&n),n;){
		memset(D,0,sizeof(D));
		memset(a,0,sizeof(a));
		for(;n--;){
			scanf("%d%d",&h,&r);
			a[h][r]=1;
		}
		scanf("%d",&n);
		for(;n--;){
			scanf("%d%d",&h,&r);
			a[h][r]=1;
		}
		for(h=1;h<1000;h++){
			for(r=1;r<1000;r++)
				D[h][r]=max(max(D[h-1][r],D[h][r-1]),D[h-1][r-1]+a[h][r]);
		}
		printf("%d\n",D[999][999]);
	}
	exit(0);
}

Measured memory_bytes: 8220
#include<stdio.h>
int main()
{
    int n,a,b,c;
    scanf("%d %d %d",&n, &a, &b);
  c=n*a;
    if(c<b){
        printf("%d",c);
    }else{
        printf("%d",b);
    }
    return 0;
}
    

Measured memory_bytes: 128
import java.util.*;
fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    println(ans(n))
}

fun ans(n:Int):String{
    for(i in 1..9){
        for(j in 1..9){
            if(i*j==n){
                return "Yes"
            }
        }
    }
    return "No"
}

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

const long long mod = 1e9 + 7;

struct BinomialCoefficient {
  vector<long long> fac, finv, inv;

  BinomialCoefficient(int N) : fac(N), finv(N), inv(N) {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for ( int i = 2; i < N; 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 combination(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;
  }
};

int main() {
  int n, k;
  cin >> n >> k;
  BinomialCoefficient BC(n+1);
  long long a[n];
  for ( int i = 0; i < n; i++ ) { cin >> a[i]; }
  sort(a, a+n);

  long long max_sum = 0;
  for ( int i = 0; i < n; i++ ) {
    if ( i < k-1 ) { continue; }
    max_sum = (max_sum + (BC.combination(i, k-1) * a[i]) % mod) % mod;
  }
  long long min_sum = 0;
  for ( int i = 0; i < n; i++ ) {
    if ( n-i-1 < k-1 ) { continue; }
    min_sum = (min_sum + (BC.combination(n-i-1, k-1) * a[i]) % mod) % mod;
  }

  long long ans = (max_sum - min_sum) % mod;
  ans = (ans + mod) % mod;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6328
import heapq
N, K = map(int, input().split())
dt = []
for i in range(N):
	t, d = map(int, input().split())
	dt.append((d, t))
dt.sort()
dt.reverse()
dic = {}
can_delete = []
dp = 0
x = 0
for i in range(K):
	d, t = dt[i]
	dp += d
	if t in dic:
		heapq.heappush(can_delete, d)
	else:
		dic[t] = d
		x += 1
ans = dp + x * x
v = ans
for i in range(K, N):
	if len(can_delete) == 0:
		break
	d, t = dt[i]
	if t in dic:
		continue
	dic[t] = d
	x += 1
	v = v - heapq.heappop(can_delete) + d + 2 * x - 1
	if v > ans:
		ans = v
print(ans)

Measured memory_bytes: 63832
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int N,M;
  cin >> N >> M;
  priority_queue<int,vi> pq;
  rep(i,N) {
    int x;
    cin >> x;
    pq.push(x);
  }
  rep(i,M) {
    int x = pq.top();
    pq.pop();
    pq.push(x/2);
  }
  ll ans = 0;
  rep(i,N) {
    ans += (ll)pq.top();
    pq.pop();
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <limits.h>
#include <queue>
#include <algorithm>
#include <map>
#include <cstring>

using namespace std;

void print(int n,int *X){

  for(int i=0;i<n;i++){
    cout<<X[i];
    if(i!=n-1)cout<<" ";
  }
  cout<<endl;

}

void insertion_sort(int n,int *X){

  print(n,X);
  
  for(int i=1;i<n;i++){
    int v = X[i];
    int j=i-1;
    while(j>=0 && v<X[j]){
      X[j+1]=X[j];
      j--;
    }
    X[j+1] = v;
    print(n,X);
  }
}

int bubble_sort(int n, int *X){

  int ch=0;
  //bool flag=false;
  int j=0;
  
  while(j<n-1){
    
    for(int i=0;i<n-j-1;i++){
      if(X[i]>X[i+1]){
	swap(X[i],X[i+1]);
	ch++;
      }
    }
    j++;
  }
  print(n,X);
  return ch;
}


int main(){

  int A[101];
  int N;
  
  cin>>N;
  for(int i=0;i<N;i++)
    cin>>A[i];

  //insertion_sort(N,A);
  cout<<bubble_sort(N,A)<<endl;
  
  
 
  return 0;
}

Measured memory_bytes: 3084
rika=[]
for i in range(4):
    rika.append(int(input()))
a=min(rika)
rika.remove(a)
sum1=0
for i in range(3):
    sum1+=rika[i]
sya=[]
for i in range(2):
    sya.append(int(input()))
b=max(sya)
print(sum1+b)


Measured memory_bytes: 5600
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=1e5;
const int inf=1e9;
int main(){
	long N,K;cin>>N>>K;
	long H[N];
	rep(i,0,N) cin>>H[i];
	sort(H,H+N);
	if(N<=K) cout<<0<<endl;
	else{
        long ans=0;
        rep(i,0,N-K) ans+=H[i];
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef long long lng;
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORD(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) FOR(i,0,n-1)
#define ALL(a) (a).begin(), (a).end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end()) //ATTENTION: <a> must be sorted in advance

lng power(lng b, lng n) {lng sol=1; while(n>0) {if(n&1) {sol=sol*b;} n>>=1; b*= b;} return sol;} //calculate b^n

const int MOD = 1000000007; //10^9+7


/*********** variables ************/

/**********************************/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    string s;
    cin >> s;
    s[5] = ' ';
    s[5+8] = ' ';
    cout << s << endl;
}


Measured memory_bytes: 256
#! /usr/bin/env python3

n = int(input())

res = 1000000

for a in range(1, n):
    b = n - a

    s = 0

    al = list(str(a))
    for c in al:
        s += int(c)

    bl = list(str(b))
    for c in bl:
        s += int(c)

    if s < res:
        res = s

print(res)


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

int main() {
  vector<int>data(26);
  while(true){
    string s;
    cin >> s;
    if(s.size() == 0) break;
    for(int i = 0;i < s.size();i++){
      if(isalpha(s[i])){
        if(isupper(s[i])) s[i] = tolower(s[i]);
        data[s[i]-'a']++;
      }
    }
  }
  for(int i = 0;i < 26;i++){
    char a;
    a = 'a'+i;
    cout << a << " : " << data[i] << endl;
  }
}



Measured memory_bytes: 3172
n = gets.to_i
t, a = gets.chomp.split(' ').map(&:to_i)
h_arr = gets.chomp.split(' ').map(&:to_i)

temp_arr = h_arr.map{|x|
  (a - (t - x * 0.006)).abs
}
puts temp_arr.index(temp_arr.min)+1

Measured memory_bytes: 1788
#include <stdio.h>

int main()
{
	int i, N, b[101];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d", &(b[i]));
		
	int j, ans[101] = {};
	for (i = N; i >= 1; i--) {
		for (j = i; j >= 1; j--) if (b[j] >= j) break;
		if (b[j] > j) break;
		else {
			ans[i] = j;
			for (; j < i; j++) b[j] = b[j+1];
		}
	}
	if (i >= 1) {
		printf("-1\n");
		fflush(stdout);
		return 0;
	} else for (i = 1; i <= N; i++) printf("%d\n", ans[i]);
	fflush(stdout);
	return 0;
}

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

int main(){
    long double a, b;
    cin >> a >> b;
    cout((ll)floor(a * b));
}


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

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<double, double> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<string> &o) {
    string a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int main() {
    int n;
    cin >> n;
    ll ans = INF;

    rep(i, n) {
        ll a, b;
        cin >> a >> b;

        ll now = a + b;
        cmin(ans, now);
    }
    cout << ans << endl;
}


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

using namespace std;

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

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

  int sum = 0;
  for (int i = 0; i < k; ++i) {
    if (a > 0) {
      ++sum;
      --a;
    } else if (b > 0) {
      --b;
    } else {
      --sum;
    }
  }
  cout << sum << '\n';

  return 0;
}


Measured memory_bytes: 3640
//11
#include<iostream>
#include<set>
#include<map>

using namespace std;

int dik(map<string,map<string,int> > d,string s,string g){
  set<string> p;
  map<string,int> n;
  n[s]=0;
  for(int i=0;i<d.size();i++){
    int nm=1<<30;
    string ns;
    for(map<string,int>::iterator it=n.begin();it!=n.end();it++){
      if(!p.count(it->first)&&it->second<nm){
	nm=it->second;
	ns=it->first;
      }
    }
    p.insert(ns);
    for(map<string,int>::iterator it=d[ns].begin();it!=d[ns].end();it++){
      if(!n.count(it->first)||n[it->first]>n[ns]+d[ns][it->first]){
	n[it->first]=n[ns]+d[ns][it->first];
      }
    }
  }
  return n[g];
}

int main(){
  for(int n,m;cin>>n>>m,n|m;){
    string s,p,g;
    cin>>s>>p>>g;
    map<string,map<string,int> > d;
    for(int i=0;i<m;i++){
      string a,b;
      int dd,t;
      cin>>a>>b>>dd>>t;
      d[a][b]=dd/40+t;
      d[b][a]=dd/40+t;
    }
    cout<<dik(d,s,p)+dik(d,p,g)<<endl;
  }
  return 0;
}

Measured memory_bytes: 3796
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
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;}
const ll INF = 1LL << 60;

int main() {
    ll n, k; cin >> n >> k;
    vector<ll> a(n); rep(i, n) cin >> a[i];
    Rep(i, 0, n-k) {
        if(a[i] < a[i+k]) cout << "Yes" << endl;
        else cout << "No" << endl;
        //cout << a[i] << endl;
    }
}


Measured memory_bytes: 4840
#include<bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
const int mod = 998244353;
using ll = long long;
const ll inf = 1e18+5;
ll ff(ll n, ll m) {
	return (ll)(n*n)%m;
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll n, x, m;
	cin >> n >> x >> m;
	ll sum = 0, prev = x;
	bool zt = 0;
	set<int> c;
	vector<int> a;
	a.push_back(prev);
	c.insert(prev);
	for(ll i=0;i<n;i++) {
		sum+=prev;
		ll xx = ff(prev,m);
		if(xx == 0) {
			zt = 1;
			break;
		}
		if(c.count(xx)) {
			prev = xx;
			break;
		}
		else {
			c.insert(xx);
			a.push_back(xx);
			//sum+=xx;
		}
		prev = xx;
	}
	if(zt) {
		//zero term;
		cout<<sum;
		return 0;
	}
	debug()<<imie(a);
	int sz = (int)a.size();
	if(n <= (int)a.size()) {
		ll out = 0;
		for(int i=0;i<n;i++) {
			out+=a[i];
		}
		cout<<out;
		return 0;
	}	
	long long ans = sum;
	int st = -1;
	for(int i=0;i<sz;i++) {
		if(a[i] == prev) {
			st = i;
			break;
		}
	}
	n-=sz;
	ll sum2 = 0;
	for(int i=st;i<sz;i++) {
		sum2+=a[i];
	}	
	ll rev = sz-st;
	ans += (sum2 * (n/rev));
	n = n%rev;
	for(int i=st;i<(st+n);i++) {
		ans += a[i];
	}
	cout<<ans;
}


Measured memory_bytes: 5912
A, B, H, M =input().split()
A = float(A)
B = float(B)
H = float(H)
M = float(M)

short_angle = 360*(M/60)
long_angle = 360*H/12+30*(M/60)

theta = abs(short_angle-long_angle)
if theta>=180:
    theta = 360-theta

import math
distance = A**2 + B**2 - (2*A*B * math.cos(math.radians(theta)))
distance = abs(math.sqrt(distance))

print(distance)

Measured memory_bytes: 9396
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << ": " << endl
#define rep(i,n) for(int i=0; (i)<(n); ++(i))
#define rrep(i,n) for(int i=(n); (i)>0; --(i))
#define reps(i,s,n) for(int i=(s); (i)<(n); ++(i))
#define maxi(v) distance(v.begin(), max_element(v.begin(), v.end()))
#define mini(v) distance(v.begin(), min_element(v.begin(), v.end()))
#define lb(v,x) v[lower_bound(v.begin(), v.end(), x) - v.begin()]
#define ub(v,x) v[upper_bound(v.begin(), v.end(), x) - v.begin()]
template<class T> inline bool print(T& x){ cout << x << endl; return true; }
template<class T> inline bool print_(T& x){ cout << x << " "; return true; }
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; }
ll gcd(ll x, ll y){
  if(y==0) return x;
  else return gcd(y, x%y);
  }
const int INF = 1e9;
const ll llINF = 1LL<<60;
const int MOD = 1e9+7;
const double EPS = 1e-9;

int main(){
    string s; cin >> s;
    ll k; cin >> k;
    int ans;
    rep(i,k){
      if(s[i] == '1') ans=1;
      else { ans = (int)s[i]-48; break; }
    }
    
    cout << ans;
    
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int n,a[200000],i,j;
    scanf("%d",&n);
    for(i = 0; i < n; i++)scanf("%d",&a[i]);

    if(n % 2 == 0)
    {
        for (i = 0; i < n / 2; i++)
        {
            printf("%d ",a[n - 1 - i * 2]);
        }
        for (i = 0; i < n / 2; i++)
        {
            printf("%d ",a[i * 2]);
        }
    }
    else
    {
        for (i = 0; i < n / 2 + 1; i++)
        {
            printf("%d ",a[n - 1 - i * 2]);
        }
        for (i = 0; i < n / 2; i++)
        {
            printf("%d ",a[i * 2 + 1]);
        }
    }
    
}

Measured memory_bytes: 2816
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
#from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
#from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [LI()for i in range(n)]
inf = 10**17
mod = 10**9 + 7

n=I()
As=list(map(int,input().rstrip().split(" ")))
#A=list(reversed(As))
#print(As)
ans=[0 for i in range(n)]
for i in range(n//2,n):
    ans[i]=As[i]
#print(ans)
for j in range(n//2):
    k=n//2-j-1
    ball=0
    for l in range(2,n//(k+1)+1):
        ball+=ans[(k+1)*l-1]
        if ball%2==As[k]:
            ans[k]=0
        else:
            ans[k]=1
print(sum(ans))
for i in range(n):
    if ans[i]==1:
        print(i+1,end=" ")

Measured memory_bytes: 68816
import sys
from collections import defaultdict
from heapq import heappop, heappush

input = sys.stdin.readline

N, M = map(int, input().split())


class Graph(object):
    def __init__(self):
        self.graph = defaultdict(list)

    def __len__(self):
        return len(self.graph)

    def add_edge(self, src, dst, weight=1):
        self.graph[src].append((dst, weight))

    def get_nodes(self):
        return self.graph.keys()


class Dijkstra(object):
    def __init__(self, graph, start):
        g = graph.graph

        self.dist = defaultdict(lambda: float('inf'))
        self.dist[start] = 0
        self.prev = defaultdict(lambda: None)

        Q = []
        heappush(Q, (self.dist[start], start))

        while Q:
            dist_u, u = heappop(Q)
            if self.dist[u] < dist_u:
                continue
            for v, weight in g[u]:
                alt = dist_u + weight
                if self.dist[v] > alt:
                    self.dist[v] = alt
                    self.prev[v] = u
                    heappush(Q, (alt, v))

    def shortest_distance(self, goal):
        return self.dist[goal]

    def shortest_path(self, goal):
        path = []
        node = goal
        while node is not None:
            path.append(node)
            node = self.prev[node]
        return path[::-1]


g = Graph()
for i in range(M):
    a, b = map(int, input().split())
    g.add_edge(a - 1, b - 1)
    g.add_edge(b - 1, a - 1)
d = Dijkstra(g, 0)
if d.shortest_distance(N - 1) == 2:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')


Measured memory_bytes: 128276
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
a,b,c,d = iim()
if a+b < c+d:
    print('Right')
elif a+b > c+d:
    print('Left')
else:
    print('Balanced')

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
using namespace std;
typedef pair<int,int> P;
int main(void){
  int n,m,i,j,l,r,d,p[100010];
  bool vo[100010]={false},ans=true;
  vector<P> g[100010];
  set<int> s;
  cin >> n >> m;
  for (i=1;i<=n;i++) s.insert(i);
  for (i=0;i<m;i++){
    cin >> l >> r >> d;
    g[l].push_back(P(r,d));
    g[r].push_back(P(l,-d));
  }
  while (!s.empty()){
    queue<int> que;
    i=*s.begin();
    s.erase(i);
    p[i]=0;
    vo[i]=true;
    que.push(i);
    while (!que.empty()){
      int t=que.front();
      que.pop();
      for (j=0;j<g[t].size();j++){
        if (vo[g[t][j].first] && p[g[t][j].first]!=p[t]+g[t][j].second) break;
        if (!vo[g[t][j].first]){
          p[g[t][j].first]=p[t]+g[t][j].second;
          vo[g[t][j].first]=true;
          s.erase(g[t][j].first);
          que.push(g[t][j].first);
        }
      }
      if (j!=g[t].size()){
        ans=false;
        break;
      }
    }
    if (!ans) break;
  }
  if (ans) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

int main()
{
    string s;
    cin >> s;
    switch (s[s.size() - 1])
    {
    case '0':
    case '1':
    case '6':
    case '8':
        cout << "pon";
        break;
    case '3':
        cout << "bon";
        break;
    default:
        cout << "hon";
    }
    return 0;
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
#define ll long long
using namespace std;
signed main(){
  ll a,b,c,k;
  cin>>a>>b>>c>>k;
  if(k <= a){
    cout<<k<<"\n";
  }else if(k <= a+b){
    cout<<a<<"\n";
  }else{
    cout<<a + (b*0) + (k-a-b)*-1<<"\n";
  }
  return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
//思路：先dfs出一个??数?A，剩下的?成一个数?B，判断B数?是否??即可。
using namespace std;
int t[11];
int v[11];
void dfs(int x,int y)
{
    if(t[x]<t[y]&&y<10)
    {
        v[y]=1;
        dfs(y,y+1);
    }
    else if(t[x]>t[y]&&y<10)
    {
        dfs(x,y+1);
    }
}
int main()
{
    int n,flag=0;
    scanf("%d",&n);
    while(n--)
    {
        memset(t,0,sizeof(t));

        //初始化
        for(int i=0;i<10;i++)
            scanf("%d",&t[i]);
        for(int i=0;i<10;i++)//i<9??
        {
            memset(v,0,sizeof(v));
              v[i]=1;
             dfs(i,i+1);
          int aa=0;flag=0;
             for(int i=0;i<10;i++)
            {
                if(v[i]==0)
                {
                      if(aa>t[i])
                      {
                          flag=1;
                          break;
                      }
                      else
                        aa=t[i];
                }

            }
            if(flag==0)
            {
                cout<<"YES"<<endl;
                break;
            }

        }
            if(flag==1)
                cout<<"NO"<<endl;






    }
}

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

int main(){
    int N; cin >> N;
    map<string,int> A;
    
    for (int i=0; i<N; i++){
        string S; cin >> S;
        sort(S.begin(),S.end());
        A[S]++;
    }
    
    long long ans=0;
    for (auto p:A){
        long long x=p.second;
        ans+=x*(x-1)/2;
    }
    cout << ans;
}

Measured memory_bytes: 11136
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N,M = map(int,input().split())
AB = []
C = []
for _ in range(M):
    AB.append(tuple(int(i) for i in input().split()))
    C.append(sum(1<<(int(i)-1) for i in input().split()))

INF = 10**18
# dp[i]: 状態がbin(i)のときの費用の最小値
# bin(i)のj桁が1: j番目の宝箱を開けられる
# 1<<N == 2**N
dp = [INF] * (1<<N)

# 初期条件(全ての宝箱を開けられない)
dp[0] = 0

for i in range(1<<N):
    for (a,b),c in zip(AB,C):
        # 状態iで状態cにする鍵を買ったときの状態
        state = i | c
        dp[state] = min(dp[state], dp[i]+a)

answer = dp[-1]
if answer == INF:
    answer = -1
print(answer)

Measured memory_bytes: 42476
#include<iostream>
#include<bitset>
#include<algorithm>

int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int h,w,m; std::cin >> h >> w >> m;
  int br[300000];
  int bc[300000];
  int cntr[300000] = {};
  int cntc[300000] = {};
  int maxr=0,maxc=0;
  for(int i = 0; i < m; ++i){
    std::cin >> br[i] >> bc[i];br[i]--;bc[i]--;
    maxr = std::max(maxr,++cntr[br[i]]);
    maxc = std::max(maxc,++cntc[bc[i]]);
  }
  std::bitset<300000>r,c;
  int cr=0,cc=0,cntd=0;
  for(int i = (h<w?w:h)-1; i >= 0; --i){
    cr+=r[i] = maxr == cntr[i];
    cc+=c[i] = maxc == cntc[i];
  }
  cntd = cr*cc;
  for(int i = 0; i < m; ++i)
    cntd -= c[bc[i]]&r[br[i]];
  std::cout << maxr + maxc - (!cntd) << '\n';
}


Measured memory_bytes: 7920
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define INF 5000000000
#define MOD 1000000007
typedef long long  ll;

using namespace std;

int ans;

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

	string s;
	map<char,int> m;
	cin >> s;

	rep(i,s.size()){
		m[s[i]]++;
	}

	if(m.size() != 2){
		cout << "No" << endl;
	}
	else{
		for(auto p : m){
			if(p.second != 2){
				cout << "No" << endl;
				return 0;
			}
		}
		cout << "Yes" << endl;
	}
	return 0;
}


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

int main() {
    int X;
    cin >> X;
    int C;
    C = X / 100;
    if(C * 100 <= X && X <= C * 105){
        cout << 1 << endl;
        return 0;
    }
    cout << 0 << endl;
}

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

using ll = long long;

signed main(){
	ll n;
	cin >> n;

	ll x = (n/500);

	ll sum = 0;
	sum = sum + (x*1000);

	n = n-(x*500);

	ll k = (n/5);
	sum = sum + (k*5);

	cout << sum << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
constexpr Int MOD = 1e9 + 7;
Int dp[2001][2001];
int main()
{
    int N, M; cin >> N >> M;
    vector<int> S(N), T(M);
    for (auto &s : S) cin >> s;
    for (auto &t : T) cin >> t;
    map<int, vector<int>> MT;
    for (int i = 0; i < M; i++) {
        MT[T[i]].push_back(i+1);
    }
    for (int i = 0; i <= 2000; i++) {
        dp[0][i] = dp[i][0] = 1;
    }
    for (int i = 1; i <= N; i++) {
        map<pair<int, int>, int> memo;
        for (int j = 1; j <= M; j++) {
            dp[i][j] = dp[i-1][j];
            auto &v = MT[S[i-1]];
            int k = upper_bound(begin(v), end(v), j) - begin(v);
            if (k != 0) {
                Int val = (memo[make_pair(S[i-1], k-1)] + dp[i-1][v[k-1]-1]) % MOD;
                memo[make_pair(S[i-1], k)] = val;
                (dp[i][j] += val) %= MOD;
            }
        }
    }
    cout << dp[N][M] << '\n';
    return 0;
}


Measured memory_bytes: 31744
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int INF = 1001001001;

ll pow_mod(ll x, ll y) {
	ll res = 1;
	for (ll i = 0; i < y; i++) res = res * x % mod;
	return res;
}

int main() {
	int n;
	cin >> n;
	for (int i = 1; i < 10; i++) {
		for (int j = 1; j < 10; j++) {
			if (i * j == n) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> appear(10000,0);

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

  for(int i=0;i<n;i++){
    int sum = 0;
    for(int j=0;j<4;j++){
      if(i+j>=n)break;
      sum = sum*10 + d[i+j];
      appear[sum] = 1;
    }
  }

  for(int i=0;i<10000;i++){
    if(appear[i]==0){
      cout << i << endl;
      break;
    }
  }
}
  

Measured memory_bytes: 1240
package main

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

type node struct {
	value int
	left  int
	right int
}

func main() {
	sc := bufio.NewScanner(os.Stdin)

	sc.Scan()
	length, _ := strconv.Atoi(sc.Text())
	tree := make([]node, length)

	c := 0
	for sc.Scan() {
		inputs := strings.Split(sc.Text(), " ")

		switch inputs[0] {
		case "insert":
			num, _ := strconv.Atoi(inputs[1])
			tree[c] = node{value: num, left: -1, right: -1}
			if c != 0 {
				insert(tree, 0, c)
			}
			c++
		case "find":
			num, _ := strconv.Atoi(inputs[1])
			fmt.Println(find(tree, num, 0))
		case "print":
			printInorder(tree, 0)
			fmt.Println()
			printPreorder(tree, 0)
			fmt.Println()
		}
	}
}

func insert(tree []node, diffPoint int, nodePoint int) {
	if tree[diffPoint].value <= tree[nodePoint].value {
		if tree[diffPoint].right == -1 {
			tree[diffPoint].right = nodePoint
		} else {
			insert(tree, tree[diffPoint].right, nodePoint)
		}
	} else {
		if tree[diffPoint].left == -1 {
			tree[diffPoint].left = nodePoint
		} else {
			insert(tree, tree[diffPoint].left, nodePoint)
		}
	}
}

func find(tree []node, value int, current int) string {
	if tree[current].value == value {
		return "yes"
	} else if tree[current].value > value {
		if tree[current].left == -1 {
			return "no"
		}
		return find(tree, value, tree[current].left)
	} else if tree[current].value < value {
		if tree[current].right == -1 {
			return "no"
		}
		return find(tree, value, tree[current].right)
	}
	return ""
}

func printInorder(tree []node, current int) {
	if current == -1 {
		return
	}
	printInorder(tree, tree[current].left)
	fmt.Printf(" %d", tree[current].value)
	printInorder(tree, tree[current].right)
}

func printPreorder(tree []node, current int) {
	if current == -1 {
		return
	}
	fmt.Printf(" %d", tree[current].value)
	printPreorder(tree, tree[current].left)
	printPreorder(tree, tree[current].right)
}



Measured memory_bytes: 24816
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll N;
	ll cnt=0;
	ll time=0;
	cin>>N;
	vector<ll> P(N+1);
	ll i;
	for(i=0;i<N;i++)cin>>P[i];
	while(1){
		for(i=0;i<N-1;i++){
			if(P[i]==i+1){swap(P[i],P[i+1]);cnt++;}
			else time++;
		}
		if(P[i]==i+1){swap(P[0],P[i]);cnt++;}
		if(time==N-1) break;
		time=0;
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

char board[310][310];
char board2[310][310];
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second

int main(){
ll N;
	cin>> N;
	REP(i,N){
		REP(j,N){
			cin >> board[i][j];
		}
	}

	ll ans = 0;
	REP(x , N) {
		ll A = x;
		ll B = 0;
		REP(i,N){
			REP(j,N){
				board2[i][j] = board[(i+A)%N][(j+B)%N];
			}
		}
		bool flag = true;
		REP(i,N){
			REP(j,N){
				if(board2[i][j] != board2[j][i]){
					flag = false;
				}
			}
		}
		
		if(flag)ans += N;
		
	}
	cout << ans <<endl;
		return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

#define TAX_8 0.08
#define TAX_10 0.10

int main(void) {
    int a, b;
    scanf("%d %d", &a, &b);

    float feel_af = (float) a / (float) TAX_8, feel_bf = (float) b / (float) TAX_10;
    int feel_a, feel_b;
    // printf("%f %f\n", feel_af, (float) ((int) feel_af));
    if (feel_af != (float) ((int) feel_af)) {
        feel_a = (int) feel_af + 1;
    } else {
        feel_a = (int) feel_af;
    }
    if (feel_bf != (float) ((int) feel_bf)) {
        feel_b = (int) feel_bf + 1;
    } else {
        feel_b = (int) feel_bf;
    }

    float feeh_af = (float) (a + 1) / (float) TAX_8, feeh_bf = (float) (b + 1) / (float) TAX_10;
    int feeh_a, feeh_b;
    if (feeh_af == (float) ((int) feeh_af)) {
        feeh_a = (int) feeh_af - 1;
    } else {
        feeh_a = (int) feeh_af;
    }
    if (feeh_bf == (float) ((int) feeh_bf)) {
        feeh_b = (int) feeh_bf - 1;
    } else {
        feeh_b = (int) feeh_bf;
    }
    // printf("%d %d\n", fee_a, fee_b);
    int fee = -1;
    if (feel_a >= feel_b && feel_a <= feeh_b) {
        fee = feel_a;
    } else if (feel_b >= feel_a && feel_b <= feeh_a) {
        fee = feel_b;
    }

    if (fee < 0) {
        fee = -1;
    }
    
    printf("%d\n", fee);

    return 0;
}

Measured memory_bytes: 128
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#include <stdio.h>
#include <bits/stdc++.h>

using namespace std;

#include <x86intrin.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(x) x.begin(), x.end()

#define mp make_pair
#define in insert
#define er erase
#define con continue
#define pb push_back
#define sc scanf
#define pr printf
#define ub upper_bound
#define lb lower_bound
#define s second
#define f first
#define int long long

const long long infl = 1e18; 
const int N = 3e5 + 300, N2 = 2e3, inf = 1e9 + 200, mod = 1e9 + 7;

set <int> S;
vector <int> g;
int n, m, k;
int a[N], ans[N], us[N];
string ss;

int bin_pow(int x, int y){
	int res = 1;
	while (y){
		if (y & 1) (res *= x) %= mod;
		(x *= x) %= mod;
		y >>= 1;
	}
	return res;
}

int f(int x){
	return bin_pow((k / x), n);
}

int rec(int x){
	if (us[x]) return ans[x];
	us[x] = 1;
	ans[x] = f(x);
	for (int i = 2; i * x <= k; i++){
		ans[x] -= rec(i * x);
		ans[x] = (ans[x] + mod) % mod;
	}
	return ans[x];
}

main (){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> k;
	int res = 0;
	for (int i = 1; i <= k; i++){
		(res += (rec(i) * i) % mod) %= mod;
	}
	cout << res;
	return 0;
}












Measured memory_bytes: 5200
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
int main()
{
	ll n, k;
	cin >> n >> k;
	pair<ll, ll> p[n];
	for (int i = 0; i < n; i++){
		cin >> p[i].first >> p[i].second;
	}
	sort(p, p+n);
	for (int i = 0; i < n; i++){
		k -= p[i].second;
		if (k <= 0){
			cout << p[i].first << endl;
			return 0;
		}
	}

}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>

using namespace std;

void solve() {
    int n;
    cin >> n;
    vector<int> h(n);
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }

    int count = 0;
    int maxcount = 0;
    for(int i = 1; i < n; i++){
        if(h[i-1] < h[i]){
            maxcount = max(maxcount, count);
            count = 0;
        }else{
            count++;
        }
    }
    maxcount = max(maxcount, count);
    cout << maxcount << endl;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 640
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 = sc.nextInt();
    int b = sc.nextInt();
    int sum = 0;
    for (int i = 1; i <= n; i++) {
      int len = String.valueOf(i).length();
      int digitSum = 0;
      int ii = i;
      while (true) {
        digitSum += ii % 10;
        ii /= 10;
        if (ii == 0) break;
      }
      if (digitSum >= a && b >= digitSum) {
        sum += i;
      }
    }
    System.out.println(sum);
  }
}

Measured memory_bytes: 23252
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#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 SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

int d[1003];
int main(){
	string str,cmp;
	cin>>str;
	cmp="JOI";int pos=0,cnt[3];
	int sz=SZ(str);
	CLR(cnt);
	int res=0;
	REP(i,sz){
		if(str[i]==cmp[pos]){
			cnt[pos]++;
		}else if(pos!=2&&str[i]==cmp[pos+1]){
			pos++;
			cnt[pos]++;
		}else if(pos==2){
			pos=0;
			if(cnt[1]<=cnt[0]&&cnt[1]<=cnt[2])res=max(res,cnt[1]);
			CLR(cnt);
			if(str[i]==cmp[pos])cnt[pos]++;
		}else{
			CLR(cnt);pos=0;
			if(str[i]==cmp[pos])cnt[pos]++;
		}
	}
	if(cnt[1]<=cnt[0]&&cnt[1]<=cnt[2]){
		res=max(res,cnt[1]);
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 2048
#include<iostream>
#include<iterator>
#include<cmath>
#include<algorithm>
using namespace std;

long A0 , L ;

long A[750] ; 	//a[j],current i
	
void init (){
	A[0]=A0;
}
long mypow ( long a , long b ){
    long ans = 1 ;
    while ( b > 0 )
    {
         ans *= 10 ;   
         b--;
    }
    return ans ; 
}

void sep (long *b , long x ){
	long i;
	for ( i = 0 ; x >= 10 ; b[i] = x%10 , x/=10 , i++ ) ; 
	b[i++] = x ; 
	while ( i < L )
		b[i++] = 0 ;
		
	sort(&b[0],&b[L]);
}

long getmax ( long x ) {
	long b[10] ;
	long ans = 0 ; 
	sep ( b , x ) ;
	for ( long i = 0 ; i < L ; i++ )
		ans += b[i] * mypow ( 10 , i ) ; 
	return ans ;
}

long getmin ( long x ) {
	long b[10] ;
	long ans = 0 ; 
	sep ( b , x ) ;
	for ( long i = 0 ; i < L ; i++ )
		ans += b[i] * mypow ( 10 , L-i-1 ) ; 
	return ans ;
}
	


void deal ( ) { 
	init ( ) ;
	long t , j = 1 ;
	while ( 1 ) {
		A[j] = getmax ( A [ j-1 ] ) - getmin ( A [ j-1 ] ) ;
		for ( int i = 0 ; i < j ; i++ )
			if ( A[i] == A[j] )
			{
				cout << i << ' ' << A[j] << ' ' << j - i << endl ;
				goto hahahaha;
			}
		j++;
	}
	
	hahahaha:
		return;
	
}


int main() {
	cin >> A0 >> L ;
	while ( L )
	{
		deal ( ) ;
		cin >> A0 >> L ; 
	}
	return 0;
}

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

int main(){
	int N,M,A,B;
	cin >> N >> M >> A >> B;
	//M = N - M;
	vector<int> a;
	int u = N;
	for(int i = 0 ; i < N ; i++){
		int d;
		cin >> d;
		if( d >= A ){
			u--;
			a.push_back(d);
			// cout << d << endl;
		}else break;
	}
	if( u < M ){
		for(int i = a.size() - 1 ; i >= 0 ; i--){
			// cout << a[i] << "<" << " " << B << endl;
			if( a[i] <= B ){
				u++;
			}else break;
		}
	}
	cout << N - u << endl;
	
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (int i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()

int N;
string S;

int solve() {
    int a = 0, b = 0;
    REP (i, N) {
        if (S[i] == '1') a++;
        else b++;
    }
    return 2*min(a, b) ;
}

int main() {
    cin >> S;
    N = S.size();
    cout << solve() << endl;
}

Measured memory_bytes: 512
N=int(input())
S=[]
for i in range(N):
  x,y,h=map(int, input().split())
  S.append((x,y,h))

for cx in range(100+1):
  for cy in range(100+1):
    isans=True
    preH=0
    late=[]
    for i in range(N):
      x,y,h=S[i]
      if h==0:
        late.append((x,y,h))
      else:
        H=h+abs(x-cx)+abs(y-cy)
        #print(H)
        if preH==0:
          preH=H
        elif preH!=H:
          isans=False
        preH=H
    for i in range(len(late)):
      x,y,h=late[i]
      if preH!=0 and preH>abs(x-cx)+abs(y-cy):
          isans=False
    if isans:
      print(cx, cy, H)



Measured memory_bytes: 3064
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

//#include <tuple>

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

int main() {
  int N;
  cin >> N;
  vector<int> a (N);
  rep(i, N){
    cin >> a[i];
  }
  int cnt = 1;
  rep(i, N){
    if(a[i] == cnt) cnt++;
  }
  cnt--;
  if (cnt == 0) cout <<  -1 << endl;
  else cout <<  N - cnt  << endl;

}


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

int main(){
  int a=0,b=0,c=0,d=0,n,len;
  string str1="AC",str2="WA",str3="TLE",str4="RE",str5;
  cin>>n;
  for(int i=0;i<n;i++)
  {
    cin>>str5;
    if((str5.compare(str1)) == 0) 
    {
        a++;
    }
    else if((str5.compare(str2)) == 0) 
    {
        b++;
    }
    else if((str5.compare(str3)) == 0) 
    {
        c++;
    }
    else if((str5.compare(str4)) == 0) 
    {
        d++;
    }



  }
  cout<<"AC x "<<a<<endl;
  cout<<"WA x"<<" "<<b<<endl;
  cout<<"TLE x "<<c<<endl;
  cout<<"RE x "<<d<<endl;
}

  
    
  
  

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define reoz(i, z, n) for(decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for(decltype(n) i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(all(v)))
#define MIN(v) (*min_element(all(v)))
#define INF 1000000000000 //1E+12
#define MOD 1000000007    //合同式の法

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<

using namespace std;
typedef long long ll;
typedef unsigned long long ul;
// 1s間で可能なループ回数2E+8回
// intの最大値2147483647~2E+9
// long longの最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<> push_back
// 連想配列map<key,value> insert,
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 setprecision()
// to_string<->stoi
// stoll(longlong)
// stod(double)
// 大文字65-90(-32)
// 小文字97-122(+32)
// 1E+9 +7
const ll mod = 1000000000+7;
int main(){
  // faster
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);

  int n; cin >> n;
  int d = n % 10;
  if(d==2 or d==4 or d==5 or d==7 or d==9) cout << "hon\n";
  else if(d==0 or d==1 or d==6 or d==8) cout << "pon\n";
  else cout << "bon\n";
  
  return 0;
}


Measured memory_bytes: 3652