akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

template <class T> void mini(T &l, T r) {l = min(l, r);}
template <class T> void maxi(T &l, T r) {l = max(l, r);}

//template <class T> using Tree = tree <T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

string to_string(string s) {
    return '"' + s + '"';
}

string to_string(bool a) {
    return a ? "T" : "F";
}

string to_string(const char* s) {
    return to_string((string) s);
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define X first
#define Y second

using ll = long long;
using ld = long double;

int n;
string s;

string get_seq(string s, int msk) {
	string ret = "";
	for (int i = 0; i < n; ++i) {
		if (msk >> i & 1) {
			ret += s[i];
		}
	}
	return ret;
}

map < pair <string, int>, int> get(string s, int fl) {
	map < pair <string, int>, int> mp;
	for (int msk = 0; msk < 1 << n; ++msk) {
		auto a = get_seq(s, msk);
		auto b = get_seq(s, ((1 << n) - 1) ^ msk);
		reverse(b.begin(), b.end());
		auto s = fl ? (a + b) : (b + a);
		auto t = __builtin_popcount(msk);
		if (!fl) {
			t = n - t;
		}
		mp[make_pair(s, t)] ++;
	}
	return mp;
}

ll solve() {
	ll ans = 0;
	auto mp = get(s.substr(0, n), 0);
	auto mp2 = get(s.substr(n, n), 1);

	debug(mp);
	debug(mp2);
	
	for (auto &kv : mp) {
		ans += 1ll * kv.Y * mp2[kv.X];
	}
	return ans;
}

void run() {
	cin >> n;
	cin >> s;
	cout << solve() << endl;
}

int main() {
    run();
    return 0;
}


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

#define FOR(i, a, b) for(long long int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;

int main(void) {
	while (1) {
		int m, mini, maxi;
		int sa = -1;
		int pos;
		int p[201] = {};

		cin >> m >> mini >> maxi;
		if (m == 0) {
			break;
		}
		FOR(i, 1, m) {
			cin >> p[i];
		}
		FOR(i, mini, maxi) {
			if (p[i] - p[i + 1] >= sa) {
				sa = p[i] - p[i + 1];
				pos = i;
			}
		}
		cout << pos << endl;
	}
}


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++) cin >> a[i];
  int ans = 0;
  while(true){
    for(int i = 0; i < n; i++){
      if(a[i] % 2 == 1){
        cout << ans << endl;
        return 0;
      }
    }
    for(int i = 0; i < n; i++){
      a[i] /= 2;
    }
    ans++;
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
n,m = gets.chomp.split().map(&:to_i)
s=[]
n.times do
  set = gets.chomp.split().map(&:to_i)
  s << set
end
s.sort! {|a,b| a[0]<=>b[0]}

cost=0
s.each do |pair|
  buy=[m,pair[1]].min
  m-=buy
  cost += buy*pair[0]
  break if m==0
end
puts cost


Measured memory_bytes: 10488
n = int(input())
fac = {}
for i in range(2,10**6):
  if n % i == 0:
    fac[i] = 0
    while n % i == 0:
      fac[i] += 1
      n //= i
if n != 1:
  fac[n] = 1
#print(fac)
jud = [1]
for i in range(10**6):
  jud.append(jud[-1]+i+2)
#print(jud)
ans = 0
for k in fac:
  num = fac[k]
  for i in range(10**6):
    if num >= jud[i]:
      ans += 1
    else:
      break
print(ans)

Measured memory_bytes: 141156
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())




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

	int q,h,s,d;
	int n;
	cin>>q>>h>>s>>d;
	cin>>n;

	h = min(h, q*2);
	s = min(s, h * 2);
	d = min(d, s * 2);

	long long ans = 0;
	ans += (long long)n/2 * d;
	n%=2;
	ans += n* s;
	cout<<ans<<endl;

	return 0;
}

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

int main() {
	string t;
	int s = 700;
	cin >> t;
	if (t[0] == 'o')s += 100;
	if (t[1] == 'o')s += 100;
	if (t[2] == 'o')s += 100;
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
	"strconv"
)

func main() {
	n := readi()
	a := make([]int, n+2)
	for i := 0; i < n; i++ {
		a[i+1] = readi()
	}

	tmp := 0
	for i := 1; i <= n+1; i++ {
		tmp = tmp + abs(a[i]-a[i-1])
	}

	for i := 1; i <= n; i++ {
		ans := tmp - (abs(a[i]-a[i-1]) + abs(a[i+1]-a[i]))
		ans = ans + abs(a[i+1]-a[i-1])
		fmt.Println(ans)
	}
}

/*-------------------utilities-------------------*/

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func chmin(x *int, y int) bool {
	if *x > y {
		*x = y
		return true
	}
	return false
}

func chmax(x *int, y int) bool {
	if *x < y {
		*x = y
		return true
	}
	return false
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return (a * b) / gcd(a, b)
}

