akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)

template<typename T, int len>
struct BIT
{
    array<T, len + 1> val;
    BIT() { val.fill(0); }
    void add(int pos, T v)
    {
        while (pos > 0 && pos <= len)
        {
            val[pos] += v;
            pos += pos & -pos;
        }
    }
    T sum(int pos)
    {
        T res = 0;
        while (pos > 0)
        {
            res += val[pos];
            pos -= pos & -pos;
        }
        return res;
    }
};

int N, M, Q;
using tpl = tuple<int, int, int>;

int main()
{
    cin >> N >> M >> Q;

    vector<tpl> query(M + Q);
    REP(m, M)
    {
        int l, r;
        cin >> l >> r;
        query[m] = tpl(r, -1, l);
    }
    REP(q, Q) {
        int l, r;
        cin >> l >> r;
        query[M + q] = tpl(r, q, l);
    }
    sort(query.begin(), query.begin() + M + Q);

    BIT<int, 500> bit;
    array<int, 100000> ans;

    REP(i, M + Q) {
        int l, r, q;
        tie(r, q, l) = query[i];
        if (q < 0)
            bit.add(l, 1);
        else {
            ans[q] = bit.sum(r) - bit.sum(l - 1);
        }
    }
    REP(q, Q) cout << ans[q] << endl;
}


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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] d =  new int[3];

        d[0] = sc.nextInt();
        d[1] = sc.nextInt();
        d[2] = sc.nextInt();

        Arrays.sort(d);



        System.out.println(10 * d[2] + d[1] + d[0]);
    }

}


Measured memory_bytes: 21712
#include <stdio.h>

int main(void)
{
	int n, m, a, b, c, d, e;
	scanf("%d %d", &n, &m);
	int num[n][m], numb[n],numc[n];
	for(a=0;a<n;a++){
		for(b=0;b<m;b++){
			scanf("%d", &num[a][b]);
		}
	}
	
	for(c=0;c<m;c++){
		scanf("%d", &numb[c]);
	}

	for(d=0;d<n;d++){
		numc[d] = 0;
		for(e=0;e<m;e++){
		
			numc[d] += num[d][e]*numb[e];
			
		}
		printf("%d\n", numc[d]);
	}
	return 0;
}
		

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
#define forr(i, a, b) for(int i = (a); i < (int) (b); i++)
#define forn(i, n) forr(i, 0, n)
#define forall(it, v) for(auto it = v.begin(); it != v.end(); ++it)
#define dforn(i, n) for(int i = ((int) n) - 1; i >= 0; i--)
#define db(v) cerr << #v << " = " << v << endl
#define pb push_back
typedef long long ll;
const int MAXN = 1000050;

ll ans, n, cnt[256];
string s;

int main() {
  cin >> s;
  n = s.size();
  
  forn(i, n){
    cnt[ s[i] - 'a' ]++;
  }
  
  ans = n*(n - 1)/2;
  forn(i, 26){
    ans -= cnt[i]*(cnt[i] - 1)/2;
  }
  
  printf("%lld\n", ans + 1);
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, e, n) for (int i = e; i < (n); ++i)
using namespace std;
typedef long long ll;
using P = pair<int,int>;
const ll inf=1000000000007;

int main(){
  int a,b,t;
  cin >> a >> b >> t;
  int val=(t+0.5)/a;
  cout << val*b << endl;
  return 0;
}

Measured memory_bytes: 3612
#include <cstdio>
#include <math.h>

int main()
{
    int n;
    int x[1001], y[1001];
    double D1 = 0, D2 = 0;
    long double D3;
    long int sum = 0;
    int a;
    double max = 0;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &x[i]);
    }
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &y[i]);
    }
    for (int i = 0; i < n; i++)
    {
        D1 += fabs(x[i] - y[i]);
    }
    printf("%.6f\n", D1);
    for (int i = 0; i < n; i++)
    {
        sum += fabs(x[i] - y[i]) * fabs(x[i] - y[i]);
    }
    D2 = sqrt(sum);
    printf("%.6f\n", D2);
    sum = 0;
    for (int i = 0; i < n; i++)
    {
        sum += pow( fabs(x[i] - y[i]),double(3));
    }
    D3 = pow(double(sum), double(0.3333333333333333333333));
    printf("%.6Lf\n", D3);
    for (int i = 0; i < n; i++)
    {
        a = fabs(x[i] - y[i]);
        if (max < a)
        {
            max = a;
        }
    }
    printf("%.6f\n", max);
}


Measured memory_bytes: 2868
#include <iostream>
#include <map>
#include <algorithm>
#include <queue>
using namespace std;
typedef pair<string,int> NODE;
int main(){
	NODE now;
	map<string,int> done;
	queue<NODE> Q;
	Q.push(make_pair("01234567",0));
	while(!Q.empty()){
		now = Q.front();Q.pop();
		done[now.first] = now.second;
		
		int x = now.first.find("0");
		if( (x+1)%4 ){
			swap(now.first[x],now.first[x+1]);
			if( done.find(now.first) == done.end() )Q.push(make_pair(now.first,now.second+1));
			swap(now.first[x],now.first[x+1]);
		}
		if( x%4 ){
			swap(now.first[x],now.first[x-1]);
			if( done.find(now.first) == done.end() )Q.push(make_pair(now.first,now.second+1));
			swap(now.first[x],now.first[x-1]);
		}
		if( x<4 ){
			swap(now.first[x],now.first[x+4]);
			if( done.find(now.first) == done.end() )Q.push(make_pair(now.first,now.second+1));
			swap(now.first[x],now.first[x+4]);
		}
		if( x>=4){
			swap(now.first[x],now.first[x-4]);
			if( done.find(now.first) == done.end() )Q.push(make_pair(now.first,now.second+1));
			swap(now.first[x],now.first[x-4]);
		}
	}
	string t,data;
	while(cin >> t){
		data = t;
		for(int i=0;i<7;i++){
			cin >> t;
			data += t;
		}
		cout << done[data] << endl;
	}
}

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

