akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define INF 1000000000000
#define MOD 1000000007
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3)                                                 \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
         << x3 << endl
#define debug_4(x1, x2, x3, x4)                                             \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
         << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5)                                         \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
         << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

using namespace std;
using ll = long long;

int main() {
    int n;
    cin >> n;
    cout << n + n * n + n * n * n << endl;
    return 0;
}

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

#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdint.h>
#include <string.h>

//#define _USE_MATH_DEFINES
//#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>
#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef int long long i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1000000007ll;
const i64 smod = 998244353ll;
const i64 inf = 1000000007; // 10000000000000007ll;

const double eps = 1e-8;

const i64 MAXN = 400005;
const i64 MAXM = 20;


i64 n;
i64 a[MAXN];


int main(int argc, char* argv[]) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);

    i64 n, a, b;
    cin >> n >> a >> b;

    i64 R = (n / (a + b)) * a;
    R += min(n % (a + b), a);

    cout << R << endl;


    return 0;
}

Measured memory_bytes: 256
#include<iostream>
int gcd(int x,int y){
	int z=x;
	if(x<y){
		z = x;
		x = y;
		y = z;
		z = 0;
	}
	while(x%y !=0){
		z = x%y;
		x = y;
		y = z;
	}
	return z;
}

int main()
{
	int x,y;
	std::cin >> x;
	std::cin >> y;
	std::cout << gcd(x,y) << "\n";
	return 0;
}


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

int main() {
  string s;
  cin >> s;
  int gcount = 0, pcount = 0;
  int win = 0, lose = 0;
  for (int i = 0; i < s.size(); i++) {
    if (gcount == pcount) {
      gcount++;
      if (s[i] == 'p') lose++;
    }
    else {
      if (s[i] == 'p') {
        pcount++;
      } else {
        pcount++;
        win++;
      }
    }
  }
  cout << win - lose << endl;
  return 0;
}


Measured memory_bytes: 512
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    import math
    a,b,h,m=map(int, input().split())
    akaku=h*30+m*0.5
    bkaku=m*6
    kaku=max(akaku,bkaku)-min(akaku,bkaku)
    kaku=min(kaku,360-kaku)
    kaku1=math.cos(math.radians(kaku))
    xx=a**2+b**2-2*a*b*kaku1
    print(xx**0.5)
resolve()

Measured memory_bytes: 62464
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 N = IO.RInt;
            long[] T = new long[N];
            for (int i = 0; i < N; i++)
            {
                var t = IO.RLong;
                T[i] = t;
            }
            long ans = T[0];
            for (int i = 1; i < N; i++)
            {
                ans = ans / GCD(ans, T[i]) * T[i];
            }
            WriteLine(ans);
        }

        public static long GCD(long x, long y)
        {
            if (x < y) Swap(ref x, ref y);
            if (y == 0) return x;
            else return GCD(x % y, y);
        }
        public static void Swap(ref long x, ref long y)
        {
            long tmp = x;
            x = y;
            y = tmp;
        }
    }

    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: 17688
#include <stdio.h>
#include <iostream>
#include <vector>
#include <math.h>

using namespace std;

int min(int a, int b){
    return (a > b) ? b : a;
}

int main(){

    int n, m, x;

    cin >> n >> m >> x;

    // cout << n << m << x << endl;

    vector<int> prices(n, 0);

    vector<int> levelUps[15];

    int max = pow(10, 5)* 12 + 5;

    int res = max;

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

        int price = 0;

        cin >> price;

        prices[i] = price;

        // cout << "price " << prices[i] << endl;

        int up;

        for(int j = 0; j < m; j++){
            
            cin >> up;
            levelUps[i].push_back(up);
            // cout << levelUps[i][j] << ",";
        }

        // cout << endl;
    }

    // cout << "pass here" << endl;
    
    for(int i = 1; i < pow(2,n); i++){

        int curBit = i;

        int sum = 0;

        int countBitIndex = 0;

        int level[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};

        while(curBit > 0){

            if(curBit & 1){
                sum += prices[countBitIndex];

                for(int j = 0; j < m; j++){
                    level[j] += levelUps[countBitIndex][j];

                }
            }

            // cout << sum << endl;
            curBit = curBit >> 1;

            countBitIndex++;
        }

        // cout << "after loop" <<  sum << endl;
        bool able = true;

        for(int k = 0; k < m; k++){
            // cout << level[k] << " ";
            if(level[k] < x){
                able = false;
            }
        }

        // cout << endl;

        if(able){
            // cout << "able " << res << endl;
            res = min(res, sum);
        }
    }

    if(res == max){
        cout << "-1" << endl;
    }
    else{
        cout << res << endl;
    }
}

Measured memory_bytes: 4076
import Control.Monad
import Data.List

solver :: [(Int, Int)] -> Int
solver ls =
  let n = length ls
   in if n == 1
        then 1
        else let dist_pat =
                   [ (x1 - x2, y1 - y2)
                   | (x1, y1) <- ls
                   , (x2, y2) <- ls
                   , (x1 /= x2 || y1 /= y2)
                   ]
              in n -
                 ((head .
                   sortBy (\a -> \b -> compare b a) . map length . group . sort)
                    dist_pat)

