akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, greater<>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long int64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//998244353;
const int base = 2187;
const double eps = 1e-8;
const int N = 10'000;
const int LOGN = 19;

int n, m, k;

void solve(int test) {
  int a, b, x;
  cin >> a >> b >> x;
  double ans = 0;
  if (2 * x > a * b * a) {
    ans = atan(2. * (a * a * b - x) / a / a / a);
  } else {
    ans = pi / 2 - atan(2. * x / a / b / b);
  }
  cout.setf(ios::fixed);
  cout.precision(11);
  cout << ans * 180 / pi << '\n';
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a; cin >> a;
    if(a%10 == 3) cout << "bon" << endl;
    else if(a%10 == 0 || a%10 == 1 || a%10 == 6 || a%10 == 8) cout << "pon" << endl;
    else cout << "hon" << endl;
    return 0;
}

Measured memory_bytes: 3608
N,K = map(int,input().split())
x = list(map(int,input().split()))

ans = []
for i in range(N-K+1):
    if x[i] < 0 and x[i+K-1] > 0:
        ans += abs(x[i]) + abs(x[i+K-1]) + min(abs(x[i]),abs(x[i+K-1])),
    elif x[i] < 0:
        ans += -x[i],
    else:
        ans += x[i+K-1],
print(min(ans))

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;

int main(){
    int x,y; cin>>x>>y;
    rep(i,103)rep(j,103){
        if(2*i+4*j==y&&i+j==x){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long int n;
  cin>>n;
  long long int res = 0;
  long long int q = pow(10, 9) + 7;
  long long int temp = 1;
  for (long long int i = 0; i<n; ++i) {
  	temp*=10;
  	temp = temp%q;
  }
  res+=temp;
  //cout<<res<<"\n";
  temp = 1;
  for (long long int i = 0; i<n; ++i) {
  	temp*=9;
  	temp = temp%q;
  }
  res -= temp;
  res += q;
  res = res%q;
  res -= temp;
  res += q;
  res = res%q;
  //cout<<res<<"\n";
  temp = 1;
  for (long long int i = 0; i<n; ++i) {
  	temp*=8;
  	temp = temp%q;
  }
  res += temp;
  res = res%q;
  if (res<0) {
  	res = q-res;
  }
  cout<<res;
}

Measured memory_bytes: 3628
n = gets.chomp.to_i

p = ((-1 + Math.sqrt(1 + 8 * n))/2).ceil
sum = p * (p + 1) / 2
diff = sum - n
ary = (1..p).to_a
if diff.zero?
  puts ary.join(' ')
else
  puts (ary - [diff]).join(' ')
end


Measured memory_bytes: 3836
import core.bitop;
import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.format;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
  string str = readln.chomp;
  int n = cast(int) str.length;
  int[] a = new int[](n + 1);
  foreach (i; 0..n) {
    a[i + 1] = a[i] ^ (1 << (str[i] - 'a'));
  }
  int[] dp = new int[](1 << 26);
  dp[] = int.max >> 2;
  dp[0] = 0;
  foreach (i; 1..n + 1) {
    int opt = dp[a[i]];
    foreach (j; 0..26) {
      opt = min(opt, dp[a[i] ^ (1 << j)]);
    }
    // stderr.writeln(format("%02d", i), " ", format("%026b", a[i]), " ", opt);
    dp[a[i]] = min(dp[a[i]], opt + 1);
  }
  dp[a[n]].max(1).writeln;
}


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

typedef long long ll;
int n;
ll a[100005],x,Out;

int main(){
	cin>>n>>x;
	for(int i = 1; i <= n; i++) cin>>a[i];
	for(int i = 1; i <= n; i++){
		if(a[i] + a[i - 1] > x){
			ll t= a[i] + a[i-1] - x;
			Out += t;
			a[i] = x - a[i - 1];
		}
	}
	cout<<Out;
	return 0;
} 


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e4+7;
int n,m;
int Wight[10] = {0,2,5,5,4,5,6,3,7,6},A[10];
vector<string> dp(maxn,"-");
string Max(string a,string b){
    if(a.size() != b.size())return a.size()>b.size()?a:b;
    return a>b?a:b;
}
signed main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)scanf("%d",&A[i]);
    dp[0] = "";
    for(int i=0;i<=n;i++)if(dp[i]!="-"){
        for(int j=1;j<=m;j++)if(i+Wight[A[j]]<=n){
            dp[i+Wight[A[j]]] = Max(dp[i+Wight[A[j]]],dp[i]+char(A[j]+'0'));
        }
    }
    cout<<dp[n]<<endl;
    return 0;
}


Measured memory_bytes: 43648
N = int(input())
A = list(map(int, input().split()))


def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    return gcd(b, a % b)


L = [0] * (N + 1)
R = [0] * (N + 1)
for i in range(N):
    L[i+1] = gcd(L[i], A[i])
    R[N-i-1] = gcd(R[N-i], A[N-i-1])

ans = 1
for i in range(N):
    ans = max(ans, gcd(L[i], R[i+1]))

print(ans)

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

//#pragma GCC optimize ("Ofast")
//#pragma GCC target ("avx,avx2")

#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define dbg(x) cerr<<#x<<" : "<<x<<endl

typedef long long int ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vii;
const ll INF = 1e18+1;
const ll MOD = 1000000007L;
clock_t time_p=clock();
void timer(){time_p=clock()-time_p;cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";}

template <typename Arg1> ostream& operator << (ostream& out, const vector<Arg1> &a) {out<<"[ ";for(const auto &x:a)out<<x<<" ";return out<<"]";}
ll h,w,k;

const ll maxsum = 2000*2000;

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

    ll n;
    cin>>n;
    vi a(n);
    ll sum=0;
    rep(i,n){
        cin>>a[i];
        sum += a[i];
    }
    dbg(sum);


    bitset<maxsum+1>v;
    v[0] = true;
    rep(i,n){
        v = v | v<<a[i];
    }

    //dbg(v);

    rep(i,sum+1){
        if(v[i] && i >= (sum+1)/2){
            cout<<i<<endl; exit(0);
        }
    }




    timer();
    return 0;
}


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

