akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF (2e9)
#define EPS (1e-7)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

unsigned euclidean_gcd(unsigned a, unsigned b) {
  return b != 0 ? euclidean_gcd(b, a % b) : a;
}

int main() {
  ll a, b;
  cin >> a >> b;
  cout << (a * b) / euclidean_gcd(a, b) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include <complex>
#include <cmath>
#include<cstdio>
using namespace std;
typedef complex<double> xy_t;

xy_t P[110];
double dot_product(xy_t a, xy_t b) { return (conj(a)*b).real(); }
double cross_product(xy_t a, xy_t b) { 
    return (conj(a)*b).imag(); 
}
xy_t projection(xy_t p, xy_t b) { return b*dot_product(p,b)/norm(b); }


#include <cstdio>
double X1,Y1,X2,Y2,XQ,YQ;

int main() {
    while (scanf("%lf,%lf,%lf,%lf,%lf,%lf",&X1, &Y1, &X2, &Y2, &XQ, &YQ) != EOF) {
        xy_t P1(X1,Y1), P2(X2,Y2), Q(XQ,YQ);
        xy_t S = projection(Q-P1,P2-P1) + P1;
        xy_t R = S + S -Q; // 線対称の点を計算
    printf("%.6f %.6f\n", real(R), imag(R));
    }
}


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

int main()
{
    string s,t,u; int a,b;
    cin>>s>>t>>a>>b>>u;
    if (u==s && s!=t){
        cout <<a-1<<" "<<b;
    }
    else if (u==t && t!=s) {
            cout <<a<<" "<<b-1;
    }
    return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int, input().split()))
b=list(map(int, input().split()))
ans=0
fii=min(a[0],b[0])
ans+=fii
fii1=min(a[1],b[0]-fii)
ans+=fii1
for i in range(1,n):
  fii=min(a[i]-fii1,b[i])
  ans+=fii
  fii1=min(a[i+1],b[i]-fii)
  ans+=fii1
print(ans)

Measured memory_bytes: 97640
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }


int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1LL << 60;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using pLL = std::pair<long long, long long>;
using ll = long long;
#define SORT(v) std::sort(v.begin(), v.end())
#define rSORT(v) std::sort(v.begin(), v.end(),std::greater<int>())
int gcd(int a, int b) {
    if (a < b) swap(a, b);
    if (b == 0) {
        return b;
    }
    return gcd(b, a%b);
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> a(n);
    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        ans += abs(a[i]);
    }
    int count = 0;
    ll mn = LINF;
    for (int i = 0; i < n; ++i) {
        if (a[i] <= 0) count++;
        mn = min(mn, abs(a[i]));

    }
    
    if (count % 2 == 0) {
        cout << ans << endl;
    }
    else {
        ans -= 2 * mn;
        cout << ans << endl;
    }
    return 0;
}



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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<endl

int main(){
    int ans = 0;
    int n;
    cin >> n;
    REP(i,n){
        int t;
        cin >> t;
        ans += t-1;
    }
    cout << ans << endl;
}


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

using namespace std;

const int INF = 1e9 + 5;

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

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

	vector<int> dp(n, INF);

	dp[0] = 0;

	for(int i=0; i <n; i++){
		for(int j=i + 1; j<= i+ k; j++){
			if(j < n){
				dp[j] = min(dp[j], dp[i] + abs(stones[j] - stones[i]));
			}
		}
	}

	cout<< dp[n-1];

	return 0;
}

Measured memory_bytes: 4016
function bomb(){
   var obj={};
   var ans="NA";
   var leaf=[[0,0,0],[1,0,0]];
   while(true){
      if(leaf.length==0)break;
      var ary=leaf.shift();
      var x=ary[0];
      var y=ary[1];
      if(obj.hasOwnProperty(x+","+y))continue;
      else obj[x+","+y]=true;
      var cnt=ary[2];
      var v=xy[x][y];
      if(v==1){
         while(true){
            y++;
            if(xy[x][y]!=1){
               y--;
               break;
            }
         }
      }else if(v==2){
         while(true){
            y--;
            if(xy[x][y]!=2)break;
         }
      }
       if(y==n-1){
         ans=cnt;
         break;
      }
      for(var i=0;i<=2;i++)leaf.push([1-x,y+i,cnt+1]);
   }
   return ans;
}
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
while(true){
   var n=arr.shift()-0;
   if(n==0)break;
   var xy=[];
   xy[0]=arr.shift().split(" ").map(Number);
   xy[1]=arr.shift().split(" ").map(Number);
   console.log(bomb());
}

Measured memory_bytes: 17816
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

using namespace std;

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvdi(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)

#define rep(i,n) for(auto i=0; i<(n); i++)

const int mod = 1000000007;

struct mint {
    ll x;
    mint(ll x=0):x(x%mod){}

    mint& operator+=(const mint a) {
        if((x += a.x) >= mod) x -= mod;
        return *this;
    }

    mint& operator-=(const mint a) {
        if((x -= mod-a.x) >= mod) x -= mod;
        return *this;
    }

    mint& operator*=(const mint a) {
        x = (x * a.x) % mod;
        return *this;
    }

    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
};

