akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define vt vector
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()
#define For(i, a, b) for(long long int i = (a); i <= (b); i++)
#define Forr(i, a, b) for(long long int i = (a); i >= (b); i--)
#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)
const int MOD=1e9+7;
const ll dx[4]={-1, 0, 1, 0} , dy[4]={0, 1, 0, -1};
const ll dxx[8]={-1, -1, 0, 1, 1, 1, 0, -1} , dyy[8]={0, 1, 1, 1, 0, -1, -1, -1};


int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;cin>>n;
	vt<int>a(n),b(n);
	vt<int>xplusy,xminusy,yminusx;
	FOR(n){
		cin>>a[i]>>b[i];
		xplusy.pb(a[i]+b[i]);
		xminusy.pb(a[i]-b[i]);
		yminusx.pb(b[i]-a[i]);
	}
	sort(all(xplusy));
	sort(all(xminusy));
	sort(all(yminusx));
	int ans=xplusy.back()-xplusy[0];
	ans=max(ans,xminusy.back()+yminusx.back());
	cout<<ans;
	return 0;
}


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

string S, T;
vector<string> cand;

void func(){
    int Ns = S.length(), Nt = T.length();
    for(int i = 0; i <= Ns - Nt; i++){
        bool jdg = true;
        for(int j = 0; j < Nt; j++){
            if(S[i + j] == '?')continue;
            else if(S[i + j] == T[j])continue;
            jdg = false;
            break;
        }
        string pus = "";
        if(jdg){
            for(int j = 0; j < i; j++){
                if(S[j] == '?')pus += "a";
                else pus += S[j];
            }
            pus += T;
            for(int j = i + Nt; j < Ns; j++){
                if(S[j] == '?')pus += "a";
                else pus += S[j];
            }
            cand.push_back(pus);
        }
    }
}

