akhauriyash/Code-Regression huggingface dataset:
from collections import defaultdict

N,M = map(int,input().split())

D = defaultdict(list) 
S = [0 for i in range(N)] #S[i-1]で探索済判定
for i in range(M):
    x,y,z = map(int,input().split())
    D[x].append(y)
    D[y].append(x)
    
ans = 0
for i in range(N):
    if S[i]>0:continue
    T = [i+1]
    S[i] = 1
    ans += 1
    while T:
        n = T.pop()
        for d in D[n]:
            if S[d-1]>0:continue
            else: S[d-1] = 1
            T.append(d)
        
print(ans)

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

using namespace std;

int main(int argc, char **argv)
{
    int S;
    cin >> S;

    int h = S / (60*60);
    int m = (S / 60) % 60;
    int s = S % 60;

    assert(h*60*60 + m*60 + s == S);

    cout << h << ":" << m << ":" << s << endl;

}


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

#define ll long long
#define llu unsigned long long
#define PB push_back
#define F first
#define S second
const ll MOD = 1000000007;
const ll INF = 1000000007;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define ck(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define ck(x...)
#endif

string gh = "here";

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	#ifndef ONLINE_JUDGE
			freopen("C:\\Users\\HP\\Desktop\\input.txt", "r", stdin);
			freopen("C:\\Users\\HP\\Desktop\\output.txt", "w", stdout);
			freopen("C:\\Users\\HP\\Desktop\\err.txt", "w", stderr);
	#endif

	ll n;
	cin>>n;
	long double res = 1;
	vector < long double > q(n, 0);
	for(ll i =0;i<n;i++){
		cin>>q[i];
	}
	for(ll i =0;i<n;i++){
		if(q[i] == 0){
			cout<<0;
			return 0;
		}
	}
	for(ll i =0;i<n;i++){
		res *= q[i];
		if(res > 1000000000000000000){
			cout<<-1;
			return 0;
		}
	}
	cout<<(ll)(res);
	
	return 0;
}

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

int main(){
    int n;
    while(cin >> n , n){
        int ans[7];
        memset(ans,0,sizeof(ans));
        for(int i=0; i<n; i++){
            int o; cin >> o;
            int ind = min(o/10,6);
            ans[ind]++;
        }
        for(int i=0; i<7; i++)
            cout << ans[i] << endl;
    }
}
            

Measured memory_bytes: 1160
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define inf 1e+9
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

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

    int n,k,ans=0;
	string s;
	cin >> s;

	//cout << s[0]<< endl;

	rep(i,s.length()){
		if(i%2!=0 && s[i]=='R'){
			cout << "No" << endl;
			//cout << i;
			return 0;
		}
		else if(i%2==0 && s[i]=='L'){
			cout << "No" << endl;
			//cout << i;
			return 0;
		}
		//cout << i;
	}
	

	cout << "Yes" << endl;
}

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

