akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
// const lint MOD = 998244353;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
char upper(char c){
	return c-0x20;
}
char lower(char c){
	return c+0x20;
}

int gcd(int x, int y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}

int main (){
	int n; cin>>n;
	vector<ll> a(n),b(n),c(n);
	cinv(n,a);
	cinv(n,b);
	cinv(n,c);
	sort(all(a));
	sort(all(c));
	ll ans = 0;
	rep(i,n){
		ll x = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
		ll y = c.end() - upper_bound(c.begin(), c.end(), b[i]);
		ans += x*y;
	}
	cout << ans << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<int ,P> P3;
typedef pair<P ,P> PP;
const ll MOD = ll(1e9+7);
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-6;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

int gcd(int p, int q){
    if(q==0) return p;
    else return gcd(q, p%q);
}

int main() {
    int n, k;
    int ans = 0;
    cin >> n >> k;
    map<P,int> lines;
    vector<int> x(n), y(n);
    REP(i,n){
        cin >> x[i] >> y[i];
    }
    for(int i=0;i<n;i++){
        lines.clear();
        for(int j=i+1;j<n;j++){
            P l;
            int dx = x[j]-x[i], dy = y[j]-y[i];
            if(dx < 0){
                dx *= -1;
                dy *= -1;
            }
            int g = gcd(abs(dx), abs(dy));
            dx /= g;
            dy /= g;
            l = {dy, dx};
            lines[l]++;  // dy/dx
            if(lines[l]>=k-1){
                ans = 1;
            }
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3324
L, R = map(int, input().split())
R -= (L // 2019) * 2019
L %= 2019

while R-4038 > L:
  R -= 2019

ans = float('inf')
for i in range(L, R):
  for j in range(i+1, R+1):
    ans = min(ans, i*j%2019)

print(ans)

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

int main()
{
    int a[3];

    cin >> a[0] >> a[1] >> a[2];

    sort(a, a + 3);

    if(a[0] == 5 && a[1] == 5 && a[2] == 7) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}


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

#define int long long
#define uint unsigned int
#define pii pair<int, int>
#define fi first
#define se second

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i >= (b); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, n, 0)
#define ALL(a) (a).begin(), (a).end()
#define SZ(a) ((int)(a).size())

#define PF(a) push_front(a)
#define PB(a) push_back(a)
#define EMPF(...) emplace_front(__VA_ARGS__)
#define EMPB(...) emplace_back(__VA_ARGS__)
#define EMP(...) emplace(__VA_ARGS__)
#define MP(a, b) make_pair(a, b)
#define MT(...) make_tuple(__VA_ARGS__)

#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, -1, sizeof(a))

#define PW(n) (1LL << (n))
#define NUM(x) char(x + '0')
#define ALP(x) char(x + 'a')

using namespace std;

template <class T> inline bool CHMIN(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <class T> inline bool CHMAX(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> void SORT(vector<T> &a) { sort(a.begin(), a.end()); }
template <class T> void SORTR(vector<T> &a) { sort(a.rbegin(), a.rend()); }
template <class T> void UNIQUE(vector<T> &a) { a.erase(unique(a.begin(), a.end()), a.end()); }

template <class S, class T> ostream& operator << (ostream& os, const pair<S, T> v) {
  os << "(" << v.first << ", " << v.second << ")"; return os;
}

const int MOD = 1000000007;
const int INF = 1LL << 30;
const double EPS = 1e-10;

/* ---------------------------------------------------------------------------------------------------- */

int N;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N;
  double ans = 0;
  REP(i, N) {
    double x;
    string u;
    cin >> x >> u;
    if (u[0] == 'J') ans += x;
    else ans += x*380000.0;
  }
  cout << ans << endl;

  return 0;
}

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


void solve () {
    int n;
    cin >> n;
    int p = 1;
    if (n % 2) p = 0;
    deque<int> b;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        if (i % 2 == p) {
            b.push_front(x);
        } else {
            b.push_back(x);
        }
    }
    for (auto x : b) {
        cout << x << " ";
    }

}

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


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

namespace ABC123C
{
    class Program
    {
        static void Main(string[] args)
        {
            long n = long.Parse(Console.ReadLine());
            long a = long.Parse(Console.ReadLine());
            long b = long.Parse(Console.ReadLine());
            long c = long.Parse(Console.ReadLine());
            long d = long.Parse(Console.ReadLine());
            long e = long.Parse(Console.ReadLine());

            var x = Math.Min(Math.Min(Math.Min(Math.Min(a, b), c), d), e);

            long r = n / x;
            long m = n % x;
            if (m > 0) r++;
            Console.WriteLine(r + 4);
        }
    }
}


Measured memory_bytes: 11092
using System;
using System.Linq;

namespace ABC054_C_CS_
{
    class Program
    {
        static int N,M;
        static bool[,] graph;//隣接行列
        static bool[] visited;//一度訪れたかどうか

        static int Dfs(int v,int N,bool[] visited){
            bool allVisited = true;//すべての頂点に訪れたかどうかのフラグ

            for(var i = 0;i < N;i++){//1津でも訪ねてないとfalseを返す
                if(!visited[i]){
                    allVisited = false;
                }
            }

            if(allVisited){//全部訪れたら1を返す
                return 1;
            }

            int ret = 0;

            //全ての遷移先のついて調べる！！！！！！！！
            for(var i = 0;i < N;i++){
                //頂点iが今いる場所とつながってない、あるいはすでに訪ねていたらi + 1に移る
                if(!graph[v,i]) continue;
                if(visited[i]) continue;

                visited[i] = true;//iに移動する
                ret += Dfs(i,N,visited);//iからの遷移を試す
                visited[i] = false;//フラグを取り消す

            }

            return ret;
        }
        static void Main(string[] args)
        {
            var s = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            N = s[0];
            M = s[1];
            graph = new bool[N,N];
            visited = new bool[N];
            for(var i = 0;i < M;i++){
                var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                graph[input[0] - 1,input[1] - 1] = graph[input[1] - 1,input[0] - 1] = true;
            }
            visited[0] = true;
            Console.WriteLine(Dfs(0,N,visited));
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <algorithm>
using namespace std;
int a, b;
int main() {
	cin >> a >> b;
	cout << ((a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) ? "Possible" : "Impossible") << endl;
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  map<string, int> s;
  string s_tmp;
  for (int i=0;i<N;i++){
    cin >> s_tmp;
    s[s_tmp]++;
  }

  int M;
  cin >> M;
  for (int i=0;i<M;i++){
    cin >> s_tmp;
    s[s_tmp]--;
  }
  
  int retval = 0;
  for (auto p : s){
    if (p.second>0) retval = max(p.second,retval);
  }
  cout << retval << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
   public static void main(String[] args) {
     Scanner sc = new Scanner(System.in);
     int  n = sc.nextInt();
     int m = sc.nextInt();
     String ans;
     if(n == m){
       ans = "Yes";
     }else{
       ans = "No";
     }
     System.out.println(ans);
   }
}

Measured memory_bytes: 25172
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;

public class Main {

	private static final int MOD = 1000000007;

	public static void main(String[] args) {

		try(BufferedReader bf =
				new BufferedReader(new InputStreamReader(System.in))) {
			String[] s = bf.readLine().split(" ");
			int N = Integer.parseInt(s[0]);
			int M = Integer.parseInt(s[1]);
			boolean[] flag = new boolean[N+1];
			Arrays.fill(flag, true);
			ArrayList<Integer> a = new ArrayList<>();
			for(int i = 0;i < M;i++) {
				a.add(Integer.parseInt(bf.readLine()));
				flag[a.get(i)] = false;
			}

			int[] dp = new int[N+1];
			dp[0] = 1;
			for(int now = 0;now < N;now++) {
				for(int next = now+1;next <= Math.min(N, now+2);next++) {
					if(flag[next]) {
						dp[next] += dp[now];
						dp[next]%=MOD;
					}
				}
			}
			System.out.println(dp[N]);

		}catch(IOException e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 30172
"abc091c - 2D Plane 2N Points"
N = int(input())
reds = [list(map(int, input().split())) for _ in range(N)]
blues = [list(map(int, input().split())) for _ in range(N)]

# 赤い点をy座標による降順ソートする
reds.sort(key=lambda x: -x[1])
# 青い点をx座標による昇順ソートする
blues.sort(key=lambda x: x[0])
# 一番左側の青い点からマッチング相手を探していく
for c, d in blues:
    for a, b in reds:
        if a <= c and b <= d:
            reds.remove([a, b])
            break
print(N-len(reds))


Measured memory_bytes: 3064
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;

class Task{
	public:
	
	long long a, b, c, ans;
	
	void run(int test_case){
		cin >> a >> b >> c;
		if (a + b >= c) {
			ans = b + c;
		} else {
			ans = 2 * b;
			c -= b;
			ans += a;
			c -= a;
			ans += (c > 0);			
		} 
		cout << ans << "\n";
	}
};

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int T = 1;
	//cin >> T;
	for (int i = 1; i <= T; i++) {
		Task *solver = new Task();
		solver->run(i);
		delete solver;
	}
}


Measured memory_bytes: 256
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);

void main()
{
    auto n = lread();
    foreach (i; 0 .. 10)
    {
        foreach (j; 0 .. 10)
        {
            if (i * j == n)
            {
                writeln("Yes");
                return;
            }
        }
    }
    writeln("No");

}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}


Measured memory_bytes: 3704
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repR(i, n) for(int i = (n) - 1; i > -1; i--)
#define rep1(i, n) for(int i = 1; i < (int)(n + 1); i++)
#define rep1R(i, n) for(int i = (n); i > 0; i--)
using namespace std;

int n;
vector<int> T;
vector<int> X;
vector<int> Y;

int main() {
  cin >> n;
  T.resize(n);
  X.resize(n);
  Y.resize(n);
  rep(i, n) cin >> T[i] >> X[i] >> Y[i];
  bool flag = true;
  int pre_x = 0, pre_y = 0, pre_t = 0;
  rep(i, n) {
    int dt = T[i] - pre_t;
    int dx = X[i] - pre_x;
    int dy = Y[i] - pre_y;
    if (abs(dx) + abs(dy) > dt) {
      flag = false;
      break;
    }
    if ((abs(dx) + abs(dy)) % 2 != dt % 2) {
      flag = false;
      break;
    }
    pre_x = X[i], pre_y = Y[i], pre_t = T[i];
  }
  if (flag) cout << "Yes";
  else cout << "No";
  return 0;
}


Measured memory_bytes: 1408
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1000000000;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={0, 1, 0, -1}, dy[4]={-1, 0, 1, 0};
using namespace std;
typedef pair<int, int> P;


/** Problem2261 : [[iwi]] **/

int ans;
string s;


void solve(int n, string t)
{
	if (n == s.size()) {
		
		int size = (int)t.size();
		
		if (size<3 || size%2==0) return;
		
		if (t[t.size()/2-1] != 'i' || t[t.size()/2] != 'w' || t[t.size()/2+1] != 'i')
			return;
		
		t.erase(t.size()/2-1, 3);
		
		while (t.size()) {
			int n = (int)t.size();
			if ((t[n/2-1] == '(' && t[n/2] == ')') ||
				(t[n/2-1] == '{' && t[n/2] == '}') ||
				(t[n/2-1] == '[' && t[n/2] == ']') ||
				(t[n/2-1] == ')' && t[n/2] == '(') ||
				(t[n/2-1] == '}' && t[n/2] == '{') ||
				(t[n/2-1] == ']' && t[n/2] == '['))
				t.erase(n/2-1, 2);
			else
				return;
		}
		
		ans = max(ans, size);
	} else {
		solve(n+1, t);
		solve(n+1, t+s[n]);
	}
}

int main()
{
	cin>>s;
	
	solve(0, "");
	cout << ans << endl;
}

Measured memory_bytes: 1212
let () =
  let n = Scanf.scanf "%d " (fun a -> a) in
  let a = Array.init n (fun _ -> Scanf.scanf "%d " (fun a -> a)) in

  let xor_sum2 arr n =
    let rec loop i j n accum res = 
      if i = n then res else (
        if j = n then (
          loop (i+1) j n (accum lxor arr.(i)) (res+j-i-1)
        ) else (
          if (accum land arr.(j) = 0) then (
            loop i (j+1) n (accum lxor arr.(j)) (res+1)
          ) else (
            loop (i+1) j n (accum lxor arr.(i)) (res+j-i-1)
          )
        )
      )
    in
    loop 0 0 n 0 0
  in
  Printf.printf "%d\n" (xor_sum2 a n);


Measured memory_bytes: 6144
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

struct WS{
  vvl d = vv(0, 0, 0, ll);
  ll N;
  WS(ll n){
    N = n;
    d.resize(n+1, vll (n+1, 10000000000));
    init();
  }
  void init(){
    re(i, N+1) d[i][i] = 0;
  }
  void insert(ll a, ll b, ll c){
    d[a][b] = min(d[a][b], c);
  }
  void warshall(){
    init();
    re(i, N+1) re(s, N+1) re(t, N+1) d[s][t]=min(d[s][t],d[s][i]+d[i][t]);
  }
};
int main(int argc, char const *argv[]) {
  ll h, w;std::cin >> h >> w;
  vector<string> s(h);
  WS ws(401);
  re(i, h) std::cin >> s[i];
  re(i, h){
    re(j, w){
      if(s[i][j]=='#') continue;
      if(i!=0&&s[i-1][j]=='.') ws.insert(i*20+j, (i-1)*20+j, 1);
      if(j!=0&&s[i][j-1]=='.') ws.insert(i*20+j, i*20+j-1, 1);
      if(i!=h-1&&s[i+1][j]=='.') ws.insert(i*20+j, (i+1)*20+j, 1);
      if(j!=w-1&&s[i][j+1]=='.') ws.insert(i*20+j, i*20+j+1, 1);
    }
  }
  ws.warshall();
  ll ans = 0;
  re(i, h){
    re(j, w){
      re(l, h){
        re(r, w){
          if(s[i][j]=='#'||s[l][r]=='#') continue;
          ans = max(ws.d[i*20+j][l*20+r], ans);
        }
      }
    }
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 2168
import sys
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

n, m = na()

flag = False
for x in range(n + 1):
    if flag is True:
        break
    for y in range(n + 1):
        if flag is True:
            break
        if x + y <= n and x * 10000 + y * 5000 + (n - x - y) * 1000 == m:
            print(x, y, (n - x - y))
            flag = True

if flag is False:
    print(-1, -1, -1)

Measured memory_bytes: 40940
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	dict := map[rune]rune {
		'A': 'T',
		'C': 'G',
		'T': 'A',
		'G': 'C',
	}

	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	c := []rune(sc.Text())[0]
	fmt.Println(string(dict[c]))
}


Measured memory_bytes: 640
n=int(input())
M=list(map(int,input().split(" ")))
q=int(input())
N=list(map(int,input().split(" ")))

#n=5
#M=[1,5,7,10,21]
#q=8
#N=[17]

def solve(i,m):
#    print("m:",m)
    if m==0:
        return True
    if i>=n:
        return False
#    print(f"solve({i+1},{m}) or solve({i+1},{m-M[i]})")
    return solve(i+1,m) or solve(i+1,m-M[i])

for cur in N:
    if   cur > sum(M):
        print("no")
    else:
        print("yes" if solve(0,cur) else "no")


Measured memory_bytes: 5624
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx")
//#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define fi first
#define se second
#define pb push_back
#define sz(x)  ((int)x.size ())
#define all(x) (x).begin(), (x).end()
#define re return
#define mp make_pair
#define sqrt(x) sqrt (abs(x))
#define y0 y3451
#define y1 y4562
#define j0 j25624
#define j1 j45624
#define makeunique(x) sort(all(x)), (x).resize (unique(all(x)) - (x).begin())

typedef pair <int, int> ii;
typedef long long ll;
typedef unsigned long long ull;
typedef double D;
typedef long double ld;
typedef unsigned int uint;
typedef vector <string> vs;
typedef vector <int> vi;
typedef vector <ii> vii;
typedef vector <vi> vvi;

template <class T> using _tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> T abs (T x) { re x > 0 ? x : -x; }
template <class T> T sqr (T x) { re x * x; }
template <class T> T gcd (T a, T b) { re a ? gcd (b % a, a) : b; }
template <class T> int sgn (T x) { re x > 0 ? 1 : (x < 0 ? -1 : 0); }

#define filename ""

const D pi = acos(-1.);
const int N = 1e5 + 20;
const int inf = 1e9 + 7;

int n, m;
ld p[3010];
ld dp[3010][3010];

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> p[i];
    dp[0][0] = 1;
    for (int i = 1; i <= n; i++)
    	for (int j = 0; j <= i; j++) {
    		dp[i][j] = dp[i - 1][j] * (1 - p[i - 1]);
    		if (j) dp[i][j] += dp[i - 1][j - 1] * p[i - 1];
		}    	
	ld ans = 0;
	for (int i = (n + 1) / 2; i <= n; i++)
		ans += dp[n][i];
	cout << setprecision(30) << ans;
	return 0;
}


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

int main() {
  string S;
  cin >> S;
  int N = S.size();
  
  S += 'R';
  
  vector<int> mojicount, RL;
  int count = 1;
  for (int i = 0; i < S.size(); i++) {
    if (S[i] == S[i+1]) {
      count++;
    } else {
      mojicount.push_back(count);
      count = 1;
    }
    
    if (S[i] == 'R' && S[i+1] == 'L') {
      RL.push_back(i);
    }
  }
  
  mojicount.pop_back();
  
  vector<pair<int, int>> child;
  for (int i = 0; i < mojicount.size(); i += 2) {
    int a = mojicount[i], b = mojicount[i+1];
    int left = (a + 1) / 2  + (b / 2);
    int right = a / 2 + (b + 1) / 2;
    
    child.push_back({left, right});


  }
  
  
  vector<int> ans(N, 0);
  
  for (int i = 0; i < child.size(); i++) {
    pair<int,int> p = child[i];
    
    int ind = RL[i];
    ans[ind] = p.first, ans[ind+1] = p.second;
  }
  
  
  for (int i = 0; i < N; i++) {
    cout << ans[i] << " ";
  }
  
  cout << endl;
  

       
        
  
}

Measured memory_bytes: 5280
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

    int nin = 10000;
    for (int i=0; i<N; i++){
        int ci, ti;
        cin >> ci >> ti;
        if (ti <= T)chmin(nin, ci);
    }
    if (nin == 10000)cout << "TLE" << endl;
    else cout << nin << endl;

}

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

int n;
int time_each[10010];
int main() {
  while(scanf("%d", &n), n) {
    vector<int> times;
    
    for (int i=0; i<n; i++) {
      int t;
      scanf("%d", &t);
      times.push_back(t);
    }
  
    sort(times.begin(), times.end());

    int wait_time = 0;
    for (int i=0; i<n-1; i++) {
      wait_time += times[i];
      time_each[i] = wait_time;
    }

    long long total_time = 0;
    for (int i=0; i<n-1; i++) {
      total_time += (long long)time_each[i];
    }
    
    printf("%lld\n", total_time);
    
  }
}

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

int main(){
    int n,x;
    int count;
    while(true){
        count=0;
        cin >> n >> x;
        if(n==0 && x==0){
            break;
        }
        for(int i=1; i<=n-2; i++){
            for(int j=i+1; j<=n-1; j++){
                for(int k=j+1; k<=n; k++){
                    if(i+j+k == x){
                        count++;
                    }
                }
            }
        }
        cout << count << endl;
    }
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, ll> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

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

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 35;
const int MAXK = 510;
const int MAXQ = 200010;

int n, m;
bool f[MAXN];
ll dp[MAXN];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n >> m;
    FOR(i,1,m) {
        int x;
        cin >> x;
        f[x] = true;
    }
    dp[0] = 1;
    FOR(i,1,n) {
        if (f[i]) continue;
        dp[i] = dp[i-1];
        if (i >= 2) dp[i] = (dp[i] + dp[i-2]) % MODBASE;
    }
    cout << dp[n];
    return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define intt int64_t
#define all(vec) vec.begin(), vec.end()
#define MOD 1000000007

int main() {
    int n;
    scanf("%d", &n);
    double ans = 0;
    rep(i,n) {
        double v;
        string type;
        scanf("%lf", &v);
        cin >> type;
        if (type == "BTC") v *= 380000.0;
        ans += v;
    }
    printf("%lf\n", ans);
}

Measured memory_bytes: 256
N,A,B=map(int,input().split())
V=list(map(int,input().split()))
V=sorted(V,reverse=True)

def fac(n):
  if n<= 1: return 1
  return n*fac(n-1)
def c (a,b): 
  if b==0: return 1
  return fac(a)//fac(b)//fac(a-b)


print(sum(V[:A])/A)

if V.count(V[0]) >= A:
  ans=0
  for i in range(A, min(B+1,V.count(V[0])+1)):
    ans+=c(V.count(V[0]),i)
else:
  ans=c(V.count(V[A-1]), V[:A].count(V[A-1]))
print(ans)
  


Measured memory_bytes: 3064
#include <cstdio>
#include <queue>
#include <iostream>
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long int ll;

using namespace std;


int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
       
    int i,j,k;
    long n,m,tmp;
    int a[10000];
    string s[200000];
    int sum=0;
    double d;
    cin >> n;
    rep(i,n){
        if(i%2==0) sum++;
    }
    d=(double)sum/n;


    cout<< d << endl;

    return 0;
}

Measured memory_bytes: 1792
//
// Created by jal on 2019-10-08.
//

#include <bits/stdc++.h>
using namespace std;
const int N = 100001;
int F[N], W[N];
struct Info{
    int father, weight;
    Info(int father, int weight):father(father), weight(weight){}
};
Info getInfo(int x){
    if(x == F[x]){
        return Info(x, 0);
    }
    Info info_x = getInfo(F[x]);
    F[x] = info_x.father;
    W[x] += info_x.weight;
    return Info(F[x], W[x]);
}
void unite(int x, int y, int z){
    Info info_x = getInfo(x), info_y = getInfo(y);
    if(info_x.father == info_y.father)return;
    F[info_y.father] = info_x.father;
    W[info_y.father] = W[x] - W[y] + z;
}
int main(){
    int n, q;
    scanf("%d %d", &n, &q);
    for(int i = 0; i < n; i++){
        F[i] = i;
    }
    for(int i = 0; i < q; i++){
        int com, x, y, z;
        scanf("%d", &com);
        if(com == 0){
            scanf("%d %d %d", &x, &y, &z);
            unite(x, y, z);
        }else{
            scanf("%d %d", &x, &y);
            Info info_x = getInfo(x), info_y = getInfo(y);
            if(info_x.father == info_y.father){
                printf("%d\n", info_y.weight - info_x.weight);
            }else{
                printf("?\n");
            }
        }
    }
    return 0;
}


Measured memory_bytes: 4012
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void map_add(map<int,int> & mp, int A)
{
  auto itr = mp.find(A);
  if(itr != mp.end())
  {
    itr->second++;
  }
  else
  {
    mp[A] = 1;
  }
  return;
}
void solve(void)
{
  int N;
  cin>>N;
  int ANS = INF;
  for (int i = 1; i*i <= N; i++)
  {
    if(N%i == 0)
    {
    int A = i;
    int B = N/i;
    int MAX = max((int)(log10(A) + 1),(int)(log10(B) + 1));
    chmin(ANS,MAX);
    }
  }
  cout<<ANS<<endl;
  return; 
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<stack>
#include<algorithm>
#include<vector>
using namespace std;
stack<int> st;
int ch[100010];
vector<pair<int,int>> vt[4];
int main()
{
	int n, m, k;
	scanf("%d %d %d", &n, &m, &k);
	for (int i = 1; i <= k; i++) {
		int q, w, e, r;
		scanf("%d %d %d %d", &q, &w, &e, &r);
		if ((q == 0 || q == n || w == 0 || w == m) && (e == 0 || e == n || r == 0 || r == m)) {
			if (q == 0)
				vt[0].push_back({ w,i });
			else if (w == m)
				vt[1].push_back({ q,i });
			else if (q == n)
				vt[2].push_back({ w,i });
			else if (w == 0)
				vt[3].push_back({ q,i });
			if (e == 0)
				vt[0].push_back({ r,i });
			else if (r == m)
				vt[1].push_back({ e,i });
			else if (n == e)
				vt[2].push_back({ r,i });
			else if (r == 0)
				vt[3].push_back({ e,i });
		}
	}
	for (int i = 0; i < 4; i++) 
		sort(vt[i].begin(), vt[i].end());
	for (int i = 2; i < 4; i++)
		reverse(vt[i].begin(), vt[i].end());
	for (int i = 0; i < 4; i++) {
		for (int y = 0; y < vt[i].size(); y++) {
			int next = vt[i][y].second;
			ch[next]++;
			if (ch[next] == 1)
				st.push(next);
			else {
				if (st.top() != next) {
					puts("NO");
					return 0;
				}
				else st.pop();
			}
		}
	}
	puts("YES");
}

Measured memory_bytes: 2588
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdlib.h>
#include<utility>
#include<functional>
#include<cfenv>
#include<cmath>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define vint vector<int>
#define vvint vector<vint>
#define P pair<ll,ll>
#define INT_MAX 2147483647
using namespace std;
typedef long long ll;


int main(void) {
	int H, N; cin >> H >> N;
	vint a(N+1), b(N+1);
	rep(i, N) {
		cin >> a[i+1] >> b[i+1];
	}

	vvint dp(N + 1, vint(H + 1,0));
	rep(i, H + 1) {
		dp[0][i] = INT_MAX;
	}
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= H; j++) {
			int x = (int)ceil((double)j / (double)a[i])*b[i];
			int y = dp[i - 1][j];
			dp[i][j] = min(x,dp[i-1][j]);
			if (j < a[i]) {
				dp[i][j] = min(b[i], dp[i - 1][j]);
			}
			else {
				dp[i][j] = min(min(dp[i][j - a[i]],dp[i-1][j-a[i]]) + b[i], dp[i - 1][j]);
			}
		}
	}

	cout << dp[N][H] << endl;
	return 0;
}

Measured memory_bytes: 39424
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		char[] s = sc.next().toCharArray();

		if((s[0] == s[1])&&(s[1] == s[2])) {
			pw.print("No");
		}else {
			pw.print("Yes");
		}
		pw.close();

	}

	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

	    public String next() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

	    public String nextLine() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                return reader.readLine();
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }

	        return tokenizer.nextToken("\n");
	    }

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

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

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

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public long[] nextLongArray(int n) {
	        long[] a = new long[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextLong();
	        return a;
	    }
	}
}

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

typedef long long ll;
using namespace std;

int pot (ll q, ll w){
	ll qw = q;
	q = 1;
	for (int i = 0; i<w; i++)
		q*= qw;
	return q;
}

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

double r;
cin >> r;
cout << 2*3.14*r;






return 0;
}


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

