akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;

const double pie = acos(-1.0);

// 最大公約数
ll gcd(ll a, ll b)
{
   if (a%b == 0) {
       return(b);
   } else {
       return(gcd(b, a%b));
   }
}

// 最小公倍数
ll lcm(ll a, ll b){
   return a / gcd(a, b) * b;
}

//素数判定
bool is_prime(const unsigned n){
    switch(n){
        case 0: // fall-through
        case 1: return false;
        case 2: // fall-through
        case 3: return true;
    } // n > 3 が保証された
    if(n % 2 == 0 || n % 3 == 0) return false;
    for(unsigned i = 5; i * i <= n; i += 6) {
        if(n % i     == 0) return false; // (6の倍数)-1
        if(n % (i+2) == 0) return false; // (6の倍数)+1
    }
    return true;
}

const ll MOD = 1e9 + 7;

void solve() {
    ll n, m; cin >> n >> m;
    ll a = max(n, m), b = min(n, m);
    if(a-b > 1){
        cout << 0 << endl;
        return;
    }
    ll ans = 1;
    if(a == b){
        Rep(i, 2, a){
            ans *= i;
            ans %= MOD;
        }
        ans = (ans * ans * 2) % MOD;
    }else{
        ll o = 1;
        Rep(i, 2, b){
            o *= i;
            o %= MOD;
        }
        ans = (o * ((o*a)%MOD)) % MOD;
    }
    cout << ans << endl;
}

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

    solve();
    return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
ans=[10**10]*n
edge=[[]for _ in range(n)]
for _ in range(m):
  l,r,d=map(int,input().split())
  l-=1;r-=1
  edge[l].append((r,d))
  edge[r].append((l,-d))
for i in range(n):
  if ans[i]==10**10:
    ans[i]=0
    Q=[i]
    while Q:
      P=[]
      for j in Q:
        for k,d in edge[j]:
          if ans[k]==10**10:
            ans[k]=ans[j]+d
            P.append(k)
          elif ans[j]+d!=ans[k]:
            print("No");exit()
      Q=P
print("Yes")

Measured memory_bytes: 82976
<?php
  list($n) = explode(" ", trim(fgets(STDIN)));
  list($m) = explode(" ", trim(fgets(STDIN)));

  if($n[0]==$m[2] && $n[1]==$m[1] && $n[2]==$m[0]){
    echo "YES";
  }else{
    echo "NO";
  }

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

typedef long long lint;
typedef pair<int, int> P;
#define REP(i, x, n) for(int i = x ; i < n ; ++i)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; --i)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort(ALL(x))

const int IINF = 1e9 + 10;
const lint LLINF = (lint)1e18 + 10;
const lint MOD = (lint)1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

