akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int n, k;
    cin >> n >> k;
    vector<ll> arr(n, 0);
    for(ll& val: arr) {
        cin >> val;
    }
    vector<ll> dp(n, INT_MAX);
    dp[0] = 0;
    for(int i = 1; i < n; i++) {
        for(int j = 1; j <= k; j++) {
            if (i - j >= 0) {
                dp[i] = min(dp[i], dp[i-j] + abs(arr[i]-arr[i-j]));
                // cout << "cand:  " << dp[i-j] + abs(arr[i]-arr[i-j]) << endl;
            }
            else
                break;
        }
        // cout << dp[i] << endl;
    }
    cout << dp.back() << endl;
    return 0;
}



Measured memory_bytes: 1792
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n)  { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x)         { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};
bool b[1299710];
int main() {
	vi pri;
	FOR(i,2, 1299710) {
		if (!b[i]) {
			pri.push_back(i);
			for (int j = i * 2;j < 1299710;j += i) {
				b[j] = true;
			}
		}
	}
	int n;
	while (cin>>n,n) {
		int l = 0;
		int r = 99999;
		while (abs(l-r)>1) {
			if (pri[(l + r) / 2] > n)
				r = (l + r) / 2;
			else
				l = (l + r) / 2;
		}
		if (pri[l] == n || pri[r] == n)
			cout << 0 << endl;
		else
			cout << pri[r] - pri[l] << endl;
	}
}

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

#ifdef LOCAL
#include "../lib/dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

typedef long long ll;
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve()
{
  string s;
  cin >> s;
  int N = s.size();
  vector<int> p(N);
  iota(p.begin(), p.end(), 0);
  for (int i = 0; i < N; i++) {
    int pos = p[i];
    for (int j = 0; j < 10; j++) {
      if (s[pos] == 'R')
        pos++;
      else
        pos--;
    }
    p[i] = pos;
  }
  dump(p);
  vector<vector<int>> jp(105, vector<int>(N));
  for (int i = 0; i < N; i++) {
    jp[0][i] = p[i];
  }
  for (int k = 1; k <= 100; k++) {
    for (int i = 0; i < N; i++) {
      int pos = jp[k - 1][i];
      for (int j = 1; j < 10; j++) {
        pos = jp[k - 1][pos];
      }
      jp[k][i] = pos;
    }
  }
  vector<int> ans(N);
  for (int i = 0; i < N; i++) {
    ans[jp[100][i]]++;
  }
  dump(ans);
  for (int i = 0; i < N; i++) {
    cout << ans[i] << " ";
  }
  cout << endl;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 42568
#include <stdio.h>
#define Max 100000
int main(){
  int i,T[Max],S[Max],k,j=0,count=0,n,left,right,mid; 
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&T[i]);
  }
  scanf("%d",&k);
  for(i=0;i<k;i++){
    scanf("%d",&S[i]);
  }
  for(i=0;i<k;i++){
    left=0;
    right=n;
    while(left < right){
      mid = (left + right)/2;
      if(T[mid] == S[i]){
      count++;
      break;
      }else if(S[i] < T[mid]){
      right = mid;
      }else{
	left = mid +1;
      }
    }
  }
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 1192
import java.util.Scanner;

public class Main {

    private void solve() {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        int h = sc.nextInt();
        int w = sc.nextInt();

        int[][] masu = new int[H][W];

        for (int i = 0; i < h; i++) {
            for (int j = 0; j < W; j++) {
                masu[i][j] = 1;
            }
        }
        for (int j = 0; j < w; j++) {
            for (int i = 0; i < H; i++) {
                masu[i][j] = 1;
            }
        }

        int ans = 0;
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if (masu[i][j] == 0) {
                    ans++;
                }
            }
        }

        System.out.println(ans);

    }

    // Main
    public static void main(String[] args) {
        new Main().solve();
    }

}


Measured memory_bytes: 23764
def aaa(aa):
    return aa.replace('apple', 'peach')
def bbb(bb):
    return bb.replace('peach', 'apple')


a=raw_input().split()
b = 0
for i in a:
    if 'apple' in i:
        i=aaa(i)
        a[b] = i
        b+=1
        continue

    if 'peach' in i:
        i = bbb(i)
        a[b] = i
        b+=1
        continue
    b+=1

print " ".join(a)

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

using namespace std;

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

    scanf(" %d %d %d", &a, &b, &c);

    if(a <= b * c)
    {
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 3660
import math

d, g = map(int, input().split())
l = [list(map(int, input().split())) for _ in range(d)]

l_money = [[(i+1)*100]*(l[i][0]-1) + [(i+1)*100 + l[i][1]] for i in range(d)]
l_sum = [sum(l_money[x]) for x in range(d)]
# print(l)
# print(l_money)
# print(l_sum)

ans = float("inf")
for i in range(2**d):
    cnt = 0
    now = 0
    amari = []
    for j in range(d):
        if ((i>>j) & 1):
            now += l_sum[j]
            cnt += l[j][0]
        else:
            amari.append(l_money[j][:-1])
    amari.sort(reverse=True)

    # print(now, cnt, amari)

    if now >= g:
        ans = min(ans, cnt)
        continue

    cnt_add_min = 1000
    for k in range(len(amari)):
        if amari[k]:
            cnt_add = math.ceil((g-now)/amari[k][0])
            if cnt_add <= len(amari[k]):
                cnt_add_min = min(cnt_add_min, cnt_add)

    if cnt_add_min != 1000:
        cnt += cnt_add_min
        ans = min(ans, cnt)
    else:
        continue

print(ans)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC111 {
	class ABC111_B {
		static void Main(string[] args) {
			var N = int.Parse(Console.ReadLine());
			var div = N / 111;
			var sur = N % 111;
			if(sur == 0 && N != 0) {
				Console.WriteLine(GetDoublets(div, 3));
				return;
			}

			if (sur > 0) {
				Console.WriteLine(GetDoublets(div+1, 3));
				return;
			}
		}
		
		private static int GetDoublets(int n, int nDigits) {
			var sb = new StringBuilder();
			for (int i = 0; i < nDigits; i++) {
				sb.Append(n.ToString());
			}
			return int.Parse(sb.ToString());
		}
	}
}


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

#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
	cin.sync_with_stdio(false); cin.tie(0);
	cin.exceptions(cin.failbit);

	double r; cin >> r;
	cout << fixed << setprecision(9) << (2 * acos(-1) * r) << endl;
}


