akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;
const int mod = 1e9+7;

int n;
vvll I;

vvll mul_matrix(vvll &a, vvll &b) {
    vvll res(n,vll(n));
    rep(i,n)rep(j,n)rep(k,n) {
        res[i][j] += a[i][k] * b[k][j];
        res[i][j] %= mod;
    }
    return res;
}

vvll pow(vvll a, ll k) {
    if (k == 0) return I;
    vvll res = pow(mul_matrix(a,a),k/2);
    if (k&1) res = mul_matrix(res,a);
    return res;
}

int main() {
    cin >> n;
    ll k; cin >> k;
    vvll a(n,vll(n));
    rep(i,n)rep(j,n) cin >> a[i][j];
    I.resize(n,vll(n));
    rep(i,n)rep(j,n) {
        if (i == j) I[i][j] = 1;
        else I[i][j] = 0;
    }
    vvll ans_mat = pow(a,k);
    ll ans = 0;
    rep(i,n)rep(j,n) {
        ans += ans_mat[i][j];
        ans %= mod;
    }
    cout << ans << endl;
}

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

#define FOR(i,a,b)  for(ll (i)=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll (i)=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      v.begin(), v.end()
#define UNIQ(v)     sort(ALL(v)); v.erase(unique(ALL(v)), v.end())
#define BIT(n)      (1LL<<(n))
#define DEBUG(a)    cout << #a << " = " << a << endl

const ll inf = 1e15;
const ll mod = 1e9+7;

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

ll mpow(ll x, ll n, ll acc = 1) {
    if (n == 0) return acc;
    
    if (n % 2 == 0) return mpow(x * x % mod, n >> 1, acc);
    else            return mpow(x, n - 1, acc * x % mod);
}

int main() {
    ll H, W, A, B; cin >> H >> W >> A >> B;
    ll MAX_N = H + W + 4;
    
    vector<ll> fct(MAX_N+1, 1);
    REP(i, MAX_N) fct[i+1] = fct[i] * (i+1) % mod;
    
    vector<ll> inv(MAX_N+1, 1);
    REP(i, MAX_N) inv[i+1] = mpow((i+1), mod-2);
    REP(i, MAX_N) inv[i+1] = inv[i+1] * inv[i] % mod;
    
    ll ans = 0;
    ll X = B + 1;
    ll Y = H - A;
    while (X <= W and Y >= 1) {
        ll temp = fct[X+Y-2] * fct[H+W-X-Y] % mod;
        temp = temp * inv[X-1] % mod;
        temp = temp * inv[Y-1] % mod;
        temp = temp * inv[W-X] % mod;
        temp = temp * inv[H-Y] % mod;
        
        ans += temp;
        ans %= mod;
        
        X++;
        Y--;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3456
#!/usr/bin/env python3
n, m = map(int, input().split())
s = [0] * m
c = [0] * m
for i in range(m):
    s[i], c[i] = map(int, input().split())
    s[i] -= 1
for i in range(10 ** n):
    d = str(i)
    if len(d) != n:
        continue
    if any(int(d[s[j]]) != c[j] for j in range(m)):
        continue
    print(d)
    exit()
print(-1)


Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <bitset>
#include <tuple>
#include <cmath>
#include <complex>
#include <algorithm>
#include <utility>
#include <regex>
#include <cstdint>
#include <numeric>
#include <functional>
#include <cassert>

using namespace std;
using ll = int64_t;
using ull = uint64_t;

constexpr ll INF = 1'000'000'000'000'000'000;
namespace utils{
    template<class T, class Compare> using p_queue = priority_queue<T, vector<T>, Compare>;
    template<class T> using min_queue = p_queue<T, greater<T>>;
    template<class T> using max_queue = p_queue<T, less<T>>;

    template<class T> bool min_update(T& X, const T& A){ if(X > A) {X = A; return true;} return false; }
    template<class T> bool max_update(T& X, const T& A){ if(X < A) {X = A; return true;} return false; }
    using V_Set = unordered_set<int>;
    using E_Set = unordered_map<int, V_Set>;

#define ALL(x) begin(x), end(x)
#define rALL(x) rbegin(x), rend(x)
}
using namespace utils;


void sub_main(istream &is) {
    ll A , B;
    is >> A >> B;
    if(!is) return;
    cout << max({A+B, A-B, A*B}) << endl;

}

int main(int argc, char *argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(16) << scientific;
#ifdef DEBUG
    string test_cases = "test_A.txt";
    cerr << "DEBUG MODE" <<  endl;
    cerr << test_cases << " -->" << endl;
    auto fs = fstream(test_cases, fstream::in);
    int lp = 0;
    while(fs) {
        lp++;
        cout << lp <<  "#------\n";
        sub_main(fs);
    }
    cout << "------#" << endl;
    if(lp <= 1) sub_main(cin);
#else
    sub_main(cin);
#endif
    return 0;
}


Measured memory_bytes: 256
N,M=map(int,input().split())
Sc=[list(map(int,input().split())) for _ in range(M)]

D=['-1']*N

for sc in Sc:
    s,c=sc[0],sc[1]
    if s==1 and c==0 and N>1:
        print(-1)
        exit()
    if D[s-1]!='-1' and D[s-1]!=str(c):
        print(-1)
        exit()
    D[s-1]=str(c)
if D[0]=='-1' and N==1:
    D[0]='0'
elif D[0]=='-1' and N>1:
    D[0]='1'
for i in range(1,N):
    if D[i]=='-1':
        D[i]='0'
 
print(''.join(D))

Measured memory_bytes: 3064
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random,resource

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    rr = []

    def f():
        n,m = LI()
        if n == 0:
            return

        bb = [int(S(), 2) for _ in range(n)]
        bc = collections.defaultdict(int)
        for i in bb:
            bc[i] += 1

        rt = 0
        b = []
        for k,v in bc.items():
            if v > 2:
                if v % 2 == 0:
                    rt += v - 2
                    v = 2
                else:
                    rt += v - 1
                    v = 1
            for i in range(v):
                b.append(k)

        n = len(b)
        c = collections.defaultdict(int)
        c[0] = 0
        for i in b:
            for k,v in list(c.items()):
                t = k ^ i
                if c[t] <= v:
                    c[t] = v + 1

        rr.append(c[0] + rt)
        return True

    while f():
        # print(rr)
        pass

    return JA(rr, "\n")


print(main())





Measured memory_bytes: 158452
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;

void main() {
    char[] s;
    scan(s);

    int ans = 100000;

    foreach (ch ; 'a' .. 'z' + 1) {
        ans = min(ans, solve(s, ch.to!char));
    }

    writeln(ans);
}

int solve(char[] s, char ch) {
    int n = s.length.to!int;
    char[] cur = s.dup;

    foreach (i ; 0 .. n - 1) {
        if (cur.all!(ch => ch == cur.front)) {
            return i;
        }

        auto nex = new char[](n - 1 - i);
        foreach (j ; 0 .. n - 1 - i) {
            if (cur[j] == ch || cur[j + 1] == ch) {
                nex[j] = ch;
            }
            else {
                nex[j] = cur[j];
            }
        }
        cur = nex;

        debug {
            writeln(cur);
        }
    }

    return n - 1;
}





















int[][] readGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new int[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v;
        scan(u, v);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= v;
        if (isUndirected) {
            adj[v] ~= u;
        }
    }

    return adj;
}

alias Edge = Tuple!(int, "to", int, "cost");

Edge[][] readWeightedGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new Edge[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v, c;
        scan(u, v, c);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= Edge(v, c);
        if (isUndirected) {
            adj[v] ~= Edge(u, c);
        }
    }

    return adj;
}