int main(){
    cin >> S >> T;
    func();
    sort(cand.begin(), cand.end());
    if(cand.size() == 0){
        cout << "UNRESTORABLE" << endl;
    }else{
        cout << cand[0] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using VE = vector<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int main() {
	int x;
	cin >> x;
	cout << 10 - (x / 200) << endl;
	return 0;
}

Measured memory_bytes: 3628
Ns = input().split()
a = int(Ns[0])
b = int(Ns[1])
c = int(Ns[2])
kawaiso = False
if a == b and a != c:
  kawaiso = True
elif a == c and a != b:
  kawaiso = True
elif b == c and b != a:
  kawaiso = True
  
if kawaiso:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
use strict;
use warnings;
use utf8;

chomp(my $inp = <STDIN>);
my ($a, $b) = split(/ /, $inp);
my $tot = $a + $b;
if ($a%3 == 0 || $b%3 == 0 or $tot%3 == 0) {
    print "Possible\n";
} else {
    print "Impossible\n";
}

Measured memory_bytes: 640
#include<iostream>

using namespace std;

int main(){

  int n;

  int n1,n2,st;
  n1=1;
  n2=1;
  st=1;

  cin >>n;

  for(int i=1;i<n;i++){
    st=n1+n2;
    n1=n2;
    n2=st;
  }
  cout <<st<<endl;

}

Measured memory_bytes: 0
import random

def down_score(d, c, last_d, score):
    sum = 0
    for i in range(26):
        sum += c[i]*(d-last_d[i])
        
    return (score - sum)

def main():
    D = int(input())

    c = list(map(int, input().split()))

    s = [list(map(int, input().split())) for i in range(D)]

    #print(c)

    #print(s)

    last_d = [0 for i in range(26)]
    
    ans = []
    
    score = 0
    
    for i in range(D):
        max = 0
        idx = 0
        for j in range(26):
            if max < (s[i][j] + c[j] * (i-last_d[j])) and c[j] != 0:
                max = s[i][j] + c[j] * (i-last_d[j])
                idx = j
            elif max == (s[i][j] + c[j] * (i-last_d[j])) and c[j] > c[idx]:
                idx = j
        last_d[idx] = i+1
        score += s[i][j]
        down_score(i+1,c,last_d,score)
        
        ans.append(idx)

    for i in range(D):
        print(ans[i]+1)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9876
S = input()

index_A = []
index_Z = []
for i in range(len(S)):
    if S[i] == "A" and len(index_A) == 0:
        index_A.append(i+1)
    if S[i] == "Z":
        index_Z.append(i+1)
            
print(max(index_Z) - index_A[0] + 1)

Measured memory_bytes: 7504
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long n;
  cin >> n;
  long long ans = 1e11;
  for (long long i = 1; i * i <= n; i++) {
	if (n%i != 0) {
	  continue;
	}
	long long cnt1 = 0, cnt2 = 0;
	long long k = i;
	long long j = n / i;
	while (j > 0) {
	  j /= 10;
	  cnt1++;
	}
	while (k > 0) {
	  k /= 10;
	  cnt2++;
	}
	long long temp = max(cnt1, cnt2);
	ans = min(ans, temp);
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
class BIT
  attr_reader :bit, :size

  def initialize(size, init: 0)
    @bit = Array.new(size + 1, init)
    @size = size
  end

  def sum(i)
    s = 0

    while i > 0
      s += bit[i]
      i -= i & -i
    end

    s
  end

  def add(i, x)
    while i <= size
      bit[i] += x
      i += i & -i
    end
  end
end

class Array
  def inversion_number
    cnt = 0
    n = size
    bit = BIT.new(n)

    order = uniq.sort.map.with_index(1) do |v, i|
      [v, i]
    end.to_h

    n.times do |j|
      cnt += j - bit.sum(order[at(j)])
      bit.add(order[at(j)], 1)
    end

    cnt
  end
end

n = gets.to_i
a = gets.split.map(&:to_i)

puts a.inversion_number




Measured memory_bytes: 46496
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a;
  cin >> a;
  if(a==1){
    cout << "Hello World" << endl;
  }
  else if(a==2){
    int A,B;
    cin >> A >> B;
    cout << A+B << endl;
  }
    
}

Measured memory_bytes: 256
import sys
import bisect
import collections


def input():
    return sys.stdin.readline().rstrip()


def main():
    n = int(input())
    la = [int(input()) for _ in range(n)]
    result = collections.deque()
    for a in la:
        idx = bisect.bisect_left(result, a)
        if idx == 0:
            result.appendleft(a)
        else:
            result[idx - 1] = a
    print(len(result))


main()


Measured memory_bytes: 8052
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

int main()
{
	ll a, n, m;
	cin >> a >> n >> m;

	int cnt = 0;
	for (int i = 1; ; i++)
	{
		ll x = (ll)pow(a + i, n);
		if (x > m)
		{
			break;
		}

		ll s = 0;
		for (ll j = x; j > 0; j /= 10)
		{
			s += j % 10;
		}

		if (i == s)
		{
			cnt++;
		}
	}



	cout << cnt << endl;
}


Measured memory_bytes: 3252
num = list(input())
for i in range(2**3):
    n = []
    pm = ["+","+","+"]
    for j in range(3):
        if ((i >> j) & 1):
            pm[j] = "-"
    for k in range(3):
        n.append(num[k])
        n.append(pm[k])
    n.append(num[3])
    formula = ""
    for j in range(7):
        formula += n[j] 
    if eval(formula) == 7:
        [print(n[k],end="") for k in range(7)]
        print("=7")
        exit()

Measured memory_bytes: 9084
#include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define OUTPUT_PERMUTATION(n) do{VI v(n); iota(ALL(v), 1); do{REPx(x, v) cout << x << " "; ENDL} while(next_permutation(ALL(v)));} while(0);
#define MAKE_PERMUTATION(n) do{VVI a(fact(n), VI(n)); int idx = 0; VI v(n); iota(ALL(v), 1); do{REP(i, n) a[idx][i] = v[i]; idx++; PER = a;} while(next_permutation(ALL(v)));} while(0); // int fact(), VVI PERを宣言しておく
#define ENDL cout << endl;
using namespace std;
using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
using VD = vector<double>;
const LL INF = 1e18;
const LL MOD = 1e9 + 7;

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;}

void END(){cout << 1 << endl; exit(0);}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  LL n, k;
  cin >> n >> k;
  VLL h(n);
  INPUT(h);
  SORTR(h);
  LL ans = 0;
  REP2(i, k, n) ans += h[i];
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>

using namespace std;
int t;
long long a,b,c,d;
int main()
{
	scanf("%d",&t);
	while(t--)
	{
		scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
		if(a<b)printf("No\n");
		else if(d<b)printf("No\n");
		else if(c>=b-1)printf("Yes\n");
		else
		{
			long long g=__gcd(b,d);
			if(b-c-2>g)printf("No\n");
			else
			{
				a%=b;
				a+=(c-a)/g*g;
				while(a<=c)
				{
					a+=g;
				}
				if(a>=b)printf("Yes\n");
				else printf("No\n");
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
void swap(int&a,int&b)
{
	int tmp=a;a=b;b=tmp;
}
int main()
{
	vector<int>num;
	int N;
	cin>>N;
	for(int i=0;i<N;i++)
	{
		int x;cin>>x;
		num.push_back(x);
	}
	int time=0;
	for(int i=0;i<N;i++)
	{
		if(i==num[i]-1)
		{
			if(i==0)
			swap(num[i],num[i+1]);
			else if(i==N-1)
			swap(num[i],num[i-1]);
			else if(num[i]>num[i-1])
			swap(num[i],num[i+1]);
			else swap(num[i],num[i+1]);
			time++;
		}
	}
	//for(int i=0;i<N;i++) cout<<num[i]<<endl;
	cout<<time<<endl;
}

Measured memory_bytes: 892
using System;

namespace Atcoder2
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] tmp = Console.ReadLine().Split(' ');
            int X = int.Parse(tmp[0]);
            int all = int.Parse(tmp[1]);

            if (all == 0)
            {
                Console.WriteLine(X);
                return;
            }

            string[] tmpNums = Console.ReadLine().Split(' ');
            int[] nums = new int[all];
            for(int i = 0; i < all; i++)
            {
                nums[i] = int.Parse(tmpNums[i]);
            }

            int[] count = new int[100];
            foreach (int num in nums)
            {
                count[Math.Abs(X - num)] += 1;
            }

            for(int i = 0; i < 100; i++)
            {
                if (count[i] == 0)
                {
                    Console.WriteLine(X - i);
                    break;
                } else if (count[i] == 1)
                {
                    if (i != 0)
                    {
                        if (Array.IndexOf(nums, X - i) == -1)
                        {
                            Console.WriteLine(X - i);
                            break;
                        }
                        else
                        {
                            Console.WriteLine(X + i);
                            break;
                        }
                    }

                }
            }
        }
    }
}

Measured memory_bytes: 27556
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main()
{
	int n, x; cin >> n >> x;
	
	vector<int> m(n);
	
	int min_m = 10000;
	int min_index;
	for (int i = 0; i < n; i++) { 
		cin >> m[i];
		x -= m[i];
		if (chmin(min_m, m[i])) min_index = i;
	}

	cout << n + x / m[min_index] << endl;
			
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define forn(i,x,y) for(int i=x;i<y;++i)
#define fornr(i,x,y) for(long long i=x;i>=y;--i)
#define testcase int _t; cin >> _t; while(_t--)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int MAXN = 2e5;


int main()
{
	ios_base :: sync_with_stdio(false);
  	cin.tie(0);
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	int arr[n];
	forn(i,0,n){
		cin >> arr[i];
	} 
	int dp[n];
	dp[0] = 0;
	dp[1] = abs(arr[1]-arr[0]);
	forn(i,2,n)
		dp[i] = min(abs(arr[i-1]-arr[i])+dp[i-1],abs(arr[i-2]-arr[i])+dp[i-2]);
	cout << dp[n-1] << '\n';  	
  	
  	return 0;
}

 	/* 















 	*/


Measured memory_bytes: 4428
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;


int main(){
    int n;
    cin >> n;
    cout << fixed << setprecision(7);
    if (n % 2 == 0) cout << 0.5 << endl;
    else cout << (double)((n + 1) / 2) / n << endl;
}

Measured memory_bytes: 256
package main

import (
  "fmt"
)

func getNumberOfDigits(n int) int {
  var i int = 0
  for n > 0 {
    n = n/10
    i++
  }
  return i
}

func main() {
  var N int 
  var n int = 1
  var i int = 0
  
  fmt.Scan(&N)

  for n <= N {
    if (getNumberOfDigits(n) % 2) != 0 {
      i++
    }
    n++
  }
  
  fmt.Println(i)
}

Measured memory_bytes: 512
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


long long x;

int main() {
  while (cin >> x) {
	long long p = x/11;
	long long q = x%11;
	int add = 0;
	if (q > 0) add = 1;
	if (q > 6) add = 2;
	cout << p*2 + add << endl;
  }
}
  





Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <string>
using namespace std;

#define rep(i, e) for (int i = 0; i < e; i++)
#define repp(i, s, e) for (int i = s; i < e; i++)
#define N_Max 100
#define Card_Max 36
#define p(a) printf("%d\n", a);
#define ll long long

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;
}

const long long INF = 1LL << 60;

int main()
{
    int n, m, a, b, c, d, k, x;
    int cnt = 0, ans = 0;
    string s;
    cin >> a >> s;
    if (a >= 3200)
    {
        cout << s << endl;
    }
    else
    {
        cout << "red" << endl;
    }
}

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

int main(){
    
    int n;
    cin >> n;
    string s;
    cin >> s;
    
    vector<int> w(n), e(n), t(n);
    
    w.at(0) = 0;
    e.at(n-1) = 0;
    for(int i=0;i<n-1;i++){
        w.at(i+1) = w.at(i);
        if(s.at(i) == 'W')  w.at(i+1)++;
    }
    for(int i=n-2;0<=i;i--){
        e.at(i) = e.at(i+1);
        if(s.at(i+1) == 'E')  e.at(i)++;
    }
    
    for(int i=0;i<n;i++)    t.at(i) = w.at(i) + e.at(i);
    
    sort(t.begin(),t.end());
    
    cout << t.at(0) << endl;
    
    return 0;
}




Measured memory_bytes: 4228
#include<stdio.h>
#define MAX 100000

int parent(int i){ return i/2; }
int left(int i){ return 2*i; }
int right(int i){ return (2*i)+1; }

int main(){
  int H, i, A[MAX+1];

  scanf("%d", &H);
  for( i = 1 ; i <= H ; i++ ){
    scanf("%d", &A[i]);
  }

  for( i = 1 ; i <= H ; i++ ){
    printf("node %d: key = %d, ", i, A[i]);
    if( A[parent(i)] != 0  ) printf("parent key = %d, ", A[parent(i)]);
    if( A[left(i)] != 0 ) printf("left key = %d, ", A[left(i)]);
    if( A[right(i)] != 0 ) printf("right key = %d, ", A[right(i)]);
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2044
import sys

s = list(input())

if s==list(reversed(s)):
  print("",end="")
else:  
  print ("No")
  sys.exit()

l=len(s)
fs = (s[0:(l//2)]) 
if (fs)==(list(reversed(fs))):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
n = int(input())
p = [int(input()) for _ in range(n)]
id = [0 for _ in range(n)]
for i in range(n):
    id[p[i]-1] = i
cnt = 0
l = r = 0
while l < n:
    while r < n-1 and id[r] < id[r+1]:
        r += 1
    cnt = max(cnt, r-l+1)
    if r == l:
        r += 1
    l = r
print(n-cnt)

Measured memory_bytes: 18892
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int re = 0; //結果用
        for(int i = 0; i < 2; i++){
            while(true){
                if(a > b){
                    re = re + a;
                    a--;
                    break;
                }
                if(a < b){
                    re = re + b;
                    b--;
                    break;
                }
                if(a == b){
                    re = re + a;
                    a--;
                    break;
                }
            }
        }
        System.out.println(re);
    }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;   //せんべいの枚数
  int K;  //参加者の人数
  
  //入力
  cin >> N >> K;
 
  //出力
  if (N % K == 0){
    cout << "0" << endl;
  } else {
    cout << "1" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define ll long long
#define pi  acos(-1)
const int w=5e5+5;
const ll mod=998244353;
int a[w];
int main()
{
    int i,j;
    int n,m;
    cin>>n>>m;
    for(i=1;i<=m;i++)
        scanf("%d",&a[i]);
    ll ans=1e18;
    for(i=1;i<=m;i++)
    {
        int pos=m+i-1;
        if(pos>m)
            pos-=m;
        ll u=a[pos]-a[i];
        if(u<0)
            u+=n;
        ans=min(ans,u);
    }
    cout<<ans<<endl;
    return 0;
}


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

int main(){
  string s; cin>>s;

  char c=s[0]; int ans=0;
  for(int i=1; i<s.size(); ++i){
    if(s[i]!=c){
      ans++;
      c=s[i];
    }
  }
  cout<<ans<<endl;
}


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

using namespace std;

int main()
{
    int n,x,sum=0;
    cin>>n>>x;
    int arr[n];
    for(int i=0 ; i<n ; i++){
      cin>>arr[i];
    }
    sort(arr,arr+n);

   for(int i=0 ; i<x ; i++) {
        sum+=arr[i];
   }
   cout<<sum;


}


Measured memory_bytes: 3628
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;
const int INF = 1e9 + 7;

int N, M;

class Edge{
  public:
    int f, t, c;
    Edge(){}
    Edge(int ff, int tt, int cc) { f = ff; t = tt; c = cc; }
};

bool update(int idx, Edge &e, vector<int> &sub, vector<bool> &visited, vector<int> &v){
  REP(i, sub.size()) if(!visited[sub[i]]) return 0;
  visited[idx] = 1;
  v[e.t] = max(v[e.t], v[e.f] + e.c);
  return 1;
}

int solve(vector<Edge> &es, vector< vector<int> > &sub){
  bool f = 1;
  vector<bool> visited(M, 0);
  vector<int> v(N, 0);
  while(f){
    f = 0;
    REP(i, M) if(!visited[i]) f = max(f, update(i, es[i], sub[es[i].f], visited, v));
  }
  return v[N - 1];
}

int main() {
  cin >>N >>M;
  vector< vector<int> > sub(N);
  vector<Edge> es(M);
  REP(i, M){
    cin >>es[i].f >>es[i].t >>es[i].c;
    sub[es[i].t].push_back(i);
  }
  cout <<solve(es, sub) <<endl;
  return 0;
}

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

using namespace std;

const double PI = 3.141592653589;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define int long long
#define ll long long
#define ll long long
#define all(c) (c).begin(),(c).end()
#define M 1000000007
#define INF LLONG_MAX
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
// Use pr(a,b,c,d,e) or cerr<<anything or prc(v.begin(),v.end()) or prc(v,v+n)
//  


int32_t main()
{
    fastio;
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    int a, b, c;
    cin >> a >> b >> c;
    int z = b/a, y = c/a;
    if(z == y)
    {
    	if((b%a) and (c%a))
    		cout << "NG\n";
    	else cout << "OK\n";
    }
    else cout << "OK\n";
    return 0;
}



Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;

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

    ll ans = 0;

    for(int i=0; i<N; i++) {
        sum -= A[i];
        ans += (A[i]) * (sum % (1000000000 + 7));
        ans %= (1000000000 + 7);
    }
    cout << ans;
}

Measured memory_bytes: 4752
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);

		int a = scan.nextInt();
		int b = scan.nextInt();

		System.out.println(String.format("a %s b", a > b ? ">" : a < b ? "<" : "=="));
	}
}



Measured memory_bytes: 26380
#include<bits/stdc++.h>
#define two(a) (1<<(a))
#define LINF (1ll<<61)
#define EPS (1e-14)
#define Lshift(a,b) (a<<b)
#define Rshift(a,b) (a>>b)
#define rep(a,b) for(a=0 ; a<b ; a++)
#define xrep(a,b,c) for(a=b ; a<c ; a++)
#define INF (1<<29)
#define swap(a,b) ( (a^=b) , (b^=a) , (a^=b) )
#define GET(x) (mark[x>>5]>>(x&31)&1)
#define SET(x) (mark[x>>5]|=1<<(x&31))
#define maxL (10000000>>5)+1
#define mod 1000000007
#define vi vector<int>
#define pii pair<int, int>
#define mii map<int, int>
#define si set<int>
#define pb push_back
typedef long long ll;
using namespace std;


int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n;
    string s;
    cin >> n >> s;
    int ans(0);
    for (size_t i = 0; i < s.length() - 2; i++) {
        if (s.substr(i, 3) == "ABC") {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
n, m = [int(i) for i in input().split()]
if n >= 2 and m >= 2:
    print((n-2)*(m-2))
elif n == 1 and m >= 2:
    print(m-2)
elif m == 1 and n >= 2:
    print(n-2)
else:
    print(1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890123456789LL
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):x)
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

typedef long long cat;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

cat mod =998244353;
vector<cat> fac, inv, inv_fac;

cat pw(cat a, cat e) {
	if(e <= 0) return 1;
	cat x =pw(a,e/2);
	x =(x*x)%mod;
	if(e&1) return (x*a)%mod;
	return x;
}

cat getC(int N, int K) {
	if(N < 0 || K < 0 || K > N) return 0;
	cat ret =(inv_fac[K]*inv_fac[N-K])%mod;
	ret =(ret*fac[N])%mod;
	return ret;
}

cat count(int up, int dn, int n) {
	if(n == 0) return (up+dn == 0);
	return getC(up+dn+n-1,n-1);
}

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int MX =500010;
	fac.resize(MX,1);
	inv.resize(MX,1);
	inv_fac.resize(MX+1,1);
	for(int i =1; i < MX; i++) {
		fac[i] =(i*fac[i-1])%mod;
		inv[i] =pw(i,mod-2);
		inv_fac[i] =(inv[i]*inv_fac[i-1])%mod;
	}

	int N,M;
	string A,B,C,D;
	cin >> N >> M >> A >> B >> C >> D;
	cat ans =0;
	bool zero =1;
	for(int k =0; k < 2; k++) {
		swap(N,M);
		swap(A,C);
		swap(B,D);

		int nL =0, nR =0;
		for(int i =0; i < M; i++) if(C[i] == '1') nL++;
		for(int i =0; i < M; i++) if(D[i] == '1') nR++;
		vector<cat> cL(N,0), cR(N,0);
		int up =0, dn =0;
		for(int i =0; i < N; i++) {
			cL[i] =count(up,dn,nL);
			if(A[i] == '1') up++;
			if(B[i] == '1') dn++;
		}
		up =dn =0;
		for(int i =N-1; i >= 0; i--) {
			cR[i] =count(up,dn,nR);
			if(A[i] == '1') up++;
			if(B[i] == '1') dn++;
		}

		cat akt =0;
		for(int i =N-1; i >= 0; i--) {
			if(A[i] == '1' || B[i] == '1') akt +=cR[i];
			if(A[i] == '1' && B[i] == '1') akt *=2;
			akt %=mod;
			if(A[i] == '1' || B[i] == '1') {
				ans =(ans+akt*cL[i])%mod;
				zero =0;
			}
		}

	}
	if(zero) ans++;
	ans %=mod;
	if(ans < 0) ans +=mod;
	cout << ans << "\n";
	return 0;}

// look at my code
// my code is amazing


Measured memory_bytes: 14160
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int H = Integer.parseInt(sc.next());
		int W = Integer.parseInt(sc.next());
		int K = Integer.parseInt(sc.next());

		String[] s = new String[H];
		for (int i = 0; i < H; i++) {
			s[i] = sc.next();
		}

		sc.close();

		int index = 1;
		int rowCount = 0;
		String ret = "";
		String lastRet = "";
		for (int tate = 0; tate < H; tate++) {
			Boolean strExi = false;
			int count = 0;
			ret = "";
			for (int yoko = 0; yoko < W; yoko++) {
				if (s[tate].charAt(yoko) == '#') {
					strExi = true;
					ret += indexStr(index, count + 1);
					count = 0;
					index++;
				} else {
					count++;
				}
			}
			if(!strExi) {
				rowCount++;
				continue;
			}
			if(count != 0) {
				ret += indexStr(index - 1, count);
			}
			for (int i = 1; i <= rowCount + 1; i++) {
				System.out.println(ret);
			}
			rowCount = 0;
			lastRet = ret;

		}
		if(rowCount > 0) {
			for (int i = 1; i <= rowCount; i++) {
				System.out.println(lastRet);
			}
		}


	}

	private static String indexStr(int index, int count) {
		String ret = "";
		for (int i = 0; i < count; i++) {
			ret += index + " ";
		}
		return ret;
	}
}


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

typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

#define pi pair<int,int>
#define pl pair<lld,lld>

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())
#define vuniq(x) x.erase(unique(x.begin(), x.end()), x.end())

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)

int main() {
    ll A,B;
    cin >> A >> B;
    cout << max(max(A+B,A-B),A*B) << endl;
}

Measured memory_bytes: 3604
//shara's here
//SPEEEEEEEEEED IS KEEEEEEEEEEY
//REEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEAD
#include <bits/stdc++.h>
using namespace std;
typedef string s;
typedef long long ll;
typedef long double ld;
#if !defined(ONLINE_JUDGE)
#include "C:\debug.hpp"
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define pb push_back
#define ins insert
#define vl vector<ll>
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
int main(){
    speed;
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    bool a1=0,a2=0;
    while(a&&c){
        c-=b;
        if(c<=0){a1=1;break;}
        a-=d;
        if(a<=0){a2=1;break;}
    }
    if(a1){cout<<"Yes"<<endl;}
    else cout<<"No"<<endl;
    
























return 0;}
/*
███████████████████████████████████████████████████
███████████████████████████████████████████████████
██████████████████████████████████▀████████████████
██████████████████████████████████░▀███████████████
██████████████████████████████▌███░░░▀▀████████████
██▀████████████████████▐██████░▐██░░░░░░▀▀█████████
██░████████████████████▐█████▌░██▌▄░░░░▄▄░▄████▀███
█▌░███████████████████▀░█████░░░█░░░▄████░░███▀▐███
█▌░▐██████████████████░░████▌░░░▀░░▀███▀▀░▐███▄████
██░▀██████████████▌▐█▐▄▄████▌░░░░░░░░░░░░░▌████████
███░███████████████▀░▄▄██▀█▐░░░░░░░░░░░░░░▐████████
███▄░██████████████▄░░░░░░▀▀▀░░░░░░░░░░░░░█▐███████
████▄░██████████████████▄▄▄▄▄▄▐▄░░░░░░░░░░░████████
█████▄█████████████████▀▀▀▀▀▀░░░░░░░░░░░░░░████████
████████████████████████▄░░░░░░░░░░░░░░░▄░░████████
██████████████████████████▄▄▄░░░░░░░░░▄█░▄█████████
████████████████████████████████▄░░░░██▄███▀░░▀████
█████████████████████████████▀█████▄███▀▀▀░░▄▄░████
████████████████████████████▀░░▀░░▀▀░░░░▄▄▄██▀░░▀▀█
███████████████████████████▌░░░░░░░░░░░███████░░░▄█
███████████████▄░▀████████▀░░░░░░▀░░░░███████▌░░░██
███▄▄████████████▄░▀██████▄░░░░░█░░░░████████░░░▀▀
░▀█████████████████▄░▀█████░░░░██░░░░▀██████░░░░░▄█
▐█▄▀█████████████████▄░▀████░░░██▌░░░▐████▀░░░░▄███
▐███▄▀▀█████████████████▄░▀▀░░░░▀██▌▄█▀▀░░░▄▄██████
▀▀▀▀▀░░░▀▀▀▀▀░░░▀▀▀▀▀▀▀▀▀▀▀░░░░░░░▀▀░░░░░░▀▀▀▀▀▀▀▀▀
*/


Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
map<ll,ll>cnt;
int main()
{
  ll n, m, x, i, sum=0;

  cin>>n;

  for(i=1; i<n; i++)
  {
    cin>>x;
    cnt[x]++;
  }

  for(i=1; i<=n; i++)
  {
    cout<<cnt[i]<<endl;
  }
  
}