Measured memory_bytes: 3812
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define ALL(n) n.begin(),n.end()

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	if (b >= c) cout << "delicious" << endl;
	else if (c - b <= a) cout << "safe" << endl;
	else cout << "dangerous" << endl;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

//const long long int MOD = 1000000007;
//const int MOD = 998244353;
const long long int MOD = 998244353;
const double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> N;
	vector<int>x(N);
	vector<int>y(N);
	for (int i = 0; i < N; i++) {
		cin >> x[i] >> y[i];
	}
	vector<long long int>by(N + 1, 1);
	for (int i = 1; i <= N; i++) {
		by[i] = by[i - 1] * 2;
		by[i] %= MOD;
	}
	long long int ans = by[N];
	ans--;
	ans -= N;
	ans += MOD;
	ans %= MOD;
	vector<vector<int>>skip(N, vector<int>(N));
	for (int i = 0; i < N; i++) {
		for (int j = i+1; j < N; j++) {
			if (skip[i][j])continue;
			vector<int>box;
			box.push_back(i);
			box.push_back(j);
			for (int k = j + 1; k < N; k++) {
				if ((y[k] - y[j])*(x[j] - x[i]) == (y[j] - y[i])*(x[k] - x[j])) {
					box.push_back(k);
				}
			}
			ans += MOD;
			ans += box.size() + 1;
			ans -= by[box.size()];
			ans %= MOD;
			for (auto k : box) {
				for (auto l : box) {
					skip[k][l] = 1;
				}
			}
		}
	}
	cout << ans << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  vector<long long> B(N + 1, 0);  // 累積和テーブル
  int mod = 1000000007;

  for (int i = 0; i < N; i++) {
    cin >> A[i];
    B[i + 1] = B[i] + A[i];
  }

  long long ans = 0;

  // i について全探索する
  for (int i = 0; i < N; i++) {
    // 累積和を使ってA[i+1] + ... + A[N] を求める
    long long sum = (B[N] - B[i + 1]) % mod;

    ans += A[i] * sum;
    ans %= mod;
  }

  cout << ans << endl;
}


Measured memory_bytes: 5644
#include<bits/stdc++.h>
using namespace std;
long long x[100005];
int main()
{
	long long n,a,b;
	long long ans=0;
	scanf("%lld%lld%lld",&n,&a,&b);
	for(int i=1;i<=n;i++)scanf("%lld",&x[i]);
	for(int i=2;i<=n;i++)ans+=min(a*(x[i]-x[i-1]),b);
	printf("%lld\n",ans);
	return 0;
}

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

using lli = long long int;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

template <class T>ostream &operator<<(ostream &o,const pair<T, T>&p)
{o<<"("<<p.first<<", "<<p.second<<")";return o;}

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

const lli MOD = 1000000007LL;

lli modpow(lli a, lli n){
    lli res = 1;

    for(lli ai = a; n; n>>=1){
        if(1&n) res = (res*ai)%MOD;
        ai=(ai*ai)%MOD;
    }
    return res;
}

lli inv(lli n){
    return modpow(n, MOD-2);
}

lli modperm(lli n, lli k){
    lli res = 1;
    rep(i, k){
        res = (res*(n-i))%MOD;
    }
    return res;
}

lli modcomb(lli n, lli k){
    return (modperm(n, k)*inv(modperm(k, k)))%MOD;
}

lli posmod(lli n){
    lli res = n;
    res %= MOD;
    if(res < 0) res += MOD;
    return res;
}
lli k;
lli sum = 0;

int main(void){
    //int ti = clock();
    cin >> k;
    rep(i, k){
        rep(j, k){
            rep(m, k){
                sum += __gcd(__gcd(i+1, j+1), m+1);
            }
        }
    }
    cout << sum << endl;
    //cout << fixed << setprecision(10) << 1.0*(clock()-ti)/CLOCKS_PER_SEC << endl;
    return 0;
}


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

#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()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;


