akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repp(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
//#define int long long
using namespace std;

signed main(){
    int n, k, x, y;
    cin >> n >> k >> x >> y;
    cout << min(k, n) * x + max(0, n - k) * y << endl;
}

Measured memory_bytes: 256
//Apparat : drobucs, aleonov, vit_72
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <iomanip>
#include <algorithm>
#include <string>
#include <queue>
#include <numeric>

//pragma warning(disable : 4996)
//#pragma GCC optimize("O3")

#define nptr nullptr
#define all(x) (x).begin(), (x).end()
#define drobucs ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
#define ff first
#define ss second
#define pb push_back

using namespace std;

typedef long long ll;

const int maxn = (int)2e5 + 13;
const ll INFL = 9223372036854775807;
const int INF = 2147483647;
const ll MOD = (int)1e9 + 7, MOD2 = 1e9 + 21;//1e9 + 21, 1e9 + 33, 1e9 + 87, 1e9 + 93
const ll base = 101, base2 = 37;
const long double pi = 3.1415926535897932;



int main() {
	drobucs;
	
	ll n;
	cin >> n;
	cout << n / 2 + n % 2;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.stream.Collectors;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int max = 0;
    ArrayList<Integer> list = new ArrayList<Integer>();
    list.add(sc.nextInt());
    for (int i = 1; i < K; i++) {
      list.add(sc.nextInt());
      max = Math.max(max, list.get(i) - list.get(i - 1));
    }
    int last = (N - list.get(list.size() - 1)) + list.get(0);
    int ans = N - Math.max(max, last);
    System.out.println(ans);

  }
}


Measured memory_bytes: 85324
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
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; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    ll n, m, k;
    cin >> n >> m >> k;
    vector<ll> A(n + 2, 0), B(m + 2, 0);
    rep(i, n) {
        ll a;
        cin >> a;
        A[i + 1] = A[i] + a;
    }
    A[0] = 0;
    A[n + 1] = LINF;
    rep(i, m) {
        ll a;
        cin >> a;
        B[i + 1] = B[i] + a;
    }
    B[0] = 0;
    B[m + 1] = LINF;
    int ans = 0;
    rep(i, n + 1) {
        if (k - A[i] < 0) break;
        chmax(ans, i + (int)(upper_bound(all(B), k - A[i]) - B.begin() - 1));
    }
    cout << ans << endl;

}

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

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

typedef long long ll;

int N;
char C;
ll dp[100010][5] = {0};
ll A;

int main()
{
    scanf("%d%lld",&N,&A);
    for(int i = 0; i < N; i++)
    {
        for(int j = 0; j < 3; j++)
        {
            dp[i][j] = -1 * 1000000000000000;
        }
    }
    dp[0][0] = A;
    for(int i = 1; i < N; i++)
    {
        scanf(" %c%d",&C,&A);
        if(C == '+')
        {
            dp[i][2] = dp[i - 1][2] + A;
            dp[i][1] = max(dp[i - 1][1] - A,dp[i - 1][2] + A);
            dp[i][0] = max(dp[i - 1][0] + A,max(dp[i - 1][1] - A,dp[i - 1][2] + A));
        }
        else
        {
            dp[i][2] = dp[i - 1][1] + A;
            dp[i][0] = dp[i][1] = max(dp[i - 1][1] + A,max(dp[i - 1][0] - A,dp[i - 1][2] - A));
        }
    }
    printf("%lld\n",max(dp[N - 1][0],max(dp[N - 1][1],dp[N - 1][2])));
}



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

int main(){
	char S[99];
	scanf("%s",S);

	int a=strlen(S);
	int i;
	int j;
	int k;
	
	for(i=0;i<=a/2;i++){
	if(S[i]==S[a-i-1]){  
		
     }else{
     	printf("No");
     	exit(0);
     }
     }

     for(j=0;j<=a/4;j++){  //
	    if(S[j]==S[a/2-j-1]){
		   
	     }else{
	     	printf("No");
	     	exit(0);
	     }
	     }

     for(k=0;k<=a/4;k++){
	       if(S[a/2+1+k]==S[a-k-1]){
		      
	         }else{
	         	printf("No");
	         	exit(0);
	         }
 	        }

 	        printf("Yes");

    return 0;
	
}

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

const int N=100010;
struct edge{int s,t,n;}e[2*N];
int n,k,h[N],a[N],col[N],l[N],r[N],fail;

void dfs1(int x,int f)
{
	if ((~a[x])&&((a[x]&1)^col[x]))  fail=1;
	for (int i=h[x],y; y=e[i].t,i; i=e[i].n)
		if (y!=f)  col[y]=col[x]^1,dfs1(y,x);		
}

void dfs2(int x,int f)
{
	if (~a[x])  l[x]=r[x]=a[x];  else  l[x]=-1<<30,r[x]=1<<30;
	for (int i=h[x],y; y=e[i].t,i; i=e[i].n)
		if (y!=f)  dfs2(y,x),l[x]=max(l[x],l[y]-1),r[x]=min(r[x],r[y]+1);
	l[x]+=((l[x]&1)^col[x]),r[x]-=((r[x]&1)^col[x]);
	if (l[x]>r[x])  fail=1;
}

void dfs3(int x,int f)
{
	for (int i=h[x],y; y=e[i].t,i; i=e[i].n)
		if (y!=f)  a[y]=a[x]+((l[y]<=a[x]+1)&&(a[x]+1<=r[y])?1:-1),dfs3(y,x);
}