Measured memory_bytes: 16180
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int T=in.nextInt();
		in.close();
		int count=1;
		int tem=7;
		int ans=-1;
		for(int i=1;i<=T;i++) {
			if(tem%T==0) {
				ans=count;
				break;
			}
			count++;
			tem=(tem*10+7)%T;
		}
		System.out.println(ans);
	}
}


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

int main(){
    string S,T;
    cin >> S >> T;

    int max_match = 0;
    int diff = S.size() - T.size() + 1;
    for(int i=0;i<diff;i++){
        int match = 0;
        //cout << T.size() << " " << S.size() << " " << i << endl;
        for(int j=0;j<T.size();j++){
            //cout << S.at(i+j);
            if(S.at(i+j) == T.at(j)){
                match++;
                if(match > max_match){
                    max_match = match;
                }
            }
        }
    }
    cout << T.size() - max_match << endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <climits>

using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define in1(n) cin>>n;
#define in2(n, k) cin>>n>>k;
#define in3(n, k, s) cin>>n>>k>>s;
#define scn(t) scanf("%d", &t)
#define scnld(t) scanf("%ld", &t)
#define scnlld(t) scanf("%lld", &t)
#define scnc(t) scanf("%c", &t)
#define scns(t) scanf("%s", t)
#define scnf(t) scanf("%f", &t)
#define scnlf(t) scanf("%lf", &t)
#define mem(a, b) memset(a, (b), sizeof(a))
#define nloop(i, j, k, in) for (int i = j; i < k; i += in)
#define rloop(i, j, k, in) for (int i = j; i >= k; i -= in)
#define rep(i, j) nloop(i, 0, j, 1)
#define rrep(i, j) rloop(i, j, 0, 1)
#define inar(n, a) \
    rep(i, n)\
        cin>>a[i];
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert(B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define fast  \
    ios_base::sync_with_stdio(false);\
    cin.tie(NULL);
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
#define test  \
    int t;    \
    cin >> t; \
    while (t--)
const double pi = acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int, int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int uint64;

int main()
{
    fast
    int64 s;
    in1(s) 
    double x = 1.0 * s;
    double a = 101.0;
    int i = 1;
    while(a<x)
    {
        a = a*1.01;
        i++;
        if (a >= x)
        {
            break;
        }
        a = floor(a);
    }
    cout<<i<<endl;
    return 0;
}

Measured memory_bytes: 3652
# DFS
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

def dfs(v):
    seen[v] = 1
    ans[v] += counter[v]

    for next_v in graph[v]:
        if seen[next_v]: continue
        ans[next_v] += ans[v]
        dfs(next_v)

n, q = map(int, input().split())

graph = [[] for _ in range(n)]
for _ in range(n-1):
    a, b = map(int, input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

counter = [0] * n
for _ in range(q):
    p, x = map(int, input().split())
    counter[p-1] += x

seen = [0] * n
ans = [0] * n
dfs(0)

print(*ans)

Measured memory_bytes: 238460
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned ui;
typedef unsigned long long ul;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef pair<bool, bool> pbb;
typedef vector<int> vi;
#define pb push_back
#define fi first
#define se second
#define mid ((l + r) >> 1)
#define ls (i << 1)
#define rs (i << 1 | 1)
#define enum(i, j, k) for(int i = j; i <= (k); i ++)
#define open(i, j, k) for(int i = j; i <  (k); i ++)
#define dec(i, j, k)  for(int i = j; i >= (k); i --)
#define ae(x) for(node *p = h[x]; p; p = p->nxt)
#define fill(x, k) memset(x, k, sizeof x)
#define copy(x, y) memcpy(x, y, sizeof x)
#define fio(x) freopen(x".in", "r", stdin); freopen(x".out", "w", stdout);
template <class T> bool chkmin(T &x, T y)
{ return y < x ? (x = y , true) : false; }
template <class T> bool chkmax(T &x, T y)
{ return y > x ? (x = y , true) : false; }
void __init()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(16);
    srand(time(0) ^ ui(ul(new char)));
}
/* default code ends here */
const ll mod = 1e9 + 7;
const int maxn = 1e6 + 10;

ll fpow(ll x, ll a)
{
	ll ret = 1;
	for( ; a; a >>= 1, x = x * x % mod)
		if(a & 1)
			ret = ret * x % mod;
	return ret;
}
ll ni(ll x)
{
	return fpow(x, mod - 2);
}

int n;
ll peng[maxn], np[maxn];
ll C(ll x, ll y)
{
	if(x < y)
		return 0;
	else if(x == y)
		return 1;
	else
		return peng[x] * np[y] % mod * np[x - y] % mod;
}
ll res[maxn];
int main()
{
	__init();
	cin >> n;
	peng[0] = np[0] = 1;
	enum(i, 1, n)
	{
		peng[i] = peng[i - 1] * i % mod;
		np[i] = ni(peng[i]);
	}
	
	ll ans = 0;
	enum(i, 1, n - 1)
		res[i] = C(i - 1, n - i - 1) % mod * peng[i] % mod * peng[n - i - 1] % mod;
	dec(i, n - 1, 1)
		res[i] -= res[i - 1];
	enum(i, 1, n - 1)
		ans = (ans + i * res[i]) % mod;
	
	/*
	ll ans = peng[n] * n % mod;
	if(n >= 3)
		ans = (ans - (n - 2) * C(n, 3) * 2 % mod * peng[n - 3]) % mod;*/
		
	
	cout << (ans + mod) % mod << '\n';
	return 0;
}


Measured memory_bytes: 23680
#include "bits/stdc++.h"
#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;

template <class X> X lcm(X a, X b){
    X mm = a, nn = b, tmp;
    while(a % b != 0){
        tmp = b;
        b = a % b;
        a = tmp;
    }
    return mm * nn / b;
}
int main(){
    ull A, B, C, D;
    cin >> A >> B >> C >> D;
    ull sum = B - A + 1;
    sum -= (B / C - (A - 1) / C);
    sum -= (B / D - (A - 1) / D);
    sum +=  (B / lcm(C, D) - (A - 1) / lcm(C, D));
    cout << sum << endl;
}

Measured memory_bytes: 256
//Keep pluggin',this is your only outlet.
#include<bits/stdc++.h>
#define MM(x,y) memset(x,y,sizeof(x))
#define MCPY(a,b) memcpy(a,b,sizeof(b))
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define fi first
#define mp make_pair
#define se second
using namespace std;
#define int long long

inline int quickpow(int m,int n,int p){int b=1;while(n){if(n&1)b=b*m%p;n=n>>1;m=m*m%p;}return b;}
inline int quickmul(int x,int y,int mod){return (x*y-(int)((long double)x/mod*y)*mod+mod)%mod;}
inline int getinv(int x,int p){return quickpow(x,p-2,p);}
inline int read(void){
    int x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){f=ch=='-'?-1:1;ch=getchar();}
    while(isdigit(ch)){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
    return x * f;
}
const int Mod = 1e9 + 7;
const int MAXN = 2e5 + 100;
#define lowbit(x) (x&-x)

struct BIT {
    int c[MAXN];
    inline void reset(void){memset(c,0,sizeof(c));}
    inline void add(int x,int d){for (int i = x; i < MAXN; i += lowbit(i)) c[i] = (c[i] + d) % Mod;}
    inline int sum(int x){int ret = 0; for (int i = x; i >= 1; i -= lowbit(i)) ret = (ret + c[i]) % Mod; return ret;}
}c1,c2;
int tot = 1,S[MAXN],a[MAXN],inv2 = (Mod + 1) / 2,_00man[MAXN],cnt[MAXN],D[MAXN],invD[MAXN],n;
inline void upd(int &x,int y){x = (x + y) % Mod;}
///------------------head------------------
signed main(signed argc, char *argv[]){
    n = read();
    rep(i,1,n) a[i] = read(),cnt[a[i]]++;
    for (int i = n - 1; i >= 1; i--) cnt[i] += cnt[i + 1];
    for (int i = 1; i <= n; ++i) cnt[i] -= (n - i);
    S[0] = D[0] = 1;
    for (int i = 1; i <= n; i++) {
        if (cnt[i] <= 0) return puts("0"),0;
        tot = tot * cnt[i] % Mod;
    }
    for (int i = 1; i <= n; ++i) {
        int x = (cnt[i] - 1) * getinv(cnt[i],Mod) % Mod;
        if (x == 0) {
            _00man[i] = _00man[i-1] + 1;
            S[_00man[i]] = i;
            D[i] = D[i-1];
        }
        else {
            _00man[i] = _00man[i-1];
            D[i] = D[i-1] * x % Mod;
        }
        invD[i] = getinv(D[i],Mod);
    }
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        upd(ans,(c1.sum(a[i])-c1.sum(S[_00man[a[i]]] - 1) + Mod) * D[a[i]] % Mod * tot % Mod * inv2 % Mod);
        c1.add(a[i],invD[a[i]]);
        c2.add(a[i],1);
    }
    c1.reset(); c2.reset();
    for (int i = n; i >= 1; --i) {
        upd(ans,(Mod-1) * (c1.sum(a[i] - 1) - c1.sum(S[_00man[a[i]]] - 1) + Mod) % Mod * D[a[i]] % Mod * tot % Mod * inv2 % Mod);
        upd(ans,c2.sum(a[i] - 1) * tot % Mod);
        c1.add(a[i],invD[a[i]]);
        c2.add(a[i],1);
    }
    printf("%lld\n",ans);
    return 0;
}

/* Examples: */
/*

*/

/*

*/


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

public class Main {

	public static void main(String[] args) {

		int n = 0;
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();

		int[] s = new int[n];
		for (int i = 0; i < n; i++) {
			s[i] = sc.nextInt();
		}

		Arrays.sort(s);
		int sum = 0;
		for (int i = n - 1; i >= 0; i--) {
			sum += s[i];
		}
		if (sum % 10 == 0) {
			for (int i = 0; i < n; i++) {
				if (s[i] % 10 != 0) {
					sum -= s[i];
					break;
				}
				if (i == n - 1) {
					sum = 0;
				}
			}
		}
		System.out.println(sum);

	}

}


Measured memory_bytes: 21712
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll A,B,C;
    cin >>A>>B>>C;
    ll a1 = max({A,B,C});
    ll a3 = min({A,B,C});
    ll a2 =A+B+C-a1-a3 ;
    ll ans=0;

    ans+=a1-a2;
    if((a2-a3)%2==0){
        ans+=(a2-a3)/2;
    }else{
        ans+=(a2-a3)/2+2;
    }
    cout << ans << endl;


    return 0;
    

}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n;
    cin >> n;

    vector<int> v(n);
    for(int i = 0; i < n; i++)
    {
        cin >> v.at(i);
    }

    sort(v.rbegin(), v.rend());
    int ans = 0;
    for(int i = 0; i < n; i++)
    {
        if (i % 2 == 0){
            ans += v.at(i);
        } else{
            ans -= v.at(i);
        }
    }   
    cout << ans << endl;
}

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

