akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int main() {
    int a,b;
    cin >> b >> a;
    if(b>=13)cout << a;
    else if(b>=6 && b<=12)cout << a/2;
    else cout << 0;
    
    //cout<<"Sum of x+y = " << z;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<limits>
#include<iomanip>
#include<string>
#include<map>
#include<vector>
#include<string.h>

using namespace std;

int main(void) {
	int n, r;
	cin >> n >> r;
	if(n >= 10) {
        cout << r << endl;
	} else {
        cout << r + (100 * (10 - n)) << endl;
	}
    
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main(void)
{
	int a, b, c;
	cin >> a >> b >> c;

	if (a + b == c || b + c == a || a + c == b) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

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

int main(){
  string a, b; cin >> a >> b;
  int x = stoi(a+b);
  int r = (int)sqrt(x);
  if (r*r == x) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define MOD 1000000007ll
#define INF 1000000000ll
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n,k;
	cin>>n>>k;
	vector<ll> x(n);
	REP(i,n) cin>>x[i];
	vector<ll> sum1;
	vector<ll> sum2;
	REP(i,n) {
		if(x[i]>=0) sum1.pb(x[i]);
	}
	for(ll i=n-1; i>=0; i--) {
		if(x[i]<0) sum2.pb(abs(x[i]));
	}
	ll ans=INF*INF;
	REP(i,k+1) {
		if(sum1.size()<i||sum2.size()<k-i) continue;
		if(i==0) ans=min(ans,sum2[k-1]);
		else if(k-i==0) {
			ans=min(ans,sum1[i-1]);
		} else {
			ans=min(ans,min(2*sum1[i-1]+sum2[k-i-1],sum1[i-1]+2*sum2[k-i-1]));
		}
	}
	cout<<ans<<endl;
}



Measured memory_bytes: 2424
/*
  dp[y][x][r][d] = テ・ツ可催・ツ崢榲ヲツ鳴ケテ・ツ青妥ィツサツ「テヲツ渉崚」ツ?療」ツ?淌」ツ?凝」ツ?ゥテ」ツ??」ツ?凝」ツ?ョテ」ツδ陛」ツδゥテ」ツつーテ」ツ?罫テ」ツ?ァテ」ツ??
  dテ」ツ?ョテヲツ鳴ケテ・ツ青妥」ツつ津・ツ青妥」ツ??」ツ?ヲテ・ツコツァテヲツィツ?x,y)テ」ツ?ォテ」ツ??」ツつ凝」ツ?ィテ」ツ??テ」ツ?敕」ツ?禿」ツ?凝」ツつ嘉」ツつエテ」ツδシテ」ツδォテ」ツ?セテ」ツ?ァテ」ツ?淌」ツ?ゥテ」ツつ甘ァツ敖?」ツ??
  テ・ツ?エテ・ツ青暗」ツ?ョテヲツ閉ー (mod 100000)

  テ」ツ?禿」ツつ古」ツ?ァテ」ツδ。テ」ツδ「テ・ツ個縫Pテ」ツ?療」ツ?セテ」ツ?療」ツつ?」ツ??」ツ??
  
  テ・ツ可イテ」ツ?」テ」ツ?淌、ツスツ凖」ツつ甘」ツつ津ィツィツ暗ァツョツ療」ツ?凖」ツつ凝・ツ?エテ・ツ青?

  a1 テ「ツ可。 a2 (mod M) テ」ツ?凝」ツ?、 b1 テ「ツ可。 b2 (mod M) テ」ツ?ェテ」ツつ嘉」ツ?ー
  (1) a1 + b1 テ「ツ可。 a2 + b2 (mod M)
  (2) a1 - b1 テ「ツ可。 a2 - b2 (mod M)
  (3) a1 * b1 テ「ツ可。 a2 * b2 (mod M)

  テ」ツ?ィテ」ツ??」ツ??ヲツ?ァティツウツェテ」ツつ津、ツスツソテ」ツ??ティツィツ暗ァツョツ療」ツ?凖」ツつ凝」ツ?づ」ツ?、テ」ツ?セテ」ツつ?
  テ・ツ?エテ・ツ青暗」ツ?ョテヲツ閉ーテ」ツつ津ヲツ閉ーテ」ツ?暗、ツクツ甘」ツ?津」ツ?ヲテ」ツ?凝」ツつ盈odテ」ツつ津」ツ?ィテ」ツ?」テ」ツ?淌・ツ?、テ」ツ?ィ,
  テ・ツ?エテ・ツ青暗」ツ?ョテヲツ閉ーテ」ツつ津ィツィツ暗ァツョツ療」ツ?凖」ツつ凝ゥツ?偲ァツィツ凝」ツ?ァmodテ」ツつ津」ツ?ィテ」ツつ?テヲツ慊?ァツオツづァツ堋?」ツ?ォテ・ツ?コテ」ツ?淌・ツ?、テ」ツ?ッテ、ツクツ?ィツ?エテ」ツ?凖」ツつ凝」ツ?ョテ」ツ?ァテ」ツ??
  テヲツ可アテ」ツ??ヲツ閉ーテ・ツュツ療」ツ?ッテ・ツクツクテ」ツ?ォmodテ」ツつ津」ツ?ィテ」ツつ?ティツィツ暗ァツョツ療」ツ?療」ツ?セテ」ツ?凖」ツ??

  modテ」ツつ津」ツ?ィテ」ツつ嘉」ツ?堙」ツ?ォテ」ツ?凖」ツ?ケテ」ツ?ヲテヲツ閉ーテ」ツ?暗、ツクツ甘」ツ?津」ツつ暗」ツ??」ツ?ィテ」ツ?凖」ツつ凝」ツ?ィテヲツ閉ーテ・ツュツ療」ツ?景ntテ・ツ楪凝」ツ?ョテ、ツクツ甘ゥツ卍?10^9テ」ツ?静」ツつ嘉」ツ??
  テ」ツつ津ィツカツ?」ツ?暗」ツ?ヲテ」ツ?療」ツ?セテ」ツ??」ツ??」ツ??」ツ?セテ」ツ?湘ィツィツ暗ァツョツ療」ツ?ァテ」ツ?催」ツ?セテ」ツ?崚」ツつ禿」ツ??
 */

#include <stdio.h>
#define MAXH 102
#define MAXW 102
#define MOD  100000

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

int W, H;
int dp[MAXH][MAXW][2][2];

int rec(int x, int y, int r, int d) {
  int i, nx, ny, nr;
  if(dp[y][x][r][d] != -1) return dp[y][x][r][d];
  if(x == W-1 && y == H-1) return dp[y][x][r][d] = 1;
  dp[y][x][r][d] = 0;
  for(i = 0; i < 2; ++i) {
    if(r && d != i) continue;
    nx = x + dx[i];
    ny = y + dy[i];
    nr = (d != i);
    if(nx < 0 || nx >= W) continue;
    if(ny < 0 || ny >= H) continue;
    dp[y][x][r][d] = (dp[y][x][r][d] + rec(nx, ny, nr, i)) % MOD;
  }
  return dp[y][x][r][d];
}

int main() {
  int i, j, k, l;
  while(scanf("%d %d", &W, &H) != EOF) {
    if(W == 0 && H == 0) break;
    for(i = 0; i < H; ++i) {
      for(j = 0; j < W; ++j) {
	for(k = 0; k < 2; ++k) {
	  for(l = 0; l < 2; ++l) {
	    dp[i][j][k][l] = -1;
	  }
	}
      }
    }
    printf("%d\n", ( rec(0,0,1,0) + rec(0,0,1,1) ) % MOD);
  }
  return 0;
}

Measured memory_bytes: 1200
'use strict'

const INF = 900719925474099;
function mapint(temp){
    return temp.split(' ').map((v)=>parseInt(v));
}
const MOD = 1000000007;

function Main(input){
    let temp = input.trim().split('\n');
    let h = mapint(temp[0])[0];
    let w = mapint(temp[0])[1];

    let m = new Array(h+2);
    m[0] = '#'.repeat(w+2);
    m[h+1] = '#'.repeat(w+2);
    for(let i=1;i<=h;i++){
        m[i]='#' + temp[i] + '#';
    }

    let yoko = [...new Array(h+2)].map(()=>new Array(w+2).fill(0));

    for(let i=1;i<=h;i++){
        for(let j=1;j<=w;j++){
            if(m[i][j]=='.') yoko[i][j] = yoko[i][j-1]+1;
        }
    }
    // for(let i=h;i>=1;i--){
    //     for(let j=w;j>=1;j--){
    //         if(m[i][j]=='.' && m[i][j+1] != '#') yoko[i][j] = yoko[i][j+1];
    //     }
    // }

    let tate = [...new Array(h+2)].map(()=>new Array(w+2).fill(0));
    for(let i=1;i<=w;i++){
        for(let j=1;j<=h;j++){
            if(m[j][i]=='.') tate[j][i] = tate[j-1][i]+1;
        }
    }
    // for(let i=w;i>=1;i--){
    //     for(let j=h;j>=1;j--){
    //         if(m[j][i]=='.' && m[j+1][i] != '#') tate[j][i] = tate[j+1][i];
    //     }
    // }
    //console.log(h,w,m,yoko,tate);

    let ans = 0;
    for(let i=h;i>=1;i--){
        for(let j=w;j>=1;j--){
            if(m[i][j]=='.' && m[i][j+1] != '#') yoko[i][j] = yoko[i][j+1];
            if(m[i][j]=='.' && m[i+1][j] != '#') tate[i][j] = tate[i+1][j];
            ans = Math.max(ans,yoko[i][j]+tate[i][j]-1);
        }
    }
    // for(let i=1;i<=h;i++){
    //     for(let j=1;j<=w;j++){
    //         ans = Math.max(ans,yoko[i][j]+tate[i][j]-1);
    //     }
    // }
    console.log(ans);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 109736
#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;
 
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<long long, long long> pl;
 
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define speedhack() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define form(i, n) for (size_t i = 0; i < size_t(n); ++i)
#define forn(i, n) for (size_t i = 1; i <= size_t(n); ++i)
template<class T> using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll mod(ll a, ll b) { return (a%b+b)%b; }
ll gcd(ll x, ll y) { return __gcd(x, y); }
ll lcm(ll x, ll y) { return x * 1ll * y / gcd(x, y); }
 
 
const ll MAXN = 1e9 + 9;
const ll SIZE = 2e5 + 5;
const ll MOD  = 1e9 + 7;

ll N, sum, a[SIZE];


int main() { speedhack()

	cin >> N;
	forn (i, N) 
		cin >> a[i];
	
	forn (i, N)
		sum = sum ^ a[i];
	forn (i, N)
		a[i] ^= sum;
	
	forn (i, N)
		cout << a[i] << " ";
	
	
	return 0;
}

Measured memory_bytes: 5088
N, A, B, C, D = map( int, input().split())
S = input()
check = "Yes"
for i in range(A-1, C-1):
    if S[i] == "#" and S[i+1] == "#":
        check = "No"
        break
if check == "Yes":
    for i in range(B-1, D-1):
        if S[i] == "#" and S[i+1] == "#":
            check = "No"
            break    
if check == "Yes":
    if C < D:
        pass
    else:
        check = "No"
        B -= 1
        D -= 1
        t = 0
        for i in range(B-1, D+2):
            if S[i] == ".":
                if t <= 1:
                    t += 1
                else:
                    check = "Yes"
                    break
            else:
                t = 0
print(check)


Measured memory_bytes: 3572
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
#define int ll
#define fi first
#define se second
#define Sort(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/4
#define INTINF INT_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
template<class T> inline bool chmax(T &a, T b){if(a < b){a = b;return true;}return false;}
template<class T> inline bool chmin(T &a, T b){if(a > b){a = b;return true;}return false;}
/*----------------------------------------------------------------*/
// int MOD = 998244353;
int MOD = 1000000007;

/*----------------------------------------------------------------*/
signed main(){
	
	int a,b;
	cin >> a >> b;

	if(b >= a)cout << "unsafe" << endl;
	else cout << "safe" << endl;

	
	
	
	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=gnu++17 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://pakencamp-2019-day3.contest.atcoder.jp/tasks/pakencamp_2019_day3_c
// rm -r -f test;oj dl https://atcoder.jp/contests/abc164/tasks/abc164_b


Measured memory_bytes: 3640
-- うおおおおお競プロでHaskell勉強してやるううううううう

import Data.Char
import Data.List
import System.IO
import Control.Applicative
import Control.Monad
-- https://hoogle.haskell.org で関数検索

{- お客様の中でHaskellを書ける方はいらっしゃいますか？
    と、Haskellの例がなくて困っていたところを @tanakh さんに助けて頂きました。本当にありがとうございました。-}
main :: IO ()
main = do
    [k,x] <- getIntegerList
    yesno (500*k >= x)
    return ()
    



  -- print
pr [] = putStrLn ""
pr (x:xs) = do
    putStr $ (show x) ++ " "
    pr xs

or2 c1 c2 x 
    | c1 x ==True    = True
    | c2 x ==True    = True
    | otherwise        = False

same3 [a,b,c]
    | a==b && b==c = True
    | otherwise         = False       
      
diff3 [a,b,c] 
    | a==b = False
    | b==c = False
    | c==a = False
    | otherwise = True

yesno cond
    | cond         = putStrLn "Yes"
    | otherwise = putStrLn "No"
    
    
    
{-


    a <- getChar
    putStrLn [chr$(ord a)+1]

ord 'a' --> 97
chr 97 --> 'a'

main = do 
    [a,b] <- getDoubleList
    print $ ceiling $  a / b
  


 「/」はdouble同士でしか使えない

main = readLn >>= print . ceiling . (/2) 


(+) 3 $ (*) 4 4
-> 19
pure (+) <*> (Just 1) <*> ( Just 3)
-> Just 4

main = do 
    [a,b] <- getIntegerList 
    print $ (a*(a-1)+b*(b-1)) `div` 2
    -- / じゃなくて'div' ！！！！！

main = do
    s <- getLine    
    samecoffee s

samecoffee [x,y,a,b,c,d] 
    | a==b && c==d = do putStrLn "Yes"
    | otherwise         = do putStrLn "No"
samecoffee s = do putStrLn ""
         
putStrLn $ (show c) ++ " " ++ (show a) ++ " " ++ (show b)


main :: IO ()
main = do
    -- 整数の入力
    a <- readLn
    -- スペース区切り整数の入力
    [b, c] <- getIntegerList

    --[b, c] <- map read . words <$> getLine
    -- 文字列の入力
    s <- getLine
    -- 出力
    putStrLn $ show (a + b + c) ++ " " ++ s
-}

-- レイアウト規則

fac 0 = 1
fac n = n * fac (n-1)

-- FileName   : 164a
-- CreatedDate: 2020-04-26 20:56:13

--------------------------------------------  https://atcoder.jp/contests/abc164/submissions/12342628

getIntList        = map (read :: String -> Int) . words <$> getLine
getIntegerList    = map (read :: String -> Integer) . words <$> getLine
getIntegerListN m = map (read :: String -> Integer) <$> replicateM m getLine

getStringList    = words <$> getLine
getDoubleList    = map (read :: String -> Double) . words <$> getLine

base :: Integer
base = 1000000007

plus :: Integer -> Integer -> Integer
plus a b = (a+b) `mod` base

times :: Integer -> Integer -> Integer
times a b = a * b `mod` base

minus :: Integer -> Integer -> Integer
minus a b
   | a < b     = a-b + base
   | otherwise = a-b

power :: Integer -> Integer -> Integer
power n k
   | k == 0         = 1
   | k `mod` 2 == 0 = power (times n n) (k`div`2)
   | otherwise      = times n $! power n (k-1)

inv :: Integer -> Integer
inv n = power n $ base - 2

binom :: Integer -> Integer -> Integer
binom n m
   | (n-m) < m = times (foldr times 1 [m+1..n]) $ inv $ foldr times 1 [1..n-m]
   | otherwise = times (foldr times 1 [n-m+1..n]) $ inv $ foldr times 1 [1..m]



















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

int main() {
	int N;
	long long D;
	long long E;
	int p;
	long long x;
	long long y;

	cin >> N >> D;
	p = 0;
	E = D * D;
	rep(i, N) {
		cin >> x >> y;
		if ( x * x + y * y <= E) p++;
	}
	cout << p << endl;
	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e9
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;
int d[110];
signed main(){
   int n;
   cin>>n;
   REP(i,n) cin>>d[i];
   ll ans=0;
   for (int i = 0; i < n; i++)
   {
       for (int j = i+1; j < n; j++)
       {
           ans+=d[i]*d[j];
       }
       
   }
   cout<<ans<<endl;
   
    return 0;
}

Measured memory_bytes: 256
extern crate core;

use std::collections::HashSet;
use std::io::{self, Read};

#[macro_export]
macro_rules! input {
  ($s:expr=>$($t:tt)*) => {
    let mut lines=$s.split("\n");
    $(
        line_parse!(lines,$t);
    )*
  };
}

macro_rules! line_parse {
  ($lines:expr,($($name:ident:$t:tt)*)) => {
    let mut line=$lines.next().unwrap().split_whitespace();
    $(value_def!(line,$name,$t);)*
  };

  //複数行
  ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
    values_def!($lines,$n,$name,$t);
  };
}

macro_rules! value_def {
    ($line:expr, $name:ident, $t:tt) => {
        let $name = value!($line, $t);
    };
}

macro_rules! values_def {
    ($lines:expr, $n:expr, $name:ident, $t:tt) => {
        let $name = {
            let mut vec = Vec::new();
            for i in 0..$n {
                let mut next = $lines.next().unwrap().split_whitespace();
                vec.push(value!(next, $t));
            }
            vec
        };
    };
}

macro_rules! value {
  //配列
  ($line:expr,[$t:tt]) => {
    $line.map(|x|{
      let mut iter=::std::iter::once(x);
      value!(iter,$t)
    }).collect::<Vec<_>>()
  };
  //タプル
  ($line:expr,($($t:tt),*)) => {
    ($(value!($line,$t),)*)
  };
  //文字列
  ($line:expr,#) => {
    $line.next().unwrap()
  };
  //インデックス(-1)
  ($line:expr,@) => {
    $line.next().unwrap().parse::<usize>().unwrap()-1
  };
  //単一値
  ($line:expr,$t:ty) => {
    $line.next().unwrap().parse::<$t>().unwrap()
  };
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn solve(input: String) -> String {
    input!(input=>(s:#));
    let set = s.chars().collect::<HashSet<_>>();
    for c in "abcdefghijklmnopqrstuvwxyz".chars() {
        if !set.contains(&c) {
            return c.to_string();
        }
    }
    "None".to_string()
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

tests! {
    test1: "atcoderregularcontest" => "b",
    test2: "abcdefghijklmnopqrstuvwxyz" => "None",
    test3: "fajsonlslfepbjtsaayxbymeskptcumtwrmkkinjxnnucagfrg" => "d",
}


Measured memory_bytes: 4352
"""segfunc"""


# 論理和を返す
def segfunc(x, y):
    return x | y


def init(init_val):
    # set_val
    for i in range(N):
        seg[i-1+num] = init_val[i]

    # built
    for i in range(num-2, -1, -1):  # 木の下の方から埋めていく, nではなくnumであることに注意
        seg[i] = segfunc(seg[2*i+1], seg[2*i+2])  # 子のインデックス


# 更新
def update(k, x):
    k += num-1  # 場所kに対するseg木の葉のindex?
    seg[k] = x
    while k:
        k = (k-1)//2  # 親のノードのindexを取得
        seg[k] = segfunc(seg[2*k+1], seg[2*k+2])


def query(p, q):
    if q <= p:  # 半開区間なので、等しくてもアウト？
        return ide_ele
    p += num-1
    q += num-2  # 半開区間なので、q側を-2している？
    res = ide_ele
    while q-p > 1:
        if p % 2 == 0:
            res = segfunc(res, seg[p])
        if q % 2 == 1:
            res = segfunc(res, seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = segfunc(res, seg[p])
    else:
        res = segfunc(segfunc(res, seg[p]), seg[q])
    return res


# 単位元
ide_ele = 0

N = int(input())
ss = list(input())
s = []
for i in range(N):
    s.append(1<<(ord(ss[i]))-97)

# num: n以上の最小の2のベキ乗
num = 2**(N-1).bit_length()
seg = [ide_ele]*2*num

init(s)


def popcnt(n):
    c = (n & 0x5555555555555555) + ((n>>1) & 0x5555555555555555)
    c = (c & 0x3333333333333333) + ((c>>2) & 0x3333333333333333)
    c = (c & 0x0f0f0f0f0f0f0f0f) + ((c>>4) & 0x0f0f0f0f0f0f0f0f)
    c = (c & 0x00ff00ff00ff00ff) + ((c>>8) & 0x00ff00ff00ff00ff)
    c = (c & 0x0000ffff0000ffff) + ((c>>16) & 0x0000ffff0000ffff)
    c = (c & 0x00000000ffffffff) + ((c>>32) & 0x00000000ffffffff)
    return c


q = int(input())
for i in range(q):
    qq, xx, yy = map(str, input().split())
    if qq == '1':
        xx = int(xx)
        update(xx-1,1<<(ord(yy)-97))
    else:
        xx, yy = int(xx), int(yy)
        res = query(xx-1,yy)
        print(popcnt(res))


Measured memory_bytes: 51624
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int N=5e5;
int x[N],opt[N],id[N],p[N],vis[N],n,m,tmp[N];
long long s[N],K;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d",x+i),id[i]=i;
    for(int i=n;i>=1;i--)x[i]-=x[i-1];
    scanf("%d%lld",&m,&K);
    for(int i=1;i<=m;i++)scanf("%d",opt+i),swap(id[opt[i]],id[opt[i]+1]);
    for(int i=1;i<=n;i++)p[id[i]]=i;
    for(int i=1;i<=n;i++)
    {
        if(vis[i])continue;
        int u=i,len=0;tmp[0]=u;vis[u]=1;
        while(p[u]!=i)u=p[u],tmp[++len]=u,vis[u]=1;
        ++len;
        for(int i=0;i<len;i++)p[tmp[i]]=tmp[(i+K)%len];
    }
    for(int i=1;i<=n;i++)id[p[i]]=i;
    
    for(int i=1;i<=n;i++)s[i]=s[i-1]+x[id[i]],printf("%.1lf\n",(double)s[i]);
}

Measured memory_bytes: 6868
#include<bits/stdc++.h>
#include<string.h>
#define ll long long
#define pf printf
#define sf scanf
#define ff first
#define ss second
#define clr clear()
#define sz size()
#define pb push_back
#define mk make_pair
#define pi acos(-1)
#define inf 2000000000000000000
#define mod 1000000007
#define ull unsigned long long int
#define f(i,k,n) for(i=k;i<n;i++)
#define fr(i,n,k) for(i=n;i>=k;i--)
#define ent(a) scanf("%lld",&a)
#define ent2(a,b) scanf("%lld%lld",&a,&b)
#define ent3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define mem(a) memset(a,0,sizeof(a))
#define vec(v,s) vector<ll>v[s]
#define arr(a,s) ll a[s];
/*#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
//knight and king//
int dr[]= {2,2,-2,-2,1,-1,1,-1};
int dc[]= {1,-1,1,-1,2,2,-2,-2};
int dr1[]= {0,0,1,1,1,-1,-1,-1};
int dc1[]= {1,-1,1,0,-1,0,1,-1};
int dr2[]= {0,0,1,-1};
int dc2[]= {1,-1,0,0};
////////////////////////////
using namespace std;
#define ma 2000005
ll fr[ma];

ll bigmod(ll n,ll p)
{
    if(p==0)return 1;
    ll x=bigmod(n,p/2);
    x=(x*x)%mod;
    if(p%2==1)x=(x*n)%mod;
    return x;
}

ll ncr(ll n,ll r)
{
    ll r1=(fr[n-r]*fr[r])%mod;
    r1=bigmod(r1,mod-2);
    return (fr[n]*r1)%mod;
}

ll cal(ll n,ll m)
{
    ll r=ncr(m,n)*fr[n];r%=mod;
    return r;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,i,j,u,v,k,x,m;
    fr[0]=1;
    for(i=1;i<ma;i++)fr[i]=(fr[i-1]*i)%mod;
    while(cin>>n>>m)
    {
        ll ans=cal(n,m)*cal(n,m);
        ans%=mod;
        for(i=1;i<=n;i++)
        {
            ll p=cal(i,m)*ncr(n,i);
            p%=mod;
            ll p1=cal(n-i,m-i);

            p1=(p1*p1)%mod;
            p=(p*p1)%mod;
            if(i%2)ans=(ans-p+mod)%mod;
            else ans=(ans+p)%mod;
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 19276
import java.util.*;

/**
 * @author masayamatu
 * 
 */
public class Main {
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String[] S = s.split("");
    String temp =S[0];
    int count = 1;
    int i = 1;
    while(  i < S.length) {
      if(temp.equals(S[i]) && i < S.length-1) {
        temp=S[i]+S[i+1];
        i += 2;
        count++;
      }else if(temp.equals(S[i])) {
        i++;
      }else if(!temp.equals(S[i])) {
        temp = S[i];
        count++;
        i++;
      }
  }
    System.out.println(count);
  }
}

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

using namespace std;

int main() {
    int n, c;

    cin >> n;

    set<string> s;
    string st;

    for(int i = 0; i < n; ++i) {
        cin >> st;
        s.insert(st);
    }

    printf("%d\n", s.size());

    return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++) {
    cin >> a.at(i);
  }

  int ans = INT_MAX;
  for(int j = -100; j <= 100; j++) {
    int tmp = 0;
    for(int i = 0; i < n; i++) {
      tmp += pow(a.at(i) - j, 2);
    }
    if(tmp < ans) {
      ans = tmp;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

void judge(int *);

int main(void)
{
    int k[5];
    int i;

    while (scanf("%d", &k[0]) != EOF)
    {
        for (i = 1; i < 5; i++){
            scanf(",%d", &k[i]);
        }
        judge(k);

    }
    return (0);
}
void judge(int *k)
{
    int i,j;
    int x;
    int count;
    int onepair;
    int fourcard;
    int threecard;
    int temp;
    int leach;

    onepair = 0;
    fourcard = 0;
    threecard = 0;
    
    for (i = 0; i < 5; i++){
        count = 0;
        for (j = i + 1; j < 5; j++){
            if(k[i] == k[j] && i != j){
                count++;
                //printf("<%d>", count);
            }
        }
        if (count == 1){ //k[i]と同じ数字が１枚あるとき
            onepair++;
            //printf("one%d\n", onepair);
        }else if (count == 2){ //k[i]と同じ数字が２枚ある時
            threecard++;
            //printf("three%d", threecard);
        }else if (count == 3){ //k[i]と同じ数字が3枚あるとき
            fourcard++;
        }
    }
    /*カードを小さい順に並べ替える*/
    for (i = 0; i < 5; i++){
        for (j = 4; j > i; j--){
            if (k[j] < k[j -1]){
                temp = k[j];
                k[j] = k[j - 1];
                k[j - 1] = temp;
            }
        }
        //printf("<%d>",k[i]);
    }

    leach = 0;
    for (i = 0; i < 5; i++){
        if (k[i] + 1 == k[i + 1]){
            leach++;
            //printf("%d %d", leach,k[i]);
        }
    }
    
    if ((k[0] = 1 && k[1] == 10 && k[2] == 11 && k[3] == 12 && k[4] == 13) || leach == 4 && onepair == 0){
        printf("straight\n");
    }else if (threecard == 1 && onepair == 2){
        printf("full house\n");
    }else if (fourcard == 1 && onepair > 0){
        printf("four card\n");
    }else if(threecard == 1 && onepair > 0){
        printf("three card\n");
    }else if (onepair == 2){
        printf("two pair\n");
    }else if (onepair == 1){
        printf("one pair\n");
    }else{
        printf("null\n");
    }
}


Measured memory_bytes: 2032
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9+7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A,B,C,D,E,F,G,H,I,J,K,L,N,M,O,P,Q,S,T,U,V,W,x,y,z;
long long max_value = INF, max_index = -1;
typedef long long ll;
typedef pair<ll, ll> Pa;

template <std::int_fast64_t Modulus> class modint {
  using u64 = std::int_fast64_t;
public:
  u64 a;
  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};
#pragma endregion

ll arr[200000];
int main() {
  cin >> K >> N;
  rep(i, N){
    cin >> arr[i];
  }
  ll _m = -1;
  rep(i, N-1){
    _m = max(_m, arr[i+1] - arr[i]);
  }
  _m = max(_m, (K - arr[N-1]) + arr[0]);
  cout << K - _m;
} 



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

int main() {
  int N;
  cin >>N;
  vector<int>p(N);
  vector<int>q(N);
  for(int i=0;i<N;i++){
  cin >>p[i];
  } 
  for(int i=0;i<N;i++){
  cin >>q[i];
  }  
  vector<int> v(N);
  for(int i=0;i<N;i++){
  v[i]=i+1;
  }
  int equalp,equalq,ansp,ansq,count;
  
  do {count++;equalp=0;equalq=0;
    for (int i=0;i<N;i++) {
      if(p[i]!=v[i]){equalp=1;}
    }
    if(equalp==0){ansp=count;}
    for (int i=0;i<N;i++) {
      if(q[i]!=v[i]){equalq=1;}
    }
    if(equalq==0){ansq=count;}  
  } while (next_permutation(v.begin(), v.end()));

cout <<abs(ansp-ansq)<<endl;
}


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

int main() {
	int n, o = 0, ma, mi;
	string s;
	cin >> n;

	for (; n-- > 0;) {
		cin >> s;

		vector<int> v;
		for (int i = 0; i < s.size(); i++) {
			v.push_back(s[i] - '0');
		}
		sort(v.begin(), v.end());

		o = s.size();
		ma = 0;
		mi = 0;
		for (int i = 0; i < o; i++) {
			ma += v[o - i - 1] * pow(10, i);
			mi += v[i] * pow(10, i);
		}
		cout << (mi - ma) << endl;
	}
	return 0;
}

Measured memory_bytes: 3340
/* 
	Author: ankrypt
*/

#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;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second
#define all(x) x.begin(), x.end() 
#define ub upper_bound
#define lb lower_bound
#define MAX_INT 55
#define fi(a, b, c, d) for(int a = b; a < c; a += d)
#define fl(a, b, c, d) for(ll a = b; a < c; a += d)
#define fei(a, b, c, d) for(int a = b; a <= c; a += d)
#define fel(a, b, c, d) for(ll a = b; a <= c; a += d)
#define quit exit(0)

ll N, M, A[MAX_INT], B[MAX_INT], C[MAX_INT], D[MAX_INT], K;
ll arr[MAX_INT], arr1[MAX_INT], arr2[MAX_INT], arr3[MAX_INT];
vector<ll> V;
ll finalAns = 0;

void rec(ll ind) {
	if(ind > N) {
		int flag = 1;
		ll ans = 0;
		fi(i, 0, K, 1) {
			if(arr[B[i]] - arr[A[i]] != C[i]) {}
			else {
				ans += D[i];
			}
		}
		finalAns = max(finalAns, ans);
		return;
	}
	fei(i, arr[ind - 1], M, 1) {
		if(!i) {}
		else {
			arr[ind] = i;
			rec(ind + 1);
		}
	}
} 


int main() {
	cin >> N >> M >> K;
	fi(i, 0, K, 1) {
		cin >> A[i] >> B[i] >> C[i] >> D[i];
	}
	rec(1);
	cout << finalAns << "\n";

	return 0;
}
/*
	Powered by Buggy Plugin
*/




Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int i,N;
  
  cin >> N;
  vector<int> v(N);
  for(i = 0;i < N;i++)
    cin >> v[i];
  for(i=0;i<N;i++)
  {
    if(v[i] % 2 == 0)
        if(v[i]%3!=0&&v[i]%5!=0)
        {
            cout << "DENIED" << endl;
            return 0;
        }
  }
  cout << "APPROVED" << endl;
  return 0;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = 10**6#float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
#from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

		
#階乗#
lim = 2*10**5   #必要そうな階乗の限界を入力
fact = [1] * (lim+1)
for n in range(1, lim+1):
	fact[n] = n * fact[n-1] % mod

#階乗の逆元#
fact_inv = [1]*(lim+1)
fact_inv[lim] = pow(fact[lim], mod-2, mod)
for n in range(lim, 0, -1):
	fact_inv[n-1] = n*fact_inv[n]%mod

def C(n, r):
	return (fact[n]*fact_inv[r]%mod)*fact_inv[n-r]%mod


#素因数分解
def factorization(n):
	arr = []
	tmp = n
	for i in range(2, int(-(-n**0.5//1))+1):
		if tmp%i == 0:
			cnt = 0
			while tmp%i == 0:
				cnt += 1
				tmp //= i
			arr.append([i, cnt])
	if tmp != 1:
		arr.append([tmp, 1])
	if arr == []:
		arr.append([n, 1])
	return arr


N, M = MAP()
if M == 1:
	print(1)
	exit()

arr = factorization(M)
ans = 1
for g, n in arr:
	ans *= C(N-1+n, n)
	ans %= mod

print(ans)


Measured memory_bytes: 25676
#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;
using PLL = pair<LL, LL>;
const int INF = 1e9;
const int MXN = 0;
const int MXV = 1e5 + 5;
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define FOR(i, L, R) for (int i = L; i != (int)R; ++i)
#define FORD(i, L, R) for (int i = L; i != (int)R; --i)
#define IOS                                                                    \
    cin.tie(nullptr);                                                          \
    cout.tie(nullptr);                                                         \
    ios_base::sync_with_stdio(false);

struct DisjointSet
{
    int p[MXV], sz[MXV];
    void init(int n)
    {
        for (int i = 0; i <= n; i++)
        {
            p[i] = i;
            sz[i] = 1;
        }
    }
    int find(int u) { return u == p[u] ? u : p[u] = find(p[u]); }
    void Union(int u, int v)
    {
        u = find(u);
        v = find(v);
        if (u == v)
        {
            return;
        }
        if (sz[u] < sz[v])
        {
            swap(u, v);
        }
        sz[u] += sz[v];
        p[v] = u;
    }
    bool isSame(int u, int v)
    {
        u = find(u);
        v = find(v);
        return u == v;
    }
    int getSize(int u)
    {
        u = find(u);
        return sz[u];
    }
};

int main()
{
    IOS;
    DisjointSet djs;
    int n, m, k;
    cin >> n >> m >> k;
    vector<int> ans(n + 1, 0);
    djs.init(n);
    FOR(i, 0, m)
    {
        int x, y;
        cin >> x >> y;
        --ans[x];
        --ans[y];
        djs.Union(x, y);
    }
    FOR(i, 0, k)
    {
        int x, y;
        cin >> x >> y;
        if (djs.isSame(x, y))
        {
            --ans[x];
            --ans[y];
        }
    }
    // FOR(i, 1, n + 1) { cout << ans[i] << " \n"[i == n]; }
    FOR(i, 1, n + 1) { cout << ans[i] + djs.getSize(i) - 1 << " \n"[i == n]; }
}


Measured memory_bytes: 2048
<?php

fscanf(STDIN, "%d %d", $a, $b);
printf("%s %s %s%s", 'a', compare($a, $b), 'b', PHP_EOL);

function compare($a, $b)
{
    if ($a > $b) {
        return ">";
    } else if ($a < $b) {
        return "<";
    } else {
        return "==";
    }
}

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

using namespace std;
int main(int argc, const char * argv[]) {
    int n, k;
    cin >> n >> k;
    if(n % k == 0){
        printf("%d\n", 0);
    }else{
        printf("%d\n", 1);
    }
    
    
    return 0;
}

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

int N, A[10010];
int min() {
   long long minnum = A[0];
   for(int i=0; i<N; ++i){
     if (minnum > A[i]) minnum = A[i];
   }
return minnum;
}
int max() {
   long long maxnum = A[0];
   for(int i=0; i<N; ++i){
     if (maxnum < A[i]) maxnum = A[i];
   }
return maxnum;
}
long long sum() {
   long long sumnum = 0;
   for(int i=0; i<N; ++i){
     sumnum += A[i];
   }
return sumnum;
}
int main() {
cin >> N;
for (int i=0; i<N; ++i)
cin >> A[i];
cout << min() << " " << max() << " " << sum() << endl;
}

Measured memory_bytes: 3080
n,t = map(int, input().split())
a = list(map(int, input().split()))
max_gain =0 
max_a = 0
max_cnt = 0
for i in range(n-1, -1, -1):
    if a[i] > max_a:
        max_a = a[i]
    elif max_a - a[i] > max_gain:
        max_gain = max_a - a[i]
        max_cnt = 1
    elif max_a - a[i] == max_gain:
        max_cnt += 1
print(max_cnt)

Measured memory_bytes: 15020
const input = require('fs').readFileSync('/dev/stdin', 'utf8').trim()
const lines = input.trim().split("\n")
while (lines.length > 1) {
    const n = parseInt(lines.shift().trim())
    const arr = lines.shift().trim().split(" ").map(Number)
    const avg = arr.reduce((s,v)=> s+ v)/n
    console.log(arr.reduce((rs, v) => v<=avg? rs+1: rs, 0))
}


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

int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	multiset<int> st;
	int d;
	for (int i = 0; i < n; ++i)
	{
		cin>>d;
		if (d==0)
		{
			cout<<"0\n";
			return 0;
		}
		st.insert(d);
	}
	for (int i = 1; i < 12; ++i)
	{
		if (st.count(i)>2)
		{
			cout<<"0\n";
			return 0;
		}
	}
	if (st.count(12)>1)
	{
		cout<<"0\n";
		return 0;
	}
	int f=0;
	vector<int> v;
	v.push_back(12);
	for (int i = 1; i < 12; ++i)
	{
		if (st.count(i)==2)
		{
			v.push_back(12-i);
			v.push_back(12+i);
		}
		else if (st.count(i)==1)
		{
			if (f%2==0)
			{
				v.push_back(12-i);
			}
			else
			{
				v.push_back(12+i);
			}
			++f;
		}
	}
	if (st.count(12)==1)
	{
		v.push_back(0);
		v.push_back(24);
	}
	sort(v.begin(), v.end());
	int ans=30;
	for (int i = 0; i < v.size()-1; ++i)
	{
		ans=min(ans,v[i+1]-v[i]);
	}
	if (v[0]!=0)
	{
		ans=min(ans,24-v[v.size()-1]+v[0]);
	}
	cout<<ans<<endl;
	return 0;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int INF=1001001001001001001ll;

int N,M,S,T;

vint dijkstra(vector<vector<pint>>G,int s){
    vint dist(N,INF);
    dist[s]=0;
    priority_queue<pint,vector<pint>,greater<pint>>que;
    que.push({0,s});
    while(que.size()){
        int c,v;
        tie(c,v)=que.top();
        que.pop();
        if(dist[v]<c)continue;
        for(auto &e:G[v]){
            if(dist[e.fi]<=dist[v]+e.se)continue;
            dist[e.fi]=dist[v]+e.se;
            que.push({dist[e.fi],e.fi});
        }
    }
    return dist;
}

signed main(){
    cin>>N>>M>>S>>T;S--;T--;
    vector<vpint>G(N),H(N);
    rep(i,M){
        int u,v,a,b;
        cin>>u>>v>>a>>b;
        u--;v--;
        G[u].pb({v,a});
        G[v].pb({u,a});

        H[u].pb({v,b});
        H[v].pb({u,b});
    }

    vint distS=dijkstra(G,S);
    vint distT=dijkstra(H,T);


    vint ans(N);
    rep(i,N){
        ans[i]=distS[i]+distT[i];
    }
    for(int i=N-2;i>=0;i--)chmin(ans[i],ans[i+1]);
    rep(i,N)cout<<1000000000000000ll-ans[i]<<endl;
    return 0;
}


Measured memory_bytes: 26684
#include<bits/stdc++.h>
using namespace std;
#define forr(i,a,n)	for(long long int i=a; i<n; i++)
#define loop(i,a,n)	for(long long int i=a; i>=n; i--)


int main() 
{
	ios_base :: sync_with_stdio(false),cin.tie(NULL),cout.tie(0);
	
	int a;
	cin>>a;
	long long int ct=0;
	forr(i,1,a+1)
	{
		for(int j=i; j<a+1; j+=i)
			ct+=j;
	}
	cout<<ct;
	
	return 0; 	
}

Measured memory_bytes: 3592
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
 
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long
 
 
 
using namespace std;
 
void file(){
	#ifndef ONLINE_JUDGE
    	freopen("in.txt", "r", stdin);
	#endif
}
int tc;
const int N=5e5+5,M=2e6+5,MOD=1e9+7,OO=1e9;
 
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//file();	
 
	int h,w;
 
	scanf("%d %d",&h,&w);
	if(h==1 || w==1)return !printf("1\n");
 
	printf("%lld\n",(ll)((ll)h*w+1)/2 );
}

Measured memory_bytes: 256
import sys, math, bisect


if(__name__ == "__main__"):
    """
    N = int( input().strip() )
    Length = list( map(int, input().strip().split() ) )
    """
    N = int( input().strip() )
    Heights = list( map(int, input().strip().split() ) )

    sum = 0
    for i in range(N-1):
        if(Heights[i+1] < Heights[i]):
            plus = Heights[i] - Heights[i+1]
            sum += plus
            Heights[i+1] += plus

    print(sum)

    


Measured memory_bytes: 33020
#include<iostream>
using namespace std;
 
int main(){
  int A, B, C;
  long long K;
 
  cin >> A >> B >> C >> K;
  K = K %2;
  if(K == 1) {
    cout << B-A << endl;
  }else{
    cout << A-B << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
 char str[1200];
 int num,i,j;


 num='a'-'A';

/*????????????????????????*/
 j=1300;

 for(i=0;i<j;i++){
  scanf("%c",&str[i]);
  if(str[i]=='\n'){
  j=i;
   break;
  }
 }

 for(i=0;i<=j;i++){
  /*??§???????????£??????*/
  if(str[i]>='A' && str[i]<='Z'){
   str[i]+=num;
   printf("%c",str[i]);
  }/*?°????????????£??????*/
   else if(str[i]>='a' && str[i]<='z'){
    str[i]-=num;
    printf("%c",str[i]);
  }/*????????\???*/
   else if(str[i]=='\n'){
    printf("\n");
   }else{
    printf("%c",str[i]);
   }

  
}




return 0;
}

  

Measured memory_bytes: 524
#include<stdio.h>

using namespace std;

struct Node{
    int key;
    Node* prev;
    Node* next;
};

int main(){
    int n;
    scanf("%d", &n);

    Node nil;
    nil.prev = &nil;
    nil.next = &nil;

    char str[12];
    int x;

    int num = 0;

    for(int i = 0; i < n; i++){
        scanf("%s", str);
        if(str[0] == 'i'){
            scanf("%d", &x);
            Node* ptr = new Node;
            ptr->key = x;
            ptr->prev = &nil;
            ptr->next = nil.next;
            nil.next->prev = ptr;
            nil.next = ptr;
            num++;
        }
        else if(str[6] == '\0'){
            scanf("%d", &x);
            Node* ptr = nil.next;
            for(int i = 0; i < num; i++){
                if(ptr->key != x){
                    ptr = ptr->next;
                }
                else{
                    ptr->next->prev = ptr->prev;
                    ptr->prev->next = ptr->next;
                    delete ptr;
                    num--;
                    break;
                }
            }
        }
        else if(str[6] == 'F'){
            Node* ptr = nil.next;
            nil.next->next->prev = &nil;
            nil.next = nil.next->next;
            delete ptr;
            num--;
        }
        else if(str[6] == 'L'){
            Node* ptr = nil.prev;
            nil.prev->prev->next = &nil;
            nil.prev = nil.prev->prev;
            num--;
        }
    }

    Node* ptr = nil.next;
    for(int i = 0; i < num; i++){
        if(i){
            printf(" %d", ptr->key);
        }
        else{
            printf("%d", ptr->key);            
        }
        ptr = ptr->next;
    }
    printf("\n");
}


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

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

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

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

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int N = in();
    vector<int> A(N);
    REP(i,N)A[i] = in();
    sort(ALL(A));
    cout << A[N/2] - A[N/2-1] << "\n";
}

Measured memory_bytes: 640
n = int(input())
a = list(map(int, input().split()))

a.sort(reverse = True)

a_score, b_score = 0, 0

for i in range(n):
    if i % 2 == 0:
        a_score += a[i]
    else:
        b_score += a[i]

print(a_score - b_score)

Measured memory_bytes: 3060
// In The Name Of God
/*
ID: alimora2
LANG: C++11
TASK: PROB
*/
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	map<int, bool> mp;
	int n, ans = 0;
	cin >> n;
	for (int i = 0, a; i < n; i++) {
		cin >> a;
		if (mp.find(a) == mp.end()) {
			ans++;
			mp[a] = 1;
		}
		else if (mp[a]) {
			ans--;
			mp[a] = 0;
		}
		else if (!mp[a]) {
			ans++;
			mp[a] = 1;
		}
	}
	return cout << ans << endl, 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#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++)
typedef long long int ll;
typedef long double ld;
using namespace std;

vll use(51, 0);
struct edge{ll to, num;};
vector<vector<edge>> G(51);
void init(){re(i, 51) use[i] = 0;}
void dfs(ll now, ll from, ll p){
  use[now] = 1;
  for(int i=0;i<G[now].size();i++){
    if(G[now][i].to==from||use[G[now][i].to]==1||G[now][i].num==p) continue;
    dfs(G[now][i].to, now, p);
  }
}
int main(int argc, char const *argv[]) {
  ll x, y, n, m;std::cin >> n >> m;
  re(i, m){
    std::cin >> x >> y;
    G[x].push_back(edge{y, i});
    G[y].push_back(edge{x, i});
  }
  ll ans = 0;
  re(i, m){
    init();
    dfs(1, -1, i);
    ll c = 0;
    for(int j=1;j<=n;j++) if(use[j]==1) c++;
    if(c!=n) ans++;
  }
  std::cout << ans << '\n';
  return 0;
}


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

int main() {
  string s;
  cin >> s;
  long long ans = 0;
  if (s.length() == 1) {
    cout << stoi(s);
    return 0;
  }
  for (int i = 0; i < (1 << s.length() - 1); ++i) {
    long long res = 0;
    int prev = 0;
    for (int j = 0; j < s.length() - 1; ++j) {
      if ((i >> j) % 2 == 1) {
        res += stoll(s.substr(prev, j - prev + 1));
        prev = j + 1;
      }
    }
    res += stoll(s.substr(prev, s.length() - prev));
    ans += res;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF 1e9+7
typedef long long int ll;
const int maxn = 200000;
ll mod = INF;

int n,m;
vector<vector<int>> v(maxn);
bool used[maxn];
int group[maxn];
int cnt[maxn]={0};
int num=-1;
int ans=0;

int main(){

    cin >> n>>m;
    for(int i=0;i<m;i++){
        int a,b;cin >> a>>b;
        a--;b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }

    for(int i=0;i<n;i++){
        if(used[i])continue;
        num++;
        queue<int> que;
        que.push(i);
        used[i]=true;
        group[i]=num;
        while(!que.empty()){
            int arg=que.front();que.pop();
            for(int j=0;j<v[arg].size();j++){
                if(!used[v[arg][j]]){
                    used[v[arg][j]]=true;
                    group[v[arg][j]]=num;
                    que.push(v[arg][j]);
                }
            }
        }
    }

    // for(int i=0;i<n;i++){
    //     cout << group[i]<<endl;
    // }

    for(int i=0;i<n;i++){
        cnt[group[i]]++;
        ans=max(ans,cnt[group[i]]);
    }

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

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

int main(void){
  int N;
  int cnt;

  while(1){

    cnt = 0;

    cin >> N;

    if( N == 0 ) break;

    for( int a = 1 ; a <= N/2 ; a++ ){
      for( int n = 2 ; n <=N ; n++ ){

	if( n*( 2*a + ( n - 1 ) ) / 2 == N ) cnt++;

      }
    }

    cout << cnt << endl;

  }

  return 0;

}

Measured memory_bytes: 1160
s=int(input())

def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)
      
print(num2alpha(s).lower())

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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  if ( (A + B) > (C + D) ) {
    cout << "Left" << endl;
  }
  else if ( (A + B) == (C + D) ) {
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define rrep(i,n) for(int (i)=1;i<=(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define MOD 1000000007
#define INF 1e18
#define int long long
#define endl "\n"
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};



signed main() {
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(15);
    
    int x;
    cin >> x;
    if(x) cout << 0 << endl;
    else cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 3632