using namespace std;

int N, x, res;
vector < int > p;

int main() {
    cin >> N;
    
    for (int i = 1; i <= N; ++i) {
        cin >> x;
        
        if (x == i) {
            p.push_back(i);
        }
    }
    
    for (int i = p.size() - 1; i >= 0; --i) {
        if (i > 0 && p[i] == p[i - 1] + 1) {
            ++res;
            --i;
        } else {
            ++res;
        }
    }
    
    cout << res << '\n';
    
    return 0;
}

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

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    string s;
    cin>>s;
    if(s=="ABC"){
        cout<<"ARC"<<endl;
    }
    else
        cout<<"ABC"<<endl;
    return 0;
}


Measured memory_bytes: 3612
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

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

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar[4] = {{0,1},{0,-1},{1,0},{-1,0}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
  int nya[3][3];
  bool ha[3][3];
  for(int i = 0; 3 > i; i++){
    for(int j = 0; 3 > j; j++){
      cin>>nya[i][j];
      ha[i][j] = false;
    }
  }
  int q;cin>>q;
  for(int i = 0; q > i; i++){
    int z;cin>>z;
    for(int j = 0; 3 > j; j++){
      for(int k = 0; 3 > k; k++){
        if(nya[j][k] == z){
          ha[j][k] = true;
        }
      }
    }
  }

  for(int i = 0; 3 > i; i++){
    if(ha[i][0] && ha[i][1] && ha[i][2]){
      cout << "Yes" << endl;
      return 0;
    }
  }
  for(int i = 0; 3 > i; i++){
    if(ha[0][i] && ha[1][i] && ha[2][i]){
      cout << "Yes" << endl;
      return 0;
    }
  }
  if(ha[0][0] && ha[1][1] && ha[2][2]){
    cout << "Yes" << endl;
    return 0;
  }
  if(ha[0][2] && ha[1][1] && ha[2][0]){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  for (;;) {
    auto rd = readln.split.map!(to!int), h = rd[0], w = rd[1];
    if (h == 0 && w == 0) break;
    foreach (_; 0..h)
      writeln('#'.repeat(w));
    writeln;
  }
}

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

int main()
{
    int A,B,K,i,p;
    cin>>K;
    cin>>A>>B;

    for(i=A;i<=B;i++)
    {
        if(i%K==0)
        {
            cout<<"OK"<<endl;
            return 0;
        }
    }

    cout<<"NG"<<endl;
    return 0;
}


Measured memory_bytes: 3604
#!/usr/bin/env python3
def main():
    N, K = map(int, input().split())
    P = [int(x) - 1 for x in input().split()]
    C = [int(x) for x in input().split()]

    ans = -10 ** 9
    for start in range(N):
        # ループを探す
        now = start
        loop = []
        total = 0
        while now != start or not loop:
            loop.append(C[now])
            now = P[now]
            total += C[now]
        # ループごとの最大スコアを探す
        length = len(loop)
        # sum_loop = sum(loop)
        # # ループ長よりも操作回数が多いか？，ループを周回すると得か？で場合分け
        # res = 0 if sum_loop <= 0 else sum_loop * (K // length)
        # limit = K if K <= length else K % length
        # for k in range(limit):
        #     res += loop[k]
        #     ans = max(ans, res)
        t = 0
        for i in range(length):
            t += loop[i]
            if i + 1 > K:
                break
            now = t
            if total > 0:
                e = (K - (i + 1)) // length
                now += total * e
            ans = max(ans, now)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 84248
#include<bits/stdc++.h>
using namespace std;
int main()
{
string s1,s2;
cin>>s1>>s2;
int l=s1.length();
int cnt=0;
for(int i=0;i<l;i++)
{
    if(s1[i]!=s2[i])
    {
        cnt++;
    }

}
cout<<cnt;
}


Measured memory_bytes: 3912
#include<iostream>
#include<bits/stdc++.h>
#include<string>
using namespace std;
int main()
{
    int t,c=0;

      string s,s1;
      cin>>s>>s1;
      for(int i=0;i<s.size();i++)
      {
          if(s[i]==s1[i])
            c++;
      }
      if(c==s.size())

              cout<<"Yes"<<endl;
      else
        cout<<"No"<<endl;
}


Measured memory_bytes: 3620
#include "bits/stdc++.h"

using namespace std;

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	int n;

	cin >> n;

	vector<int> a(n);

	for (auto& x : a) {
		cin >> x;
	}

	int s = 0,ans = 1,sn;

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

		if (sn != 0) {
			if (s == 0) {
				s = sn;
			}
			else if (sn != s) {
				ans++;
				s = 0;
			}
		}

	}

	cout << ans << endl;

	return 0;

}