int main() {
  int L, R; cin >> L >> R;
  int ans = 2019;

  if (L / 2019 != R / 2019) {
    ans = 0;
  } else {
    L %= 2019, R %= 2019;
    for(int i = L; i < R; i++) {
      for(int j = i + 1; j <= R; j++) {
        ans = min(ans, (i * j) % 2019);
      }
    }
  }

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

Measured memory_bytes: 256
#include<iostream>
#include<map>
using namespace std;
const int BUF = 200005;


int nVal, K;
int val[BUF];

void read() {
    cin >> nVal >> K;
    val[0] = 0;
    for (int i = 1; i <= nVal; ++i) {
        cin >> val[i];
    }
    ++nVal;
}


void work() {
    for (int i = 1; i < nVal; ++i) {
        --val[i];
    }

    int sum[BUF];
    sum[0] = val[0] % K;
    for (int i = 1; i < nVal; ++i) {
        sum[i] = (sum[i - 1] + val[i]) % K;
    }

    long long ans = 0;
    
    map<int, int> sum2cnt;
    sum2cnt[0] = 1;
    for (int i = 1; i < nVal; ++i) {
        if (i >= K) {
            --sum2cnt[sum[i - K]];
        }
        
        if (sum2cnt.count(sum[i])) {
            ans += sum2cnt[sum[i]];
        }
        
        if (!sum2cnt.count(sum[i])) {
            sum2cnt[sum[i]] = 0;
        }
        ++sum2cnt[sum[i]];
    }

    cout << ans << endl;
}


int main() {
    read();
    work();
    return 0;
}


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

using namespace std;

typedef long long LL;

const double pi=3.1415926; 

const int N=2e5+10,mod=1e9+7;

int a[N];
LL sumz[N],sumf[N];

int main()
{
	int n,k;
	cin>>n>>k;
	LL res=0;
	for(int i=k;i<=n+1;i++) 
	{
		//cout<<i*(n-i+1)+1<<'\n';
		res=(res+(LL)i*(n-i+1)%mod+1)%mod;
	}
	cout<<res<<'\n';
 	return 0;
} 

Measured memory_bytes: 3592
#include <cstdio>

signed main() {
  char str[10];
  scanf("%s", str);
  int cnt = 1;
  for (int i = 1; i < 4; ++i)
    if (str[i] == str[i - 1]) {
      if (++cnt >= 3)
        return puts("Yes"), 0;
    }
    else
      cnt = 1;
  return puts("No"), 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <queue>

using namespace std;

#define int long long

signed main() {
    int k;
    cin >> k;

    queue<int> q;
    for(int i = 1; i < 10; i++) q.push(i);
    
    for(int i = 0; i < k - 1; i++) {
        int x = q.front();
        q.pop();
        int d = x % 10;
        for(int j = -1; j <= 1; j++) {
            int nd = d + j;
            if(nd < 0 || nd > 9) continue;
            q.push(10 * x + nd);
        }
    }

    cout << q.front() << endl;
    return 0;
}

Measured memory_bytes: 1792
n = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

cur_a = A[0]
ans = 0

for i,b in zip(range(n),B):
	if A[i]+A[i+1] <= b:
		ans += A[i]+A[i+1]
		A[i+1] = 0
	else:
		ans += b
		b = max(0,b-A[i])
		A[i+1] -= b
print(ans)


Measured memory_bytes: 18624
#include<iostream>

using namespace std;

long long factorial(long long n){
  long long int ans;
  if(n==0)
    ans=1;
  else
    ans =n*factorial(n-1);
  return ans;
}

int main(){
  long long  n=0;
  cin>>n;

  long long int ans=1;
  ans=factorial(n);

  cout<<ans<<endl;
}

Measured memory_bytes: 0
require 'pp'
require 'set'

class Shinsu
    include Enumerable

    def initialize
        @data = []
    end

    def next
        if @data.empty?
            @data = ['7', '5', '3']
            return @data
        else
            digit(0)
            @data
        end
    end

    def digit(index)
        x = @data[index]
        if x == nil
            @data[index] = '3'
        elsif x == '7'
            @data[index] = '3'
            digit(index + 1)
        elsif x == '3'
            @data[index] = '5'
        else
            @data[index] = '7'
        end
    end 
end

n = gets.chomp!.to_i
x = Shinsu.new

count = 0
loop do
    z = x.next.reverse
    if z.join.to_i > n
        break
    end

    if z.group_by{|x| x}.keys.length == 3
        count += 1
    end
end

puts count


Measured memory_bytes: 4348
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
#include<iostream>
#include<iomanip>
#include<cmath>
#include<array>
#include<vector>
#include<set>
#include <utility>
#include <map>
#include<bitset>

using namespace std;



int main(){
int n; cin>>n;
long long k; cin>>k;
int q; cin>>q;

int a[110000];
for(int i=0; i<q;i++){
  cin>>a[i];
}

int score[110000]={0};

for(int i=0;i<q;i++)
score[a[i]-1]++;


for(int i=0;i<n;i++){
  if(k-q+score[i]>0){
    cout<<"Yes"<<endl;
  }
  else
  cout<<"No"<<endl;
}

}


Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;

// typedef
typedef long long ll;
typedef unsigned long ul;
// #define int long long

// macro
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define DESCEND greater<int>()  // sort 降順 大きい順
#define UNIQUE(vec) (vec).erase(unique(ALL((vec))), (vec).end());  // 必ずsortを行なってから
#define MIN(vec) min_element(ALL((vec)))  // 値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
#define zero_pad(num) setfill('0') << std::right << setw(num)  // 直後の要素をパディング
#define space_pad(num) setfill(' ') << std::right << setw(num)  // 直後の要素をパディング

// func declaration
template <class T> void print2DVec(vector< vector<T> >&);
template <class T> void calcVec(vector<T>&, int, char);
int char_to_int(const char);

// const
const int INF = 10000000;

/*MEMO
・辞書順
abc < abcd, atcoder < atlas
・イテレータ
std::vector<int>::iterator とタイプするのは面倒なので、
 通常は型推論の auto を使用する。
 auto iter = max_element(ALL(vec));
・2次元配列
vector<vector<int>> vec = {{1, 2, 3}, {4, 5, 6}}
・20×10の配列
vector<vector<int>> vec(20, vector<int>(10, 0));
・(n, m)の多次元配列
vector< vector<int> > vec(n, vector<int>(m, 0))  // 0で初期化
*/

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

    // input
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    
    // calculation
    int train = (A < B) ? A: B, bus = (C < D) ? C: D;
    cout << train + bus << "\n";
    
    return 0;
}


// function
template <class T> void print2DVec(vector< vector<T> >& vec) {
    REP(i, vec.size()) {
        REP(j, vec.front().size()) {
            cout << vec.at(i).at(j);
        }
        cout << endl;
    }
}

template <class T> void calcVec(vector<T> &vec, int num, char ch) {
    // vec全体への演算
    switch (ch) {
        case '+':
            REP(i, vec.size()) vec.at(i) += num; break;
        case '-':
            REP(i, vec.size()) vec.at(i) -= num; break;
        case '*':
            REP(i, vec.size()) vec.at(i) *= num; break;
        case '/':
            REP(i, vec.size()) vec.at(i) /= num; break;
        case '%':
            REP(i, vec.size()) vec.at(i) %= num; break;
        default:
            cout << "Incorrect Operator" << endl;
    }
}

int char_to_int(const char c) {
    if('0' <= c && c <= '9') return (c - '0');
    return -1;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef long long ll;

const int LGX = 40;

ll f(ll x) {
    ll r = 0;
    for (int i = LGX - 1; i >= 0; i--) {
        ll t = x / (1ll << (i + 1)) * (1ll << i);
        t += max(0ll, x % (1ll << (i + 1)) - (1ll << i) + 1);
        r += (t & 1) * (1ll << i);
    }
    return r;
}

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

    cout << (f(a - 1) ^ f(b)) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>

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

using namespace std;

typedef long long ll;

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

int main(){
	for(int n,m;scanf("%d%d",&n,&m),n;){
		int p[20];
		rep(i,m) scanf("%d",p+i);

		ll sum=0,tot=0;
		rep(S,1<<m){
			ll L=1,pc=0;
			rep(i,m) if(S&(1<<i)) L=lcm(L,p[i]), pc++;

			if(L<=n){
				if(pc%2==1) sum-=(L+n)*(n/L)/2, tot-=n/L;
				else        sum+=(L+n)*(n/L)/2, tot+=n/L;
			}
		}
		printf("%.9f\n",tot==0?0:(double)sum/tot);
	}

	return 0;
}

Measured memory_bytes: 796
package main

import (
	"fmt"
)

func main() {
	// なぜかWAなる
	// var A, B, C float64
	// fmt.Scan(&A, &B, &C)
	// if C-A-B > 0 && 4*A*B < math.Pow(C-A-B, 2) {
	// 	fmt.Println("Yes")
	// } else {
	// 	fmt.Println("No")
	// }
	// なぜか通る
	var A, B, C int
	fmt.Scan(&A, &B, &C)
	if C-A-B > 0 && 4*A*B < (C-A-B)*(C-A-B) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

namespace AtCoder
{
    static class Program
    {
        static void Main()
        {
            //ここから

            var S = IO.ReadLineToString().Select(s=>s=='1').ToList();

            int N = S.Count();

            int num = 0;

            for(var i = 0; i < N-1; i++)
            {
                if (S[i] == S[i + 1])
                {
                    num++;
                    S[i + 1] = !S[i + 1];
                }
            }

            var ans = Math.Min(N - num, num);

            //ここまで
            Console.WriteLine(ans);
            Console.ReadKey();
        }
    }

    static class Func
    {
        static long mod = 1000000007;
        static public void Swap<T>(ref T a, ref T b) { T temp = a; a = b; b = temp; }
        static public long GCD(long a, long b) { return b != 0 ? GCD(b, a % b) : a; }
        static public long LCM(long a, long b) { return (long)a * b / GCD(a, b); }
        static public int Factorial(int a) { return a == 1 ? a : a * Factorial(a - 1); }


        public static double ToAngle(this double radian)
        {
            return (double)(radian * 180 / Math.PI);
        }

        public static double ToRadian(this double angle)
        {
            return (double)(angle * Math.PI / 180);
        }

        static public long Conbination(int n,int m)
        {
            if (m == 0) return 1;
            if (n == 0) return 0;
            return n * Conbination(n - 1, m - 1) / m;
        }

        static public void Factoring(long num, ref long[] vs)
        {
            if (num == 1)
            {
                vs[1]++;
            }
            for (long i = 2; i < Math.Sqrt(num); i++)
            {
                if (num % i == 0)
                {
                    vs[i]++;
                    Factoring(num / i, ref vs);
                }
            }
            vs[1]++;
        }
    }

    static class IO
    {
        static public string ReadLineToString() { return Console.ReadLine(); }
        static public int ReadLineToInt() { return int.Parse(Console.ReadLine()); }
        static public long ReadLineToLong() { return long.Parse(Console.ReadLine()); }
        static public List<string> ReadLineToStringList() { return Console.ReadLine().Split(' ').ToList(); }
        static public List<int> ReadLineToIntList() { return Console.ReadLine().Split(' ').Select(int.Parse).ToList(); }
        static public List<long> ReadLineToLongList() { return Console.ReadLine().Split(' ').Select(long.Parse).ToList(); }

        static public List<double> ReadLineToDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }

        static public void WriteStrings(object[] strings) { foreach (var o in strings) { Console.Write(o + " "); } }
    }
}

Measured memory_bytes: 13396
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	h := make([]int, n)
	l := make([]int, n)
	for i := 0; i < n; i++ {
		var m int
		fmt.Scan(&m)
		for ; m > 0; m-- {
			var x, y uint
			fmt.Scan(&x, &y)
			x--
			if y == 1 {
				h[i] |= 1 << x
			} else {
				l[i] |= 1 << x
			}
		}
	}

	var ans int
	for i := 0; i < (1 << uint(n)); i++ {
		x, y := i, ^i
		for j := 0; j < n; j++ {
			if i>>uint(j)&1 == 0 {
				continue
			}
			x |= h[j]
			y |= l[j]
		}
		ok := true
		for j := 0; j < n; j++ {
			if x>>uint(j)&1 == 1 && i>>uint(j)&1 == 0 {
				ok = false
			}
			if y>>uint(j)&1 == 1 && i>>uint(j)&1 == 1 {
				ok = false
			}
		}

		if ok {
			var cnt int
			for j := 0; j < n; j++ {
				if i>>uint(j)&1 == 1 {
					cnt++
				}
			}
			if ans < cnt {
				ans = cnt
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] dp = new int[N+1];

    dp[0] = 0;
    for (int n = 1; n <= N; n++) {
      dp[n] = 1 + dp[n-1];
      int power6 = 6;
      while (n >= power6) {
        dp[n] = Math.min(dp[n], 1 + dp[n-power6]);
        power6 *= 6;
      }
      int power9 = 9;
      while (n >= power9) {
        dp[n] = Math.min(dp[n], 1 + dp[n-power9]);
        power9 *= 9;
      }
    }
    System.out.println(dp[N]);
  }
}

Measured memory_bytes: 21844
def main():
    N = int(input())
    A = list(map(int,input().split()))

    count = [0 for i in range(N+1)]

    num = [0 for i in range(N+1)]
    sum_all = 0

    for i in range(N):
        count[A[i]] += 1
    
    for i in range(1,N+1):
        if count[i] >= 2:
            num[i] = int(count[i]*(count[i]-1)/2)
            sum_all += num[i]

    for i in range(0,N):
        ans = sum_all - num[A[i]]
        if count[A[i]]-1 >= 2:
            ans += int((count[A[i]]-1)*(count[A[i]]-2)/2)
        print(ans)

main()

Measured memory_bytes: 88400
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
int main (){
    int a, b;
    cin >> a >> b;
    int max;
    if (a==b)cout << a*2;
    else {
        if (a>b)max = a;
        else max = b;
    cout << max*2-1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
//what the fuck was this question 
#include <bits/stdc++.h> 
#include <boost/math/common_factor.hpp> 
using namespace std;
typedef unsigned long long int ll;
#define f(i,a,b) for(ll i = a; i < b; i++)
 void lcs(string s1,string s2)
 {
     int n = s1.length();
     int m = s2.length();
     set <char> s;
     int dp[n+1][m+1] = {};
     for(int i = 1; i <= n; i++)
     {
         for(int j = 1; j <= m; j++)
         {
             if(s1[i-1] == s2[j-1]){
             dp[i][j] = 1 + dp[i-1][j-1];
             
             }
             else
             dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
             
         }
     }
    cout<< dp[n][m];
 }
 long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

int main() {
       
          
          int k;
          cin>>k;
          int ans = boost::math::lcm(360,k)  ;
          cout<<(ans/k)<<endl;
	return 0;
 
}

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

using namespace std;

#ifndef ONLINE_JUDGE
  #define pr_debug(...) do { printf("DEBUG: line %d: %s: ", __LINE__, __PRETTY_FUNCTION__); printf(__VA_ARGS__); } while(0)
  #define pr_vars(...) do { pr_debug(" "); pr_var(split(#__VA_ARGS__, ',').begin(), __VA_ARGS__); } while(0)
#else
  __attribute__ ((constructor)) static void fast_cin() { ios_base::sync_with_stdio(false); cin.tie(0); }
  #define pr_debug(...) do { } while(0)
  #define pr_vars(...) do { } while(0)
#endif /* ONLINE_JUDGE */

using ll = int64_t;
using ull = uint64_t;
#define X first
#define Y second
#define pb push_back

template<typename T> ostream &operator<< (ostream &fout, const vector<T> &vec)
{ for (const auto &el : vec) fout << el << ' '; return fout; }

template<typename T> istream &operator>> (istream &fin, vector<T> &vec)
{ for (size_t i = 0; i < vec.size(); i++) fin >> vec[i]; return fin; }

vector<string> split(const string &s, char c) { vector<string> v; ull st = 0, fn = 0, lvl = 0;
for ( ; fn < s.size(); fn++ ) { if (s[fn] == c && lvl == 0) { v.push_back(s.substr(st, fn - st)); st = fn + 1; }
if (s[fn] == '(') { lvl++; } if (s[fn] == ')') { lvl--; } } v.push_back(s.substr(st, fn - st)); return v; }

void pr_var(vector<string>::iterator it) { (void) it; cout << endl; }
template<typename T, typename... Args> void pr_var(vector<string>::iterator it, T a, Args... args)
{ cout << *it << "=" << a << "  "; pr_var(++it, args...); }

ll div_ceil(ll n, ll d) { ll res = n / d; if (res >= 0) res += n % d ? 1 : 0; return res; }
ll gcd(ll a, ll b) { a = llabs(a); b = llabs(b); while (a && b) a > b ? a %= b : b %= a; return a + b; }
ll lcm(ll a, ll b) { ll c = gcd(a, b); return c == 0 ? 0 : llabs(a / c * b); }

#define setp(a) fixed << setprecision(a)
const double PI = acos(-1.0);
constexpr double EPS = 1e-9;
constexpr double INF = 2e18;

using mp = pair<ll, ll>;
using mt = tuple<ll, ll, ll>;    // unpack: tie(ll, ll, ll) = mt;

constexpr ll MAX = 1e5 + 5;

char arr[MAX];

int main()
{
    ll n; cin >> n;
    for (ll i = 0; i < n; i++) {
        ll l, r; cin >> l >> r;
        ll sz = r - l + 1;
        memset(arr + l, 1, sz);
    }
    ll res = 0;
    for (ll i = 1; i <= 1e5; i++)
        if (arr[i] == 1)
            res++;
    cout << res << endl;
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> b(n - 1), a(n);
    rep(i, n - 1) cin >> b[i];
    a[0] = b[0];
    for(int i = 0; i < b.size() - 1; i++) {
        a[i + 1] = min(b[i], b[i + 1]);
    }
    a[n - 1] = b[n - 2];
    //rep(i, n) cout << a[i];
    cout << accumulate(a.begin(), a.end(), 0) << endl;
    return 0;
}

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

int main() {
    int a,b;
    cin >> a >> b;
    if(a<b){
        for(int i=0; i<b;i++){
            cout << a;
        }
    }
    else{
          for(int i=0; i<a;i++){
            cout << b;
        }
      
    }
}

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

int main()
{
  int n;
  while (~scanf("%d", &n)) {
    vector<int> g(6, 0);
    for (int i = 0; i < n; ++i) {
      double h;
      scanf("%lf", &h);
      if (h < 165.0)
	++g[0];
      else if (h < 170.0)
	++g[1];
      else if (h < 175.0)
	++g[2];
      else if (h < 180.0)
	++g[3];
      else if (h < 185.0)
	++g[4];
      else
	++g[5];
    }

    for (int i = 0; i < 6; ++i) {
      printf("%d:", i+1);
      for (int j = 0; j < g[i]; ++j)
	printf("*");
      puts("");
    }
  }
  return 0;
}

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

using lint = long long;

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	vector<int> values(n);
	for (int i = 0; i < n; ++i) cin >> values[i];
	vector<int> sorted = values;
	sort(sorted.begin(), sorted.end());
	int dif = 0, ok = 0;
	for (int i = 0; i < n; ++i) {
		if (dif > 2) {
			cout << "NO\n";
			exit(0);
		}
		if (values[i] != sorted[i]) dif++;
	}
	cout << "YES\n";
}



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

#define SIZE 3000000
int prime[SIZE];

int main(){
	for(int i = 0; i < SIZE; i++){
		prime[i] = 1;
	}

	for(int i = 2; i * i < SIZE; i++){
		if(prime[i]){
			for(int j = i + i; j < SIZE; j += i){
				prime[j] = 0;
			}
		}
	}
	int N;
	while(cin >> N, N){
		int cnt = 0;
		for(int i = N + 1; i <= 2 * N; i++){
			cnt += prime[i];
		}
		cout << cnt << endl;
	}
}

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

int N;
int d[100000],list[100000],am[100000][2];

struct abc{
		int a;
		int b;
		long long c;
};
struct abc abc[200000];

int compare_int(const void *a,const void *b){
		struct abc A=*(struct abc*)a,B=*(struct abc*)b;
		return A.a-B.a;
}

int main(){
		int n,i,j;
		scanf("%d",&n);N=2*n-2;
		for(i=0;i<n-1;i++){
				int a,b;
				scanf("%d%d",&a,&b);
				a--,b--;
				abc[i*2].a=a;
				abc[i*2].b=b;
				abc[i*2].c=1;
				abc[i*2+1].b=a;
				abc[i*2+1].a=b;
				abc[i*2+1].c=1;
		}
		qsort(abc,N,sizeof(struct abc),compare_int);
		for(i=1;i<N;i++){
				if(abc[i].a!=abc[i-1].a)list[abc[i].a]=i;
		}
		for(i=0;i<n;i++)d[i]=-1;
		int st=0,fn=2;
		am[0][0]=0,am[0][1]=0;
		am[1][0]=n-1,am[1][1]=1;
		while(fn>st){
				for(j=0;abc[j+list[am[st][0]]].a==am[st][0];j++){
						if(d[abc[j+list[am[st][0]]].b]==-1){
								am[fn][0]=abc[j+list[am[st][0]]].b;
								am[fn][1]=am[st][1];
								d[abc[j+list[am[st][0]]].b]=am[st][1];
								fn++;
						}
				}
				st++;
		}
		int ans=0;
		for(i=0;i<n;i++)ans+=d[i];
		if(ans*2<n)puts("Fennec");
		else if(ans*2==n)puts("Snuke");
		else puts("Snuke");
		return 0;
}


Measured memory_bytes: 7036
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define ll long long
#define endl "\n"
#define print_array(name,n) for(ll o=0;o<n;o++) cout<<name[o]<<" "
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 2e18
#define pll pair<ll,ll>
#define pii pair<int,int>
bool sortbysecond(const pair<int,int> &a,const pair<int,int> &b){
	return (a.ss>b.ss);
}
 
ll gcd(ll a,ll b){ if(b==0) return a; return gcd(b,a%b) ;} 

template <typename T>
string NumberTostring(T Number )
{
	ostringstream ss;
	ss<<Number;
	return ss.str();
}
 

 
int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
 	ll x;
 	cin>>x;
 	if(x>=30){
 		cout<<"Yes"<<endl;
 	}   
 	else{
 		cout<<"No"<<endl;
 	}
    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define VAL 100000
#define ll  long long
#define INF 10000000000000000LL
#define pll pair<long long , long long>
const int MAX=1e6+10;
const ll MOD=1e9+7;
const int TOT_PRIMES=19;
const int MAX_A=70;
using namespace std;
vector<int>adj[MAX];
ll take_p5(ll n){
	return (n*n*n*n*n);
}
int main() 
{
	ll n;
	cin>>n;
	for(ll i=-1000;i<=1000;i++){
		for(ll j=-1000;j<=1000;j++){
			ll p=take_p5(i);
			ll q=take_p5(j);
			if((p-q)==n)
			{
				cout<<i<<" "<<j<<"\n";
				return 0;
			}
		}
	}
}

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

int main() 
{
	ll l , r;
	cin >> l >> r;
	if(r-l>2019)
		cout << 0;
	else
	{
		ll ans = 2019*2019 ;
		for(ll i = l ; i <= r ; i++)
			for(ll j = i+1 ; j <= r ; j++)
				ans = min(ans,((i%2019)*(j%2019))%2019);
		cout << ans;
	}
}

Measured memory_bytes: 256
/*
問題の名称：Reverse Polish Notation
問題のURL：http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_A&lang=jp
所要時間：10分程度
学んだこと：stack
着席位置：中央　中央
*/
#include <iostream>
#include <stack>
#include <string>
using namespace std;
int main()
{
	string word;
	stack<int> S;
	int a,b;
	while(cin >> word)
	{
		if (word == "+")
		{
			a = S.top();
			S.pop();
			b = S.top();
			S.pop();
			S.push(b + a);
		}
		else if (word == "-")
		{
			a = S.top();
			S.pop();
			b = S.top();
			S.pop();
			S.push(b - a);
		}
		else if (word == "*")
		{
			a = S.top();
			S.pop();
			b = S.top();
			S.pop();
			S.push(b * a);
		}
		else
		{
			S.push(stoi(word));
		}
	}

	cout << S.top() << endl;
	return 0;
}


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

int main() {
	long long n, y;
	cin >> n >> y;

	int k = 0;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n - i; j++) {
			k = n - i - j;
			if (1000 * i + 5000 * j + 10000 * k == y) {
				cout << k << " " << j << " " << i << endl;
				return 0;
			}
		}
	}

	cout << "-1 -1 -1\n";

	return 0;
}

Measured memory_bytes: 3628
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <unordered_map>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)