main :: IO ()
main = do
  n <- read <$> getLine
  dat <-
    forM [1 .. n] (\_ -> ((\(x:y:_) -> (x, y)) . map read . words) <$> getLine)
  print $ solver dat

Measured memory_bytes: 1532
def gcd(x,y):
    if x < y:
        x,y = y,x # x>yという状態を作っておく
    while y > 0:  #yが0になるまで（下記においてyはxをyで割ったときの余り）
        r = x % y #余りをrとして一時保管
        x = y     #yをxに代入して
        y = r     #余りをyとする
    return x      #余り（y）が0になった時のxの値を返す

x,y = map(int,input().split())
print(gcd(x,y))


Measured memory_bytes: 5596
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            int MAX = 104729;
            int sqrtMAX = (int)Math.Sqrt(MAX);

            int[] isPrime = Enumerable.Range(0, MAX + 1).ToArray();
            isPrime[0] = isPrime[1] = -1;

            for (int i = 0; i < sqrtMAX; i++)
            {
                if (isPrime[i] != -1)
                {
                    for (int j = i * i; j <= MAX; j += i)
                    {
                        isPrime[j] = -1;
                    }
                }
            }

            var primes = isPrime.Where(p => p != -1);

            while (true)
            {
                int n = int.Parse(Console.ReadLine());

                if (n == 0) break;

                int sum = primes.Take(n).Sum();
                sb.AppendLine(sum.ToString());
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 10644
n,k = map(int, input().split())
p = list(map(int, input().split()))
for i in range(n):
    p[i] = (p[i]+1)/2
ans = 0
s = [0]*(n+1)
for i in range(n):
    s[i+1] = p[i]+s[i]
for i in range(k-1,n):
    ans = max(s[i+1]-s[i-k+1],ans)
print(ans)

Measured memory_bytes: 24556
// https://atcoder.jp/contests/abc110/tasks/abc110_a
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

#define FOR(i, n) for (int i = 0; i < n; i++)
#define EACH(i, n) for (auto &i: n)

int main() {
  int abc[3];

  while (cin >> abc[0] >> abc[1] >> abc[2]) {
    sort(abc, abc + 3);
    cout << (abc[2] * 10 + abc[1] + abc[0]) << endl;
  }

  return 0;
}


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

int main(){
   char a;
    cin>>a;
    
    if(isupper(a)) cout<<"A"<<endl;
    else cout<<"a"<<endl;
    
    return 0;
}

Measured memory_bytes: 3616
import sys, math, itertools, collections, bisect 
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') 
inf = float('inf') ;mod = 10**9+7 
mans = inf ;ans = 0 ;count = 0 ;pro = 1

import sys, math, itertools, collections, bisect 
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') 
inf = float('inf') ;mod = 10**9+7 
mans = inf ;ans = 0 ;count = 0 ;pro = 1
 
n, k = map(int, input().split())
A = list(map(int, input().split()))
for i in range(k-1, n):
    if i == k-1:
        continue
    else:
        if A[i] > A[i-k]:
            print("Yes")
        else:
            print("No")
        #print(A[i], A[i-k])

Measured memory_bytes: 96032
#include <bits/stdc++.h>
#define DAU  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC return 0;
using namespace std;
int n, q, op, x, y, res, p2[30], arb[2000002];
char ch;
string s;
int l, r, pos, val;
inline void Update(int node, int st, int dr) {
    if (st == dr) {
        arb[node] = val;
        return;
    }
    int mid = (st + dr) / 2;
    if (pos <= mid)
        Update(2 * node, st, mid);
    else Update(2 * node + 1, mid + 1, dr);
    arb[node] = (arb[2 * node] | arb[2 * node + 1]);
}
inline int Query(int node, int st, int dr) {
    if (l <= st && dr <= r)
        return arb[node];
    int mid = (st + dr) / 2, r1(0), r2(0);
    if (l <= mid)
        r1 = Query(2 * node, st, mid);
    if (mid < r)
        r2 = Query(2 * node + 1, mid + 1, dr);
    return (r1 | r2);
}
int main() {
    DAU
    p2[0] = 1;
    for (int i = 1; i < 30; ++i)
        p2[i] = p2[i-1] * 2;
    cin >> n >> s >> q;
    for (int i = 1; i <= n; ++i) {
        pos = i, val = p2[s[i-1] - 'a'];
        Update(1, 1, n);
    }
    for (int i = 1; i <= q; ++i) {
        cin >> op >> x;
        if (op == 1) {
            cin >> ch;
            pos = x, val = p2[ch - 'a'];
            Update(1, 1, n);
        }
        else {
            cin >> y;
            l = x, r = y;
            cout << __builtin_popcount(Query(1, 1, n)) << '\n';
        }
    }
    PLEC
}


Measured memory_bytes: 7196
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
using namespace std;
int main()
{
	int N,K,ANS=0;
	cin >> N >> K;

	for(int i=0;i<N;i++){
		int a;
		cin >> a;
		if(a>=K){
			ANS++;
		}
	}
	cout << ANS << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ios::sync_with_stdio(false);
    string s;cin>>s;
    if(s[2]==s[3]&&s[4]==s[5]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
	return 0;
}


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

int main(){
  int n;
  double s=0;
  cin>>n;
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    s += 1.0/a;
  }
  
  cout<<1.0/s<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	try {
    		final int N = sc.nextInt();
    		int[][] v = new int[N][3];

    		for (int i=0; i<N; i++) {
    			v[i][0] = sc.nextInt();
    			v[i][1] = sc.nextInt();
    			v[i][2] = sc.nextInt();
    		}

    		int[][] h = new int[N][3];
    		h[0][0] = v[0][0];
    		h[0][1] = v[0][1];
    		h[0][2] = v[0][2];

    		for (int i=1; i<N; i++) {
    			h[i][0] = Math.max(h[i-1][1] + v[i][0], h[i-1][2] + v[i][0]);
    			h[i][1] = Math.max(h[i-1][0] + v[i][1], h[i-1][2] + v[i][1]);
    			h[i][2] = Math.max(h[i-1][0] + v[i][2], h[i-1][1] + v[i][2]);
    		}

    		if (h[N-1][0] < h[N-1][1]) {
    			if (h[N-1][1] < h[N-1][2]) {
    				System.out.println(h[N-1][2]);
    			} else {
    				System.out.println(h[N-1][1]);
    			}
    		} else {
    			if (h[N-1][0] < h[N-1][2]) {
    				System.out.println(h[N-1][2]);
    			} else {
    				System.out.println(h[N-1][0]);
    			}
    		}

    	} finally {
    		sc.close();
    	}
    }
}



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