mint dp[100005][13];

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

  int n;
  cin >> n;

  vector<long> d(n+1);
  fillLong(d, n);

  d[n] = 0;
  sortv(d);

  int cnts[37];
  rep(i, 37) {
    cnts[i] = 0;
  }

  int isPlus = true;
  rep(i, n+1) {
    if (isPlus) {
      cnts[12 + d[i]]++;
    } else {
      cnts[12 - d[i]]++;
      cnts[36 - d[i]]++;
    }
    isPlus = !isPlus;
  }

  int res = 12;

  rep(i, 37) {
    if(cnts[i] >= 2) res = 0;
    if(cnts[i] == 0) continue;
    for(int j = i+1; j < 37; j++) {
      if(cnts[j] >= 1) {
        res = min(res, j-i);
        break;
      }
    }
  }

  cout << res << endl;
}


Measured memory_bytes: 10496
import heapq
import numpy as np

H, W = [int(x) for x in input().split()]
maze = np.zeros((H, W))

for i in range(H):
    for j, way in enumerate(input()):
        if way == '.':
            maze[i, j] = 1
        else:
            maze[i, j] = 0

able_list = []

for i in range(H):
    for j in range(W):
        able = []
        if maze[i,j] == 1:
            if 0 <= i-1 < H:
                if maze[i-1, j] == 1:
                    able.append([(i-1) * W + j, 1])
            if 0 <= j-1 < W:
                if maze[i, j-1] == 1:
                    able.append([i * W + j - 1, 1])
            if 0 <= j+1 < W:
                if maze[i, j+1] == 1:
                    able.append([i* W + j + 1, 1])
            if 0 <= i+1 < H:
                if maze[i+1, j] == 1:
                    able.append([(i+1)*W + j, 1])
        able_list.append(able)



def Dijkstra(list_adjlist, initnode):
    # list_Dを初期化
    list_D = [-1] * len(list_adjlist)
    # 始点の距離=0
    list_D[initnode] = 0
    # list_Tを初期化
    list_T = [-1] * len(list_adjlist)
    # 最短経路・距離が確定している点のリスト
    list_check = [False] * len(list_adjlist)
    # ヒープの初期化：暫定最短距離と点の名前をペアにしたリストをヒープに格納する
    list_S = []
    heapq.heappush(list_S, (list_D[initnode], initnode))
    # ヒープが空になるまで続ける
    while(len(list_S)):
        # ヒープから暫定最短距離が小さい点を取り出す
        pair_w_node = heapq.heappop(list_S)
        if list_check[pair_w_node[1]] is False:
            list_check[pair_w_node[1]] = True
            # 点pair_w_node[1]の各隣接点について調べる
            for neighbor in list_adjlist[pair_w_node[1]]:
                if list_D[neighbor[0]] == -1 or list_D[neighbor[0]] > list_D[pair_w_node[1]] + neighbor[1]:
                    list_D[neighbor[0]] = list_D[pair_w_node[1]] + neighbor[1]
                    list_T[neighbor[0]] = pair_w_node[1]
                    heapq.heappush(list_S, (list_D[neighbor[0]], neighbor[0]))
    return list_D, list_T

ans = 0
for i in range(H):
    for j in range(W):
        if maze[i, j] == 1:
            list_D, list_T = Dijkstra(able_list, i*W + j)
            if ans < max(list_D):
                ans = max(list_D)
print(ans)

Measured memory_bytes: 12476
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
int H, W;
string S[2005];
 
int U[2005][2005];
int D[2005][2005];
int L[2005][2005];
int R[2005][2005];
 
int main() {
    ios_base::sync_with_stdio(false);
    cin >> H >> W;
    for(int i = 0; i < H; i++)
        cin >> S[i];
 
 
    for(int i = 0; i < H; i++) {
        int cnt = 0;
        for(int j = 0; j < W; j++) {
            cnt = S[i][j] == '.' ? cnt + 1 : 0;
            L[i][j] = cnt;
        }
    }
 
    for(int i = 0; i < H; i++) {
        int cnt = 0;
        for(int j = W - 1; j >= 0; j--) {
            cnt = S[i][j] == '.' ? cnt + 1 : 0;
            R[i][j] = cnt;
        }
    }
 
    for(int i = 0; i < W; i++) {
        int cnt = 0;
        for(int j = 0; j < H; j++) {
            cnt = S[j][i] == '.' ? cnt + 1 : 0;
            U[j][i] = cnt;
        }
    }
 
    for(int i = 0; i < W; i++) {
        int cnt = 0;
        for(int j = H - 1; j >= 0; j--) {
            cnt = S[j][i] == '.' ? cnt + 1 : 0;
            D[j][i] = cnt;
        }
    }
    int ans = 0;
    for(int i = 0; i < H; i++)
        for(int j = 0; j < W; j++)
            ans = max(ans, L[i][j] + R[i][j] + D[i][j] + U[i][j] - 3);
    cout << ans;
}


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

int SV[200001] = {0};
 
int main(void){
    int n, num;
    cin >> n;
    for(int i = 0; i < n-1; i++){
        cin >> num;
        SV[num-1]++;
    }
    
    for(int i = 0; i < n; i++) cout << SV[i] << endl;
    
    return 0;
}

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

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef long double ld;

const ll mod = (ll)1e9 + 7;
const ll mxN = 200200;