using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
const int MAXN = 2345678;
const LL MOD = (LL)1e9 + 7;
LL fac[MAXN], ifac[MAXN];

LL mul(LL a, LL b) {
    return (a * b) % MOD;
}

LL qpow(LL x, LL n) {
    LL ans = 1, base = x;
    while (n) {
        if (n % 2) ans = mul(ans, base);
        base = mul(base, base);
        n /= 2;
    }
    return ans;
}

LL C(LL n, LL m) {
    if (m > n) return 0;
    return mul(mul(fac[n], ifac[m]), ifac[n - m]);
}

void init() {
    fac[0] = ifac[0] = 1;
    for (int i = 1; i < MAXN; i++)
        fac[i] = mul(fac[i - 1], i);
    ifac[MAXN - 1] = qpow(fac[MAXN - 1], MOD - 2);
    for (int i = MAXN - 2; i >= 1; i--)
        ifac[i] = mul(ifac[i + 1], i + 1);
}

int main() {
    init();
    int K;
    cin >> K;
    string S;
    cin >> S;
    int N = S.length();
    LL ans = 0;
    for (int i = 0; i <= K; i++) {
        LL tmp = mul(qpow(26, i), qpow(25, K - i));
        tmp = mul(tmp, C(N + K - 1 - i, N - 1));
        ans = (ans + tmp) % MOD;
    }
    cout << ans << "\n";

    return 0;
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
by Benq;
*/


Measured memory_bytes: 41908
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<iterator>
#include<stack>
#include<queue>
#include<utility>
#include<functional>
#include<bitset>
#include<numeric>
#include<cstring>
#include<tuple>
using namespace std;

int n, k;
vector< int > arr( 1e5 + 200 ), dp( 1e5 + 200, -1 );

int solve( int j )
{
	if( j > n )
	{
		return 1e9 + 9;
	}
	if( j == n )
	{
		return 0;
	}
	if( dp[ j ] != -1 )
	{
		return dp[ j ];
	}
	dp[ j ] = 1e9 + 2;
	for( int i = 1; i <= k; ++i )
	{
		dp[ j ] = min( dp[ j ], abs( arr[ j ] - arr[ j + i ] ) + solve( j + i ) );
	}
	return dp[ j ];
}

int main( void )
{
	ios :: sync_with_stdio( 0 );
	cin.tie( 0 );
	
	cin >> n >> k;
	for( int i = 1; i <= n; ++i )
	{
		cin >> arr[ i ];		
	}
	cout << solve( 1 ) << "\n";
	return 0;
}


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

ll n, m;

inline ll read(){
	ll s = 0, w = 1;
	char ch = getchar();
	for (; ch < '0' || ch > '9'; ch = getchar()) w *= ch == '-' ? -1 : 1;
	for (; ch >= '0' && ch <= '9'; ch = getchar()) s = s * 10 + ch - '0';
	return s * w;
}

inline void work(){
	n = read(), m = read();
	if (n == 1 || m == 1) puts("1");
	else printf("%lld\n", (n * m + 1) / 2);
}

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

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void) {
	int r,g,b;
	cin >> r >> g >> b;
	if (((100*r)+(10*g)+b)%4 == 0) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
use proconio::{fastout, input};

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[fastout]
fn main() {
    input! {
        v: [usize; 5],
    }

    let mut ans = 0;
    for e in &v {
        ans += e;
        while ans % 10 != 0 {
            ans += 1;
        }
    }
    ans -= v.iter().map(|&e| (10 - (e % 10)) % 10).max().unwrap();
    println!("{}", ans);
}


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

constexpr int INF = 1e9;

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> c(m);
	for (int i = 0; i < m; i++) {
		cin >> c[i];
	}
	
	vector<int> dp(n + 1, INF);
	dp[0] = 0;
	
	for (int e : c) {
		for (int i = 0; i <= n; i++) {
			if (i + e <= n) {
				dp[i + e] = min(dp[i + e], dp[i] + 1);
			}
		}
	}
	
	cout << dp[n] << '\n';
	
	return 0;
}


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

