akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
# define ll long long
# define mo 1000000009
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n],dp[n];
	for(int i=0;i<n;i++)
	cin>>a[i];
	dp[0]=0;
	dp[1]=abs(a[1]-a[0]);
	for(int i=2;i<n;i++)
	{
		dp[i]=min(abs(a[i]-a[i-1])+dp[i-1],abs(a[i]-a[i-2])+dp[i-2]);
	}
	cout<<dp[n-1];
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <list>
#include <algorithm>
#include <ctime>
#include <limits>
#include <cmath>
#include <typeinfo>


using namespace std;

//  ||
// \

int main() {
	string s;
	cin >> s;
	int length = s.length();
	cout << s[0] << length-2 << s[length-1]; 
    return 0;
}

Measured memory_bytes: 256
import sys

def solve():
    input = sys.stdin.readline
    L = [int(i) for i in input().split()]
    count = 0
    L.sort()
    addMin = (L[2] - L[0]) // 2  
    addMid = (L[2] - L[1]) // 2
    count = addMin + addMid
    L[0] += addMin * 2
    L[1] += addMid * 2
    if L[0] < L[2] and L[1] < L[2]: print(count + 1)
    elif L[0] == L[1] == L[2]: print(count)
    else: print(count + 2)
    #print(L)

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 3064
use proconio::input;
use proconio::marker::{Chars};

// x ** n % mods を求める
pub fn mod_pow(x: i64, n: i64, mods: i64) -> i64 {
    if n == 0 {
        return 1;
    }
    let mut res = mod_pow(x * x % mods, n / 2, mods);
    if n % 2 == 1 {
        res = res * x % mods;
    }
    return res;
}

// (1/n) % mods を求める
pub fn mod_inv(n: i64, mods: i64) -> i64 {
    return mod_pow(n, mods-2, mods);
}

// nCk % mods を求める
pub fn mod_comb(n: i64, k: i64, mods: i64) -> i64 {
    let sum1 = (n-k+1..n+1).fold(1, |ac, x| ac * x % mods);
    let sum2 = (1..k+1).fold(1, |ac, x| ac * x % mods);
    return sum1 * mod_inv(sum2, mods) % mods;
}

// nCk の組み合わせを列挙する
pub fn combination(n: usize, k: usize) -> Vec<Vec<usize>> {
    let mut ans = Vec::new();
    if k == 1 {
        for i in 1..n+1 {
            let mut tmp = Vec::new();
            tmp.push(i);
            ans.push(tmp);
        }
    }
    else {
        for iter in combination(n-1, k-1) {
            let max = iter.iter().max().unwrap();
            for j in *max+1..n+1 {
                let mut tmp = iter.clone();
                tmp.push(j);
                ans.push(tmp);
            }
        }
    }
    ans
}