Measured memory_bytes: 640
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#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 FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class FIntervalRunning {
public:
    static constexpr int kStressIterations = 0;

    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int t1, t2, a1, a2, b1, b2;
        cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
        if (a1 * t1 + a2 * t2 == b1 * t1 + b2 * t2) {
            cout << "infinity" << endl;
            return;
        }
        if (a1 > b1) {
            swap(a1, b1);
            swap(a2, b2);
        }
        if (a1 * t1 + a2 * t2 < b1 * t1 + b2 * t2) {
            cout << 0 << endl;
            return;
        }

        int d1 = b1 * t1 - a1 * t1;
        int d2 = (a1 * t1 + a2 * t2) - (b1 * t1 + b2 * t2);
        int num = d1 / d2;
        int res = 1 + 2 * num;
        if (num > 0 && d1 % d2 == 0) res--;
        cout << res << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    FIntervalRunning solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::cmp::{min, max};
use std::collections::{HashMap, HashSet, VecDeque, BinaryHeap};

fn main() {
    input!{
        n: usize
    }
    let mut ans = 0;
    let fac = factor(n);
    for &(_, e) in &fac {
        let mut i = 1;
        while (i + 1) * (i + 2) <= 2 * e {
            i += 1;
        }
        ans += i;
    }
    println!("{}", ans);
}