int pow(int a, int b) {
  int c = a;
  for (int i = 1; i < b; i++) {
      c *= a;
  }
  return c;
}

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

  int _max = max(a, max(b, c));
  int restSum = (a + b + c) - _max;

  int ans = _max * pow(2, k) + restSum;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import math
n = int(input())
d, x = map(int, input().split())
a = []
for i in range(n):
    a.append(int(input()))
count_day = [0 for i in range(n)]
for i in range(n):
    count_day[i] = math.ceil(d / a[i])
ans = x + sum(count_day)
print(ans)


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

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> p(n);
  rep(i,n) cin >> p[i];
  sort(p.begin(),p.end());
  int ans=0;
  rep(i,k) ans += p[i];
  cout << ans << endl;
  return 0;
  
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long INF=pow(2,31)-1;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
const int MAX_N=400004;
int dat[MAX_N];
int N;
int size;
int init(){
	size=1;
	while(size<N)size*=2;
	REP(i,size*2)dat[i]=INF;
}
long find(int a,int b,int k=0, int l=0,int r=size){	
	if (r <= a || b <= l) return INF;
    if (a <= l && r <= b) return dat[k];
	long vl=find(a,b,k*2+1,l,(l+r)/2);
	long vr=find(a,b,k*2+2,(l+r)/2,r);
	return min(vl,vr);
}

