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

int main(){
  int n;
  cin >> n;
  
  map<int, int> mp;
  
  //n!の約数をmp[約数][個数]に記憶。
  for(int i=1; i<=n; i++){
    int k = i;
    for(int j=2; j<=i; j++){
      while((k % j == 0) && k >= j){
        mp[j]++;
        k /= j;
      }
      if(k == 1) break;
    }
  }
    
  int mt74 = 0;
  int mt24 = 0;
  int mt14 = 0;
  int mt4 = 0;
  int mt2 = 0;

  for(int i=1; i<=n; i++){
    if(mp[i] >= 74) mt74++;
    else if(mp[i] >= 24) mt24++;
    else if(mp[i] >= 14) mt14++;
    else if(mp[i] >= 4)  mt4++;
    else if(mp[i] >= 2) mt2++;
  }
  
  int ans = mt74 + (mt74 + mt24) * (max(mt74+mt24-1, 0) + mt14 + mt4 + mt2) + (mt74+mt24+mt14) * (max(mt74+mt24+mt14-1,0) + mt4) + (mt74 + mt24 + mt14 + mt4) * max(mt74 + mt24 + mt14 + mt4 - 1, 0) / 2 * (max(mt74 + mt24 + mt14 + mt4 - 2, 0) + mt2);
  cout << ans << endl;
}

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

using namespace std;

vector<int> v;

void push(int n){
    for(int i=0; i< n; i++){
        int h, m;
        cin >> h >> m;
        bool is = true;
        for(int j=0; j< v.size(); j++) if(v[j] == h*60+m) is = false;
        if(is)v.push_back(h*60+m);
    }
}

int main(){
    int n;
    cin >> n;
    push(n);
    cin >> n;
    push(n);
    sort(v.begin(), v.end());
    for(int i=0; i< v.size(); i++){
        cout << (i==0?"": " ");
        printf("%d:%02d", v[i]/60, v[i]%60);
    }
    cout << endl;
}

Measured memory_bytes: 1252
#include<iostream>
#include<vector>
#include<set>
#include<algorithm>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<iomanip>
#include<fstream>
using namespace std;
typedef long long ll;
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main()
{
	fast_io;
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	string s, t;
	cin >> s;
	cin >> t;

	int c = 0;
	for (ll i = 0; i < s.size(); i++)
	{
		if (s[i] != t[i])
		{
			c++;
		}
	}

	cout << c << endl;

	return 0;
}

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

int operate[25];
int main()
{
	int n;
	while(cin >> n){
		if(!n)
			break;
		int m = 31;
		for(int i=0;i<n;i++){
			cin >> operate[i];
		}
		int pos = 0;
		while(m>0){
			m -= (m-1)%5;
			if(m<=0)
				break;
			cout << m << endl;
			m -= operate[pos];
			if(m<=0)
				break;
			cout << m << endl;
			pos++;
			if(pos==n)
				pos = 0;
		}
		cout << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 0
//#pragma optimization_level 3
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define ms multiset
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("sumsqr.in");ofstream out("sumsqr.out");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); //uid<int> u1(5, 10); u1(rnd);

int main() {
    fast;
    int a; cin>>a;
    int fl = 1;
    for(int q=0; q<a; q++){
        int x; cin>>x;
        if(x%2==0) fl &= x%3==0 || x%5==0;
    }
    cout<<(fl  ?"APPROVED" : "DENIED");
}

Measured memory_bytes: 256
def main():
    N, K = map(int, input().split())
    a = list(map(int, input().split()))
    a.sort()
    dp = [False] * (K+1)
    for i in range(K+1):
        for hop in a:
            if i - hop >= 0:
                if dp[i - hop] is False:
                    dp[i] = True
                    break
    if dp[-1]:
        print("First")
    else:
        print("Second")


if __name__ == "__main__":
    main()


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


int main() {
    int A, B; cin >> A >> B;
    if (A >= 13) {
        cout << B << endl;
    } else if (A <= 5) {
        cout << 0 << endl;
    } else {
        cout << B / 2 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

class Solver{
	Scanner sc =new Scanner(System.in);
	
	void run(){
		
		int n = sc.nextInt();
		long sum[] = new long[n+1];
		
		for(int i = 0; i < n ; i++){
			sum[i+1] = sc.nextInt() + sum[i];
		}
		
		
		Map<Long, Integer> map = new HashMap<Long,Integer>();
		
		for(int i =0 ; i< n+1 ; i++){
			int value = map.getOrDefault(sum[i], 0);
			map.put(sum[i], value+1);
		}
		
		BigInteger res = BigInteger.valueOf(0);
		
		for(long value : map.values()){
			res = res.add(BigInteger.valueOf(value*(value-1)/2)); 
		}
		System.out.println(res);
	}
	
}

public class Main {
	public static void main(String[] args){
		Solver s  = new Solver();
		s.run();
	}
}


Measured memory_bytes: 92084
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main(){
	int N; 
	cin >> N; 
	long long int A[100010] = {}; 
	for(int i = 1; i <= N; i++){
		cin >> A[i]; 
	}
	long long int ans = 0; 
	for(int i = 1; i <= N; i++){
		if(A[i] > 0 && A[i-1] > 0){
			ans ++; 
			A[i] --; 
		}
		ans += A[i] / 2; 
		A[i] = A[i] % 2;
	}
	cout << ans << endl; 
}

Measured memory_bytes: 1024
#include <stdio.h>

int isLeap(int year){
	return (year % 400 == 0 || year % 100 != 0 && year % 4 == 0);
}

int main(void)
{
	int first, last;
	int year_it;
	int separate_flag = 0;
	int na_flag;

	while (scanf("%d %d", &first, &last), first || last){
		if (separate_flag == 0){
			separate_flag = 1;
		}
		else {
			puts("");
		}

		na_flag = 1;
		for (year_it = first; year_it <= last; year_it++){
			if (isLeap(year_it)){
				na_flag = 0;
				printf("%d\n", year_it);
			}
		}
		if (na_flag){
			puts("NA");
		}
	}

	return (0);
}

Measured memory_bytes: 612
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var s = ReadLine();

            var a = new long[s.Length + 1];

            for (int i = 0; i < s.Length; i++)
            {
                if (s[i] == '<')
                    a[i + 1] = a[i] + 1;
            }
            for (int i = s.Length - 1; i >= 0; i--)
            {
                if (s[i] == '>')
                    a[i] = Max(a[i + 1] + 1, a[i]);
            }
            WriteLine(a.Sum());

            //IO.OutJoinSpace(a);
        }
    }

    public class IO
    {
        #region Input
        public static int RInt => int.Parse(ReadLine());
        public static long RLong => long.Parse(ReadLine());
        public static double RDouble => double.Parse(ReadLine());

        public static string[] RSString => ReadLine().Split();
        public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
        public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
        #endregion
    }

    public class Mod
    {
        #region
        private readonly static long M = 1000000007;

        public static long Add(long a, long b) => (a * b) % M;
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        public static long Multi(long a, long b) => (a * b) % M;
        #endregion
    }
}

