akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define reps(i,s,n) for(ll (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define reptr(i,n) for(ll (i)=(n);(i)>=0;--(i))
#define All(x) (x).begin(),(x).end()
#define Rall(a) (a).rbegin(), (a).rend()
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>
#define mp make_pair
#define pb push_back
const ll MOD=1e9+7;
using namespace std;

signed main() {
  int N;
  cin >> N;
  vector<pair<int,int> > ab,cd;

  for(int i=0;i<N;i++) {
    int a,b;
    cin >> a >> b;
    ab.push_back({a,b});
  }
  for(int i=0;i<N;i++) {
    int c,d;
    cin >> c >> d;
    cd.push_back({c,d});
  }
  sort(All(ab));
  sort(All(cd));

  ll cnt = 0;
  auto itr=ab.begin();
  auto itr2=cd.begin();

  auto tmp = ab.end()+1;

  while(cd.size()>0 && ab.size()>0){
    //あるitr2に対して、abを一周見た
    if(itr==ab.end()){
      //itr2と組み合わせる組が存在する
      if(tmp!=ab.end()+1){
        //tmpは消したいabの組
        ab.erase(tmp);
        cnt++;
      }
      cd.erase(itr2);

      if(ab.size()==0 || cd.size()==0){
        break;
      }
      //再び初期化
      itr = ab.begin();
      itr2 = cd.begin();
      tmp = ab.end()+1;
    }
    if(tmp==ab.end()+1){
      if((*itr2).first>(*itr).first && (*itr2).second>(*itr).second){
        tmp = itr;
      }
    }else if((*itr2).first>(*itr).first && (*itr2).second>(*itr).second){
      if((*tmp).second<(*itr).second){
        tmp = itr;
      }
    }
    itr++;

    if(ab.size()==0 || cd.size()==0){
      break;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
(defun int-to-digit (n &key (base 10)) ;; (int-to-digit 123) => (1 2 3)
  (if (zerop n)
      `(0)
      (labels ((rec (n list)
                 (if (= n 0)
                     list
                     (rec (floor n base) (cons (rem n base) list)))))
        (rec n nil))))

(defun solver ()
  (let* ((n (read))
         (nlist (int-to-digit n))
         (sn (apply #'+ nlist)))
    (if (zerop (mod n sn))
        (format t "Yes~%")
        (format t "No~%"))))

(solver)

Measured memory_bytes: 15844
#include<iostream>
using namespace std;int n,i,j,a,s,u[101],d[101];main(){cin>>n;for(;i<n;)cin>>u[i++];for(;j<n;)cin>>d[j++];for(;--i>=0;){for(s=j=0;j<=i;)s+=u[j++];for(j--;j<n;)s+=d[j++];a=a<s?s:a;}cout<<a;}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

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

	if (a > b)
	{
		cout << "a > b" << endl;
	}
	else if(a < b)
	{
		cout << "a < b" << endl;
	}
	else if (a == b)
	{
		cout << "a == b" << endl;
	}
}

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

public class Main {
    public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
	long a = sc.nextLong();
	double b = sc.nextDouble();
	sc.close();
	long c = (long)Math.round(b * 100);
	long d = a * c;
	System.out.println(d / 100);
    }
}

Measured memory_bytes: 37172
#include<bits/stdc++.h>
#define endl '\n';
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    while(N!=0){
        double heikin = 0;
        vector<int> A(N);
        for(int i=0; i<N; i++){
            cin >> A[i];
            heikin += A[i];
        }
        heikin /= double(N);
        int cnt = 0;
        for(int i=0; i<N; i++){
            if(heikin >= A[i]) cnt++;
        }
        cout << cnt << endl;
        cin >> N;
    }
    return 0;
}


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

using namespace std;
using llong = long long;
using ldbl = long double;
using P = pair<llong, llong>;

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

const llong inf = 1100100100100100ll;
const llong mod = 1e9+7;

int main(){
	llong R, G, B, N;
	cin >> R >> G >> B >> N;

	llong sum = 0;
	for (int r = 0; r <= N; r += R) {
		for (int g = 0; g <= N-r; g += G) {
			int b = (N-r-g);
			if (b%B == 0)
				sum++;
		}
	}

	cout << sum << endl;

	return 0;
}

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

using namespace std;

#define PB push_back
#define MP make_pair
#define X first
#define Y second

#define cil(a,b) ( ((a)%(b) == 0)?((a)/(b)):((a)/(b)+1) )
#define err(x) cerr << #x << " = " << x << endl;
#define read(a) freopen(a,"r",stdin)
#define write(a) freopen(a,"w",stdout)
#define forall(i,a,b) for(int i=a;i<b;i++)
#define foreach(v, c) for(typeof((c).begin())v=(c).begin();v!=(c).end();++v)
#define read(a) freopen(a,"r",stdin)
#define write(a) freopen(a,"w",stdout)

typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<pii> vii;

clock_t start;
void Time(bool timeIt) {
	if (!timeIt) return;
	clock_t end = clock();
	double elapsed_time = ((db)end - (db)start) / (db)CLOCKS_PER_SEC;
	printf("Time elapsed = %0.4lf\n", elapsed_time); 
}

#define LINF (long long)1e18
#define EPS 1e-9
#define INF 1000000007ll
#define SIZE 100010
#define MAX_A 1000010

int main() {
	start = clock();

	ll n, m;
	cin >> n >> m;
	ll bord = 2 * (n + m) - 4;
	if (n == 1 && m == 1) cout << 1 << endl;
	else if (n == 1) {
		cout << m - 2 << endl;
	}
	else if (m == 1) {
		cout << n - 2 << endl;
	}
	else cout << n * m - bord << endl;

	Time(false);
	return 0;
}

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

int main(){
	int n, a[52],f;
	char suit[52];
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> suit[i] >> a[i];
	}
	char suitX[] = {'S','H','C','D'};
	//cout << suitX[1]<<endl;
	//cout << suit[5] << "   " << a[5]<<endl;
	for (int s = 0; s < 4; s++){
		for (int t = 1; t < 14; t++){
			f = 0;
			for (int i = 0; i < n; i++){
				if (suitX[s] == suit[i] && t == a[i])f++;
			}
			if (f == 0)cout << suitX[s] << ' ' << t << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3080
n=int(input())
rest=[input().split() for i in range(n)]
rest=[[rest[i][0],int(rest[i][1])] for i in range(n)]
for i in range(n):
  rest[i].append(i+1)

rest.sort(key=lambda i:i[0])
#print(rest)
cnt=0
for i in range(1,n):
  if rest[i-1][0]==rest[i][0]:
    continue
  else:
    res=rest[cnt:i]
    res.sort(key=lambda i:i[1],reverse=True)
    #print(res)
    for j in range(i-cnt):
      print(res[j][2])
    cnt=i
    #print(str(cnt)+'がcntです')
res=rest[cnt:n]
#print(res)
res.sort(key=lambda i:i[1],reverse=True)
for i in range(n-cnt):
  print(res[i][2])


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

using namespace std;

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

	vector<int> A;
	for(int i = 0;i < N;++i){
		int t;
		scanf("%d", &t);
		A.push_back(t);
	}

	sort(A.begin(), A.end());
	reverse(A.begin(), A.end());

	int s = 0;
	int p = 0;
	for(int i = 0;i < N;i += 2){
		s += A[i];
	}
	for(int i = 1;i < N;i += 2){
		p += A[i];
	}

	printf("%d\n", s - p);
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
H, W = [int(x) for x in input().split()]
s = []
for _ in range(H):
    temp = list(input().rstrip())
    s.append(temp)
def A(i,j,s):
    next_point = [[i+1,j],[i-1,j],[i,j-1],[i,j+1]]
    for n in next_point:
        x, y = n[0], n[1]
        if 0 <= x <= H-1 and 0 <= y <= W-1:
            if s[x][y] == "#":
                return 0
    return 1
for k in range(H):
    for l in range(W):
        flag = 0
        if s[k][l] == "#":
            flag = A(k,l,s)
        if flag:
            print("No")
            sys.exit()
print("Yes")



Measured memory_bytes: 40812
#include <iostream>
#include <vector>
#include <math.h>

using namespace std;

#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)

class Point{
public:
	double x, y;

	Point(double x = 0, double y = 0) :x(x), y(y){}

	Point operator + (Point p){ return Point(x + p.x, y + p.y); }
	Point operator - (Point p){ return Point(x - p.x, y - p.y); }
	Point operator * (Point p){ return Point(x * p.x, y * p.y); }
	Point operator / (Point p){ return Point(x / p.x, y / p.y); }

	Point operator * (double t){ return Point(x * t, y * t); }
	Point operator / (double t){ return Point(x / t, y / t); }


	double abs(){ return sqrt(norm()); }
	double norm(){ return x * x + y * y; }

	bool operator<(const Point &p){ return (x != p.x) ? (x < p.x) : (y < p.y); }
	bool operator==(const Point &p)
	{
		return equals(x, p.x) && equals(y, p.y);
	}
};

typedef Point Vector;

class Segment{
public:
	Point p1, p2;
};

double dot(Vector a, Vector b){
	return a.x * b.x + a.y * b.y;
}

double cross(Vector a, Vector b){
	return a.x * b.y - a.y * b.x;
}

bool isOrthogonal(Vector a, Vector b){
	return equals(dot(a, b), 0);
}

bool isOrthogonal(Point a1, Point a2, Point b1, Point b2){
	return isOrthogonal(a1 - a2, b1 - b2);
}

bool isParallel(Vector a, Vector b){
	return equals(cross(a, b), 0);
}

bool isParallel(Point a1, Point a2, Point b1, Point b2){
	return isParallel(a1 - a2, b1 - b2);
}

Point projection(Segment s, Point p){
	Vector v1 = s.p2 - s.p1;
	Vector v2 = p - s.p1;
	return s.p1 + v1 * dot(v1, v2) / v1.norm();
}

int main()
{
	std::ios_base::sync_with_stdio(false);
	cout.precision(20);

	Segment s;
	cin >> s.p1.x >> s.p1.y >> s.p2.x >> s.p2.y;


	int q; cin >> q;
	for (int i = 0; i < q; ++i){
		Point p; cin >> p.x >> p.y;
		Point res = projection(s, p);
		cout << res.x << " " << res.y << endl;
	}
}

Measured memory_bytes: 3268
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
        int n;
        cin >> n;
        vector<int> a(n);
        for(int i=0;i<n;i++)    cin >> a[i];
        sort(a.begin(),a.end());
        for(int i=0;i<n-1;i++){
                a[n-1]-=a[i];
        }
        if(a[n-1]<0)    cout << "Yes\n";
        else    cout << "No\n";
        return 0;
}


Measured memory_bytes: 256
import sys
import itertools
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

A = LI()

A = list(itertools.combinations(A,2))
jikans = []
for a in A:
    a[0] + a[1]
    jikans.append(a[0] + a[1])

jikans.sort()
print(jikans[0])

Measured memory_bytes: 9180
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int AX = (int)1e5 + 2;
ll dp[102][100003];
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll n, w;
    cin >> n >> w;
    for (int i = 1; i <= AX; i++)
        dp[0][i] = 1e12;
    dp[0][0] = 0ll;
    for (ll i = 1; i <= n; i++)
    {
        ll hz, zh;
        cin >> hz >> zh;
        for (ll j = 1; j <= AX; j++)
        {
            dp[i][j] = dp[i - 1][j];
            if(j - zh >= 0)
                dp[i][j] = min(dp[i][j], dp[i - 1][j - zh] + hz);
        }
    }
    ll ax = -1;
        for (int j = 1; j <= AX; j++)
        {
            if(dp[n][j] <= w && ax <= j)
                ax = j;
        }

    cout << ax;
}


Measured memory_bytes: 82536
#include<bits/stdc++.h>
using namespace std;
#define FasterIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

#define ll long long
const int MX=1000000;
const ll m=1000000007;

ll n;

void mltple(ll a[55][55], ll b[55][55])
{
    ll ml[55][55];
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<n; j++)
        {
            ml[i][j]=0;
            for(int k=0; k<n; k++)
            {
                ml[i][j]=(ml[i][j] + (a[i][k]*b[k][j])%m )%m;
            }
        }
    }
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<n; j++)
        {
            a[i][j]=ml[i][j];
        }
    }
}
void power(ll a[55][55], ll k)
{
    ll b[55][55];
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<n; j++) b[i][j]=a[i][j];
    }

    if(k==1)
    {
        return;
    }
    else if(k%2==0)
    {
        power(a,k/2);
        mltple(a,a);
    }
    else if(k%2!=0)
    {
        power(a,k-1);
        mltple(a,b);
    }
}

ll mat(ll k, ll a[55][55])
{
    power(a, k);
    ll res=0;
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<n; j++) res=(res+a[i][j])%m;
    }
    return res;
}

int main()
{
    FasterIO;

    ll k, a[55][55];

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

    ll res=mat(k, a);

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


Measured memory_bytes: 3072
fn main() {
  let mut s = {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim_right().as_bytes().to_owned()
  };

  s.sort();

  if s[0] == s[1] && s[2] == s[3] && s[0] != s[2] {
    print!("Yes");
  } else {
    print!("No");
  }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
double pi = 3.141592653589793;
ll mod = 1000000007;
ll INF = 1000000001;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
 
 
 
int main(){
  string s;
  int m=INF;
  cin>>s;
  rep(i,s.size()-2){
  	m=min(abs((s[i] - '0')*100+(s[i+1] - '0')*10+(s[i+2] - '0') -753),m);
  }
  cout<<m<<endl;
    return 0;
  
}

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

using namespace std;

int main() {


	std::ios::sync_with_stdio(false);
	std::cin.tie(0);


	int N, K;

	cin >> N >> K;

	vector<int> A(N);

	vector<int> B(N, 0);

	vector<int> S(N, 0);

	bool fit = false;

	int cnt = 0;
	int other = 0;

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

	sort(B.rbegin(), B.rend(), [&](int x, int y) {return S[x] < S[y]; });

	
	for (int i = 0; i < N; i++) {
		fit = false;
		for (int j = 0; j < K; j++) {
			if ((B[j] + 1) == A[i]) {
				fit = true;
				break;
			}
		}
		if (fit == false)
			other++;
	}


	cout << other;

	getchar();
	getchar();


	return 0;
}

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

using namespace std;

const int MAXN = 3E5;
int ans[MAXN];

int main()
{
    int n, a, b;
    cin >> n >> a >> b;
    if (n < a + b - 1 || n > (long long) a * b)
        cout << -1 << endl;
    else
    {
        int extra = n - (a + b - 1);
        for (int i = 0; i < b; i++)
        {
            ans[i] = b - i;
        }
        int ind = b;
        for (int i = 0; i < a - 1; i++)
        {
            int len = min(extra + 1, b);
            extra = max(0, extra - (b - 1));
            int start = ind + len;
            for (int j = 0; j < len; j++)
            {
                ans[ind++] = start--;
            }
        }
        for (int i = 0; i < n; i++)
        {
            if (i > 0)
                cout << " ";
            cout << ans[i];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
typedef long long unsigned int ll;

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int n,m,d;
    Scd3(n,m,d);

    double ans = 1.0;

    int hit = d == 0 ? n : (n-d)*2;

    printf ("%0.9lf\n", ans * hit / n * (m-1) / n );


    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <queue>
#include <algorithm> // sort
#include <map> // pair

using namespace std;
using Graph = vector<vector<int32_t>>;

int main(){
    int64_t N,M;


    typedef std::pair<int64_t, int64_t> mypair;
    // first value, second weight
    vector<mypair> pairvect;

    cin >> N >> M;

    Graph G(N+1);

    for(int i=0;i<M;++i){
        int32_t A,B;
        cin >> A >> B;
        G[A].push_back(B);
        G[B].push_back(A);
    }
    vector<int> dist(N+1,-1);
    queue<int> que;

    dist[0]=0;
    dist[1]=0;
    que.push(1);

    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();// 先頭頂点をqueから削除

        // v から辿れる頂点をすべて調べる
        for (int nv : G[v]) {// 範囲for文
            if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            //dist[nv] = dist[v] + 1;
            // 今回は部屋番号を追加
            dist[nv] = v;
            que.push(nv);
        }
    }

    int flag =1;
    for(int i=2;i<=N;++i){
        if(dist[i] <0){
            flag =0;
            break;
        }
    }
    if(flag){
        cout<<"Yes"<<endl;
        for(int i=2;i<=N;++i){
            cout<< dist[i]<<endl;
        }
    }
    else{
        cout<<"No"<<endl;
    }

}



Measured memory_bytes: 10152
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        
        int[] array = new int[n];
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }
        
        int index = k - 1;
        int sum = 0;
        for (int i = 0; i < k; i++) {
            sum += array[i];
        }
        int max = sum;
        
        
        for (int i = k; i < n; i++) {
            sum -= array[i - k];
            sum += array[i];
            if (sum > max) {
                max = sum;
                index = i;
            }
        }
        
        double ans = 0;
        for (int i = index; i > index - k; i--) {
            ans += ((((double)array[i])+1) / 2);
        }
        
        System.out.println(ans);
    }
}


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) cin >> A[i];
    auto A_CP = A;
    sort(A_CP.rbegin(), A_CP.rend());
    int max1 = A_CP[0];
    int max2 = A_CP[1];
    for (auto a : A) {
        if (a == max1) {
            cout << max2 << endl;
        }
        else {
            cout << max1 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3200
#include <iostream>

using namespace std;

void solve()
{
	int r, c;
	while(cin >> r >> c, r || c)
	{
		if((r * c) % 2 == 0)
		{
			cout << "yes" << endl;
		}
		else
		{
			cout << "no" << endl;
		}
	}
}

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

Measured memory_bytes: 1152
#include "iostream"
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	
	int ave;
	if ((a + b) % 2 == 0) ave = (a + b) / 2;
	else ave = (a + b + 1) / 2;

	cout << ave << "\n";
}

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

using namespace std;

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

using i64 = long long;

const int mod = 998244353;

int mod_inv(int a) {
  int b = mod, s = 1, t = 0;
  while (b) {
    int q = a / b;
    swap(a -= q * b, b);
    swap(s -= q * t, t);
  }
  return s < 0 ? s + mod : s;
}

int add_mod(int a, int b) {
  return (a += b - mod) < 0 ? a + mod : a;
}

int mul_mod(int a, int b) {
  return i64(a) * b % mod;
}

void solve() {
  i64 N, A, B, K;
  scanf("%lld %lld %lld %lld", &N, &A, &B, &K);
  vector<int> binom(N + 1); // binom(n, i)
  binom[0] = 1;
  for (int i = 1; i <= N; ++i) {
    binom[i] = mul_mod(binom[i - 1], mul_mod(mod_inv(i), N - i + 1));
  }

  int ans = 0;
  for (i64 x = 0; x <= N; ++x) {
    i64 r = K - A * x;
    if (r < 0 || r % B != 0) continue;
    i64 y = r / B;
    if (0 <= y && y <= N) {
      ans = add_mod(ans, mul_mod(binom[x], binom[y]));
    }
  }
  printf("%d\n", ans);
}

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


Measured memory_bytes: 1408
import java.util.Scanner;

public class Main{
  public static void main (String [] args){
    Scanner sc = new Scanner(System.in);     
    int N = sc.nextInt();
    int B[] = new int [N-1];
    for (int i = 0; i<N-1; i++){
      B[i] = sc.nextInt();
    }
    int A[] = new int [N];
    A[0] = B[0];
    for(int i = 0; i < N-2; i++){
      A[i+1] = Math.min(B[i],B[i+1]);
    }
    int ans = 0;
    for(int i = 0; i < N; i++){
      ans += A[i];
    }
    ans += B[N-2];
    System.out.println(ans);
  }
}


Measured memory_bytes: 35812
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] a = new long[n * 3];
		
		Arrays.setAll(a, i -> sc.nextInt());
		Arrays.sort(a);
		
		long ans = 0;
		int idx = n * 3 - 2;
		for (int i = 0; i < n; i++) {
			ans += a[idx];
			idx -= 2;
		}
		
		System.out.println(ans);
		
		sc.close();
	}

}


Measured memory_bytes: 98440
// AOJ 0114: Electro-Fly
// 2017.8.23 bal4u@uu
// 1017.11.5 retry

#include <stdio.h>

long long gcd(long long a, long long b)
{
	long long r;
	while (b) r = a % b, a = b, b = r;
	return a;
}
long long lcm(long long a, long long b) { return a/gcd(a, b) * b; }

int carmichael(int a, int m)
{
    int n, b;
	for (n = 1, b = a; b != 1; n++) b = (b * a) % m;
	return n;
}

int main()
{
	int i;
	int a[3], m[3], b[3];

	while (1) {
		for (i = 0; i < 3; i++) {
			scanf("%d%d", a+i, m+i);
			if (!a[0]) return 0;
		}
		for (i = 0; i < 3; i++)	b[i] = carmichael(a[i], m[i]);
		printf("%lld\n", lcm(lcm((long long)b[0], (long long)b[1]), (long long)b[2]));
	}
	return 0;
}

Measured memory_bytes: 1680
n = int(input())
nums = list(map(int, input().split()))
ans = [-1] * n
for i in range(1, n + 1)[::-1]:
  C = i * 2
  BALL = nums[i-1]
  while C <= n:
    BALL = BALL ^ ans[C-1]
    C += i
  ans[i-1] = BALL 

print(ans.count(1))
ball = []
for i in range(n):
  if ans[i] == 1:
    ball.append(i+1)
print(*ball)

Measured memory_bytes: 14140
#include <bits/stdc++.h>
using namespace std;
#define PI 3.1415926535
const long long int MOD = 998244353;
#define pb push_back
#define mp make_pair
#define fill(a)  memset(a, 0, sizeof (a))
#define MAX(v) *max_element(v.begin(), v.end())
#define MIN(v) *min_element(v.begin(), v.end())
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define watch(x) cout << (#x) << " is " << (x) << endl;
const long long int MAXX = 2e5+5;
const long long int MINN = 2e6 + 5;
const long long int inf = 1e9;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef vector< iii > viii;

ll lcm(ll a, ll b) {
   return a / __gcd(a, b) * b;
}
int XOR(int x, int y){
  return (x | y) & (~x | ~y);
}
bool cmp(const pair<int,int> &a,const pair<int,int> &b) {
    return (a.second < b.second);
}
// bool isl = binary_search(x.begin(), x.end(), 5);
// __builtin_popcount(x)  - Returns the number of set bits in x
const long long int N = 1e7;
const int MAXN = 105;
int binsearch(int lo, int hi){
    while(lo<hi){
        int mid=(lo+hi)/2;
        if((mid))   // check(mid)
            hi=mid;
        else
            lo=mid+1;
    }
    return lo;
}
int power(int x,int y){
    int res=1;
    while(y>0){
      if(y&1) res=((res*x));

      y/=2;
      x=((x*x));
    }
    return res;
}


int main(){
    FAST    
    int n,cnt=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        int a;
        cin>>a;
        if(a%2 && i%2){
            cnt++;
        }
    }
    cout<<cnt;
    return 0;
}




Measured memory_bytes: 3656
#include <vector> 
#include <list> 
#include <map> 
#include <set> 
#include <deque> 
#include <queue> 
#include <stack> 
#include <bitset> 
#include <algorithm> 
#include <functional> 
#include <numeric> 
#include <utility> 
#include <sstream> 
#include <iostream> 
#include <iomanip> 
#include <cstdio> 
#include <cmath> 
#include <cstdlib> 
#include <cctype> 
#include <string> 
#include <cstring> 
#include <ctime> 

using namespace std;

#define _int64 long long

int main()
{
  int i,j,m,n,k,tmp;
  scanf("%d%d%d",&m,&n,&k);
  for (i=0;i<=m;i++)
    for (j=0;j<=n;j++)
    {
      tmp=(m-i)*j+(n-j)*i;
      if (tmp==k)
      {
        printf("Yes\n");
        return 0;
      }
    }
  printf("No\n");
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
using namespace std;
#include <limits.h>
#include <cstdlib>

int main(void){
  int n,a[200000];
  long long afor[200000],abak[200000];
  cin >> n;
  for(int i = 0;i < n;++i)
    cin >> a[i];

  afor[0] = a[0];
  for(int i = 1;i < n-1;++i)
    afor[i] = a[i] + afor[i-1];

  abak[0] = afor[n-2] -a[0] +a[n-1];
  for(int i = 1;i < n-1;++i)
    abak[i] = abak[i-1] - a[i];

  long long min = INT_MIN;
  long long ans = INT_MAX;
  for(int i = 0;i < n-1;++i){
    min = abs(afor[i] - abak[i]);
    if(min < ans)
      ans = min;
  }
  cout << ans << endl;
}


Measured memory_bytes: 4096
#include<iostream>
#include<string>
#include<map>
using namespace std;
int f(char c){
	if (c == '2')return 2;
	if (c == '3')return 3;
	if (c == '4')return 4;
	if (c == '5')return 5;
	if (c == '6')return 6;
	if (c == '7')return 7;
	if (c == '8')return 8;
	if (c == '9')return 9;
	return 1;
}
void solve() {
	int ans[] = { 0,0,0,0 };
	string a, b; cin >> a >> b;
	for (int i = 0; i < a.size(); i++) {
		if (a[i] == 'm') {
			if (i == 0)ans[0]++;
			else ans[0] += f(a[i - 1]);
		}
		else if (a[i] == 'c') {
			if (i == 0)ans[1]++;
			else ans[1] += f(a[i - 1]);
		}
		else if (a[i] == 'x') {
			if (i == 0)ans[2]++;
			else ans[2] += f(a[i - 1]);
		}
		else if (a[i] == 'i') {
			if (i == 0)ans[3]++;
			else ans[3] += f(a[i - 1]);
		}
	}
	for (int i = 0; i < b.size(); i++) {
		if (b[i] == 'm') {
			if (i == 0)ans[0]++;
			else ans[0] += f(b[i - 1]);
		}
		else if (b[i] == 'c') {
			if (i == 0)ans[1]++;
			else ans[1] += f(b[i - 1]);
		}
		else if (b[i] == 'x') {
			if (i == 0)ans[2]++;
			else ans[2] += f(b[i - 1]);
		}
		else if (b[i] == 'i') {
			if (i == 0)ans[3]++;
			else ans[3] += f(b[i - 1]);
		}
	}
	if (ans[3] >= 10) { ans[3] %= 10; ans[2]++; }
	if (ans[2] >= 10) { ans[2] %= 10; ans[1]++; }
	if (ans[1] >= 10) { ans[1] %= 10; ans[0]++; }
	if (ans[0] != 0) {
		if (ans[0] != 1)cout << ans[0];
		cout << 'm';
	}
	if (ans[1] != 0) {
		if (ans[1] != 1)cout << ans[1];
		cout << 'c';
	}
	if (ans[2] != 0) {
		if (ans[2] != 1)cout << ans[2];
		cout << 'x';
	}
	if (ans[3] != 0) {
		if (ans[3] != 1)cout << ans[3];
		cout << 'i';
	}
	cout << endl;
}
int main() {
	int n; cin >> n;
	for (int i = 0; i < n; i++)solve();
}

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

#define INF (1e9) + 7

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

  vector<long long int> t(n), a(n);
  for(int i = 0; i < n; i++){ cin >> t[i]; }
  for(int i = 0; i < n; i++){ cin >> a[i]; }

  vector<long long int> mountain(n, 0);
  vector<long long int> mountain_limit(n, INF);
  mountain[0] = mountain_limit[0] = t[0];
  mountain[n - 1] = mountain_limit[n - 1] = a[n - 1];
  
  if((a[1] != a[0] && t[0] != a[0]) || (t[n - 2] != t[n - 1] && t[n - 1] != a[n - 1])){
    cout << "0" << endl;
    return 0;
  }
  
  for(int i = 1; i < n - 1; i++){
    mountain_limit[i] = min(t[i], a[i]);
    if(t[i - 1] != t[i] && a[i + 1] != a[i] && t[i] != a[i]){
      cout << "0" << endl;
      return 0;
    }
    if(t[i - 1] != t[i]){ mountain[i] = t[i]; }
    if(a[i + 1] != a[i]){ mountain[i] = a[i]; }
  }
  
  long long int ans = 1;
  for(int i = 0; i < n; i++){
    if(mountain[i] == 0){
      ans *= mountain_limit[i];
      ans %= (int)INF;
    }
    else{
      if(mountain[i] != mountain_limit[i]){
        cout << "0" << endl;
        return 0;      
      }
    }
  }
  
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3456
#include<iostream>
#include<vector>

using namespace std;
constexpr int MOD = 1e9 + 7;

int modpow(long long a, long long b, int base) {
	vector<long long> vb, va;
	while (b != 0) {
		vb.push_back(b % 2);
		b /= 2;
		va.push_back(a);
		a *= a;
		a %= base;
	}
	long long ans = 1;
	for (int i = 0;i < vb.size();i++) {
		if (vb[i] == 1) {
			ans *= va[i];
			ans %= base;
		}
	}
	return ans;
}

long long func(int x, int y);

long long kaijo[200001];

int main() {
	kaijo[0] = 1;
	for (int i = 1;i <= 200000;i++) {
		kaijo[i] = i * kaijo[i - 1];
		kaijo[i] %= MOD;
	}
	int h, w, a, b;
	cin >> h >> w >> a >> b;
	long long ans = 0;
	for (int i = b + 1;i <= w;i++) {
		ans += func(i, h - a) * func(w - i + 1, a);
		ans %= MOD;
	}
	cout << ans << endl;
}

long long func(int x, int y) {
	int n = x + y - 2;
	int k = x - 1;
	long long ans = kaijo[n];
	ans *= modpow(kaijo[k], MOD - 2, MOD);
	ans %= MOD;
	ans *= modpow(kaijo[n - k],MOD-2,MOD);
	ans %= MOD;
	return ans;
}

Measured memory_bytes: 4708
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rrep(i, n) for (ll i = n - 1; i >= 0; i--)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define RRep(i, r, n) for (ll i = n - 1; i <= r; i--)
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define int long long
#define pb push_back
const int dx[] = {0, -1, 0, 1};
const int dy[] = {1, 0, -1, 0};
const int MOD = (1000000007);
//const int MOD = (998244353);
//const int INF = (1 << 30)-1;
const int INF = (1LL << 60)-1;
const double EPS = (1 >> 30);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}

using Graph = vector<vector<pair<int, int>>>;

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    //---------------------------------------------
    
    int n,k;
    cin>>n>>k;
    cout<<n-k+1<<endl;
    
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    bool res = true;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;

        if (a % 2 == 0) {
            res = (res && (a % 3 == 0 || a % 5 == 0));
        }
    }

    cout << (res ? "APPROVED" : "DENIED") << endl;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
using namespace std;
int n,m,q;
long long ans;
long long a[100000+10],b[100000+10];
int main()
{
	scanf("%d%d%d",&n,&m,&q);
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	n++;a[n]=1e18;a[0]=-1e18;
	for(int i=1;i<=m;i++)
		scanf("%lld",&b[i]);
	m++;b[m]=1e18;b[0]=-1e18;
	for(int i=1;i<=q;i++){
		long long x;
		scanf("%lld",&x);
		int k1=lower_bound(a+1,a+n+1,x)-a;
		int k2=lower_bound(b+1,b+m+1,x)-b;
		ans=min(min(a[k1]-b[k2-1]+min(a[k1]-x,x-b[k2-1]),b[k2]-a[k1-1]+min(b[k2]-x,x-a[k1-1])),
				min(x-min(a[k1-1],b[k2-1]),max(a[k1],b[k2])-x));
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 2816
# -*- coding: utf-8 -*-
"""
https://beta.atcoder.jp/contests/abc043/tasks/arc059_a

"""
import sys
from sys import stdin
input = stdin.readline


def solve(A, N):
    # 総当たりでチェックl
    costs = [0] * 201

    for i in range(-100, 101):
        t = [(x - i)**2  for x in A]
        costs[i+100] = sum(t)

    return min(costs)


def main(args):
    N = int(input())
    A = [int(x) for x in input().split()]
    ans = solve(A, N)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])
    

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int n, W, w[100], v[110], dp[110][10010];

int main()
{
    cin >> n >> W;
    for (int i = 0; i < n; i++)
        cin >> v[i] >> w[i];

    for (int i = 0; i <= W; i++)
        dp[0][i] = 0;

    for (int i = 0; i < n; i++)
        for (int j = 0; j <= W; j++)
        {
            if (j >= w[i])
                dp[i + 1][j] = max(dp[i][j - w[i]] + v[i], dp[i][j]);
            else
                dp[i + 1][j] = dp[i][j];
        }

    cout << dp[n][W] << endl;

    return 0;
}


Measured memory_bytes: 7052
#include <bits/stdc++.h>
#include <unordered_set>
#include <random>
using namespace std;
#define ll long long
#define fr first
#define sc second
#define pll pair<ll, ll>
#define all(v) v.begin(), v.end()

ll modpow(ll a, ll b, int MOD) {
	if (b == 0) return 1;
	if (b & 1) return modpow(a, b - 1, MOD) * a % MOD;
	ll half = modpow(a, b / 2, MOD) % MOD;
	return (half * half) % MOD;
}

ll mod(string s, int n) {
	reverse(s.begin(), s.end());
	ll tmp = 1;
	int ret = s[0] == '1';
	for (int i = 1; i < s.size(); i++) {
		tmp *= 2;
		tmp %= n;
		if (s[i] == '1') {
			ret += tmp;
			ret %= n;
		}
	}
	return ret % n;
}

ll mod2(ll s) {
	int n = 0;
	for (int i = 0; i < 30; i++) if ((1 << i) & s) n++;
	return s % n;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int N; cin >> N;
	string s; cin >> s;
	int pc = 0;
	for (int i = 0; i < N; i++) if (s[i] == '1') pc++;

	ll mod_np1 = mod(s, pc + 1), mod_nm1 = -1;
	if (pc - 1 > 0) mod_nm1 = mod(s, pc - 1);

//	cout << mod_np1 << ' ' << mod_nm1 << '\n';

	for (int i = 0; i < s.size(); i++) {
		ll nmod;
		int ans = 1;
		if (s[i] == '1') {
			if (pc == 1) {
				nmod = 0, ans = 0;
			}
			else if (pc != 1) {
				nmod = (mod_nm1 - modpow(2, s.size() - i - 1, pc - 1) + pc - 1) % (pc - 1);
			}
			else nmod = 0;
		}
		else {
			nmod = (mod_np1 + modpow(2, s.size() - i - 1, pc + 1)) % (pc + 1);
		}

//		cout << nmod << '\n';	
		while (nmod != 0) nmod = mod2(nmod), ans++;
		cout << ans << '\n';
	}
	return 0;
}

Measured memory_bytes: 3884
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b;
    cin >> a;
    cin >> b;
    cout << "";
    if (a<b){ 
        cout << "a < b";
    }
     else if (a > b){ 
        cout << "a > b";
     }
     else cout << "a == b";
     
     cout << endl;
    
}


Measured memory_bytes: 3060
N = int(input())

h, n, w = 0, 0, 0

for i in range(1, 3501):
  for j in range(i, 3501):
    if (4 * i * j - N * (i + j)) > 0 and (N * i * j) % (4 * i * j - N * (i + j)) == 0:
      h = i
      n = j
      w = (N * h * n) // (4 * h * n - N * (h + n))
      break
  if w != 0:
    break

print(h, n, w)

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

using i64 = long long int;

map<i64, i64> prime_factor(i64 n) {
    map<i64, i64> res;
    for (i64 i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            res[i]++;
            n /= i;
        }
    }
    if (n != 1)
        res[n] = 1;
    return res;
}

int main(){
    i64 n;
    cin >> n;
    auto mp = prime_factor(n);
    cout << n << ":";
    for(auto e : mp){
        for(int i=0;i<e.second;++i){
            cout << " " << e.first;
        }
    }

    cout << endl;

    return 0;
}



Measured memory_bytes: 3088
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn main() {
    let n = read::<usize>();

    let ans = (1+n) * n / 2 - n;

    println!("{}", ans);
}

Measured memory_bytes: 4352
package main

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

type process struct {
	name string
	time int
}

type roundRobin struct {
	quantum int
	time    int
	pQueue  *processQueue
}

func (rb *roundRobin) run() {
	for {
		rb.calc()
		if rb.pQueue.isEmpty() {
			break
		}
	}
}

func (rb *roundRobin) calc() {
	p := rb.pQueue.dequeue()
	if p.time > rb.quantum {
		p.time = p.time - rb.quantum
		rb.time = rb.time + rb.quantum
		rb.pQueue.enqueue(p)
	} else {
		rb.time = rb.time + p.time
		fmt.Printf("%s %d\n", p.name, rb.time)
	}
	return
}

type processQueue struct {
	queue    []*process
	firstIdx int
	lastIdx  int
}

func (pq *processQueue) enqueue(p *process) {
	pq.queue[pq.lastIdx] = p
	pq.lastIdx++
	if pq.lastIdx >= len(pq.queue) {
		pq.lastIdx = 0
	}
}

func (pq *processQueue) dequeue() *process {
	p := pq.queue[pq.firstIdx]
	pq.queue[pq.firstIdx] = nil
	pq.firstIdx++
	if pq.firstIdx >= len(pq.queue) {
		pq.firstIdx = 0
	}

	return p
}

func (pq *processQueue) isEmpty() bool {
	return pq.queue[pq.firstIdx] == nil
}

func initProcessQueue(l int) *processQueue {
	return &processQueue{
		queue:    make([]*process, l),
		firstIdx: 0,
		lastIdx:  0,
	}
}

func initRoudRobin(line string) *roundRobin {
	in := strings.Split(line, " ")
	l, err := strconv.Atoi(in[0])
	if err != nil {
		panic(err)
	}
	pq := initProcessQueue(l)

	q, err := strconv.Atoi(in[1])
	if err != nil {
		panic(err)
	}
	return &roundRobin{
		quantum: q,
		time:    0,
		pQueue:  pq,
	}
}

func initProcess(line string) *process {
	in := strings.Split(line, " ")
	t, err := strconv.Atoi(in[1])
	if err != nil {
		panic(err)
	}
	return &process{
		name: in[0],
		time: t,
	}
}

func main() {
	stdin := bufio.NewScanner(os.Stdin)
	stdin.Scan()
	rb := initRoudRobin(stdin.Text())

	for stdin.Scan() {
		p := initProcess(stdin.Text())
		rb.pQueue.enqueue(p)
	}
	rb.run()
}



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

using namespace std;

int n, a;
vector<int> v;

int main(){	
	cin >> n;
	v.resize(n);
	for(int i = 0; i < n - 1; ++i){
		cin >> a;
		v[a-1]++;
	}
	for(int i = 0; i < n; ++i) cout << v[i] << endl;
}


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

int main() {
  int n;
  cin >> n;
  int d[n];
  for (int i = 0; i < n; i++) {
    cin >> d[i];
  }
  int ans = 0;
  for (int i = 0; i < n-1; i++) {
    for (int j = i+1; j < n; j++) {
      ans += d[i] * d[j];
    }
  }
  cout << ans << endl;
}

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

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

  int n, k; cin >> n >> k;
  vector<long long> c(n);
  for(int i = 0; i < n; i++) {
  	cin >> c[i];
  }
  long long ans = 1e15;
  for(int i = 0; i <= n - k; i++) {
  	ans = min(ans, c[i + k - 1] - c[i] + min(abs(c[i]) ,abs(c[i + k - 1])));
  }
  cout << ans << endl;
	return 0;
}	


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
int ctoi(char c) {
	switch (c) {
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		default: return 0;
	}
}

int main() {
  int64_t x;
  char a,b,c,d;
  cin >> x >> a >> b >> c >> d;
  int e=ctoi(a);
  int f=ctoi(c);
  int g=ctoi(d);
  int n=100*e+10*f+g;
  
  cout << fixed << setprecision(0);
  cout << (x*n)/100 << endl;

}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define uu unsigned
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MOD 1000000007
#define pi pair<int,int>
#define pl pair<ll,ll>
#define mkp make_pair
#define ss second
#define ff first
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define pb push_back
#define pf push_front
#define printcas cout<<"Case "<<cas<<": "
#define _ continue;
#define endl '\n'
#define __ cout<<endl;continue;
#define vc4d(nam,type,a,b,c,d,fix) vector<vector<vector<vector<type>>>> nam(a,vector<vector<vector<type>>>(b,vector<vector<type>>(c,vector<type>(d,fix))))
const ll oo=(1ll<<60);
bool flag;
void done()
{
    if(flag)cout<<"setwise coprime";
    else cout<<"not coprime";
}
int gg(){
    int x=0,w=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
    if(ch=='-')w=0,ch=getchar();
    while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
    return w?x:-x;
}
bool vis[1000010];
ll GCD(ll s,ll l)
{
    if(s>l)swap(l,s);
    if(!s) return l;
    ll mod=l%s;
    while(mod)
    {
        l=s;
        s=mod;
        mod=l%s;
    }
    return s;
}
int main()
{
     io;
    int T=1;
    //T=gg();
    //cin>>T;
    //for(int cas=1;cas<=T;cas++)
    while(T--)
    {
       ll n,i,j,k,l,holegcd=-1;bool check=1;
       cin>>n;
       vl v(n);
       for(auto &x:v)
       {
           cin>>x;
           if(holegcd==-1)holegcd=x;
           else holegcd=GCD(holegcd,x);
       }
       if(holegcd!=1)
       {
           flag=0;
           done();
           _
       }
       else flag=1;
       for(i=0;i<n;i++)
       {
           k=v[i];
           if(k==1) _
            if(~k&1)
    {
        if(vis[2])
        {
            check=0;
            goto xy;
        }
        vis[2]=1;
        while((k&1)==0)
        {
            k>>=1;
        }
    }
    if((k%3)==0)
    {
        if(vis[3])
        {
            check=0;
            goto xy;
        }
        vis[3]=1;
        while(k%3==0)
        {
            k/=3;
        }
    }
    for(int i=5; (i)*(i)<=k; i+=6)
    {
        if((k%(i))==0)
        {
            if(vis[i])
            {
                check=0;
                goto xy;
            }
            vis[i]=1;
            while((k%(i))==0)
            {
                k/=(i);
            }

        }
        if((k%(i+2))==0)
        {
             if(vis[i+2])
            {
                check=0;
                goto xy;
            }
            vis[i+2]=1;
            while((k%(i+2))==0)
            {
                k/=(i+2);
            }

        }
    }
    if(k>1)
    {
        if(vis[k])
        {
            check=0;
                goto xy;

        }
        vis[k]=1;
    }
       }
       xy:
           if(check)
           {
               cout<<"pairwise coprime";
               _
           }
           done();
    }
    return 0;
}


Measured memory_bytes: 11116
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<cstdio>
#include<algorithm>
#define int long long
#define mp make_pair
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
using namespace std;
typedef pair<int,int>pii;
string st;
int h[10];
signed main(){
	cin>>st;
	for(auto x:st)h[x-'a']++;
	sort(h,h+3);
	if(h[2]-h[0]>1)puts("NO");
	else puts("YES");
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cmath>
using namespace std;
int main(int argc, char** argv) {
	int N,M,tot1=0,tot2=0,tot=0;
	cin>>N>>M;
	if(N>1)
	{
		tot1=(N*(N-1))/2;
	}
	if(M>1)
	{
		tot2=(M*(M-1))/2;
	}
	tot=tot1+tot2;
	cout<<tot;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(long long i=0;i<n;++i)
#define REPR(i,n) for(long long i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(v) {for(long long sitr=0;sitr<v.size();++sitr){cin>>v[sitr];}}

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

using namespace std;

typedef pair<int,int> pii;

llong solve(llong n){
  if(n <= 0) return 0;
  if(n % 2 == 1) return ((n+1) / 2) % 2;
  else{
    return solve(n-1) ^ n;
  }
}

int main(){

  llong a, b;
  cin >> a >> b;

  cout << (solve(a-1) ^ solve(b)) << endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <cmath>

using namespace std;

int main(){
    int n,c;
    string ans;
    cin>>n>>c;
    if(c<0){
        if(n==1) ans="11";
        else{
            string s;
            for(int i=0;i<n;++i) s +='9';
            ans =s+s;
        }
    }
    else{
        int p=1;
        for(int i=0;i<n;++i) p *=10;
        --p;
        for(int i=p;i>p/10;--i){
            bool flag=true;
            stringstream ss,ssc;ss<<i;ssc<<c;
            string s=ss.str(),sc=ssc.str();
            string sr=s;reverse(sr.begin(),sr.end());
            s +=sc+sr;
            int t=atoi(s.c_str());
            if(t%2==0) continue;
            for(int j=3;j<=sqrt(t);j+=2){
                if(t%j==0){
                    flag=false;break;
                }
            }
            if(flag){
                ans=s;break;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3160
#include <cstdio>

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

using namespace std;

int rint() {
  int n;
  scanf("%lld", &n);
  return n;
}

void wint(int n) {
  printf("%lld\n", n);
}

// Returns the gcd while setting x and y so that a x + b y = gcd
int euclid(int a, int b, int& x, int& y) {
  if (a < b) {
    int d = euclid(b, a, x, y);
    int t = x;
    x = y;
    y = t;
    return d;
  }
  int m[2][2] = { { 1, 0 }, { 0, 1 } };
  while (b > 0) {
    int q = a / b, r = a % b;
    int n[2][2] = { { 0, 1 }, { 1, -q } }, l[2][2] = { { 0, 0 }, { 0, 0 } };
    dotimes(i, 2)
      dotimes(j, 2)
      dotimes(k, 2)
      l[i][j] += n[i][k] * m[k][j];
    dotimes(i, 2)
      dotimes(j, 2)
      m[i][j] = l[i][j];
    a = b;
    b = r;
  }
  x = m[0][0];
  y = m[0][1];
  return a;
}

inline int euclid(int a, int b, int& x) {
  int y;
  return euclid(a, b, x, y);
}

inline int euclid(int a, int b) {
  int x;
  return euclid(a, b, x);
}

int modinv(int a, int p) {
  int x;
  euclid(a, p, x);
  int r = x % p;
  return r < 0 ? r + p : r;
}

int modpow(int m, int n, int p) {
  int r = 1;
  while (n) {
    if (n & 1)
      r = r * m % p;
    m = m * m % p;
    n >>= 1;
  }
  return r;
}

int modbinom(int n, int k, int p) {
  if (n - k < k)
    k = n - k;
  int numer = 1, denom = 1;
  dotimes(i, k) {
    numer = numer * (n-i) % p;
    denom = denom * (k-i) % p;
  }
  return numer * modinv(denom, p) % p;
}

signed main() {
  int X = rint();
  int Y = rint();
  if (!((X + Y) % 3 == 0 && Y <= X * 2 && X <= Y * 2)) {
    wint(0);
    return 0;
  }
  int a = (2 * X - Y) / 3, b = X - 2 * a;
  wint(modbinom(a + b, a, 1'000'000'007));
  return 0;
}


Measured memory_bytes: 128