void update(int k,int x){
	k+=(size-1);//????????????????????????????????????
	dat[k]=x;
	while(k>0){
		k=(k-1)/2;
		dat[k]=min(dat[k*2+1],dat[k*2+2]);
	}
}

int main(){
	int Q;
	cin>>N>>Q;
	init();
	REP(i,Q){
		int c,x,y;
		cin>>c>>x>>y;
		if(c==0){
			update(x,y);
		}else{
			//cout<<find(x,y+1)<<" "<<x<<","<<y<<endl;
			cout<<find(x,y+1)<<endl;
		}
	}
	//cout<<"!"<<dat[0]<<endl;
	//REP(i,2*N-1)cout<<dat[i]<<" ";
	//cout<<endl;
	return 0;
}

/*
4 7
0 0 1
0 1 2
0 2 3
0 3 10
1 0 2
1 1 2
1 2 3
*/

Measured memory_bytes: 2188
#include <stdio.h>

int count[10010];
int main()
{
	int a;
	scanf("%d",&a);
	
	for(int i=1;i<=100;i++)
	{
		for(int j=1;j<=100;j++)
		{
			for(int k=1;k<=100;k++)
			{
				int C = i*i+j*j+k*k+i*j+j*k+k*i;
				if(C<=a) count[C]++;
			}
		}
	}
	for(int i=1;i<=a;i++) printf("%d\n",count[i]);
}