void yes(bool b) {
    writeln(b ? "Yes" : "No");
}

void YES(bool b) {
    writeln(b ? "YES" : "NO");
}

T[] readArr(T)() {
    return readln.split.to!(T[]);
}

T[] readArrByLines(T)(int n) {
    return iota(n).map!(i => readln.chomp.to!T).array;
}

void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


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

int main(){
    string s;
    cin >> s;
    int q;
    cin >> q;

    vector<char> begin, end;
    int flag = 0;

    rep(i,q){
        int t, f;
        char c;
        cin >> t;
        if(t == 1){
            flag++;
        }else{
            cin >> f >> c;
            if((flag + f)%2 == 1){
                begin.push_back(c);
            }else{
                end.push_back(c);
            }
        }
    }

    int bn = begin.size(), en = end.size();
    if(flag%2 == 0){
        rep(i,bn){
            cout << begin[bn-1-i];
        }
        cout << s;
        rep(i,en){
            cout << end[i];
        }
    }else{
        rep(i,en){
            cout << end[en-1-i];
        }
        int sn = s.size();
        rep(i,sn){
            cout << s[sn-1-i];
        }
        rep(i,bn){
            cout << begin[i];
        }
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int count = 0;
        
        for(int i = 0; i < n; i++){
            int a = Integer.parseInt(sc.next());
            while(0 < a && a%2 == 0){
                a /= 2;
                count++;
                
            }
            
        }
        System.out.println(count);
        
    }
}

Measured memory_bytes: 30208
#include <iostream>
#include <set>
#include <numeric>

unsigned int gcd(unsigned int a, unsigned int b)
{
	return b == 0 ? a : gcd(b, a % b);
}
unsigned long long lcm(unsigned int a, unsigned int b)
{
	return (unsigned long long)a * b / gcd(a, b);
}