using namespace std;
int main(){

  map<string,int>mp;

  int n;

  cin>>n;

  string str,str1;

  for(int i=0;i<n;i++){

    cin>>str>>str1;

    if(str=="insert"){
      mp[str1]=1;
    }
    else{
      if(mp.count(str1))
	cout<<"yes"<<endl;
      else
	cout<<"no"<<endl;
    }

  }

  return 0;
  
}



Measured memory_bytes: 36892
from itertools import combinations
n,x,y = map(int,input().split())
x -= 1
y -= 1
ans = [0]*n
for i,j in combinations(range(n),2):
  dist = min(j-i,abs(i-x)+abs(j-y)+1)
  ans[dist-1] += 1
anss = ans[:n-1]
print(*anss,sep="\n")


Measured memory_bytes: 46044
import sys
import math

INF = 10**9+7

stdin = sys.stdin
def na(): return map(int, stdin.readline().split())
def ns(): return stdin.readline().strip()
def nsl(): return list(stdin.readline().strip())
def ni(): return int(stdin.readline())
def nil(): return list(map(int, stdin.readline().split()))

def gcd(a, b):
    if b == 0: return a
    return gcd(b, a % b)

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

a, b, c = nil()

ans = "NO"

if c % (b/(lcm(a, b)/a)) == 0:
    ans = "YES"

print(ans)

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

using namespace std;

const int md = 1000000007;

inline void add(int &a, int b) {
  a += b;
  if (a >= md) {
    a -= md;
  }
}

const int N = 1234567;

int f[N], g[N];
int fs[N], gs[N];
int can_a[N], can_b[N];
long long _p[N], *p = _p + 1;