fn main() {
    input!{
        h: usize,
        w: usize,
        k: usize,
        c: [Chars; h],
    }
    let mut ans = 0;
    for bit in 0..2_i64.pow((h+w) as u32) {
        let mut v = Vec::new();
        let mut tmp = 0;
        for i in 0..h+w {
            if bit & (1 << i) > 0 {
                v.push(i);
            }
        }
        for i in 0..h {
            for j in 0..w {
                if !v.contains(&i) && !v.contains(&(j+h)) && c[i][j] == '#' {
                    tmp += 1;
                }
            }
        }
        if tmp == k {
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2272
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define print(ele) cout << ele << endl
#define print10(ele) cout << fixed << setprecision(10) << ele << endl

using namespace std;
typedef long long ll;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

int main() {
  int n, m;
  cin >> n >> m;
  ivec s(m);
  vector<char> c(m);
  REP(i, m) { cin >> s[i] >> c[i]; }

  REP(i, 1000) {
    string num = to_string(i);
    if (num.size() == n) {
      bool ok = true;
      REP(j, m) {
        if (num[s[j] - 1] != c[j]) ok = false;
      }
      if (ok) {
        print(num);
        return 0;
      }
    }
  }
  print(-1);
  return 0;
}

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

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int gcd(int a, int b)
{
  if (b == 0)
    return a;
  return gcd(b, a % b);
}

int lcm(int a, int b)
{
  int g = gcd(a, b);
  return a / g * b;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<int> C(N), S(N), F(N);
  for (int i = 0; i < N - 1; i++)
    cin >> C[i] >> S[i] >> F[i];

  vector<int> ans;

  for (int i = 0; i < N - 1; i++)
  {
    if (i != 0)
    {
      for (auto &a : ans)
      {
        a = max(S[i], ((a + (F[i] - 1)) / F[i]) * F[i]) + C[i];
      }
    }
    ans.push_back(C[i] + S[i]);
  }
  cerr << lcm(25, 17) << endl;
  for (int i = 0; i < N - 1; i++)
    cout << ans[i] << endl;
  cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    static class Task {
        void solve(InputReader in, PrintWriter out) {
            // write your code here
            int R = in.nextInt();
            if (R < 1200) {
                out.println("ABC");
            } else if (R < 2800) {
                out.println("ARC");
            } else {
                out.println("AGC");
            }
        }
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
    }
}


Measured memory_bytes: 21460
/*

Coded and Decoded by : Yash Kapoor

*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

// s.find_by_order(index);
// s.order_of_key(value);

#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define mp make_pair
#define pll pair<ll, ll>
#define vl vector<ll>
#define sl set<ll>
#define vll vector<pll>
#define ml map<ll, ll>
#define mll map<pll, ll>
#define all(a) a.begin(), a.end()
#define F first
#define S second
#define sz(x) (ll) x.size()
#define dl '\n'
#define elasped_time  1.0 * clock() / CLOCKS_PER_SEC
#define why (ll)1000000007
//#define why (ll)998244353
#define lp(i, a, b) for (ll i = a; i < b; ++i)
#define lpr(i, a, b) for (ll i = a; i >= b; i--)
#define lpd(i, x) for (auto i : x)
#define ios                                                                                                            \
  ios_base::sync_with_stdio(false);                                                                                    \
  cin.tie(0);                                                                                                          \
  cout.tie(0);

typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

ll inf = 1e18;
ld pi = 3.141592653589;
ll mod = why;
ll fast_power(ll base, ll power, ll mod)
{
  ll result = 1;
  while (power) {
    if (power % 2)
      result = (result * base) % mod;
    base = (base * base) % mod;
    power /= 2;
  }
  return result;
}

ll inverse(ll base, ll mod) { return fast_power(base, mod - 2, mod); }
int test = 1;
vl adj[200005];
vl visited(200005);
ll n,ans,m,c,v;

void dfs(ll node){
  visited[node] = 1;
  c ++;
  lpd(i,adj[node]){
    if(!visited[i]){
      dfs(i);
    }
  }
}

void solve() {
  cin >> n >> m;
  mll mp;
  lp(i,0,m){
    ll x,y; cin >> x >> y;
    if(!mp[{x,y}] and !mp[{y,x}]){
      adj[x].pb(y);
      adj[y].pb(x);
      mp[{x,y}] = 1;
      mp[{y,x}] = 1;
    }
  }
  ll mx = 0;
  lp(i,1,n+1){
    if(!visited[i]){
      c = 0;
      dfs(i);
      mx = max(mx,c);
    }
  }
  cout << mx << dl;
} 

int main()
{
  // #ifndef ONLINE_JUDGE 
  //   freopen("input.txt", "r", stdin);
  //   freopen("output.txt", "w", stdout);
  // #endif
  ios 
  ll t = 1;
  //cin >> t;
  while (t--) 
  {
    //cout << "Case #" << test++ << ": ";
    solve();
  }
  //cerr<<endl<<"समय गुज़रा : "<<elasped_time<<dl;
}

Measured memory_bytes: 46868
#include <iostream>
#include <vector>
#include <string>
#define ll long long
using namespace std;

int main() 
{
    ll k, a, b, t = 0;
    cin >> k >> a >> b;

    for(ll i = a; i <= b; i++) {
        if(i % k == 0)
            t = 1;
    }

    if(t)
        cout << "OK" << endl;
    else
                cout << "NG" << endl;

}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
const int N=105;
char s[N],t[N];
int main() {
	int n;
	scanf("%d%s%s",&n,s,t);
	for(int i=0;i<n;i++) {
		printf("%c%c",s[i],t[i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<queue>
#include<string.h>
#include<string>
#include<map>
#include<stack>
#include<vector>
#define mod 998244353
using namespace std;
struct str {
	int x, y;
};
struct str2 {
	int cur;
	double cost, time;
	bool operator < (const str2&A)const {
		return cost > A.cost;
	}
};
int n, t, w, k, h, m, e, q;
long long ans = 0, ans2 = 0;
int X[4] = { 0,0,1,-1 };
int Y[4] = { 1,-1,0,0 };
string s[1000];
bool chk[1000][1000];
void dfs(int x, int y) {
	chk[x][y] = true;
	if (s[x][y] == '#') {
		ans++;
		for (int i = 0; i < 4; i++) {
			int nx = x + X[i], ny = y + Y[i];
			if (0 <= nx && nx < h && 0 <= ny && ny < w) {
				if (chk[nx][ny])continue;
				if (s[nx][ny] == '.') {
					dfs(nx, ny);
				}
			}
		}
	}
	if (s[x][y] == '.') {
		ans2++;
		for (int i = 0; i < 4; i++) {
			int nx = x + X[i], ny = y + Y[i];
			if(0<=nx && nx < h && 0 <= ny && ny < w){
				if (chk[nx][ny])continue;
				if (s[nx][ny] == '#') {
					dfs(nx, ny);
				}
			}
		}
	}
}
int main() {
	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		cin >> s[i];
	}
	long long q = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (s[i][j] == '#' && !chk[i][j]) {
				dfs(i, j);
				q += (ans*ans2);
				ans = 0; ans2 = 0;
			}
		}
	}
	cout << q;
	return 0;
}

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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N, X, Y = MAP()
A = LIST()

ans = 0
for i in range(N-1):
    ans += min((A[i+1] - A[i]) * X, Y)
print(ans)


Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
const int K = 1000;
int v[2*K][2*K];
int s[2*K+1][2*K+1];
const int dx[] = {0,1,2,1,0,-1,-2,-1};
const int dy[] = {2,1,0,-1,-2,-1,0,1};
int main() {
  int n,k;
  cin >> n >> k;
  rep(i,n){
    int x,y; char c;
    cin >> x >> y >> c;
    if(c=='B') x+=k;
    x %= 2*k; y %= 2*k;
    v[x][y]++;
  }
  rep(i,2*k)rep(j,2*k) s[i+1][j+1] = s[i][j+1]+s[i+1][j]-s[i][j]+v[i][j];
  auto f = [&](int x1,int y1,int x2,int y2){
    if(x1>=2*k||y1>=2*k||x2<0||y2<0) return 0;
    x1=max(x1,0); y1=max(y1,0); x2=min(x2,2*k); y2=min(y2,2*k);
    return s[x2][y2] - s[x2][y1] - s[x1][y2] + s[x1][y1];
  };
  int ans = 0;
  rep(i,2*k)rep(j,k){
    int temp = f(i,j,i+k,j+k);
    rep(d,8) {
      int x = i+k*dx[d], y = j+k*dy[d];
      temp += f(x,y,x+k,y+k);
    }
    ans = max(ans,temp);
  }
  cout << ans << endl;
}


Measured memory_bytes: 34644
import java.util.*;
fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    // 整数の入力
    val a = sc.nextInt()
    val b = sc.nextInt()
    val c = sc.nextInt()

    var count = 0
    var money = b
    while(count <= c && money >= 0 && money >= a) {
      money -= a
      count += 1
    }
 	if(count > c) {
    	count = c
    }

    // 出力
    println(count.toString())
}

Measured memory_bytes: 31276
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  int sum = 0;
  for (int i = 0;i != s.length() / 2;++i) {
    if (s[i] != s[s.length() - 1 - i])
      sum++;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
N, K = (int(i) for i in input().split())  
R, S, P = (int(i) for i in input().split())  
T = str(input())
T = list(T)
max_w = max(R,S,P)*N
dp = [0] * (N+1)
dp_flg = [0] * (N+1)
def junk_win(x):
    if x == 'r':
        return('p')
    elif x == 's':
        return('r')
    else:
        return('s')
T_win = []
for i in range(N):
    T_win.append(junk_win(T[i]))
def get_w(x):
    if x == 'r':
        return(R)
    elif x == 's':
        return(S)
    else:
        return(P)
T_win_w = []
for i in range(N):
    T_win_w.append(get_w(T_win[i]))
for i in range(K):
    #print(i)
    dp[i] = dp[i-1] + T_win_w[i]
    dp_flg[i] = 1
    
for i in range(K,N):
    #print(i)
    if T_win[i]==T_win[i-K] and dp_flg[i-K]==1:#勝つために成約がある場合
        dp[i] = dp[i-1]
    else:
        dp[i] = dp[i-1] + T_win_w[i]
        dp_flg[i] = 1
print(dp[-2])

Measured memory_bytes: 53772
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
#define rep2(i,a,n) for (int i = a; i < n; i++)
using namespace std;
int N, M;
int A[11000];
int main() {
    cin >> N >> M;
    rep(i, M) {
        cin >> A[i];
    }
    long long res = N;
    rep(i, M) {
        res -= A[i];
    }
    if (res < 0) {
        cout << -1 << endl;
    } else {
        cout << res << endl;
    }

    return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<numeric>
#include<math.h>
using namespace std;
#define INF (1 << 30) - 1
#define LINF 1LL << 60
const int MOD = 1000000007;
using ll = long long;
using P = pair<int, int>;

const double PI = 3.14159265358979323846;

int main(){
  double a, b, h, m;
  cin >> a >> b >> h >> m;
  double aa = (h * 60 + m) * 0.5;
  double ba = 6.0 * m;
  double angle = abs(aa - ba);
  angle = min(angle, 360.0 - angle);
  double c = a * a + b * b - 2.0 * a * b * cos(angle * (PI / 180.0));
  c = sqrt(c);
  printf("%.20f\n", c);
  return 0;
}


Measured memory_bytes: 4296
import sys
from heapq import heappop, heappush
from operator import itemgetter
from collections import deque, defaultdict, Counter
from bisect import bisect_left, bisect_right
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
MOD = 10**9 + 7
INF = float('inf')

def sol():
    N = int(input())
    A = [(n, i + 1) for i, n in enumerate(map(int, input().split())) ]

    A.sort()
    ans = []
    for _, i in A:
        ans.append(i)
    print(*ans)

sol()

Measured memory_bytes: 24348
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
#define down_queue(x) priority_queue<x>
#define up_queue(x) priority_queue<x, vector<x>, greater<x>>
#define vec(x) vector<x>
ll gcd(ll a,ll b){while(b){ll tmp = a % b;a = b;b = tmp;}return a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
#define rep(x, y) for(int x = 0; x < (y); x++)
#define rrep(x, y) for(int x = (y); x >= 0; x--)
#define REP(x, z, y) for(int x = (z); x < (y); x++)
#define all(x) x.begin(), x.end()
#define split_str(str, sp_word) istringstream stream(str); string res; for(int cnt = 0; getline(stream,res,sp_word); cnt++)
#define digit(x) ((int)log10((double)(x)) + 1)
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define out(x) for(auto i : x) cout << i << " "; cout << endl;
#define outln(x) for(auto i : x) cout << i << " " << endl;
#define vec_cpy(to,from) copy(all(to),back_inserter(from))
#define ary_cpy(to,from) memcpy(to, from, sizeof from)
#define MOD = 1000000007; 
#ifdef DEBUG
#define debug_echo(e) cout << "L" << __LINE__ << ": " << e << endl
#define debug_var(e) cout << "L" << __LINE__ << ": " << #e << " = " << e << endl
#define debug_echo_dp(dp, N) { cout << "[ "; rep(i, N) cout << dp[i] << " ";  cout << "]" << endl; }
#else
#define debug_echo(e)
#define debug_var(e)
#define debug_echo_dp(dp, N)
#endif

int main(){
  int d,c;cin >> d >> c;
  cout << d * c << endl;
}

Measured memory_bytes: 3092
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <math.h>
#include <limits.h>
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0);
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ll long long
#define INF 100000000
#define MOD 1000000007
#define SIZE 100005
#define FOR(i,a,n) for(i=(a);i<(n);i++)
int comp(const void* a,const void* b){
	return *(int*)a-*(int*)b;
}
char str[27];
int main(void)
{
	int h,w,i,j;
	scanf("%d%d",&h,&w);
	FOR(i,0,h){
		FOR(j,0,w){
			scanf("%s",str);
			if(strcmp(str,"snuke")==0){
				printf("%c%d\n",'A'+j,i+1);
				return 0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <iterator>
#include <numeric>
#include <cstdint>
#include <cmath>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  n; ++i )
#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )

using namespace std;

int main()
{
  uint64_t N, X, Y;
  cin >> N >> X >> Y;

  uint64_t L = Y - X + 1;
  vector<vector<uint64_t>> distXY(L, vector<uint64_t>(L, -1));
  map<uint64_t, uint64_t> counter_distXY;
  N_TIMES(i, L) {
    N_TIMES(j, L) {
      if (j < i) { continue; }
      uint64_t u = i + X , v = j + X;
      uint64_t dist = min(v - u, L - (v - u));
      distXY[i][j] = dist;
      ++counter_distXY[dist];
    }
  }

  map<uint64_t, uint64_t> counter_dist1N;
  N_TIMES(i, X) {
    N_TIMES(j, (N - Y) + 1) {
      uint64_t u = i + 1, v = j + Y;
      uint64_t dist = (X - u) + (v - Y) + 1;
      ++counter_dist1N[dist];
    }
  }

  map<uint64_t, uint64_t> counter_dist1X;
  N_TIMES(i, X) {
    N_TIMES(j, L) {
      uint64_t u = i + 1, v = j + X;
      uint64_t dist = (X - u) + distXY[0][v - X];
      if (u == X || v == X || v == Y) { continue; }
      ++counter_dist1X[dist];
    }
  }
  
  map<uint64_t, uint64_t> counter_distXN;
  N_TIMES(i, L) {
    N_TIMES(j, (N - Y) + 1) {
      uint64_t u = i + X, v = j + Y;
      uint64_t dist = distXY[i][L - 1] + (v - Y);
      if (u == X || u == Y || v == Y) { continue; }
      ++counter_distXN[dist];
    }
  }

  auto query = [&](uint64_t k) {
    uint64_t S = 0;
    // [1] (u, v) ∈ [1, X]^2
    S += (X > k) ? (X - k) : 0;

    // [2] (u, v) ∈ [Y, N]^2
    S += ((N - Y + 1) > k) ? ((N - Y + 1) - k) : 0;

    // [3] (u, v) ∈ [X, Y]^2
    S += counter_distXY[k];

    // [4] u ∈ [1, X], v ∈ [Y, N]
    S += counter_dist1N[k];

    if (k == 1) { --S; } // [3]と[4]のダブルカウント

    // [5] u ∈ [1, X), v ∈ (X, Y)
    S += counter_dist1X[k];

    // [6] u ∈ (X, Y), v ∈ (Y, N]
    S += counter_distXN[k];

    return S;
  };

  for (uint64_t k = 1; k <= N - 1; ++k) {
    cout << query(k) << endl;
  }

  return 0;
}

Measured memory_bytes: 32128
# encoding: utf-8

input = raw_input().split()

stack = []
for n in input:
    if(n.isdigit()):
        stack.append(int(n))
    else:
        a = stack.pop()
        b = stack.pop()
        if n == '+':
            stack.append(b + a)
        elif n == '-':
            stack.append(b - a)
        elif n == '*':
            stack.append(b * a)
        else:
            stack.append(b / a)
print stack.pop()

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

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

    ll ans = 0;
    for (size_t i = 1; i <= K; i++)
    {
        if (A <= 0 && B <= 0 && C <= 0)
        {
            break;
        }

        if (A > 0)
        {
            ans += 1;
            A--;
        }
        else if (B > 0)
        {
            ans += 0;
            B--;
        }
        else if (C > 0)
        {
            ans += -1;
            C--;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3632
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<string>
#include<ctype.h>
#include<math.h>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<bitset>
#include<algorithm>
#include<time.h>
using namespace std;
void fre() { freopen("c://test//input.in", "r", stdin); freopen("c://test//output.out", "w", stdout); }
#define MS(x, y) memset(x, y, sizeof(x))
#define ls o<<1
#define rs o<<1|1
typedef long long LL;
typedef unsigned long long UL;
typedef unsigned int UI;
template <class T1, class T2>inline void gmax(T1 &a, T2 b) { if (b > a)a = b; }
template <class T1, class T2>inline void gmin(T1 &a, T2 b) { if (b < a)a = b; }
const int N = 1e5 + 10, M = 0, Z = 1e9 + 7, inf = 0x3f3f3f3f;
template <class T1, class T2>inline void gadd(T1 &a, T2 b) { a = (a + b) % Z; }
int casenum, casei;
int n;
int a[N];
int main()
{
	while (~scanf("%d", &n))
	{
		for (int i = 1; i <= n; ++i)
		{
			scanf("%d", &a[i]);
		}
		int ans = 0;
		for (int i = 1; i < n; ++i)
		{
			if (a[i] == i)
			{
				swap(a[i], a[i + 1]);
				++ans;
			}
		}
		if (a[n] == n)++ans;
		printf("%d\n", ans);
	}
	return 0;
}
/*
【trick&&吐槽】


【题意】


【分析】


【时间复杂度&&优化】


*/

Measured memory_bytes: 640
#include<iostream>
#include<stack>
//#include "stdio.h"

using namespace std;

#define N 100

#define WHITE 0
#define GRAY 1
#define BLACK 2
#define NIL -1

int n, M[N][N];
int color[N],d[N],f[N];
int world_time;

int next(int node){
  for(int v=0;v<n;v++){
    if(M[node][v] == 1 && color[v] == WHITE){
      return v;
    } 
  }
  return NIL;
}

void dfs_visit(int i){
  
  world_time = world_time + 1;
  stack<int> S;
  S.push(i);
  color[i] = GRAY;
  d[i] = world_time;

  int present,next_node;
  while( !S.empty() ){
    world_time = world_time + 1;
    present = S.top();
    next_node = next(present);

    if(next_node != NIL){
      S.push(next_node);
      d[next_node] = world_time;
      color[next_node] = GRAY;
    }else{
      color[present] = BLACK;
      S.pop();
      f[present] = world_time;
    }
  }
}

void dfs(){
  world_time = 0;

  for(int i=0;i<n;i++){
    color[i] = WHITE;
  }

  for(int i=0;i<n;i++){
    if(color[i] == WHITE){
      dfs_visit(i);
    }
  }

  for(int i=0;i<n;i++){
    cout << i+1 << " " << d[i] << " " << f[i] <<endl;
  }
}


int main(void){
  cin >> n;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      M[i][j] = 0;
    }
  }

  int u,v,k;
  for(int i=0;i<n;i++){
    cin >> u >> k;

    for(int j=0;j<k;j++){
      cin >> v;
      M[u-1][v-1] = 1;
    }
  }

  dfs();

  return 0;
}



Measured memory_bytes: 3116
import bisect
import sys
from itertools import accumulate

input = sys.stdin.readline


def main():
    N, M, K = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    B_cumsum = list(accumulate(B))
    ans = 0
    time = 0
    for i in range(N + 1):
        if time > K:
            break
        j = bisect.bisect_right(B_cumsum, K - time)
        ans = max(ans, i + j)

        if i < N:
            time += A[i]

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 41512
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Runtime.InteropServices.ComTypes;
using System.Text;
using System.Threading;

class Program
{
  
    
    static void Main(string[] args)
    {
        string s = Console.ReadLine();
        int len = s.Length;
        string ans = "";
        for(int i = 0; i < len; i++)
        {
            ans += "x";
        }
        Console.WriteLine(ans);


    }




}

Measured memory_bytes: 25844
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	static class Task {
        public void solve(InputReader in, PrintWriter out) {
        	int a = in.nextInt();
          	int b = in.nextInt();
			int c = in.nextInt();
          	out.println(a*b/2);
        }
    }
	
    public static void main(String argds[]) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

	static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
        
        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
 
        public int nextInt() {
            return Integer.parseInt(next());
        }
 
        public long nextLong() {
            return Long.parseLong(next());
        }
    }	
}