int main() {
	int A(0);
	int B(0);
	std::cin >> A >> B;

	std::cout << lcm(A, B);

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;

int main()
{
    string s;
    cin >> s;
    int n = s.size();
    int ans1 = 0;
    int ans2 = 0;
    for(int i = 0; i < n;i++){
        ans1 += (s[i]-'0');
    }
    ans2 += (s[0]-'1');
    for(int i = 0; i < n-1;i++){
        ans2 += 9;
    }
    cout << max(ans1,ans2) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

main(){
	int a, 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: 580
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]param
//0:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
function myconv(i,no){switch(no){case 0:return i;case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));}}
function Main(input) {
  input = myconv(input,3);
  var H = myconv(input[0],4)[0];
  var W = myconv(input[0],4)[1];
  var D = myconv(input[0],4)[2];
  var list = {};
  input.shift();
  for(var i = 0; i < H; i++){
    var tmp = myconv(input[0],4);
    input.shift();
    for(var j = 0; j < W; j++){
      list[tmp[j]] = {"h" : i+1, "w" : j+1};
    }
  }
  var resultlist = new Array(H*W+1);
  for(var i = 1; i <= D; i++){
    var subindex = i;
    resultlist[subindex] = 0;
    while(true){
	if(subindex + D > (H * W)){
         break;
      }else{
	 subindex += D
	}
      resultlist[subindex] = resultlist[subindex - D] + Math.abs(list[subindex]["h"] - list[subindex - D]["h"]) + Math.abs(list[subindex]["w"] - list[subindex - D]["w"]);
    }
  }
  myerr(resultlist);
  var output = [];
  var Q = myconv(input[0],1);
  input.shift();
  for(var i = 0; i < Q; i++){
    var l = myconv(input[i],4)[0];
    var r = myconv(input[i],4)[1];
    output.push(resultlist[r] - resultlist[l]);
  }
  myout(output.join("\n"));
}
Main(myin());

Measured memory_bytes: 68700
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int gcd(int x,int y)
{
    if(y==0){
        return x;
    }
    return gcd(y,x%y);
}
int main()
{
    int a=1,b=1,c=1,k,sum=0;
    cin>>k;
    for(a=1;a<=k;a++){
        for(b=1;b<=k;b++){
           for(c=1;c<=k;c++){
                sum+=gcd(a,gcd(b,c));
           }
       }

    }
    cout<<sum;
}






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

int main()
{
    int n, t;
    cin >> n;
    t = n;
    int fx = 0;
    while (t > 0)
    {
        fx += t % 10;
        t /= 10;
    }
    if (n % fx == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

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

int main(){
  int N, M, X;
  cin >> N >> M >> X;
  vector<int> C(N);
  vector<vector<int>> A(N, vector<int>(M));
  for(int i = 0; i < N; i++){
    cin >> C.at(i);
    for(int j = 0; j < M; j++){
      cin >> A.at(i).at(j);
    }
  }
  vector<int> min_cost;
  bool ans = false;
  for(int tmp = 0; tmp < (1 << N); tmp++){
    int Cost = 0;
    vector<int> Und(M);
    bitset<12> s(tmp);
    bool judge = true;
    for(int i = 0; i < N; i++){
      if(s.test(i)){
        Cost += C.at(i);
        for(int j = 0; j < M; j++){
          Und.at(j) += A.at(i).at(j);
        }
      }
    }
    for(int k = 0; k < M; k++){
      if(Und.at(k) < X) judge = false;
    }
    if(judge){
      ans = true;
      min_cost.push_back(Cost);
    }
  }
  if(ans == false) cout << -1 << endl;
  else{
    sort(min_cost.begin(), min_cost.end());
    cout << min_cost.at(0) << endl;
  }
}


Measured memory_bytes: 3668
import java.util.Scanner;
class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		//input
		int n = sc.nextInt();
		int[] a = new int[n];
		int max = 0;
		for(int i=0; i<n; i++){
			a[i] = sc.nextInt();
		}

		//method
		for(int i=0; i<a.length; i++){
			for(int j=1; j<a.length; j++){
				int diff = Math.abs(a[i]-a[j]);
				if(diff>max){
					max = diff;
				}
			}
		}
		System.out.println(max);
	}
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
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 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);
}