func permutations(arr []int) [][]int {
	var helper func([]int, int)
	res := [][]int{}

	helper = func(arr []int, n int) {
		if n == 1 {
			tmp := make([]int, len(arr))
			copy(tmp, arr)
			res = append(res, tmp)
		} else {
			for i := 0; i < n; i++ {
				helper(arr, n-1)
				if n%2 == 1 {
					tmp := arr[i]
					arr[i] = arr[n-1]
					arr[n-1] = tmp
				} else {
					tmp := arr[0]
					arr[0] = arr[n-1]
					arr[n-1] = tmp
				}
			}
		}
	}
	helper(arr, len(arr))
	return res
}

func isPrime(n int) bool {
	if n == 1 {
		return false
	}
	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			return false
		}
	}
	return true
}

func divisor(n int) (res []int) {
	for i := 1; i*i <= n; i++ {
		if n%i == 0 {
			res = append(res, i)
			if i*i != n {
				res = append(res, n/i)
			}
		}
	}
	sort.Ints(res)
	return
}

// func searchInts(a []int, k int) int {
// 	return binarySearch(len(a), func(i int) bool {
// 		return a[i] >= k
// 	})
// }

func binarySearch(n int, f func(int) bool) int {
	i, j := 0, n
	for i < j {
		h := int(uint(i+j) >> 1)
		if !f(h) {
			i = h + 1
		} else {
			j = h
		}
	}
	return i
}

/*-------------------init-------------------*/

const (
	INF = 1000000000000000000
	MOD = 1e9 + 7
)

var (
	readString func() string
)

func init() {
	readString = newReadString(os.Stdin)
}

/*-------------------inputs-------------------*/

func readi() int {
	return int(readi64())
}

func readi64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readf() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read(){
	ll a=0,b=getchar(),c=1;
	while(!isdigit(b))c=b=='-'?-1:1,b=getchar();
	while(isdigit(b))a=a*10+b-'0',b=getchar();
	return a*c;
}
ll n,k,ans,h[200005];
int main(){
	n=read(),k=read();
	for(int i=0;i<n;i++)
		h[i]=read();
	sort(h,h+n);
	for(int i=0;i<n-k;i++)
		ans+=h[i];
	cout << ans;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define _CRT_SECURE_NO_WARNINGS
#define REP(i, n) for(LL i=0; i<(n); i++)
#define FOR(i, m, n) for(LL i=(m);i<(n);i++)
#define SZ(x) ((int)(x).size())
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define MP make_pair
#define PB push_back
#define INF INT_MAX

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	LL N, T;
	cin >> N >> T;
	vector<LL> t(N);
	REP(i, N)cin >> t[i];

	LL ans = 0;
	for (LL i = 1; i < N; i++) {
		if (t[i] - t[i - 1] < T)ans += t[i] - t[i - 1];
		else ans += T;
	}
	cout << ans + T << endl;
}

Measured memory_bytes: 1792
x1, y1, x2, y2 = list(map(int, input().split()))

diff_x = x2 - x1
diff_y = y2 - y1

x3 = x2 - diff_y
y3 = y2 + diff_x
x4 = x1 - diff_y
y4 = y1 + diff_x

print("{} {} {} {}".format(x3, y3, x4, y4))


Measured memory_bytes: 2940
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn parity(bit: u32, v: &Vec<u32>) -> u32 {
    v.iter().fold(0, |acc, x| acc ^ ((bit >> x) & 1))
}

