akhauriyash/Code-Regression huggingface dataset:
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE RankNTypes #-}
import qualified Data.ByteString.Lazy.Char8 as B
import Data.Maybe
-- import Data.List
-- import qualified Data.Vector.Unboxed as VU
-- import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import Control.Monad
-- import Control.Monad.ST
-- import Debug.Trace
-- trace _ = id

solve :: Int -> [(Int,Int)] -> String
solve bN lstAB | fNodes > sNodes = "Fennec"
               | otherwise       = "Snuke"
  where
  tree = rootedTree lstAB 1 (bN+1)
  path = rtPath tree 1 bN 1
  top = path !! (((length path) - 2) `div` 2)
  sNodes = countNodes top
  fNodes = bN - sNodes
  countNodes i = 1 + sum (map countNodes (rtChildren tree i))

-------------------------------------------------------------------------------
-- Rooted Tree

type RTree = Int -> (Int, [Int])

{-
 If we set
    let tree = rootedTree xys root vSize
 then
    tree :: Int -> (Int, [Int])
    tree i = (parent of i, children of i)
 Note that:
   - vSize should be maxIndex+1
   - node indices should be nonnegative
   - (-1) is set as the "parent of root"
-}

rootedTree :: [(Int,Int)] -> Int -> Int -> RTree
rootedTree xys root vSize i = v V.! i where
  v = V.create $ ((,) <$> VM.replicate vSize [] <*> VM.new vSize) >>= act
  act (vec,vecRC) = do
    forM_ xys $ \(x,y) -> do
      VM.modify vec (x:) y
      VM.modify vec (y:) x
    rootChildren <- VM.read vec root
    setRC (-1) root
    return vecRC
    where
    setRC parent idx = do
      cs <- filter (/= parent) <$> VM.read vec idx
      VM.write vecRC idx (parent, cs)
      mapM_ (setRC idx) cs

rtParent :: RTree -> Int -> Int
rtParent tree node = fst (tree node)

rtChildren :: RTree -> Int -> [Int]
rtChildren tree node = snd (tree node)

-- (rtPath tree root x y) is the path from x to y
rtPath :: RTree -> Int -> Int -> Int -> [Int]
rtPath tree root x y = combine root (pathRoot x) (pathRoot y)
  where
    pathRoot x = sub x []
      where sub x xs | x == root = xs
                     | otherwise = sub (rtParent tree x) (x:xs)
    combine c (x:xs) (y:ys) | x == y = combine x xs ys
    combine c xs ys = reverse xs ++ (c : ys)


readBInt :: B.ByteString -> Int
readBInt = fst . fromJust . B.readInt

tmain :: B.ByteString -> String
tmain cont =
  let remLines0 = map B.words (B.lines cont)
      [bs_bN]:remLines1 = remLines0
      bN = readBInt bs_bN
      lstAB = map (\[x1,x2] -> (readBInt x1,readBInt x2)) remLines1
  in solve bN lstAB

outAnswer :: String -> IO ()
outAnswer = putStrLn

main :: IO ()
main = outAnswer . tmain =<< B.getContents


-------------------------------------------------------------------------------

inp1 = "7\n3 6\n1 2\n3 1\n7 4\n5 7\n1 4\n"
inp2 = "4\n1 4\n4 2\n2 3\n"
tv1 = tmain $ B.pack inp1
tv2 = tmain $ B.pack inp2
test1 = tv1 == "Fennec"
test2 = tv2 == "Snuke"
alltest = test1 && test2



Measured memory_bytes: 38268
N = int(input())

A = list(map(int,input().split()))

ans = 1
q = []

for i,a in enumerate(A):

    if len(q) != 0 and ( (q[0] < q[-1] and q[-1] > a) or (q[0] > q[-1] and q[-1] < a) ):
        q = [a]
        ans += 1

    else:
        q.append(a)

print (ans)


Measured memory_bytes: 63468
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,m,u,k;
	scanf("%d%d%d%d",&n,&m,&u,&k);
	if((abs(n-m)<=k&&abs(m-u)<=k)||abs(n-u)<=k)
		printf("Yes");
	else
		printf("No");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cassert>
#include <utility>
#include <numeric>
#include <cstring>
#include <map>
using namespace std;
using ll = long long;

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

    vector<pair<int, int>> a(N);
    for (int i=1;i<=N;i++){
        int t;
        cin >> t;
        a[i-1] = make_pair(t,i);
    }
    sort(a.begin(), a.end());

    for (int i=0;i<N;i++){
        
        cout << a[i].second << " ";
    }
}

Measured memory_bytes: 1536
// AOJ ITP1_11_D Dice IV
// 2018.5.2 bal4u
 
#include <stdio.h>
#include <string.h>
 
#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()
{
    int n = 0, c = gc();
    do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
    return n;
}
 