Measured memory_bytes: 22356
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
#define toupper(S) transform(S.begin(),S.end(),S.begin(),toupper)
#define tolower(S) transform(S.begin(),S.end(),S.begin(),tolower)
//const lint MOD = pow(10, 9) + 7;

int main() {
	int N, M;
	cin >> N >> M;
	if (M == 0) {
		if (N == 1) {
			cout << 0 << endl;
			return 0;
		}
		else if (N == 2) {
			cout << 10 << endl;
			return 0;
		}
		else {
			cout << 100 << endl;
			return 0;
		}
	}
	vector<IP>SC(M);
	rep(i, M) {
		cin >> SC[i].first >> SC[i].second;
	}
	sort(SC);
	/*rep(i, M) {
		cout << SC[i].first << ' ' << SC[i].second << endl;
	}*/
	vector<int>ans(N, 0);

	


	if (M >= 2) {
		rep(i, M - 1) {
			if (SC[i].first == SC[i + 1].first && SC[i].second != SC[i + 1].second) {
				cout << -1 << endl;
				return 0;
			}
		}
	}

	if (N != 1) {
		if (SC[0].first == 1 && SC[0].second == 0) {
			cout << -1 << endl;
			return 0;
		}
	}
	
	rep(i, M) {
		ans[SC[i].first - 1] = SC[i].second;
	}

	if (N == 1) {
		cout << ans[0] << endl;
	}

	else {
		rep(i, N) {
			if (i == 0) {
				if (ans[i] == 0) {
					cout << 1;
				}
				else {
					cout << ans[i];
				}
			}
			else {
				cout << ans[i];
			}
		}
		cout << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
vector<long long> d;
int main(void) {
  lint n;cin>>n;
  long long p;cin>>p;
  if (n==1) {
    cout<<p<<endl;
    return 0;
  }
  for (long long i=2;i*i<=p;i++){
    while(p%i==0) {
      d.push_back(i);
      p/=i;
    }
  }
  if (p!=1) d.push_back(p);
  int cnt=1;
  lint ans=1;
  for (int i=0;i<(int)d.size()-1;i++){
    if (d[i]==d[i+1]) {
      cnt++;
    }
    else {
      if (cnt>=n) ans*=pow(d[i],(cnt/n));
      cnt=1;
    }
    if (i==(int)d.size()-2) {
      if (cnt>=n) ans*=pow(d[i],(cnt/n));
    }
  }
  cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 3920
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <complex>
#include <chrono>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second

using namespace std;
const int MX = 100010;            // maximum no. of nodes in graph
vector<bool> visited(MX+1,0);
vector<int> maxdis(MX+1,0);
int n;
vector< vector<int> > G(MX+1);        // adjacency list, (edge,cost) pair
vector< vector<int> > P(MX+1);

int dfs(int x)
{
    if (visited[x]) {
        return maxdis[x];
    }
    visited[x]=true;
    int ans = 0,t;
    for(auto& i : G[x])
    {
        t = dfs(i);
        if (ans < t) {
            ans = t;
        }
    }
    ans++;
    maxdis[x] = ans;
    return ans;
}
int main()
{
    std::ios::sync_with_stdio(false);
    for(int i=0; i<MX+1; i++)
    {
        G[i].clear();
        P[i].clear();
    }
    fill(all(visited),0);
    int m;                    // no. of edges
    cin>>n>>m;
    for(int i = 1 ; i <= m ; i++)
    {
        int u,v;
        cin>>u>>v;            // 1 based indexing of nodes
        G[u].eb(v);
        P[v].eb(u);
    }
    vector<size_t> sizes(n+1,0);
    int ans = 0,t;
    for (size_t i = 1 ; i <= n; i++) {
        if (P[i].empty()) {
            t = dfs((int)i);
            if (ans < t) {
                ans = t;
            }
        }
    }
    std::cout << ans - 1 << endl;
    
    return 0;
}



Measured memory_bytes: 19980
#include <cstdio>

#define cmax(a,b) ((a)>(b)?(a):(b))

template<class T>void fr(T &a) {
    T w=0,s=1;char c=getchar();
    while(c<'0'||c>'9') {if(c=='-')s=-1;c=getchar();}
    while(c>='0'&&c<='9') w=w*10+c-'0',c=getchar();
    a=w*s;
}
template<class T>T fr() {T a;fr(a);return a;}
#define R() fr<int>()

char str[100010];

signed main() {
    int n=R(),ans=1;scanf("%s",str+1);
    for(int i=2;i<=n;i++)
        if(str[i]!=str[i-1])ans++;
    return !printf("%d\n",ans);
}

/*
03210120123452101
<>>><<><<<<<>>><

6+3+15+3+1=28
*/

Measured memory_bytes: 384
#include <stdio.h>
using namespace std;

int main(void) {
  long long i, j, k, n, ans = 0, a, now = 0;
  scanf("%lld", &n);
  for(i = 0; i < n; ++i) {
    scanf("%lld", &a);
    if(!a) ans += now / 2, now = 0;
    else now += a;
  }
  ans += now / 2;
  printf("%lld", ans);
  return 0;
}

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

using namespace std;

#define int long long int
#define vi vector<int>
#define pi pair<int,int>
#define ff first
#define ss second
#define vlli vector<long long int>
#define si set<int>
#define loop(i,k,n) for(int i=k;i<n;i++)
#define MOD 1000000007
#define r0 return 0
/*
//gcd in O(log(a))
int gcd(int a, int b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
*/
/*
int gcd, x, y;

void extendedEuclid (int a, int b)
{
    if (b==0)
    {
        x=1;
        y=0;
        gcd=a;
        return;
    }
    extendedEuclid(b, a%b);
    int x1=y;
    int y1=x-(a/b)*y;
    x=x1;
    y=y1;
}

int nCr (int n, int r)
{
    int p=1, k=1, modInv;
    if (n-r<r)
        r=n-r;
    if (r!=0)
    {
        while (r)
        {
            p=(p*n)%MOD;
            k*=r;
            n--;
            r--;
        }
        extendedEuclid(k, MOD);
        modInv=(x+MOD)%MOD;
        p=(p*modInv)%MOD;
    }
    else
        p=1;
    return p;
}
*/
 double dp[3100][3100];
int32_t main(void)
{
    int y=1;
    //cin>>t;
    while(y--)
    {
        int n;
        cin>>n;
        vector<double> p(n+1);
        for(int i=1;i<=n;i++)
            cin>>p[i];
        for(int i=0;i<=n;i++)
        {
            for(int j=0;j<=n;j++)
                dp[i][j]=0;
        }
        dp[0][1]=1-p[1];
        dp[1][1]=p[1];
        for(int j=2;j<=n;j++)
        {
            for(int i=0;i<=j;i++)
            {
                if(i==0)
                    dp[i][j]=dp[i][j-1]*(1-p[j]);
                else
                {
                    dp[i][j]=dp[i][j-1]*(1-p[j])+(p[j]*dp[i-1][j-1]);
                }
            }
        }

        int k=(n/2)+1;
        double ans=0;
        for(int i=k;i<=n;i++)
        {
            ans+=dp[i][n];
        }
        cout<<setprecision(10)<<ans;

    }
}

Measured memory_bytes: 73984
#include <iostream>

using lint = long long;

int main() {
    lint n, a, b;
    std::cin >> n >> a >> b;
    if (a < b) std::swap(a, b);

    if ((a - b) % 2 == 0) {
        std::cout << (a - b) / 2 << std::endl;
        return 0;
    }

    lint ans = (a + b - 1) / 2;

    a = n - a + 1;
    b = n - b + 1;
    std::swap(a, b);

    ans = std::min(ans, (a + b - 1) / 2);
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
A = [int(x) for x in input().split()]

B = []
c = 0
for a in A:
    B.append(c)
    c = (c + a) % M
B.append(c)
from collections import Counter
cnt = Counter(B)

ans = 0
for v in cnt.values():
    if v >= 2:
        ans += (((v - 1) + 1) * (v - 1)) // 2
print(ans)

Measured memory_bytes: 16596
#ifdef ConanYu
#include "local.hpp"
#else
#pragma GCC optimize("-O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void Main();
#define debug(...) do { } while(0)
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  Main();
}
#endif

int dp[20005];

void Main() {
  int h, n; cin >> h >> n;
  memset(dp, 0x3f, sizeof dp);
  dp[0] = 0;
  for(int i = 0; i < n; i++) {
    int a, b; cin >> a >> b;
    for(int j = 0; j <= 20000 - a; j++) {
      dp[j + a] = min(dp[j + a], dp[j] + b);
    }
    for(int j = 20000; j >= 0; j--) {
      dp[j] = min(dp[j + 1], dp[j]);
    }
  }
  cout << dp[h] << "\n";
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;



int main(){
    LL n;cin >> n;
    cout << n*(n-1)/2 << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d,sa;
  cin >> a >> b >> c >> d;
  sa = a + b - c - d;
  bool x,y,z;
  x = sa == 0;
  y = sa > 0;
  z = sa < 0;
 
  if (x) {
    cout << "Balanced" << endl;
  }else if(y){
    cout << "Left" << endl;
  }else if(z){
    cout << "Right" << endl;
  }
 
}

Measured memory_bytes: 256
/*
AizuOnline A0070
Combination of Number Sequences
*/
#include <stdio.h>
#define min(x,y) (((x)>(y))?(y):(x))

int used_list[10];
int upper_limit[11]={0,9,26,50,80,115,154,196,240,285,330};

long int c_n_s(int n,int s,int used_list_ptr)
{
  int i,j;
  long int sum,ret;

/* printf("%d %d %d\n",n,s,used_list_ptr);*/
   if(s > upper_limit[n])
        return(0);

  if(n==1)
    {
      for(i=0;i<used_list_ptr;i++)
        {
          if(s == used_list[i])
            {
              return(0);
            }
        }
      /*if(s > 9)
        return(0);*/
      /*printf("*");*/
      return(1);
            
        
    }
  else
    { sum = 0;
      for(i=min(9,(int)(s/n));i>=0;i--)
        { 
          {for(j=0;j<used_list_ptr;j++)
            if(i == used_list[j])
              goto AAA;
          }
         
          used_list[used_list_ptr]=i;
          
          ret = c_n_s(n-1,s-i*n,used_list_ptr+1);
          sum += ret;
        AAA:
          ;
        }
      ;
    }
  return(sum);
}



main()
{
int n , s;
long int ret;

  while(EOF != scanf("%d %d",&n,&s))
    {
      ret = c_n_s (n,s,0);

      printf("%ld\n",ret);
    }
  return(0);
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <ccomplex>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;


int main() {
	ll h, w; cin >> h >> w;
	if (w == 1) {
		cout << 1 << endl;
		return 0;
	}
	if (h == 1) {
		cout << 1 << endl;
		return 0;
	}
	cout << h*(w / 2) + (w & 1 ? (h + 1) / 2 : 0) << endl;
	return 0;
}

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

using namespace std;

int s[200];
int b[200][200];
int sum[200];

int main(){
	
	int N, K;
	
	while(true){
		cin >> N >> K;
		if(N == 0 && K == 0){
			break;
		}
		for(int i = 0; i < K; i++){
			cin >> s[i];
			sum[i] = 0;
		}
		for(int i = 0; i < N; i++){
			for(int j = 0; j < K; j++){
				cin >> b[i][j];
				sum[j] += b[i][j];
			}
		}
		for(int i = 0; i < K; i++){
			if(s[i] < sum[i]){
				printf("No\n");
				break;
			}
			if(i == K - 1){
				printf("Yes\n");
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
#define int long long
#define N 300004
#define LL long long
#define ULL unsigned long long
#define pp pair<int,int>
#define mp make_pair
#define pb push_back
#define ff first
#define dd second
#define REP(i,n) for(int i=0;i<(n);++i)
#define FWD(i,a,b) for (int i=(a); i<(b); ++i)
#define BCK(i,a,b) for (int i=(a); i>(b); --i)
#define SIZE(c) ((int)((c).size()))
#define ALL(u) (u).begin(),(u).end()
#define K 41
LL fpw(LL a, ULL b, LL p){
    LL r = 1; while(b){if(b&1) r=r*a%p; a=a*a%p; b/=2;} return (LL)r;
}

using namespace std;
int n, m,a,b,k;

int mod = 998244353;

bitset<301> tab[301];

int potTwo[301];

int newton[301][301];

int potThree[301];

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin >> n >> m;

    for(int i = 0; i  < 301; ++i) for(int j = 0; j < 301; ++j) newton[i][j] = 0;
    for(int i = 0; i < 301; ++i) newton[i][0] = 1;
    for(int i = 1; i < 301; ++i) {
        for(int j = 1; j <= i; ++j) {
            newton[i][j] = (newton[i-1][j-1] + newton[i-1][j]) % mod;
        }
    }

    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < m; ++j) {
           int temp; cin >> temp;
            tab[i].set(j,temp);
        }
    }

    int row = 0;
    for(int col = 0; col < m; ++col) {
        for(int i = row; i < n; ++i) {
            if (tab[i][col]) {
                swap(tab[i], tab[row]); break;
            }
        }
        if (row < n && tab[row][col]) {
            for(int i = row+1; i < n; ++i) {
                if(tab[i][col]) tab[i] ^= tab[row];
            }
            row++;
        }
    }

   /* cout << "row " << row << endl;

    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < m; ++j) {
            cout << tab[i][j] << " ";
        }
        cout << endl;
    }*/

    potTwo[0] = potThree[0] = 1;
    for(int i = 1; i < 301; ++i) potTwo[i] = potTwo[i-1]*2 % mod;
    for(int i = 1; i < 301; ++i) potThree[i] = potThree[i-1]*3 % mod;

    int ans = potTwo[n-row]*potTwo[m-row] % mod;
    int ile = 0;
    for(int i = 1; i <= row; i += 2) {
        ile += potThree[row-i]*newton[row][i] % mod;
        ile %= mod;
    }
    ans *= ile;
    ans %= mod;
    cout << ans << endl;
}


Measured memory_bytes: 1024
x=int(input())

ans=0
if 1800<=x:
    ans=1
elif 1600<=x:
    ans=2
elif 1400<=x:
    ans=3
elif 1200<=x:
    ans=4
elif 1000<=x:
    ans=5
elif 800<=x:
    ans=6
elif 600<=x:
    ans=7
else:
    ans=8

print(ans)

Measured memory_bytes: 61616
fn main() {
    proconio::input! {
        n: usize,
        a: i128,
        b: i128,
        xs: [i128; n],
    }
    let mut cost = 0;
    for i in 1..n {
        let distance = xs[i] - xs[i - 1];
        if distance * a < b {
            cost += distance * a;
        } else {
            cost += b;
        }
    }
    println!("{}", cost);
}


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

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


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


Measured memory_bytes: 2132
#include <iostream>
using namespace std;
int main() {
	int D, N; cin >> D >> N;

	int S = 1; for (int i = 0; i < D; i++) S *= 100;
	if (N <= 99) {
		cout << S * N << endl;
	}
	else {
		cout << S * 101 << endl;
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    String S, T;
    int cnt = 0;
    Scanner sc = new Scanner(System.in);

    S = sc.next();
    T = sc.next();
    for (int i = 0; i < S.length(); i++) {
      if (S.charAt(i) != T.charAt(i)) {
        cnt++;
      }
    }
    System.out.print(cnt);
  }
}

Measured memory_bytes: 41236
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#define rep(i,a,b) for(i=a;i<=b;i++)
using namespace std;
const int N=110;
int dp[N][N];int ans;
int s1[2][N][N],s2[N][N];int a[N][N];char s[N];
int px,py;int n,m;

void init(){
	int i,j;
	rep(i,1,n)	rep(j,1,m)	s1[0][i][j]=s1[0][i][j-1]+a[i][j];
	rep(i,1,n)	rep(j,1,m)	s1[1][i][j]=s1[1][i-1][j]+a[i][j];
	rep(i,1,n)	rep(j,1,m)	s2[i][j]=s2[i-1][j]+s1[0][i][j];
}

void calc(int x,int y){
	int i,j,tx,ty,lx,ly;
	memset(dp,0,sizeof(dp));
	tx=px+x-(n-px);ty=py+y-(m-py);
	dp[tx][ty]=s2[px+x][py+y]-s2[px+x][ty-1]-s2[tx-1][py+y]+s2[tx-1][ty-1];
	lx=n-px;ly=m-py;
	for(i=tx;i>=x+1;i--){
		for(j=ty;j>=y+1;j--){
			if(i<tx)	dp[i][j]=max(dp[i][j],dp[i+1][j]+s1[0][i][j+ly]-s1[0][i][j-1]);
			if(j<ty)	dp[i][j]=max(dp[i][j],dp[i][j+1]+s1[1][i+lx][j]-s1[1][i-1][j]);
			//if(x==1&&y==0)	cerr<<i<<' '<<j<<' '<<dp[i][j]<<endl;
		}
	}
	//cerr<<x<<' '<<y<<' '<<dp[x+1][y+1]<<endl;
	ans=max(ans,dp[x+1][y+1]);
}

void work(){
	int i,j;
	rep(i,0,px-1)	rep(j,0,py-1){
		if(px+i>n||py+j>m)	continue;
		calc(i,j);
	}
}
			

int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	int i,j;
	scanf("%d%d",&n,&m);
	rep(i,1,n){
		scanf("%s",s+1);
		rep(j,1,m){
			if(s[j]=='.')	a[i][j]=0;
			else if(s[j]=='o')	a[i][j]=1;
			else px=i,py=j;
		}
	}
	if(px-1<n-px){
		rep(i,1,n)	rep(j,1,m)	if(i<n-i+1)	swap(a[i][j],a[n-i+1][j]);
		px=n-px+1;
	}
	if(py-1<m-py){
		rep(i,1,n)	rep(j,1,m)	if(j<m-j+1)	swap(a[i][j],a[i][m-j+1]);
		py=m-py+1;
	}
	/*cerr<<px<<' '<<py<<endl;
	rep(i,1,n){
		rep(j,1,m)	cerr<<a[i][j];
		cerr<<endl;
	}*/
	init();work();
	printf("%d\n",ans);
}



































































































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

int main() {
     char X,Y;
     cin >> X >> Y;
     if(X==Y){
         cout << "=" << endl;
     }
     if(X<Y){
         cout << "<" << endl;
     }
     if(X>Y){
         cout << ">" << endl;
     }

return 0;
}

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

int main(){
    int n;
    cin >> n;
    int x = n;
    int sum = 0;
    while(n>0){
        sum += n%10;
        n /= 10;
    }
    if(x%sum == 0){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

ll sum;
int n;
vector<ll>v;

int main() {
	cin>>n;
	for (int i=0;i<n;i++) {
		ll t; cin>>t;
		sum+=t; v.pb(t);
	}
	sort(v.begin(),v.end());
	cout<<v.front()<<' '<<v.back()<<' '<<sum<<'\n';
}


Measured memory_bytes: 3260
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from collections import deque

N,C,*H = map(int,read().split())

class ConvexHullTrick:
    """
    f_i = a_ix + b_i とする。f_i の追加および、min_i f(x) の取得ができるデータ構造。
    ただし、傾き a_i は昇順に追加されなければならない。
    また、クエリ x も昇順に実行されなければならない。
    """
    def __init__(self):
        self.funcs = deque()

    def add(self,a,b):
        funcs = self.funcs
        while len(funcs) >= 2:
            a1,b1 = funcs[-2]
            a2,b2 = funcs[-1]
            if (a2-a1)*(b-b2) < (b2-b1)*(a-a2):
                break
            funcs.pop()
        funcs.append((a,b))

    def query(self,x):
        funcs = self.funcs
        a,b = funcs[0]
        y = a*x+b
        while len(funcs) >= 2:
            a2,b2 = funcs[1]
            y2 = a2*x+b2
            if y < y2:
                break
            y = y2
            funcs.popleft()
        return y

dp = [0] * N
cht = ConvexHullTrick()
add = cht.add; query = cht.query

h = H[0]
add(-2*h, h*h)
for i,h in enumerate(H[1:],1):
    x = query(h) + h*h + C
    dp[i] = x
    add(-2*h, h*h + x)

answer = dp[-1]
print(answer)

Measured memory_bytes: 41540
#include<bits/stdc++.h>
using namespace std;
const long long N=100010;
long long s[N];
int main(){
	long long n,m,last;
	scanf("%d%d",&n,&m);
	scanf("%d",&last);
	long long x,tot=0,fir=last;
	for(long long i=2;i<=n;i++){
		scanf("%d",&x);
		if(x<last){
			tot++;
			s[last+1]-=last;
			s[1]-=last-m;
			s[x+1]+=last-m;
		}else{
			s[last+1]-=last;
			s[x+1]+=last;
		}
		last=x;
	}
	for(long long i=1;i<=m;i++) s[i]+=s[i-1];
	for(long long i=1;i<=m;i++){
		long long k=0;
		if(i<=x) k++;
		if(i<=fir) k--;
		s[i]+=(tot+k)*(i-1);
	}
	long long fav=1;
	for(long long i=2;i<=m;i++) if(s[i]>s[fav]) fav=i;
	printf("%lld\n",x+tot*m-fir-s[fav]);
	return 0;
}


Measured memory_bytes: 1024
#!/usr/bin/env python3
import sys
# gcd
from fractions import gcd
# 切り上げ，切り捨て
# from math import ceil, floor
# リストの真のコピー（変更が伝播しない）
# from copy import deepcopy
# 累積和。list(accumulate(A))としてAの累積和
from itertools import accumulate
# l = ['a', 'b', 'b', 'c', 'b', 'a', 'c', 'c', 'b', 'c', 'b', 'a']
# S = Counter(l)  # カウンタークラスが作られる。S=Counter({'b': 5, 'c': 4, 'a': 3})
# print(S.most_common(2))  # [('b', 5), ('c', 4)]
# print(S.keys())  # dict_keys(['a', 'b', 'c'])
# print(S.values())  # dict_values([3, 5, 4])
# print(S.items())  # dict_items([('a', 3), ('b', 5), ('c', 4)])
# from collections import Counter
# import math
# from functools import reduce
#
# input関係の定義
# fin = open('in_1.txt', 'r')
# sys.stdin = fin
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template


def iterate_tokens():
    for line in sys.stdin:
        for word in line.split():
            yield word


if __name__ == '__main__':

    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    P = int(next(tokens))  # type: int

    # write code
    P += 3 * A
    print(P//2)


Measured memory_bytes: 5076
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

def lcm(a,b):
    return a*b//gcd(a,b)

n = int(input())
A = list(map(int, input().split()))

tg = 1
for a in A:
    tg = lcm(tg, a)
ans = 0
for a in A:
    ans += tg // a
print(ans%(10**9+7))

Measured memory_bytes: 4084