fn main() {
    let n: u32 = read();
    let m: u32 = read();
    let mut vv = Vec::new();
    for _ in 0..m {
        let k: u32 = read();
        let v: Vec<u32> = (0..k).map(|_| read::<u32>() - 1).collect();
        vv.push(v);
    }
    let p: Vec<u32> = (0..m).map(|_| read()).collect();

    let ans = (0..1 << n).filter(|&i| {
        (0..m).all(|j| parity(i, &vv[j as usize]) == p[j as usize])
    }).count();

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define LL long long
using namespace std;

inline LL read() {
    char c = getchar(); LL ret = 0, f = 1;
    for (; c < '0' || c > '9'; f = c == '-'? -1: 1, c = getchar());
    for (; '0' <= c && c <= '9'; ret = ret * 10 + c - '0', c = getchar());
    return ret * f;
}

int main() {
    LL x = read(), len = 0, mn = 0;
    int dig[100];
    for (LL tmp = x; tmp; tmp /= 10) {
        dig[++len] = tmp % 10;
        mn += tmp % 10;
    }
    if (len > 1) {
        cout<<max(mn, dig[len] - 1 + (len - 1) * 9);
    } else {
        cout<<x;
    }
    return 0;
}

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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = (ll)998244353;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   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; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (b % 2 == 0) return (pow(a * a, b / 2, m) % m); else return (pow(a * a, b / 2) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

   ll dx[4]={1,0,-1,0};
   ll dy[4]={0,1,0,-1};
const ll MAX_N = 2000;
string S;
bool grid[MAX_N * 2 + 1][MAX_N * 2 + 1];
ll ans[MAX_N * 2 + 1][MAX_N * 2 + 1] = {};
int main(){
   cin >> S;
   ll n = S.size();
   REP(i, 2 * n + 1) REP(j, 2 * n + 1) grid[i][j] = true;
   ll red = 0, blue = 0;
   REP(i, n){
      if(S[i] == '0') red += 2;
      if(S[i] == '2') blue += 2;
      if(S[i] == '1'){red++; blue++;}
      REP(j, i + 2){
         if(j > red || (i + 1 - j) > blue) grid[j][i + 1 - j] = false;
      }
   }
   ans[0][0] = 1;
   REP(i, red + 1){
      REP(j, blue + 1){
         if(i > 0 && grid[i - 1][j]) ans[i][j] += ans[i-1][j];
         if(j > 0 && grid[i][j - 1]) ans[i][j] += ans[i][j-1];
         ans[i][j] %= MOD;
      }
   }
/*
   REP(i, red + 1){
      REP(j, blue + 1){
         printf("ans[%lld][%lld] = %lld ", i, j, ans[i][j]);
      }
      cout << endl;
   }
*/
   cout << ans[red][blue] << endl;
}


Measured memory_bytes: 139136
#include<stdio.h>
int max = 0;
int n, m, q;
int s[15];
int a[60],b[60],c[60],d[60];

void roop(int k,int l){
  int i,sum = 0;
  int j;
  
  if(k > n){
    return;
  }
  if(k == n){
    for(i = 0; i < q; i++){
      if(s[b[i] - 1] - s[a[i] - 1] == c[i]){
        sum += d[i];
      }
    }
    if(max < sum){
      max = sum;
    }
  }
  if(l > m){
    return;
  }
  roop(k, l + 1);
  s[k] = l;
  roop(k + 1, l);
  return;
}

int main(void){
  int i;
 
  scanf("%d%d%d",&n, &m, &q);
  for(i = 0; i < q; i++){
    scanf("%d%d%d%d",&a[i], &b[i], &c[i], &d[i]);
  }
  roop(0,1);
  printf("%d\n",max);
  return 0;
}

Measured memory_bytes: 1696
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef vector<ll>VI;
typedef pair<ll,ll>P;
#define VV(T) vector<vector<T>>
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define ALL(a)  (a).begin(),(a).end()
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=max(x,a)
#define chmin(x,a) x=min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX_6 1001001//6
#define MAX_7 10010010//7
#define SENTINEL 2000000000//9
const int MOD = 1000000007;
#define INF 1<<30
#define INFTY 1LL<<61
#define MAX_INT INT_MAX
#define Endl '\n'
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
template<class T> bool contain(const std::string& s, const T& v) {
   return s.find(v) != std::string::npos;
}
using Edge=pair<int,ll>;
using Graph=vector<vector<ll> >;//ll or Edge
//const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// sort_reverse -> greater<long long>()
// vector型から重複を削除 list.erase(unique(ALL(list)),list.end());
// g++ -o a a.cpp -Wall -lm -std=c++17
//push_back -> emplace_back
ll dp[55][3555][55];
//dp[i][s][k]:=最初のi個からk個選場合について, 総和をsにする物の数

int main(){
    int n,a;cin>>n>>a;
    VI x(n);
    rep(i,n)cin>>x[i];
    memset(dp,0,sizeof(dp));
    dp[0][0][0]=1;
    rep(i,n){
        for(int s=0;s<=n*a;s++){
            for(int k=0;k<=n;k++){
                dp[i+1][s][k]+=dp[i][s][k];
                dp[i+1][s+x[i]][k+1]+=dp[i][s][k];
            }
        }
    }
    ll res=0;
    for(int k=1;k<=n;k++)res+=dp[n][a*k][k];
    cout<<res<<endl;
}

Measured memory_bytes: 87632
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    int n; cin>>n;
    vector<ll> cnt(5, 0);
    for(int i=0; i<n; i++){
        string s; cin>>s;
        if(s[0] == 'M') cnt[0]++;
        if(s[0] == 'A') cnt[1]++;
        if(s[0] == 'R') cnt[2]++;
        if(s[0] == 'C') cnt[3]++;
        if(s[0] == 'H') cnt[4]++;
    }

    vector<int> v(5, 0);
    for(int i=2; i<5; i++) v[i] = 1;

    ll ans = 0;
    do{
        ll sum = 1;
        for(int i=0; i<5; i++){
            if(v[i]) sum *= cnt[i];
        }

        ans += sum;

    }while(next_permutation(v.begin(), v.end()));

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int dx[]={1,0,-1,0,1,-1,-1,1};
const int dy[]={0,1,0,-1,1,1,-1,-1};
const int INF = 1e9;
const long long LINF = 4*1e18;
const double EPS = 1e-8;
#define PB push_back
#define mk make_pair
#define fr first
#define sc second
#define ll long long
#define reps(i,j,k) for(int i = (j); i < (k); ++i)
#define rep(i,j) reps(i,0,j)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
typedef pair<int,int> Pii;
typedef vector<int> vi;
typedef pair<string, int> Psi;
typedef pair<ll, ll> Pll;
  
ll A[100001];
int way[100001];
  
vector<ll> points;
  
ll search(int idx,ll T){
    ll l = 0;
    ll r = points.size();
    while(l + 1 != r){
        int med = (l+r)/2;
        if(points[med] > A[idx]){
            r = med;
        }
        else{
            l = med;
        }
    }
  
    int s;
    ll c;
    if(way[idx] == 1){
        s = l + 1;
        c = 1;
    }
    else if(way[idx] == 2){
        s = l;
        c = -1;
    }
    if(T >= abs(A[idx]-points[s])){
        return points[s];
    }
    return A[idx]+c*T;
}
  
int main(){
    int N,Q;
    ll T;
    scanf("%d%lld%d",&N,&T,&Q);
    points.PB(-LINF);
    rep(i,N){
        scanf("%lld%d",&A[i],&way[i]);
        if(i > 0 && way[i-1] == 1 && way[i] == 2){
            points.PB(A[i-1]+(A[i]-A[i-1])/2);
        }
    }
  
    points.PB(LINF);
    rep(i,Q){
        int x;
        scanf("%d",&x);
        --x;
        printf("%lld\n",search(x,T));
    }
  
    return 0;
}

Measured memory_bytes: 4540
#include <bits/stdc++.h>
using namespace std;
#define sf(xx) scanf("%lld",&xx)
#define fast()              ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define input()             freopen("G:/daily practise/in0.txt","r",stdin)
#define output()            freopen("G:/daily practise/out0.txt","w",stdout)
#define maxn 1000001
bool p[maxn];
int q[maxn];
vector<int> v[maxn];
void sieve()
{
	for (int i = 1; i < maxn; ++i)
		for (int j = i; j < maxn; j += i)
			v[j].push_back(i);
}
int main() {
#ifndef ONLINE_JUDGE
	input();
	output();
#endif
	sieve();
	int n, ans=0;
	scanf("%d", &n);
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		q[a[i]]++;
	}
	sort(a.begin(), a.end());
	for (auto i : a)
	{
		if(q[i]>1) {ans++;p[i]=1;continue;}
		for (auto j : v[i]) if(p[j]) {ans++;break;}
		p[i]=1;
	}
	cout << n-ans << endl;
}

Measured memory_bytes: 123120
package main

import "fmt"

func main() {
	var t int

	fmt.Scanf("%d",&t)

	fmt.Printf("%d", lcm(t, 360) / t)
}

func gcd(a int, b int) int {
	if b == 0 {
		return a
	} else {
		return gcd(b, a % b)
	}
}

func lcm(a int, b int) int {
	return a * b / gcd(a, b)
}

Measured memory_bytes: 1832
#include <stdio.h>
#include <math.h>

int main(void){
    double x1, y1, x2, y2, distance;
    scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
    distance=sqrt((pow(x2-x1, 2)+pow(y2-y1, 2)));
    printf("%f\n", distance);

    return 0;
}


Measured memory_bytes: 2072
#include<stdio.h>
int main(){
  int n,a,b,sum=0,i;
  scanf("%d%d%d",&n,&a,&b);
  for(i=1;i<=n;i++){
    int count=0;
    int num=i;
    while(num!=0){
      count+=num%10;
      num/=10;
    }
    if(a<=count && count<=b)
      sum+=i;
  }
  printf("%d\n",sum);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define all(X) (X).begin(),(X).end()
#define P 1000000007

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0), cout.tie(0);
	
	int n, a[200010];
	cin >> n;
	
	for(int i = 0; i < n; i++) cin >> a[i];
	
	int all = 0;
	for(int i = 0; i < n; i++) all ^= a[i];
	
	for(int i = 0; i < n; i++) {
		int num = all ^ a[i];
		cout << num << " ";
	} 
	
	return 0;
}