Measured memory_bytes: 23532
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	string ans = "APPROVED";
	rep(i, n){
		if(a[i]%2 == 0){
			if(a[i]%3 != 0 && a[i]%5 != 0){
				ans = "DENIED";
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>

template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr istream &operator >> (istream &is, const Fp<MOD>& a) noexcept {
        long long t;
        is >> t;
        a = Fp<MOD>(t);
        return (is);
    }
    // 指数関数 O(logN)
    friend constexpr Fp<MOD> mpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = mpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
    
};

const int MOD = 1000000007;
using mint = Fp<MOD>;

// 指数関数の計算、O(log(n))
mint modpow(long long x, long long n){
    mint ret = x;
    return mpow(ret,n);
}

// 二項係数の計算、O(min(k,n-k))
mint binomial(long long n, long long k){
    if(k < 0 || n < k) return 0;
    if (n-k < k) return binomial(n,n-k);
    mint ret = 1;
    for(long long i = 1; i <= k; ++i) {
        mint tmp = i;
        ret *= n--;
        ret /= tmp;
    }
    return ret;
}
int main(){
  int X, Y; cin >> X >> Y;
  ll n = (X+Y)/3;
  if ((X+Y)%3==0 && n<=X && X<=2*n) {
    ll j = Y-n;
    mint ans = binomial(n,j);
    cout << ans << endl;

  }
  else cout << 0 << endl;


  // cout << fixed << setprecision(10);
  
  return 0;
}


Measured memory_bytes: 3656
"use strict";

const main = arg => {

    const input = arg.trim().split(" ")

    const N = parseInt(input[0])
    const M = parseInt(input[1])

    console.log(N * (N - 1) / 2 + M * (M - 1) / 2)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));  


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

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

using namespace std;
using ll = long long;

int main(void)
{
  string s;
  ll k;
  cin >> s >> k;
  char res = '1';
  for (int i = 0; i < min((ll)s.size(), k); ++i) {
    if (s[i] != '1') {
      res = s[i];
      break;
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
char c[100005];
int ans;
int main(){
	scanf("%s",c);
	int l=strlen(c);
	for(int i=1;i<l;++i)
		if(c[i]!=c[i-1])
			++ans;
	printf("%d\n",ans); 
	return 0;
}

Measured memory_bytes: 384
yen_500_count = gets.to_i
yen_100_count = gets.to_i
yen_50_count = gets.to_i
sum = gets.to_i
count = 0

for i in 0..yen_500_count do
  for j in 0..yen_100_count do
    for k in 0..yen_50_count do
      count += 1 if i * 500 + j * 100 + k * 50 == sum
    end
  end
end

p count


Measured memory_bytes: 3836
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
using namespace std;


typedef long long ll;
int n;

ll a[100010];

ll imos[100010];


ll solve(int start)
{
	int sign = start;
	ll change = 0;
	ll res = 0;
	for(int i = 1;i <= n;i++)
	{
		ll x = imos[i] + change;

		if(x * sign <= 0)
		{
			res += abs(x) + 1;
			change += -x + sign;
		}
		sign *= -1;
	}
	return res;
}


		

int main()
{
	cin >> n;

	for(int i = 1;i <= n;i++)
	{
		cin >> a[i];
		imos[i] += imos[i - 1] + a[i];
	}

	cout << min(solve(1) , solve(-1)) << endl;
	return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<iomanip>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (2e9)
// cout << setprecision(10)

using namespace std;
typedef long long int ll;

double A, B, C, D;
int main(void){
    cin >> A >> B >> C >> D;
    int T1 = ceil(C/B);
    int T2 = ceil(A/D);
    if(T1 <= T2) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}



Measured memory_bytes: 3724
#--d--#
import sys,math,collections,itertools
input = sys.stdin.readline

def solve(i):#-スタートする番号-#
    visit = set([i])
    tmp = [] #訪れた場所から飛ぶ時の得点
    #tmp_sum = [] #得点の累積和
    while True:
        tmp.append(C[i-1])
        next_point = P[i-1]
        if next_point not in visit:
            visit |=set([next_point])
            i = next_point
        else:
            break
    roopLength = len(tmp)
    roop_sum = sum(tmp)
    cum_sum = list(itertools.accumulate(tmp))
    #print(roopLength,tmp,list(cum_sum))
    #print(visit)
    #-もしループで負になるなら、roopLength or Kの小さいほうの中でcum_sumの大きいもの
    if roop_sum <=0:
        ans = -float('inf')
        for i in range(min(K,roopLength)):
            ans = max(ans,cum_sum[i])
    #ループ長さｘ２がKよりおおきいなら、Kまで足し上げる
    elif roopLength * 2 >=K:
        point = 0
        ans = -float('inf')
        for i in range(K):
            point +=  tmp[i%roopLength]
            ans = max(ans,point)
    #ループ長さｘ２がKみ満たないなら、２週分残したとこまでループさせて、足し上げる
    elif roopLength *2 < K:
        point = roop_sum*(K//roopLength-1)
        ans = -float('inf')
        for i in range(roopLength+K%roopLength):
            point += tmp[i%roopLength]
            ans = max(ans,point)
    return ans


N,K=list(map(int,input().split()))
P=list(map(int,input().split()))
C=list(map(int,input().split()))
ans = -float('inf')
for i in range(N):
    point = solve(i+1)
    ans = max(point,ans)
print(ans)
    



Measured memory_bytes: 219988
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>
#include <stack>
#define inf 1e9+7
#define pb push_back
#define make make_pair
#define kaku(a) cout << a << endl;
 
using namespace std;
 
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define PI 3.14159265359
long long gcd(long long a,long long b){ return b==0?a:gcd(b,a%b);}
long long lcm(long long a,long long b){ return a/gcd(a,b)*b;}
 
typedef pair<ll,ll> Pair;
 
int main(){
    ll n,m ;
    cin >> n >> m;
    vector<ll> g[n];
    rep(i,m){
        ll a,b;
        cin >> a >> b;
        a--;b--;
        g[a].pb(b);
    }
    ll d[n][3];
    rep(i,n) rep(j,3) {
        d[i][j]=inf;
    }
    queue<Pair> que;//頂点とどの段階か
    ll s,t;
    cin >> s >> t;
    s--;t--;
    d[s][0]=0;
    que.push(make(s,0));
    while(!que.empty()){
        Pair ima=que.front();
        que.pop();
        for(ll b : g[ima.first]){
            ll modit=(ima.second+1)%3;
            ll a=ima.second%3;
            if(d[b][modit]!=inf) continue;
            else{
                d[b][modit]=d[ima.first][a]+1;
                que.push(make(b,ima.second+1));
            }
        }
    }
    if(d[t][0]==inf) {kaku(-1);}
    else{kaku(d[t][0]/3);}
}



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

int main() {
  int N,t,f;
  cin >> N;
  t = N, f = 0;
  while(t > 0) {
    f += t % 10;
    t /= 10;
  }
  if(N % f == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
template <typename T>
inline void readin(T &x) {
	x = 0;
	T fh = 1;
	char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fh = -1;
	for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ 48);
	x *= fh;
}
inline void d_read(double &x) {
	x = 0.0;
	int fh = 1;
	char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fh = -1;
	for (; isdigit(ch); ch = getchar()) x = x * 10 + (ch ^ 48);
	if (ch == '.') {
		double num = 1.0;
		ch = getchar();
		for (; isdigit(ch); ch = getchar()) x = x + (num /= 10) * (ch ^ 48);
	}
	x *= fh;
}

template <typename T>
inline void wt(T x) {
	if (x > 9) wt(x / 10);
	putchar(x % 10 + 48);
}
template <typename T>
inline void writeln(T x, char c) {
	if (x < 0) {
		putchar('-');
		x = -x;
	}
	wt(x);
	putchar(c);
}

int main() {
	int n, ans = 0;
	long long d;
	readin(n);
	readin(d);
	for (int i = 1; i <= n; i ++) {
		long long x, y;
		readin(x); readin(y);
		if (x * x + y * y <= d * d) ans ++;
	}
	writeln(ans, '\n');
	return 0;
}




Measured memory_bytes: 3620
/***
 *      __  __            _    _       _
 *     |  \/  |          | |  | |     | |
 *     | \  / |_ __      | |  | |_ __ | | ___ __   _____      ___ __
 *     | |\/| | '__|     | |  | | '_ \| |/ / '_ \ / _ \ \ /\ / / '_ \
 *     | |  | | |     _  | |__| | | | |   <| | | | (_) \ V  V /| | | |
 *     |_|  |_|_|    (_)  \____/|_| |_|_|\_\_| |_|\___/ \_/\_/ |_| |_|
 *
 *
***/
#include<stdio.h>
//#include<bits/stdc++.h>
//using namespace std;
//#define ll long long
//#define f(i,a,b) for (int i=a;i<=b;i++)
//#define f_(i,a,b) for (int i=a;i>=b;i--)
//#define MP make_pair
//#define ii pair<int,int>
//#define iii pair<int,ii>
//const ll mod=1000000007;

int n,p[25],dem=0;
int main() {
//	freopen("","r",stdin);
//	freopen("","w",stdout);
	scanf("%d", &n);
	for (int i=1;i<=n;i++) scanf("%d", &p[i]);
	for (int i=2;i<n;i++) if (((p[i]<=p[i-1]&&p[i]>=p[i+1]))||((p[i]<=p[i+1]&&p[i]>=p[i-1]))) dem++;
	printf("%d", dem);
	return 0;
}

Measured memory_bytes: 128
N, W = [int(_) for _ in input().split()]
WV = [[int(_) for _ in input().split()] for i in range(N)]

from collections import defaultdict
from itertools import accumulate

cs = defaultdict(list)

for w, v in WV:
    cs[w].append(v)

minw = min(cs.keys())

for k in range(minw, minw+4):
    cs[k] = [0] + list(accumulate(sorted(cs[k], reverse=True)))

result = 0

for w0, t0 in enumerate(cs[minw]):
    for w1, t1 in enumerate(cs[minw+1]):
        tw1 = w0 * minw + w1 * (minw+1)
        tv1 = t0 + t1
        if tw1 > W:
            break
        for w2, t2 in enumerate(cs[minw+2]):
            tw2 = tw1 + w2 * (minw+2)
            tv2 = tv1 + t2
            if tw2 > W:
                break
            for w3, t3 in enumerate(cs[minw+3]):
                tw3 = tw2 + w3 * (minw+3)
                tv3 = tv2 + t3
                if tw3 > W:
                    break
                result = max(result, tv3)

print(result)


Measured memory_bytes: 3372
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
	int n,sum=0;
	scanf("%d",&n);
	int l,r;
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&l,&r);
		sum+=r-l+1;
	}
	printf("%d",sum);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};


int main() {

	int h,w;
	char chr[51][51];
	int o=0,t=0;
	int c[51][51]={};

	cin>>h>>w;

	rep(i,h){
		rep(j,w){
			cin>>chr[i][j];
			if(chr[i][j]=='#'){
				o++;
			}
		}
	}
	rep(i,h){
		rep(j,w){
			if(chr[i][j]=='#'){
				if(chr[i][j+1]=='#'){
					c[i][j]=1;
					c[i][j+1]=1;
				}
			}
			if(chr[i][j]=='#'){
				if(chr[i+1][j]=='#'){
					c[i][j]=1;
					c[i+1][j]=1;
				}
			}

		}
	}
	rep(i,h){
		rep(j,w){
			t+=c[i][j];
		}
	}
	if(o==t){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}

	return 0;
}


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

int main() {
  ios::sync_with_stdio(false);

  int N, M, K;
  cin >> N >> M >> K;

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

  vector<int> B(M);
  for (int i = 0; i < M; ++i) cin >> B[i];

  vector<int64_t> sa(N + 1);
  for (int i = 0; i < N; ++i) sa[i + 1] = sa[i] + A[i];

  vector<int64_t> sb(M + 1);
  for (int i = 0; i < M; ++i) sb[i + 1] = sb[i] + B[i];

  int res = 0;

  for (int i = 0, j = M; i <= N; ++i) {
    while (j && sa[i] + sb[j] > K) --j;
    if (sa[i] + sb[j] <= K) res = max(res, i + j);
  }

  cout << res << endl;

  return 0;
}



Measured memory_bytes: 7936
n, k = map(int, input().split())
x = list(map(int, input().split()))
ans=4*10**8
for i in range(n-k+1):
    diff = x[i+k-1]-x[i]
    ans = min(abs(x[i])+diff, abs(x[i+k-1])+diff, ans)
print(ans)

Measured memory_bytes: 15020
#include <iostream>
#include <bits/stdc++.h>
#include <string>

using namespace std;

int abcdefg(int a, int b, int c) {
    return  __gcd(__gcd(a,b),c);
}
int main()
{
    int count = 0;
    unsigned long long sum = 0LL;

    cin >> count;

    int i,j,k = 0;

    for(i=1;i<=count;i++){
        for(j=1;j<=count;j++){
            for(k=1;k<=count;k++){
                sum += (long long)abcdefg(i,j,k);
            }
        }
    }


    cout<<sum<<endl;



    return 0;
}


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

int n,a[100009],b[100009],c1,c2,cntw,col[100009];vector<int>x,y,X[100009];

void dfs(int pos){
	if(col[pos]>=1) return;
	col[pos]=cntw;
	for(int i=0;i<X[pos].size();i++) dfs(X[pos][i]);
}

int main(){
	cin>>n;
	for(int i=1;i<=n;i++){cin>>a[i];c1^=a[i];x.push_back(a[i]);} x.push_back(c1);
	for(int i=1;i<=n;i++){cin>>b[i];c2^=b[i];y.push_back(b[i]);} y.push_back(c2);
	sort(x.begin(),x.end());
	sort(y.begin(),y.end());
	if(x!=y){cout<<"-1"<<endl;return 0;}
	
	x.erase(unique(x.begin(),x.end()),x.end());
	y.erase(unique(y.begin(),y.end()),y.end());
	
	int cnt=0;for(int i=1;i<=n;i++){if(a[i]!=b[i]){cnt++;}}
	
	for(int i=1;i<=n;i++){
		a[i]=lower_bound(x.begin(),x.end(),a[i])-x.begin();
		b[i]=lower_bound(y.begin(),y.end(),b[i])-y.begin();
		if(a[i]!=b[i]){
			X[a[i]].push_back(b[i]);
			X[b[i]].push_back(a[i]);
		}
	}
	c1=lower_bound(x.begin(),x.end(),c1)-x.begin();
	c2=lower_bound(y.begin(),y.end(),c2)-y.begin();
	if(c1!=c2){
		X[c1].push_back(c2);
		X[c2].push_back(c1);
	}
	else{
		bool flag=false;
		for(int i=1;i<=n;i++){
			if(a[i]!=b[i] && b[i]==c1) flag=true;
		}
		if(flag==false) cntw++;
	}
	for(int i=0;i<x.size();i++){
		if(col[i]>=1 || X[i].size()==0) continue;
		cntw++;dfs(i);
	}
	if(cnt==0) cout<<"0"<<endl;
	else cout<<cnt+cntw-1<<endl;
	return 0;
}


Measured memory_bytes: 10744
#include <algorithm>
#include <cmath>
#include <iostream>
#include <queue>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;

#define INF (1e15)

int N;

int main() {
    cin >> N;

    vi A(3 * N);
    for (int i = 0; i < 3 * N; i++) {
        cin >> A[i];
    }

    vi L(N + 1);  // L[i] : A[0=<x<N+i]の中からN個選んだときの総和の最大値
    priority_queue<ll, vector<ll>, greater<ll> > queL;
    for (int i = 0; i < N; i++) {
        L[0] += A[i];
        queL.push(A[i]);
    }
    for (int i = 0; i < N; i++) {
        queL.push(A[N + i]);
        L[i + 1] = L[i] + A[N + i] - queL.top();
        queL.pop();
    }

    vi R(N + 1);  // R[i] : A[2N-i=<x<3N]の中からN個選んだときの総和の最小値
    priority_queue<ll, vector<ll>, less<ll> > queR;
    for (int i = 0; i < N; i++) {
        queR.push(A[3 * N - 1 - i]);
        R[0] += A[3 * N - 1 - i];
    }
    for (int i = 0; i < N; i++) {
        queR.push(A[2 * N - 1 - i]);
        R[i + 1] = R[i] + A[2 * N - 1 - i] - queR.top();
        queR.pop();
    }

    ll ans = -INF;
    for (int i = 0; i <= N; i++) {
        ans = max(ans, L[i] - R[N - i]);
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6516
#include<iostream>
using namespace std;
int main(){
  int S;
  cin>>S;
  int le=S/100,ri=S%100;
  if(1<=le && le<=12){
    if(1<=ri && ri<=12){
      cout<<"AMBIGUOUS"<<endl;
    }
    else{
      cout<<"MMYY"<<endl;
    }
  }
  else if(1<=ri && ri<=12){
    cout<<"YYMM"<<endl;
  }
  else{
    cout<<"NA"<<endl;
  }
  return 0;
}

  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s, t; cin >> s >> t;
    string ss = s + s;
    vector<int> v[26];
    for (int i = 0; i < ss.size(); i++) {
        v[ss[i]-'a'].emplace_back(i);
    }
    if (v[t[0]-'a'].empty()) {
        cout << -1 << endl;
        return 0;
    }
    long long curr = v[t[0]-'a'][0];
    if (t.size() == 1) {
        cout << curr+1 << endl;
        return 0;
    }
    for (int i = 1; i < t.size(); i++) {
        int c = t[i] - 'a';
        int x = curr % s.size();
        if (v[c].empty()) {
            cout << -1 << endl;
            return 0;
        }
        int next = *upper_bound(v[c].begin(), v[c].end(), x);
        curr += next - x;
    }
    cout << curr+1 << endl;
    return 0;
}

Measured memory_bytes: 1980
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define LL long long
#define Inf 2e9
#define fcl fclose(stdin);fclose(stdout);
const int maxn=1010;
int A,B,C; 
void Init();
int main(){
    Init();
    getchar();getchar();
    return 0;
}
void Init(){
	scanf("%d%d%d",&A,&B,&C);
	int num=0;
	bool flag=false;
	while(num<=100000000){
		if(A&1 || B&1 || C&1) {flag=true;break;}
		int x=A,y=B,z=C;
		A=0;B=0;C=0;
		A+=(y>>1)+(z>>1);
		B+=(x>>1)+(z>>1);
		C+=(x>>1)+(y>>1);
		num++;
	}
	if(flag) printf("%d\n",num);
	else puts("-1");
}


Measured memory_bytes: 384
from sys import exit, setrecursionlimit
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

(A, B, C, X, Y) = reads()

ans = 0

if A + B >= 2 * C:
  Z = min(X, Y)
  X, Y = X - Z, Y - Z
  ans += C * 2 * Z
  ans += min(A, 2 * C) * X
  ans += min(B, 2 * C) * Y
else:
  ans = A * X + B * Y

print(ans)


Measured memory_bytes: 3828
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <map>

using namespace std;

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <int, pii> piii;

#define F first
#define S second
#define mkp make_pair
#define pb push_back
#define ppb pop_back
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define show(x) cerr << "# " << #x << " = " << (x) << endl
//#define int ll

const int N = 2e6 + 1;
const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int szT = (1 << 17) - 1;
const double PI = acos(-1.0);
const int dx[] = {0,0,1,-1};
const int dy[] = {1,-1,0,0};

int a, b, c;

int main () {
//    freopen(".in", "r", stdin);
//    freopen(".out", "w", stdout);
    ios_base :: sync_with_stdio(0);
    cin >> a >> b >> c;
    int x = (a * 100) + (b * 10) + c;
    if (x % 4 == 0)
        cout << "YES";
    else
        cout << "NO";
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <string>

using namespace std;

#define LL long long

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

class edge {
public:
	int t, nxt;
	edge(int _t, int _nxt) {
		t = _t;
		nxt = _nxt;
	}
};

vector<edge> edges;
int e = 0;
int *d;
int n;
int *h, *mh;
int *f;

void add_edge(int s, int t) {
	edges.push_back(edge(t, d[s]));
	d[s] = e++;
}

void dfs(int x) {
	//cout << "dfs " << x << endl;
	mh[x] = 0;
	for (int p = d[x]; p != -1; p = edges[p].nxt) {
		int t = edges[p].t;
		if (h[t] == -1) {
			h[t] = h[x] + 1;
			f[t] = x;
			dfs(t);
			mh[x] = max(mh[x], mh[t] + 1);
		}
	}
}

int get_ans(int d, int emp) {
	if (d <= 0) {
		return 0;
	}
	return emp + d - 1;
}

int main() {
	int n, a, b, s, t;
	cin >> n >> a >> b;
	--a; --b;
	swap(a, b);
	d = new int[n];
	f = new int[n];
	for (int i = 0; i < n; ++i) {
		d[i] = -1;
	}
	for (int i = 0; i < n - 1; ++i) {
		cin >> s >> t;
		--s; --t;
		add_edge(s, t); add_edge(t, s);
	}

	//cout << "here" << endl;
	h = new int[n];
	mh = new int[n];
	for (int i = 0; i < n; ++i) {
		h[i] = -1;
		mh[i] = -1;
		f[i] = -1;
	}
	h[a] = 0;
	dfs(a);
	int d = h[b], emp = mh[b];
	//cout << d << ' ' << emp << endl;
	int ans = 0;
	int c = 0;
	for (int i = b; i != -1; i = f[i]) {
				if (d - 2 * c <= 0) {
			break;
		}
		ans = max(ans, get_ans(d - 2 * c, mh[i]) + c);
		//cout << i << ' ' << mh[i] << ' ' << (d - 2 * c) << endl;
		//cout << ans << endl;
		++c;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 7280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(12);
    ll X,K,D;
    cin >> X >> K >> D;
    X = abs(X);
    ll kaisuu = min(X/D,K);
    X -= D*kaisuu;
    K -= kaisuu;
    K%=2;
    X -= K*D;
    cout << abs(X) << "\n";
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcountll
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif

    int x, y;
    cin >> x >> y;
    if (x == 1 && y == 1) {
        cout << 1000 * 1000 << endl;
        exit(0);
    }   

    int ans = 0;
    vector <int> t = {100000, 200000, 300000};
    if (x <= 3)
        ans += t[3 - x];
    if (y <= 3)
        ans += t[3 - y];
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define N 1001
int p[N],r[N],c[N],n,t,u[N],a[2];
void init(){for(int i=0;i<N;i++)p[i]=i,c[i]=1;}
int find(int x){return (p[x]==x)?x:(p[x]=find(p[x]));}
void unite(int x,int y) {x=find(x),y=find(y);if(x!=y){int cx=c[x],cy=c[y];if(r[x]<r[y])p[x]=y;else{p[y]=x;if(r[x]==r[y])r[x]++;}c[find(x)]=cx+cy;}}

int main() {
  init();
  cin >> n;
  string s[n];
  for(int i=0;i<n;i++){cin>>s[i];for(int j=0;j<i;j++)if(s[i][j]=='Y')t++,unite(i,j);}
  for(int i=0;i<n;i++){int k=find(i);if(!u[k])u[k]=1,a[c[k]%2]++;}
  int f=(!a[0]&&a[1]==2?0:1);
  cout<<((a[0]==1&&a[1]==2||(n*(n-1)/2-t)%2==f)?"Taro":"Hanako")<<endl;
  return 0;
}


Measured memory_bytes: 4092
import Control.Applicative
-- using separate funtcions concering the accuracy of (**)
manhattanDist :: [Double] -> [Double] -> Double
manhattanDist xs ys = sum $ zipWith ((abs .) . (-)) xs ys

euclDist :: [Double] -> [Double] -> Double
euclDist xs ys = sqrt . sum $ zipWith (\x y -> (x-y)^2) xs ys

chebyshevDist :: [Double] -> [Double] -> Double
chebyshevDist xs ys = maximum $ zipWith ((abs . ) . (-)) xs ys

minkowskiDist :: Int -> [Double] -> [Double] -> Double
minkowskiDist n xs ys =
    (** (1/fromIntegral n)) . sum $ zipWith (\x y -> abs (x-y) ^n) xs ys

main = do
    _ <- getLine
    xs <- map read . words <$> getLine
    ys <- map read . words <$> getLine
    print $ manhattanDist xs ys
    print $ euclDist xs ys
    print $ minkowskiDist 3 xs ys
    print $ chebyshevDist xs ys

Measured memory_bytes: 4552
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,i,e,f,g,n,m,k,l,A[200005],B[200005],C[200005],D[200005],ans,x,y;
int main() {
	cin>>x>>y>>a>>b>>c;
  	for(long long i=1;i<=a;i++) {
		cin>>A[i];
           }
  	sort(A+1,A+1+a);
  	for(long long i=1;i<=b;i++) {
		cin>>B[i];
           }
  	sort(B+1,B+1+b); 
  	for(long long i=1;i<=c;i++) {
		cin>>C[i];
                 	k++;
                 	D[k]=C[i];
           }
  	sort(C+1,C+1+c);
	for(long long i=a-x+1;i<=a;i++) {
                 	k++;
                 	D[k]=A[i];
           }
	for(long long i=b-y+1;i<=b;i++) {
                 	k++;
                 	D[k]=B[i];
           }
  	sort(D+1,D+1+k);
  	for(long long i=k-(x+y)+1;i<=k;i++) {
                 	ans+=D[i];
           }
  	cout<<ans;
}

Measured memory_bytes: 6400
ans = {}
ans[[[0, 1], [1, 0], [1, 1]]] = "A"
ans[[[1, 0], [2, 0], [3, 0]]] = "B"
ans[[[0, 1], [0, 2], [0, 3]]] = "C"
ans[[[1,-1], [1, 0], [2,-1]]] = "D"
ans[[[0, 1], [1, 1], [1, 2]]] = "E"
ans[[[1, 0], [1, 1], [2, 1]]] = "F"
ans[[[0, 1], [1,-1], [1, 0]]] = "G"

arr = $stdin.read.split("\n")

m = arr.size
i = 0
while i < m
  pos = []
  8.times{|j|
    8.times{|k|
      if arr[i][k] == "1"
        pos << [j, k]
      end
    }
    i += 1
  }
  p = []
  1.upto(3){|j|
    p[j-1] = [pos[j][0] - pos[0][0], pos[j][1] - pos[0][1]]
  }
  puts ans[p]
  i += 1
end

Measured memory_bytes: 8744
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int N;
  cin >> N;
  
  for (int k = 0; k <= 100/4; k++) {
    for (int d = 0; d <= 100/7; d++) {
      if (k*4 + d*7 == N) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 3592
from collections import defaultdict

N = int(input())
MOD = 10**9+7
mp = defaultdict(int)
# N! -> N-1, N-2,...で対応 (1は影響ないから2からスタート)
for i in range(2, N+1) :
  x = i
  for j in range(2, x+1): # 素数jの個数を求める
    while x%j == 0:
      x /= j
      mp[j] += 1
      
ans = 1
for v in mp.values():
  ans = ((ans%MOD) * (v+1)%MOD) % MOD
print(ans)  
  

Measured memory_bytes: 3316
#include <stdio.h>
#include <algorithm>

using namespace std;

int main(){
	int array[6];
	for(int i = 0; i < 3; i++) scanf("%d",&array[i]);
	for(int i = 2; i > 0; i--){
		for(int j = 0; j < i; j++){
			if(array[j] > array[j+1])swap(array[j],array[j+1]);
		}
	}
	printf("%d %d %d\n",array[0],array[1],array[2]);
}



Measured memory_bytes: 2744
#include <bits/stdc++.h>
#define f(i,j,k) for(int i=j;i<k;i++)
using namespace std;
int main(){
    long long n,a,b,ans,ans2;
    cin>>n>>a>>b;
    ans=min(n-a,b-1);
    if((b-a)%2==0){
        ans=min(ans,(b-a)/2);
    }
    else if((b-a)%2==1){
        long long ans2=min(a+(b-a-1)/2,n-b+1+(b-a-1)/2);
        ans=min(ans,ans2);
    }
    cout<<ans<<endl;
    return 0;
}


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

int main(){
  int n, a, b, c, x;
  while(true){
    cin >> n >> a >> b >> c >> x;
    if(n == 0)
      break;
    
    vector<int> y(n);
    for(int i=0; i<n; i++)
      cin >> y[i];

    int reel = 0;
    int ans = -1;
    for(int i=0; i<=10000; i++){
      if(x == y[reel])
        reel++;
      x = (a*x + b) % c;
      if(reel == n){
        ans = i;
        break;
      }
    }

    cout << ans << endl;
  }
  
  return 0;
}

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

const int MAXN = 1e4;
int a[MAXN+1];

int main() {
	int n;
	cin >> n;
	ll sum = 0;
	for(int i=1; i<=101; i++) {
		for(int j=1; j<=101; j++) {
			for(int k=1; k<=101; k++) {
				sum = (i*i)+(j*j)+(k*k)+(i*j)+(j*k)+(i*k);
				if(sum <= MAXN) {
					a[sum] ++;
				}
			}
		}
	}
	for(int i=1; i<=n; i++) {
		cout << a[i] << "\n";
	}
	return 0;
}

Measured memory_bytes: 3476
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

#define M_PI 3.14159265358979

int main()
{
    int A, B, H, M;
    cin >> A >> B >> H >> M;

    double a, b;
    a = A;
    b = B;

    double angleA = 360.0 / 12.0 * H + 360.0 / 12.0 / 60.0 * M;
    double angleB = 360.0 / 60.0 * M;

    double c2 = a * a + b * b - 2.0 * a * b * cos(M_PI / 180.0 * (angleA - angleB));
    cout << std::setprecision(11) << sqrt(c2);

    return 0;
}


Measured memory_bytes: 4160
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <int, ii> iii;
typedef pair<ll, ll> pll;
typedef pair<double, int> pdi;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
#ifdef VC
#define scanf scanf_s
#endif
#define iINF (1<<30)
#define INF (1LL<<59)
#define forn(i) for(int i = 0;i < n; ++i)
#define form(i,n) for(int i = 0 ;i < n; ++i)
#define NIL -1

const ll mod = 998244353;
int n;
int alp[30] = {};
string S;
ll used = 0LL;
int ans = 0;

int main(){
	int a[3010];
	cin >> n;
	forn(i) {
		cin >> a[i];
		ans += a[i] - 1;
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including seg_tree_order_statistics_node_update
#include <stdio.h>
#include <cassert>
using namespace std;
//using namespace __gnu_pbds;
typedef long long lo;
typedef pair<lo,lo> ll;//pair
typedef vector<lo> vl;  //vector of long
typedef vector<ll > vll;   //vector of pair
typedef priority_queue<lo>p_q;
typedef vector< vl > vvl;  //vector of vectors
#define X first
#define Y second
#define mp(a,b) make_pair((a),(b))
#define REP(a,b) for(lo i=(a);i<(lo)b;i++)//no need to declare variable i
#define REPE(a,b,c,d) REP(a,b)for(lo j=(c);j<(lo)d;j++)//no need to declare vaiables i,j
#define REPV(a,b,c) for((a)=b;(a)<(c);(a)++)//a is the variable
#define IREP(a,b) for(lo i=(a);i>=(b);i--)
#define IREPV(a,b,c) for((a)=b;(a)>=(c);(a)--)
#define all(v) (v).begin(),(v).end()
#define TRV(a) for(auto it : a)
#define INF 200100
#define MOD 1000000007
#define M 1000000007
#define CHECK_BIT(var,pos) ((var) & (1<<(pos)))
#define pb(a) push_back((a))
/*order statistic tree
typedef
tree<
  lo,
    null_type,
  less_equal<lo>,
  rb_tree_tag,
  // This policy updates nodes' metadata for order statistics.
  tree_order_statistics_node_update>
ordered_set;*/

/*#define gc getchar_unlocked
#define pc putchar_unlocked
inline void sprlo( lo a){
    lo i=0;
    char S[20];
    if(a==0)pc('0');
    if(a<0){
        pc('-');
        a*=-1;
    }
    while(a>0){
        S[i++]=a%10+'0';
        a=a/10;
    }
    --i;
    while(i>=0)
    pc(S[i--]);
    pc(' ');
}
inline void lprlo( lo a){
    lo i=0;
    char S[20];
    if(a==0)pc('0');
    while(a>0){
        S[i++]=a%10+'0';
        a=a/10;
    }
    --i;
    while(i>=0)
    pc(S[i--]);
    pc('\n');
}
inline lo uscan(){
    lo n=0;
    char c=gc();
    while(c<'0'||c>'9')c=gc();
    while(c<='9'&&c>='0'){
	    n=n*10+c-'0';
	    c=gc();
	}
    return n;
}*/
template<typename T> ostream& operator<< ( ostream &o,vector<T> v ) {
    if ( v.size() >0 )o<<v[0];
    for ( unsigned   i=1; i<v.size(); i++ )o<<" "<<v[i];
    return o<<endl;
}
template<typename U,typename V> ostream& operator<< ( ostream &o,pair<U,V> p ) {
    return o<<"("<<p.first<<", "<<p.second<<") ";
}
template<typename T> istream& operator>> ( istream &in,vector<T> &v ) {
    for ( unsigned   i=0; i<v.size(); i++ )in>>v[i];
    return in;
}
template<typename T> istream& operator>> ( istream &in,pair <T,T> &p ) {
    in>>p.X;
    in>>p.Y;
    return in;
}
bool dig(lo n){
    lo x=0;
    while(n>0){
        if(n%10==9)return true;
        n/=10;
        x++;
    }
    return false;;
}
int main(){
    std::ios::sync_with_stdio(false);
	lo n;
	cin>>n;
	lo ans=0;
	REP(0,n){
	lo x,y;
	cin>>x>>y;
	ans+=y-x+1;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  ll H;
  while (cin >> H) {
    int c = 0;
    while (H > 0) {
      ++c;
      H /= 2;
    }
    ll res = (1ll << c) - 1;
    cout << res << endl;
  }
  return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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 ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
	ll N;cin>>N;
	for(ll i=N;i<=100000;i+=N){
		for(ll j=N;j<=100000;j+=N){
			for(ll k=1;k<=3500;++k){
				if((4*i*j*k)==(i*j+j*k+k*i)*N){
					cout<<i<<" "<<j<<" "<<k<<endl;
					return 0;
				}
			}
		}
	}
}


Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG
// #pragma GCC optimize("Ofast")
#pragma GCC diagnostic ignored "-Wsign-compare"
#include <bits/stdc++.h>
// #include <atcoder/all>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define reps(i, s, n) for (int i = s; i < (int)(n); ++i)
using namespace std;
using ll = long long;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
constexpr int INF = 1e9 + 7;
constexpr ll LINF = 1LL << 60;

void solve() {
    int n;
    cin >> n;
    ll ans = 1;
    ll upper = 1e18;
    bool ng = false;
    bool zero = false;
    rep(i, n) {
        ll a;
        cin >> a;
        if (a == 0) {
            zero = true;
            break;
        }
        if (ng) continue;
        ll u = upper / ans;
        if (u < a) {
            ng = true;
            ans = -1;
            continue;
        }
        ans *= a;
    }
    if (zero)
        cout << "0\n";
    else if (ng)
        cout << "-1\n";
    else
        cout << ans << "\n";
}
int main() {
    cin.tie(nullptr);
    // ios_base::sync_with_stdio(false);
    // cout << fixed << setprecision(15);
    solve();
}

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

int main(){
	vector<ll> e(3);
	rep(i, 3) cin >> e.at(i);
	sort(e.begin(), e.end());

	if (!(e[0] % 2 && e[1] % 2 && e[2] % 2)){ // if one of them is even
		cout << 0 << endl;
		return 0;
	}
	cout << e[0] * e[1] << endl;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repc(i, a, b) for (int i = a; i <= (int)(b); i++)
#define ll long long
#define vec vector
#define pb push_back
#define ft first
#define sd second
#define all(vec) vec.begin(), vec.end()

typedef pair<int, int> P;

const int MOD = 1e9 + 7;
const int INF = 1001001001;
const int dx[4] = {1, 0,-1, 0};
const int dy[4] = {0, 1, 0,-1};

//------------------------------------------------------//


int main(){
  ll n, x, m;
  cin >> n >> x >> m;
  vec<int> id(m, -1);
  vec<int> a;
  int len = 0;
  ll tot = 0;
  while(id[x] == -1){
    a.pb(x);
    id[x] = len;
    len++;
    tot += x;
    x = (x * x) % m;
  }

  int c = len - id[x];
  ll s = 0;
  repc(i, id[x], len-1) s += a[i];

  ll ans = 0;
  if(n <= len){
    rep(i, n) ans += a[i];
  }
  else{
    ans += tot;
    n -= len;
    ans += s*(n/c);
    n %= c;
    rep(i, n) ans += a[id[x]+i];
  }
  cout << ans << endl;
  return 0;
}

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

#define int long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

int dp[105][(int)1e5+5];

signed main(){
	fastio
	int n,m;
	cin >> n >> m;
	int w[n+1], v[n+1];
	for(int i = 1;i <= n;i++) cin >> w[i] >> v[i];
	for(int i = 1;i <= n;i++){
		for(int j = 0;j <= m;j++){
			if(j-w[i] >= 0) dp[i][j] = max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
			else dp[i][j] = dp[i-1][j];
		}
	}
	cout << dp[n][m] << "\n";
}

Measured memory_bytes: 81664
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
const int MAXD=2500,MOD=1000000007;

int PowMod(int a,int b)
{
	int ret=1;
	while(b)
	{
		if(b&1)
			ret=(1LL*ret*a)%MOD;
		a=(1LL*a*a)%MOD;
		b>>=1;
	}
	return ret;
}

int dp[MAXD];
vector<int> fac;

int main()
{
	int N,K,ans=0;
	scanf("%d%d",&N,&K);
	for(int i=1;1LL*i*i<=N;i++)
		if(N%i==0)
		{
			fac.push_back(i);
			if(1LL*i*i!=N)
				fac.push_back(N/i);
		}
	sort(fac.begin(),fac.end());
	for(int i=0;i<(int)fac.size();i++)
	{
		int d=fac[i];
		dp[i]=PowMod(K,(d+1)/2);
		for(int j=0;j<i;j++)
			if(d%fac[j]==0)
				dp[i]=(dp[i]-dp[j]+MOD)%MOD;
		if(d%2==0)
			d/=2;
		ans=(ans+(1LL*dp[i]*d)%MOD)%MOD;
	}
	
	printf("%d\n",ans);
	
	return 0;
}


Measured memory_bytes: 256