Measured memory_bytes: 1764
#pragma region Include
#include <bits/stdc++.h>
// #include <algorithm>
// #include <bitset>
// #include <climits>
// #include <cmath>
// #include <iostream>
// #include <iterator>
// #include <map>
// #include <queue>
// #include <sstream>
// #include <stack>
// #include <string>
// #include <unordered_map>
// #include <unordered_set>
// #include <vector>
#pragma endregion

using namespace std;

#pragma region Macros
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define all(c) (c).begin(), (c).end()
#define newl "\n"
#define out(x) cout << (x) << newl
#define dump(x) \
  cout << "Line " << __LINE__ << " : " << #x << " = " << (x) << newl
template <class T>
using VV = vector<vector<T>>;
#define Uni(v) (v).erase(unique((v).begin(), (v).end()), (v).end());

template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
  os << "[";
  rep(i, vec.size()) os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  os << "]";
  return os;
}

template <typename T>
ostream& operator<<(ostream& os, vector<vector<T>>& mat) {
  os << "[";
  rep(i, mat.size()) os << mat[i] << (i + 1 == mat.size() ? "" : ",\n ");
  os << "]";
  return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x;
  return is;
}

template <typename V, typename H>
void resize(vector<V>& vec, const H head) {
  vec.resize(head);
}