int main() {
  int n;
  long long a, b;
  scanf("%d %lld %lld", &n, &a, &b);
  p[-1] = -(long long) 3e18;
  for (int i = 0; i < n; i++) {
    scanf("%lld", p + i);
  }
  can_a[n - 1] = can_b[n - 1] = n - 1;
  for (int i = n - 2; i >= 0; i--) {
    can_a[i] = (p[i + 1] - p[i] >= a ? can_a[i + 1] : i);
    can_b[i] = (p[i + 1] - p[i] >= b ? can_b[i + 1] : i);
  }
  f[0] = g[0] = 1;
  int ans = 0;
  int sf = 0, sg = 0;
  for (int i = 0; i < n; i++) {
    add(sf, fs[i]);
    add(sg, gs[i]);
    add(f[i], sf);
    add(g[i], sg);
    {
      int to = can_a[i] + 1;
      int from = lower_bound(p, p + n, p[i - 1] + b) - p;
      from = max(from, i + 1);
      to = min(to, n - 1);
      if (from <= to) {
        add(gs[from], f[i]);
        add(gs[to + 1], md - f[i]);
      }
    }
    {
      int to = can_b[i] + 1;
      int from = lower_bound(p, p + n, p[i - 1] + a) - p;
      from = max(from, i + 1);
      to = min(to, n - 1);
      if (from <= to) {
        add(fs[from], g[i]);
        add(fs[to + 1], md - g[i]);
      }
    }
    if (can_a[i] == n - 1) {
      add(ans, f[i]);
    }
    if (can_b[i] == n - 1) {
      add(ans, g[i]);
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 3456
# セグメント木を用いた解法
from fractions import gcd
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines


class SegmentTree:
    # セグ木は 1-indexed
    def __init__(self, n, initial=0):
        """
        n: 配列の大きさ
        initial: 単位元 (RMQでは大きな値)
        """
        self.offset = 2**(n-1).bit_length()  # 2進数表記の長さ
        self.initial = initial
        self.seg = [self.initial] * (2 * self.offset)
        

    def build(self, A):
        """
        A: 処理したい配列
        """
        for i, a in enumerate(A, start=self.offset):
            self.seg[i] = a
        for i in range(self.offset-1,0,-1):
            self.seg[i] = gcd(self.seg[i<<1] ,self.seg[(i<<1)+1])

            
    def update(self, k, a):
        """
        k番目の値をaに変更
        """
        k += self.offset
        self.seg[k] = a
        while k:
            k >>= 1
            self.seg[k] = gcd(self.seg[k<<1], self.seg[(k<<1)+1])

            
    def query(self, a, b):
        """
        区間[a, b)に対して最小公倍数を求める
        """
        a += self.offset
        b += self.offset - 1 
        res = self.initial
        while a < b:
            if a & 1:  # 兄弟の右なら
                res = gcd(res, self.seg[a])
                a += 1
            if not b & 1:  # 兄弟の左なら
                res = gcd(res, self.seg[b])
                b -= 1
            a >>= 1
            b >>= 1
        
        if a == b:
            res = gcd(res, self.seg[a])
        
        return res


if __name__ == "__main__":
    N = int(readline())
    A = [int(i) for i in readline().split()]
    seg = SegmentTree(N)
    seg.build(A)

    ans = seg.query(1, N)
    for i in range(N-2):
        tmp = gcd(seg.query(0, i+1), seg.query(i+2, N))
        ans = max(ans, tmp)
    ans = max(ans, seg.query(0, N-1))

    print(ans)

Measured memory_bytes: 89832
#include <bits/stdc++.h>
using namespace std;
 
//long long
using ll = long long;
 
// pair<int, int>
using PII = pair<int, int>;
 
//最大値、mod
const int MOD = 1000000007;
const int INF = 1000000000;
const long long LINF = 1e18;
const int MAX = 510000;
 
//出力系
#define print(x) cout << x << endl
#define prints(x) cout << fixed << setprecision(10) << x << endl
#define printc(x) cout << setw(2) << setfill('0') << x << endl;
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()
 
//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
 
//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
 
// 最小公倍数
unsigned lcm(unsigned a, unsigned b){
    return a / gcd(a, b) * b; 
}
 
// a = max(a, b), a = min(a, b)
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; }
 
// 階乗(MODをとる)
ll pow_mod(ll num, ll pow, ll mod) {
    ll prod = 1;
    num %= mod;
    while (pow > 0) {
        if (pow & 1) prod = prod * num % mod;
        num = num * num % mod;
        pow >>= 1;
    }
    return prod;
}
 
 
 
// 二項係数(MODとる、1 ≦ k ≦ n ≦ 10^7 程度)
// COMinit()
// COM(x, y)
// とコンビで使う
 
// テーブルを作る前処理
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
//int dx[4] = {0, 0, 1, -1}, dy[4] = {1, -1, 0, 0};
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(){
    int N, M;
    cin >> N >> M;
    vector<int>A(N, 0);
    REP(i, M){
        int a, b;
        cin >> a >> b;
        a--; b--;
        int mi = min(a, b);
        int mx = max(a, b);
        A[mi]++;
        A[mx]--;
    }
    bool flag = true;
    for(int i = 1; i < N; i++){
        A[i] = A[i] + A[i - 1];
    }
    REP(i, N - 1){
        if(A[i] % 2 != 0){
            flag = false;
            break;
        }
    }
    flag ? YES : NO;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>

using namespace std;

struct cloth{
	cloth(int a, int b, int c):maxtem(a), mintem(b), gaudy(c){}
	int maxtem;
	int mintem;
	int gaudy;
};

struct state{
	state(bool a, int b):mark(a), count(b){}
	bool mark;
	int count;
};

int main(){
	int d, n;
	cin >> d >> n;
	vector<int> maxtem(d, 0);
	for(int i = 0; i < d; i++){
		cin >> maxtem[i];
	}
	vector<cloth> c(n, cloth(0, 100, 0));
	for(int i = 0; i < n; i++){
		cin >> c[i].mintem >> c[i].maxtem >> c[i].gaudy;
	}

	vector<vector<state> > table(d, vector<state>(101, state(false, 0)));
	for(int i = 0; i < d; i++){
		for(int j = 0; j < n; j++){
			if(maxtem[i]>=c[j].mintem&&maxtem[i]<=c[j].maxtem){
				if(!i){
					table[i][c[j].gaudy].mark = true;
					continue;
				}
				int max = 0;
				for(int k = 0; k < table[i-1].size(); k++){
					if(table[i-1][k].mark){
						int tmp = c[j].gaudy-k;
						if(tmp<0) tmp *= -1;
						tmp += table[i-1][k].count;
						if(max<=tmp){
							max = tmp;
						}
					}
				} 
				table[i][c[j].gaudy].mark = true;
				table[i][c[j].gaudy].count = max;
			}
		}
	}
	
	/*for(int i = 0; i < d; i++){
		for(int j = 0; j < table[i].size(); j++){
			if(j) cout << " ";
			cout << table[i][j].count;
		}
		cout << endl;
	}*/

	int max = 0;
	for(int i = 0; i < table[d-1].size(); i++){
		if(max<table[d-1][i].count) max = table[d-1][i].count; 
	}
	cout << max << endl;
	return 0;
}

Measured memory_bytes: 1328
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
#define pb push_back
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define inp(n) for(i=0;i<n;i++) cin>>A[i];
#define inz(A) memset(A,0,sizeof(A))
#define lb lower_bound
#define ub upper_bound
#define all(v) v.begin(),v.end()
#define T 1000000
#define F first
#define S second
#define pi pair<int,int>
#define vi vector<int>
#define mii map<int,int>
#define vp vector<pair< int,int> >
#define mip map<int, pair<int,int> >
#define inf INT_MAX
#define sz(v) v.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define debug(a,n) for(i=0;i<n;i++)cout<<a[i]<<" ";
#define d(x) cout<<x<<endl;
#define lower(s) transform(all(s),s.begin(),::tolower)
vector<int>adj [T];
			/*brownsands IIITA*/

void solve()
{   string s,s1;
int i,cnt=0;
    cin>>s>>s1;
    for(i=0;i<s.size();i++)
    if(s[i]==s1[i])cnt++;
    cout<<cnt;
}
signed main()
{
   boost
        int test=0,t;
		//cin>>t;
		t=1;
		while(test++ <t){
            //cout<<"Case "<<test<<": ";
            solve();
                           }		
} 
               
			
 

				
		
		




Measured memory_bytes: 23680
//ABC069B
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <unordered_map>
using namespace std;

int main(){
	string s;
	cin >> s;
	int n = s.size();
	cout << s.at(0) << n-2 << s.at(n-1) << endl;
	return 0;
}

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

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def solve(cake_list, M, p1, p2, p3):
    a, b, c = 0, 0, 0
    l = []
    for x, y, z in cake_list:
        k = x * p1 + y * p2 + z * p3
        l.append((k, x, y, z))

    for k, x, y, z in list(sorted(l, reverse=True))[:M]:
        a += x
        b += y
        c += z

    return abs(a) + abs(b)  + abs(c)


def main():
    N, M = map(int, input().split())
    cake = []
    for _ in range(N):
        x, y, z = map(int, input().split())
        cake.append((x, y, z))

    ans = -INF
    for p1, p2, p3 in product([-1, +1], repeat=3):
        ans = max(ans, solve(cake, M, p1, p2, p3))
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 4084
fun main(args: Array<String>) {
    val (a, b) = readLine()!!.split(" ").map { it.toInt() }

    if (a >= b) {
        if ((a - 1) >= b) {
            println(a + (a - 1))
        } else {
            println(a + b)
        }
    } else {
        if (a >= (b - 1)) {
            println(b + a)
        } else {
            println(b + (b - 1))
        }
    }
}

Measured memory_bytes: 37816
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include <iomanip>
#include <cmath>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60


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

	int A, B; cin >> A >> B;
	int ans = max(A + B, A - B);
	ans = max(ans, A*B);
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int cnt=1;
	while(1)
	{
		if(cnt%2==0)
		{
			a-=d;
			if(a<=0) 
		     {
		     	cout<<"No";
		     	return 0;
			 }
				
		}
		else
		{
			c-=b;
			if(c<=0) {
				cout<<"Yes";
				return 0;
			 }
		}
		cnt++;
	}
	return 0;
 } 

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

using namespace std;
int main(){
  int N,max=0,min=2000000000,i=0;
  cin >> N;
  int a[100];
  for(i=0;i!=N;i++) {
    cin >> a[i];
    if(a[i]>max) max=a[i];
    if(a[i]<min) min=a[i];
  }
  cout << max-min << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int l=s.length();
    if(l%2!=0)
    cout<<"No"<<endl;
    else{
        int i;
        for(i=0;i<l;i+=2)
        {
        if(s[i]!='h'||s[i+1]!='i')
           break;
        }
        if(i==l)
        cout<<"Yes"<<endl;
        else
        cout<<"No"<<endl;
    }
}

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

int main(){
  int K;
  string N;
  cin >> K >> N;
  
  int s = N.size();
  
  if(s <= K) cout << N << endl;
  else {
    for(int i = 0; i < K ;i++){
      cout << N.at(i);}
    cout << "..." << endl;
  }
}

Measured memory_bytes: 3628
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n,k = readline() |> split |> parseMap
	if k > div(n*(n-1),2)-n+1
		println(-1)
	else
		println(div(n*(n-1),2)-k)
		t = 0
		for i in 1:n
			for j in i+1:n
				if t >= div(n*(n-1),2)-k
					break
				end
				println(i," ",j)
				t += 1
			end
			if t >= div(n*(n-1),2)-k
				break
			end
		end
	end
end

main()

Measured memory_bytes: 165060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read(){
	ll a=0,b=getchar(),c=1;
	while(!isdigit(b))c=b=='-'?-1:1,b=getchar();
	while(isdigit(b))a=a*10+b-'0',b=getchar();
	return a*c;
}
ll n,x,ans=1,inf=1e18,a[100005];
int main(){
	cin >> n;
	for(int i=0;i<n;i++){
		a[i]=read();
		if(a[i]==0)return puts("0"),0;
	}
	for(int i=0;i<n;i++){
		if(a[i]>inf/ans)return puts("-1"),0;
		ans=ans*a[i];
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 4348
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long a = sc.nextLong();
    long b = sc.nextLong();
    System.out.println(lcm(a,b)); 
  }
    //最大公約数・最小公倍数（セットで使う）
static long gcd (long a, long b) {return b>0?gcd(b,a%b):a;}
static long lcm (long a, long b) {return a*b/gcd(a,b);}
  

  
}

Measured memory_bytes: 21844
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <utility>
#include <tuple>
using namespace std;

const double pi = acos(-1);
#define nyan cout << "(=^•ω•^=)" << endl;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define loop while(true)

int ans=10000;

signed main(){
    string s;cin>>s;
    for(int i=0;i<s.length()-2;i++){
        string t=s.substr(i,3);
        int v=stoi(t);
        if(abs(v-753)<ans)ans=abs(v-753);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

typedef long long ll;

int N;
ll A[200001];

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

    ll res=1;
    ll sum=A[0];
    int l=0;
    for(int r=1;r<N;r++) {
        while(sum+A[r] != (sum^A[r])) {
            sum-=A[l];
            l++;
        }
        res+=r-l+1;
        sum+=A[r];
    }
    cout<<res;
}

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

struct PrimalDual{
  const int INF = 1<<28;
  typedef pair<int,int> P;
  struct edge{
    int to,cap,cost,rev;
    edge(){}
    edge(int to,int cap,int cost,int rev):to(to),cap(cap),cost(cost),rev(rev){}
  };

  int n;
  vector<vector<edge> > G;
  vector<int> h,dist,prevv,preve;

  PrimalDual(){}
  PrimalDual(int sz):n(sz),G(sz),h(sz),dist(sz),prevv(sz),preve(sz){}
  
  void add_edge(int from,int to,int cap,int cost){
    G[from].push_back(edge(to,cap,cost,G[to].size()));
    G[to].push_back(edge(from,0,-cost,G[from].size()-1));
  }

  int flow(int s,int t,int f){
    int res=0;
    fill(h.begin(),h.end(),0);
    while(f>0){
      priority_queue<P,vector<P>,greater<P> > que;
      fill(dist.begin(),dist.end(),INF);
      dist[s]=0;
      que.push(P(0,s));
      while(!que.empty()){
        P p=que.top();que.pop();
        int v=p.second;
        if(dist[v]<p.first) continue;
        for(int i=0;i<(int)G[v].size();i++){
          edge &e=G[v][i];
          if(e.cap>0&&dist[e.to]>dist[v]+e.cost+h[v]-h[e.to]){
            dist[e.to]=dist[v]+e.cost+h[v]-h[e.to];
            prevv[e.to]=v;
            preve[e.to]=i;
            que.push(P(dist[e.to],e.to));
          }
        }
      }
      if(dist[t]==INF) return -1;
      for(int v=0;v<n;v++) h[v]+=dist[v];
      int d=f;
      for(int v=t;v!=s;v=prevv[v]){
        d=min(d,G[prevv[v]][preve[v]].cap);
      }
      f-=d;
      res+=d*h[t];
      for(int v=t;v!=s;v=prevv[v]){
        edge &e=G[prevv[v]][preve[v]];
        e.cap-=d;
        G[v][e.rev].cap+=d;
      }
    }
    return res;
  }
};

int main(){
  int n;
  while(cin>>n,n){
    PrimalDual p(n*2+2);
    int sum=0,cube[n],a[3];
    vector<vector<int> >v(n);
    r(i,n){
      r(j,3)cin>>a[j];
      sort(a,a+3);
      sum+=a[0]*a[1]*a[2];
      cube[i]=a[0]*a[1]*a[2];
      r(j,3)v[i].push_back(a[j]);
    }
    r(i,n){
      r(j,n){
        int c=0;
        r(k,3)if(v[i][k]>v[j][k])c++;
        if(c==3){
          p.add_edge(i,n+j,1,-cube[j]);
        }
      }
    }
    r(i,n)p.add_edge(n*2,i,1,0);
    r(i,n)p.add_edge(i+n,n*2+1,1,0);
    r(i,n)p.add_edge(i,n*2+1,1,0);
    cout<<sum+p.flow(n*2,n*2+1,n)<<endl;
  }
}


Measured memory_bytes: 3284
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
  	cin>>s;
  	int n;
  	n=s.size();
  	string t="x";
  	for(int i=0;i<n-1;i++){
    	t=t+"x";
    }
  	cout<<t<<endl;
}

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

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

Measured memory_bytes: 3572
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>

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

using namespace std;

inline int max(int a, int b) {
	if (b > a) swap(a, b);
	return a;
}

inline int min(int a, int b) {
	if (a > b) swap(a, b);
	return a;
}




int main() {
	int n, d;
	int count = 0;
	cin >> n >> d;
	vector<vector<int>> x;
	rep(i, n) {
		vector<int> tmp(d);
		rep(j, d) {
			cin >> tmp[j];
		}
		x.emplace_back(tmp);
	}

	rep(i, n-1) {
		for (int j = i + 1; j < n; j++) {
			int sum = 0;
			double ans;
			for (int k = 0; k < d; k++) {
				sum += pow(x[i][k] - x[j][k], 2);
			}
			ans = sqrt(sum);
			if (ceil(ans) == floor(ans)) {
				count++;
			}
		}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define N 30
#define M 200005
using namespace std;
int a[N], b[N];
char s[M], T[M];
int main() {
	ios::sync_with_stdio(0);
	cin >> s >> T;
	for(int i = 0; s[i] != '\0'; i++)
		a[s[i]-'a'] ++;
	for(int i = 0; T[i] != '\0'; i++)
		b[T[i]-'a'] ++;
	sort(a, a+26);
	sort(b, b+26);
	for(int i = 0; i < 26; i++) {
		if(a[i] != b[i]) {
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

int M, D;

int main()
{
    cin >> M >> D;
    int ans = 0;
    for (int i = 1; i <= M; i++)
    {
        for (int j = 1; j <= D; j++)
        {
            int d1 = j % 10, d10 = (j - j % 10) / 10;
            if (d1 < 2 || d10 < 2)
                continue;
            if (d1 * d10 == i)
                ans++;
        }
    }
    cout << ans << endl;
}

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

using namespace std;

int main() {
  int n, m;
  scanf("%d %d", &n, &m);

  vector<int> x(m);
  for (int i = 0; i < m; i++) {
    scanf("%d", &x[i]);
  }
  sort(x.begin(), x.end());

  if (n > m) {
    cout << 0 << endl;
    return 0;
  }

  vector<int> diff_per_x_element(m-1);
  for (int i = 0; i < m-1; i++) {
    diff_per_x_element[i] = abs(x[i] - x[i+1]);
  }
  sort(diff_per_x_element.begin(), diff_per_x_element.end());

  int min_movement = accumulate(diff_per_x_element.begin(), diff_per_x_element.begin()+m-n, 0);

  cout << min_movement << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <cmath>
#include<iomanip>
#include<algorithm>
#include<list>
using namespace std;


int main()
{
	int n, a[101] = {0}, count = 0;
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> a[i];
	}
	bool flag = true;
	while(flag){
		 flag = false;
		for (int i = n - 1; i > 0; i--){
			if (a[i] < a[i - 1]){
				int tmp = a[i];
				a[i] = a[i - 1];
				a[i - 1] = tmp;
				flag = true;
				count++;
			}
		}
	}
	for (int i = 0; i < n; i++){
		if (i < n - 1){
			cout << a[i] << " ";
		}
		else{
			cout << a[i] << endl;
		}
	}
	cout << count <<endl;
	
	return 0;
}

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

using namespace std;


int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    double sum = 0;
    for(int i = 0; i < n; i++) {
        sum += a[i];
    }
    double ave = sum / n;
    double diff = 10000;
    int ans;
    for(int i = 0; i < n; i++) {
        if(diff > abs(ave - a[i])) {
            ans = i;
            diff = abs(ave - a[i]);
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
int f(int N)
{
    if(N == 0) return 0;
    return N%10+f(N/10);
}
int main()
{
    int N, A, B;
    cin >> N >> A >> B;
    int cnt = 0;
    for(int i=0; i<=N; ++i)
        if(A <= f(i) && f(i) <= B)
            cnt += i;
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
 
const int mod=1e9+7;
 
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};
 
mint c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}
 
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
 
    return true;
}
 
map<ll, ll> primeFact(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}
 
void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
void printv(vll& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}
 
int main()
{
  //init(); // mint初期化
  cin.tie( 0 );
  ios::sync_with_stdio( false );
 
  int n;cin>>n;
  vi l(n);
  rep(i,n)cin>>l[i];
  rvisort(l);
  int max=l[0];
  int other=vtotal(l)-max;
  string ans="No";
  if(max<other)ans="Yes";
  
  cout(ans);
 
  return 0;
}

Measured memory_bytes: 125568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(int I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))


int main(){
	int N,Q;
	cin >> N >> Q;
	vector<int> a(N);
	FOR(i,0,N) cin >> a[i];
	a.push_back(MOD);
	SORT(a);
	FOR(i,0,Q){
		int l,r;
		cin >> l >> r;
		l = POSL(a,l);
		r = POSU(a,r)-1;
		cout << r-l+1 << endl;
	}
}


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

int main() {
 set<UL> S;
 UL Q; scanf("%u",&Q);
 rep(q,Q){
  UL c; scanf("%u",&c);
  if(c==0){
   UL x; scanf("%u",&x);
   S.insert(x);
   printf("%u\n",S.size());
  }
  if(c==1){
   UL x; scanf("%u",&x);
   printf("%u\n",S.count(x));
  }
  if(c==2){
   UL x; scanf("%u",&x);
   S.erase(x);
  }
  if(c==3){
   UL L,R; scanf("%u%u",&L,&R);
   for(auto itr=S.lower_bound(L); itr!=S.end(); itr++){
    if(*itr>R) break;
    printf("%u\n",*itr);
   }
  }fflush(stdout);
 }
 return 0;
}




Measured memory_bytes: 12508
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int D;
ll G;
vector<int> p;
vector<int> c;
vector<bool> sel;
int ans = 1000000;
void dfs(ll total, int num){
    if(sel.size()==D) {
        if(total>=G){
            ans = min(ans, num);
            return;
        }else{
            for (int i = D-1; i >= 0; i--)
            {
                if(!sel[i]){
                    if((G-total)/((i+1)*100)<p[i]){
                        num += max((G-total)/((i+1)*100), 1ll);
                        ans = min(num, ans);
                    }
                    break;
                }
            }
            return;
        }
    }
    for (int i = 0; i < 2; i++)
    {
        sel.push_back(i);
        int it = sel.size();
        ll tmp = (i)? total+(it)*100*p[it-1]+c[it-1]:total;
        dfs(tmp, num+p[it-1]*i);
        sel.pop_back();
    }
    
}
int main() {
    cin >> D >> G;
  	p.resize(D);
  	c.resize(D);
    for (int i = 0; i < D; i++)
    {
        cin >> p[i] >> c[i];
    }
    dfs(0, 0);
    cout << ans << endl;
}

Measured memory_bytes: 256
def maxHeapfy(a, h, i):
    l = 2 * i
    r = 2 * i + 1

    if l <= h and a[l] > a[i]:
        largest = l
    else:
        largest = i
    if r <= h and a[r] > a[largest]:
        largest = r

    if largest != i:
        a[i], a[largest] = a[largest], a[i]
        maxHeapfy(a, h, largest)


h = int(input())
a = [-1]
a.extend([int(v) for v in input().split()])

for i in range(h//2, 0, -1):
    maxHeapfy(a, h, i)

print(' ' + ' '.join([str(v) for v in a[1:]]))


Measured memory_bytes: 64560
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

using P = pair<ll, ll>;
#define fi first
#define se second

int main() {
    int n;
    cin >> n;
    P xl[n];
    for (auto &xli: xl) cin >> xli.fi >> xli.se;
    sort(xl, xl+n, [](P l, P r) {
        return l.fi + l.se < r.fi + r.se;
    });
    ll cur = -1e10;
    int ans = 0;
    for (auto &xli:xl) {
        if (xli.fi - xli.se < cur) continue;
        cur = xli.fi + xli.se;
        ans++;
    }
    cout << ans << '\n';
    return 0;
}

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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >
# define PQ priority_queue

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvs vector < vs >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

# define fr(a,b) for(int i = a; i < b; i++)
# define rep(i,a,b) for(int i = a; i < b; i++)

string vow = "aeiou";
int month[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.1415926535897932384626 ;
const ll mod = 1e9 + 7 ;

void solve(){

    int W, H, N ;

	cin >> W >> H >> N ;

	int x1 = 0, x2 = W, y1 = 0, y2 = H ;

	int x, y, a ;
	for(int i = 0 ; i < N ; i++)
	{
		cin >> x >> y >> a ;

		if(a == 1)
			x1 = max(x1, x) ;
		else if(a == 2)
			x2 = min(x2, x) ;
		else if(a == 3)
			y1 = max(y1, y) ;
		else if(a == 4)
			y2 = min(y2, y) ;
	}

	int newW = x2-x1 ;
	int newH = y2-y1 ;

	if(newW <= 0 || newH <= 0)
		cout << "0" ;
	else
		cout << newH * newW ;


  	return;

}

int main(){
	fast
	int tc=1;
	//cin >> t;
	while(tc--){
             solve();
    }

	R 0;
}


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


int main(){
	int n;
	int i,itemp;
	string s;
	
	s = "";
	cin >> n ;
	
	for(i=0;;i++){
		itemp = abs(n%(-2));
		n -= itemp;
		
		s = to_string(itemp) + s;
		if(n==0){
			cout << s << endl;
			return 0;
		}
		n /= -2;
	}
	return 1;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = signed;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

template<typename T,T MOD = 1000000007>
struct Mint{
  static constexpr T mod = MOD;
  T v;
  Mint():v(0){}
  Mint(signed v):v(v){}
  Mint(long long t){v=t%MOD;if(v<0) v+=MOD;}

  Mint pow(long long k){
    Mint res(1),tmp(v);
    while(k){
      if(k&1) res*=tmp;
      tmp*=tmp;
      k>>=1;
    }
    return res;
  }

  static Mint add_identity(){return Mint(0);}
  static Mint mul_identity(){return Mint(1);}

  Mint inv(){return pow(MOD-2);}

  Mint& operator+=(Mint a){v+=a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator-=(Mint a){v+=MOD-a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator*=(Mint a){v=1ULL*v*a.v%MOD;return *this;}
  Mint& operator/=(Mint a){return (*this)*=a.inv();}

  Mint operator+(Mint a) const{return Mint(v)+=a;};
  Mint operator-(Mint a) const{return Mint(v)-=a;};
  Mint operator*(Mint a) const{return Mint(v)*=a;};
  Mint operator/(Mint a) const{return Mint(v)/=a;};

  Mint operator-() const{return v?Mint(MOD-v):Mint(v);}

  bool operator==(const Mint a)const{return v==a.v;}
  bool operator!=(const Mint a)const{return v!=a.v;}
  bool operator <(const Mint a)const{return v <a.v;}
};
template<typename T,T MOD> constexpr T Mint<T, MOD>::mod;
template<typename T,T MOD>
ostream& operator<<(ostream &os,Mint<T, MOD> m){os<<m.v;return os;}


struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;

//INSERT ABOVE HERE
using M = Mint<Int, 998244353>;
const Int MAX = 1e6+10;
M sum[MAX]={};
M dp[MAX]={};

signed main(){
  Int n;
  cin>>n;
  vector<Int> as(n);
  for(Int i=0;i<n;i++) cin>>as[i];

  for(Int a:as){
    for(Int i=1;i*i<=a;i++){
      if(a%i) continue;
      sum[i]+=M(a/i);
      if((long long)i*i!=a) sum[a/i]+=M(i);
    }
  }

  M ans{0};
  for(Int i=MAX-1;i>0;i--){
    dp[i]=sum[i]*sum[i]*M(i);
    for(Int j=i+i;j<MAX;j+=i) dp[i]-=dp[j]*M(j/i);
    ans+=dp[i];
  }

  for(Int a:as) ans-=M(a);
  ans/=M(2);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 8832
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int N=in();
	vector<int> B(N-1);
	REP(i,N-1){
		B[i] = in();
	}
	int sum = 0;
	sum += B[0]+B[N-2];
	for(int i=0;i<N-2;i++){
		sum += min(B[i],B[i+1]);
	}
	
	out(sum);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, to) for (int i = 0; i < (to); ++i)
#define repf(i, from, to) for (int i = (from); i < (to); ++i)
#define unless(cond) if (!(cond))
using namespace std;
using ll = long long;
template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;

// 以下の物がある時間に置いてわかればその時間においてバスを出すべきかがわかる。
// それまでに乗車している人の人数
// それまでに乗車した人でもっとも早く乗車した時間

int main() {
  int n, c, k;
  V<int> t_list;

  cin >> n >> c >> k;
  t_list.resize(n);

  rep(i, n) {
    cin >> t_list[i];
  }
  sort(t_list.begin(), t_list.end());

  int passenger_num = 1;
  int wait_start_time = t_list[0];
  int bus_count = 0;

  repf(i,1, n) {
    if(passenger_num < c &&  t_list[i] <= wait_start_time + k) {
      passenger_num++;
    } else {
      bus_count++;

      wait_start_time = t_list[i];
      passenger_num = 1;
    }
  }
  if(passenger_num > 0) {
    bus_count++;
  }

  cout << bus_count << endl;
}

Measured memory_bytes: 3780
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;
ll mod=1e6+3;

int main(){
   int p,q,r;cin>>p>>q>>r;
   int x=max(max(p,q),r);
   cout<<p+q+r-x;
   
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int H, W;
  cin >> H >> W;
  int cost[10][10], dp[10];
  for(int i=0;i<10;i++)
    for(int j=0;j<10;j++)
      cin >> cost[i][j];

  for(int i=0;i<10;i++) {
    for(int j=0;j<10;j++) {
      for(int k=0;k<10;k++) {
        cost[j][k] = min(cost[j][k], cost[j][i] + cost[i][k]);
      }
    }
  }

  ll ans = 0;
  for(int i=0;i<H;i++) {
    for(int j=0;j<W;j++) {
      int ai;
      cin >> ai;
      if(ai != -1)
        ans += cost[ai][1];
    }
  }
  cout << ans << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007

using namespace std;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n;
	cin>>n;
	
	int a[n],b[n],c[n];
	for(int i=0;i<n;i++) {
		cin>>a[i]>>b[i]>>c[i];
	}
	
	int dp[n][3];
	
	dp[0][0] = a[0];
	dp[0][1] = b[0];
	dp[0][2] = c[0];
	
	for(int i=1;i<n;i++) {
		dp[i][0] = a[i] + max(dp[i-1][1],dp[i-1][2]);
		dp[i][1] = b[i] + max(dp[i-1][0],dp[i-1][2]);
		dp[i][2] = c[i] + max(dp[i-1][0],dp[i-1][1]);
	}
	
	int ans = max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
	
	cout<<ans;
	
	return 0;
}


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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cout << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9;
const LL LINF = INF * INF;

const int mod = 1e9 + 7;
 
inline int add(int x, int y)
{
	if (x + y >= mod)
		return x + y - mod;
	return x + y;
}
 
inline int mult(int x, int y)
{
	return x * (LL) y % mod;
}

inline int power(int x, int y)
{
	int r = 1;
	while(y)
	{
		if (y & 1)
			r = mult(r, x);
		x = mult(x, x);
		y >>= 1;
	}
	
	return r;
}

int n, h, w;
const int MAX = 300000 + 7;
PII a[MAX];
int f[MAX];
int inv[MAX];
int dp[MAX];

int C(int x, int y)
{
	int res = f[y];
	res = mult(res, inv[x]);
	res = mult(res, inv[y - x]);
	return res;
}

int get(PII x, PII y)
{
	if (x.Y > y.Y)
		return 0;
	if (x.X == y.X || x.Y == y.Y)
		return 1;
	int dx = y.X - x.X;
	int dy = y.Y - x.Y;
	return C(dx, dx + dy);
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	//freopen("In.txt", "w", stdout);

	cin >> h >> w >> n;
	FOR(i, 0, n)
	{
		cin >> a[i].X >> a[i].Y;
		--a[i].X;
		--a[i].Y;
	}
	
	f[0] = 1;
	FOR(i, 1, MAX)
		f[i] = mult(i, f[i - 1]);
	
	FOR(i, 0, MAX)
		inv[i] = power(f[i], mod - 2);
	
	a[n] = MP(h - 1, w - 1);
	sort(a, a + n);
	
	FOR(i, 0, n + 1)
	{
		dp[i] = get({0, 0}, a[i]);
		FOR(j, 0, i)
			dp[i] = add(dp[i], mod - mult(dp[j], get(a[j], a[i])));
	}

	cout << dp[n] << endl;
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}


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

int main() {
	int a, b;
	cin>>a>>b;
	for(int i=1;i<=2000;i++) {
		if(floor(i * 0.08) == a && floor(i*0.1) == b) {
			cout<<i<<"\n";
			return 0;
		}
	}
	cout<<"-1\n";
	return 0;
}

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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();

    ll n;
    cin>> n;

    ll a[n];



    for(ll i=0; i<n; i++)
        cin>> a[i];

    cout <<  *max_element(a, a+ n)- *min_element(a,a+n);
    nl;
    return 0;
}



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

namespace abc065a
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            if (input[1] >= input[2])
            {
                Console.WriteLine("delicious");
            }
            else if (input[0] + input[1] < input[2])
            {
                Console.WriteLine("dangerous");
            }
            else
            {
                Console.WriteLine("safe");
            }
        }
    }
}

Measured memory_bytes: 13268
#include<iostream>
using namespace std;
int main(){
	int n,m,sum=0,temp;
	cin>>n>>m;
	
	for(int i=0;i<m;i++){
		cin>>temp;
		sum+=temp;
	}
	if(sum<=n){
		cout<<n-sum;
	}
	else{
		cout<<-1;
	}
}

Measured memory_bytes: 3580