Measured memory_bytes: 4440
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <deque>
#include <queue>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
typedef long long ll;
typedef pair<int,int> P;
int main() {
    string t = "keyence";
    string s;
    cin >> s;
    ll n = s.size();
    rep(i, 0, n){
        rep(j, i, n){
            string tmp = s.substr(0,i)+s.substr(j);
            if (t == tmp) {
                cout << "YES" << endl;
                return 0;
            }
        }
    }
    cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 3616
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {//236
	double w,h,x,y;
	cin>>w>>h>>x>>y;
	double ar = w*h/2;
	int val =0;
	if(x==w/2&&y==h/2)val=1;
	printf("%.9lf %d",ar,val);
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


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

int main()
{
	int N,max = 0,ans;

	cin >> N;

	map<int, int >mp;

	for (int i = 0; i < N; i++)
	{
		int n;
		cin >> n;
		mp[n]++;
		if (mp[n] > max) {
			max = mp[n];
		}
		mp[n - 1]++;
		if (mp[n-1] > max) {
			max = mp[n-1];
		}
		mp[n + 1]++;
		if (mp[n+1] > max) {
			max = mp[n+1];
		}
	}

	cout << max;

	return 0;
}

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

int main() {
	
	string s, t;
	cin >> s >> t;
	sort(all(s));
	sort(all(t));
	vector<int> sv(26), tv(26);
	int p = 0;
	sv[0] = 1;
	for(int i = 1; i < s.size(); i++){
		if(s[i] != s[i-1]){
			p++;
		}
		sv[p]++;
	}
	p = 0;
	tv[0] = 1;
	for(int i = 1; i < t.size(); i++){
		if(t[i] != t[i-1]){
			p++;
		}
		tv[p]++;
	}
	sort(all(sv));
	sort(all(tv));
	
	if(sv == tv){
		puts("Yes");
	}else{
		puts("No");
	}
	return 0;
}

Measured memory_bytes: 776
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <string>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

ll mpow(ll a, ll b){
	if(b==0) return 1;
	else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
	else return mpow(a,b-1) * a % MOD;
}

signed main(){
  int n,k; cin>>n>>k;
	VI c(n+5,0);
	rep(i,n){
		int a; cin>>a; c[a]++;
	}
	sort(RALL(c));
	int sum = 0;
	for(int i=k; i<=n; i++){
		if(!c[i]) break;
		sum += c[i];
	}
	cout << sum << endl;




  return 0;
}


Measured memory_bytes: 1152
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
#include <cassert>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

void cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
int main(void){
    ll w, h;
    cin >> w >> h;
    vector<pair<ll,ll>> vec;

    rep(i, w){
        ll p;
        cin >> p;
        vec.push_back({p, 0});
    }

    rep(i, h){
        ll p;
        cin >> p;
        vec.push_back({p, 1});
    }

    sort(all(vec));
    w++, h++;
    ll ans = 0;
    rep(i, vec.size()){
        if(w > 0 && vec[i].second == 0){
            ans += vec[i].first * h;
            w--;
        } else if(h > 0 && vec[i].second == 1){
            ans += vec[i].first * w;
            h--;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 7404
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int[] a = new int[N];
        for (int i = 0; i < N; i++) {
            a[i] = scanner.nextInt();
        }
        int index = 1;
        int ans = 0;

        for (int i = 0; i < N; i++) {
            if (index == a[i]) {
                index++;
            } else {
                ans++;
            }
        }

        if (index > 1) {
            System.out.println(ans);
        } else {
            System.out.println(-1);
        }
    }
}


Measured memory_bytes: 65296
#include<stdio.h>
int main()
{
	int N;
	int M;
	int total;
	scanf("%d %d",&N,&M);
	N=--N*(N+1)/2;
	M=--M*(M+1)/2;
	total= N + M;
	printf("%d",total);
	
	return 0;
}

Measured memory_bytes: 1712
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String X = sc.next();
		String[] listA =  X.split("");
		int[] listb = new int[4];
		for(int i = 0; i <= 3; i++) {
			for(int c = 0; c <= 3; c++) {
				if(listA[i].equals(listA[c])) {
					listb[i]++;
				}
			}
		}

		String ans = "Yes";
		for(int i = 0; i < 3; i++) {
			if(listb[i] != 2) {
				ans = "No";
			}
		}

		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
#include<stdio.h>
int main()
{
    long long int x,sum=0;
    int n_500,n_5,r;
    scanf("%lld",&x);
    n_500=x/500;
    r=x%500;
    n_5=r/5;
    sum=n_500*1000+n_5*5;
    printf("%lld",sum);
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

void swap(int *x, int *y) {
    int temp;
    temp = *x;
    *x = *y;
    *y = temp;
}

int main() {
    int n, i, j, min;
    int arr[101];
    int cnt = 0;

    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%d", &arr[i]);
    }

    for(i = 0; i < n-1; i++) {
        min = i;
        for (j = i+1; j < n; j++) {
            if(arr[min] > arr[j]) {
                min = j; 
            }
        }
        if(min != i){
            cnt++;
            swap(&arr[i], &arr[min]);
        }
    }

    for (i = 0; i < n-1; i++) {
        printf("%d ", arr[i]);
    }
    printf("%d\n", arr[n-1]);
    printf("%d\n", cnt);



    return 0;
}

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


using namespace std;

char a[20][20];
long long int n,X,Y,text[1000][20][20],i;

void K(int x,int y){
    a[x][y]='0';
    for(int k=1;k<4;k++){
        if((x+k)<9&&a[x+k][y]=='1')K(x+k,y);
        if((x-k)>0&&a[x-k][y]=='1')K(x-k,y);
        if((y+k)<9&&a[x][y+k]=='1')K(x,y+k);
        if((y-k)>0&&a[x][y-k]=='1')K(x,y-k);
    }
}
int main(){

cin >> n;

for(i=1;i<=n;i++){
    for(int k=1;k<9;k++){
        for(int j=1;j<9;j++)
        cin >> a[k][j];
    }
    cin >> X >> Y;
    K(Y,X);
    cout << "Data " << i << ":" << endl;
    for(int i=1;i<9;i++){
        for(int j=1;j<9;j++){
            cout << a[i][j];
        }
        cout << endl;
    }
}
return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think
const ll LINF = 1e18;


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }


main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s, t;
    cin >> t >> s;
    cout << s << t << '\n';
}


Measured memory_bytes: 3620
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define for_rev(i,a,b) for(int i=(a);i>=(b);--i)

class UnionFind {
private:
    vector< int > data;
    int gc;
    
public:
    UnionFind(int n) : data(n, -1), gc(n) {}
    
    bool unionSet(int x, int y) {
        x = root(x); y = root(y);
        
        if (x == y) return false;
        
        if (data[y] < data[x]) swap(x, y);
        data[x] += data[y]; data[y] = x;
        --gc;
        
        return true;
    }
    
    bool sameSet(int x, int y) {
        return root(x) == root(y);
    }
    
    int root(int x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    
    int size(int x) {
        return -data[root(x)];
    }
};

int N, M, x[5010];
map< string, int > id;

int main() {
    cin >> N;
    for_(i,0,N) {
        string name;
        cin >> name >> x[i];
        id[name] = i;
    }
    
    UnionFind uf(N);
    cin >> M;
    for_(i,0,M) {
        string s, t;
        cin >> s >> t;
        uf.unionSet(id[s], id[t]);
    }
    
    vector< vector< int > > G(N, vector< int >());
    
    for_(i,0,N) {
        G[uf.root(i)].push_back(i);
    }
    
    int ans = 0;
    for_(i,0,N) {
        int gsize = (int)G[i].size();
        
        if (gsize > 0) {
            int minx = 1010;
            for_(j,0,gsize) minx = min(minx, x[G[i][j]]);
            ans += minx * gsize;
        }
    }
    
    cout << ans << endl;
}

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

#define fi first
#define se second
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple

using namespace std;

vector<int> neg;
vector<int> poz;
int niz[200010];
ll pozD = 0;
ll negD = 0;

ll izbrojN(ll p, ll b)
{
    b = -b;
    if(poz[poz.size()-1]*b > p) return 0;
    ll l = 0;
    ll r = poz.size()-1;
    while(l < r)
    {
        int sr = (l+r)/2;
        if(poz[sr]*b > p) l = sr + 1;
        else r = sr;
    }
    return poz.size() - l;
}
ll manjiPoz(ll p, ll b)
{
    if(b * poz[0] > p)
        return 0;
    ll l = 0;
    ll r = pozD - 1;
    while(l < r)
    {
        ll sr=(l + r + 1)/2;
        if(b * poz[sr] > p)
            r = sr - 1;
        else
            l = sr;
    }
    if(b * b > p) return l + 1;
    return l;
}

ll manjiNeg(ll p, ll b)
{
    if(b * neg[0] > p)
        return 0;
    ll l = 0;
    ll r = negD - 1;
    while(l < r)
    {
        ll sr = (l + r + 1)/2;
        if(b * neg[sr] > p)
            r = sr - 1;
        else
            l = sr;
    }
    if(b * b > p) return l + 1;
    return l;
}

ll check(ll p)
{
    ll res = 0;
    if(p < 0)
    {
        for(int i = 0; i < neg.size(); i++)
            res += izbrojN(p, neg[i]);
        return res;
    }
    res += pozD*negD;
    ll p1 = 0;
    ll p2 = 0;
    for(int i = 0; i < pozD; i++)
        p1+=manjiPoz(p, poz[i]);
    res += p1/2;
    for(int i = 0; i < negD; i++)
        p2+=manjiNeg(p, neg[i]);
    res += p2/2;
    return res;
}
ll k;
ll binarna(ll l, ll r)
{
    if(l == r) return l;
    ll p;
    if(l + r < 0) p = (l + r - 1)/2;
    else p = (l + r)/2;
    if(check(p) >= k) return binarna(l, p);
    return binarna(p+1, r);
}

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

    int n;
    cin >> n;

    cin >> k;
    for(int i = 0; i < n; i++)
    {
        cin >> niz[i];
        if(niz[i] >= 0) poz.pb(niz[i]);
        else neg.pb(abs(niz[i]));
    }
    pozD = poz.size();
    negD = neg.size();
    sort(poz.begin(), poz.end());
    sort(neg.begin(), neg.end());
    ll l = -1e18;
    ll r = -l;
    cout << binarna(l, r);


    return 0;
}


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

int odd(int n,int cnt){
    cnt++;
    if(n/10==0) {
        return cnt;
    }
    else {
        return (odd(n/10,cnt));
 }
}

int main(){
int n,cnt=0,count=0;
cin >> n;
for (int i = 1;i <= n;i++){
    if(odd(i,cnt)%2==1){
        count++;
    }
}
cout << count << endl;

}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
--import Data.Array
--import Data.Array.Unboxed
import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
-- import System.IO.Unsafe
 
f [x, y, h, w]
  | l<=60 && w<=2 = 600
  | l<=80 && w<=5 = 800
  | l<=100 && w<=10 = 1000
  | l<=120 && w<=15 = 1200
  | l<=140 && w<=20 = 1400
  | l<=160 && w<=25 = 1600
  | otherwise = 0
  where
    l = x + y + h

main = do
    n <- getInt
    when (n/=0) $ replicateM n getInts >>= print . sum . map f >> main

-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
fnBin op f g x = op (f x) $ g x
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
modifyArray :: (Ix i, MArray a e m) => a i e -> i -> (e -> e) -> m ()
modifyArray arr ix f = readArray arr ix >>= writeArray arr ix . f
dictCompare :: [a -> a -> Ordering] -> a -> a -> Ordering
dictCompare [] _ _ = EQ
dictCompare (f:fs) x y = let c = f x y in if c==EQ then dictCompare fs x y else c
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
-- templete



Measured memory_bytes: 12292
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int H, W, N;

    cin >> H >> W;
    cin >> N;

    vector<int> a;
    a.reserve(N);

    for (int n = 0; n < N; n++) { cin >> a[n]; }

    vector<vector<int>> tile;
    tile = vector<vector<int>>(H, vector<int>(W, 0));

    int row = 0;
    int col = 0;

    for (int n = 0; n < N; n++) {
        int c = a[n];
        for (int m = 0; m < c; m++) {
            tile[row][col] = n + 1;
            if (row % 2 == 0) { col++; }
            else { col--; }

            if (col >= W) { 
                row++;
                col--;
            }
            else if (col < 0) {
                row++;
                col = 0;
            }
        }
    }

    for (int n = 0; n < H; n++) {
        for (int m = 0; m < W; m++) {
            cout << tile[n][m];
            if (m != W - 1) { cout << " "; }
            else { cout << endl; }
        }
    }

    return 0;
}

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

#define int long long

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  string s;
  cin >> s;

  bool flag = true;
  for ( int i = 0; i < (int)s.size(); i++ ) {
    if ( i%2 == 0 && !(s[i] == 'R' || s[i] == 'U' || s[i] == 'D') ) flag = false;
    if ( i%2 == 1 && !(s[i] == 'L' || s[i] == 'U' || s[i] == 'D') ) flag = false;
  }

  if ( flag ) cout << "Yes" << endl;
  else cout << "No" << 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 REP(i,n) for(int i=1;i<=n;i++)
typedef long long ll;

using edge = pair<int,ll>;
vector<vector<edge>> G;
vector<int> color;

//vをcolに塗る
void dfs(int v, int col, int p){
	color[v] = col;
	
	for (auto nextv: G[v]) {
		//親だったらスルー
		if(nextv.first == p){
			continue;
		}
		//重みが偶数だったら同じ色に塗る
		if (nextv.second  % 2 == 0){
			dfs(nextv.first, col, v);
		}else{
			dfs(nextv.first, 1-col, v);
		}
	}
}


int main(){
	int N;
	cin >> N;
	
	G.resize(N);
	
	rep(i,N-1){
		int u,v;
		ll w;
		cin >> u >> v >> w;
		u--;
		v--;
		G[u].push_back(edge(v,w));
		G[v].push_back(edge(u,w));
	}
	color.assign(N,0);
	
	//頂点0を1に塗る
	dfs(0,1,-1);
	
	for (auto v: color){
		cout << v << endl;
	}
	
    return 0;
}

Measured memory_bytes: 10496
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;

vector<int> t;
vector<int> v;
vector<int> h;
int func(int tt, int i){
  int ht;
  if(tt<=t[i-1]) ht = v[i] + (t[i-1]-tt);
  else if(tt>t[i-1] && tt<=t[i]) ht = v[i];
  else ht = v[i] + (tt-t[i]);
  return ht;
}

int main(){
  int n;
  cin>>n;
  t.push_back(0);
  v.push_back(0);
  int temp;
  REP(i, n){
    cin>>temp;
    temp=2*temp + t[i];
    t.push_back(temp);
  }
  int tmax=t[n];
  t.push_back(40002);
  REP(i, n){
    cin>>temp;
    temp *= 2;
    v.push_back(temp);
  }
  v.push_back(0);

  for(int a=0; a<=tmax; ++a){
    int ht=INF;
    //cout<<a<<" ";
    ht=min({ht, a, tmax-a});
    for(int i=1; i<=n; ++i){
      ht = min(ht, func(a, i));
    }
    //cout<<ht<<endl;
    h.push_back(ht);
  }
  double ans=0;
  REP(i, h.size()-1){
    ans += double(h[i+1]+h[i])/2;
    //cout<<ans<<endl;
  }
  ans /=4;
  printf("%.4f\n", ans);



  return 0;
}


Measured memory_bytes: 640
import java.util.*;
class Main{
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
	int H = sc.nextInt();
	int W = sc.nextInt();
	int[] a = new int[N];
	int[] b = new int[N];
	int cnt = 0;
	for(int i = 0; i < N; i++) {
	    a[i] = sc.nextInt();
	    b[i] = sc.nextInt();
	    if(a[i] >= H && b[i] >= W){
		cnt++;
	    }
	}
	System.out.println(cnt);
    }
}