typedef long long ll;
typedef pair<int,int> ii;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int a,b,c; cin>>a>>b>>c;
	set<int> st={a,b,c};
	cout << st.size() << endl;
	return 0;
}


Measured memory_bytes: 256
tate =int(input())
yoko=int(input())
arr = [i+1 for i in range(tate)]
for j in range(yoko):
    rep1,rep2=input().split(",")
    rep1=int(rep1)-1
    rep2=int(rep2)-1
    arr[rep1],arr[rep2] = arr[rep2],arr[rep1]

for k in range(tate):
    print(arr[k])


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

using namespace std;
typedef long long ll;

map<string,int>mp;

int main()
{
   string s[5]={"1","Sunny","Cloudy","Rainy"};
   for(int i=1;i<=3;i++){
    mp[s[i]]=i;
   }
   string x;cin>>x;
   int y=mp[x]+1;
   if(y>3) cout<<s[y-3];
   cout<<s[y];
    return 0;
}


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

const int MAXN = 100000 + 5 ;

bool noSolution;
int N, K;
pair <int, int> pnt[MAXN];
struct node
{
    int l, r, oe;
}rng[MAXN];
vector <int> Adj[MAXN];

void UpdateNode(int toUpdate, int evidence)
{
    int l = rng[evidence].l-1, r = rng[evidence].r+1;
    if(rng[evidence].oe != -1)
    {
        if(rng[toUpdate].oe == -1)
            rng[toUpdate].oe = rng[evidence].oe ^ 1;
        else if(rng[toUpdate].oe == rng[evidence].oe)
            noSolution = true ;
    }
    rng[toUpdate].l = max(rng[toUpdate].l, l), rng[toUpdate].r = min(rng[toUpdate].r, r);

    if(rng[toUpdate].l > rng[toUpdate].r)
        noSolution = true ;
}