int main(){
  
  ll n,m,i,j,k;
  bool ok = true;
  
  cin >> n >> m;
  vector<int> s(m), c(m);
  rep(i,m){
    cin >> s.at(i) >> c.at(i);
  }
  
  rep(i,m){
    for(j = i+1; j < m; j++){
      if((s.at(i) == s.at(j)) && (c.at(i) != c.at(j))){
        ok = false;
        break;
      }  
    }
    if((s.at(i) == 1) && (c.at(i) == 0) && (n != 1))
      ok = false;
  }
  
  if(!ok){
    cout << -1 << endl;
  }
  else{
    ll ans = 0;
    /*rep(i,m){
      bool b = true;
      rep(j,i){
        if((i != 0) && (s.at(i) == s.at(j))){
          b = false;
        }
      }
      if(b)
        ans += c.at(i)*pow(10, n-s.at(i));
    }*/
    
    vector<int> b(n);
    rep(i,m){
      b.at(s.at(i)-1) = c.at(i);
    }
    
    rep(i,n){
      ans += b.at(i) * pow(10, n-i-1);
    }
    
    if(ans < pow(10, n-1))
      ans += pow(10, n-1);
    
    if((n == 1) && (m == 0))
       ans = 0;
    if(n == 1){
      bool l = false;
      rep(i,m){
        if(c.at(i))
          l = true;
      }
      if(!l)
        ans = 0;
    }
      
    cout << ans << endl;
    
  }
  
}




Measured memory_bytes: 256
def main():
    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
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n = int(input())
    for i in range(1, 50001):
        if int(i*1.08) == n:
            print(i)
            break
    else:
        print(':(')

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include<stdio.h>
#include<string.h>
#define min(x,y) ((x<y)?x:y)
int tn[1005][1005],tp[1005][1005],f[1005][1005];
void swap(int *a,int *b){
	int x;
	x=*a;*a=*b;*b=x;
	return;
}
int main(){
	int i,j,k,w,h,n,m,a,b,ans;
	while(1){
		scanf("%d%d%d%d",&n,&m,&h,&k);
		if(n==0)break;
		memset(f,0,sizeof(f));
		memset(tn,0,sizeof(tn));
		memset(tp,0,sizeof(tp));
		for(i=1;i<=n;i++){
			scanf("%d",&tp[h][i]);
			tn[0][i]=i;
		}
		for(i=0;i<m;i++){
			scanf("%d%d",&a,&b);
			f[b][a]=1;
		}
		for(i=1;i<h;i++){
			memcpy(tn[i],tn[i-1],sizeof(int)*(n+1));
			memcpy(tp[h-i],tp[h-i+1],sizeof(int)*(n+1));
			for(j=1;j<=n;j++){
				if(f[i][j])swap(&tn[i][j],&tn[i][j+1]);
				if(f[h-i][j]==1)swap(&tp[h-i][j],&tp[h-i][j+1]);
			}
		}
		ans=0;
		for(j=1;j<=n;j++){
			if(tn[1][j]<=k){
				if(f[1][j]==1)ans+=tp[1][j+1];
				else if(f[1][j-1]==1)ans+=tp[1][j-1];
				else ans+=tp[1][j];
			}
		}
		a=ans;
		//printf(" %d\n",ans);
		for(i=1;i<h;i++){
			for(j=1;j<=n;j++){
				if(tn[i][j]<=k){
					if(f[i][j]==1 && tn[i][j+1]>k)  ans=min(ans,a+tp[i][j]-tp[i][j+1]);
					if(f[i][j-1]==1 && tn[i][j-1]>k)ans=min(ans,a+tp[i][j]-tp[i][j-1]);
				}
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 11000
using System;
using System.Collections.Generic;
using System.Linq;


public class Contest
{
	public static void Main()
	{
		int[] a = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<string,int>(s => int.Parse(s)));

//		int[] b = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<string,int>(s => int.Parse(s)));
//		int[] c = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<string,int>(s => int.Parse(s)));
//		int[] d = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<string,int>(s => int.Parse(s)));
/*
		int m = a[1];
		int[][] e = new int[m][];
		for(int i=0; i<m; i++) {
			e[i] = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<string,int>(s => int.Parse(s)));
			e[i] = e[i].Concat(new int[] { i }).ToArray();
		}

		Array.Sort(e,(x,y)=>((x[0]==y[0])?(x[1]-y[1]):(x[0]-y[0])));
*/

		int h=a[0];int w=a[1];int k=a[2];
		
		int total = (int)Math.Pow(2,w-1);

		int[,] route = new int[w,total];
		bool[] valid = new bool[total];
		ulong[,] rcnt = new ulong[w,w];

		for(int j=0; j<total; j++){
			valid[j] = true;
			for(int i=0; i<w-2; i++) if( (((j>>i)&1)==1) && (((j>>(i+1))&1)==1) ) {
				valid[j] = false;
				break;
			}
			if (!valid[j]) continue;
			
			route[0,j] = ((j&1)==0) ? 0 : 1 ;
			for(int i=1; i<w-1; i++)	{
				if(((j>>(i-1))&1)==0) {
					route[i,j] = (((j>>i)&1)==0) ? i : i+1 ;
				}else{
					route[i,j] = i-1;
				}
			}
			route[w-1,j] = (((j>>(w-2))&1)==0) ? w-1 : w-2 ;
			
			for(int i=0; i<w; i++)	rcnt[i,route[i,j]]++;
		}

		ulong[] tcnt = new ulong[w];
		tcnt[0] = 1;
		for(int i=0; i<h; i++){
			ulong[] tmp = new ulong[w];
			for(int l=0; l<w; l++)for(int p=0; p<w; p++)	tmp[p] += rcnt[l,p]*tcnt[l];
			for(int p=0; p<w; p++)	tcnt[p] = tmp[p]%1000000007;
		}

		string ans = tcnt[k-1].ToString();

		Console.WriteLine(ans);
	}
	
	private static int calc_main(int[] a,int[] b,int[] c,int[] d) {



		return 0;
	}




}


Measured memory_bytes: 11220
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int K = sc.nextInt();
    
    	if(K<=A) System.out.println(K);
    	else if(K <= A+B) System.out.println(A);
    	else System.out.println(A-(K-A-B));
    }
}

Measured memory_bytes: 35724
using System;

namespace ConsoleApp4
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(System.Console.ReadLine());
            long[] nm = Array.ConvertAll(System.Console.ReadLine().Split(' '), long.Parse);
            long mal = nm[0];
            for(int i=0; i<a;i++)
            {
                if (nm[i] == 0)
                {
                    Console.WriteLine(0);
                    return;
                }
            }
            for (int i=1; i<a;i++)
            {  
                try
                {
                    checked
                    {
                        if (mal > 1000000000000000000)
                        {
                            Console.WriteLine(-1);
                            return;
                        }
                        mal *= nm[i];
                        if(mal>1000000000000000000)
                        {
                            Console.WriteLine(-1);
                            return;
                        }
                    }
                }
                catch(OverflowException ex)
                {
                    Console.WriteLine(-1);
                    return;
                }
                

            }
            System.Console.WriteLine(mal);

        }
    }
}