void work()
{
	scanf("%d",&n),memset(a,-1,sizeof(a));
	for (int i=1,u,v,tot=0; i<n; i++)
		{
			scanf("%d %d",&u,&v);
			e[++tot]=(edge){u,v,h[u]},h[u]=tot;
			e[++tot]=(edge){v,u,h[v]},h[v]=tot;
		}
	scanf("%d",&k);
	for (int i=1,v,p; i<=k; i++)  scanf("%d %d",&v,&p),a[v]=p;
	for (int i=1; i<=n; i++)  if (~a[i])  {col[i]=a[i]&1,dfs1(i,0);  break;}
	if (fail)  puts("No"),exit(0);
	dfs2(1,0);
	if (fail)  puts("No"),exit(0);
	a[1]=l[1],dfs3(1,0);
	puts("Yes");
	for (int i=1; i<=n; i++)  printf("%d\n",a[i]);
}

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


Measured memory_bytes: 9856
using System;

public class Hello{
  public static void Main(){
    int result;
    int M = 500;
    var str = Console.ReadLine().Split(' ');
    int K = int.Parse(str[0]);
    int X = int.Parse(str[1]);
    if(K*M>=X){
      Console.Write("Yes");
    }else{
      Console.Write("No");
    }
  }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<l_l> vpl;
typedef vector<string> vs;
typedef pair<l_l,ll> lll;
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=1;i<=(n);i++)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=10100100100100100;
const ll dx[4]={1,-1,0,0};
const ll dy[4]={0,0,1,-1};
template<class T> inline bool chmin(T& a,T b){
if(a>b){
a=b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a,T b){
if(a<b){
a=b;
return true;
}
return false;
}
ll size,q,n;
vl node,lazy;
void init(){
    n=1;
    while(n<size)n*=2;
    node.resize(2*n-1,0);
    lazy.resize(2*n-1,0);
}
void eval(ll l,ll r,ll pos){
    if(lazy[pos]!=0){
        node[pos]+=lazy[pos];
        if(r-l>1){
            lazy[2*pos+1]+=lazy[pos]/2;
            lazy[2*pos+2]+=lazy[pos]/2;
        }
        lazy[pos]=0;
    }
}
void add(ll l,ll r,ll val,ll bottom=0,ll top=-1,ll pos=0){
    if(top<0)top=n;
    eval(bottom,top,pos);
    if(r<=bottom||top<=l)return;
    if(l<=bottom&&top<=r){
        lazy[pos]+=(top-bottom)*val;
        eval(bottom,top,pos);
    }
    else{
        ll mid=(bottom+top)/2;
        add(l,r,val,bottom,mid,2*pos+1);
        add(l,r,val,mid,top,2*pos+2);
        node[pos]=node[2*pos+1]+node[2*pos+2];
    }
}
ll getsum(ll l,ll r,ll bottom=0,ll top=-1,ll pos=0){
    if(top<0)top=n;
    eval(bottom,top,pos);
    if(r<=bottom||top<=l)return 0;
    if(l<=bottom&&top<=r)return node[pos];
    ll mid=(bottom+top)/2;
    ll vl=getsum(l,r,bottom,mid,2*pos+1);
    ll vr=getsum(l,r,mid,top,2*pos+2);
    return vl+vr;
}
int main(){
    cin>>size>>q;
    init();
    rep(i,q){
        ll query;cin>>query;
        if(query){
            ll s,t;cin>>s>>t;
            cout<<getsum(s-1,t)<<endl;
        }
        else{
            ll s,t,x;cin>>s>>t>>x;
            add(s-1,t,x);
        }
    }
    return 0;
}


Measured memory_bytes: 7056
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
int n,a[1000010];

int main(){
	cin >> n;
	REP(i,0,n) cin >> a[i];
	
	ll s=0,ss=0,pos=0;
	REP(i,0,n){
		pos+=a[i];
		if(!(i%2) and pos<=0) s+=abs(pos)+1,pos+=abs(pos)+1;
		if(i%2 and pos>=0) s+=pos+1,pos-=pos+1;
	}
	
	pos=0;
	REP(i,0,n){
		pos+=a[i];
		if(i%2 and pos<=0) ss+=abs(pos)+1,pos+=abs(pos)+1;
		if(!(i%2) and pos>=0) ss+=pos+1,pos-=pos+1;
	}
	
	cout << min(s,ss) << endl;
	return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<math.h>

using namespace std;

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

    int val[n];
    for(int i=0;i<n;i++){
        cin >> val[i];
    }

    int minv = val[0];
    int maxv = val[1]-val[0];
    for(int i=1;i<n;i++){
        maxv = max(maxv,val[i]-minv);
        minv = min(minv,val[i]);
    }

    cout << maxv << endl;
    return 0;
}


Measured memory_bytes: 3884
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

int N, s[SIZE];
map<int,ll> suml[SIZE], sumr[SIZE];

int main(){

  scanf("%d", &N);

  for (int i=0; i<N; i++) {
    scanf("%d", s+i);
  }

  for (int i=1; i<=N-1; i++) {
    ll sum = 0;
    for (int j=0; j<=N-1; j+=i) {
      sum += s[j];
      suml[j][i] = sum;
    }
  }

  for (int i=1; i<=N-1; i++) {
    ll sum = 0;
    for (int j=N-1; j>=0; j-=i) {
      sum += s[j];
      sumr[j][i] = sum;
    }
  }

  ll ans = 0;

  for (int A=1; A<N-1; A++) {
    int r = N-1 - A;
    for (int d=1; d*d<=r; d++) {
      if (r % d) continue;

      {
        int B = A - d;
        if (B > 0 && (A % d != 0 || A / d > r / d)) {
          ans = max(ans, sumr[A][d] + suml[r][d]);
        }
      }
      {
        int B = A - r/d;
        if (B > 0 && (A % (r/d) != 0 || A / (r/d) > r / (r/d))) {
          ans = max(ans, sumr[A][r/d] + suml[r][r/d]);
        }
      }
    }
  }


  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 177792
#include <stdio.h>
#include <algorithm>
using namespace std;
int n, q, r, ret, a[10000];
int main() {
	scanf("%d", &n);
	for(int i = 0; i < n; i++) scanf("%d", &a[i]);
	scanf("%d", &q);
	for(int i = 0; i < q; i++) {
		scanf("%d", &r);
		for(int j = 0; j < n; j++) {
			if(a[j] == r) {
				ret++; break;
			}
		}
	}
	printf("%d\n", ret);
	return 0;
}

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

int H, W;

int solve(char S[20][20], int h, int w)
{
    if(S[h][w] != '.'){
        return 0;
    }
    queue<pair<int, int> > q;
    int m[20][20];
    for(int i=0; i<400; i++){
        m[i/20][i%20] = 10000;
    }

    int imax = 0;

    m[h][w] = 0;
    q.push({h, w});

    while(!q.empty()){
        auto i = q.front();
        if(i.first != 0 && S[i.first-1][i.second] == '.'
                && m[i.first-1][i.second] > m[i.first][i.second] + 1 ){
            m[i.first-1][i.second] = m[i.first][i.second] + 1;
            q.push({i.first-1, i.second});
        }
        if(i.first != H-1 && S[i.first+1][i.second] == '.'
                && m[i.first+1][i.second] > m[i.first][i.second] + 1 ){
            m[i.first+1][i.second] = m[i.first][i.second] + 1;
            q.push({i.first+1, i.second});
        }
        if(i.second != 0 && S[i.first][i.second-1] == '.'
                && m[i.first][i.second-1] > m[i.first][i.second] + 1 ){
            m[i.first][i.second-1] = m[i.first][i.second] + 1;
            q.push({i.first, i.second-1});
        }
        if(i.second != W-1 && S[i.first][i.second+1] == '.'
                && m[i.first][i.second+1] > m[i.first][i.second] + 1 ){
            m[i.first][i.second+1] = m[i.first][i.second] + 1;
            q.push({i.first, i.second+1});
        }
        if(m[i.first][i.second] > imax){
            imax = m[i.first][i.second];
        }
        q.pop();
    }
    return imax;   
}

int main()
{
    cin >> H >> W;
    char S[20][20];
    for(int h=0; h<H; h++){
        for(int w=0; w<W; w++){
            cin >> S[h][w];
        }
    }

    int imax = 0;
    for(int h=0; h<H; h++){
        for(int w=0; w<W; w++){
            int res = solve(S, h, w);
            if(imax < res){
                imax = res;
            }
        }
    }

    cout << imax << endl;

	return 0;
}


Measured memory_bytes: 256
def ans(x1, x2, x3, x4, state1, state2, state3):
    return int(eval("{}{}{}{}{}{}{}".format(x1,state1,x2,state2,x3,state3,x4)))

n = input()

x1 = int(n[0])
x2 = int(n[1])
x3 = int(n[2])
x4 = int(n[3])

state1 = "+"
state2 = "+"
state3 = "+"

x = 7

for n in range(8):
    if n == 0:
        k = "000"
    if n == 1:
        k = "001"
    if n == 2:
        k = "010"
    if n == 3:
        k = "011"
    if n == 4:
        k = "100"
    if n == 5:
        k = "101"
    if n == 6:
        k = "110"
    if n == 7:
        k = "111"
    
    if k[0] == "0":
        state1 = "+"
    else:
        state1 = "-"
    try:
        if k[1] == "0":
            state2 = "+"
        else:
            state2 = "-"
    except:
        state2 = "+"
    try:
        if k[2] == "0":
            state3 = "+"
        else:
            state3 = "-"
    except:
        state3 = "+"
    a = ans(x1, x2,x3,x4,state1,state2,state3)
    if a == 7:
        break
print("{}{}{}{}{}{}{}=7".format(x1,state1,x2,state2,x3,state3,x4))



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

struct Node {
  int key;
  Node *right,*left,*parent;
};

Node *root,*NIL;

void insert(int k) {
  Node *y=NIL;
  Node *x=root;
  Node *z;
  z=(Node *)malloc(sizeof(Node));
  z->key=k;
  z->left=NIL;
  z->right=NIL;
  while (x!=NIL) {
    y=x;
    if (z->key<x->key) {
      x=x->left;
    }
    else {
      x=x->right;
    }
  }
  z->parent=y;
  if (y==NIL) {
    root=z;
  }
  else {
    if (z->key<y->key) {
      y->left=z;
    }
    else {
      y->right=z;
    }
  }
}
void inorder(Node *u) {
  if (u==NIL) {
    return ;
  }
  inorder(u->left);
  cout<<" "<<u->key<<flush;
  inorder(u->right);
}
void preorder(Node *u) {
  if (u==NIL) {
    return ;
  }
  cout<<" "<<u->key<<flush;
  preorder(u->left);
  preorder(u->right);
}
int main() {
  int n;
  cin>>n;
  for (int i=0; i<n; i++) {
    string com;
    cin>>com;
    if (com=="insert") {
      int x;
      cin>>x;
      insert(x);
    }
    else {
      inorder(root);
      cout<<endl;
      preorder(root);
      cout<<endl;
    }
  }
  return 0;
}



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

int main(){
  int N, sum=0;
  int V[20], C[20], str[20];
  
  cin >> N;
  
  int i;
  for(i=0; i<N; i++){
    cin >> V[i];
  }
  for(i=0; i<N; i++){
    cin >> C[i];
  }
  for(i=0; i<N; i++){
    str[i]=V[i]-C[i];
    if(str[i]>0){
      sum+=str[i];
    }
  }
  
  cout << sum;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
int main()
{
    double a,b,h,m;
    cin >> a >> b >> h >> m;
    double rad = fabs(min(h * 30 + m / 2 - m * 6,360 - (h * 30 + m / 2 - m * 6))) * M_PI / 180;
    cout << fixed << setprecision(20) << sqrt(a * a + b * b - 2 * a * b * cos(rad)) << "\n";

    return 0;
}

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

int main(){
    int n, k, x, y;
    int sum;
    cin >> n >> k >> x >> y;
    if(n>k){ 
        cout << (((n-k)*y)+(k*x)) << endl;
    }else{
        cout << n*x << endl;
    }
}

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

using namespace std;

int h[100000];
int cost[100000];

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

  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> h[i];
  }
  cost[1] = abs(h[0] - h[1]);
  for (int i = 2; i < N; i++) {
    cost[i] = min(cost[i - 1] + abs(h[i - 1] - h[i]),
                  cost[i - 2] + abs(h[i - 2] - h[i]));
  }
  cout << cost[N - 1] << endl;
  return 0;
}


Measured memory_bytes: 4320
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



using namespace std;
using ll = long long;
using ull = unsigned long long;

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

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












 
int main(){
    ll n;
    cin >> n;
    vector<ll> L(n);
    REP(i, n){
        cin >> L[i];
    }
    sort(L.begin(), L.end());
    ll ans = 0;
    for(ll i = 0; i < n - 2; i++){
        for(ll j = i + 1; j < n - 1; j++){
            ans += --lower_bound(L.begin() + j + 1, L.end(), L[i] + L[j]) - lower_bound(L.begin() + j + 1, L.end(), L[j] - L[i] + 1) + 1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"from itertools import*;n=int(input());print(sum(len(set(a))>2and n>=int(''.join(a))for i in range(11)for a in product(*['357']*i)))\n"
"\"";
  system(s);
  return 0;
}            

Measured memory_bytes: 3280
X = int(input())


def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]


l = primes(10 ** 5 + 10000)
for i in l:
    if i >= X:
        print(i)
        exit()

Measured memory_bytes: 4204
#include <assert.h>
#include <limits.h>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cout << i << "\n"

//const ll MOD = 998244353;
const ll MOD = 1e9+7;

//exact search by Z algorithm
std::vector<ll> Zsearch(const std::string& T, const std::string& P){
  std::string S = P + "$" + T;
  std::vector<ll> z(S.length(), 0);

  ll L = 0, R = 0;
  for(ll i=1; i<S.length(); i++){
    if(i>R){
      L = R = i;
      while(R<S.length() && S[R-L] == S[R]) R++;
      z[i] = R-L;
      R--;
    }else{
      ll k = i-L;
      if(z[k] < R-i+1){
        z[i] = z[k];
      }else{
        L = i;
        while(R<S.length() && S[R-L] == S[R]) R++;
        z[i] = R-L;
        R--;
      }
    }
  }
  
  std::vector<ll> ret;
  for(ll i=P.length()+1; i<S.length(); i++){
    if(z[i] == P.length()){
      ret.push_back( i-(P.length()+1) );
    }
  }
  return ret;
}

//非再帰トポロジカルソート 隣接リストを渡す 返り値のサイズがnじゃないならnot DAG
std::vector<ll> topo_sort(std::vector<std::vector<ll>>& graph){
  ll n=graph.size();
  std::vector<ll> ret,num(n,0);
  std::queue<ll> que;
  rep(i,0,n){
    for(ll j:graph[i])num[j]++;
  }
  rep(i,0,n){
    if(num[i]==0)que.push(i);
  }
  while(!que.empty()){
    ll u=que.front();que.pop();
    ret.push_back(u);
    for(ll i:graph[u]){
      num[i]--;
      if(num[i]==0)que.push(i);
    }
  }

  return ret;
}
 
int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!

  std::string s,t,u="";
  std::cin>>s>>t;

  ll n=s.size(),m=t.size();

  rep(i,0,(ll)(m/n)+2)u+=s;

  std::vector<ll> match=Zsearch(u,t);
  std::vector<std::vector<ll>> graph(n);

  if(match.empty()){
    std::cout<<0;
    return 0;
  }

  for(ll i:match){
    if(i<n)graph[i].push_back((i+m)%n);
  }

  std::vector<ll> a=topo_sort(graph),dp(n,0);

  if(a.size()!=n){
    std::cout<<-1;
    return 0;
  }

  for(ll i=n-1;i>=0;i--){
    ll now=a[i];
    for(ll j:graph[now])dp[now]=std::max(dp[now],dp[j]+1);
  }

  ll ans=0;
  rep(i,0,n)ans=std::max(ans,dp[i]);

  std::cout<<ans;

  return 0;
}

Measured memory_bytes: 49092
package main

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

func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b > 0 {
		a, b = b, a%b
	}
	return a
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

type segmentTree struct {
	data   []int
	offset int
}

func newSegmentTree(n int) segmentTree {
	var result segmentTree
	t := 1
	for t < n {
		t *= 2
	}
	result.offset = t - 1
	result.data = make([]int, 2*t-1)
	return result
}

func (st segmentTree) updateAll(a []int) {
	for i, v := range a {
		st.data[st.offset+i] = v
	}
	for i := st.offset - 1; i > -1; i-- {
		st.data[i] = gcd(st.data[i*2+1], st.data[i*2+2])
	}
}

func (st segmentTree) update(index, value int) {
	i := st.offset + index
	st.data[i] = value
	for i >= 1 {
		i = (i - 1) / 2
		st.data[i] = gcd(st.data[i*2+1], st.data[i*2+2])
	}
}

func (st segmentTree) _query(start, stop, index, left, right int) int {
	if right <= start || stop <= left {
		return 0
	}
	if start <= left && right <= stop {
		return st.data[index]
	}
	a := st._query(start, stop, index*2+1, left, (left+right)/2)
	b := st._query(start, stop, index*2+2, (left+right)/2, right)
	return gcd(a, b)
}

func (st segmentTree) query(start, stop int) int {
	return st._query(start, stop, 0, 0, st.offset+1)
	/*
		result := 0
		q := make([][3]int, 1)
		q = append(q, [3]int{0, 0, st.offset + 1})
		for len(q) != 0 {
			index := q[0][0]
			left := q[0][1]
			right := q[0][2]
			q = q[1:]
			if right <= start || stop <= left {
				continue
			}
			if start <= left && right <= stop {
				result = gcd(result, st.data[index])
				continue
			}
			q = append(q, [3]int{index*2 + 1, left, (left + right) / 2})
			q = append(q, [3]int{index*2 + 2, (left + right) / 2, right})
		}
		return result
	*/
}

func main() {
	N := readInt()
	A := readInts(N)

	st := newSegmentTree(N)
	//for i, v := range A {
	//	st.update(i, v)
	//}
	st.updateAll(A)

	result := st.query(1, N)
	for i := 1; i < N-1; i++ {
		result = max(result, gcd(st.query(0, i), st.query(i+1, N)))
	}
	result = max(result, st.query(0, N-1))

	fmt.Println(result)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}

func readInts(n int) []int {
	result := make([]int, n)
	for i := 0; i < n; i++ {
		result[i] = readInt()
	}
	return result
}


Measured memory_bytes: 6528
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#pragma warning(disable : 4996) //_CRT_SECURE_NO_WARNINGS

int main(void) {
	int N;
	scanf("%d", &N);
	printf("%d", (N / 2) + (N % 2));
	return 0;
}

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

      int main(){
        int n;
        string s;
        cin >> n;
        if (n%10 == 9 || n/10 == 9) cout << "Yes"<< endl;
        else cout << "No" << endl;
        
        return 0;

        
      }
        
        

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long H = sc.nextLong();
        long count = 0;
        long mCount = 1;
        while (H != 0) {
            count += mCount;
            mCount *= 2;
            if (H % 2 == 1) {
                H = (H - 1) / 2;
            } else {
                H = H / 2;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 23124
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());
        int x = Integer.parseInt(sc.next());
        int y = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        int normal = a * x + b * y;
        int half = c * Math.max(x, y) * 2;

        int comb = x > y ? a * (x - y) + c * Math.min(x, y) * 2 : b * (y - x) + c * Math.min(x, y) * 2;
        int price = Math.min(Math.min(normal, half), comb);

        int result = price;

        // 出力
        System.out.println(result);
    }
}


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