void solve() {
	ll a,b,c;
	cin>>a>>b>>c;
	if((3*max({a,b,c})-(a+b+c))&1^1)
		cout<<(3*max({a,b,c})-(a+b+c))/2;
	else 
		cout<<(3*max({a+1,b+1,c+1})-(a+b+c))/2;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(20);
	cout << fixed;
//	ll t;cin>>t;while(t--)
	solve();

}


Measured memory_bytes: 256
fn main() {
    let mode = "a";
    if mode == "a" {
        a::solve();
    }
}

mod a {
    use std;
    use std::io::Read;

    pub fn solve() {
        let mut buf = String::new();
        std::io::stdin().read_to_string(&mut buf).unwrap();
        let mut text = buf.split_whitespace();
        let a = text.next().unwrap().parse().unwrap();
        let b = text.next().unwrap().parse().unwrap();
        let c = text.next().unwrap().parse().unwrap();

        let res = calc(a, b, c);
        println!("{}", res);
    }

    fn calc(a: i32, b: i32, c: i32) -> i32 {
        let used = std::cmp::min(a - b, c);
        c - used
    }

    #[cfg(test)]
    mod tests {
        #[test]
        fn test1() {}
    }

}


Measured memory_bytes: 4352
// why am I so weak
#include<bits/stdc++.h>
using namespace std;
#define _              ios_base::sync_with_stdio(0);cin.tie(0);
#define pb             emplace_back
#define mp             make_pair
#define F              first
#define S              second
#define rep(i, x)      for (__typeof(x) i = 0; i < x; i++)
#define repp(i, x, y)  for (__typeof(x) i = x; i < y; i++)
#define all(a)         (a).begin(),(a).end()
#define sz(x)          (int)x.size()
#define endl           '\n'
#define DB(x)          cerr << #x << " is " << x << endl;
#define TEST(T)        int T; cin >> T; rep(_i, T)
#define MOD            1000000007
typedef long long          ll;
typedef vector<int>        vi;
typedef vector<ll>         vl;
typedef pair<int, int>    pii;
typedef pair<ll, ll>      pll;
typedef vector<pii>       vii;
typedef vector<pll>       vll;
typedef set<int>           si;

int main(){ _
    string s; cin >> s;
    int a, z;
    rep(i, s.size()){
        if (s[i] == 'A') {a=i; break;}
    }
    for(int i=s.size()-1;i>=0;i--){
        if (s[i] == 'Z') {z=i; break;}
    }
    cout << z-a+1 << endl;
}

Measured memory_bytes: 720
n = int(input())
con = [-1] * n
g = [[] for i in range(n)]
for i in range(n-1):
  u,v,w = map(int,input().split())
  u-=1;v-=1;w%=2
  g[u].append([v,w])
  g[v].append([u,w])
con[0] = 0
stack = [0]
while stack:
  cur = stack.pop()
  for i,j in g[cur]:
    if con[i] == -1:
      con[i] = con[cur] + j
      stack.append(i)
for i in range(n):
  print('01'[con[i]%2::2])

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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define MIN(c) (*min_element(ALL(c))) 
#define MAX(c) (*max_element(ALL(c)))
#define ACC(c) (accumulate(ALL(c), 0))
#define MP(a, b) (make_pair((a), (b)))
#define ENDL "\n"
#define PRINT(x) cout << (x) << ENDL

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int in(int& a) {return scanf("%d", &a);}
inline void out(int n) {printf("%d\n", n);}
template<typename T> inline void swap(T& a, T& b) {T tmp = a; a = b; b = tmp;}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};


int N;
int a[300000];
ll A[100001], B[100001];
priority_queue<int, vector<int>, greater<int> > L;
priority_queue<int, vector<int>, less<int> > R;

signed main(){
    in(N);
    REP(i, 3 * N) in(a[i]);
    REP(i, N){
        L.push(a[i]);
    }
    REP(i, N){
        R.push(a[i + 2 * N]);
    }
    A[0] = accumulate(a, a + N, 0LL);
    B[N] = accumulate(a + 2 * N, a + 3 * N, 0LL);
    REP(i, N){
        L.push(a[i + N]);
        A[i + 1] += A[i] + a[i + N] - L.top();
        L.pop();
    }
    REP(i, N){
        R.push(a[2 * N - 1 - i]);
        B[N - i - 1] += B[N - i] + a[2 * N - 1 - i] - R.top();
        R.pop();
    }
    ll m = A[0] - B[0];
    FOR(i, 1, N + 1) m = max(m, A[i] - B[i]);
    PRINT(m);
    return 0;
}

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

int main() {
    string s; cin >> s;
    int ans = 0;
    Int sum_w = 0;
    Int sum = 0;
    for(int i = 0; i < s.size(); i++) {
        if (s[i] == 'W') {
            sum_w++;
            sum += (Int)i;
        }
    }
    cout << sum - (sum_w*(sum_w-1)/2) << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdlib>
#include <string>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
	int n, m, x;
	int a[101];
	int c1 = 0;
	int c2 = 0;
	cin >> n >> m >> x;
	for(int i=0;i<m;i++) cin >> a[i];
	
	for (int i = x; i != 0; i--) {
		for (int j = 0; j < m; j++) {
			if (i == a[j]) c1++;
		}
	}

	for (int i = x; i != n; i++) {
		for (int j = 0; j < m; j++) {
			if (i == a[j]) c2++;
		}
	}
	cout << min(c1, c2 ) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define sc scanf
using namespace std;
char c;
int main(){
	c=getchar();
	if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u')cout<<"vowel\n";
	else cout<<"consonant\n";
	return 0;
} 

Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
# import math
# from string import ascii_lowercase, ascii_upper_case, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4 (previous contest @AtCoder)


def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79...e+308
    # inf = 2 ** 64 - 1               # (for fast JIT compile in PyPy) 1.84...e+19
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    n, m, x, y = mi()
    X = lmi()
    Y = lmi()
    if max(X) < min(Y):
        for p in range(max(X) + 1, min(Y) + 1):
            if x < p <= y:
                print('No War')
                exit()
    print('War')

if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; ++i)
typedef long long ll;
const ll MOD = 1e9+7;