#ifdef LOCAL
  #include <contest/local.hpp>
#else
  #define LOG(...) do {} while (false)
#endif

using namespace std;

auto gcd (int64_t m, int64_t n) -> int64_t
{
  return n == 0 ? m : gcd (n, m % n);
}

auto lcm (int64_t m, int64_t n)
{
  return m / gcd (m, n) * n;
}

auto main () -> int
{
  cin.tie (nullptr);
  ios::sync_with_stdio (false);
  cout << fixed << boolalpha;
  cerr << fixed << boolalpha;


  int64_t a, b, c, d;
  cin >> a >> b >> c >> d;

  auto cd = lcm (c, d);
  auto divc = b / c - (a - 1) / c;
  auto divd = b / d - (a - 1) / d;
  auto divcd = b / cd - (a - 1) / cd;
  auto aaaa = divc + divd - divcd;
  LOG (divc);
  LOG (divd);
  LOG (divcd);
  LOG (aaaa);
  auto ans = b - a + 1 - aaaa;
  cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

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

signed main(void)
{
    ll n, x;
    cin >> n >> x;
    vll l(n);
    ll r = 1;
    ll d = 0;
    
    rep(i, n) {
        cin >> l[i];
        d += l[i];
        if (d > x) break;
        r++;
    }
    
    mes (r);
    
    
}

Measured memory_bytes: 3636
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define SZ(a) (signed)((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

const int MOD = 1000000007;

#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"  << " " << __FILE__ << endl;

signed main(void) {
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed, ios::floatfield);
    cout.precision(10);
    cin.tie(0);

    int w, a, b;
    cin >> w >> a >> b;

    if (w + a < b) {
        cout << b - (w + a) << endl;
    } else if (b + w < a) {
        cout << a - (w + b) << endl;
    } else {
        cout << 0 << endl;
    }

    return 0;
}


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

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1<<29)

using namespace std;

struct P
{
  int weight,index;
  P(int weight=inf,int index=inf):weight(weight),index(index){}
  bool operator < (const P& a)const
  {
    return weight < a.weight;
  }
};

int n,m,W;

int main()
{
  int k;
  scanf("%d %d %d",&n,&m,&W);
  
  int idx = 0;
  vector<vector<P> > vec;
  vector<int> FLOOR;

  rep(i,n)
    {
      scanf("%d",&k);
      if(k == 0)
	{
	  if(i == 0)
	    {
	      FLOOR.push_back(i);
	      vec.push_back(vector<P>());
	    }
	  continue;
	}
      int cur = vec.size();
      vec.push_back(vector<P>(k));
      FLOOR.push_back(i);
      rep(j,k)
	{
	  scanf("%d",&vec[cur][j].weight);
	}
    }

  if(FLOOR[FLOOR.size()-1] == 0)
    {
      puts("0");
      return 0;
    }

  int ans = FLOOR[FLOOR.size()-1]+1-m;
  for(int i=FLOOR.size()-1;i>=1;i--)
    {
      //cout << "cost = " << FLOOR[i] << " - " << FLOOR[i-1] << endl;
      int cost = FLOOR[i] - FLOOR[i-1];
      assert(cost >= 0);
      int SIZE = vec[i].size();
      //cout << "SIZE = " << SIZE << endl;
      int dp[(1<<SIZE)];
      rep(j,(1<<SIZE))dp[j] = inf;
      dp[0] = 0;
      rep(state,(1<<SIZE))//テ、ツサツ甘」ツ?ョテ」ツδ陛」ツδュテ」ツつ「テ」ツ?ョテァツ環カテヲツウツ?0 -> テ」ツ?セテ」ツ??ァツァツサテ・ツ仰陛」ツ?療」ツ?ヲテ」ツ?ェテ」ツ?? 1 -> テァツァツサテ・ツ仰陛」ツ?療」ツ?淌」ツ?淌」ツ?敕ッツスツ?
	{
	  if(dp[state] == inf)continue;
	  vector<P> tmp;//テ」ツ?セテ」ツ??」ツ?禿」ツ?ョテ」ツδ陛」ツδュテ」ツつ「テ」ツ?ォテ」ツつ凝」ツつづ」ツ?ョテ」ツ?淌」ツ?敕ッツスツ?
	  rep(j,SIZE)
	    {
	      if((state>>j) & 1)continue;
	      tmp.push_back(P(vec[i][j].weight,j));
	    }

	  sort(tmp.begin(),tmp.end());
	  int limit = tmp.size();
	  rep(j,(1<<limit))//テヲツャツ。テ」ツ?ォテァツァツサテ・ツ仰陛」ツ?凖」ツつ凝」ツつづ」ツ?ョ
	    {
	      int sum = 0;
	      int tstate = 0;
	      rep(k,limit)
		{
		  if((j>>k) & 1)
		    {
		      tstate |= (1<<tmp[k].index);
		      sum += tmp[k].weight;
		    }
		}
	      assert(sum >= 0);
	      if(sum > W)continue;
	      assert((state ^ tstate) == (state | tstate));
	      int nstate = state | tstate;
	      dp[nstate] = min(dp[nstate],
			       dp[state]+2);
	    }
	}
      rep(j,vec[i].size())vec[i-1].push_back(vec[i][j]);
      assert((dp[(1<<SIZE)-1]-1)*cost >= 0);
      ans += (dp[(1<<SIZE)-1]-1)*cost;//テヲツ鳴ーテ」ツ?淌」ツ?ェテ・ツ?、テ」ツつ津・ツセツ療」ツつ凝」ツ?淌」ツ?敕ッツスツ?
      assert(ans >= 0);
      //cout << "ans = " << ans << " dp = " << dp[(1<<SIZE)-1] << endl;
    }

  printf("%d\n",ans);//テ」ツ?暗」ツつ凝」ツ?淌」ツ?敕ッツスツ?

  return 0;
}

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

int main(){
    int N,M;    cin>>N>>M;
    vector<int> A(N),B(N);
    
    for(int i=0;i<N;i++)    cin>>A[i]>>B[i];
    
    vector<pair<int,int>> AB(N);
    
    for(int i=0;i<N;i++)    AB[i]=make_pair(A[i], B[i]);
    
    sort(AB.begin(),AB.end());
    
    long long ans=0;
    
    for(int i=0;i<N;i++){
        int buy=min(M,AB[i].second);
        ans+=(long long)buy*AB[i].first;
        M-=buy;
    }
    
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
#define rep(i,N) for(int i=0;i<(int)N;++i)
#define rep1(i,N) for(int i=1;i<=(int)N;++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define SZ(x) (int)x.size()
#define e_b emplace_back
using ll = long long;
const ll LINF=1LL<<60;
const int INF=1<<30;

struct LazySegmentTree{
	const ll INF=(1LL<<31)-1;
	int n;
	vector<ll> node,lazy;
	
	LazySegmentTree(int sz){
		n=1;
		while(sz>n) n<<=1;
		node.assign(2*n,INF);
		lazy.assign(2*n,-1);
	}
	
	void eval(int k,int l,int r){
		if(lazy[k]!=-1){
			node[k]=lazy[k];
			if(r-l>1){
				lazy[2*k]=lazy[k];
				lazy[2*k+1]=lazy[k];
			}
			lazy[k]=-1;
		}
	}
	
	void update(int a,int b,ll x,int k=1,int l=0,int r=-1){
		if(r<0) r=n;
		eval(k,l,r);
		if(r<=a||b<=l) return;
		if(a<=l&&r<=b){
			lazy[k]=x;
			eval(k,l,r);
		}
		else{
			update(a,b,x,2*k,l,(l+r)/2);
			update(a,b,x,2*k+1,(l+r)/2,r);
			node[k]=min(node[2*k],node[2*k+1]);
		}
	}
	
	ll getMin(int a,int b,int k=1,int l=0,int r=-1){
		if(r<0) r=n;
		eval(k,l,r);
		if(r<=a||b<=l) return INF;
		if(a<=l&&r<=b) return node[k];
		ll vl=getMin(a,b,2*k,l,(l+r)/2);
		ll vr=getMin(a,b,2*k+1,(l+r)/2,r);
		return min(vl,vr);
	}
};

int main(){
	int n,q; cin>>n>>q;
	LazySegmentTree tree(n);
	rep(i,q){
		int m,s,t,x;
		cin>>m;
		if(m==0){
			cin>>s>>t>>x;
			tree.update(s,t+1,x);
		}else{
			cin>>s>>t;
			cout<<tree.getMin(s,t+1)<<endl;
		}
	}
}

	



Measured memory_bytes: 7012
#include <bits/stdc++.h>                                           
 
#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
 
 
using namespace std;
 
 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;
typedef unsigned long long ull;         
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb; 
typedef long long ll;  
typedef double db;                         
 
 
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 555;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const int inf = 1e9, N = 3e3 + 48, mod = 1e9 + 7, maxn = 102;
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;


string s, t;
int dp[N][N];
pii p[N][N];

main () {
	cin >> s >> t;	
	int n = sz(s), m = sz(t);
	s = "#" + s;
	t = "#" + t;

	forn (i, 1, n)
		forn (j, 1, m)
			if (s[i] == t[j]) {
				dp[i][j] = dp[i - 1][j - 1] + 1;
				p[i][j] = {i - 1, j - 1};
			} else if (dp[i][j - 1] > dp[i - 1][j]) {
				dp[i][j] = dp[i][j - 1];             
				p[i][j] = {i, j - 1};
			} else {
				dp[i][j] = dp[i - 1][j];
				p[i][j] = {i - 1, j}; 
			}

	string ans = "";
	int i = n, j = m;
	while (1) {
		int ii = p[i][j].f, jj = p[i][j].s;
		if (i == ii + 1 && j == jj + 1) 
			ans += s[i];
		if (!ii && !jj)
			break;
		i = ii;
		j = jj;	
	}

	reverse(all(ans));
	cout << ans << endl;

}                       

Measured memory_bytes: 217344
#include <cstdio>
#include <queue>
#include <set>
#include <algorithm>

using namespace std;

int ans;
char c[100001];
int a[100000];
set <int> s[100000];

int dfs(int x, int y) {
    int p = 0, q = 0;
    set <int>::iterator it;
    
    for (it = s[x].begin(); it != s[x].end(); it++) {
        int nx = *it;
        
        if (nx != y) {
            int r = dfs(nx, x);
            
            if (r > p) {
                q = p;
                p = r;
            } else if (r > q) {
                q = r;
            }
        }
    }
    
    p += a[x];
    ans = max(ans, p + q);
    return p;
}

int main() {
    int n, num, i;
    queue <int> q;
    
    scanf("%d", &n);
    
    for (i = 0; i < n - 1; i++) {
        int x, y;
        
        scanf("%d %d", &x, &y);
        
        x--;
        y--;
        
        s[x].insert(y);
        s[y].insert(x);
    }
    
    scanf("%s", c);
    
    num = n;
    
    for (i = 0; i < n; i++) {
        if (c[i] == 'B' && s[i].size() <= 1) q.push(i);
    }
    
    while (!q.empty()) {
        int x = q.front(), y;
        
        q.pop();
        
        if (s[x].size() == 0) break;
        
        y = *s[x].begin();
        
        num--;
        s[x].erase(y);
        s[y].erase(x);
        
        if (c[y] == 'B' && s[y].size() <= 1) q.push(y);
    }
    
    if (num <= 1) {
        for (i = 0; i < n; i++) {
            if (c[i] == 'W') ans++;
        }
        
        printf("%d\n", ans);
    } else {
        int p = -1;
        
        num = (num - 1) * 2;
        
        for (i = 0; i < n; i++) {
            if (s[i].size() == 0) continue;
            if (p == -1) p = i;
            
            if (c[i] == 'W') a[i] = 1;
            a[i] += s[i].size();
            a[i] %= 2;
            
            num += a[i];
        }
        
        dfs(p, -1);
        
        printf("%d\n", num - ans * 2);
    }
    
    return 0;
}


Measured memory_bytes: 21760
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) noexcept {
  return std::vector<T>(n, std::forward<T>(val));
}

template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) noexcept {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}