using namespace std;
using ll = long long;

//container util
#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)


int main(void){

	
	int K, X; cin >> K >> X;
	FOR(i, X-K+1, X+K) cout << i << ' ';
	cout << endl;


	return 0;

}


Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <complex>
#include <numeric>
#define _for(i,n) for(ull i = 0; i < n; i++)

typedef long long ll;
typedef unsigned long long ull;


using namespace std;

template <typename T>
T gcd(T a, T b) {
  if (b==0) return a;
  return gcd(b,a%b);
}

int main() {
  ull n;
  cin >> n;
  ull t[n];
  _for(i,n) cin >> t[i];
  ull tlcm = 1;
  _for(i,n) {
    tlcm = tlcm*(t[i]/gcd(tlcm,t[i]));
  }
  cout << tlcm << endl;
  return 0;
}

Measured memory_bytes: 256
/* Hello darkness my old friend, I've come to visit you again! */

#include<bits/stdc++.h>
#define lli long long int
#define FOR(i,a,b) for(i=a;i<b;i++)
#define FORB(i,b,a) for(i=b;i>=a;i--)
#define mod 1000000007
#define PI 2*acos(0.0)
#define gs getline(cin,s)
#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pb push_back
#define eb emplace_back
#define mem(a,b) memset(a,b,sizeof(a))
#define inf 1000000005
#define INF 1000000000000000005
#define io ios_base::sync_with_stdio(0);
#define ff first
#define ss second
using namespace std;
int vis[1005];
int main()
{
    io;
    cin.tie(0);
    cout.tie(0);
    int n,i,j;
    cin>>n;
    vis[1]=1;
    FOR(i,2,sqrt(n)+1)
    {
        int mul=i*i;
        while(mul<=n)
        {
            vis[mul]=1;
            mul*=i;
        }
    }
    FORB(i,n,1)
    if(vis[i])
    {
        cout<<i;
        return 0;
    }
    return 0;
}