template <typename V, typename H, typename... T>
void resize(vector<V>& vec, const H& head, const T... tail) {
  vec.resize(head);
  for (auto& v : vec) resize(v, tail...);
}
constexpr double EPS = 1e-10;
const int INF = 0x3f3f3f3f;

string tostring(int i, int digit) {
  auto cur = cout.flags();
  stringstream ss;
  ss << setw(4) << setfill('0') << i;
  string ret = ss.str();
  cout.flags(cur);
  return ret;
}

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

#pragma endregion

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll H;
  cin >> H;
  ll cnt = 0;
  while (H > 0) {
    cnt++;
    H /= 2;
  }
  ll ans = 1;
  rep(i, cnt) { ans *= 2; }
  out(ans - 1);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    string s;
    cin >> s;
    vector<int> divnum(4);
    rep(i, 4) {
        divnum[i] = s[i] - '0';
    }

    rep(i, 1<<3) {
        int tmp_ans = divnum[0];
        string ans = "";
        ans += (char)(divnum[0] + '0');
        for ( int j = 1; j <= 3; ++j ) {
            if ( (i>>(j-1))&1 ) {
                tmp_ans += divnum[j];
                ans += "+";
                ans += (char)(divnum[j]+'0');
            }
            else {
                tmp_ans -= divnum[j];
                ans += "-";
                ans += (char)(divnum[j]+'0');
            }
        }
//        cout << i << " " << ans << endl;
        if ( tmp_ans == 7 ) {
            cout << ans + "=7" << endl;
            return 0;
        }
    } 
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <sstream>

#define DEBUG 0
#define fi first
#define se second
#define pb push_back
#define fore(i,a,b) for (int i = (a), _b = (b); i < (_b); ++i)
#define fort(i,a,b) for (int i = (a), _b = (b); i <= (_b); ++i)
#define ford(i,a,b) for (int i = (a), _b = (b); i >= (_b); --i)

using namespace std;

typedef long long LL;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int INF = 1e9 + 3;
const int MOD = 1e9 + 7;
const int N = 2003;

int n;
LL k;
int a[N];