Measured memory_bytes: 41996
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,i;
	cin>>n;
	vector<int> a(n);
	map<int,long long> cnt;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		cnt[a[i]]++;
	}
	long long ret=0;
	map<int,long long>::iterator p;
	for(p=cnt.begin();p!=cnt.end();p++)
		ret+=(p->second-1)*p->second/2;
	for(int k=0;k<n;++k)
	{
		long long n=cnt[a[k]];
		long long tmp=ret-(n-1)*n/2+(n-2)*(n-1)/2;
		cout<<tmp<<"\n";
	}
	return 0;
}

Measured memory_bytes: 10240
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <vector>
#include <queue>
#include <unordered_map> 
#include <iomanip>
#include <random>
#include <future>
#include <thread>
#include <utility>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#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 INF (INT_MAX/3)
#define PSB push_back
#define PN 1000000007
typedef long long LL;
#define int long long


//booooooooooooost
//#include <boost/multiprecision/cpp_int.hpp>
//#include <boost/multiprecision/cpp_dec_float.hpp>
//namespace mp = boost::multiprecision;	//多倍長整数(mp::cpp_int), 多倍長小数(mp::cpp_dec_float_100)



LL inv_mod(LL a, LL m)
{
	LL b, x, u, q, tmp;

	b = m; x = 1; u = 0;
	while (b > 0) {
		q = a / b;
		tmp = u; u = x - q * u; x = tmp;
		tmp = b; b = a - q * b; a = tmp;
	}

	return (x < 0) ? m + x : x;
}

int N, A, B;
vector<int> h;

int binary_s(int imin, int imax) {
	if (imax < imin) return imin;
	else {
		int imid = imin + (imax - imin) / 2;
		int key = 0;
		for (int i = 0; i < N; ++i) {
			int tmp = h[i] - B * imid;
			if (0 < tmp) key += (tmp + (A - B - 1)) / (A - B);
		}

		if (imid >= key) {
			return binary_s(imin, imid - 1);
		} else if (imid < key) {
			return binary_s(imid + 1, imax);
		}
	}
}


signed main() {

	cin >> N >> A >> B;
	for (int i = 0; i < N; ++i) {
		int _hi;
		cin >> _hi;
		h.push_back(_hi);
	}

	sort(h.begin(), h.end(), [](int x, int y){ return x > y; });

	const int MAX_ANS = (h[0] + B - 1) / B;
	cout << binary_s(0, MAX_ANS) << endl;


	return 0;
}

Measured memory_bytes: 1400
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		String w = s.nextLine();
		int count = 0;
		List<String> t = new ArrayList<>();
		
		while(true) {
			String test = s.next();
			if(test.equals("END_OF_TEXT")) {
				break;
			}else {
				t.add(test);
			}
		}
		
		for(int j =0;j<t.size();j++) {
			if(t.get(j).equalsIgnoreCase(w)) {
				count++;
			}
		}

		System.out.println(count);
	}

}

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

int main() {
    int N, A, B;
    cin >> N >> A >> B;
    if (N * A < B) {
        cout << N * A <<endl;
    }
    else if (N * A > B) {
        cout << B << endl;
    }
    else {
        cout << B << endl;
    }
    return 0;
}


Measured memory_bytes: 256
/*                    */
#include <bits/stdc++.h>
using namespace std;
using lint = int64_t;
char to_char(int n) { return n + '0'; };
int to_int(char c) { return c - '0'; };
/*                    */

void solve(string s, int ord, int k);
int cnt = 0;

int main() {
  int k;
  cin >> k;
  int ord = 1;
  if (k < 10) {
    cout << k << endl;
    return 0;
  }
  cnt = 9;
  ord = 2;
  while (true) {
    for (int i = 1; i <= 9; i++) {
      solve(to_string(i), ord, k);
    }
    ord++;
  }
}

void solve(string s, int ord, int k) {
  if (s.size() == ord) {
    cnt++;
    if (cnt == k) {
      cout << s << endl;
      exit(0);
    }
    return;
  }
  for (int i = -1; i <= 1; i++) {
    int tmp = to_int(s.back()) + i;
    if (tmp < 0 || tmp > 9) continue;
    s.push_back(to_char(tmp));
    solve(s, ord, k);
    s.pop_back();
  }
}