/* This is the end, beautiful friend! */


Measured memory_bytes: 256
#include <atcoder/segtree>
using namespace atcoder;
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
using namespace std;
using ll = long long;
template<typename T>
inline bool chmax(T& a, const T& b) {
    if (a < b){
        a = b;
        return true;
    }
    return false;
}
template<typename T>
inline bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
/**
 * @brief 多次元 vector の作成
 * @author えびちゃん
 */
namespace detail {
    template<typename T, int N>
    auto make_vec(vector<int>& sizes, T const& x) {
        if constexpr (N == 1) {
            return vector(sizes[0], x);
        } else {
            int size = sizes[N-1];
            sizes.pop_back();
            return vector(size, make_vec<T, N-1>(sizes, x));
        }
    }
}
template<typename T, int N>
auto make_vec(int const(&sizes)[N], T const& x = T()) {
    vector<int> s(N);
    for (int i = 0; i < N; ++i) s[i] = sizes[N-i-1];
    return detail::make_vec<T, N>(s, x);
}
__attribute__((constructor))
void fast_io() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

using S = int;
S op (S l, S r) { return max(l, r); }
S e() { return 0; }

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int maxa = 300005;
    segtree<S, op, e> seg(maxa);
    vector<int> dp(n);
    rrep(i, n) {
        dp[i] = seg.prod(max(0, a[i] - k), min(maxa, a[i] + k + 1)) + 1;
        seg.set(a[i], max(dp[i], seg.get(a[i])));
    }
    int ans = *max_element(dp.begin(), dp.end());
    cout << ans << '\n';
}

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