Measured memory_bytes: 26708
#include<cstdio>  
#include<cstring>  
#include<algorithm>  
#include<iostream>  
#include<string>  
#include<vector>  
#include<stack>  
#include<bitset>  
#include<cstdlib>  
#include<cmath>  
#include<set>  
#include<list>  
#include<deque>  
#include<map>  
#include<queue>
using namespace std;
typedef long long ll;
const ll inf=1<<29;
const ll Maxn=1e6;

char s[Maxn];

int main(){
	ll n,t,x,y,s,k;
	ll mid=0;
	cin>>n;
	k=n;
	while(k--){
		cin>>t>>x>>y;
		s=x+y;
		if(t>=s && ((t%2==1 && s%2==1)||(t%2==0 && s%2==0))) mid++;
	}
	if(mid==n) printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
using namespace std;
#define int long long
int a[200005];
signed main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)cin >> a[i];
	int ans = 1e11;
	int sum = 0;
	for (int i = 0; i < n; i++)sum += a[i];

	int sn = 0;
	for (int i = 0; i < n-1; i++) {
		sn += a[i];
		int ar = sum - sn;
		ans = min(ans, abs(ar - sn));
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
from functools import reduce
import itertools

def gcd_base(x,y):
    while y!=0:
        x,y = y,x%y
    return x

def gcd(num):
    return reduce(gcd_base,num)

ans = 0
k = int(input())
if k >=3:
    l = [i for i in range(1,k+1)]
    ll = list(itertools.combinations(l,3))
    for x in ll:
        ans += (gcd(x))*6
    ll = list(itertools.combinations(l,2))
    for x in ll:
        y = [x[0],x[0],x[1]]
        z = [x[0],x[1],x[1]]
        ans += (gcd(y))*3
        ans += (gcd(z))*3
    for i in l:
        tmp = [i,i,i]
        ans += gcd(tmp)
    print(ans)
elif k == 2:
    print(9)
elif k ==1:
    print(1)


Measured memory_bytes: 189928
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   string s;
   cin >> s;
   int n = s.length();
   vector<int> a(n+1);
   f(i,0,n){
      if(s[i] == '<'){
         a[i+1] = max(a[i+1],a[i]+1);
      }
   }
   for(int i=n-1;i>=0;i--){
      if(s[i] == '>'){
         a[i] = max(a[i],a[i+1]+1);
      }
   }
   int ans = 0;
   f(i,0,n+1){
      ans += a[i];
   }
   cout << ans << '\n';
   return 0;
}