void DFSPushUp(int x, int fa)
{
    if(noSolution)
        return ;
    for(int & to : Adj[x])
        if(to != fa)
            DFSPushUp(to, x),   UpdateNode(x, to);
}

void DFSPushDown(int x, int fa)
{
    if(noSolution)
        return;
    if(fa)
        UpdateNode(x, fa);
    for(int & to : Adj[x])
        if(to != fa)
            DFSPushDown(to, x);
}

int main()
{
    int u, v, w;
    cin >> N ;

    for(int i = 1; i < N; i++)
        cin >> u >> v , Adj[u].push_back(v), Adj[v].push_back(u);

    cin >> K ;
    for(int i = 1; i <= N; i++)
        rng[i].l = 0x80808080, rng[i].r = 0x7F7F7F7F, rng[i].oe = -1;
    for(int i = 1; i <= K; i++)
        cin >> pnt[i].first >> pnt[i].second, rng[pnt[i].first].l = pnt[i].second, rng[pnt[i].first].r = pnt[i].second, rng[pnt[i].first].oe = pnt[i].second & 1;

    DFSPushUp(1, 0);
    DFSPushDown(1, 0);

    if(noSolution)
        puts("No");
    else
    {
        puts("Yes");
        for(int i = 1; i <= N; i++)
            cout << rng[i].l << endl ;
    }

    return 0;
}


Measured memory_bytes: 12800