def _f(H, W, S):
    '''
    >>> f = _f(3, 3, [[1, 0, 0], [1, 0, 1], [0, 1, 1]])
    >>> f(0, 0, 1, 1)
    1
    >>> f(0, 0, 3, 0)
    0
    >>> f(0, 0, 3, 1)
    2
    >>> f(1, 1, 3, 3)
    3
    >>> f(0, 0, 3, 3)
    5
    >>> f(2, 0, 3, 3)
    2
    '''
    acc = [[0] * (W + 1) for _ in range(H+1)]
    for h in range(1, H+1):
        for w in range(1, W+1):
            acc[h][w] = acc[h][w-1] + acc[h-1][w] - acc[h-1][w-1] + S[h-1][w-1]

    def f(sh, sw, eh, ew):
        return acc[eh][ew] + acc[sh][sw] - acc[sh][ew] - acc[eh][sw]

    return f

def _solve(H, W, K, S, c, f):
    #print(H, W, K, S, c, f)
    sw = 0
    cut = 0
    for ew in range(1, W+1):
        #print([(((sh, sw), (eh, ew)), f(sh, sw, eh, ew)) for sh, eh in c])    
        if any(f(sh, ew-1, eh, ew) > K for sh, eh in c):
            return float('inf')
        if any(f(sh, sw, eh, ew) > K for sh, eh in c):
            cut += 1
            sw = ew - 1
    return cut