int main() {
    if (DEBUG) {
        freopen("CP.inp", "r", stdin);
        //freopen("CP.out", "w", stdout);
    }
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n >> k;
    fort(i, 1, n) cin >> a[i];
    LL cnt1 = 0;
    fort(i, 1, n) fore(j, 1, i) if (a[j] > a[i]) ++cnt1;
    cnt1 %= MOD;
    LL cnt2 = 0, cnt3 = 0;
    fort(i, 1, n) fort(j, 1, n) if (a[j] > a[i]) ++cnt2;
    cnt2 %= MOD;
    fort(i, 1, k) cnt3 += i - 1;
    cnt3 %= MOD;
    cout << (cnt1 * k + cnt2 * cnt3) % MOD << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,i;
  cin >>A>>B;
  for (;A<=B;A++){
    
    int C,D;
    C=((A/1000)%10)*10+A/10000;
    D=A%100;
    if (C==D)
      i++;
  }
  cout<<i<<endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    a=LI()+[10**10]
    ans=0
    now=-1
    cnt=0
    for i in range(N+1):
        if a[i]>now:
            ans=max(ans,cnt)
            cnt=0
        else:
            cnt+=1
        now=a[i]
        
    print(ans)
        

main()


Measured memory_bytes: 86160
n=int(input())
s=input()
ans=0
for i in range(n):
  a=set(s[:i])
  b=set(s[i:])
  A=list(a)
  B=list(b)
  count=0
  for j in range(len(a)):
    if A[j] in B:
      count+=1
  ans=max(ans,count)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <ios>
#include <sstream>
#include <cstdio>

#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <regex>
#include <utility>
#include <random>

#include <cstddef>
#include <cstdint>
#include <cfloat>
#include <limits>

#include <array>
#include <bitset>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <valarray>
#include <vector>
#include <deque>
#include <forward_list>

#define FOR(i, a, b) for(auto i{a}; i < (b); ++i)
#define RFOR(i, a, b) for(auto i{(b)-1};i >= (a); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(a) std::begin(a), std::end(a)
#define CAST static_cast

template<typename T>
constexpr bool in_range(T const &l, T const &a, T const &u){ return l < a && a < u; };
constexpr double inf {std::numeric_limits<double>::infinity()};

#define FAST_TYPE
#ifdef FAST_TYPE
using i32 = std::int_fast32_t;  using i64 = std::int_fast64_t;
using u32 = std::uint_fast32_t; using u64 = std::uint_fast64_t;
#else
using i32 = std::int_least32_t;  using i64 = std::int_least64_t;
using u32 = std::uint_least32_t; using u64 = std::uint_least64_t;
#endif

using imx = std::intmax_t;
using umx = std::uintmax_t;

using namespace std;

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

  i32 ab, bc, ca;

  cin >> ab >> bc >> ca;

  cout << min(ab + bc, min(bc + ca, ca + ab)) << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)

int main() {
  cin.tie(0); ios_base::sync_with_stdio(false);
  int n; cin >> n; 
  vector<int> s(1<<n); REP(i, 1<<n) cin >> s[i];
  sort(s.begin(), s.end());

  vector<int> exist;
  exist.push_back(s.back());
  s.back() = -1;
  REP(i, n) {
    vector<int> tmp = exist;
    sort(tmp.begin(), tmp.end());
    int sidx = (1<<n)-1;
    while(tmp.size() && sidx >= 0) {
      if(s[sidx] == -1) { --sidx; continue; }
      if(tmp.back() > s[sidx]) {
        exist.push_back(s[sidx]);
        tmp.pop_back();
        s[sidx] = -1;
      }
      --sidx;
    }
    if(tmp.size()) {
      cout << "No";
      return 0;
    }
  }

  cout << "Yes";
  return 0;
}

Measured memory_bytes: 2932
#include <bits/stdc++.h>
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;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
#define bv vector<bool>
using namespace std;
typedef pair<int, int> pii;
#define MAX 99999999
vector<vector<char> > v(2000,vc(2000));
vector<pii>u(1000);
int mx[]={0,0,1,-1};
int my[]={1,-1,0,0};
int h,w,n;
int bfs(pii st,pii g){
    queue<pii>que;
    vvi d(2000,vi(2000,INF));
    que.push(st);
    d[st.first][st.second]=0;
    while(!que.empty()){
        pii p=que.front(); que.pop();
        if(p==g)break;
        rep(i,4){
            int ny=p.first+my[i]; int nx=p.second+mx[i];
            pii np=pii(ny,nx);
            if(0<=ny&&ny<h&&0<=nx&&nx<w&&d[ny][nx]==INF&&v[ny][nx]!='X')
            {
                d[ny][nx]=d[p.first][p.second]+1;
                que.push(np);
            }
        }
    }
    return d[g.first][g.second];
}
int main(){
    pii st;
    cin>>h>>w>>n;
    int ans=0;
    rep(i,h)rep(j,w){
        cin>>v[i][j];
        if(v[i][j]=='S')st=pii(i,j);
            else if(v[i][j]!='X'&&v[i][j]!='.'){
            u[(v[i][j]-48)]=pii(i,j);
            //cout<<v[i][j]-48<<endl;
        }
    }
    u[0]=st;
    for(int i=0;i<n;i++){
        ans+=bfs(u[i],u[i+1]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 22680
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int l[] = new int[N];
    int r[] = new int[N];
    int ans = 0;
    for(int i=0;i<N;i++){
      l[i] = sc.nextInt();
      r[i] = sc.nextInt();
    }
    for(int i=0;i<N;i++){
      ans += r[i] - l[i] + 1;
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 25424
import itertools
import sys
from scipy.sparse.csgraph import csgraph_from_dense
from scipy.sparse.csgraph import dijkstra
input = sys.stdin.readline


n, m, r = map(int, input().split())
visiting_town = list(map(int, input().split()))
edges = [[float('INF')]*n for _ in range(n)]

for i in range(m):
    a, b, c = map(int, input().split())
    edges[a-1][b-1] = c

G = csgraph_from_dense(edges, null_value=float('INF'))
comp_dist = dijkstra(G, directed=False)

candidates = []
for route in itertools.permutations(visiting_town):
    result = 0
    for _from, to in zip(route[:-1], route[1:]):
        dist = comp_dist[_from-1][to-1]
        result += dist
    candidates.append(result)

print(int(min(candidates)))


Measured memory_bytes: 22272
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	int h, w, x, y; scanf("%d%d%d%d", &h, &w, &x, &y);
	
	if((h * w) & (x + y) & 1) printf("No\n");
	else printf("Yes\n");
	return 0;
}



Measured memory_bytes: 3132