ll fact(ll n){
    ll ret = 1LL;
    for(ll i= 1; i <= n; ++i) ret = ret*i%MOD;
    return ret;
}

int main(){
    int n,m; cin >> n >> m;
    if(abs(n-m)>1){
        cout << 0 << endl;
        return 0;
    }
    if(n == m){
        cout << 2*fact(n)%MOD*fact(n)%MOD;
    }else{
        cout << fact(n)*fact(m)%MOD;
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <string>
using namespace std;

int num[10] = {0, 5, 6, 6, 6, 6, 6, 8, 6, 8};
char c[10][10] = {{},
			  {' ','\'',',','.','!','?'},
			  {' ','a','b','c','A','B','C'},
			  {' ','d','e','f','D','E','F'},
			  {' ','g','h','i','G','H','I'},
			  {' ','j','k','l','J','K','L'},
			  {' ','m','n','o','M','N','O'},
			  {' ','p','q','r','s','P','Q','R','S'},
			  {' ','t','u','v','T','U','V'},
			  {' ','w','x','y','z','W','X','Y','Z'}};

int main() {
	char s[10010];
	while (scanf("%s", s) != EOF) {
		int n = strlen(s);
		for (int i = 0; i < n; ++i) {
			int j = i + 1;
			while (j < n && s[j] == s[i]) ++j;
			int cnt = j - i;
			//printf("%d\n", cnt);
			if (s[i] == '0') {
				while (cnt > 1) {printf(" ");cnt--;}
			}
			else {
				int m = num[s[i] - '0']; 
				cnt %= m;
				if (cnt == 0) cnt = m;
				printf("%c", c[s[i]-'0'][cnt]);
 			}
 			i = j - 1;
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 0
package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b, c, d float64
	fmt.Scan(&a, &b, &c, &d)
	direct := math.Abs(a-c) <= d
	indirect := math.Abs(a-b) <= d && math.Abs(b-c) <= d
	if direct || indirect {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#include <time.h>
#define ll long long
#define LINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
#define PI 3.14159265
#define RAND (rand()*rand())
using namespace std;
const int MAX = 1e5 + 10; //N
const ll MOD = 1e9 + 7;
int N, M, K, Q;
ll pos[MAX], neg[MAX];

int main()
{
	int i, j, posn, negn;
	ll x;
	scanf("%d%d", &N, &K);
	posn = negn = 0;
	for (i = 1; i <= N; ++i) {
		scanf("%lld", &x);
		if (x >= 0) {
			pos[++posn] = x;
		}
		else {
			neg[++negn] = -x;
		}
	}
	sort(neg + 1, neg + 1 + negn);
	int l, r;
	l = r = 0;
	ll mini = LINF;
	for (i = 1; i <= K; ++i) {
		if (r <= posn && K - r <= negn) {
			mini = min(mini, 2LL * pos[r] + neg[K - r]);
		}
		if (l <= negn && K - l <= posn) {
			mini = min(mini, 2LL * neg[l] + pos[K - l]);

		}
		l++, r++;
	}
	printf("%lld", mini);


}

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

int main(){
    int N;
    long a[200005];
    long long sumleft = 0;
    long long sumright = 0;
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> a[i];
        sumright += a[i];
    }
    long long ans = 1e18;
    for(int i=0;i<N-1;i++){
        sumleft += a[i];
        sumright -= a[i];
        ans = min(ans, abs(sumleft - sumright));
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int N, A, B;
  cin>>N>>A>>B;

  int de;
  de=N*A;
  if(de<=B){
    cout<<de<<endl;
  }
  else{
    cout<<B<<endl;
  }
  return 0;
}

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

using namespace std;
typedef long long ll;


ll ans,mx,mn=1e8,sum,cnt;

int main(){
	ll a,b;
	cin>>a>>b;
	if(a <= 0 && b >= 0) cout<<"Zero";
	else if(a > 0 && b> 0) cout<<"Positive";
	else if(a==b) cout<<"Positive";
	else if(((b-a)+1)%2==0) cout<<"Positive";
	else cout<<"Negative";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }

#define ALL(a) (a).begin(), (a).end()
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define rep(i, n) FOR(i, 0, n)
#define repi(i, n) FOR(i, 1, n + 1)
#define pp(v) cerr << #v "=" << (v) << endl;
#define ppa(v) cerr << "- " << #v << endl; rep(i,v.size()) cerr << #v << "[" << i << "] = " << v[i] << endl;
#define div_ceil(a,b) ((a) + ((b) - 1)) / (b)
#define UNIQUE(v) v.erase( unique(ALL(v)), v.end() );
#define INF 0x3f3f3f3f
#define LLINF 1000111000111000111LL
#define MOD 1000000007
#define TIME system("date +%M:%S.%N")
#define LBi(a,b) lower_bound(ALL(a),b)-a.begin()
#define LBr(a,b) a.end()-lower_bound(ALL(a),b)
using Graph = vector<vector<int>>;
using ll = long long;
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

signed main() {
  ll n,m;cin>>n>>m;
  vector<ll> a(n);cin>>a;
  sort(ALL(a));
  // pp(a);
  vector<ll> cs(n+1);rep(i,n) cs[i+1]=cs[i]+a[i];
  ll ok = 0, ng = 1e12;
  ll ans = 0, cnt = 0;
  while (ng - ok > 1) {
    ll mid = (ok + ng) / 2;
    ans = 0; cnt = 0;
    rep(i,n) {
      auto itr = lower_bound(ALL(a), mid - a[i]);
      int j = itr - a.begin();
      int k = a.end() - itr;
      cnt += k;
      ans += cs[n] - cs[j] + k * a[i];
    }
    (cnt >= m ? ok : ng) = mid;
  }
  cout << ans - (cnt - m) * ok << endl;
}


Measured memory_bytes: 1792
def main():
    n = int(input())
    a = [list(map(int, input().split())) for _ in range(n)]
    dp = [[0] * 3 for _ in range(n)]
    dp[0] = a[0]
    for i in range(1, n):
        dp[i][0] = max(dp[i - 1][1] + a[i][0], dp[i - 1][2] + a[i][0])
        dp[i][1] = max(dp[i - 1][0] + a[i][1], dp[i - 1][2] + a[i][1])
        dp[i][2] = max(dp[i - 1][0] + a[i][2], dp[i - 1][1] + a[i][2])
    print(max(dp[n - 1]))

if __name__ == '__main__':
    main()


Measured memory_bytes: 47344
#include<stdio.h>
int main(){
	int a;
	int b;
	scanf("%d %d", &a, &b);
	if (a<b){
		printf("a < b\n");
	}
	else if (a>b){
		printf("a > b\n");
	}
	else{
		printf("a == b\n");
	}
	return 0;
}

Measured memory_bytes: 1012
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)

int main(void){
    set<int> a;
    int n;
    rep(_,3){
        cin >> n;
        a.insert(n);
    }
    if(a.size() == 2){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
int main() 
{
    long long a,b,c,d;
    scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
    if(a*b>c*d)
    {
     printf("%lld\n",a*b);
    }
    else if(a*b<c*d)
    {
     printf("%lld\n",c*d);
    }
    else
    {
     printf("%lld\n",a*b);
    }
	return 0;
}

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

int calc(int x){
    int ret = 0;
    while(x % 100 == 0){
        x /= 100;
        ++ ret;
    }
    return ret;
}

int main(){
    int d, n;
    cin >> d >> n;
    int cnt = 0, val = 0;
    while(cnt < n){
        ++ val;
        if(calc(val) == d) ++cnt;
    }
    cout << val << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#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
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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; }



int main(int argc, char const *argv[]) {
  string s;
  int n,k;
  cin >> n >> s >> k;
  rep(i,n){
    if(s[i]!=s[k-1]) s[i]='*';
  }
  cout << s << endl;
  return 0;
}


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

Measured memory_bytes: 3624
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int h, w, n, sr, sc; cin >> h >> w >> n >> sr >> sc; --sr; --sc;
  string s, t; cin >> s >> t;
  int sy = 0, sx = 0, gy = h - 1, gx = w - 1;
  for (int i = n - 1; i >= 0; --i) {
    if (t[i] == 'L') gx = min(gx + 1, w - 1);
    else if (t[i] == 'R') sx = max(sx - 1, 0);
    else if (t[i] == 'U') gy = min(gy + 1, h - 1);
    else sy = max(sy - 1, 0);
    if (s[i] == 'L') ++sx;
    else if (s[i] == 'R') --gx;
    else if (s[i] == 'U') ++sy;
    else --gy;
    if (sx >= w || gx < 0 || sy >= h || gy < 0) {
      cout << "NO\n";
      return 0;
    }
  }
  cout << (sy <= sr && sr <= gy && sx <= sc && sc <= gx ? "YES\n" : "NO\n");
  return 0;
}


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

main :: IO ()
main = print =<< solve . map read . words <$> getLine

solve :: [Integer] -> Integer
solve [n, p] = product . map (\(x, len) -> (x ^ (len`div`n))) . filter ((>=n) . snd) . pf $ p 

pf :: Integer -> [(Integer, Integer)]
pf n = map (\xs -> (head xs, (fromIntegral.length) xs)) . group $ pf' n (2:[3,5..(truncate.sqrt.fromIntegral $ n)])
  where
   pf' 1 _ = []
   pf' n [] = [n]
   pf' n (x:xs) = if (n `mod` x) == 0
     then x : pf' (n `div` x) (x:xs)
     else pf' n xs


Measured memory_bytes: 1020
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int a,b,k;
    cin >> a >> b >> k;
    bool flag = true;
    for(int i=1;i<=k;i++){
        if(flag == true){
        if(a%2 != 0){
            b = b +(a-1)/2;
            a = (a-1)/2;
        }else{
            b =  b +a/2;
            a = a/2;
        }
        flag = false;
        }else{
        if(b%2 != 0){
            a = a +(b-1)/2;
            b = (b-1)/2;
        }else{
            a =  a +b/2;
            b = b/2;
        }  
        flag = true;
        }
    }
    cout << a << " " << b << endl;
    return 0;
}

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

int main(){
    string s,t;
    cin>>s>>t;int ans=INT_MAX;int n=s.length();int m = t.length();
    for(int i=0;i<=s.length()-t.length();++i){
        int count=0;
        for(int j=0;j<t.length();++j){
            if(s[i+j]==t[j])count++;
        }
        ans = min(ans,m-count);
    }
    cout<<ans;











    return 0;
}

Measured memory_bytes: 3628
import java.util.*;

public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		StringBuilder[] s = new StringBuilder[100];
		StringBuilder ans = new StringBuilder();
		int i, j;
		int n = sc.nextInt();
		int l = sc.nextInt();
		
		for(i = 0; i < 100; i++){
			s[i] = new StringBuilder(100);
		}
		
		for(i = 0; i < n; i++){
			s[i].append(sc.next()); 
		}
		
		for(i = 0; i < n - 1; i++){
			for(j = n - 1; j > i; j--){
				String str = new String(s[j - 1].toString());
				String str2 = new String(s[j].toString());
				
				if(str.compareTo(str2) > 0){
					s[j - 1].delete(0, l);
					s[j - 1].append(str2);
					s[j].delete(0, l);
					s[j].append(str);
				}
			}
		}
		
		for(i = 0; i < n; i++){
			ans.append(s[i].toString());
		}
		
		System.out.println(ans.toString());
	}
}

Measured memory_bytes: 16608
import math
def nCr(n,r):
    return math.factorial(n) / math.factorial(r) / math.factorial(n-r)

n,p = map(int, input().split())
list_a = list((map(int, input().split())))
for i in range(0,n):
    list_a[i] = list_a[i] % 2
odd = list_a.count(1)
even = list_a.count(0)
even_ans = int(2**even)
odd_ans = 0
if p == 0:
    for i in range(0,odd+1):
        if i % 2 == 0:
            odd_ans += nCr(odd, i)
else:
    for i in range(0,odd+1):
        if i % 2 == 1:
            odd_ans += nCr(odd, i)

print(int(even_ans * odd_ans))


Measured memory_bytes: 3064
#pragma GCC optimize ("O2")
#include<bits/stdc++.h>
#include <queue>
#include <cstring>

#define mp make_pair
#define pb push_back
#define p push

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define ll long long

#define getI(a) scanf("%d",&a)
#define getII(a, b) scanf("%d%d",&a,&b)
#define getIII(a, b, c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a, b) scanf("%lld%lld",&a,&b)
#define getLLL(a, b, c) scanf("%lld%lld%lld",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define BEND2(c) (c).rbegin(),(c).rend()
#define fi first
#define se second
#define pi 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfi(a) printf("%d",a);
#define pfii(a, b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a, b) printf("%lld%lld",a,b);
#define pfd(a) printf("%lf",a);
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);
#define endl "\n"
#define sag (sol|1)
//#define sol (root<<1)
#define ort (bas+son)/2
#define SIZE  ( int)(1e9 + 7)
#define MAXN (ll) ((1e5+5))
#define K 25
#define  ALPHABET_SIZE  26
#define N (int)(1e5+10)
#define INF (ll )1e18
#define int ll
using namespace std;

typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<long long> vl;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair <ll, ll> pll;
typedef vector<vi> graph ;

signed main(){
   ll n ;
cin >> n;
ll m ;
cin >>m;
if(m > n){
    for (int i = 0; i <m ; ++i) {
        cout<<n;
    }
}else{
    for (int i = 0; i <n ; ++i) {
        cout << m;
    }
}
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;


int gcd2(int a, int b){
  if(a < b)
    return gcd2(b, a);
  int r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int gcd3(int a,int b,int c){
  int tmp = gcd2(a,b);
  int ans = gcd2(tmp,c);
  return ans;
}

int main(void){
  int K;
  cin >> K;
  int sum = 0;
  for(int i=0;i<K;i++){
    for(int j=0;j<K;j++){
      for(int k=0;k<K;k++){
	sum = sum + gcd3(i+1,j+1,k+1);
      }
    }
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
	private Scanner sc;
	
	public static void main(String[] args) {
		new Main();
	}
	
	public Main() {
		sc = new Scanner(System.in);
		
		int[] g = new int[4];
		for (int i = 0; i < g.length; i++) {
			g[i] = 0;
		}
		
		while (sc.hasNextLine()) {
			String[] nico = sc.nextLine().split(",");
			
			switch (nico[1]) {
			case "A":
				g[0]++;
				break;
			case "B":
				g[1]++;
				break;
			case "AB":
				g[2]++;
				break;
			case "O":
				g[3]++;
				break;
			}
		}
		
		for (int i = 0; i < g.length; i++) {
			System.out.println(g[i]);
		}
	}
}

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

int main(){
    int m,f,r;
    int sum;
    while(true){
        cin >> m >> f >> r;
        sum = m+f;
        if(m == -1 && f == -1 && r == -1) break;
        else if(m >= 0 && f >= 0){
            if(sum>=80) cout << "A" << endl;
            else if(sum>=65) cout << "B" << endl;
            else if(sum>=50) cout << "C" << endl;
            else if(sum>=30){
                if(r>=50)cout << "C" << endl;
                if(r<50)cout << "D" << endl;
            }
            else if(sum<30) cout << "F" << endl;
        }
        if(m == -1 || f == -1) cout << "F" << endl;
    
    }
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)

int main()
{
    int N;
    int H[100010];
    ll dp[100010];
    cin >> N;
    rep(i,N)
    {
        cin >> H[i];
        dp[i] = 10000000000;
    }
    dp[0] = 0;
    rep(i, N)
    {
        if (i+1<N) dp[i+1] = min(dp[i+1], dp[i]+abs(H[i+1]-H[i]));
        if (i+2<N) dp[i+2] = min(dp[i+2], dp[i]+abs(H[i+2]-H[i]));
    }
    cout << dp[N-1] << endl;

}

Measured memory_bytes: 1408
import collections
N = int(input())
S = [str(input()) for i in range(N)]
li = collections.Counter(S)
MAX = li.most_common()[0][1]
li = li.most_common()
li.sort(key=lambda x:x[0])

for i in range(len(li)):
    if li[i][1]==MAX:
        print(li[i][0])


Measured memory_bytes: 45084
#include<bits/stdc++.h>
#define mx 100000
#define pb push_back
#define siz(v) v.size();
#define print(a) printf("%d",a)
#define sc1(a) scanf("%d",&a)
using namespace std;

typedef unsigned long  ull;
typedef long long int lli;

int main()
{
 
	
	lli x,y;
	cin>>x>>y;
	if (x==0 || x==y)
		cout<<"0\n";
	else if (x<y)
	{
		if (x*2>y)
			cout<<(y-x)<<endl;
		else
			cout<<x<<endl;
	}
		
	else 
	{
		if (x%y==0)
			cout<<"0\n";
		else
		{
			lli mod=(x%y);
			cout<<y-mod<<endl;
		}
	}

	
 return 0;
 }
  


Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto nx = readln.split.to!(int[]);
    auto N = nx[0];
    auto X = nx[1];
    auto xs = readln.split.to!(int[]);

    auto d = xs[0];
    X = abs(X - d);
    foreach (x; xs[1..$]) {
        X = gcd(X, abs(x - d));
    }

    writeln(X);
}

Measured memory_bytes: 4220
#define MYDEBUG
//
#include <bits/stdc++.h>
#ifdef MYDEBUG
#define dbp(x) cout<<#x<<": "<<x<<endl
#define dbp2(x,y) cout<<#x<<","<<#y<<": "<<x<<","<<y<<endl
#define dbp3(x,y,z) cout<<#x<<","<<#y<<","<<#z<<": "<<x<<","<<y<<","<<z<<endl
#define dbp4(w,x,y,z) cout<<#w<<","<<#x<<","<<#y<<","<<#z<<": "<<w<<","<<x<<","<<y<<","<<z<<endl
#define ifcin(x) std::ifstream cin(x)
#else
#define dbp(x)
#define dbp2(x,y)
#define dbp3(x,y,z)
#define dbp4(w,x,y,z)
#define ifcin(x)
#endif
#define ll long long
#define all(x) x.begin(), x.end()
#define rep(i, from, to) for(int i=from; i<to; ++i)
#define REP(i, from, to) for(int i=from; i<=to; ++i)
using namespace std;

typedef struct Node {
  int parent, left, right;
} Node;

static const int NMAX = 100000;
static const int NIL = -1;
Node T[NMAX];
int n, D[NMAX];
static const string ROOT = "root";
static const string INTERNAL = "internal node";
static const string LEAF = "leaf";

//頂点番号idに深さdepthを記録
void setDepth(int id, int depth) {
  D[id] = depth;
  if (T[id].right != NIL) {
    setDepth(T[id].right, depth);
  }
  if (T[id].left != NIL) {
    setDepth(T[id].left, depth + 1);
  }
}

//頂点番号idのすべての子を表示
void printChildren(int id) {
  cout << "[";
  int cid = T[id].left;
  while (cid != NIL) {
    if (cid != T[id].left) {
      cout << ", ";
    }
    cout << cid;
    cid = T[cid].right;
  }
  cout << "]";
}

void printNode(int id) {
  if (id == NIL) {
    return;
  }
  printf("node %d: parent = %d, depth = %d, ", id, T[id].parent, D[id]);
  string nodeType = INTERNAL;
  if (T[id].parent == NIL) {
    nodeType = ROOT;
  } else if (T[id].left == NIL) {
    nodeType = LEAF;
  }
  printf("%s, ", nodeType.c_str());
  printChildren(id);
  printf("\n");
}

int main() {
  cin >> n;
  rep(i,0,NMAX)
  {
    T[i].parent = T[i].left = T[i].right = NIL;
    D[i] = 0;
  }
  rep(i,0,n)
  {
    int id, k;
    cin >> id >> k;
    int lastChild = NIL;
    rep(j,0,k)
    {
      int c;
      cin >> c;
      T[c].parent = id;
      if (T[id].left == NIL) {
        T[id].left = c;
      }
      if (lastChild != NIL) {
        T[lastChild].right = c;
      }
      lastChild = c;
    }
  }
  int root = 0;
  rep(i,1,n)
  {
    if (T[i].parent == NIL) {
      root = i; //頂点番号0が根とは限らない
    }
  }
  setDepth(root, 0);
  rep(i,0,n)
  {
    printNode(i);
  }
}



Measured memory_bytes: 7908
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
using namespace std;
 
const int nom = 1000000007;
long long ans = 0, f[100005];
int n, m;
 
int main()
{
         scanf("%d%d", &n, &m);
         if (abs(n - m) > 1) { printf("0"); return 0; }
         f[0] = 1;
         for (int i = 1; i <= max(n, m); i++)
                f[i] = (f[i - 1] * i) % nom;
         ans = (f[n] * f[m]) % nom;
         if (n == m) ans = (ans * 2) % nom;
         printf("%lld", ans);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define mod 998244353
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fll
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
int main()
{
	int h,a;
	cin>>h>>a;
	cout<<(h+a-1)/a<<endl;
	return 0;
}


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll h,a;
  cin>>h>>a;

  ll ans = h/a;
  if(h%a!=0)
    ans++;
  cout<<ans<<endl;

}


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

template <typename tn> void read (tn & a) {
	tn x = 0, f = 1; char c = getchar();
	while (c < '0' || c > '9'){ if (c == '-') f = -1; c = getchar(); }
	while (c >= '0' && c <= '9'){ x = x * 10 + c - '0'; c = getchar(); }
	a = f == 1 ? x : -x;
}

const int MAXN = 1e5 + 10;

int fa[MAXN],x[MAXN];
bool k[MAXN],s[MAXN];
int n, m;
ll i, l, r, t, cnt;
ll ans;

int find (int xx) {
    if (!fa[xx]) return xx;
    int t = find(fa[xx]);
    x[xx] ^= x[fa[xx]];
    return fa[xx] = t;
}

int main(){
	read(n);
	read(m);
    rep(i, 1, m) {
    	int u, v;
    	read(u);
    	read(v);

        k[u] = 1;
		k[v] = 1;

        l = find(u); 
		r = find(v);
        if (l < r) {
            swap(l,r);
            swap(u,v);
        }
        if (l == r && x[u] == x[v]) {
			s[l] = 1;
		}
        if (l == r) continue;
        s[r] |= s[l];
        fa[l] = r;
        x[l] = x[u] ^ x[v] ^ 1;
    }
    rep(i, 1, n) if (!k[i]) {
		cnt++;
	}
    ans = (ll)cnt * (n - cnt) * 2 + (ll)cnt * cnt;
    cnt = 0;
    rep(i, 1, n) if (k[i]&&!fa[i]) {
		cnt++;
	}
    ans += (ll)cnt * cnt;
    cnt = 0;
    rep(i, 1, n) if (k[i] && !fa[i] && !s[i]) cnt++;
    rep(i, 1, n) if (k[i] && !fa[i] && !s[i]) ans += (ll)cnt;
	cout << ans << "\n";
	return 0;
}

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

int main(){
    int x;
    cin>>x;
    
    int h = x / 3600;
    
    int m = (x / 60 ) % 60;
    
    int s = x % 60;
    
    cout<<h<<":"<<m<<":"<<s<<endl;
    
    return 0;
    
}


Measured memory_bytes: 3104
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

S = S()
if 'RRR' in S:
    print(3)
elif 'RR' in S:
    print(2)
elif 'R' in S:
    print(1)
else:
    print(0)

Measured memory_bytes: 68356
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <string>
#include <queue>

using namespace std;

int main() {
    int N;
    vector<int> X, Y;

    cin >> N;
    for(int i = 0; i < N; i++) {
        int t;
        cin >> t;
        X.push_back(t);
        Y.push_back(t);
    }

    sort(X.begin(), X.end());

    int a = X[N / 2 - 1], b = X[N / 2];

    for(int i = 0; i < N; i++) {
        if(Y[i] <= a) cout << b << endl;
        else cout << a << endl;
    }
}

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

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

    int N;
    cin >> N;

    vector<int> vi;
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        int p;
        cin >> p;
        vi.push_back(p);

        if (i >= 1)
        {
            if (vi[i - 1] == i)
            {
                swap(vi[i - 1], vi[i]);
                ans++;
            }
        }
    }
    if (vi[N-1] == N) ans++;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 892
def countInRangeUtil(pos, cnt, tight, num): 

	# Last position 
	if pos == len(num):
		if cnt == K: 
			return 1
		return 0
	if dp[pos][cnt][tight] != -1: 
		return dp[pos][cnt][tight] 

	ans = 0
	limit = 9 if tight else num[pos] 

	for dig in range(limit + 1): 
		currCnt = cnt 
		if dig != 0: 
			currCnt += 1

		currTight = tight 

		if dig < num[pos]: 
			currTight = 1

		# Next recursive call 
		ans += countInRangeUtil(pos + 1, currCnt, currTight, num) 

	dp[pos][cnt][tight] = ans 
	return dp[pos][cnt][tight] 
def countInRange(x): 
	global dp, K, M 

	num = [] 
	while x: 
		num.append(x % 10) 
		x //= 10

	num.reverse()
	dp = [[[-1, -1] for i in range(M)] for j in range(M)] 
	return countInRangeUtil(0, 0, 0, num) 


dp = [] 
M = 101
K = 0

L = 1
R = int(input())
K = int(input())
print(countInRange(R) - countInRange(L - 1)) 





Measured memory_bytes: 5236