def solve(H, W, K, S):
    from itertools import product, compress
    f = _f(H, W, S)
    ans = float('inf')
    for flag in product(range(2), repeat=H-1):
        t = (0,) + tuple(compress(range(1,H), flag)) + (H,)
        c = tuple(zip(t, t[1:]))
        ans = min(ans, _solve(H, W, K, S, c, f)+sum(flag))
    return ans


    

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
def main():
    H, W, K = list(map(int, input().split()))
    S = [list(map(int, input())) for _ in range(H)]
    print(solve(H, W, K, S))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


Measured memory_bytes: 45916
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long INF = 1LL << 60;
template <class T> bool chmin(T& a, T b){if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b){if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

int main()
{
  long long N, A, B, C, D, E;
  cin >> N >> A >> B >> C >> D >> E;
  
  long long m = min(min(min(min(A, B), C), D), E);
  long long t = 5 + divCeil(N, m) - 1;
  
  cout << t << endl;
}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

bool cmp(pair<int, int> a, pair<int, int> b){
	return (a.second == b.second)?(a.first < b.first):(a.second < b.second);
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n, m;
	cin>>n>>m;
	vector<pair<int, int> > a(m);
	for(int i = 0; i < m; i++){
		cin>>a[i].first>>a[i].second;
	}
	sort(a.begin(), a.end(), cmp);
	int cur = 0, ans = 0;
	for(int i = 0; i < m; i++){
		if(a[i].first < cur)continue;
		cur = a[i].second; ans++;
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 1024
#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 std;
using namespace __gnu_pbds;
#define ll long long
#define pp pair<ll,ll>
typedef tree<pp,null_type,less<pp>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin() , (x).end()
#define rep(i,a,b) for( ll i = a ; i < b ; i+=1 )
#define sz(v) (ll)(v.size())
#define hell (ll)1000000007
#define slld(x) scanf("%lld",&x)
ll t = 1;
const ll inf = hell, N=200005;
inline ll mult(ll x,ll y){return (x*y)%hell;}
inline ll add(ll x,ll y){x+=y;return x%hell;}
vector<ll> adj[N], revg[N], dist(N,inf);
void solve(){
	string s;
	cin>>s;
	s[2]==s[3] and s[4]==s[5]?cout<<"Yes\n":cout<<"No\n";
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
//    cin >> t ;
    while(t--){
        solve();
    }
    return 0 ;
}


Measured memory_bytes: 11136
m=int(input())
nums=[list(map(int,input().split())) for i in range(m)]
S=0
Slen=0
for i in nums:
  S+=i[0]*i[1]
  Slen+=i[1]
if S%9==0:
  kuriagari=S//9-1
else:
  kuriagari=S//9
print(Slen-1+kuriagari)

Measured memory_bytes: 79960
#include <cassert>
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;



struct K {
  int v, cnt;
};
bool operator<(const K& a, const K& b) {
  return a.cnt < b.cnt;
}
K ks[2][100000+10];
int vs[100000+10];

int main(void) {
  int n;
  scanf("%d", &n);
  map<int,int> hist[2];
  REP(i, n) {
    scanf("%d", &vs[i]);
    hist[i%2][vs[i]]++;
  }
  
  int ns[2];
  REP(i, 2) {
    int j = 0;
    for(auto p : hist[i]) {
      ks[i][j] = (K){p.first, p.second};
      ++j;
    }
    sort(ks[i], ks[i]+j);
    reverse(ks[i], ks[i]+j);
    ns[i] = j;
  }

  int res = n;
  if(ns[0] == 1 && ns[1] == 1) {
    if(ks[0][0].v == ks[1][0].v) { // 全一致
      res = n/2;
    } else { // できてる
      res = 0;
    }
  } else {
    REP(i, min(ns[0], 2)) {
      REP(j, min(ns[1], 2)) {
        if(ks[0][i].v != ks[1][j].v) {
          int cur = (n+1)/2 - ks[0][i].cnt + n/2 - ks[1][j].cnt;
          res = min(res, cur);
        }
      }
    }
  }
  printf("%d\n", res);
  
  return 0;
}


Measured memory_bytes: 6144
N, A, B, C, D = map(int, input().split())
mod = 7 + 10 ** 9

fact = [1] * (N+1)
frev = [1] * (N+1)
for i in range(1, N+1):
    temp = fact[i] = (fact[i-1] * i) % mod
    frev[i] = pow(temp, mod-2, mod)

def P(n, r):
    return (fact[n] * frev[n-r]) % mod

DP = [[0 for j in range(N+1)] for i in range(N+1)]
for i in range(N+1): DP[i][0] = 1
for i in range(A, B+1):
    revi = frev[i]
    for j in range(1, N+1):
       dpij = 0 + DP[i-1][j]
       for k in range(C, D + 1):
           if j - i * k < 0: break
           temp = (P(N-j+i*k, i*k) * pow(revi, k, mod) * frev[k]) % mod
           dpij += (temp * DP[i-1][j-i*k]) % mod
       DP[i][j] = dpij % mod

print(DP[B][N])


Measured memory_bytes: 133980
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
ll binpow(ll a,ll b,ll mod)
{
   // if(mod<=1) return 0;
    ll res=1;
    while(b>0)
    {
        if(b%2)
        {
            res=(res*a)%mod;
        }
        a=(a*a)%mod;
        b/=2;
    }
    return res;

}
ll getans(string s,ll p)
{
    int n=s.length();
    ll pop=p;
    ll ans=0;
    
    if(pop>1)
    {

    for(int i=0;i<n;i++)
    {
        if(s[i]=='1')
        {
            ans=(ans+binpow((ll)2,(ll)(n-1-i),pop))%pop;
            
        }
    }
    }
    return ans;

}
int solve(int ans)
{
//     int n=s.length();
//     ll pop=p;
//   //  for(auto it : s) if(it=='1') pop++;
//     ll ans=0;
//     int cnt=0;
//     if(pop>0){
//     for(int i=0;i<n;i++)
//     {
//         if(s[i]=='1')
//         {
//             ans=(ans+binpow((ll)2,(ll)(n-1-i),pop))%pop;
            
//         }
//     }
//     }
//     if(pop>0)
//     cnt++;
    int cnt=0;
     cnt++;
    while(ans>0)
    {
        int z=(__builtin_popcount(ans));
        ans=ans%z;
        cnt++;
    }
    return cnt;

}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    string s;
    //int val=0;
    cin>>n;
    cin>>s;
     ll p=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='1') p++;
        //val+=(1<<(n-1-i))*(s[i]-'0');
    }
    // if(p<=1) 
    // {
    //      cout<<"1"<<endl;
    //      return 0;
    // }
   // cout<<val<<endl;
   ll ans,ans1=0,ans2=0;
   //ans=getans(s,p);
   if(p>1)
   ans1=getans(s,p-1);
   ans2=getans(s,p+1);
    for(int i=0;i<n;i++)
    {
        if(s[i]=='1')
        {
           // int x=val-(1<<(n-1-i));
           
           ll val=0;
           if(p>1)
           {val=((ans1+p-1)-binpow((ll)2,(ll)n-1-i,p-1))%(p-1);
           cout<<solve(val)<<endl;
           }
           else if(p-1==0) cout<<"0"<<endl;
          
           
          
      
         
           
            //cout<<solve(t,p-1)<<endl;
        }
        else
        {
           // int x=val+(1<<(n-1-i));
            ll val=0;

           val=(ans2+binpow((ll)2,(ll)n-1-i,p+1))%(p+1);
       
        cout<<solve(val)<<endl;
    
        }
 
    }


}