fn factor(mut n: usize) -> Vec<(usize, usize)> {
    let mut ret = vec![];
    let mut p = 0;
    while n % 2 == 0 {
        p += 1;
        n /= 2;
    }
    if p != 0 {
        ret.push((2, p));
    }
    let mut r = 3;
    while r * r <= n {
        p = 0;
        while n % r == 0 {
            p += 1;
            n /= r;
        }
        if p != 0 {
            ret.push((r, p));
        }
        r += 2;
    }
    if n != 1 {
        ret.push((n, 1));
    }
    ret
}


Measured memory_bytes: 2168
#include <iostream>
#include <cassert>

#define DVSR  1'000'000'007
#define DVSRA 1'000'000'005

long long int add(long long int a, long long int b) {
    return (a % DVSR + DVSR + b % DVSR) % DVSR;
}

long long int multiply(long long int a, long long int b) {
    return (a * b) % DVSR;
}

long long int power(long long int a, long long int b) {
    if (b == 0) return 1;
    if (b == 1) return a % DVSR;
    int s = power(a, b/2);
    int ss = multiply(s, s);
    if (b % 2 == 0) return ss;
    return multiply(ss, a);
}

long long int divide(long long int a, long long int b) {
    return multiply(a, power(b, DVSRA));
}

long long int choose(int n, int k) {
    assert(k >= 0);
    if (k > n) return 0;
    if (k > n - k) return choose(n, n - k);

    long long int x = 1;

    for (int i=1; i<=k; i++)
        x = divide(multiply(x, n-i+1), i);

    return x;
}