int rot[24][7] = {
    { 0,1,2,3,4,5,6 },{ 0,1,3,5,2,4,6 },{ 0,1,4,2,5,3,6 },{ 0,1,5,4,3,2,6 },
    { 0,2,6,3,4,1,5 },{ 0,2,3,1,6,4,5 },{ 0,2,1,4,3,6,5 },{ 0,2,4,6,1,3,5 },
    { 0,3,1,2,5,6,4 },{ 0,3,2,6,1,5,4 },{ 0,3,5,1,6,2,4 },{ 0,3,6,5,2,1,4 },
    { 0,4,1,5,2,6,3 },{ 0,4,2,1,6,5,3 },{ 0,4,5,6,1,2,3 },{ 0,4,6,2,5,1,3 },
    { 0,5,1,3,4,6,2 },{ 0,5,3,6,1,4,2 },{ 0,5,4,1,6,3,2 },{ 0,5,6,4,3,1,2 },
    { 0,6,2,4,3,5,1 },{ 0,6,3,2,5,4,1 },{ 0,6,5,3,4,2,1 },{ 0,6,4,5,2,3,1 } };
 
int  a[102][7];
char f[102];
 
int identical(int *a, int *b)
{
    int i, j;
    memset(f, 0, sizeof(f));
    for (i = 1; i <= 6; i++) f[a[i]]++;
    for (i = 1; i <= 6; i++) f[b[i]]--;
    for (i = 1; i <= 6; i++) if (f[b[i]]) return 0;
 
    for (j = 0; j < 24; j++) {
        if (b[1] == a[rot[j][1]]) {
            for (i = 2; ; i++) {
                if (i > 6) return 1;
                if (b[i] != a[rot[j][i]]) break;
            }
        }
    }
    return 0;
}
 
int main()
{
    int n, i, j, f;
 
    n = in();
    for (i = 0; i < n; i++) {
        for (j = 1; j <= 6; j++) a[i][j] = in();
    }
    f = 1;
    for (i = 0; i < n; i++) for (j = i+1; j < n; j++) {
        if (identical(a[i], a[j])) { f = 0; goto done; }
    }
done:
    puts(f? "Yes": "No");
    return 0;
}


Measured memory_bytes: 2112
#include <iostream>
#include <vector>
#include <cmath>
#include <string> 
//https://qiita.com/ofutonfuton/items/92b1a6f4a7775f00b6ae
 
using namespace std;
typedef long long ll;
 
const ll M = 998244353;