Measured memory_bytes: 3852
N, M, K = input().split()
N, M, K = [int(N), int(M), int(K)]
A = list(map(int, input().split()))
B = list(map(int, input().split()))
SA = [0]
for i in range(N):
    SA.append(SA[i] + A[i])
SB = [0]
for i in range(M):
    SB.append(SB[i] + B[i])
ans = 0
j = M
for i in range(N + 1):
    while j > 0 and SA[i] + SB[j] > K:
        j -= 1
    if SA[i] + SB[j] <= K:
        ans = max(ans, i + j)
print(ans)


Measured memory_bytes: 48496
#pragma GCC optimize("-O3")
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
using namespace std;

using l = long int;
using ll =long long int;
#define imax INT_MAX
#define lmax LLONG_MAX
#define pb push_back
#define ld long double
#define pii pair<l,l> 
#define pll pair<ll,ll>
#define v vector
#define vl vector<l>
#define vll vector<ll>
#define vvl vector<vector<l>>
#define vvll vector<vector<ll>>
#define vv(a) vector<vector<a>> 
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define mni(a,i,j) *min_element((a).begin()+i,(a).begin()+j)
#define mxi(a,i,j) *max_element((a).begin()+i,(a).begin()+j)
#define f first
#define se second
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define rep(i, begin, end) \
        for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define tc l t=0;cin>>t;while(t--)

// ONLINE JUDGE START
#ifndef ONLINE_JUDGE
    // FILE
    #define file ifstream cin; cin.open("input.txt");  ofstream cout; cout.open("output.txt");
    // DEBUG
    #define debug(x) cout<<"LINE NUMBER:     "<<__LINE__<<"\t :--> \t"<<#x<<"   =   "<<x<<endl;
#else 
    #define debug(x) 
#endif

// SYSTEM
#define DeBuG(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d) for(long blockTime=NULL;(blockTime==NULL?(blockTime=clock())!=NULL:false); \
            DeBuG("%s:%.4f s\n",d,(double)(clock()-blockTime)/CLOCKS_PER_SEC))
// OVERLOADING
istream& operator >> (istream& cin,vll &a){
    for(auto &i:a)cin>>i;
    return cin;
}
ostream& operator << (ostream& cout,pll &a){
    cout<<a.f<<" "<<a.se<<"\t";
    return cout;
}
ostream& operator << (ostream& cout,vl &a){
    for(auto &i:a)cout<<i<<" ";
    return cout;
}
ostream& operator << (ostream& cout,vll &a){
    for(auto &i:a)cout<<i<<" ";
    return cout;
}
ostream& operator << (ostream& cout,v<pll> &a){
    for(auto &i:a)cout<<i<<"\t";
    return cout;
}
ostream& operator << (ostream& cout,vvl &a){
    for(auto &i:a){cout<<i<<endl;}
    return cout;
}
ostream& operator << (ostream& cout,vvll &a){
    for(auto &i:a){cout<<i<<endl;}
    return cout;
}
ostream& operator << (ostream& cout,unordered_map<ll,bool> &a){
    for(auto &i:a){cout<<i.f<<" "<<i.se<<"\t";}
    return cout;
}


// GLOBAL VARIABLE AND FUNTIONS
const ll inf = 1e9+7;