Measured memory_bytes: 4764
#include<stdio.h>

void trace(int A[], int N) { // Show all of the elements in the array.
  int i;
  for (i=0; i<N; i++) {
    if (i>0) printf(" ");
    printf("%d", A[i]);
  }

  printf("\n");
}

void insertionSort(int A[], int N) {
  int i, j, v;
  for (i=1; i<N; i++) {
    v = A[i]; //Store the value of concern.
    j = i - 1;

    while (j>=0 && A[j] > v) { // Make a spcae for v to join into a sorted area by moving 1 right away all the e>v elements.
      A[j+1] = A[j];
      j--;
    }

    A[j+1] = v; // Join v into sorted area of the array.
    trace(A, N);
  }
}

int main() {
  int N, i;
  int A[100];

  scanf("%d", &N);
  for (i=0; i<N; i++) scanf("%d", &A[i]);

  trace(A, N);
  insertionSort(A, N);

  return 0;
}



Measured memory_bytes: 2148
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;


int main() {
    long long A, B, C, X;
    cin >> A >> B >> C >> X;
    int ans = 0;

    for (int i = 0; i <= A; i++) {
        for (int j = 0; j <= B; j++) {
            for (int k = 0; k <= C; k++) {
                if (500 * i + 100 * j + 50 * k == X) {
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3612