template<class T, class Cond>
struct chain {
  Cond cond; chain(Cond cond) : cond(cond) {}
  bool operator()(T& a, const T& b) const {
    if(cond(a, b)) { a = b; return true; }
    return false;
  }
};
template<class T, class Cond>
chain<T, Cond> make_chain(Cond cond) { return chain<T, Cond>(cond); }

int main() {
  i64 N;
  cin >> N;
  i64 ans = 0;
  for(i64 i = 1; i <= N; i++) {
    if(i % 3 == 0 || i % 5 == 0) {

    }
    else {
      ans += i;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(all(x));
#define RSORT(x) sort(rall(x));
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vd = vector<double>;
using vb = vector<bool>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;
const ll inf = 1ll<<29;
const ll mod = 1000000007;      
const double eps = 1e-9;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};

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() {
  int N; cin >> N;
  vi A(N); rep(i,N) cin >> A.at(i);

  vi S = A;
  RSORT(S);
  rep(i,N) {
    int ans = S.at(0);
    if(S.at(0) == A.at(i)) ans = S.at(1);
    cout << ans << endl;
  }
  return 0;
}

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

#define int long long

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a, i##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

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

using namespace std;

using P = pair<int,int>;
using ll = long long;

const long long INF = LLONG_MAX/3;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

struct UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[b]+=siz[a];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

const int MOD=1e9+7;
long long fac[510000], finv[510000], inv[510000];
long long MAX=510000;
bool COMinited=false;
long long COM(int n, int k){
	if(COMinited==false){
		fac[0] = fac[1] = 1;
    	finv[0] = finv[1] = 1;
    	inv[1] = 1;
    	for (int i = 2; i < MAX; i++){
        	fac[i] = fac[i - 1] * i % MOD;
        	inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        	finv[i] = finv[i - 1] * inv[i] % MOD;
    	}
		COMinited=true;
	}
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}
signed main(){
	int n;
	cin>>n;
	UnionFind f(n);
	int m,k;
	cin>>m>>k;
	int a[100010],b[100010];
	rep(i,m){
		cin>>a[i]>>b[i];
		a[i]--;
		b[i]--;
		f.marge(a[i],b[i]);
	}
	//rep(i,n)cout<<f.siz[i]<<endl;
	int cn[100010]={};
	//cout<<f.size(1)<<endl;
	rep(i,n){
		cn[i]=f.size(i)-1;
		//cout<<cn[i]<<endl;
	}
	rep(i,m){
		cn[a[i]]--;
		cn[b[i]]--;
	}
	rep(i,k){
		int c,d;
		cin>>c>>d;
		c--;
		d--;
		if(f.issame(c,d)){
			cn[c]--;
			cn[d]--;
		}
	}
	rep(i,n)cout<<cn[i]<<" ";
	cout<<endl;
}

Measured memory_bytes: 5504
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define db double
#define pi 3.14159265358979323846
#define ar array
#define pow pw
int pw(int a,int b){
    int ans=1;
    while(b){
    if (b%2) ans*=a;
    a*=a;
    b/=2;
    }
    return(ans);
}
signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,p;
    cin>>n>>p;
    vector<ar<int,2> > sieve;
    for (int i=2;i<=sqrt(p);i++)
    {
        int c=0;
        while(p%i==0)
        {
            c++;
            p/=i;
        }
        if (c>0) sieve.push_back({i,c});
    }
    if (p>1) sieve.push_back({p,1});
    int ans=1;
    for (int i=0;i<sieve.size();i++)
    {
        ans*=pw(sieve[i][0],(sieve[i][1]/n));
    }
    cout<<ans;
}

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

#define fi first
#define sd second
#define lson (nd<<1)
#define rson (nd+nd+1)
#define PB push_back
#define mid (l+r>>1)
#define MP make_pair
#define SZ(x) (int)x.size()

using namespace std;

typedef long long LL;

typedef vector<int> VI;

typedef pair<int,int> PII;

inline int read(){
    int res=0, f=1;char ch=getchar();
    while(ch<'0'|ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){res=res*10+ch-'0';ch=getchar();}
    return res*f;
}

const int MAXN = 200'005;

const int MOD = 1000000007;

void addmod(int& a, int b){a+=b;if(a>=MOD)a-=MOD;}
int mulmod(int a, int b){return 1ll*a*b%MOD;}

#define go(e,u) for(int e=head[u];e;e=Next[e])
int to[MAXN<<1],Next[MAXN<<1],head[MAXN],tol;

void add_edge(int u,int v){
    Next[++tol]=head[u];to[tol]=v;head[u]=tol;
    Next[++tol]=head[v];to[tol]=u;head[v]=tol;
}

int ans[MAXN];

int cnt[MAXN], pre[MAXN], tp[MAXN];

int sz[MAXN];

int fac[MAXN], inv[MAXN], n;

int powmod(int x, int y){
    int res=1;
    while(y){
        if(y&1)res=1ll*res*x%MOD;
        y>>=1;
        x=1ll*x*x%MOD;
    }

    return res%MOD;
}

void init(){
    fac[1]=fac[0]=1;
    for(int i=2;i<=n;++i)fac[i]=1ll*fac[i-1]*i%MOD;
    inv[0]=inv[1]=1;
    for(int i=2;i<=n;++i)inv[i]=1ll*MOD-1ll*MOD/i*inv[MOD%i]%MOD;
    for(int i=2;i<=n;++i)inv[i]=1ll*inv[i-1]*inv[i]%MOD;
}

int C(int n, int m){
    return 1ll*fac[n]*inv[m]%MOD*inv[n-m]%MOD;
}

void dfs1(int u, int f){
    sz[u]=1;pre[u]=1;
    go(e,u){
        int v=to[e];
        if(v==f) continue;
        dfs1(v,u);
        sz[u]+=sz[v];
        pre[u]=1ll*pre[u]*pre[v]%MOD*C(sz[u]-1,sz[v])%MOD;
    }
}

void dfs2(int u, int f){
    ans[u]=1ll*tp[u]*pre[u]%MOD*C(n-1,n-sz[u])%MOD;
    go(e,u){
        int v=to[e];
        if(v==f)continue;
        tp[v]=1ll*ans[u]*powmod(1ll*pre[v]*C(n-1,sz[v])%MOD,MOD-2)%MOD;
        dfs2(v,u);
    }
}

int main(){
    n=read();
    for(int i=1;i<n;++i){
        int u, v;
        u=read();
        v=read();
        add_edge(u,v);
    }

    init();
    dfs1(1,0);
    tp[1]=1;
    dfs2(1,0);

    for(int i=1;i<=n;++i)cout<<ans[i]<<endl;

    return 0;
}
/*
8
1 2
2 3
3 4
3 5
3 6
6 7
6 8


40
280
840
120
120
504
72
72

*/



Measured memory_bytes: 11648
import qualified Data.ByteString.Char8 as BC
import Data.Maybe
import qualified Data.IntMap as IM
import Data.List
import Data.Ord

type Map = IM.IntMap Int

readIntsLine :: IO [Int]
readIntsLine = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

countUp :: Int -> Int -> Map -> Map
countUp = IM.insertWithKey f
  where f _ new old = old + new

count :: Int -> [Int] -> Map -> Map -> (Map, Map)
count c [] mo me = (mo, me)
count c (v:vs) mo me = count (c + 1) vs nextmo nextme
  where nextmo = if odd c then countUp v 1 mo else mo
        nextme = if even c then countUp v 1 me else me

main :: IO ()
main = do
  getLine
  vs <- readIntsLine
  let (mo, me) = count 1 vs IM.empty IM.empty
  let rsort = sortOn (Down . snd) . IM.toList
  let smo = rsort mo
  let sme = rsort me
  let (o1, oc1) = head smo
  let (e1, ec1) = head sme
  let two sm = if length sm > 1 then snd $ sm !! 1 else 0
  let oc2 = two smo
  let ec2 = two sme
  let lvs = length vs
  print $ if o1 /= e1
          then lvs - oc1 - ec1
          else lvs - max (oc1 + ec2) (oc2 + ec1)

Measured memory_bytes: 42364
# coding: utf-8
# Your code here!


l = list(map(int,input().split()))
i = l[0]
count = 0
for target_list in range(l[1] - l[0] + 1):
    if l[2] % i == 0 :

        count += 1

    i += 1

print(str(count))



Measured memory_bytes: 5596
import java.io.*;

class Main {
    public static void main(String[] args) {
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            String line;
            while((line = br.readLine()) != null){
            		String[] lineList = line.split(" ", 0);
                int x = Integer.parseInt(lineList[0]);
                int y = Integer.parseInt(lineList[1]);
                if(x < y) {
	    	    			int tmp = x;
	    	    			x = y;
	    	    			y = tmp;
	    	    		}
                System.out.println(gcd(x, y));
            }
            
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * @param line
     *            ??´??°x,y?????\???
     * @return x,y????????§??¬?´???°
     */
    private static long gcd(int x, int y) {
    		if(y == 0) {
    			return x;
    		}else{
    			return gcd(y, x % y);
    		}
    }
}

Measured memory_bytes: 24320
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
long long gcd(long long a,long long b){
    if(a<b) swap(a,b);
    while(a%b!=0){
        swap(a,b);
        b = b%a;
    }
    return b;
}
int main(){
    long long a,b;
    cin >> a >> b;
    cout << (a*b)/gcd(a,b) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

ll ok(ll i, ll n)
{
	if(i == 1)
		return 0;
	while(n % i == 0)
		n /= i;
	return (n % i == 1);
}
int main()
{
	ll n, res = 0;
	cin >> n;
	set<ll> ans;
	for(ll i = 1; i * i <= n; i ++)
	{
		if(n % i != 0)
			continue;
		if(ok(i, n))
			ans.insert(i);
		ll j = n / i;
		if(i != j)
		{
			if(ok(j, n))
				ans.insert(j);
		}
	}
	n --;
	for(ll i = 1; i * i <= n; i ++)
	{
		if(n % i != 0)
			continue;
		ll j = n / i;
		if(i != j)
		{
			if(j > 1)
				ans.insert(j);
		}
		if(i > 1)
			ans.insert(i);
	}
	cout << ans.size();



	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

Measured memory_bytes: 256
from collections import deque

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

def solve(sh, sw):
    visited = [[-1]*w for i in range(h)]
    visited[sh][sw] = 0
    q = deque([(sh, sw)])
    max_ = 0
    while q:
        i, j = q.popleft()
        for ni, nj in [(i+1, j), (i-1, j), (i, j+1), (i, j-1)]:
            if not(0 <= ni < h and 0 <= nj < w):
                continue
            if s[ni][nj] == "#":
                continue
            if visited[ni][nj] >= 0:
                continue
            visited[ni][nj] = visited[i][j] + 1
            max_ = max(max_, visited[ni][nj])
            q.append((ni, nj))
    return max_

ans = 0
for sh in range(h):
    for sw in range(w):
        if s[sh][sw] == "#":
            continue
        ans = max(ans, solve(sh, sw))
print(ans)

Measured memory_bytes: 45592
//url:
//problem name: 

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    ll N,M; cin >> N >> M;
    ll ans = 0;
    ll cnt = 0;
    vector<pair<int,int>> res(N);
    REP(i,N) cin >> res[i].first >> res[i].second;
    sort(res.begin(),res.end());
    REP(i,N) {
        ll a = res[i].first;
        ll b = res[i].second;
        if(M-b > 0) {
            ans += a*b;
        } else {
            ans += a*M;
            break;
        }
        M -= b;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(void){
      int h,w;
      while(1){
            cin>>h>>w;
            if(h==0&&w==0)break;
            for(int i=0;i<h;i++){
                  for(int j=0;j<w;j++){
                        if(i!=0&&j!=0&&i!=h-1&&j!=w-1){
                              cout<<".";
                        }
                        else{
                              cout<<"#";
                        }
                  }
                  cout<<endl;
            }
            cout<<endl;
      }
      return 0;
}


Measured memory_bytes: 3084
#http://abc079.contest.atcoder.jp/
# -*- coding: utf-8 -*-
import sys

n = int(input())

ryuka = [2,1]
if n<2:
    print(ryuka[n])
    sys.exit()
    
for i in range(2,n+1):
    ryuka.append(ryuka[i-2]+ryuka[i-1])

print(max(ryuka))


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

const long MOD = 1000000007;
typedef pair<int, int> P;
typedef long long ll;

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

    ll x[N], y[N], z[N];
    for(int i=0; i<N; i++) cin >> x[i] >> y[i] >> z[i];

    ll ans = 0;
    for(int d=0; d<8; d++){
        int dx = pow(-1, ((d>>0)&1));
        int dy = pow(-1, ((d>>1)&1));
        int dz = pow(-1, ((d>>2)&1));

        ll sum[N];
        fill(sum, sum+N, 0);
        for(int i=0; i<N; i++){
            sum[i] = x[i]*dx + y[i]*dy + z[i]*dz;
        }
        sort(sum, sum+N, greater<ll>());

        ll t = 0;
        for(int i=0; i<M; i++){
            t = t + sum[i];
        }
        ans = max(t, ans);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3788
import sys
sys.setrecursionlimit(1000000000)
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())

def main():
    N, K = mis()
    S = input()
    ans = min(sum(S[i]==S[i+1] for i in range(N-1)) + 2*K, N-1)
    print(ans)

main()


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define gc getchar()
using namespace std;
typedef long long ll;
const int mod=1000000007;
const int N=1000009;
int n,Ans,inv[N],jc[N],jc_inv[N];
int read()
{
	int x=1;
	char ch;
	while (ch=gc,ch<'0'||ch>'9') if (ch=='-') x=-1;
	int s=ch-'0';
	while (ch=gc,ch>='0'&&ch<='9') s=s*10+ch-'0';
	return s*x;
}
int C(int n,int m)
{
	if (n<m||m<0) return 0;
	return (ll)jc[n]*jc_inv[m]%mod*jc_inv[n-m]%mod;
}
int W(int k)
{
	return C(k,n-2-k);
}
int T(int x)
{
	if (x==0) return jc[n-1];
	return (ll)((ll)C(n-2,x)+C(n-2,x-1)-W(x-1)+mod)*jc[x]%mod*jc[n-x-1]%mod;
}
int main()
{
	jc[0]=1;
	for (int i=1;i<N;i++) jc[i]=(ll)jc[i-1]*i%mod;
	inv[1]=1;
	for (int i=2;i<N;i++) inv[i]=(ll)(mod-mod/i)*inv[mod%i]%mod;
	jc_inv[0]=1;
	for (int i=1;i<N;i++) jc_inv[i]=(ll)jc_inv[i-1]*inv[i]%mod;
	n=read();
	for (int i=0;i<n-1;i++) Ans=(Ans+T(i))%mod;
	printf("%d\n",Ans);
	return 0;
}


Measured memory_bytes: 11904
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int A, B, C, D; cin >> A >> B >> C >> D;
    if (min(B, D) - max(A, C) <= 0) printf("%d\n", 0);
    else printf("%d\n", min(B, D) - max(A, C));
}


Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,x;
    cin >> n >> k;
    while(n!=0||k!=0){
       vector<int> a(n);
        int S[100010];
        for(int j=0;j<n;j++){
            cin >> a.at(j);
        }
        S[0]=0;
        for(int i=1;i<n;i++){
            S[i]=S[i-1]+a.at(i-1);
        }
        x=S[k];
        for(int l=1;l<n-k;l++){
            if(x<S[k+l]-S[l]){
                x=S[k+l]-S[l];
            }
        }
        cout << x << endl;
        cin >> n >> k;
        

    }

}


Measured memory_bytes: 3552