int main()
{
#ifndef ONLINE_JUDGE
    // file;
#endif 

    ll n,k;cin>>n>>k;
    vll arr(n);cin>>arr;
    sort(all(arr));
    ll sum=0;
    for(ll i=0;i<n-k;i++){
        sum+=arr[i];
    }
    cout<<sum<<endl;

#ifndef ONLINE_JUDGE
//    cerr << "Time elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms.\n";
#endif
    return 0;
}


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

using namespace std;

int main()
{
    cin.tie(0);
    int test; cin >> test;
    
    while (1)
    {
        bool pass(true);
        for (int i = 2; i <= sqrt(test); ++i)
        {
            if (!(test % i))
            {
                pass = false;
                break;
            }
        }
        
        if (pass)
            break;
        
        ++test;
    }
    
    cout << test;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
using ll = long long;
using lint = long long;
typedef pair<int,int> P;
const lint inf=1e18+7;
const int MOD=1000000007;
signed main(){  
  int n;cin>>n;
  vector<int> p(n);
  rep(i,n)cin>>p[i];
  sort(p.begin(),p.end());
  lint res=0;
  p[n-1]/=2;
  rep(i,n)res+=p[i];
  cout<<res<<"\n";
  return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int X, A;
    cin >> X >> A;
    cout << (X < A ? 0 : 10) << endl;
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repc(i, a, b) for (int i = a; i <= (int)(b); i++)
#define ll long long
#define vec vector
#define ft first
#define sd second
#define all(vec) vec.begin(), vec.end()
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const int dx[4] = {1, 0,-1, 0};
const int dy[4] = {0, 1, 0,-1};

//------------------------------------------------------//

int main() {
  rep(i, 5){
    int x;
    cin >> x;
    if(x == 0){
      cout << i+1 << endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 3496
# coding: utf-8
# Your code here!

strs = input()
check = ['A', 'G', 'C', 'T']

maxval = 0
cnt = 0
for s in strs:
    if s in check:
        cnt += 1
        if cnt > maxval:
            maxval = cnt
    else:
        cnt = 0
            
    
print(maxval)

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

#define mt make_tuple
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sqr(x) ((ll)(x) * (x))

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

    vector <ll> ranac(w + 1, -1LL);
    vector <pii> v(n);

    for(int i = 0; i < n; i++)
    {
        int tez, vred;
        cin >> tez >> vred;
        v[i] = mp(tez, vred);
    }

    ranac[0] = 0;

    for(int i = 0; i < n; i++)
    {
        for(int j = w; j >= 0; j--)
        {
            if(j + v[i].fi <= w)
            {
                ranac[j + v[i].fi] = max(ranac[j+v[i].fi], ranac[j] + v[i].se);
            }
        }
    }

    ll najveci = -2;

    for(int i = 0; i <= w; i++)
    {
        najveci = max(najveci, ranac[i]);
    }

    cout << najveci << '\n';

    return 0;
}


Measured memory_bytes: 1152
package main

import (
	"fmt"
)

func main() {
	var n, a, b int
	fmt.Scanf("%d %d %d", &n, &a, &b)
	answer := countRedBall(n, a, b)
	fmt.Println(answer)
}

func countRedBall(n, a, b int) int {
	x := n / (a + b)
	y := n % (a + b)
	cntRedBall := x * a
	if y > a {
		cntRedBall += a
	} else {
		cntRedBall += y
	}
	return cntRedBall
}


Measured memory_bytes: 512
import java.util.*;
public class Main{   
    public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] a = new int[n];
      for(int i = 0;i < n;i++)a[i]=sc.nextInt();
      int[] cnt = new int[9];
      for(int i = 0;i < n;i++){
      	if(a[i]<400)cnt[0]++;
        else if(a[i]<800)cnt[1]++;
        else if(a[i]<1200)cnt[2]++;
        else if(a[i]<1600)cnt[3]++;
        else if(a[i]<2000)cnt[4]++;
        else if(a[i]<2400)cnt[5]++;
        else if(a[i]<2800)cnt[6]++;
        else if(a[i]<3200)cnt[7]++;
        else cnt[8]++;
      }
      int sum = 0;
      for(int i = 0;i < 8;i++)if(cnt[i]>0)sum++;
      if(sum==0)System.out.println(1+" "+(sum+cnt[8]));
      else{
      	System.out.println(sum+" "+(sum+cnt[8]));
      }
    }
    public static int lcm(int x, int y){
      return x*y/gcd(x,y);
    }
    public static int gcd(int x, int y){
      if(x < y)return gcd(y,x);
      if(y==0)return x;
      return gcd(y,x%y);
    }
}


Measured memory_bytes: 22100
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	ll a, b;

	cin>>a>>b;

	if(a<=b){
		cout<<a<<endl;
	}else{
		cout<<a-1<<endl;
	}

}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void)
{
    int k,a,b;
    cin >> k >> a >> b;
    while(1){
        if(a>b)
        {
            cout << "NG";
            return 0;
        }
        if(a%k==0)
            {
                cout << "OK";
                return 0;
            }
        a++;
    }
    cout << "NG";
    return 0;
}


Measured memory_bytes: 3624
#include<stdio.h>
#include<string.h>
int main(){
	int i,j,len,c=0;
	char s[101];
	scanf("%s",&s);
	len=strlen(s);
	for(i=0,j=len-1;i<j;i++,j--){
		if(s[i]!=s[j])
			c++;
	}
	printf("%d",c);
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
int main(){
	int n,m,ans=0;
	cin >>n>>m;
	vector<int>cnt(m);
	rep(i,m)
		cnt[i]=0;
	rep(i,n){
		int k,a;
		cin >>k;
		rep(j,k){
			cin >>a;
			cnt[a-1]++;
		}
	}
	rep(i,m){
		if (cnt[i]==n)
			ans++;
	}
	cout <<ans;
}


Measured memory_bytes: 256