signed main(){
	int s,w; cin>>s>>w;
	if(s<=w) cout<<"unsafe"<<endl;
	else cout<<"safe"<<endl;

	return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <stdio.h>

#define rep(i,min,sup) for(int i=min;i<sup;i++)
#define per(i,min,sup) for(int i=(sup-1);i>=min;i--)
#define swap(a,b) {a+=b;b=a-b;a-=b;}
#define ll long long

using namespace std;

bool pali(string S,int N){
  rep(i,0,N/2)if(S[i]!=S[N-1-i])return false;
  return true;
}

main(){
  string S;
  cin>>S;
  int N=S.size();
  bool ans=pali(S,N)&&pali(S,N/2);
  if(ans)printf("Yes");else printf("No");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define sz(v) (int)v.size() 
#define all(v) v.begin(), v.end()
void dbg_out() { cerr << "\b\b]\n"; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T){ cerr << H << ", "; dbg_out(T...);}
#define watch(...) cerr << "[" << #__VA_ARGS__ << "]: [", dbg_out(__VA_ARGS__)


/****************************** CODE IS HERE ***********************************/

const int inf = 1e9;

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

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

    int n, m; cin >> n >> m;
    int s1, s2, t1, t2; 
    cin >> s1 >> s2 >> t1 >> t2;
    s1--, s2--, t1--, t2--;

    vector <string> A(n);
    for (auto &i: A) cin >> i;

    vector <vector<int>> dist(n, vector<int>(m, inf));
    vector <vector<bool>> used(n, vector<bool>(m, false));
    
    auto check = [&](int r, int c) {
        if (r < 0 or c < 0 or r >= n or c >= m or A[r][c] == '#' or used[r][c]) return false;
        return true;
    };

    deque<pair<int,int>> q;
    q.push_back({s1, s2});
    dist[s1][s2] = 0;
    while (!q.empty()) {
        int r, c;
        tie(r, c) = q.front(); q.pop_front();
        used[r][c] = true;
        for (int i = 0; i < 4; ++i) {
            int x = r + dx[i];
            int y = c + dy[i];
            if (!check(x, y)) continue;
            if (dist[r][c] < dist[x][y]) {
                dist[x][y] = dist[r][c];
                q.push_front({x, y});  //cost 0
            }
        }
        //looking for every 5 x 5 grid with center cell as (r, c)
        for (int i = r-2; i <= r + 2; ++i) {
            for (int j = c-2; j <= c + 2; ++j) {
                if (!check(i, j)) continue;
                if (dist[i][j] > dist[r][c] + 1) {
                    dist[i][j] = dist[r][c] + 1;
                    q.push_back({i, j});  //cost 1
                }
            }
        }
    }

    cout << (dist[t1][t2] == inf ? -1 : dist[t1][t2]);
    

    return 0;
}

/*
 * Concept is same as 0-1BFS
 * If we are able to do 1step up, down, left or right it costs: zero(0) cost.
 * If we check all cells under 5 x 5 then it costs : 1.


*/


Measured memory_bytes: 8940
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e21 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
//char c;

#define Endl endl


/*--------------------template--------------------*/

stack<char> st;

int main() {
    cin >> s;
    REP(i, s.size()) {
        if (st.size() == 0) {
            st.push(s[i]);
        } else {
            if (st.top() == 'S') {
                if (s[i] == 'T') {
                    st.pop();
                    continue;
                }
            }
            st.push(s[i]);
        }



    }
    cout << st.size() << endl;
}

Measured memory_bytes: 644
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template <typename T>
struct SegmentTree{
  using F = function<T(T,T)>;
  Int n;
  F f;
  T ti;
  vector<T> dat;
  SegmentTree(){};
  SegmentTree(F f,T ti):f(f),ti(ti){}
  void init(Int n_){
    n=1;
    while(n<n_) n<<=1;
    dat.assign(n<<1,ti);
  }
  void build(const vector<T> &v){
    Int n_=v.size();
    init(n_);
    for(Int i=0;i<n_;i++) dat[n+i]=v[i];
    for(Int i=n-1;i;i--)
      dat[i]=f(dat[(i<<1)|0],dat[(i<<1)|1]);
  }
  void set_val(Int k,T x){
    dat[k+=n]=x;
    while(k>>=1)
      dat[k]=f(dat[(k<<1)|0],dat[(k<<1)|1]);
  }
  T query(Int a,Int b){
    T vl=ti,vr=ti;
    for(Int l=a+n,r=b+n;l<r;l>>=1,r>>=1) {
      if(l&1) vl=f(vl,dat[l++]);
      if(r&1) vr=f(dat[--r],vr);
    }
    return f(vl,vr);
  }
  template<typename C>
  Int find(Int st,C &check,T &acc,Int k,Int l,Int r){
    if(l+1==r){
      acc=f(acc,dat[k]);
      return check(acc)?k-n:-1;
    }
    Int m=(l+r)>>1;
    if(m<=st) return find(st,check,acc,(k<<1)|1,m,r);
    if(st<=l&&!check(f(acc,dat[k]))){
      acc=f(acc,dat[k]);
      return -1;
    }
    Int vl=find(st,check,acc,(k<<1)|0,l,m);
    if(~vl) return vl;
    return find(st,check,acc,(k<<1)|1,m,r);
  }
  template<typename C>
  Int find(Int st,C &check){
    T acc=ti;
    return find(st,check,acc,1,0,n);
  }
};

//INSERT ABOVE HERE
signed main(){
  Int n,k;
  cin>>n>>k;
  vector<Int> ps(n);
  for(Int i=0;i<n;i++) cin>>ps[i];

  using P = pair<Int, Int>;
  auto f=[&](P a,P b){
           return P(max(a.first,b.first),
                    min(a.second,b.second));
         };
  const Int INF = 1e9;
  P ti(-INF,INF);
  SegmentTree<P> seg(f,ti);

  vector<P> vp;
  for(Int i=0;i<n;i++) vp.emplace_back(ps[i],ps[i]);
  seg.build(vp);


  vector<Int> inc(n,1);
  for(Int i=0;i+1<n;i++)
    inc[i+1]=(ps[i]<ps[i+1]?inc[i]:0)+1;

  Int ans=1;
  Int flg=inc[k-1]>=k;
  for(Int i=1;i+k<=n;i++){
    // stay same
    if(inc[i+k-1]>=k){
      if(!flg) ans++;
      flg=1;
      continue;
    }

    // change
    Int x=ps[i-1],y=ps[i+k-1];
    auto res=seg.query(i-1,i+k);
    if(res!=P(y,x)) ans++;
  }

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


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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;

template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

const int mod=1e9+7;

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 *= 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 c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }

    return true;
}

map<ll, ll> primeFact(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}