namespace EDPC
{
    class A2
    {
        static void Main(string[] args)
        {
            // input
            long[] input = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long N = input[0];
            long K = input[1];
            long[] h = Console.ReadLine().Split().Select(long.Parse).ToArray();

            //DP table
            long[] DP = new long[N].Select(x => x = int.MaxValue).ToArray();

            // Main
            DP[0] = 0;
            DP[1] = Math.Abs(h[1] - h[0]);
            for (long i = 2; i < N; i++)
            {
                for (long j = 1; j <= K; j++)
                {
                    if (0 <= i - j) DP[i] = Math.Min(DP[i], DP[i - j] + Math.Abs(h[i] - h[i - j]));
                }
            }
            Console.WriteLine(DP[N - 1]);
        }
    }
}


Measured memory_bytes: 24672
#include<bits/stdc++.h> 
using namespace std;
const int roll[10][10]=
			{
				{3, 2, 6, 1, 5, 4}, //W
				{4, 2, 1, 6, 5, 3}, //E
				{2, 6, 3, 4, 1, 5}, //N
				{5, 1, 3, 4, 6, 2}, //S
			};
int main()
{
	int dice[10], newdice[10], key[200];
	string cmd;
	key['W']=0, key['E']=1, key['N']=2, key['S']=3;
	for(int i=0;i<6;i++)
	{
		cin>> dice[i];
	}
	cin>> cmd;
	for(int i=0;i<cmd.size();i++)
	{
		for(int j=0;j<6;j++)
		{
			newdice[j]=dice[roll[key[cmd[i]]][j]-1];
		}
		for(int j=0;j<6;j++)
		{
			dice[j]=newdice[j]; 
		} 
	}
	cout<< dice[0]<< endl;
	return 0;
}


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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;


int main(){

    int n,m;
    cin>>n>>m;
    vector<vector<int>>light(m);
    rep(l,m){
        int k;
        cin>>k;
        rep(i,k){
            int sw;
            cin>>sw;
            light[l].emplace_back(sw-1);
        }
    }
    int p[m];
    rep(i,m)cin>>p[i];
    
    int switches[n];
    switches[0]=1;
    rep(i,n-1)switches[i+1]=switches[i]*2;

    int ans=0;

    for(int i=0;i<(1<<n);i++){
        bool on[n]={};
        bool all_on=true;
        rep(k,n)if(i&switches[k])on[k]=true;

        rep(l,m){
            int now=0;
            for(auto sw:light[l]){
                if(on[sw])now++;
            }
            if(now%2!=p[l]){
                all_on=false;
                break;
            }
        }
        if(all_on)ans++;
        
        
    }

    cout<<ans<<endl;


    return 0;

}
/*


*/


Measured memory_bytes: 256
//#include <bits/stdc++.h>
//
//using namespace std;
//
//typedef long long ll;
//const int maxn=1e5+5;
//typedef long long ll;
//
//ll a[maxn],b[maxn],sum[maxn];
//ll sum2[maxn];
//
//int main()
//{
//    ios::sync_with_stdio(false);
//    int n;
//    while(cin>>n){
//        for(int i=0;i<n;i++){
//            cin>>a[i];
//        }
//        for(int i=0;i<n;i++){
//            cin>>b[i];
//            if(!i) sum[i]=b[i];
//            else sum[i]=sum[i-1]+b[i];
//        }
//        memset(sum2,0,sizeof(sum2));
//        priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > >que;
//        pair<int,int>temp;
//        for(int i=0;i<n;i++){
//            int p=lower_bound(sum,sum+n,a[i]+sum[i-1])-sum;
//            temp.first=p,temp.second=i;
//            que.push(temp);
//        }
//        ll cnt=0;
//        ll ss=0;
//        for(int i=0;i<n;i++){
//            ss=0;
//            cnt++;
//            if(que.top().first==i){
//                cnt--;
//                int id=que.top().second;
//                que.pop();
//                if(!id)
//                    ss+=-sum[id]+a[id]+sum[id-1];
//                else
//                    ss=-sum[id]+a[id];
////                cout<<id<<"   "<<ss<<endl;
//            }
//            ss+=cnt*b[i];
////            cout<<cnt<<" "<<ss<<endl;
//            cout<<ss<<endl;
//        }
//    }
//    return 0;
//}


#include <bits/stdc++.h>
using namespace std;

const int maxn=100;
char s[maxn][maxn];

int main()
{
    ios::sync_with_stdio(false);
    int a,b;
    while(cin>>a>>b){
        for(int i=0;i<50;i++){
            for(int j=0;j<maxn;j++){
                s[i][j]='#';
            }
        }
        for(int i=50;i<maxn;i++){
            for(int j=0;j<maxn;j++){
                s[i][j]='.';
            }
        }
        a--,b--;
        int r=1,c=1;
        while(a--){
            s[r][c]='.';
            c+=2;
            if(c>=maxn){
                r+=2,c=1;
            }
        }
        r=51,c=1;
        while(b--){
            s[r][c]='#';
            c+=2;
            if(c>=maxn){
                r+=2,c=1;
            }
        }
        printf("100 100\n");
        for(int i=0;i<maxn;i++){
            for(int j=0;j<maxn;j++){
                printf("%c",s[i][j]);
            }
            printf("\n");
        }
    }
    return 0;
}


Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Data.List
import Data.Array.IArray
import Data.Array.MArray
import Data.Array.Unboxed
import Data.Array.ST
import Data.STRef

solve :: Int -> Int -> [Int] -> Int
solve n a xs = sum $ [memo ! (n, k, k * a) | k <- [1 .. n]]
  where
    x = maximum (a:xs)
    xa = listArray (1, n) xs :: UArray Int Int

    memo :: UArray (Int, Int, Int) Int
    memo = runSTUArray $ do
        m <- newArray ((0, 0, 0), (n, n, n * x)) (-1)
        let is = [(j, k, s) | j <- [0 .. n], k <- [0 .. n], s <- [0 .. n * x]]
        forM_ is $ \(j, k, s) -> iter m j k s
        return m
      where
        iter m 0 0 0 = writeArray m (0, 0, 0) 1
        iter m j k s
            | j >= 1, s < (xa ! j) = do
                a <- readArray m (j - 1, k, s)
                writeArray m (j, k, s) a
            | j >= 1, k >= 1, s >= (xa ! j) = do
                a <- readArray m (j - 1, k, s)
                b <- readArray m (j - 1, k - 1, s - (xa ! j))
                writeArray m (j, k, s) (a + b)
            | otherwise = do
                writeArray m (j, k, s) 0