Measured memory_bytes: 256
import Foundation
func toTuple<T>(_ args: [T]) -> (T, T) { (args[0], args[1]) }
func toTuple<T>(_ args: [T]) -> (T, T, T) { (args[0], args[1], args[2]) }
func toTuple<T>(_ args: [T]) -> (T, T, T, T) { (args[0], args[1], args[2], args[3]) }
func readInts() -> [Int] { readLine()!.split(separator: " ").map { Int($0)! } }
func readDoubles() -> [Double] { readLine()!.split(separator: " ").map { Double($0)! } }
func readStrings() -> [String] { readLine()!.split(separator: " ").map { String($0) } }

let xi = readInts()
var ans = 0
for (i, x) in xi.enumerated() {
  ans = i + 1
  if (x == 0) { break }
}
print(ans)

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

using namespace std;
typedef long long LL;
#define rep(i, l, r) for (int i = l; i<r;i++)
#define print(arr, r, c) rep(i, 0, r) {rep(j, 0, c)cout<<arr[i][j]<<"";cout<<endl;}
#define all(b) b.begin() , b.end()
#define mp(a, b) make_pair(a,b)
#define pb(a) push_back(a)
#define vi vector<int>
#define vd vector<double>
#define vs vector<string>
#define vii vector<pair<int,int>>
#define vvi vector<vector<int>>
#define ii pair<int,int>
#define turnOff(k, i) (k&(~(1<<(i-1))))
#define isOn(k, i) (k&&(1<<i-1)?true:false)
#define pll pair<long long int , long long int>
#define ull unsigned long long int
#define ll  long long int
#define add(a, b) ((a+b)%MOD)
#define sub(a, b) ((a-b+MOD)%MOD)
#define mul(a, b) ((1ll*a*b)%MOD)
#ifdef  DEBUG
#define MAXN 203
#else
#define MAXN 402
#endif
#define MAXLG 20
#define endl '\n'
#define PI 3.141592653589793238
#define MOD (1000000007)
#define INF (2000000000)
#define EPS (0.00000001)
#define treap treapNode

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
#ifdef DEBUG
    freopen("input", "r", stdin);
#endif
     ii price[4];
    ll q,h,s,d;
    cin>>q>>h>>s>>d;
    price[0] = mp(q,1);
    price[1] = mp(h,2);
    price[2] = mp(s,4);
    price[3] = mp(d,8);

    sort(price,price+4,[](ii a,ii b) { return a.first/(1.00*a.second) < b.first/(1.00*b.second);});
    ll n;
    cin>>n;
    n = n*4;
    ll ans = 0;
    rep (i,0,4) {
        int quant = price[i].second;
        int p = price[i].first;
        ans += (n/quant)*p;
        n = n%quant;

    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Security;
using System.Xml.Serialization;

namespace AtCoderCs
{

    class Program
    {

        const int Mod = 1000000007;

        static void Main()
        {

            var arg = Console.ReadLine().ToArray();
            var result = 0L;

            for (int i = 0, l = arg.Length, counter = 0; i < l; i++)
                if (arg[i] == 'W')
                    result += i - counter++;

            Console.WriteLine(result);
        }



    }
}


Measured memory_bytes: 13152
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>

using namespace std;


int main() {

    int N;
    cin >> N;
    string S;
    cin >> S;

    char c = S[0];
    int cnt = 1;
    for (int i = 1; i < N; ++i) {
        if (c == S[i]) {
            continue;
        } else {
            c = S[i];
            cnt += 1;
        }
    }

    cout << cnt << endl;

    return 0;

}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
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; }
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
const ll INF = 1LL<<60;
const ll mod=1e9+7;
using namespace std;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

ll a[220000],b[220000];
int main(){
    ll n;
    cin>>n;
    rep(i,0,n)cin>>a[i]>>b[i];
    sort(a,a+n);
    sort(b,b+n);
    if(n%2==1){
        cout<<labs(b[(n-1)/2]-a[(n-1)/2])+1;
    }
    else{
        ll p=(b[(n-1)/2]+b[n/2]-a[(n-1)/2]-a[n/2]); 
        cout<<p+1;
    }
}