void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
void printv(vll& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}

int main()
{
  //init(); // mint初期化
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  int n,a;cin>>n>>a;
  int ans=n*n-a;
  cout(ans);
  
  return 0;
}

Measured memory_bytes: 125568
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
#define  ll long long
#define mod 1000000007
void solve(){

  ll n,m; cin>>n>>m;
  if(m<=2*n) {
     cout<<m/2<<endl;return ;
  } 
  
  ll k=m-2*n;

  cout<< k/4 + n <<endl; 

    
  }

int main() {
   #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif

 ios_base::sync_with_stdio(0);
 cin.tie(0);

  int t =1;  /*cin>>t ;*/

  while(t--){
        solve();
  }

 return 0;
}


Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
string s1,s2;
int mi,a,b,c;
int main()
{
	int i,j;
	getline(cin,s1);
	getline(cin,s2);
	a=s1.size();
	b=s2.size();
	mi=999999999;
	for(i=0;i<a-b+1;i++)
	{
		c=0;
		for(j=i;j<i+b;j++)
		{
			if(s1[j]!=s2[j-i])
			{
				c++;
			}
		}
		mi=min(mi,c);
	}
	cout<<mi<<endl;
	return 0;
}


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

cnt = 0
for i in range(1, N + 1):
    if N // 10**5:
        cnt = 90909
    elif N // 10**4:
        cnt = (N - 10**4 + 1) + 900 + 9
    elif N // 10**3:
        cnt = 900 + 9
    elif N // 10**2:
        cnt = (N - 10**2 + 1) + 9
    elif N // 10:
        cnt = 9
    else:
        cnt = N
print(cnt)

Measured memory_bytes: 3060
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<vector>
using namespace std;
int main(void){
	int N=0,a;
	cin>>N;
	vector<pair<int,int> >ID;
	for(int i=0;i<N;i++)
	{
		cin>>a;
		ID.push_back(make_pair(a,i+1));
	}
	sort(ID.begin(),ID.end());
	for(int i=0;i<N;i++){
		cout<<ID[i].second;
		if(i!=N-1){
			cout<<" ";
		}
	}
	cout<<endl;
	return 0;
}

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

int main(){
  string S,T;
  cin >> S;
  int s=S.size();
  int a,b,c;
  c=1000;
  for(int i=0;i<s-1;i++){
    T=S.substr(i,3);
    a=atoi(T.c_str());
    b=abs(a-753);
    if(c>b){c=b;}
  }
  cout << c << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int h[10];
    int c,t[3]={0,0,0};
    
    for(c=0;c<10;c++)
    {
        scanf("%d",&h[c]);
    }
    
    for(c=0;c<10;c++)
    {
        if(h[c]>=t[0])
        {
            t[2]=t[1];
            t[1]=t[0];
            t[0]=h[c];
        }
        else if((h[c]>=t[1])&&(h[c]<t[0]))
        {
            t[2]=t[1];
            t[1]=h[c];
        }
        else if((h[c]>=t[2])&&(h[c]<t[1]))
        {
            t[2]=h[c];
        }
        else
        {
        }
    }
    for(c=0;c<3;c++)
    {
        printf("%d\n",t[c]);
    }
    return 0;
}

Measured memory_bytes: 600
import java.util.*;

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

        while(true){
            int x = sc.nextInt();
            int y = sc.nextInt();

            if(x == 0 && y == 0){
                break;
            }else{
                for(int i=0;i<x;i++){
                    for(int j=0;j<y;j++){
                        System.out.print("#");
                    }
                    System.out.println();
                }
                System.out.println();
            }
        }
        sc.close();
    }
}


Measured memory_bytes: 35008
n,k = map(int, input().split())
*a, = map(int, input().split())
ans = 0
wer = 0

for i in range(n-1):
  for j in range(i+1, n):
    if a[i] > a[j]:
      ans += 1
ans *= k

for i in range(n):
  for j in range(n):
    if a[i] > a[j]:
      wer += 1
wer *= k*(k-1)//2

ans += wer
ans %= 10**9 + 7
  
print(ans)

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

void solve(long long a, std::string s){
    if (a >= 3200) cout << s << '\n';
    else cout << "red" << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long a;
    cin >> a;
    std::string s;
    std::cin >> s;
    solve(a, s);
    return 0;
}


Measured memory_bytes: 256
import std.stdio, std.string, std.array, std.conv, std.algorithm, std.typecons, std.range, std.container, std.math, std.algorithm.searching, std.functional,std.mathspecial;