main :: IO ()
main = do
    [n, a] <- fmap read . words <$> getLine :: IO [Int]
    xs <- fmap read . words <$> getLine :: IO [Int]
    print $ solve n a xs

Measured memory_bytes: 52348
package main
 
import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
	"math"
)
 
func run() {

	var N int;
    N = nextInt();
    var L int;
    L = nextInt();
	solve(N, L);

}

func solve(N int, L int){
	ans := 0.0
	for i := 1; i <= int(N); i++ {
		ans += float64(i+L-1)
	}
	if L > 0 {
		Println(int(ans)-L)
	}else if int(math.Abs(float64(L))) < N {
		Println(ans)
	}else {
		Println(ans + math.Abs(float64(L+N)-1))
	}
}


// --- template ---
// Thanks https://gist.github.com/halllllll/853ab587fd82ee3ffe6f7fb7fb499695
 
var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)
 
// Caution: You will get unexpected result if a single token is larger than this size.
const BufferSize = 64 * 1024 * 1024
 
func Print(a ...interface{}) (n int, err error) {
	return fmt.Fprint(out, a...)
}
 
func Printf(format string, a ...interface{}) (n int, err error) {
	return fmt.Fprintf(out, format, a...)
}
 
func Println(a ...interface{}) (n int, err error) {
	return fmt.Fprintln(out, a...)
}
 
func next() string {
	sc.Scan()
	return sc.Text()
}
 
func nextInt() int {
	a, err := strconv.Atoi(next())
	if err != nil {
		log.Fatal(err)
	}
	return a
}

func nextFloat() float64 {
	a, err := strconv.ParseFloat(next(), 64)
	if err != nil {
		log.Fatal(err)
	}
	return a
}


type IntHeap []int
func (h IntHeap) Len() int           { return len(h) }
func (h IntHeap) Less(i, j int) bool { return h[i] > h[j] }
func (h IntHeap) Swap(i, j int)      { h[i], h[j] = h[j], h[i] }

func (h *IntHeap) Push(x interface{}) {
	// Push and Pop use pointer receivers because they modify the slice's length,
	// not just its contents.
	*h = append(*h, x.(int))
}

func (h *IntHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}

/////数字と文字
// 基本クラス
type NS struct {
    Num int
    Str string
}

//////　数字と数字
// 基本クラス
type NN struct {
    Num1 int
    Num2 int
}

 
func main() {
	sc.Buffer(make([]byte, 0, BufferSize), BufferSize)
	sc.Split(bufio.ScanWords)
	run()
	out.Flush()
}



Measured memory_bytes: 2688
n = int(input())
a = [int(i) for i in input().split() if int(i) % 2 == 0]
f = 1
for i in range(len(a)):
    if a[i] % 3 == 0 or a[i] % 5 == 0:
        f *= 1
    else:
        f *= 0
if f == 0:
    print("DENIED")
else:
    print("APPROVED")


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

#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> P;

const ll mod = 1e9 + 7;


int main() {
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);


    int a, b, c;
    cin >> a >> b >> c;
    if(a + b + c >= 22){
        cout << "bust" << endl;
    }else{
        cout << "win" << endl;
    }


    return 0;
}



Measured memory_bytes: 256
def main():
    A, B, C = map(int, input().split())
    visited = set()
    count = 0
    while A % 2 == 0 and B % 2 == 0 and C % 2 ==0:
        count += 1
        visited.add((A, B, C))
        A, B, C = (B+C)//2, (C+A)//2, (A+B)//2
        if (A, B, C) in visited:
            return -1
    return count

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 3064
from collections import deque

h, w = map(int, input().split())
cx, cy = map(lambda x: int(x) - 1, input().split())
dx, dy = map(lambda x: int(x) - 1, input().split())
s = [input() for _ in range(h)]
c = [[10**6] * w for _ in range(h)]


def bfs():
    d = ((1, 0), (-1, 0), (0, 1), (0, -1))
    q = deque([(cx, cy)])

    c[cx][cy] = 0

    while q:
        x, y = q.pop()
        cp = c[x][y]
        if (x, y) == (dx, dy):
            c[x][y] = cp
            break
        for i, j in d:
            nx = x + i
            ny = y + j
            if 0 <= nx < h and 0 <= ny < w and s[nx][ny] != "#" and c[nx][
                    ny] > cp:
                q.append((nx, ny))
                c[nx][ny] = cp
        cp += 1
        for i in range(-2, 3):
            for j in range(-2, 3):
                nx = x + i
                ny = y + j
                if 0 <= nx < h and 0 <= ny < w and s[nx][ny] != "#" and c[nx][
                        ny] > cp:
                    c[nx][ny] = cp
                    q.appendleft((nx, ny))

    return -1 * (c[dx][dy] == 10**6) or c[dx][dy]


print(bfs())


Measured memory_bytes: 95672
#include<iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>

using namespace std;



int main()
{
    vector<char> n(3);

    for (int i = 0; i < 3; i++) {
        cin >> n[i];
    }
    int out=0;

    if (n[0] == 'R') {
        if (n[1] == 'R') {
            if (n[2] == 'R') {
                out = 3;
            }
            else {
                out = 2;
            }
        }
        else {
            if (n[2] == 'R') {
                out = 1;
            }
            else {
                out = 1;
            }
        }
    }
    else {
        if (n[1] == 'R') {
            if (n[2] == 'R') {
                out = 2;
            }
            else {
                out = 1;
            }
        }
        else {
            if (n[2] == 'R') {
                out = 1;
            }
            else {
                out = 0;
            }
        }

    }

    cout << out;


    return 0;
}



Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int a;
  cin>>a;
  string b;
  cin>>b;
  long long int c = ((b[0]-'0')*100)+((b[2]-'0')*10)+(b[3]-'0');
  a*=c;
  cout<<a/100;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
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; }
const long long INF = 1LL << 60;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
#define MAX_N 100100
#define MOD 1000000007
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}

ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