int main()
{

    ll N;
    
    vector<string> strs;
    cin >> N;
    for(ll i = 0; i < N; i ++){
        string str;
        cin >> str;
        if(i != 0){
            for(string compStr: strs){
                if(compStr == str){
                    cout << "No";
                    return 0;
                }
            }
            if(strs[strs.size() - 1][strs[strs.size() - 1].size() - 1] != str[0]){
                cout << "No";
                    return 0;
            }
        }
        strs.push_back(str);
    }

    cout << "Yes";
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define ll long long
#define double long double
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define ALL(V) ((V).begin(),(V).end())
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
using namespace std;

int main(){
  int A,B,C,D,ans=0;
  cin>>A>>B>>C>>D;
  
  if((C+B-1)/B<=(A+D-1)/D) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(void){
    int i;
    int n,k,q,a;
    scanf("%d%d%d\n",&n,&k,&q);
    int *p;
    p=(int *)malloc(sizeof(int)*100000);
    if (p==NULL)exit(0);
    memset(p,0,n+1);
    for (i=0;i<q;i++){
	scanf("%d\n",&a);
	p[a]++;
	}
    for (i=1;i<=n;i++){
	if((p[i]+k-q)>0)printf("Yes\n");
	else printf("No\n");
	}

    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  int x, y, z;
  cin >> x >> y >> z;
  x -= z;
  cout << x / (y+z) << endl;
}


Measured memory_bytes: 256
from math import factorial
n,p=map(int,input().split())
a=list(map(int,input().split()))
even=0
odd=0
for i in a:
    if i%2==0:
        even+=1
    else:
        odd+=1
def comb(a,b):
    return factorial(a)//(factorial(a-b)*factorial(b))
n_even=0
n_odd=0
for i in range(even+1):
    n_even+=comb(even,i)

if p==1:
    for i in range(1,odd+1,2):
        n_odd+=comb(odd,i)
else:
    for i in range(0,odd+1,2):
        n_odd+=comb(odd,i)
print(n_even*n_odd)


Measured memory_bytes: 9208
#include <bits/stdc++.h>
#include <complex>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,C,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
const long double EPS = 1e-9;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;


int main() {
    cin>>A>>B;
    if(abs(A - B) >= 2){
        cout<<0<<endl;
    }else{
        ll ans = 1;
        reps(i,1,A+1) (ans *= i)%=MOD;
        reps(i,1,B+1) (ans *= i)%=MOD;
        if(A == B) (ans *= 2)%=MOD;
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
int main(void){
    int N,K;
    cin >> N >> K;
    long long ans = 1;
    for(int i=0;i<N;i++){
        if(i == 0){
            ans *= K;
            K--;
        }
        else{
            ans *= K;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3192
import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.util.Map.Entry;



public class  Main{
	
	public static void main(String[] args) throws Exception{
    	MScanner sc = new MScanner(System.in);
        //MScanner sc = new MScanner("task.in");
        PrintWriter pw=new PrintWriter(System.out);
        char[]in=sc.nextLine().toCharArray();
        char cur='0';
        int ans0=0;
        for(int i=0;i<in.length;i++) {
        	if(in[i]!=cur)ans0++;
        	if(cur=='0')cur='1';
        	else	cur='0';
        }
        int ans1=0;cur='1';
        for(int i=0;i<in.length;i++) {
        	if(in[i]!=cur)ans1++;
        	if(cur=='0')cur='1';
        	else	cur='0';
        }
        pw.println(Math.min(ans0,ans1));
        pw.flush();
    }
	static class pair implements Comparable<pair>{
		int t;int d;
		pair(int x,int y){
			t=x;d=y;
		}
		@Override
		public int compareTo(pair o) {
			if(t!=o.t) {
				return t-o.t;
			}
			return d-o.d;
		}
	}
    static class MScanner {
		StringTokenizer st;
		BufferedReader br;
 
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
 
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

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

vector<int> b;
multiset<int,greater<int>> a;

int main() {
	
	int n,val;
	cin>>n;
	
	for(int i =0; i<n;i++){
		cin>>val;
		a.insert(val);
		b.push_back(val);
	}
	
	for(int i = 0;i<n;i++){
		a.erase(a.find(b[i]));
		cout<<*a.begin()<<endl;
		a.insert(b[i]);
	}
	
	
	
	return 0;
}

Measured memory_bytes: 13684
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*1)

func main() {
	list := getStdinIntArr()
	A := list[0]
	B := list[1]

	if A >= 13 {
		fmt.Printf("%d\n", B)
	} else if A >= 6 {
		fmt.Printf("%d\n", B/2)
	} else {
		fmt.Printf("%d\n", 0)
	}

}

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}

func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}

func readLine() string {
	buf := make([]byte, 0, 1024*1024*10)
	for {
		l, p, e := sc.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


Measured memory_bytes: 3072
N = int(input())
P = input().split()
P = [int(s) for s in P]
T = range(1, N+1)
count=[]
for i in range(N):
  if P[i] != T[i]:
    count.append(i)
if len(count) != 2 and len(count) != 0:
  print("NO")
elif len(count) == 0:
  print("YES")
else:
  P[count[0]], P[count[1]] = P[count[1]], P[count[0]]
  if list(T) == P:
    print("YES")
  else:
    print("NO")

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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
#define PI 3.14159265359 //πの値
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

 
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll A,B;
cin >> A >> B;
if(A>=10||B>=10) cout << -1;
else cout << A*B;
  
}

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

#define NMAX 50000

using namespace std;

//ifstream fin("f.in");
//ofstream fout("f.out");

int date;
int year, month;
bool yearCanBeMonth, monthCanBeYear;
bool monthIsMonth, yearIsYear;

int main()
{
    cin >> date;
    year = date / 100;
    month = date % 100;

    if(year >= 1 && year <= 12)
        yearCanBeMonth = true;
    monthCanBeYear = true;

    if(month >= 1 && month <= 12)
        monthIsMonth = true;
    yearIsYear = true;

    if(monthIsMonth)
        if(yearCanBeMonth)
            cout << "AMBIGUOUS\n";
        else
            cout << "YYMM\n";
    else
        if(yearCanBeMonth)
            cout << "MMYY\n";
        else
            cout << "NA\n";

    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;

class IO {
    private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    private static String[] buffers = new String[1];
    private static int cur=1;

    static BufferedReader getBr() {
        return br;
    }

    static String next() {
        String res = null;
        try {
            res = br.readLine();
            cur = buffers.length;
        } catch (IOException e) {
            e.printStackTrace();
        }
        return res;
    }

    static int nextInt() {
        if(buffers.length == cur) {
            buffers = next().split(" ");
            cur = 0;
        }
        return Integer.parseInt(buffers[cur++]);
    }

    static long nextLong() {
        if(buffers.length == cur) {
            buffers = next().split(" ");
            cur = 0;
        }
        return Long.parseLong(buffers[cur++]);
    }

    static double nextDouble() {
        if(buffers.length == cur) {
            buffers = next().split(" ");
            cur = 0;
        }
        return Double.parseDouble(buffers[cur++]);
    }

    static void out(Object... obj) {
        StringBuilder sb = new StringBuilder();
        for(Object o:obj) {
            sb.append(o);
        }
        System.out.println(sb);
    }

    static void outs(Object... obj) {
        StringBuilder sb = new StringBuilder();
        sb.append(obj[0]);
        for(int i=1; i<obj.length; i++) {
            sb.append(" ").append(obj[i]);
        }
        System.out.println(sb);
    }
}

// ABC073
public class Main {

    public static void main(String[] args) {
        int N = IO.nextInt();
        HashMap<Long, Integer> hm = new HashMap<>();

        for (int i = 0; i < N; i++) {
            long A = IO.nextLong();
            Integer v = hm.get(A);
            if (v==null || v==0) {
                hm.put(A, 1);
            } else {
                hm.put(A, 0);
            }
        }

        int ans = 0;
        for (Long k : hm.keySet()) {
            if (hm.get(k) == 1) ans++;
        }
        IO.out(ans);
    }
}


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

#define ll long long
#define mp make_pair
#define pb push_back

#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define rep(i, n) for (int i = 0; i < (int)(n); ++ i)

const int mxn = 2e5 + 5;
const int mod = 998244353, inv9 = 443664157;
int n, q;
int pw10[mxn], full[mxn];

struct SEG {
	static const int mxn = 1 << 18, k = 18;

	struct VA {
		int va, len;
		VA(int va = 0, int len = 0): va(va), len(len) {}
		VA operator+ (const VA& rhs) const {
			return VA((1LL * va * pw10[rhs.len] % mod + rhs.va) % mod, len + rhs.len);
		}
		void modify(int x) {
			va = 1LL * x * full[len] % mod;
		}
	};
	VA va[mxn << 1];

	int tag[mxn];

	SEG() {
		memset(tag, -1, sizeof(tag));
	}

	inline void push(int x, int v) {
		va[x].modify(v);
		if (x < mxn) tag[x] = v;
	}

	inline void pushdown(int x) {
		if (tag[x] != -1) {
			push(x << 1, tag[x]);
			push(x << 1 | 1, tag[x]);
			tag[x] = -1;
		}
	}

	inline void pushup(int x) {
		va[x] = va[x << 1] + va[x << 1 | 1];
	}

	void build(int n) {
		rep(i, n) va[i + mxn] = VA(1, 1);
		for (int i = mxn - 1; i; -- i) pushup(i);
	}

	void upd(int l, int r, int v) {
		l += mxn; r += mxn;
		for (int i = k; i; -- i) {
			if (((l >> i) << i) != l) pushdown(l >> i);
			if (((r >> i) << i) != r) pushdown(r >> i);
		}
		int l0 = l, r0 = r;
		for (; l < r; l >>= 1, r >>= 1) {
			if (l & 1) push(l ++, v);
			if (r & 1) push(-- r, v);
		}
		for (int i = 1; i <= k; ++ i) {
			if (((l0 >> i) << i) != l0) pushup(l0 >> i);
			if (((r0 >> i) << i) != r0) pushup(r0 >> i);
		}
	}
} seg;

int main() {
	rep(i, mxn) pw10[i] = i ? 10LL * pw10[i - 1] % mod : 1;
	rep(i, mxn) full[i] = 1LL * (pw10[i] + mod - 1) * inv9 % mod;
	scanf("%d %d", &n, &q);
	seg.build(n);
	while (q --) {
		int l, r, d;
		scanf("%d %d %d", &l, &r, &d);
		-- l;
		seg.upd(l, r, d);
		printf("%d\n", seg.va[1].va);
	}
	return 0;
}

Measured memory_bytes: 10412
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long A = sc.nextLong();
        long B = sc.nextLong();
        long ans = computeXOR(A - 1) ^ computeXOR(B);//^ computeXOR(A - 1);
        System.out.println(ans);
    }
    private static long computeXOR(long n) {
        if(n % 4 == 0) return n;
        if(n % 4 == 1) return 1;
        if(n % 4 == 2) return n + 1;
        if(n % 4 == 3) return 0;
        return 0;
    }
}

Measured memory_bytes: 25172
import sys
n,m = [int(j) for j in sys.stdin.readline().split()]
l = [int(j) for j in sys.stdin.readline().split()]
l.sort(reverse=True)
for i in range(m):
    if l[i]<sum(l)/(4*m):
        # print(l[i])
        print("No")
        break
else:
    print("Yes")
    # else:


Measured memory_bytes: 38384
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		Scanner scan=new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		
		int y=scan.nextInt();
		int x=scan.nextInt();
		System.out.print(y/x);
		System.out.print(" "+y%x+" ");
		System.out.printf("%f",(double)y/x);
		System.out.println();
		
		
	}

}

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

#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define _ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

typedef long long lli;
typedef unsigned long long ulli;
typedef pair<int, int> pii;

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

int h, w, dH[4] = {-1, 0, 1, 0}, dW[4] = {0, 1, 0, -1};
pii in, fin;
vector<vector<bool>> pared;

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

void leerDatos()
{   _

    cin >> h >> w;
    cin >> in.fi >> in.se;
    cin >> fin.fi >> fin.se;
    pared.resize(h + 1, vector<bool>(w + 1));
    for (int i=1; i<=h; ++i)
    {
        for (int j=1; j<=w; ++j)
        {
            char ch;
            cin >> ch;
            pared[i][j] = (ch == '#');
        }
    }
}

bool ok(pii p)
{
    return (1 <= p.fi && p.fi <= h && 1 <= p.se && p.se <= w && !pared[p.fi][p.se]);
}

int bfs(pii o, pii destino)
{
    vector<vector<int>> dist(h + 1, vector<int>(w + 1, -1));

    dist[o.fi][o.se] = 0;

    deque<pii> cola;

    cola.push_front(o);

    while (!cola.empty())
    {
        pii a = cola.front();
        cola.pop_front();

        for (int i=0; i<4; ++i)
        {
            pii hijo = a;

            hijo.fi += dH[i];
            hijo.se += dW[i];

            if (ok(hijo))
            {
                if (dist[hijo.fi][hijo.se] == -1 || dist[a.fi][a.se] + 0 < dist[hijo.fi][hijo.se])
                {
                    dist[hijo.fi][hijo.se] = dist[a.fi][a.se] + 0;
                    cola.push_front(hijo);
                }
            }
        }
        for (int i=-2; i<=2; ++i)
        {
            for (int j=-2; j<=2; ++j)
            {
                pii hijo = a;

                hijo.fi += i;
                hijo.se += j;

                if (ok(hijo))
                {
                    if (dist[hijo.fi][hijo.se] == -1 || dist[a.fi][a.se] + 1 < dist[hijo.fi][hijo.se])
                    {
                        dist[hijo.fi][hijo.se] = dist[a.fi][a.se] + 1;
                        cola.push_back(hijo);
                    }
                }
            }
        }
    }
    return dist[destino.fi][destino.se];
}

int main()
{   _

    leerDatos();

    cout << bfs(in, fin) << endl;

    return 0;
}

Measured memory_bytes: 7776
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iomanip>
#include<vector>
#include<queue>
#include<deque>
#include<string>
#include<utility>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<set>
#include<map>
#include<bitset>
#include<stack>
#include<ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<pli> vpli;
typedef vector<vi> mat;

inline ll read(){
	ll Hashimoto=0,Kanna=1;
	char I_Love=getchar();
	while(I_Love<'0'||I_Love>'9'){
		if(I_Love=='-')Kanna=-1;
		I_Love=getchar();
	}
	while(I_Love>='0'&&I_Love<='9'){
		Hashimoto=Hashimoto*10+I_Love-'0';
		I_Love=getchar();
	}
	return Hashimoto*Kanna;
}

#define I_Love_Hashimoto_Kanna main
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define filein(s) freopen(s,"r",stdin);
#define fileout(s) freopen(s,"w",stdout);
#define file freopen("I_Love_Hashimoto_Kanna.out","w",stdout);
#define RE cout<<"I_Love_Hashimoto_Kanna"<<endl;
#define Tone(Kanna) cout<<Kanna<<endl;
#define Tall(Hashimoto,Kanna) for(int I_Love=0;I_Love<Kanna;I_Love++)cout<<Hashimoto[I_Love]<<(I_Love==Kanna-1?"\n":" ");
#define FOR(I_Love,Hashimoto,Kanna) for(int I_Love=Hashimoto;I_Love<Kanna;I_Love++)
#define MP(Hashimoto,Kanna) make_pair(Hashimoto,Kanna)
#define REV(Kanna) reverse(Kanna.begin(),Kanna.end());
#define SORT(Kanna) sort(Kanna.begin(),Kanna.end());
#define inf (int)1e9
#define linf (ll)1e15
#define mod (inf+7)

int n,k;
int a[5555];

bool check(int x){
	if(a[x]>=k)return 0;
	bool dp[5555]={};
	dp[0]=1;
	int mx=0;
	FOR(i,0,n){
		if(i==x)continue;
		for(int j=min(mx,k-1-a[i]);j>=0;j--){
			if(dp[j]){
				dp[j+a[i]]=1;
				mx=max(mx,j+a[i]);
			}
		}
	}
	FOR(i,k-a[x],k){
		if(dp[i])return 0;
	}
	return 1;
}

int I_Love_Hashimoto_Kanna() {
  fastio;
  n=read();k=read();
  FOR(i,0,n){
  	a[i]=read();
	}
	sort(a,a+n);
	if(!check(0)){
		Tone(0);
		exit(0);
	}
	int l=0,r=n;
	while(l<r-1){
		int mid=l+r>>1;
		if(check(mid))l=mid;
		else r=mid;
	}
  Tone(l+1);
  
  return 0;
}


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

#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <complex>
#include <string>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <fstream>
#include <iomanip>
#include <assert.h>

using namespace std;
#define el  '\n'
#define ll long long
#define clr(a, b)memset(a,b,sizeof(a))
#define sz(a) (int)(a).size()
const long long N = 102, OO = 0x3f3f3f3f, MOD = (int) 1e9 + 7;

int n, totW;
pair<int, int> a[N];
int dp[(int) 1e5 + 2];

class EKnapsack2 {
public:
    void init() {
        clr(dp, OO);
    }


    void solve(istream &cin, ostream &cout) {
        init();
        cin >> n >> totW;
        int sum = 0;
        for (int i = 0; i < n; i++) {
            cin >> a[i].first >> a[i].second;
            sum += a[i].second;
        }
        dp[0] = 0;
        for (int i = 0; i < n; i++) {
            for (int curV = sum; curV >= a[i].second; curV--)
                dp[curV] = min(dp[curV], dp[curV - a[i].second] + a[i].first);
        }
        int ans = 0;
        for (int i = 0; i <= sum; i++) {
            if (dp[i] <= totW)
                ans = max(ans, i);
        }
        cout << ans << el;
    }
};
int main() {
	ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
	EKnapsack2 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

int main(){
  int n,m,l,j,k=0;
  cin >> n >> m;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a.at(i);
    k += a.at(i);
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  j = 4*m;
  l = k;
  k /= j;
  if(l%j > 0) k++;
  
  if(a.at(m-1) >= k) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fi first
#define se second
int main(){
    ll n,a=0,b=0;
    cin >> n;
    vector<ll> v(n),u(n);
    for(ll i=0;i < n;i++)
    {
        cin >> v.at(i);
    }
    for(ll i=0;i < n;i++)
    {
        cin >> u.at(i);
    }

    for(ll i=0;i < n;i++)
    {
        if(v.at(i)-u.at(i)>0){
            a += v.at(i)-u.at(i);
        }else{
             b += (u.at(i)-v.at(i))/2;
        }
    }

    if(a<=b){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }//koko
}
/*条件を詰め切れなかった*/

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

public class Main{
	
	static int gcd(int a, int b) {
		if(a == 0) return b;
		return gcd(b % a, a);
	}

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		int n = sc.nextInt();

		int x = sc.nextInt();
		
		int gcd = sc.nextInt();
		int max = gcd;
		
		for (int i = 1; i < n; i++) {
			int cur = sc.nextInt();
			gcd = gcd(cur, gcd);
			max = Math.max(max, cur);
		}
		
		if(x <= max && x % gcd == 0)
			out.println("POSSIBLE");
		else
			out.println("IMPOSSIBLE");
		
		out.flush();
	}


	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public String next() throws IOException {
			while(st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}
	}	

}

Measured memory_bytes: 35852
#include <bits/stdc++.h>
using namespace std;
 
typedef pair<int,int> pii;
typedef long long ll;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}

ll N, X;

ll rec(ll h, ll w){
    ll sum = 0;
    if(h % w == 0){
        sum += h / w * 2 * w - w;
    }
    else{
        sum += h / w * 2 * w;
        sum += rec(w, h - h / w * w);
    }
    return sum;
}

int main(){

    cin >> N >> X;
    ll minv = min(N - X , X);
    ll maxv = max(N - X , X);
    cout << N + rec(maxv, minv) << endl;


    return 0;
}


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

int main() {

    string S;
    cin >> S;

    if (S[0] == S[1] && S[2] == S[3] && S[1] != S[2]) cout << "Yes" << endl;
    else if (S[0] == S[2] && S[1] == S[3] && S[1] != S[2]) cout << "Yes" << endl;
    else if (S[0] == S[3] && S[1] == S[2] && S[0] != S[1]) cout << "Yes" << endl;
    else cout << "No" << endl;

        return 0;
}

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

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

  int A = N / 100 * 100 + N / 100 * 10 + N / 100 * 1;

  if (N <= A) cout << A << endl;
  else cout << A + 111 << endl;
}

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

int main() {
    int A;
    int B;
    cin >> A >> B ;
    
    int plugCount= 1;
    int answer = 0;
    while(true){
        if (B <= plugCount) break;

        plugCount += A - 1;
        answer++;

    }

    cout << answer << endl;
    return 0;
}

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

int main() {
  int n;
  cin >> n;

  map<ll, ll> mp;
  ll a, ans = 0;
  for (ll i=0; i<n; i++) {
    cin >> a;
    if (i >= a) ans += mp[i-a];
    mp[i+a]++;
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 17240
n, k =map(int, input().split())
H=list(map(int, input().split()))

dp = [10**10] * n

dp[0] = 0

dp[1] = abs(H[1] - H[0])
for i in range(2,n):
    for j in range(1,k+1):
        if i-j>=0:
    
            dp[i] = min(dp[i-j] + abs(H[i] - H[i-j]), dp[i])
    
print(dp[-1])

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

#define ln                '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fm, to)    for (int i = fm; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

template<int mod>
struct modulo {
	int w;
	operator int&() { return w; }
	
	modulo() {}
	modulo(int w) { this->w = w; fix(); }
	void inline fix() { w %= mod; if (w < 0) w += mod; }
	modulo inline fix(int w) const { w %= mod; if (w < 0) w += mod; return w; }
	
	modulo& operator += (modulo b) { if ((w += b.w) >= mod) w -= mod; return *this; }
	modulo& operator -= (modulo b) { if ((w -= b.w) < 0) w -= mod; return *this; }
	modulo& operator *= (modulo b) { w = (num) w * b.w % mod; return *this; }
	modulo& operator /= (modulo b) { w = (num) w * b.inv() % mod; return *this; }
	modulo inline operator + (modulo b) { modulo r = *this; r += b; return r; }
	modulo inline operator - (modulo b) { modulo r = *this; r -= b; return r; }
	modulo inline operator * (modulo b) { modulo r = *this; r *= b; return r; }
	modulo inline operator / (modulo b) { modulo r = *this; r /= b; return r; }
	
	modulo inline inv() const {
		int a = w, m = mod, u = 0, v = 1, t;
		for (; a != 0; t = m / a, m -= t * a, swap(a, m), u -= t * v, swap(u, v));
		return fix(u);
	}
	
	modulo inline pow(int p) const {
		if (!w)  return 0;
		modulo a = *this, r = 1;
		for (; p > 0; a *= a, p >>= 1) if (p & 1) r *= a;
		return r;
	}
};
const int mod = 998244353;
typedef modulo<mod> rem;

const int nsz = int(2e5);
rem n, m, k, inv[nsz + 5], fac[nsz + 5], ifc[nsz + 5], ans;

void inline init() {
	inv[1] = 1;
	circ (i, 2, n) {
		inv[i] = rem(-mod / i) * inv[mod % i];
	}
	fac[0] = ifc[0] = 1;
	cont (i, n) {
		fac[i] = fac[i - 1] * rem(i);
		ifc[i] = ifc[i - 1] * inv[i];
	}
}

rem inline C(int n, int m) { return fac[n] * ifc[m] * ifc[n - m]; }

rem inline f(int n, int k) { return C(n - 1, k) * m * (m - rem(1)).pow(n - k - 1); }

int main() {
	scanf("%d%d%d", &n, &m, &k);
	if (m == 1) {
		printf("%d\n", k == n - rem(1));
		return 0;
	}
	init();
	circ (i, 0, int(k)) {
		ans += f(n, i);
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 6152
n = int(input())
a = list(map(int, input().split()))
count = 0
i = 0
while True:
    if a[i] % 2 != 0:
        break
    else:
        a[i] = a[i]/2
    i += 1
    if i+1 == n:
        count += 1
        i = 0
print(count)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
using namespace std;
const int N = 20;
int main(int argc, char *argv[])
{
  for(;;) {
    int n, k, s;
    cin >> n >> k >> s;
    if(n == 0 && k == 0 && s == 0) break;
    int cnt = 0;
    for(int i = 0; i < 1<<n; i++) {
      int c = 0;
      int ss = 0;
      for(int j = 1, x = 1; j <= i; j<<=1, x++) {
        if(i & j) { c++; ss+=x; }
      }
      if(c == k && s == ss) cnt++;
    }
    cout << cnt << endl;
  }
  return 0;
}



Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
constexpr auto INF = INT_MAX / 2;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int main() {

	int n;
	cin >> n;
	vi x(n), y(n);
	rep(i, n)cin >> x[i] >> y[i];

	map<P, int> mp;

	rep(i, n)rep(j, n) {
		if (i == j)continue;
		mp[make_pair(x[i] - x[j], y[i] - y[j])]++;
	}

	int mx = 0;
	for (auto x : mp)mx = max(mx, x.second);

	cout << n - mx << endl;

}

Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<int,int>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll N;
  cin>>N;
  ll A[N+1],ANS[N+1];
  RREP(i,N){
    cin>>A[i];
    ANS[i]=0;
  }
  
  vector<ll> L;
  for(int i=N; i>=1; --i){
    ll cnt=0;
    for(int j=1; j<=N/i; ++j){
      cnt+=ANS[i*j];
    }
    ANS[i]=abs(A[i]-cnt%2);
    if(ANS[i]>0) L.PB(i);
  }
  SORT(L);
  co(L.size());
  REP(i,L.size()) cout<<L[i]<<" ";
  cout<<endl;
  return 0;
}

Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
typedef long long  ll ;
typedef double db;
const double pi = 3.141592654;
#define pb         push_back
#define forab(i,a,b)       for(int i=(a);i<=(b);i++)
#define CIN	ios_base::sync_with_stdio(0); cin.tie(0)
#define pcase(z,x)     printf("Case %ld: %lld\n",z,x)
#define nw	 "\n"
#define mod 1000000007


int main(void)
{
	CIN;
	ll tc,l,k=0,sum=0,x=0,y,z=0,m=1,n=0,ans=0,cnt=0;
	cin>>n;
	ll arr1[n],arr2[n];
	cin>>arr1[0];
	for(ll i=1;i<n;i++){
		cin>>arr1[i];
		arr1[i]+=arr1[i-1];
	}
	for(ll i=0;i<n;i++)cin>>arr2[i];
	for(ll i=n-2;i>=0;i--)
		arr2[i]+=arr2[i+1];
	for(ll i=0;i<n;i++)
		z=max(z,arr1[i]+arr2[i]);
	cout<<z;
	
}

Measured memory_bytes: 3588
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, n);
    IN(ll, m);
    IN(ll, d);
    double ans = (1.0 + (d != 0)) * (m - 1) * (n - d) / (n * n);
    FOUT(ans);
}

Measured memory_bytes: 3752
h, w = map(int, input().split())

edges = [[] for i in range(10)]

for _from in range(10):
    line = list(map(int, input().split()))
    for to in range(10):
        if _from == to:
            continue
        cost = line[to]
        edges[_from].append([to, cost])

cost_to_1 = [10**5] * 10
cost_to_1[1] = 0

for num in range(10):
    if num == 1:
        continue
    min_cost_to = [10**5] * 10
    min_cost_to[num] = 0
    todo = []
    for to, cost in edges[num]:
        if to == num:
            continue
        min_cost_to[to] = cost
        todo.append(to)

    while todo:
        now = todo.pop()
        cost = min_cost_to[now]
        for to, add_cost in edges[now]:
            if to == now:
                continue
            if cost + add_cost < min_cost_to[to]:
                min_cost_to[to] = cost + add_cost
                todo.append(to)
            else:
                continue

    cost_to_1[num] = min_cost_to[1]

ans = 0
for i in range(h):
    line = list(map(int, input().split()))
    for num in line:
        if num == -1 or num == 1:
            continue
        ans += cost_to_1[num]

print(ans)


Measured memory_bytes: 3064
# -*- coding:utf-8 -*-

if __name__ == "__main__":
    A, B = list(map(int, list(map(float, input().split()))))
    ans = 0
    for i in range(A, B+1):
        c = str(i)
        length = len(c)
        if length%2 == 0:
            continue
        for j in range(length):
            if c[j] == c[length-1-j]:
                if j == length-1-j:
                    ans += 1
                    break
                continue
            else:
                break
    print(ans)


Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
#include <queue>
using namespace std;
#define ll long long
int q, n, v;
char c;
int p[100005];
int main() {
    while ((~scanf("%d %d", &n, &q)) && q && n) {
        for (int i = 2; i <= n; ++i) scanf("%d", &p[i]);
        p[1] = 1;
        ll ans = 0;
        for (int i = 0; i < q; ++i) {
            scanf("\n%c %d", &c, &v);
            if (c == 'M') p[v] = v;
            else {
                while (p[v] != v) v = p[v];
                ans += v;
            }
        }
        printf("%lld\n", ans);
    }
    return 0;
}



Measured memory_bytes: 3092
#!/usr/bin/env python3
import sys
from itertools import accumulate


def solve(N: int, X: int, x: "List[int]"):
    coeff = [2*i+1 if i>=3 else 5 for i in range(N+1)]
    acc = list(accumulate([0]+x))
    tmp = 0
    for i in range(N):
        tmp += coeff[N-i]*x[i]
    tmp += N*X+X
    ans = tmp
    for i in range(2, N+1):
        #def tmp_iter():
        #    cnt = 0
        #    p, q = -(-N//i), N%i
        #    if q>0:
        #        for _ in range(q):
        #            cnt += 1
        #            yield coeff[p]
        #            if cnt==N:
        #                break
        #    else:
        #        p += 1
        #    while cnt<N:
        #        p -= 1
        #        for j in range(i):
        #            cnt += 1
        #            yield coeff[p]
        #            if cnt==N:
        #                break
        #for k, elem in enumerate(tmp_iter()):
        #    print(i, k, elem)
        #    tmp_ans += elem*x[k]
        #tmp_ans += N*X+i*X
        tmp_ans = 0
        p, q = N//i, N%i
        for j in range(p):
            tmp_ans += coeff[p-j]*(acc[q+i*(j+1)]-acc[q+i*j])
        if q>0:
            tmp_ans += coeff[p+1]*acc[q]
        tmp_ans += N*X+i*X

        ans = min(ans, tmp_ans)
    print(ans)

    return


# Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    x = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, X, x)

if __name__ == '__main__':
    main()


Measured memory_bytes: 46272
n = int(input())
data = [list(map(int,input().split())) for i in range(n)]
room = [[[0 for k in range(10)] for j in range(3)] for i in range(4)]
for a in data:
    room[a[0]-1][a[1]-1][a[2]-1]+=a[3]

for x,i in enumerate(room):
    for j in i:
            print(''," ".join(map(str,j)))
    if x <= 2 : print('#'*20)

Measured memory_bytes: 7788
#include <bits/stdc++.h>
#define SIZE 20
#define BT (1<<19)
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int dp[BT][SIZE];
int A[SIZE],B[SIZE];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%d",&A[i]);
	for(int i=0;i<n;i++) scanf("%d",&B[i]);
	memset(dp,-1,sizeof(dp));
	for(int i=0;i<n;i++) dp[1<<i][i]=0;
	for(int S=1;S<(1<<n);S++)
	{
		int c=0;
		for(int i=0;i<n;i++) if(S>>i&1) c++;
		for(int i=0;i<n;i++)
		{
			if(!(S>>i&1)||dp[S][i]==-1) continue;
			//printf("%d %d : %d\n",S,i,dp[S][i]);
			int w=(i%2==c%2?B[i]:A[i]);
			int cost=c;
			for(int j=0;j<n;j++)
			{
				if(S>>j&1) cost--;
				else
				{
					int v=(j%2==c%2?A[j]:B[j]);
					if(w<=v)
					{
						int vl=dp[S][i]+cost;
						if(dp[S|1<<j][j]==-1||dp[S|1<<j][j]>vl) dp[S|1<<j][j]=vl;
					}
				}
			}
		}
	}
	int ret=-1;
	for(int i=0;i<n;i++)
	{
		if(dp[(1<<n)-1][i]!=-1)
		{
			//printf("%d %d\n",i,dp[(1<<n)-1][i]);
			if(ret==-1||ret>dp[(1<<n)-1][i]) ret=dp[(1<<n)-1][i];
		}
	}
	printf("%d\n",ret);
	return 0;
}

Measured memory_bytes: 41216
#include<bits/stdc++.h>
#include <math.h>
#include<iostream>
#include <string>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)


int main() {
    int x,y,z;
	cin >> x>> y;
      cout << (x+y+1)/2 << endl;
}

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();
        
        if (A >= 13) {
            System.out.println(B);
        } else if (6 <= A && A <= 12) {
            System.out.println(B / 2);
        } else {
            System.out.println(0);
        }
    }
}

Measured memory_bytes: 21588
#include <iostream>
#include <string>

using namespace std;

int main(){
    int dish[5];
    for(int i = 0; i < 5; i++)cin >> dish[i];
    int j = 0;
    int time = 0;
    int check = 10;
    for(int i = 0; i < 5; i++){
        if(dish[i] % 10 < check && dish[i] % 10 != 0){
            check = dish[i] % 10;
            j = i;
        }
    }
    if(j != 4){
        check = dish[j];
        dish[j] = dish[4];
        dish[4] = check;
    }
    j = 0;
    while(j < 5){
        if(time % 10 == 0){
            time += dish[j];
            j++;
        }else{
            time++;
        }
    }
    cout << time << endl;
}

Measured memory_bytes: 256