int main(){
    int h, w;
    cin >> h >> w;
    char a[110][110];
    vector<int> cnt(26);
    rep(i, h){
        rep(j, w){
            cin >> a[i][j];
            ++cnt[a[i][j] - 'a'];
        }
    }
    bool flag = true;
    vector<int> v(3, 0);
    if(h % 2 == 1 && w % 2 == 1){
        v[0] = 1;
        v[1] = (h / 2) + (w / 2);
        v[2] = (h / 2) * (w / 2);
    }else if(h % 2 == 1){
        v[0] = 0;
        v[1] = w / 2;
        v[2] = (h / 2) * (w / 2);
    }else if(w % 2 == 1){
        v[0] = 0;
        v[1] = h / 2;
        v[2] = (h / 2) * (w / 2);
    }else{
        v[0] = 0;
        v[1] = 0;
        v[2] = (h / 2) * (w / 2);
    }
    rep(i, 26){
        if(cnt[i] == 0){
            continue;
        }
        if(cnt[i] % 2 == 1){
            --v[0];
            --cnt[i];
        }
        if(cnt[i] % 4 == 2){
            --v[1];
            cnt[i] -= 2;
        }
        rep(j, cnt[i] / 4){
            if(v[2] > 0){
                --v[2];
            }else{
                v[1] -= 2;
            }
        }
    }
    rep(i, 3){
        if(v[i] != 0){
            flag = false;
            break;
        }
    }
    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

cnt = 0

for i in range(N):
    flag = 0
    min_j = i
    for j in range(i, N):
        if A[j] < A[min_j]:
            min_j = j
            flag = 1

    if flag:
        A[i], A[min_j] = A[min_j], A[i]
        cnt += 1

print(*A)
print(cnt)



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

#define all(v) v.begin(), v.end()

typedef long long ll;
const int N = 4e4;

int gcd(int a, int b)
{
    while(b)
    {
        a %= b;
        swap(a, b);
    }
    return a;
}

int main()
{
    //freopen("input.txt", "r", stdin);


    int prime[] = {2, 3};
    vector<int> ans;
    for (int i = 0; i < 2; ++i)
    {
        for (int x = 2; x <= 30000; ++x)
            if (x % prime[i] == 0)
                ans.push_back(x);
    }
    sort(all(ans));
    ans.erase(unique(all(ans)), ans.end());

    /*
    for (int n = 3; n <= 20000; ++n)
    {
        ll sum = 0;
        bool used[N];
        for (int i = 0; i < N; ++i)
            used[i] = false;
        for (int i = 0; i < n - 2; ++i)
        {
            sum += ans[i];
            used[ans[i]] = true;
            //cout << ans[i] << ' ';
        }

        //cout << r << ' ';
        bool f = false;
        for (int x = 4; x <= 30000; ++x)
        {
            for (int y = 4; y <= 30000; ++y)
            {
                if (y == x || used[x] || used[y]) continue;
                if (((sum + x + y) % 6 == 0) && gcd(sum, x) > 1 && gcd(sum, y))
                {
                    f = true;
                    break;
                    //cout << x << '\n';
                }
            }
        }
        if (!f)
        {
            cout << sum % 6 << ' ' << sum << ' ' << n << '\n';
            break;
        }
    }
    */

    //*
    int n;
    scanf("%d", &n);

    if (n == 3)
    {
        printf("2 5 63");
        return 0;
    }

    ll sum = 0;

    bool used[N];
    for (int i = 0; i < N; ++i)
        used[i] = false;
    for (int i = 0; i < n - 2; ++i)
    {
        sum += ans[i];
        used[ans[i]] = true;
        printf("%d ", ans[i]);
    }

    int r = (6 - (sum % 6)) % 6;
    //cout << '\n' << sum << ' ' << r << '\n';
    //cout << ans[n - 2] << '\n';
    vector<int> v;
    for (int i = 2; i <= 30000; ++i)
        if (!used[i])
            v.push_back(i);

    for (int x : v)
    {
        for (int y : v)
        {
            if (y == x) continue;
            if (gcd(sum + y, x) > 1 && gcd(sum + x, y) > 1 && ((sum + x + y) % 6 == 0))
            {
                printf("%d %d", x, y);
                return 0;
            }
        }
    }
    //*/
}


Measured memory_bytes: 640
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from heapq import heappop, heappush, heapify, heappushpop
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
A = LIST()
B = list(accumulate(A))

l, c, r = 0, 1, 2
P = sum(A[:l])
Q = sum(A[l:c])
R = sum(A[c:r])
S = sum(A[r:])

ans = INF

for c in range(1, N-1):
	while True:
		if abs(P-Q) < abs((P+A[l])-(Q-A[l])):
			break
		if l == c-1:
			break
		P += A[l]
		Q -= A[l]
		l += 1

	while True:
		if abs(R-S) < abs((R+A[r])-(S-A[r])):
			break
		if r == N-1:
			break
		R += A[r]
		S -= A[r]
		r += 1

	ans = min(max(P, Q, R, S)-min(P, Q, R, S), ans)

	Q += A[c]
	R -= A[c]

print(ans)


Measured memory_bytes: 24956
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 15;
const int MAXS = 1 << 8;
typedef long long ll;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
vector <pair <int, int>> ans, tmp;
int n, bit[MAXN]; bool flg[MAXS]; char s[MAXS];
void augment(vector <pair <int, int>> &res, int x) {
	if (res.size() == 0) {
		res.emplace_back(x, 0);
		res.emplace_back(x, 1);
		return;
	}
	vector <pair <int, int>> tmp;
	tmp.emplace_back(x, 0);
	for (auto x : res) tmp.push_back(x);
	tmp.emplace_back(x, 0);
	reverse(tmp.begin(), tmp.end());
	tmp.emplace_back(x, 1);
	for (auto x : res) tmp.push_back(x);
	tmp.emplace_back(x, 1);
	res = tmp;
}
void work(int mask) {
	tmp.clear(); int cur = 0;
	for (int i = n; i >= 1; i--)
		if (mask & bit[i]) augment(tmp, i);
	for (auto x : tmp) {
		if (x.second == 0) {
			if (cur >= x.first) while (cur >= x.first) ans.emplace_back(--cur, 0);
			else while (cur < x.first) ans.emplace_back(++cur, 0);
		} else {
			if (cur >= x.first) {
				while (cur >= x.first + 1) ans.emplace_back(--cur, 0);
				ans.emplace_back(cur, 1);
				ans.emplace_back(--cur, 1);
				ans.emplace_back(cur, 0);
			} else {
				while (cur < x.first - 1) ans.emplace_back(++cur, 0);
				ans.emplace_back(cur, 1);
				ans.emplace_back(++cur, 1);
				ans.emplace_back(cur, 0);
			}
		}
	}
	while (cur > 0) ans.emplace_back(--cur, 0);
}
int main() {
	read(n), scanf("\n%s", s);
	for (int i = 1; i <= n; i++)
		bit[i] = 1 << (i - 1);
	int goal = 1 << n;
	for (int i = 0; i < goal; i++)
	for (int j = 0; j < i; j++)
		if ((i & j) == j && s[j] == '0') flg[i] = true;
	for (int i = 0; i < goal; i++)
		if (s[i] == '1' && flg[i]) {
			puts("Impossible");
			return 0;
		}
	puts("Possible");
	for (int i = 0; i < goal; i++)
		if (s[i] == '0' && !flg[i]) work(i);
	cout << ans.size() << endl;
	printf("%d %d\n", 0, 0);
	for (auto x : ans)
		printf("%d %d\n", x.first, x.second);
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int n;
int A[1001],B[1001];

int getIdx(){
  int idx = n;
  for(int i=0;i<n;i++)if(A[i]!=B[i] && A[idx]>A[i]) idx = i;  
  return idx;
}

int Sort(int pos){
  int sum=0,cnt=0;
  while(A[pos]!=B[pos]){
    cnt++;
    int idx=0;
    while(B[pos]!=A[idx]) idx++;
    sum += A[idx];
    swap(A[pos],A[idx]);
    pos = idx;
  }
  return min(sum+A[pos]*cnt,sum+A[pos]*2+(cnt+2)*B[0]);
}

int main(){
  cin>>n;
  for(int i=0;i<n;i++)cin>>A[i],B[i] = A[i];
  A[n] = B[n] = 1e9;
  sort(B,B+n);

  int ans = 0;  
  for(int i=0;i<n;i++)ans+=Sort(getIdx());
  cout<<ans<<endl;
  
  return 0;
}

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

int main()
{
	int N, M;
  	long long sum = 0;
	cin >> N >> M;

	priority_queue<int> qu;

	int sale;
	for (int i = 0; i < N; i++)
	{
		cin >> sale;
		qu.push(sale);
	}
	while(M > 0)
	{
		sale = qu.top();
		qu.pop();
		sale = sale >> 1;
		M--;
		qu.push(sale);
	}
	while (!qu.empty())
	{
		sum += qu.top();
		qu.pop();
	}
	cout << sum << endl;

	return 0;
}



Measured memory_bytes: 892
import bisect
w = [48, 51, 54, 57, 60, 64, 69, 75, 81, 91]
c = ["light fly", "fly", "bantam", "feather", "light", "light welter", "welter", "light middle", "middle", "light heavy", "heavy"]
while 1:
    try:print(c[bisect.bisect_left(w,float(input()))])
    except:break


Measured memory_bytes: 5608
#include <iostream>
#include <string>
#include <map>

int main () {
    int n, m;
    std::cin >> n;
    std::string a[n];
    std::map<std::string, int> sc;
    
    for(int i = 0; i < n; ++i){
        std::cin >> a[i];
        sc.insert(std::make_pair(a[i], 0)); 
        sc[a[i]]++;  
    }
    std::cin >> m;
    std::string b[m];
    for(int i = 0; i < m; ++i){
        std::cin >> b[i];
        sc[b[i]] -= 1;
    }
    int ans = 0;
    for(int i = 0; i < n; ++i){
        if(ans < sc[a[i]]) ans = sc[a[i]];
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 3624
import math
N,K = map(int,input().split())

pro_list = []
for i in range(1,N+1):
	if i<K:
		try_number = math.ceil(math.log2(K/i))
		pro_list.append(1/ (N * 2**try_number) )
	else:
		pro_list.append(1/ N )
print(sum(pro_list))

Measured memory_bytes: 6296
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
#define ll  long long 
#define mod 1000000007
  vector<ll>to[1000005];
int main(){
  int a,b,c=0,d=0;cin>>a;
  rep(i,a){
    cin>>b;
    d+=max(b-c,0);
    c=b;
  }
  cout<<d;
}


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

using namespace std;

#define all(x) begin(x), end(x)

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;

// 0 indexed template
template <typename T>
struct BIT {
    int n;
    vector<T> f_tree;
    BIT(int n): n(n) {
        f_tree.assign(n + 1, 0);
    }

    void update(int x, T v) {
        ++x;
        for (; x <= n; x += (x & -x)) {
            f_tree[x] = max(f_tree[x], v);
        }
    }

    T query(int x) const {
        ++x;
        T res = 0;
        for (; x; x -= (x & -x)) {
            res = max(res, f_tree[x]);
        }

        return res;
    }
};

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

    int n;
    cin >> n;
    BIT<ll> dp(n);

    vi h(n);
    vector<ll> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> h[i];
        --h[i];
    }
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    for (int i = 0; i < n; ++i) {
        ll prev_val = dp.query(h[i]);
        dp.update(h[i], prev_val + a[i]);
    }

    cout << dp.query(n - 1) << '\n';
    
    return 0;
}


Measured memory_bytes: 4224
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#define show(...) cerr << #__VA_ARGS__ << " = ",debug(__VA_ARGS__);
using namespace std;
using ll = long long;
using pii = pair<int,int>;
template<typename T, typename S>
ostream &operator<<(ostream &os,pair<T,S>a){
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template<typename T>
ostream &operator<<(ostream &os, vector<T> v){
    for(auto x:v)os << x << ' ';
    return os;
}
void debug(){cerr << '\n';}
template<typename H, typename... T>
void debug(H a, T... b){
    cerr << a;
    if(sizeof...(b))cerr << ", ";
    debug(b...);
}

//char inv(char c){
//    return c^32;
//}
//string inv(string &a){
//    auto res = a;
//    for(auto &x:res) x^=32;
//    reverse(res.begin(),res.end());
//    return res;
//}
//string product(const string &a,const string &b){
//    auto res = a;
//    for(auto x:b){
//        if(res.size() and inv(x) == res.back())res.erase(res.begin()+res.size()-1);
//        else res.push_back(x);
//    }
//    return res;
//    
//}

vector<int> id(const int n){
    vector<int> res(n);
    rep(i,n)res[i] = i;
    return res;
}
vector<int> inv(const vector<int> &a){
    vector<int> res(a.size());
    rep(i,a.size()){
        res[a[i]] = i;
    }
    return res;
}
vector<int> product(const vector<int> &a, const vector<int> &b){
    vector<int> res(a.size());
    rep(i,a.size()){
        res[i] = a[b[i]];
    }
    return res;
}
vector<int> power(const vector<int> &a, ll p){
    if(p == 0)return id((int)a.size());
    auto res = a;
    auto temp = a;
    p--;
    for(int i = 0; i < 28; i++){
        if(p >> i & 1){
            res = product(res, temp);
        }
        temp = product(temp, temp);
    }
    return res;
}
int main(){
    int n, k;
    scanf("%d%d", &n, &k);
    vector<int>p(n),q(n);
    rep(i,n)scanf("%d",&p[i]),p[i]--;
    rep(i,n)scanf("%d",&q[i]),q[i]--;
    auto g = product(q,product(inv(p),product(inv(q),p)));
    g = power(g,(k-1)/6);
    auto a = product(g,product(p,inv(g)));
    auto b = product(g,product(q,inv(g)));
    int now = 1 + (k-1)/6*6;
    while(now != k){
        auto c = product(b,inv(a));
        a = b;
        b = c;
        now++;
    }
    rep(i,n)printf("%d ",a[i]+1);
}

Measured memory_bytes: 3544
#include <bits/stdc++.h>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define moca(a, s, b) a=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
template<class T>bool chmax(T &a, const T &b) {if(a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if(b<a) {a=b; return 1;} return 0;}
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;


//for(i=0; i<N; i++) cin >> a[i];

ll D;
ll c[26];
ll s[366][26];

ll calcScore(vector<ll> sche) {
  ll score=0;
  ll i, j, k;
  ll p[26];
  for(i=0; i<26; i++) p[i]=-1;
  
  for(ll d=0; d<sche.size(); d++) {
    score+=s[d][sche[d]];
    
    p[sche[d]]=d;
    for(i=0; i<26; i++) score-=c[i]*(d-p[i]);
    
  }
  
  return score;
}

int main(void) {
  ll i, j, k;
  
  cin >> D;
  for(i=0; i<26; i++) cin >> c[i];
  for(i=0; i<D; i++) {
    for(j=0; j<26; j++) {
      cin >> s[i][j];
    }
  }
  
  ll width=10;
  vector<vector<ll>> tops; tops.push_back({});
  
  for(ll d=0; d<D; d++) {
    
    priority_queue<pair<ll, vector<ll>>> candidates;
    for(k=0; k<tops.size(); k++) {
      for(i=0; i<26; i++) {
        tops[k].push_back(i);
        candidates.push({calcScore(tops[k]), tops[k]});
        tops[k].pop_back();
      }
    }
    
    tops.clear();
    for(i=0; i<min(width, (ll)candidates.size()); i++) {
      tops.push_back(candidates.top().sc);
      candidates.pop();
    }
    
    
  }
  
  for(i=0; i<D; i++) pt(tops[0][i]+1);
  
}



Measured memory_bytes: 4784
n = int(input())
a = []
from collections import Counter
for _ in range(n):
    a.append(int(input()))
    
a = a + [0]
    
ans = 0
for i in range(n):
    ans += a[i] // 2
    a[i] %= 2
    if a[i] == 1 and a[i+1] >= 1:
        ans += 1
        a[i] = 0
        a[i+1] -= 1
        
print(ans)

Measured memory_bytes: 51416
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;

void main() {
    string input = readln.chomp;
    switch(input) {
        case "1 0 0": case "0 1 0": case "0 0 0": {
            writeln("Close");
        } break;
        default: {
            writeln("Open");
        } break;
    }
}

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    set<int> s;
    int current = 0;
    int ans = 0;
    while(true) {
        if(s.count(current) == 1) {
            ans = -1;
            break;
        }
        s.insert(current);
        bool finished=false;
        for(int i=1; i<=a; ++i) {
            if((current+i)%60 == c) {
                ans += i;
                finished = true;
                break;
            }
        }
        if(finished) {
            break;
        } else {
            current = (current + a + b)%60;
            ans += a + b;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3124
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
#define pb push_back
#define fi first
#define se second
const ll mod = 1e9+7;
const int N = 1e7+6;
ll a[N];
void solve(){
	for(int i=1;i<N;i++){
		for(int j=i;j<N;j+=i){
			a[j]++;
		}
	}
	ll ans = 0;
	int n; 
	cin>>n; 
	for(ll i=1;i<=n;i++){
		ans+=a[i]*i;
	}
	cout<<ans<<endl;
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t=1; 
//	cin>>t; 
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 81744
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	string s;
	while(cin>>s){
		int ans[2]={0};
		if(s.size()>2){
			char bef[2]={s[0],s[1]};
			for(int i=2;i<s.size();i++){
				if(s[i]=='I'&&bef[1]=='O'){
					if(bef[0]=='J')ans[0]++;
					if(bef[0]=='I')ans[1]++;
				}
				bef[0]=bef[1],bef[1]=s[i];
			}
		}
		cout<<ans[0]<<"\n"<<ans[1]<<endl;
	}
	return 0;
}

Measured memory_bytes: 3048
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 1000000000
#define InfLL 1000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=(n-1);(i)>=(0);(i)--)
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

ll gcd_ll(ll a, ll b)
{
	if (a == 0)
		return 0;
	if (b == 0)
		return 0;
	ll x;
	while (1)
	{
		x = a % b;
		if (x == 0)
			return b;
		else
		{
			a = b;
			b = x;
		}
	}
}

int main() {
	vl pow2(1000000, 1LL);
	rep(i, 1000000) {
		if (i == 0)
			continue;
		pow2[i] = pow2[i - 1] * 2LL;
		pow2[i] %= mod;
	}
	ll N;
	cin >> N;
	map<pll, ll> ABcount;
	set<pll> AB;
	ll zz = 0, z_ = 0, _z = 0;
	rep(i, N) {
		ll A, B;
		cin >> A >> B;
		if (A == 0 && B == 0)
			zz++;
		else if (A == 0)
			z_++;
		else if (B == 0)
			_z++;
		else {
			ll ABgcd = gcd_ll(abs(A), abs(B));
			if (A < 0) {
				A *= -1;
				B *= -1;
			}
			ABcount[make_pair((A / ABgcd), (B / ABgcd))]++;
		}
	}
	ll ans = 1;
	auto it = ABcount.begin();
	while (it != ABcount.end()) {
		pll ABtmp = it->first;
		if (AB.find(ABtmp) == AB.end()) {
			AB.insert(ABtmp);
			pll BAtmp = make_pair(ABtmp.second, -ABtmp.first);
			if (BAtmp.first < 0) {
				BAtmp.first *= -1;
				BAtmp.second *= -1;
			}
			AB.insert(BAtmp);
			ll anstmp = 0;
			anstmp += pow2[ABcount[ABtmp]];
			anstmp += pow2[ABcount[BAtmp]];
			anstmp--;
			anstmp += mod;
			anstmp %= mod;
			ans *= anstmp;
			ans %= mod;
		}
		it++;
	}
	ll anstmp = 0;
	anstmp += pow2[z_];
	anstmp += pow2[_z];
	anstmp -= 1;
	ans *= anstmp;
	ans %= mod;
	ans--;
	ans += zz;
	ans += mod;
	ans %= mod;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 60892
#include<cstdio>	
#include<algorithm>
#include<cstring>
using namespace std;
char s[100];
int ans;
inline bool mzls(int x)
{
	sprintf(s,"%d",x);
	int len=strlen(s);
	for(int i=0;i<len;i++)
		if(s[i]!=s[len-i-1])
			return 0;
	return 1;
}
int n,m;
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=n;i<=m;i++)
		ans+=mzls(i);
	printf("%d",ans);
}

Measured memory_bytes: 128
#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;
using PLL = pair<LL, LL>;
using VI = vector<int>;
const int INF = 1e9;
const int MXN = 0;
const int MXV = 0;
const LL MOD = 998244353;
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define FOR(i, L, R) for (int i = L; i < (int)R; ++i)
#define FORD(i, L, R) for (int i = L; i > (int)R; --i)
#define IOS                                                                    \
    cin.tie(nullptr);                                                          \
    cout.tie(nullptr);                                                         \
    ios_base::sync_with_stdio(false);

int main()
{
    IOS;
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5])
    {
        cout << "Yes\n";
    }
    else
    {
        cout << "No\n";
    }
}


Measured memory_bytes: 256
n = int(input())
arr = []


for i in range(n):
  s,t = input().split()
  t = int(t)
  arr.append([s,t])
  
x = input()

flag = False
count = 0
for i in range(n):
  if flag:
    count += arr[i][1]
    
  if arr[i][0] == x:
    flag = True
    
print(count)

Measured memory_bytes: 3064
from fractions import gcd
def LCM(x,y):
  return x*y//gcd(x,y)
A, B, C, D = map(int, input().split())

S = B - A + 1

canC = B // C - (A - 1) // C
canD = B // D - (A - 1) // D
canCD = B // LCM(C, D) - (A - 1) // LCM(C, D)

print(S - (canC + canD) + canCD)

Measured memory_bytes: 5460
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;


import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;


public class Main {
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final long N = sc.nextLong(); 
			
			final int PRIMES = (int)(Math.sqrt(N)) + 1;
			
			boolean[] is_prime = new boolean[PRIMES + 1];
			Arrays.fill(is_prime, true);
			is_prime[0] = is_prime[1] = false;
			
			long X = N, answer = 0;
			for(int i = 2; i <= PRIMES; i++) {
				if(!is_prime[i]) { continue; }
				
				long count = 0;
				while(X % i == 0) {
					X /= i;
					count++;
				}
				
				for(int j = 1; j <= count; j++) {
					count -= j;
					answer++;
				}
				
				//System.out.println(i + " " + count + " " + answer);
				
				for(int j = 2 * i; j <= PRIMES; j += i) {
					is_prime[j] = false;
				}
			}
			
			if(X > PRIMES) {
				answer++;
			}
			
			System.out.println(answer);
			
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
		

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}


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

typedef long long ll;
//loop
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//STL
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

//const
#define MOD 1000000007 //10^9+7:合同式の法

//acronym
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

void Main() {
    ll a,b,c,d;
    cin >> a >> b>>c>>d;
    ll area1 = a*b;
    ll area2 = c*d;

    if (area1 >= area2) {
        cout << area1 << endl;
    } else {
        cout << area2 << endl;
    }
}

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


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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

typedef pair<int,int> pi;

const int N=200000;
const ll INF=1234567890123456LL;

struct edge{int to,cost;};
vector<edge> G[N];
ll val[N];

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

    vector<int> r(n), c(n), a(n);
    rep(i,n)
    {
        scanf(" %d %d %d", &r[i], &c[i], &a[i]);
        --r[i];
        --c[i];
        G[r[i]].pb(edge{R+c[i],a[i]});
        G[R+c[i]].pb(edge{r[i],a[i]});
    }

    // 隣り合う辺同士で値を決めていく
    fill(val,val+N,INF);
    rep(i,R+C)
    {
        if(val[i]!=INF) continue;

        val[i]=0;
        queue<int> que;
        que.push(i);
        while(!que.empty())
        {
            int v=que.front();
            que.pop();
            rep(j,G[v].size())
            {
                edge e=G[v][j];
                if(val[e.to]==INF)
                {
                    val[e.to] = (ll)e.cost-val[v];
                    que.push(e.to);
                }
            }

        }
    }

    bool valid=true;

    // 正当性のチェック
    rep(i,n)
    {
        if(val[r[i]]+val[R+c[i]] != (ll)a[i])
        {
            valid=false;
            break;
        }
    }

    if(valid)
    {
        vector<bool> vis(R+C, false);
        rep(i,R+C)
        {
            if(vis[i]) continue;

            queue<int> que;
            vis[i]=true;
            que.push(i);

            ll minr=INF, minc=INF;
            if(i<R) minr=min(minr,val[i]);
            else minc=min(minc,val[i]);

            while(!que.empty())
            {
                int v=que.front();
                que.pop();
                rep(j,G[v].size())
                {
                    edge e=G[v][j];
                    if(!vis[e.to])
                    {
                        vis[e.to]=true;
                        que.push(e.to);

                        if(e.to<R) minr=min(minr,val[e.to]);
                        else minc=min(minc,val[e.to]);
                    }
                }
            }

            if(minr+minc<0)
            {
                valid=false;
                break;
            }
        }
    }

    cout << (valid?"Yes":"No") << endl;
    return 0;
}


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

using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int x;
  cin >> x;
  if (x < 1200) {
    cout << "ABC\n";
  } else {
    cout << "ARC\n";
  }
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main()
{
	string S;
	int s[100010];
	cin >> S;
	int cnt0 = 0, cnt1 = 0;
	for (int i = 0; i < S.size(); i++)
	{
		s[i] = S[i] - '0';
		if (s[i] == 0) cnt0++;
		if (s[i] == 1) cnt1++;

	}
	//数値変換完了

	int ans = min(cnt0, cnt1);
	cout << ans * 2 << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define pb           push_back
#define pii          pair<int,int>
#define vi           vector<int>
#define vpii         vector<pair<int,int>>
#define gph          map<int, vector<int>>
#define mp           make_pair
#define FOR(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD0(i, n) for (int i = (int)n; i >= 0; i--)
#define FORD1(i, n) for (int i = (int)n; i >= 1; i--)
#define FORS(i, n) for(; i < (int)(n); i++)
#define debug(X) { cout << #X << " = " << (X) << endl; }
#define printArr(A,n) { cout << #A << " = "; FOR(i,n) cout << A[i] << ' '; cout << endl; }
using namespace std;
#define int long long int

bool comp(pii x, pii y){
    return x.first + x.second > y.first + y.second;
}

signed main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    
    int n,k;cin >> n >> k;
    k--;
    if(n - 1 < 2*k){
        cout << -1;
        return 0;
    }
    vector<pii> temp;
    int one = 2*n;
    int other = (n+1)/2;
    while(other != 0){
       temp.pb(mp(one, other)); 
       one--;
       other--;
    }
    other = n;
    while(one != n){
        temp.pb(mp(one, other));
        one--, other--;
    }
    sort(temp.begin(), temp.end(), comp);
    FOR(i, n){
        cout << temp[i].first + k << " " << temp[i].second + k << " " << 3*n -i + k << endl;  
    }


}




Measured memory_bytes: 3952
#include<stdio.h>
#include<stdlib.h>

int main(){
  int strlen;
  char *str;
  int i;
  
  scanf("%d", &strlen);
  
  if(strlen % 2 == 1){
    printf("No");
    return 0;
  }else if((str = (char *)malloc(strlen * sizeof(char))) == NULL){
    printf("No");
    return 0;
  }
  
  scanf("%s", str);
  for(i=0; i < strlen/2; i++){
    if(str[i] != str[i+(strlen/2)]){
      printf("No");
      return 0;
    }
  }
  
  printf("Yes");
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int a[100001], b[100001];
int p[200001];
vector<int> v[200001];
set<int> r, c;
int root(int a){
    return p[a] == a?a:(p[a]=root(p[a]));
}
void merge(int a, int b){
    a = root(a), b = root(b);
    if(a != b) p[a] = b;
}
int main(){
    int n;
    scanf("%d", &n);
    for(int i=1;i<=200000;i++) p[i] = i;
    for(int i=1;i<=n;i++){
        scanf("%d%d", &a[i], &b[i]);
        merge(a[i], 100000+b[i]);
    }
    for(int i=1;i<=n;i++){
        v[root(a[i])].push_back(i);
    }
    LL ans = 0;
    for(int i=1;i<=200000;i++){
        if(root(i) == i){
            r.clear(), c.clear();
            for(int j=0;j<v[i].size();j++){
                int k = v[i][j];
                int y = a[k], x = b[k];
                r.insert(y);
                c.insert(x);
            }
            ans += r.size()*1ll*c.size() - v[i].size();
        }
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 11512
K = int(input())

import math

def gcd(a, b, c):
    return math.gcd(math.gcd(a, b), c)

ans = 0
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            ans = ans + gcd(a,b,c)

print(ans)


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


unsigned long long int lcm(unsigned long long int a, unsigned long long int b){
    unsigned long long x = a * b;
    unsigned long long int tmp,r;
    if(a<b){
        tmp = a;
        a = b;
        b = tmp;
    }
    r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return x/b;
}

int main(){
    unsigned long long int A,B,C,D;
    cin >> A >> B >> C >> D;

    unsigned long long int count = 0;

    unsigned long long int divC = (B / C) - (A / C);
    if(A%C==0) divC++;

    unsigned long long int divD = (B / D) - (A / D);
    if(A%D==0) divD++;


    unsigned long long int CD = lcm(C,D);
    unsigned long long int divCD = (B / CD) - (A / CD);
    if(A%CD==0) divCD++;

    unsigned long long int CorD = divC + divD - divCD;
    count = (B-A+1) - CorD;
    cout << count << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

int main(){
  int R;
  cin >> R;
  if(R<1200) cout << "ABC" << endl;
  else if(1200<=R && R<2800) cout << "ARC" << endl;
  else cout << "AGC" << endl;
  return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>  // Including tree_order_statistics_node_update

using namespace __gnu_pbds;
using namespace std;

#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define tr(c, i) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define present(c, x) ((c).find(x) != (c).end())
#define cpresent(c, x) (find(all(c), x) != (c).end())
#define minei(x) min_element(x.begin(), x.end()) - (x).begin()
#define maxei(x) max_element(x.begin(), x.end()) - (x).begin()
#define LSOne(S) (S & (-S))

#define uns(v) sort((v).begin(), (v).end()), v.erase(unique(v.begin(), v.end()), v.end())
#define acusum(x) accumulate(x.begin(), x.end(), 0)
#define acumul(x) accumulate(x.begin(), x.end(), 1, multiplies<int>());
#define bits(x) __builtin_popcount(x)
#define oo INT_MAX
#define inf 1000000000
#define MAXN 200007
#define MOD 1000000007

const double pi = acos(-1.0);
const double eps = 1e-11;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
ll dp[MAXN][2];
int main() {
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<ll> v(n + 1);
    for (int i = 1; i <= n; i++) cin >> v[i];
    dp[2][0] = v[1];
    dp[2][1] = v[2];
    for (int i = 3; i <= n; i++) {
        dp[i][1] = v[i] + max(dp[i - 2][0], dp[i - 2][1]);
        dp[i][0] = i % 2 == 0 ? v[i - 1] + dp[i - 2][0] : max(dp[i - 1][0], dp[i - 1][1]);
    }
    cout << max(dp[n][0], dp[n][1]) << endl;

    return 0;
}


Measured memory_bytes: 7916
/*
    Author  :   jignesh1604
    College :   SVNIT
    "Do what you can , with what you have , where you are"
    1 contest + 2 upsolve + 1 new topic + 5 problems = 1900+ of cf in 3 months
*/

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

void solve() {
    long long int n;
    cin >> n;
    if(n%1000 == 0) {
        cout << 0 << "\n";
    }
    else {
        cout << 1000*(n/1000 + 1) - n << "\n";
    }
}

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

Measured memory_bytes: 3604
#include <stdio.h>
#include <unordered_map>
using namespace std;
unordered_map<int,int> m;
int get(int n){
    if(n>1000)n=2000-n;
    return n+1;
}
int solve(int n){
    int ans=0;
    for(int l=0;l<=2000;l++)if(n-l>=0&&n-l<=2000)ans+=get(n-l)*get(l);
    return ans;
}
int main(){
    int n;
    while(scanf("%d",&n)!=EOF)printf("%d\n",solve(n));
}


Measured memory_bytes: 2732
#pragma GCC optimize("O3") //コンパイラ最適化用

#define _GLIBCXX_DEBUG //配列に[]でアクセス時のエラー表示
#include <algorithm>   //sort,二分探索,など
#include <bitset>      //固定長bit集合
#include <chrono>      //実行時間計測
#include <cmath>       //pow,logなど
#include <complex>     //複素数
#include <deque>       //両端アクセスのキュー
#include <functional>  //sortのgreater
#include <iomanip>     //setprecision(浮動小数点の出力の誤差)
#include <iostream>    //入出力
#include <iterator>    //集合演算(積集合,和集合,差集合など)
#include <map>         //map(辞書)
#include <numeric>     //iota(整数列の生成),gcdとlcm,accumulate
#include <queue>       //キュー
#include <set>         //集合（順序保持）
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility> //pair
#include <vector>  //可変長配列
using namespace std;
typedef long long ll;
typedef long double ld;

#define REP(i, n) for (int i = 0; i < ll(n); i++)
#define REPD(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < ll(b); i++)
#define FORD(i, a, b) for (int i = a; i > ll(b); i--)
// xにはvectorなどのコンテナ
#define ALL(x) x.begin(), x.end()
#define SIZE(x) ll(x.size()) // sizeをsize_tからllに直しておく
const long long INF = 1e12;
const int MOD = 1e9 + 7;
#define MAXR 100000 // 10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define Umap unordered_map
#define Uset unordered_set
#define int long long
const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

// https://qiita.com/Lily0727K/items/06cb1d6da8a436369eed#c%E3%81%A7%E3%81%AE%E5%AE%9F%E8%A3%85
void print() { cout << endl; }

template <class Head, class... Tail> void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail) != 0)
        cout << " ";
    print(forward<Tail>(tail)...);
}

template <class T> void print(vector<T> &vec) {
    for (auto &a : vec) {
        cout << a;
        if (&a != &vec.back())
            cout << " ";
    }
    cout << endl;
}

template <class T> void print(vector<vector<T>> &df) {
    for (auto &vec : df) {
        print(vec);
    }
}

void add(long long &a, long long b) {
    a += b;
    if (a >= MOD)
        a -= MOD;
}
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

signed main() {

    int k;
    cin >> k;

    int i = 1;
    while (true) {
        if (360 * i % k == 0) {
            print(360 * i / k);
            break;
        } else {
            i++;
        }
    }
}


Measured memory_bytes: 3564
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

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

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

    int n, a[112345], res = 0;

    cin >> n;

    REP(i, n)
    cin >> a[i];

    bool s;

    int i = 1;

    while (i < n && a[i] == a[i - 1])
        i++;

    if (i == n)
    {
        cout << 1 << endl;
        return 0;
    }

    s = (a[i] - a[i - 1] > 0);

    i = 1;

    while (i < n)
    {

        if (((a[i] - a[i - 1]) > 0) != s && a[i] != a[i - 1])
        {
            res++;

            i++;

            while (i < n && a[i] == a[i - 1])
                i++;

            if (i < n)
            {
                s = (a[i] - a[i - 1] > 0);
            }
        }
        else
            i++;
    }

    cout << res + 1 << endl;

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; i++)

int main () {
  ll n, b;
  cin >> n;
  b = 10000000000000001LL;
  rep(i,5) {
    ll c;
    cin >> c;
    b = min(b, c);
  }

  ll g = (n+b-1)/b;
  cout << g + 4LL << endl;

  return 0;
}


Measured memory_bytes: 256
N, M = gets.split.map(&:to_i)
LR = M.times.map { gets.split.map(&:to_i) }
L = 0
R = 1

s_cnt = Array.new(N + 1, 0)
e_cnt = Array.new(N + 1, 0)

LR.each do |lr|
  s_cnt[lr[L]] += 1
  e_cnt[lr[R]] += 1
end

now = 0
ans = 0
1.upto(N) do |i|
  now += s_cnt[i]
  ans += 1 if now >= M
  now -= e_cnt[i]
end

puts ans


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

int main() {
  int N, A, i, j;
  
  j = 40;
  
  cin >> N;
  
  while(N > 0){
    cin >> A;
    i = 0;
    while(A % 2 == 0){
      A /= 2;
      i += 1;
    }
    
    if(i < j){
      j = i;
    }
    
    N -= 1;
  }
  
  cout << j << endl;
  
}


Measured memory_bytes: 256
import fractions, math
def lcm(x, y):
  return (x * y) // fractions.gcd(x, y)

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

lcm = lcm(C, D)

nA = (A-1)//C + (A-1)//D - (A-1)//lcm
nB = B//C + B//D - B//lcm

print(B-A+1-nB+nA)

Measured memory_bytes: 5048
// #define DEBUGGING
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
template <typename T> using V = std::vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = std::int64_t;
using ull = std::uint64_t;
using PLL = std::pair<ll, ll>;
using TLL = std::tuple<ll, ll, ll>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }
#define mv_rec make_v(init, tail...)
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, size_t s, Tail... tail) { return V<decltype(mv_rec)>(s, mv_rec); }
#undef mv_rec
using namespace std;
#ifdef DEBUGGING
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

int main() {
    ll N;
    cin >> N;
    V<ll> A(N);
    for(auto &&ele : A) cin >> ele;
    cout << distance(A.begin(), min_element(ALL(A))) + 1 << endl;
    return 0;
}



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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "1" : "0") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

struct UnionFind {
  vector< int > par;
  UnionFind(int n = 1) {
    init(n);
  }

  void init(int n = 1) {
    par.resize(n);
    for(int i = 0; i < n; i++)
      par[i] = -1;
  }
  
  int root(int n) {
    if (par[n] < 0) return n;
    return par[n] = root(par[n]);
  }

  bool merge(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (par[x] > par[y]) swap(x, y);
    par[x] += par[y];
    par[y] = x;

    return true;
  }

  bool issame(int x, int y) {
    return root(x) == root(y);
  }
};

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

  CIN(N, Q);
  UnionFind uf(N + 1);
  
  REP(qi, Q) {
    CIN(c, x, y);
    if (c == 0) {
      // merge
      uf.merge(x, y);
    } else {
      OK(uf.issame(x, y));
    }
  }

  return 0;
}




Measured memory_bytes: 3232