void  base_num(ll data,ll base){
    if(data==0) return;
    ll next=abs(data)%abs(base);
    if(data<0) next=(abs(base)-next)%abs(base);
    base_num((data-next)/base,base);
    cout << next;
}

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main(){
    
    ll N,ans=0;
    cin >> N;
    const auto &res = prime_factorize(N);
    for (ll i=0;i<res.size();i++){
        ll x=res[i].second;
        for (ll j=1;x>0;j++){
            x-=j;
            if (x>=0)ans++;
        }
    }
    cout << ans << endl;
    return 0;
}
 
 

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

map <long long int,long long int> cnt1,cnt2;

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

	int n,t;
	cin >> n;

	for(int i=0;i<n;i++)
	{
		cin >> t;
		cnt1[i + 1 + t]++;
		cnt2[(i + 1) - t]++;
	}

	long long int res = 0;

	for(auto it : cnt1)
	{
		res += (cnt2[it.first]*it.second);
	}

	cout << res << '\n';
	
	return 0;
}


Measured memory_bytes: 37916
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define x first
#define y second

using namespace std;

typedef long long ll;

const int INF = (int) 2e9;

pair <int, int> otr[100005];

bool cmp(pair <int, int> A, pair <int, int> B)
{
 	return (A.y < B.y);
}