void main(){
    auto n=readln().chomp.to!int;
    auto k=readln().chomp.to!int;
    auto x=readln().chomp.to!int;
    auto y=readln().chomp.to!int;
    writeln(min(n,k)*x+max(0,n-k)*y);
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
const int maxn=100+5;
int a[maxn];
int main()
{
    int n;
    while (scanf("%d",&n)!=EOF) {
        for(int i=1;i<=n;i++)scanf("%d",&a[i]);
        sort(a+1,a+1+n);
        int sum=0,flag=true;
        for(int i=n;i>=1;i--)
        {
            if(flag)
                sum+=a[i];
            else
                sum-=a[i];
            flag=!flag;
        }
        printf("%d\n",sum);
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
#define FOR(i,k,n) for(int i=(k);i<(n);++i)
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int main(){
    int N,K;cin>>N>>K;
    if(K>(N-2)*(N-1)/2){cout<<-1<<endl;return 0;}
    else{
        int M=N-1+(N-1)*(N-2)/2-K;
        cout << M << endl;
        rep(i,N-1)cout<<1<<" "<<i+2<<endl;
        int cnt=0;
        rep(i,N-1)rep(j,N-1){
            int x=i+2,y=j+2;
            if(i<j&&cnt<(N-1)*(N-2)/2-K){
                cout<<x<<" "<<y<<endl;
                cnt++;
            }
        }
    }
    return 0;

}

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

#define int long long

int n, k;

vector<int> v(109);

bool memo[100009][2];

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> k;
    for(int i = 0; i < n; i++) cin >> v[i];
    for(int i = 0; i <= k; i++){
        for(int j = 0; j < 2; j++){
            for(int k = 0; k < n; k++){
                if(i-v[k] >= 0){
                    if(!memo[i-v[k]][!j]){
                        memo[i][j] = true;
                        break;
                    }
                }
            }
        }
    }
    if(memo[k][1]) cout << "First" << endl;
    else cout << "Second" << endl;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int YYQ=1e9+7;
int f[100005],ff[100005];
int n,k;
bool vis[100005];
vector<int> g[100005];
int exgcd(int a,int b,int &x,int &y){
	if(b==0){
		x=1;y=0;
		return a;
	}
	int t=exgcd(b,a%b,x,y);
	int temp=x;
	x=y;
	y=temp-(a/b)*y;
	return t;
}
int inv(int a,int b){
	int x,y;
	exgcd(a,b,x,y);
	return x;
}
int A(int n,int k){
	return f[n]*ff[n-k]%YYQ;
}
void pre(){
	f[0]=1;
	for(int i=1;i<=100000;i++)	f[i]=f[i-1]*i%YYQ;
	ff[100000]=(inv(f[100000],YYQ)+YYQ)%YYQ;
	for(int j=99999;j>=0;j--)	ff[j]=ff[j+1]*(j+1)%YYQ;
}
int ans;
void dfs(int cur){
	vis[cur]=1;
	int cnt1=0,cnt2=0;
	for(int i=0;i<g[cur].size();i++){
		if(vis[g[cur][i]])
			cnt1++;
		else
			cnt2++;
	}
	ans=ans*(A(k-cnt1-1,cnt2))%YYQ;
	for(int i=0;i<g[cur].size();i++){
		if(!vis[g[cur][i]])
			dfs(g[cur][i]);
	}
}
signed main(){
	pre();
	cin>>n>>k;
	ans=k;
	for(int i=1;i<n;i++){
		int a,b;
		cin>>a>>b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	for(int i=1;i<=n;i++){
		if(g[i].size()+1>k)
			return puts("0"),0;
	}
	dfs(1);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 9728
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int d=sc.nextInt();
		int x=sc.nextInt();
		int X[]=new int[n];
		int ans=x;
		for(int i=0;i<n;i++)X[i]=sc.nextInt();
		for(int i=1;i<=d;i++) {
			for(int j=0;j<n;j++) {
				if((i-1)%X[j]==0)ans++;
			}
		}

		System.out.println(ans);
	}
}

Measured memory_bytes: 21844
n = int(input())
a = [int(i) for i in input().split()]

minus_cnt = len([i for i in a if i < 0])

a_abs = [abs(i) for i in a]
if minus_cnt%2 == 0:
  ans = sum(a_abs)
else:
  ans = sum(a_abs) - min(a_abs)*2
print(ans)

Measured memory_bytes: 14412
#include <iostream>
using namespace std;
int main(){
  int n;
  int a[210];
  cin >> n;
  for(int i=0; i<n; i++) cin >> a[i];
  int ans = 100;
  for(int i=0; i<n; i++){
    int p = 0;
    while(a[i] % 2 == 0){
      a[i] /= 2;
      p++;
    }
    ans = min(p, ans);
  }
  cout << ans << endl;
}

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

#define ll long long
#define vl vector<ll>
#define fo(i,a,b) for(ll i=a; i<b; i++)

int main(){
    ll A, B, N;
    cin >> A >> B >> N;
    ll flmax = 0;

    if(N >= B){
        cout << (A*(B-1)/B)-(A * ((B-1)/B)) << endl;
    }else{
        cout << (A*N/B)-(A * (N/B)) << endl;
    }
    
    // cout << "--" << endl;

    // fo(i,1,N+1){
    //     ll tmp = ((A*i/B) - (A * (i/B)));
    //     cout << tmp << endl;
    //     if(tmp > flmax) flmax = tmp;
    // }
    
    // cout << "--" << endl;
    // cout << flmax << endl;
       
}

/*
　 ◇　　　　 ミ ◇
　◇◇　 /￣|　 ◇◇
◇◇＼　 L＿| ◇◇
　　彡Ｏ(・＿・)/
　 　　ヽ Ｐ`Ｏ
　　 ／彡#_|ミ＼
　　　 </LL凵>
　　　　∪ ∪
pass system test !!
*/

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

int main(void){
    ll n; cin>>n;
    ll a[n],x[n][n],y[n][n];

    for (ll i = 0; i < n; i++){
        cin>>a[i];
        for (ll j = 0; j < a[i]; j++){
            cin>>x[i][j]>>y[i][j];
        }
    }
    ll ans=0;
    for(ll bits=0;bits<(1<<n);bits++){ //bit全探索
        bitset<15> s(bits); //bitsを15ビットで表す。
        ll sum=0; bool can=true;
        for (ll i = 0; i < n; i++){
            if(s.test(i)){ // .test(i):i番目のbitが1であればtrue
                sum++; //正直者の数を数える
                for(ll j=0;j<a[i];j++){
                    if(s.test(x[i][j]-1)!=y[i][j]){//数えた正直者と与えられた正直者があっているか
                        can=false;
                        break;
                    }
                }
            }
        }
        if(can) ans=max(ans,sum);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	while(true) {
	int N;
	cin >> N;
	if(N == 0) break;
	int count = 0;
	bool na = true;
	for (int i = 0; i < N; i++) {
		int k;
		cin >> k;
		if(k > 1)
			na = false;
		if(k > 0)
			count++;
	}
	if(na == true)
		cout << "NA" << endl;
	else
		cout << count + 1 << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
import scala.util.control.Breaks
object Main extends App {
  val b = new Breaks
  b.breakable {
    for (i <- 1 to 10000) {
      val n = readLine().toInt
      if (n != 0)
        println("Case %d: %d".format(i, n))
      else
        b.break
    }
  }
}


Measured memory_bytes: 77468
#include<bits/stdc++.h>
using namespace std;
int main(){
int A,B,C;
vector<int> vec(10);
  cin>>A>>B>>C;
  vec.at(0)=A*C-B;
  cout<<vec.at(0)<<endl;
 for(int i=1;i<10;i++){
   vec.at(i)=A*vec.at(i-1)-B;
   cout<<vec.at(i)<<endl;
 }
  
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(clippy::many_single_char_names)]

// language: Rust(1.42.0)
// check available crates on AtCoder at "https://atcoder.jp/contests/language-test-202001"
// My Library Repo' is at "https://github.com/Loptall/prcn_lib"

/*
    6月で水色になるぞ〜!!!
*/

// from std...
use std::cmp::{
    max, min,
    Ordering::{Equal, Greater, Less},
    Reverse,
};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::mem::swap;
use std::ops::*;
use std::process::exit;
use std::{f32, f64, i128, i16, i32, i64, i8, isize, u128, u16, u32, u64, u8, usize};

// Dep' crates are...
use itertools::*;
use itertools_num::*;
use lazy_static::lazy_static;
use maplit::{btreemap, btreeset, hashmap, hashset};
use num_bigint::{BigInt, BigUint};
use num_complex::Complex;
use num_integer::{binomial, gcd, lcm, Integer};
use num_rational::Rational;
use num_traits::{one, zero, One, Zero};
use permutohedron::Heap;
use petgraph::unionfind::UnionFind;
use proconio::{fastout, input, is_stdin_empty, marker::*};
use rand::random;

pub const MOD: usize = 1000000007;
pub const MAX: usize = 1usize << 63usize;
pub const MIN: i64 = i64::MIN;
pub const PI: f64 = f64::consts::PI;
pub const A: u8 = 'A' as u8;

// code...
// #[fastout]
fn main() {
    input! {
        c: char
    }

    let c: char = c;
    if c.is_uppercase() {
        println!("A");
    } else {
        println!("a");
    }
}


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

struct mint {
    long long x;
    mint(long long x=0):x((x%MOD+MOD)%MOD){}
    mint operator-() const { return mint(-x);}
    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 *= 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 pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
    	if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint a) {
    	return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

int main(void){
    ll N; mint K; cin >> N >> K.x;
    vector<ll> A(N); REP(i,N) cin >> A[i];
    vector<mint> t1(N);
    REP(i,N){
        mint tmp = 0;
        REP(j,i){
            if(A[i] < A[j]) tmp.x++;
        }
        t1[i] = tmp;
    }

    vector<mint> t2(N);
    REP(i,N){
        mint tmp = 0;
        REP(j,N){
            if(A[i] < A[j]) tmp.x++;
        }
        t2[i] = tmp;
    }
    mint ans = 0;
    REP(i,N) ans = (ans + t2[i]*(K-1)*K/2);
    REP(i,N) ans = (ans + t1[i]*K);
    cout << ans.x << endl;
    return 0;
}

Measured memory_bytes: 256
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};
fn main() {
    input! {//
        n:usize,q:usize,
        a:[usize;n],
        qs:[(usize,usize,usize);q],
    }

    let mut bt = FenwickTree::new(MX, 0);
    for (i, &x) in a.iter().enumerate() {
        bt.add(i, x);
    }
    for &(x, l, r) in qs.iter() {
        match x {
            0 => {
                bt.add(l, r);
            }
            _ => {
                println!("{}", bt.sum(l, r));
            }
        }
    }
}
const MX: usize = 1010101;

pub struct FenwickTree<T> {
    n: usize,
    ary: Vec<T>,
    e: T,
}
impl<T: Clone + std::ops::AddAssign<T>> FenwickTree<T> {
    pub fn new(n: usize, e: T) -> Self {
        FenwickTree {
            n,
            ary: vec![e.clone(); n],
            e,
        }
    }
    pub fn accum(&self, mut idx: usize) -> T {
        let mut sum = self.e.clone();
        while idx > 0 {
            sum += self.ary[idx - 1].clone();
            idx &= idx - 1;
        }
        sum
    }
    /// performs data[idx] += val;
    pub fn add<U: Clone>(&mut self, mut idx: usize, val: U)
    where
        T: std::ops::AddAssign<U>,
    {
        let n = self.n;
        idx += 1;
        while idx <= n {
            self.ary[idx - 1] += val.clone();
            idx += idx & idx.wrapping_neg();
        }
    }
    /// Returns data[l] + ... + data[r - 1].
    pub fn sum(&self, l: usize, r: usize) -> T
    where
        T: std::ops::Sub<Output = T>,
    {
        self.accum(r) - self.accum(l)
    }
}


Measured memory_bytes: 37128
<>;@y=map-$t+($t=$_),glob<>;map{@s=$_?@s[@s]:0..$#y;@s[$_-1,$_]=@s[$_,$_-1]for<>;@y=@y[@s]if$'>>$_&1;}<>!~($/=$")..59;print$z+=$_,$"for@y

Measured memory_bytes: 49800
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
struct RAQ {
	int n;
	vector<int>d;
	RAQ(int m) {
		for (n = 1; n < m; n <<= 1);
		d.assign(2 * n, 0);
	}
	void add(int a, int b, int x = -1, int k = 1, int l = 0, int r = -1) {
		if (r == -1)r = n;
		if (r <= a || b <= l)return;
		if (a <= l&&r <= b) {
			if(x>=0)d[k] += (r - l)*x;
			return;
		}
		else {
			if (d[k] != 0) {
				d[2 * k] += d[k] / 2;
				d[2 * k + 1] += d[k] / 2;
				d[k] = 0;
			}
			add(a, b, x, 2 * k, l, (l + r) / 2);
			add(a, b, x, 2 * k + 1, (l + r) / 2, r);
		}
	}
	int get(int i) {
		add(i, i + 1);
		return d[n + i];
	}
};
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, q; cin >> n >> q;
	RAQ raq(n);
	rep(i, 0, q) {
		int com; cin >> com;
		if (com) {
			int x; cin >> x;
			cout << raq.get(x - 1)<<endl;
		}
		else {
			int s, t, x; cin >> s >> t >> x;
			raq.add(s - 1, t, x);
		}
	}
	return 0;
}

Measured memory_bytes: 4916
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
	// your code goes here
	int n; cin>>n;
	int ans=0;
	int a=1,b=1;
	while(a<n){
	    int b=1;
	    while((a*b)<n){
	        b++;
	        ans++;
	    }
	    a++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3632
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func pow(n int) int {
	var p float64 = math.Pow(float64(n), 2.0)
	return int(p)
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	x := make([]int, n)
	for i := range x {
		x[i] = nextInt()
	}

	temp, sum := 0, 0
	var min int = math.MaxInt64
	for i := 1; i <= 100; i++ {
		for j := 0; j < n; j++ {
			temp = pow(x[j] - i)
			sum += temp
		}
		if sum < min {
			min = sum
		}
		sum = 0
	}
	fmt.Println(min)
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(NULL);
ios::sync_with_stdio(false);

 int x;
 cin>>x;
 if(x==25){
   cout<<"Christmas"<<"\n";
 }
 else if(x==24){
   cout<<"Christmas Eve"<<"\n";
 }
 else if(x==23){
   cout<<"Christmas Eve Eve"<<"\n";
 }
 else if(x==22){
   cout<<"Christmas Eve Eve Eve"<<"\n";
 }

 return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<typename T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<typename T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}

int main()
{
    string s;getline(cin,s);
    ll foo=0,bar=1;
    for(int i=s.length()-1;i>=0;--i){
        if(s[i]!=' '){
            foo+=(s[i]-'0')*bar;
            bar*=10;
        }
    }
    for(int i=0;i<=1000;++i){
        if(i*i==foo){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
  int n, i;
  int *s;
  double m, alpha;

  while (1) {
    scanf("%d", &n);
    if (n == 0) break;

    s = (int *)malloc(sizeof(int) * (n + 1));
    for (i = 0; i <= n; i++) s[i] = 0;
    m = 0;
    alpha = 0;

    for (i = 1; i <= n; i++) {
      scanf("%d", &s[i]);
      m += s[i];
    }
    m /= (double)n;

    for (i = 1; i <= n; i++) alpha += (s[i]-m) * (s[i]-m);
    alpha /= (double)n;
    alpha = sqrt(alpha);

    printf("%.8lf\n", alpha);

    free(s);
  }

  return 0;
}

Measured memory_bytes: 640