Measured memory_bytes: 6712
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
int main()
{
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    bool swap_flag = true;
    rep(i,n-1){
        if (p[i] > p[i+1]){
            if (swap_flag == false){
                cout << "NO" << endl;
                return 0;
            }
            int min_s = 51;
            int swap_offset;
            rep2(j,i+1,n){
                if (p[j] < min_s){
                    min_s = p[j];
                    swap_offset = j;
                }
            }
            if (p[i-1] >= min_s){
                cout << "NO" << endl;
                return 0;
            }
            swap(p[i], p[swap_offset]);
            swap_flag = false;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  using namespace std;
  long long a, b, c, k;
  cin>>a>>b>>c>>k;
  long long ans = 0;
  if(k > 0){
    if(k >= a){
      ans += a;
      k -= a;
    }else{
      ans += k;
      k = 0;
    }
  }
  if(k > 0){
    if(k >= b){
      k -= b;
    }else{
      k = 0;
    }
  }
  if(k > 0){
    if(k >= c){
      k -= c;
      ans -= c;
    }else{
      ans -= k;
      k = 0;
    }
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

#define vi vector<int>
#define pb push_back
#define lli long long int
#define INF 1000000000


void solve() {
    int d, t, s;
    cin >> d >> t >> s;
    if (t * s >= d)cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

#ifndef ONLINE_JUDGE

    freopen("input.txt", "r", stdin);

    freopen("output.txt", "w", stdout);
#endif

    solve();




    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)

using namespace std;
typedef long long ll;

const ll INF = 1e13;

int main(){
	ll N, A, B;
	
	cin >> A >> B >> N;

	ll ans = INF;
	rep(i,N+1){
		if( i == 0 ) continue;
		if( B%i == 0 ){
			rep(j,N){
				ll nA = (B/i) * (j+1);
				ans = min( ans, abs(A - nA) );
			}
		}
	}
	rep(j,N){
		ll nA = B * (j+1);
		ans = min( ans, abs(A - nA) );
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3088
#!/usr/bin/env python3
import sys, math, fractions, itertools

def connected_num(N, G):
    # ノード0から行けるノードの数が全体のノード数に一致するか
    visited = [0] * N
    stack = [0]
    while(len(stack) > 0):
        n = stack.pop()
        if visited[n] == 0:
            stack += G[n]
            visited[n] = 1
    return sum(visited) != N
def solve(N: int, M: int, a: "List[int]", b: "List[int]"):
    counter = 0
    for j in range(M):
        G = [[] for _ in range(N)]
        for i in list(range(j))+list(range(j+1, M)):
            G[a[i]-1].append(b[i]-1)
            G[b[i]-1].append(a[i]-1)
        if connected_num(N, G):
            counter += 1
    print(counter)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    a = [int()] * (M)  # type: "List[int]" 
    b = [int()] * (M)  # type: "List[int]" 
    for i in range(M):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    solve(N, M, a, b)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5332
#include <iostream>
#include <strstream>
#include <string>
#include <deque>
#include <vector>
#include <map>
typedef unsigned int UINT;
using namespace std;

int main(void) {
    map<string, int > mas;
    int H, W;
    string in;
    cin >> H >> W;
    const int size = H * W;
    for (int index = 0; index < size; index++) {
        cin >> in;
        mas[in] = index;
    }
    int ans_index = mas["snuke"];

    string ans = "A";
    ans[0] = 'A' + ans_index % W;
    ans+= to_string((ans_index /W)+1);
    cout << ans << endl;
    return 0;
}


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

int main() {
  string S;
  string way;
  char c;
  int Q,p,rc=0,f=0,l=0;
  cin >> S >> Q;
  for(int i=0;i<Q;i++) {
    cin >> p;
    if(p==1) {
      way.pb('r');
      rc++;
    }else{
      cin >> p;
      cin >> c;
      way.pb(c);
      if(p==1) way.pb('f');
      else way.pb('l');
    }
  }
  way.insert(way.begin(),'o');
  p=0;
  if(rc%2==1) reverse(S.begin(),S.end());
  for(int i=way.size()-1;0<i;i--) {
	if(way.at(i)=='r'){
      if(way.at(i-1)!='r'){
        p++;
      }else i--;
    }else if(way.at(i)=='f'){
      if(p%2==1){
        S.insert(S.end()-l,way.at(i-1));
        i--;
        l++;
      }else{
        S.insert(S.begin()+f,way.at(i-1));
        i--;
        f++;
      }
    }else{
      if(p%2==1){
        S.insert(S.begin()+f,way.at(i-1));
        i--;
        f++;
      }else{
        S.insert(S.end()-l,way.at(i-1));
        i--;
        l++;
      }
    }
  }
  cout << S << endl;
}

Measured memory_bytes: 1412
from collections import defaultdict
n = int(input())
v = list(map(int, input().split()))
rec0 = defaultdict(int)
rec1 = defaultdict(int)
for i in range(n):
    if i % 2 == 0:
        rec0[v[i]] += 1
    else:
        rec1[v[i]] += 1

rec00 = []
rec11 = []
for i, k in rec0.items():
    rec00.append((i, k))
for i, k in rec1.items():
    rec11.append((i, k))


rec00 = sorted(rec00, key=lambda x: x[1], reverse=True)
rec11 = sorted(rec11, key=lambda x: x[1], reverse=True)
m = n // 2
if rec00[0][0] != rec11[0][0]:
    print(abs(m - rec00[0][1]) + abs(m - rec11[0][1]))
else:
    if len(rec00) == 1 and len(rec11) == 1:
        print(m)
    elif len(rec00) == 1:
        print(abs(m - rec11[0][1]))
    elif len(rec11) == 1:
        print(abs(m - rec00[0][1]))
    else:
        a = abs(m - rec00[1][1])
        b = abs(m - rec11[1][1])
        num = min(a + abs(m - rec11[0][1]), abs(m - rec00[0][1]) + b)
        print(num)





Measured memory_bytes: 21532
import math as mh
import fractions as fr
from functools import reduce

n, p = (int(_) for _ in input().split())
x = list(int(_) for _ in input().split())
x.append(p)
x.sort()

dx = []
for i in range(1,len(x)):
    dx.append(x[i] - x[i-1])

exgcd = reduce(fr.gcd, dx)
print(exgcd)



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

int main()
{
	int n,p;
	while(cin >> n >> p, n||p)
	{
		int s=p;
		int snum[64] = {0};

		for(int i=0; true; i=(i+1)%n)
		{
			if(s)
			{
				s--;
				snum[i]++;
				if(snum[i]==p)
				{
					cout << i << endl;
					break;
				}
			}
			else
			{
				s=snum[i];
				snum[i]=0;
			}
		}
		
	}
}

Measured memory_bytes: 868
import itertools
N,M,Q=map(int,input().split())
a=[]
b=[]
c=[]
d=[]
for i in range(Q):
  ta,tb,tc,td=map(int,input().split())
  a+=[ta]
  b+=[tb]
  c+=[tc]
  d+=[td]
maxs=0
A=[i for i in range(M)]
for i in itertools.combinations_with_replacement(A,N):
  s=0
  for k in range(Q):
    if i[b[k]-1]-i[a[k]-1]==c[k]:
      s+=d[k]
  maxs=max(maxs,s)
      
print(maxs)


Measured memory_bytes: 9048
class Sieve:
    """区間[2,n]の値を素因数分解する"""

    def __init__(self, n=1):
        primes = []
        f = [0] * (n + 1)
        f[0] = f[1] = -1
        for i in range(2, n + 1):  # 素数を探す
            if f[i]: continue
            primes.append(i)
            f[i] = i  # 素数には自身を代入
            for j in range(i * i, n + 1, i):  # 合成数に素因数を書き込む
                if not f[j]:
                    f[j] = i  # 最小の素因数を代入
        self.primes = primes
        self.f = f

    # def is_prime(self, x) -> bool:  # 素数判定
    #     return self.f[x] == x
    #
    # def factor_list(self, x) -> list:  # 素因数分解の昇順リスト, [2,2,3,5,...]
    #     res = []
    #     while x != 1:
    #         res.append(self.f[x])
    #         x //= self.f[x]
    #     return res
    #
    # def factor(self, x) -> list:  # 素因数分解の頻度リスト, [[2,x],[3,y],[5,z],...]
    #     fl = self.factor_list(x)
    #     if not fl: return []
    #     res = [[fl[0], 0]]
    #     for p in fl:
    #         if res[-1][0] == p:
    #             res[-1][1] += 1
    #         else:
    #             res.append([p, 1])
    #     return res


def main():
    import sys

    input = sys.stdin.readline

    sieve = Sieve(10 ** 5)
    prime_set = set(sieve.primes)

    acc = [0] * (10 ** 5 + 1)
    cnt = 0
    for x in range(1, 10 ** 5 + 1):
        if (x % 2 == 1) and (x in prime_set) and ((x + 1) // 2 in prime_set):
            cnt += 1
        acc[x] = cnt

    q = int(input())
    for _ in range(q):
        left, right = map(int, input().split())  # [left,right]<=10**5
        res = acc[right] - acc[left - 1]
        print(res)


if __name__ == '__main__':
    main()


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

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds; 
 
typedef long long int ll;
typedef long int li;

const ll mod = 1000000007;
const ll inf = 1000000000000000000;

typedef vector<int> vi;
typedef vector<li> vli;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef vector<vli> vvli;
typedef vector<vll> vvll;
typedef vector<vs> vvs;
typedef map<ll, ll> mll;
typedef map<ll, string> mls;
typedef map<string, ll> msl;
typedef pair<ll, ll> pll;

// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#pragma GCC optimize ("-O3")
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define all(v) v.begin(), v.end()
#define mini(a) *min_element(all(a))
#define maxi(a) *max_element(all(a))
#define tol(s) transform(s.begin(), s.end(), s.begin(), ::tolower);
#define tou(s) transform(s.begin(), s.end(), s.begin(), ::toupper);
#define FOR(i, j, k, in) for(li i=j; i<k; i+=in)
#define RFOR(i, j, k, de) for(li i=j; i>=k; i-=de)
#define rep(i,j,k) FOR(i, j, k, 1)
#define rrep(i,j,k) RFOR(i, j, k, 1)
#define repc(v) for(auto it=v.begin(); it!=v.end(); it++)
#define rrepc(v) for(auto it=v.rbegin(); it!=v.rend(); it--)
#define T ll t; cin>>t; while(t--)

ll gen(){
    ll temp;
    cin>>temp;
    return temp;
}

ll power(ll a, ll b, ll m){    
    ll res=1;
    while(b>0){
        if(b&1){
            res=(res*a)%m;
            b--;
        }
        a=(a*a)%m;
        b=b>>1;
    }
    return res;
}

ll gcd(ll a, ll b){if(a==0)return b; else return gcd(b%a, a);}
ll lcm(ll a, ll b){return (a*b)/gcd(a,b);}

#define inpt(v) generate(all(v),gen)
#define sum(v) accumulate(all(v),0LL)
#define vpll vector<pll>
#define umap unordered_map
#define uset unordered_set
#define print(v) rep(i,0,n) cout<<v[i]<<" ";

int32_t main(){
  FAST

   ll n,x,t;
   cin>>n>>x>>t;

   ll ans = (n/x) * t;
   if(n%x) ans += t;
   cout<<ans;    


  
  return 0;
}

Measured memory_bytes: 3648
import java.util.*;
import java.io.*;

import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		InputReader in = new InputReader(System.in);
	    String s = in.readString();
	    int min = Integer.MAX_VALUE;
	    int lol = 0; 
	    for(int i = 0; i<s.length()-2; i++) {
	    	lol = Integer.valueOf(s.substring(i,i+3));
	    	min = Math.min(Math.abs( lol - 753), min);
	    }
	    System.out.println(min);
	}
}

class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	
	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public String next() {
		return readString();
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}


Measured memory_bytes: 22996
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
using ll = long long;
#define MAX_N 1000001
#define MAX_M 100010
const long long mod = 1e9 + 7;
#define vec vector<int>
#define vecll vector<ll>
#define vecllvec vector<vector<ll>>
#define vecb vector<bool>
#define vecBvec vector<vector<bool>>
#define vecst vector<string>
#define veche vector<char>
#define vecd vector<double>
#define vecvec vector<vector<int>>
#define vecDvec vector<vector<double>>
#define vecHvec vector<vector<char>>
#define all(x) (x).begin(),(x).end()
#define ent cout<<endl
#define printvec(vec) for(int aqw=0;aqw<vec.size();aqw++){cout<<vec[aqw]<<" ";}ent;
#define rep1(n) for(ll i = 0; i < (n); ++i)
#define rep2(i, n) for(ll i = 0; i < (n); ++i)
#define rep3(i, a, b) for(ll i = (a); i < (b); ++i)
#define rep4(i, a, b, c) for(ll i = (a); i < (b); i += (c))
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; }
#define INF 1e+9
#define print(x) cout<<x<<endl;
using pll = pair<ll, ll>;
#define PLL pair<ll, ll>;
#define MAX_V 1000
#define PI 3.141592653589793
// cout << setprecision(15) << std::fixed;


int main() {
	int n;
	cin >> n;
	vecll A(n), cou(62,0);
	for (ll i = 0;i < n;i++) {
		cin >> A[i];
	}
	ll  ans = 0;
	rep1(61) {
		ll x = 0;
		rep2(j, n) if (A[j] >> i & 1) x++;
		ll now = x * (n - x) % mod;
		rep2(j, i) now = now * 2 % mod;
		ans += now;
		ans %= mod;
	}
	print(ans);	
}




Measured memory_bytes: 2560
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#define MN 2000
#define ll long long
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return x*f;
}
int n,m,a[MN+5],f[MN+5];
ll ans;
int main()
{
    n=read();m=read();
    for(int i=1;i<=n;++i) a[i]=f[i]=read(),ans+=a[i];
    for(int i=1;i<n;++i)
    {
        ll tot=0;
        for(int j=1;j<=n;++j)
        {
            f[j]=min(f[j],a[(j-i+n-1)%n+1]);
            tot+=f[j];
        }
        ans=min(ans,1LL*i*m+tot);
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 256
s = input()

max_length = 0
counter = 0
for i in range(len(s)):
    if s[i] == "A" or s[i] == "C" or s[i] == "G" or s[i] == "T":
        counter += 1
    else:
        max_length = max(max_length, counter)
        counter = 0
max_length = max(max_length, counter)

print(max_length)


Measured memory_bytes: 8948
#include<stdio.h>
#include<iostream>
#include<algorithm> // sort(ALL())
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue> // push(), front(), pop() 先入れ先出し
#include<map> // 連想配列 map<string, int>
#include<iomanip>
#include<set>
#include<utility>
using namespace std;
#define FOR(i, a, b) for(int i=(a); i<(b);  i++)
#define REP(i, n)    for(int i=0;   i<(n);  i++)
#define REP1(i, n)   for(int i=1;   i<=(n); i++)
#define pb push_back
#define mp make_pair
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define EPS 1e-7
#define ALL(obj) (obj).begin(), (obj).end()
#define MAX_INDEX(arg) distance(arg.begin(), max_element(arg.begin(), arg.end()))
using ul    = unsigned long;
using ll    = long long;
using ld    = long double;
using vint  = vector<int>;
using vll   = vector<ll>;
using pint  = pair<int, int>;
using pll   = pair<ll, ll>;
using vpint = vector<pint>;
using vpll  = vector<pll>;
const int INF = (int)1e9 + 1;
const int MOD = (int)1e9 + 7;
#define INT(argu) (int)(argu+EPS)

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

  int n;
  scan(n);
  n /= 2;
  vint a(100002), b(100002);
  int x, y;
  REP(i, n){
    cin >> x >> y;
    a[x]++; b[y]++;
  }

  vint::iterator itrmaxa = max_element(ALL(a));
  vint::iterator itrmaxb = max_element(ALL(b));
  bool find_2_a = find(next(itrmaxa), a.end(), *itrmaxa) != a.end();
  bool find_2_b = find(next(itrmaxb), b.end(), *itrmaxb) != b.end();
  if( !(find_2_a || find_2_b) && (distance(a.begin(), itrmaxa) == distance(b.begin(), itrmaxb)) ){
    cout <<
    n*2 -
    max(
      max(*max_element(a.begin(), prev(itrmaxa)), *max_element(next(itrmaxa), a.end())) + *itrmaxb
    , max(*max_element(b.begin(), prev(itrmaxb)), *max_element(next(itrmaxb), b.end())) + *itrmaxa
    )
    << endl;
  }else{
    cout << n*2 - *itrmaxa - *itrmaxb << endl;
  }

  return 0;
}


Measured memory_bytes: 1024
def lcm(a, b):
    import fractions 
    return a // fractions.gcd(a, b) * b


def f(x, c, d):
    res = x
    res -= x//c
    res -= x//d
    res += x//lcm(c,d)
    return res

A, B, C, D = map(int, input().split())

ans = f(B, C, D) - f(A-1, C, D)
print(int(ans))

Measured memory_bytes: 5044