int main()
{
 	//freopen("input.txt", "r", stdin);
 	//freopen("output.txt", "w", stdout);
 	ios_base::sync_with_stdio(0); cin.tie(0);
 	int n;
 	cin >> n;
 	for (int i = 1; i <= n; i++)
 	{
 		int x, len;
 		cin >> x >> len;
 		otr[i] = mp(x - len, x + len);
 	}
 	sort(otr + 1, otr + n + 1, cmp);

 	int ans = 0, last = -INF;
 	for (int i = 1; i <= n; i++)
 		if (otr[i].x >= last) last = otr[i].y, ans++;
 	cout << ans << '\n';
 	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int64_t> data(60, 0);
  for(int i = 0; i < N; i++) {
    int64_t a;
    cin >> a;
    bitset<60> s(a);
    for(int j = 0; j < 60; j++) {
      if(s.test(j)) {
        data.at(j)++;
      }
    }
  }
  int64_t ans = 0;
  for(int i = 0; i < 60; i++) {
    int64_t a = data.at(i) * (N - data.at(i)) % 1000000007;
    int64_t b = 1;
    for(int j = 0; j < i; j++) {
      b *= 2;
      b %= 1000000007;
    }
    ans += a * b % 1000000007;
  }
  cout << ans % 1000000007 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
 
  int N;
  cin >> N;
  int AN[N];
  int ANS[1000];
  bool flag[1000];
  for(int i = 0; i < N; i++){
    flag[i] = true;
  }
  
  for(int i = 0; i < N; i++){
    cin >> AN[i];
    while(flag[i]){
      if(AN[i] % 2 == 0){
        AN[i] = AN[i] / 2;
        ANS[i]++;
      }else{
        flag[i] = false;
      }
    }
  }
  
  for(int i = 0; i < N; i++){
    for(int j = 1; j < N; j++){
      if(ANS[i] > ANS[j]){
        int x = ANS[i];
        ANS[i] = ANS[j];
        ANS[j] = x;
      }
    }
  }
  
  cout << ANS[0] << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn = 1e5 + 50;
ll p[64];
int st[64];
int tot = 0;

int n;
int a[maxn];
int b[maxn];
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++) {
        cin>>a[i];
        b[a[i]] = i;
    }
    for(int i=1;i<=n;i++){
        cout<<b[i]<<' ';
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 1664
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

int main(){
    double t,x;
    cin>>t>>x;
    printf("%.10lf\n",t/x);
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

llong n;

int main() {
    cin >> n;
    cout << (n + 1) / 2 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2000000000000000000
#define ll long long
#define pb push_back
using namespace std;

ll H, W;
bool check(ll h, ll w) {
  if (h < 0 || h >= H || w < 0 || w >= W) {
    return false;
  }
  return true;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> H >> W;
  ll ch, cw;
  cin >> ch >> cw;
  ch -= 1;cw -= 1;
  ll dh, dw;
  cin >> dh >> dw;
  dh -= 1;dw -= 1;
  vector<vector<ll>> move = {{0, 1}, {1, 0}, {-1, 0}, {0, -1}};
  vector<vector<char>> maze(H, vector<char>(W));
  for (ll i = 0; i < H; ++i) {
    for (ll j = 0; j < W; ++j) {
      cin >> maze.at(i).at(j);
    }
  }
  vector<vector<ll>> dp(H, vector<ll>(W, INF));
  dp.at(ch).at(cw) = 0;
  set<vector<ll>> q;
  q.insert({0, ch, cw});
  while (!q.empty()) {
    vector<ll> now = *q.begin();
    ll h = now.at(1), w = now.at(2);
    q.erase(q.begin());
    if (now.at(0) > dp.at(h).at(w)) {
      continue;
    }
    for (ll i = 0; i < 4; ++i) {
      ll nh = h + move.at(i).at(0), nw = w + move.at(i).at(1);
      if (!check(nh, nw)) {
        continue;
      }
      if (maze.at(nh).at(nw) == '#') {
        continue;
      }
      if (dp.at(nh).at(nw) > dp.at(h).at(w)) {
        q.insert({dp.at(h).at(w), nh, nw});
        dp.at(nh).at(nw) = dp.at(h).at(w);
      }
    }
    for (ll i = -2; i <= 2; ++i) {
      for (ll j = -2; j <= 2; ++j) {
        ll nh = h + i, nw = w + j;
        if (!check(nh, nw)) {
          continue;
        }
        if (maze.at(nh).at(nw) == '#') {
          continue;
        }
        if (dp.at(nh).at(nw) > dp.at(h).at(w) + 1) {
          q.insert({dp.at(h).at(w) + 1, nh, nw});
          dp.at(nh).at(nw) = dp.at(h).at(w) + 1;
        }
      }
    }
  }
  // for (ll i = 0; i < H; ++i) {
  //   for (ll j = 0; j < W; ++j) {
  //     cout << dp.at(i).at(j) << " ";
  //   }
  //   cout << "\n";
  // }
  if (dp.at(dh).at(dw) == INF) {
    cout << -1 << "\n";
  }
  else {
    cout << dp.at(dh).at(dw) << "\n";

  }
}


Measured memory_bytes: 13536
from bisect import bisect_left

n=int(input())
arr=list(map(int,input().split()))
arr=sorted(arr,reverse=True)
dic={}
for val in arr:
  if val not in dic:
    dic[val]=1
  else:
    dic[val]+=1
arr2=[]
for i in range(40):
  arr2.append(2**i)
ans=0
for val in arr:
  pos=bisect_left(arr2,val)
  if val==arr2[pos]:
    persuit=arr2[pos+1]
  else:
    persuit=arr2[pos]
  if persuit-val==val:
    if val in dic:
      if dic[val]>=2:
        ans+=1
        dic[val]-=2
        if dic[val]==0:
          del dic[val]
      else:
        continue
    else:
      continue
  else:
    if val in dic and persuit-val in dic:
      ans+=1
      dic[val]-=1
      if dic[val]==0:
        del dic[val]
      dic[persuit-val]-=1
      if dic[persuit-val]==0:
        del dic[persuit-val]
    else:
      continue
print(ans)

Measured memory_bytes: 109652
#include<iostream>
#include<cstdio>
#include<stack>
#include<algorithm>
#include<cstring>
#include<queue>
#include<vector>
#include<time.h>
#include<random>
#include<string>
#include<cmath>
#include <ctime>
#include<bitset>
#include <cctype>
#define low_bit(x) ((x)&(-(x)))
#define debug cout<<"*********degug**********";
#define index index_
#define ll long long
#define RE register
#define yn yn_
using namespace std;
mt19937 rnd(233);
const long long max_ = 1e5 + 7;
const double alpha = 0.75;
const int mod = 1e9 + 7;
const int inf = 1e9;
const long long INF = 1e18;
int read() {
	int s = 0, f = 1;
	char ch = getchar();
	while (ch<'0' || ch>'9') {
		if (ch == '-')
			f = -1;
		ch = getchar();
	}
	while (ch >= '0'&&ch <= '9') {
		s = s * 10 + ch - '0';
		ch = getchar();
	}
	return s * f;
}
inline int min(int a, int b) {
	return a < b ? a : b;
}
inline int max(int a, int b) {
	return a > b ? a : b;
}
int main() {
	int a = read(), b = read(), t = 0;
	while (b--){
		t += read();
	}
	if (t >= a) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = input()
B = input()
C = input()

ans = 0
for i in range(N):
    c = set([A[i], B[i], C[i]])
    if len(c) == 3:
        ans += 2
    elif len(c) == 2:
        ans += 1

print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
const int maxn = 1<<20;
int n, k, q;
int x[maxn], l[maxn], r[maxn], w[maxn];
int res[maxn];
struct dsu {
	vector<int> p;
	vector<int> r, rtop;
	dsu(int n) : p(n), r(n, 1) { iota(all(p), 0); rtop = p; }
	int par(int v) {
		return p[v] == v ? v : p[v] = par(p[v]);
	}
	void unite(int u, int v) {
		u = par(u), v = par(v);
		if(u == v) return;
		int rr = rtop[u];
		if(r[u] < r[v]) swap(u, v);
		p[v] = u;
		r[u] += r[v];
		rtop[u] = rr;
	}
};
ll d[maxn], s[maxn];
int par[maxn];
vector<int> g[maxn], p[maxn];
void dfs(int v) {
	d[v] += w[v];
	s[v] += 1;
	for(auto &i : g[v]) {
		d[i] = d[v];
		s[i] = s[v];
		par[i] = v;
		dfs(i);
	}
}
vector<ll> solve() {
	memset(d, 0, sizeof d);
	memset(s, 0, sizeof s);
	for(int i = 0; i < maxn; i++) g[i].clear(), p[i].clear();
	vector<ll> ans(q);
	memset(par, -1, sizeof par);
	for(int i = 0; i < n; i++) {
		auto it = lower_bound(x, x+n, x[i]+k)-x;
		if(it < n) g[it].push_back(i), par[i] = it;
	}
	for(int i = 0; i < n; i++) if(par[i] == -1) dfs(i);
	for(int i = 0; i < q; i++) {
		p[r[i]].push_back(i);
	}
	dsu f(n);
	for(int i = 0; i < n; i++) {
		for(auto j : g[i]) f.unite(i, j);
		for(auto &qid : p[i]) {
			int x = l[qid];
			res[qid] = s[x];
			ans[qid] = d[x];
			int y = par[f.rtop[f.par(x)]];
			if(y != -1) {
				res[qid] -= s[y];
				ans[qid] -= d[y];
			}
		}
	}
	return ans;
}
int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> n >> k;
	for(int i = 0; i < n; i++)
		cin >> x[i], w[i] = i;
	cin >> q;
	for(int i = 0; i < q; i++)
		cin >> l[i] >> r[i], l[i]--, r[i]--;
	auto a = solve();
	for(int i = 0; i < n; i++) {
		x[i] *= -1;
		l[i] = n-1-l[i];
		r[i] = n-1-r[i];
		swap(l[i], r[i]);
	}
	reverse(x, x+n);
	reverse(w, w+n);
	auto b = solve();
	for(int i = 0; i < q; i++) cout << b[i] - a[i] + res[i] << '\n';
}


Measured memory_bytes: 105604
#include <stdio.h>

int main(void) {
  int i, j, n, t, ans = 0;
  scanf("%d", &n);
  int l[n * 2];
  for(i = 0; i < n * 2; ++i) scanf("%d", &l[i]);
  for(i = 0; i < n * 2; ++i) for(j = i + 1; j < n * 2; ++j) if(l[i] > l[j]) t = l[i], l[i] = l[j], l[j] = t;
  for(i = 0; i < n * 2; i += 2) ans += l[i];
  printf("%d", ans);
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<cmath>
#include<stdio.h>
using namespace std;

double sum = 0;
int N;
int x[8], y[8];


double calcKyori(int *data) {
	double kyori = 0;
	for (int i = 0;i < N-1;i++) {
		kyori += sqrt(pow(x[data[i]]-x[data[i+1]],2)+pow(y[data[i]]-y[data[i+1]],2));
	}
	
	return kyori;
}

void func(int n,int *data,bool *flag) {
	if (n == N) {
		sum += calcKyori(data);
	}
	else {
		for (int i = 0;i < N;i++) {
			if (flag[i]) {
				data[n] = i;
				flag[i] = false;
				func(n + 1, data,flag);
				flag[i] = true;
			}
		}
	}
	

}

int perm(int n) {
	if (n == 1) {
		return 1;
	}
	else {
		return n * perm(n - 1);
	}
}

void solve5() {
	string str;
	int *data;
	bool *flag;

	cin >> N;
	data = new int[N];
	flag = new bool[N];
	for (int i = 0;i < N;i++) {
		cin >> x[i] >> y[i];
		data[i] = -1;
		flag[i] = true;
	}

	func(0, data,flag);
	sum /= perm(N);

	
	printf("%f\n", sum);

	
}


int main() {

	solve5();
}

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

int main() {
    long N;
    cin >> N;
    int order;
    long num;
    int F = 20;
    for (long i = 1; i <= sqrt(N); i++) {
        if (N % i == 0) {
            num = N / i;
            order = 1;
            while (num / 10 > 0) {
                num /= 10;
                order++;
            }
            F = min(F, order);
        }
    }
    cout << F << endl;
}


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

int main(){
  int N;  
  cin >> N;
  int mod = 1000000007;
  if(N == 1){
    cout << 0 << endl;
    return 0;
  }
  //10^N - 2*9^N + 8^Nをmodしたい
  long long tans = 1;
  long long nans = 1;
  long long eans = 1;

  for(int i = 0; i < N;i++){
    tans *= 10;
    nans *= 9;
    eans *= 8;
    
    tans %= mod;
    nans %= mod;
    eans %= mod;
  }
  long long ans = tans - 2 * nans + eans;
  while(ans < 0)ans += mod;
  cout << ans << endl;
}

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

using namespace std;

int a, b, k;

int main() {
    cin >> a >> b >> k;
    if (k > ((b - a) >> 1)) {
        for (int i = a; i <= b; i++)
            cout << i << "\n";
        return 0;
    }
    for (int i = a; i < a + k; i++)
        cout << i << "\n";
    for (int i = b - k + 1; i <= b; i++)
        cout << i << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <bitset>
#include<vector>
using namespace std;
typedef long long ll;
#define rep(i,k) for(i=0;i<k;i++)


int main() {
	int a=0, b,i,j,k,l,n,z=100,sum=0;
	ll x[52], y[52],p,q,pp,qq;
	cin >> n;
	rep(i, n)cin >> x[i] >> y[i];
	rep(i, n) {
		for (j = i + 1; j < n; j++) {
			p = x[i] - x[j];
			q = y[i] - y[j];
			a = 0;
			rep(k, n) {
				for (l = k + 1; l < n; l++) {
					pp = x[k] - x[l];
					qq = y[k] - y[l];
					if (p == pp && q == qq)a++;
					pp = x[l] - x[k];
					qq = y[l] - y[k];
					if (p == pp && q == qq)a++;
				}
			}
			sum = max(sum, a);
		}
	}
	z = n - sum;
	cout << z;
	return 0;
}

	

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		// スペース区切りの整数の入力
		int b = sc.nextInt();
		int c = sc.nextInt();
		// 文字列の入力
		int t = a;
		a = c;
		c = b;
		b = t;
		// 出力
		System.out.println(a + " " + b + " " + c);
	}
}

Measured memory_bytes: 21844
#include "bits/stdc++.h"
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define pi acos(-1.0)
#define ri register int
#define Max(x, y) (((x) > (y)) ? (x) : (y))
#define Min(x, y) (((x) < (y)) ? (x) : (y))
#define Abs(x) ((x) < 0 ? (-(x)) : (x))
#define int long long
const int maxn = 1e2 + 10;
inline int read()
{
    int f = 1, r = 0;
    char c = getchar();
    while (!isdigit(c)) {
        if (c == '-') {
            f = -1;
        }
        c = getchar();
    }
    while (isdigit(c)) {
        r = 10 * r + c - '0';
        c = getchar();
    }
    return f * r;
}
inline void write(int x)
{
    if (x < 0)
        putchar('-'), x = -x;
    if (x > 9)
        write(x / 10);
    putchar(x % 10 + '0');
}
inline void writesp(int x) { write(x), putchar(' '); }
inline void writeln(int x) { write(x), puts(""); }
int W, H, N, map[maxn][maxn];
signed main()
{
    W = read(), H = read(), N = read();
    for (ri i = 1; i <= N; ++i) {
        int x = read(), y = read(), a = read();
        if (a == 1) {
            for (ri j = 1; j <= x; ++j) {
                for (ri k = 1; k <= H; ++k) {
                    map[j][k] = 1;
                }
            }
        } else if (a == 2) {
            for (ri j = x + 1; j <= W; ++j)
                for (ri k = 1; k <= H; ++k)
                    map[j][k] = 1;
        } else if (a == 3) {
            for (ri j = 1; j <= W; ++j)
                for (ri k = 1; k <= y; ++k)
                    map[j][k] = 1;
        } else {
            for (ri j = 1; j <= W; ++j)
                for (ri k = y + 1; k <= H; ++k)
                    map[j][k] = 1;
        }
    }
    int ans = 0;
    for (ri i = 1; i <= W; ++i) {
        for (ri j = 1; j <= H; ++j) {
            if (!map[i][j])
                ans++;
        }
    }
    writeln(ans);
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ul;
typedef signed long long ll;

mt19937 mt(time(nullptr));
// uniform_int_distribution< int > rand_int(0, 10) // rand[0, 10] inclusive

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  int n, m;
  cin >> n >> m;
  vector< int > a(n);
  for (int i=0; i<n; ++i) cin >> a[i];
  sort(a.rbegin(), a.rend());
  int sum = 0;
  for (int i=0; i<n; ++i) sum += a[i];
  cout << (a[m-1] * 4 * m >= sum ? "Yes" : "No") << endl;
  return 0;
}


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

int main(){
  string s;
  cin >> s;
  int ans = 0;
  if(s.at(0) == 'o'){
    ans++;
  }
  if(s.at(1) == 'o'){
    ans++;
  }
  if(s.at(2) == 'o'){
    ans++;
  }
  cout << 700 + ans * 100 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string haha,b;
	int x;
	int zh(string s);
	cin>>haha>>b;
	x=zh(haha+b);
	if(int(sqrt(x))==sqrt(x))
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
	return 0;
}
int zh(string s)
{
	int tmp=0;
	for(int i=0;i<s.size();i++)
	tmp=tmp*10+(s[i]-'0');
	return tmp;
}

Measured memory_bytes: 256
H = int(input())
def max_heapify(A, i):
    left = i*2
    right = i*2+1
    largest = i
    if left <= H and A[left-1] > A[i-1]:
        largest = left
    if right <= H and A[right-1] > A[largest-1]:
        largest = right
    if largest != i:
        tmp = A[i-1]
        A[i-1] = A[largest-1]
        A[largest-1] = tmp
        max_heapify(A, largest)
def build_max_heap(A):
    for i in range(1, H//2+1)[::-1]:
        max_heapify(A, i)
A = list(map(int, input().split(' ')))
build_max_heap(A)
str_A = " ".join(map(str, A))
print(" {}".format(str_A))


Measured memory_bytes: 63696
#include <cstdio>
#include <queue>
using namespace std;

int main(){
  int c[4][4];
  for (int i = 1; i < 4; i++){
    for (int j = 1; j < 4; j++){
      int k;
      scanf("%d", &k);
      c[i][j] = k;
    }
  }

  int a[4];
  int b[4];

  a[1] = 0;
  for (int i = 1; i < 4; i++){
    b[i] = c[1][i] - a[1];
    a[i] = c[i][1] - b[1];
  }
  for (int i = 1; i < 4; i++){
    for (int j = 1; j < 4; j++){
      if (c[i][j] != a[i] + b[j]) {
        printf("No\n");
        return 0;
      }
    }
  }
  printf("Yes\n");
  return 0;
}


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

class People
{
public:
	People(){}
	People(long long int n, long long int pos, bool stopflag) : n(n), pos(pos), stopflag(stopflag){}
	long long int n, pos;
	bool stopflag;
};
bool operator<(const People& p1, const People& p2)
{
	return p1.pos < p2.pos;
}

int main()
{
	long long int n, t, q;
	cin >> n >> t >> q;

	vector<People> left;
	vector<People> right;
	for (int i = 1; i <= n; i++)
	{
		long long int a, d;
		cin >> a >> d;
		if (d == 1) right.push_back(People(i, a, false));
		if (d == 2) left.push_back(People(i, a, false));
	}
	for (int i = right.size() - 1; i >= 0; i--)
	{
		auto itr = lower_bound(begin(left), end(left), right[i]);
		if (itr == end(left)) continue;
		if (itr->stopflag)
		{
			if (right[i].pos + t >= itr->pos)
			{
				right[i].stopflag = true;
				right[i].pos = itr->pos;
			}
		}
		else
		{
			if (right[i].pos + t >= itr->pos - t)
			{
				right[i].stopflag = true;
				itr->stopflag = true;
				long long int p = (right[i].pos + itr->pos) / 2;
				right[i].pos = p;
				itr->pos = p;
			}
		}
	}
	for (int i = 0; i < left.size(); i++)
	{
		if (left[i].stopflag) continue;
		auto itr = lower_bound(begin(right), end(right), left[i]);
		if (itr == begin(right)) continue;
		itr--;
		if (itr->stopflag)
		{
			if (left[i].pos - t <= itr->pos)
			{
				left[i].stopflag = true;
				left[i].pos = itr->pos;
			}
		}
		else
		{
			if (left[i].pos - t <= itr->pos + t)
			{
				left[i].stopflag = true;
				itr->stopflag = true;
				long long int p = (left[i].pos + itr->pos) / 2;
				left[i].pos = p;
				itr->pos = p;
			}
		}
	}
	for (int i = 0; i < left.size(); i++)
	{
		if (!left[i].stopflag) left[i].pos -= t;
	}
	for (int i = 0; i < right.size(); i++)
	{
		if (!right[i].stopflag) right[i].pos += t;
	}

	for (int i = 0; i < q; i++)
	{
		int a;
		cin >> a;
		for (int j = 0; j < left.size(); j++)
		{
			if (left[j].n == a)
			{
				cout << left[j].pos << endl;
				break;
			}
		}
		for (int j = 0; j < right.size(); j++)
		{
			if (right[j].n == a)
			{
				cout << right[j].pos << endl;
				break;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 6200
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

constexpr int P = 998244353;

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

    int n, s;
    cin >> n >> s;

    ll r = 0;
    vector<int> dp(s + 1, 0);

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

        dp[0]++;
        for (int j = s; j >= a; j--) {
            dp[j] += dp[j - a];
            if (dp[j] >= P) dp[j] -= P;
        }
        r += dp[s];
    }

    cout << r % P << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
typedef long long ll;
const int MAX = 100010;
ll inv[MAX],fact[MAX],fi[MAX],mod = 1000000007;

void inverse(){
	int i;
	inv[1] = 1;
	for(i=2;i<MAX;i++){
		inv[i] = mod - (mod/i)*inv[mod%i]%mod;
	}
	fact[0] = fi[0] = 1;
	for(i=1;i<MAX;i++){
		fact[i] = fact[i-1]*i%mod;
		fi[i] = (fi[i-1]*inv[i])%mod;
	}
}

ll comb(int n,int k){
	if(n<0 || k<0 || n<k){
		return 0;
	}else{
		return fact[n]%mod*fi[k]%mod*fi[n-k]%mod;
	}
}

int main(){
	ll i,n,k;
	cin >> n >> k;
	inverse();
	for(i=1;i<=k;i++){
		cout << comb(k - 1,i - 1)*comb(n - k + 1,i)%mod << endl;
	}
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define MOD 1000000007
#define INF 1e7
#define LINF 1e15
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
// 'a' = 97 'z' = 122 => 'a' = 0 'z' = 25

int main() {
    int n, x, y;
    cin >> n >> x >> y;
    x--; y--;
    vector<int> ans(n-1);
    for(int i = 0; i < n-1; i++){
        for(int j = i+1; j < n; j++){
            int cost = 0;
            if(i <= x && j >= y){ //ショートカット可能
                cost = min((x-i)+(j-y)+1, j-i);
            }else if(i <= x && (j < y && j > x)){ //行きすぎてから戻ってくることができる
                cost = min((x-i)+1+(y-j), j-i);
            }else if(i >= x && (j < y && j > x)){ //戻ってショートカットすることができる
                cost = min((i-x)+(y-j)+1, j-i);
            }else if(i >= x && j >= y){ //戻ってショートカットして右に進んでいく
                cost = min((i-x)+1+(j-y), j-i);
            }else{
                cost = j-i;
            }
            cost--;
            ans[cost]++;
            //cout << "(" << i+1 << ", " << j+1 << ") = " << cost+1 << endl;
        }
    }
    rep(i, ans.size()) cout << ans[i] << endl;
}




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

 int main(){
   int atai,n,power;
   int i,j,k;
   cin>>n; 
   vector<int> taco(n); 
   for(k=0;k<n;k++){
   cin>>taco.at(k);
   }
   for(j=0;j<n-1;j++){
   for(i=j+1;i<n;i++){
     power+=taco.at(i)*taco.at(j);
   }
   }
   cout<<power<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a,b,k,r,s[100],c=0,i;

	scanf("%d%d%d",&a,&b,&k);

	if(a<b){
		a+=b;
		b=a-b;
		a=a-b;
	}
	r=a%b;
	for(i=1;i<=b;i++)
		if((a%i==0)&&(b%i==0)){
			c++;
			s[c-1]=i;
		}
	printf("%d",s[c-k]);
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

class Main {

	public static void main(String[] args){

		Scanner scan = new Scanner(System.in);
		int heigt  = scan.nextInt();
		int width = scan.nextInt();
		scan.close();

		int area = heigt * width;
		int circum = 2*(heigt + width);

		System.out.println(area + " " + circum);

	}

}

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


def main():
    N, Q = map(int, input().split())
    link = [[] for _ in range(N)]
    a = []
    b = []
    a_append = a.append
    b_append = b.append
    for i in range(N-1):
        x, y = map(int, input().split())
        a_append(x)
        b_append(y)
    cost = [0] * N
    for _ in range(Q):
        p, x = map(int, input().split())
        cost[p-1] += x

    for i in range(N-1):
        ai = a[i]-1
        bi = b[i]-1
        ci = cost[i]
        link[ai].append((bi, ci))
        link[bi].append((ai, ci))

    def dfs(v, c, p):
        for nv in link[v]:
            nv0 = nv[0]
            if nv0 != p:
                cost[nv0] += c
                dfs(nv0, cost[nv0], v)

    dfs(0, cost[0], -1)

    print(*cost)


if __name__ == '__main__':
    main()


Measured memory_bytes: 328352
N = list(input())
n = [int(val) for val in reversed(N)] + [0]
ln = len(N)

ans = 0
for i in range(ln):
    if n[i] <= 4: a = n[i]
    elif n[i] == 5:
        if n[i+1] <= 4:
            a = n[i]
        else:
            a = 10 - n[i]
            n[i+1] += 1
    else:
        n[i+1] += 1
        a = 10 - n[i]
    ans += a

ans += n[ln]
print(ans)  


Measured memory_bytes: 143036
#include<iostream>
#include<stack>
#include<string>
#include <cstdlib>
int main(){
	std::stack<int> s;
	std::string b;
	int bu;
	while(std::cin>>b){
		if(b=="+"){
			bu=s.top();
			s.pop();
			s.top()+=bu;
		}
		else if(b=="-"){
			bu=s.top();
			s.pop();
			s.top()=s.top()-bu;
		}
		else if(b=="*"){
		    bu=s.top();
			s.pop();
			s.top()*=bu;	
		}
		else{
			s.push(std::atoi( b.c_str() ));
		}
	}
	std::cout<<s.top()<<"\n";
	return 0;
}

Measured memory_bytes: 3212
import java.util.Scanner;

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

		String[] strs = sc.next().split("");

		String[][] signs = new String[(1<<strs.length-1)][strs.length-1];

		for(int i=0; i<signs.length; i++) {
			for(int j=0; j<signs[i].length; j++) {
				signs[i][j] = "-";
			}
		}

		for(int bit=0; bit<(1<<strs.length-1); bit++) {
			for(int i=0; i<strs.length-1; i++) {
				if((1&bit>>i)==1) {
					signs[bit][i] = "+";
				}
			}
		}

		int index = 0;
		for(int i=0; i<signs.length; i++) {
			int result = Integer.parseInt(strs[0]);
			for(int j=0; j<signs[i].length; j++) {
				if(signs[i][j].equals("+")) {
					result += Integer.parseInt(strs[j+1]);
				}else{
					result -= Integer.parseInt(strs[j+1]);
				}
			}
			if(result == 7) {
				index = i;
				break;
			}
		}

		String message = "";
		for(int i=0; i<strs.length-1; i++) {
			message += strs[i] + signs[index][i];
		}

		System.out.println(message + strs[strs.length-1] + "=7");
	}
}

Measured memory_bytes: 25172
import itertools

n = int(input())
s = input()

left = s[:n]
right = s[n:][::-1]

dicleft = {}
for v in itertools.product([0, 1], repeat=n):
    red, blue = '', ''
    for i in range(n):
        if v[i] == 0: red += left[i]
        else: blue += left[i]
    idx = red + '_' + blue
    if idx in dicleft:
        dicleft[idx] += 1
    else:
        dicleft[idx] = 1

dicright = {}
for v in itertools.product([0, 1], repeat=n):
    red, blue = '', ''
    for i in range(n):
        if v[i] == 0: red += right[i]
        else: blue += right[i]
    idx = red + '_' + blue
    if idx in dicright:
        dicright[idx] += 1
    else:
        dicright[idx] = 1

ans = 0
for key, value in dicleft.items():
    if key in dicright:
        ans += value * dicright[key]
print(ans)

Measured memory_bytes: 123356
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#define int long long
#define double long double
#define oku7 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用
using namespace std;
std::mt19937 mt((int)time(0));

int dx[4] = { 0, 1, 0, -1 }; // x軸方向への変位
int dy[4] = { 1, 0, -1, 0 }; // y軸方向への変位

signed main() {
	int A, B;
	cin >> A >> B;
	if (A <= 8 && B <= 8) {
		cout << "Yay!\n";
	}
	else {
		cout << ":(\n";
	}

	//int ans = 0;

	//cout << ans << "\n";


	return 0;
}

Measured memory_bytes: 256