long long int f(int N, int M) {
    long long int sum = 0;
    sum = add(sum, +multiply(power(N, 3), power(M, 2)));
    sum = add(sum, +multiply(power(N, 2), power(M, 3)));
    sum = add(sum, -multiply(power(N, 2), power(M, 1)));
    sum = add(sum, -multiply(power(N, 1), power(M, 2)));
    sum = divide(sum, 6);
    return sum;
}


long long int g(int n, int k) {
    long long int v = choose(n-2, k-2);
    return v;
}

int main() {
    // Given values
    int N; // # of rows
    int M; // # of columns
    int K; // # of pieces
    std::cin >> N >> M >> K;

    // Bounds
    assert(2 <= N * M && N * M <= 200'000); // the grid size
    assert(2 <= K && K <= N * M);           // # of piece

    // Computation
    long long int sum = multiply(
            f(N, M),  // the sum of the grid cost
            g(N*M, K) // # of combinations
            // choose(N*M-2, K-2) // # of combinations
            );

    std::cout << sum << std::endl;

    return 0;
}


Measured memory_bytes: 256
H,W=map(int,input().split())
G=[list(input()) for i in range(H)]
hcnt,wcnt=set(),set()
for i in range(H):
    ok=True
    for j in range(W):
        if(G[i][j]=='#'):
            ok=False
            break
    if(ok):
        hcnt.add(i)
for j in range(W):
    ok=True
    for i in range(H):
        if(G[i][j]=='#'):
            ok=False
            break
    if(ok):
        wcnt.add(j)

for i in range(H):
    cnt=0
    if(i in hcnt):
        continue
    for j in range(W):
        if(j in wcnt):
            continue
        print(G[i][j],end='')
        cnt+=1
    if(cnt>0):
        print()

Measured memory_bytes: 43352
#include <iostream>
#include <cmath>
using namespace std;
int n, k=1, a[55];
int main() {
	int i;
	cin>>n;
	for(i=1; i<=n; i++) {
		cin>>a[i];
		if(abs(a[i])>abs(a[k])) k = i;
	}
	cout<<2*n-1<<endl;
	for(i=1; i<=n; i++) cout<<k<<' '<<i<<endl;
	if(a[k]>0) for(i=1; i<n; i++) cout<<i<<' '<<i+1<<endl;
	else for(i=n; i>1; i--) cout<<i<<' '<<i-1<<endl;
	return 0;
}

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

#define all(A) begin(A), end(A)
#define rall(A) rbegin(A), rend(A)
#define sz(A) int(A.size())
#define pb push_back
#define mp make_pair

using namespace std;

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

int main () {
  ios::sync_with_stdio(false); cin.tie(0);
  string s;
  cin >> s;
  vector <int> arr;
  for (int l = 0; l < sz(s);) {
    int r = l;
    while (r + 1 < sz(s) and s[l] == s[r + 1]) r++;
    arr.push_back(r - l + 1);
    l = r + 1;
  }
  vector <int> ans(sz(s));
  int cur = 0;
  for (int pos = 0; pos < sz(arr); pos += 2) {
    cur = cur + arr[pos];
    int l = cur - 1;
    int r = cur;
    ans[l] += (arr[pos] + 1) / 2;
    ans[r] += arr[pos] / 2;
    ans[r] += (arr[pos + 1] + 1) / 2;
    ans[l] += arr[pos + 1] / 2;
    cur += arr[pos + 1];
  }
  for (int i = 0; i < sz(s); i++) cout << ans[i] << " \n"[i == sz(s) - 1];
  return (0);
}


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

def main():
    N,K = map(int, input().split())
    X = list(map(int, input().split()))
    ans = 3*10**8
    for i in range(0,N-K+1):
        l = X[i]
        r = X[i+K-1]
        if l*r < 0:
            ans = min(ans, 2*min(abs(l),abs(r)) + max(abs(l),abs(r)))
        else:
            ans = min(ans, max(abs(l),abs(r)))

    print(ans)

if __name__ == '__main__':
    main()


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

int main() {
  long m = 1000000007;

  int s;
  cin >> s;

  if (s < 3) {
    cout << 0 << endl;
    return 0;
  }

  vector<long> series(s + 1);
  series[0] = 0;
  series[1] = 0;
  series[2] = 0;
  for (int i = 3; i <= s; i++) {
    long a = 1;
    for (int j = 0; j <= i - 3; j++) {
      a += series[j];
      a = a % m;
    }
    series[i] = a;
  }
  long answer = series[s];
  cout << answer << endl;
}

Measured memory_bytes: 3628