akhauriyash/Code-Regression huggingface dataset:
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(x) (x).erase(unique(all(x)), (x).end());
#define REPIT(x) for(auto it=(x).begin(), end=(x).end(); it!=end; ++it)
#define perm(c) sort(all(c)); for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
	cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
	cout << head;
	if (sizeof...(tail) != 0) cout << " ";
	print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
	for (auto& a : vec) {
		cout << a;
		if (&a != &vec.back()) cout << " ";
	}
	cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
	for (auto& vec : df) {
		print(vec);
	}
}

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

signed solve()
{
	int a, b;
	cin >> a >> b;
	print(a*b % 2 == 0 ? "Even" : "Odd");
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


Measured memory_bytes: 256
S = raw_input()
A = 'AKIHABARA'
used = False
p = 0

for i in xrange(len(A)):
    if p < len(S) and S[p] == A[i]:
        p += 1
        used = False
    elif not used and A[i] == 'A':
        used = True
    else:
        print 'NO'
        exit()

if p == len(S):
    print 'YES'
else:
    print 'NO'


Measured memory_bytes: 2568
H, N = map(int, input().split())
#Cost[hp] ... min magic cost if reduced hp is m
cost = [float('inf')] * (H+1)
cost[0] = 0
magics = [tuple(map(int, input().split())) for _ in range(N)]
for hp in range(0, H+1):
    now_cost = cost[hp]
    for a, b in magics:
        reduced_hp = a+hp
        if a + hp > H:
            reduced_hp = H
        cost[reduced_hp] = min(cost[reduced_hp], now_cost+b)
print(cost[H])


Measured memory_bytes: 43100
x, y = map(int, input().split())
l = []
if x <= y:
    l.append(y - x)
if -x <= y: # 最初に1回符号反転
    l.append(y + x + 1)
if x <= -y: # 最後に1回符号反転
    l.append(-y - x + 1)
if -x <= -y: # 両方符号反転
    l.append(-y + x + 2)

ans = min(l)
print(ans)


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

typedef long lint;
typedef long long llint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }


int main(void) {
    int n, m;
    cin >> n >> m;

    vector<int> a(m);
    int ans = n;
    for(int im=0;im<m;im++) {
        cin >> a.at(im);
        ans -= a.at(im);
    }

    if(ans<0) ans=-1;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3624
/* include c++ libraries */
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <map>
#include <queue>
#include <set>

/* include c-lang libraries */
#include <climits>
#include <cmath>

/* include my libraries */
//#include <show_vec.hh>

using namespace std;

#define LINE DEBUG{ printf("LINE : %d\n", __LINE__); }
#define DEBUG if(false)

using ll = long long;
template<class T> using vec = vector<T>;

const int MOD = 1000000007;

int main(){

  ll X, K, D;
  int plus = 1;
  cin >> X >> K >> D;
  if(X < 0){
    X = -1*X;
    plus = -1;
  }

  ll Y = X / D;

  if(K <= Y){
    //cout << X - K*D << endl;
    X = X - K*D;
  }else{
    // K > Y
    if((K-Y)%2 == 0){
      X = X - Y*D;
    }else{
      X = abs(X - (Y+1)*D);
    }
  }
  cout << X << endl;

  return 0;
}


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

#define f first
#define s second
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int N = (int)2e5 + 123, inf = 1e9, mod = 1e9 + 7;
const ll INF = 1e18;

int n, k, p[N], ans, a[N << 2], b[N << 2], last, OK, t[N << 2];
void build(int v, int tl, int tr){
	if(tl == tr){
		a[v] = b[v] = p[tl];
		t[v] = 1;
		return;
	}
	int tm = (tl + tr) >> 1;
	build(v << 1, tl, tm);
	build(v << 1 | 1, tm + 1, tr);       
	a[v] = min(a[v << 1], a[v << 1 | 1]);
	b[v] = max(b[v << 1], b[v << 1 | 1]);
	t[v] = ((t[v << 1] & t[v << 1 | 1]) & (b[v << 1] < a[v << 1 | 1]));
}
int f(int v, int tl, int tr, int l, int r){
	if(r < tl | tr < l)
		return inf;
	if(l <= tl && tr <= r)
		return a[v];
	int tm = (tl + tr) >> 1;
	return min(f(v << 1, tl, tm, l, r), f(v << 1 | 1, tm + 1, tr, l, r));  
}
int g(int v, int tl, int tr, int l, int r){
	if(r < tl | tr < l)
		return -inf;
	if(l <= tl && tr <= r)
		return b[v];
	int tm = (tl + tr) >> 1;
	return max(g(v << 1, tl, tm, l, r), g(v << 1 | 1, tm + 1, tr, l, r));  
}
void get(int v, int tl, int tr, int l, int r){
	if(r < tl | tr < l)
		return;
	if(l <= tl && tr <= r){
		OK &= t[v];
		OK &= (last < a[v]);
		last = b[v];
		return;
	}
	int tm = (tl + tr) >> 1;
	get(v << 1, tl, tm, l, r);
	get(v << 1 | 1, tm + 1, tr, l, r);  
}
bool GET(int l, int r){
	last = -inf;
	OK = 1;
	get(1, 0, n - 1, l, r);
	return OK;
}
int main()
{
	scanf("%d%d", &n, &k);
	for(int i = 0; i < n; i++)
		scanf("%d", &p[i]);
	build(1, 0, n - 1);
	int ans = n - k + 1;
	bool ok = 0;
	for(int i = 0; i + k - 1 < n; i++){
		int l = i, r = i + k - 1;
		if(GET(l, r)){
			if(ok)
				ans--;
			ok = 1;
		}else if(i > 0 && f(1, 0, n - 1, l - 1, r - 1) == p[l - 1] && g(1, 0, n - 1, l, r) == p[r]){
			ans--;
		}
	}

	printf("%d", ans);
	return 0;
}


Measured memory_bytes: 9472
#include <stdio.h>

int main()
{
    int input;
    scanf("%d", &input);
    int a, b, c;
    a = input/100;
    b = input%100/10;
    c = input%100%10;
    
    if(a == 7 || b == 7 || c == 7)
    {
        printf("Yes\n");
    } else
    {
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 1608
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <set>
using namespace std;

int main(){
    string ans;
    int iniarray[5];
    for (int i = 0; i < 5; i++)
    {
        cin >> iniarray[i];
    }
    int maxdiff;
    cin >> maxdiff;
    sort(iniarray, iniarray+4);
    int diff;
    diff = iniarray[4] - iniarray[0];
    if (diff <= maxdiff)
    {
        ans = "Yay!";
    }
    else
    {
        ans = ":(";
    }
        
    cout << ans;
    return 0;

    
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define int long long
#ifndef FAST_IO
  #define IOS ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
#endif
#define ff first
#define ss second
#define endl "\n"
#define all(c) c.begin(),c.end()
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" "; cout<<endl;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void solve(){
   string s,a;
   cin>>s;
   int ans=INT_MAX;
   for(int i=0;i<=(int)s.size()-3;i++){
	   a+=s[i];
	   a+=s[i+1];
	   a+=s[i+2];
	   int x=stoi(a);
	   //cout<<x<<endl;
	   ans=min(ans,abs(753-x));
	   a.clear();
	 }
	 cout<<ans<<endl;
}
int32_t main(){
   IOS;
   solve();
   //debug();
  #ifdef LOCAL_DEFINE
   cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
  #endif	
}


Measured memory_bytes: 256
import java.util.TreeMap;
import java.util.Map;
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Map<String, Integer> map = new TreeMap<>();
		int max = 0;
		for(int i=0;i<n;i++){
			String s = sc.next();
			int c = 0;
			if(map.containsKey(s)){
				c = map.get(s);
			}
			map.put(s, ++c);
			if(max<c){
				max = c;
			}
		}
		sc.close();
		int com = max;
    	// 出現回数最大に一致するものだけ
		map.entrySet().stream()
			.filter(s -> s.getValue()==com)
        	.forEach(s -> System.out.println(s.getKey()));
	}
}


Measured memory_bytes: 85708
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
    int n,m;
    cin >> n;
    vector<string> s(n);
    for (int i=0;i<n;i++) cin >> s[i];
    cin >> m;
    vector<string> t(m);
    int ans = 0;
    for (int i=0;i<m;i++) cin >> t[i];
    for (int i=0;i<n;i++){
        int s_cnt = count(s.begin(),s.end(),s[i]);
        int t_cnt = count(t.begin(),t.end(),s[i]);
        ans = max(ans,(s_cnt -t_cnt));
    }   
    cout << ans << endl;
    
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

num = [1 for i in range(1000001)]
ans_list = [0 for i in range(1000001)]
for i in range(N):
    now = A[i]
    if ans_list[now] == 2:
        continue
    elif ans_list[now] == 1:
        ans_list[now] = 2
    else:
        ans_list[now] = 1
    for j in range(2*now, 1000001, now):
        num[j] = 0

count = 0
for i in range(N):
    now = A[i]
    if num[now] == 1 and ans_list[now] == 1:
        count += 1
        
print(count)

Measured memory_bytes: 167612
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
  int w, h, x, y, r;
  cin >> w >> h >> x >> y >> r;

  if ( x >= r && y >= r
       && x <= w-r && y <= h-r )
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 1160
import numpy as np 

N = int(input())
C = [int(i) for i in input().split()]
V = [int(i) for i in input().split()] 
X = 0
Y = 0
for n in range(N):
	if(C[n]>V[n]):
		X += C[n]
		Y += V[n]

print(X-Y)



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

#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <fstream>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define ll long long int
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n) for(int i=0;i<n;++i)
#define FOREACH(x, a) for(auto& (x) : (a))
#define ALL(a) (a).begin(),(a).end()
#define COUT(x) out << (x) << endl;

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

using namespace std;


class DDigitsParade {
public:
    ll T[13][100000];
    string S;

    void solve(std::istream& in, std::ostream& out) {
        REP(i, 13) REP(j, 100000) T[i][j] = 0;
        in >> S;

        if (S[0] == '?') FOR(i, 0, 10) T[i][0]++;
        else T[S[0] - '0'][0]++;

        FOR(i, 1, S.length()) {
            if (S[i] == '?') {
                FOR(num, 0, 10) FOR(res, 0, 13) {
                        T[(res * 10 + num) % 13][i] += T[res][i - 1];
                        T[(res * 10 + num) % 13][i] %= MOD;
                    }
            }
            else {
                int num = S[i] - '0';
                FOR(res, 0, 13) {
                    T[(res*10+num)%13][i] += T[res][i-1];
                    T[(res*10+num)%13][i] %= MOD;
                }
            }
        }

        COUT(T[5][S.length()-1]);
    }
};


int main() {
    DDigitsParade solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 10624
def c_sugar_water(A, B, C, D, E, F):
    x = set()  # 水の量が取りうるパターン
    y = set()  # 砂糖の量が取りうるパターン
    for i in range(F // 100 + 1):
        for j in range(F // 100 + 1):
            tmp = 100 * A * i + 100 * B * j
            if tmp <= F:
                x.add(tmp)
    for i in range(F):
        for j in range(F):
            tmp = C * i + D * j
            if tmp <= F:
                y.add(tmp)

    concentration = 0  # 砂糖水の濃度
    tmp = [0, 0]
    for water in x:
        for sugar in y:
            if water == 0 and sugar == 0:
                # 水も砂糖も入れないパターン
                continue
            elif E * (water // 100) < sugar:
                # 砂糖を溶かしきれない
                continue
            elif water + sugar > F:
                # ビーカーに入れられる質量を超えた
                continue
            else:
                if (100 * sugar) / (water + sugar) >= concentration:
                    concentration = (100 * sugar) / (water + sugar)
                    tmp = [water + sugar, sugar]
    ans = '{} {}'.format(tmp[0], tmp[1])
    return ans

A,B,C,D,E,F = [int(i) for i in input().split()]
print(c_sugar_water(A, B, C, D, E, F))

Measured memory_bytes: 3188
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define ALL(a) a.begin(), a.end()
typedef long long ll;
const int INF = 100100100;
using namespace std;

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

    int a, b, k;
    cin >> a >> b >> k;

    vector<int> co;
    FOR(i, 1, max(a, b) + 1) {
        if (a % i == 0 && b % i == 0)
            co.push_back(i);
    }
    int ans = co[co.size() - k];
    cout << ans << endl;

    return 0;
}

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

using namespace std;

int d[450][450];

void solve() {
    int n; cin >> n;
    int k = 1;
    auto c2 = [](int x){
        return x*(x-1)/2;
    };
    while (c2(k) < n) {
        k++;
    }
    if (c2(k) != n) {
        cout << "No"; return;
    }
    int edge_cnt = 1;
    for (int i = 0; i < k; i++) {
        for (int j = i+1; j < k; j++) {
            d[i][j] = d[j][i] = edge_cnt++;
        }
    }

    cout << "Yes\n";
    cout << k << "\n";
    for (int i = 0; i < k; i++) {
        cout << (k-1) << ' ';
        for (int j = 0; j < k; j++) {
            if (i != j) {
                cout << d[i][j] << ' ';
            }
        }cout << "\n";
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 2176
def aux(f)
  p=[]   # inbetween
  q=[]   # output
  while f.length > 0
    x=f.shift
    if (x=="0")
      q.push(p.pop)
    else
      p.push(x)
    end
  end
  q
end

def main
  fh=STDIN
  #fh=File.new("vol0-0013.txt", "r")
  seq=[]
  while fh.gets
    seq.push($_.chomp)
  end
  puts aux(seq)
end

if $0 == __FILE__ then
  main
end


Measured memory_bytes: 6860
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
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(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

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

	vector<int> a(n+2);

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

	LL sum = 0;
	for (int i = 0; i < n + 1; i++) {
		sum += abs(a[i] - a[i + 1]);
	}

	for (int i = 1; i < n+1; i++) {
		LL tmp = sum - abs(a[i] - a[i - 1]) - abs(a[i] - a[i + 1]) + abs(a[i - 1] - a[i + 1]);
		cout << tmp << endl;
	}
}
	


Measured memory_bytes: 1664
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args)throws IOException{
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader reader = new BufferedReader(isr);
		String string;
		int h, w, n, c, v;
		
		while(!(string = reader.readLine()).equals("0 0")){
			h = Integer.parseInt(string.split(" ")[0]);
			w = Integer.parseInt(string.split(" ")[1]);
			
			int[][] array = new int[h + 1][w + 1];
			boolean[][] imp = new boolean[h + 1][w + 1];
			
			n = Integer.parseInt(reader.readLine());
			for(int i = 0; i < n; i++){
				string = reader.readLine();
				c = Integer.parseInt(string.split(" ")[0]);
				v = Integer.parseInt(string.split(" ")[1]);
				imp[c][v] = true;
			}
			
			array[1][1] = 1;
			for(int i = 1; i <= h; i++){
				for(int j = 1; j <= w; j++){
					if(!imp[i][j]){
						array[i][j] = array[i][j - 1] + array[i - 1][j];
						if(i == 1 && j == 1) array[i][j] = 1;
					}else{
						array[i][j] = 0;
					}
				}
			}
			System.out.println(array[h][w]);
		}
		reader.close();
	}
}

Measured memory_bytes: 24208
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
   int n,m;
   cin>>n>>m;
   int a,b;
   int d[50]={};
   for(int i=0;i<m;i++){
       cin>>a>>b;
       d[a-1]++;
       d[b-1]++;
   }
   for(int i=0;i<n;i++){
       cout<<d[i]<<endl;
   }
    return 0;

}


Measured memory_bytes: 256
// ITP1_7_D Matrix Multiplication
import java.io.*;

public class Main {

   public static void main(String[] args) {
      try {
         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
         String strAry0[] = br.readLine().split(" ");
         int n = Integer.parseInt(strAry0[0]);
         int m = Integer.parseInt(strAry0[1]);
         int l = Integer.parseInt(strAry0[2]);
         int[][] A = new int[n][m];
         int[][] B = new int[m][l];
         long[][] C = new long[n][l];

         for (int i = 0; i < n; i++) {
            String strAry1[] = br.readLine().split(" ");
            for (int j = 0; j < m; j++) {
               A[i][j] = Integer.parseInt(strAry1[j]);
            }
         }

         for (int i = 0; i < m; i++) {
            String strAry2[] = br.readLine().split(" ");
            for (int j = 0; j < l; j++) {
               B[i][j] = Integer.parseInt(strAry2[j]);
            }
         }

         for (int i = 0; i < n; i++) {
            for (int j = 0; j < l; j++) {
               for (int k = 0; k < m; k++) {
                  C[i][j] += (A[i][k] * B[k][j]);
               }
            }
         }

         for (int i = 0; i < n; i++) {
            for (int j = 0; j < l; j++) {
               System.out.print(j < l - 1 ? C[i][j] + " ": C[i][j] + "\n");
            }
         }
      }

      catch (Exception e) {
         System.err.println(e);
      }
   }
}

Measured memory_bytes: 28812
import sys
from collections import deque
from copy import copy

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: map(int, read().split())


def bfs_grid(H, W, s, grid):

    q = deque(s)
    move = [(-1, 0), (1, 0), (0, -1), (0, 1)]
    ans = 0

    while True:

        nq = deque()
        f = False
        while q:
            now = q.popleft()
            x, y = now
            for m in move:
                nx, ny = x + m[0], y + m[1]
                if 0 <= nx < W and 0 <= ny < H:
                    if grid[ny][nx]:
                        f = True
                        grid[ny][nx] = False
                        nq.append((nx, ny))

        if f:
            ans += 1
        if nq:
            q = nq
        else:
            break

    return ans


def main():

    H, W = in_nn()
    grid = in_map2(H)

    s = []
    for y in range(H):
        for x in range(W):
            if not grid[y][x]:
                s.append((x, y))

    if len(s) == H * W:
        print(0)
        exit()

    print(bfs_grid(H, W, s, grid))


if __name__ == '__main__':
    main()


Measured memory_bytes: 159592
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

void solve() {
    const int d = 28;
    ll n;
    cin >> n;
    vll a(n), b(n);
    for(ll i = 0; i < n; i++) cin >> a[i];
    for(ll i = 0; i < n; i++) cin >> b[i];
    vvll v(d, vll(n));
    for(ll i = 0; i < d; i++) {
        ll mask = (1 << (i + 1)) - 1;
        for(ll j = 0; j < n; j++) v[i][j] = a[j] & mask;
        sort(v[i].begin(), v[i].end());
    }
    vll cnt(d + 1);
    for(ll i = 0; i < d; i++) {
        ll mask = (1 << (i + 1)) - 1;
        for(ll j = 0; j < n; j++) {
            ll _b = b[j] & mask;
            ll l = lower_bound(v[i].begin(), v[i].end(), (1 << i) - _b) - v[i].begin();
            ll r = upper_bound(v[i].begin(), v[i].end(), mask - _b) - v[i].begin();
            ll k = lower_bound(v[i].begin(), v[i].end(), (1 << i) + mask + 1 - _b) - v[i].begin();
            cnt[i] += r - l + n - k;
        }
    }
    for(ll j = 0; j < n; j++) {
        ll l = lower_bound(v[d-1].begin(), v[d-1].end(), (1 << d) - b[j]) - v[d-1].begin();
        cnt[d] += n - l;
    }
    ll ans = 0;
    for(ll i = 0; i <= d; i++) {
        if(cnt[i] % 2) ans += 1 << i;
    }
    cout << ans << endl;
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 48768
#pragma comment(linker, "/stack:200000000")
        #pragma GCC optimize ("Ofast")
        #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
        #include <iostream>
        #include <iomanip>
        #include <sstream>
        #include <cstring>
        #include <vector>
        #include <deque>
        #include <queue>
        #include <set>
        #include <map>
        #include <valarray>
        #include <iterator>
        #include <functional>
        #include <limits>
        #include <algorithm>
        #include <numeric>
        #include <cmath>
        #include <cassert>
        #include <unordered_map>
        #include <unordered_set>
        #include <stack>
        using namespace std;
        #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
         #define trace(x) cerr << #x << ": " << x << " " << endl;
     
        typedef int64_t ll;
     
        #define endl '\n'
        #define int ll
        ll mod=998244353;
        ll mod1=1e9+5;
        ll power(ll a,ll b)
        {
            if(b==0) return 1;
            else if(b%2==0)
                return power((((a%mod)*(a%mod))%mod),b/2)%mod;
            else return ((a%mod)*(power((((a%mod)*(a%mod))%mod),b/2)%mod))%mod;
        }
     int32_t main()
        {
            IOS
      
        
        int n;
        cin>>n;
        int a[n];
        int c=0;
        for(int i=0;i<n;++i)
        {

            cin>>a[i];
            if(a[i]==0)
                c++;
        }
        
        if(c!=1 or a[0]!=0)
        {
            cout<<0;
            return 0;
        }
        map<int,int> m;
        for(int i=0;i<n;++i)
            m[a[i]]++;
        int ans=1;
        for(auto i:m)
        {
            int tex=i.first;
            int pex=i.second;
            if(tex==0)
                continue;
            else
            {
                int q=m[tex-1];
                if(q==0)
                {
                    cout<<0;
                    return 0;
                }
                
                ans=ans*power(q,pex);
                ans%=mod;
            }

        }
        cout<<ans;


        }

Measured memory_bytes: 7296
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

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

  ll N, M; std::cin >> N >> M;
  std::vector<ll> A(N);
  rep(i,N) std::cin >> A[i];
  std::sort( all(A) );

  // [i, j) : S[j] = A[j-1] + A[j-2] + ... + A[i] + A[i-1] + ... + A[0]
  //          S[i] =                              + A[i-1] + ... + A[0]
  // S[j] - S[i] = A[i] + ... + A[j-1]
  std::vector<ll> S(N+1, 0);
  rep(i,N) S[i+1] = S[i] + A[i];

  ll l = 0, r = (1LL<<62);
  while( l+1 < r ) {
    ll mid = (l+r)/2;
    ll cnt = 0;
    rep(i, N) {
      int num = std::distance( A.begin(), std::lower_bound(all(A), mid-A[i]) );
      cnt += (N-num);
    }
    if ( cnt <= M ) r = mid;
    else l = mid;
  }

  ll ans = 0;
  ll cnt = 0;
  rep(i, N) {
    int num = std::distance( A.begin(), std::upper_bound(all(A), l-A[i]) );
    ans += (S[N] - S[num]) + A[i]*(N-num);
    cnt += (N-num);
  }
  std::cout << ans + l*(M-cnt) << std::endl;
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;

ll MOD = 1000000007;

ll fact(ll a) {
  if (a == 1) {
    return a;
  }
  return a * fact(a-1) % MOD;
}

int main() {
  ll N, M;
  cin >> N >> M;
  ll ans = 0;
  ll diff = abs(N-M);
  if (diff == 1) {
    ans = fact(N) * fact(M);
  } else if (diff == 0) {
    ans = fact(N) * fact(M) * 2;
  } else {
    ans = 0;
  }
  cout << ans % MOD << endl;
}

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

void open() {
	freopen("duliu.in", "r", stdin);
	freopen("duliu.out", "w", stdout);
}

const int MAXN = 100000 + 5;

int N, A[MAXN], B[MAXN];
std::map<int, int> Cnt, M;
std::set<int> S;

int num, Fa[MAXN];

int findFa(int x) {
	return Fa[x] == x ? x : Fa[x] = findFa(Fa[x]);
}

void merge(int x, int y) {
	x = findFa(x), y = findFa(y);
	if (x == y) {
		return ;
	}
	Fa[y] = x;
	--num;
}

int main() {
	// open();
	scanf("%d", &N);
	int x = 0;
	for (int i = 1; i <= N; ++i) {
		scanf("%d", &A[i]);
		Cnt[A[i]]++;
		x ^= A[i];
	}
	Cnt[x]++;
	S.insert(x);
	for (int i = 1; i <= N; ++i) {
		scanf("%d", &B[i]);
		if (--Cnt[B[i]] < 0) {
			puts("-1");
			return 0;
		}
		if (A[i] != B[i]) {
			S.insert(A[i]);
			S.insert(B[i]);
		}
	}
	int cnt = 0;
	for (std::set<int>::iterator p = S.begin(); p != S.end(); ++p) {
		M[*p] = ++cnt;	
	}
	int ans = 0;
	for (int i = 1; i <= N; ++i) {
		if (A[i] != B[i]) {
			if (!Fa[M[A[i]]]) {
				Fa[M[A[i]]] = M[A[i]];
				++num;
			}
			if (!Fa[M[B[i]]]) {
				Fa[M[B[i]]] = M[B[i]];
				++num;
			}
		}
	}
	if(!Fa[M[x]]) {
		Fa[M[x]] = M[x];
		++num;
	}
	for (int i = 1; i <= N; ++i) {
		if (A[i] != B[i]) {
			merge(M[A[i]], M[B[i]]);
			++ans;
		}
	}
	ans += num;
	printf("%d\n", ans - 1);
	return 0;
}

Measured memory_bytes: 15488
#include<bits/stdc++.h>
using namespace std;
int a,b[1000002],ans,ans1,q,qq,tot,tot1;
int c[1000002],d[1000002];
int main(){
	cin>>a;
	for(int i=1;i<=a;i++){
		cin>>b[i];
		if(i%2==1){
			 c[b[i]]++;
			 if(ans<c[b[i]])
			 	ans=c[b[i]],q=b[i];
		}
		else{
			d[b[i]]++;
			if(ans1<d[b[i]])
				ans1=d[b[i]],qq=b[i];
		}
	}
	if(q==qq){
		for(int i=1;i<=1000000;i++)
			if(i!=q) 
				tot=max(tot,c[i]);
		for(int i=1;i<=1000000;i++)
			if(i!=qq) 
				tot1=max(tot1,d[i]);
		cout<<a-max(ans1+tot,ans+tot1);
	}
	else cout<<a-(ans+ans1);
	return 0;
}


Measured memory_bytes: 8832
MOD = 10**9+7
MAX = 2*(10**5)+1
fac = [1 for i in range(MAX)]
finv = [1 for i in range(MAX)]
inv = [1 for i in range(MAX)]
b,w = map(int,input().split())
if (b >= w):
    flag = 0
else:
    flag = 1
    b,w = w,b

for i in range(2,MAX):
    fac[i] = fac[i-1]*i%MOD
    inv[i] = MOD - inv[MOD%i]*(MOD // i)%MOD
    finv[i]=finv[i-1]*inv[i]%MOD

def com(n,k):
    if(n < k): return 0
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD

def pow(n,k,m):#n^k mod m
    ans = 1
    while k>0:
        if(k & 1):ans = (ans*n) % m
        n = (n*n)%m
        k >>= 1
    return ans

for i in range(w):
    print(inv[2])

p1 = 1
p2 = 0
for i in range(1,w+1):
    p2 = (p2+ com(w,i)) % MOD

deno = pow(inv[2],w,MOD)
denodeno = pow(2,w,MOD)
for i in range(b-w):
    p1 = (p1*2)%MOD
    deno = (deno* inv[2]) % MOD
    denodeno = (denodeno*2) % MOD
    if(flag == 0):print(((p1+p2)*deno)%MOD)
    else : print(((denodeno-p1-p2)*deno)%MOD)
    p2 = (p2*2-com(w+i,i+1)) % MOD
    p1 = (p1+com(w+i,i+1)) % MOD
    
    


p2 -= 1

for i in range(b+1,b+w+1):
    p1 *= 2
    deno = (deno* inv[2]) % MOD
    denodeno = (denodeno*2) % MOD
    if(flag == 0):print(((p1+p2)*deno)%MOD)
    else : print(((denodeno-p1-p2)*deno)%MOD)
    p1 = (p1+com(i-1,w-1)) % MOD
    p2 = (p2*2-com(i-1,w-1)-com(i-1,i-b)) % MOD

Measured memory_bytes: 59852
#include <stdio.h>

int main(void){
    int y, m, d;

    scanf("%d/%d/%d", &y, &m, &d);

    if(y == 2019){
        if(m <= 4){
            printf("Heisei\n");
        }else{
            printf("TBD\n");
        }
    }else{
        if(y < 2019){
            printf("Heisei\n");
        }else{
            printf("TBD\n");
        }
    }
}

Measured memory_bytes: 128
class dice:
    # top,down,right,left,up,back
    def rota(self, direction):
        if direction == "E":
            self.surface = [self.surface[3], self.surface[1], self.surface[0],
                            self.surface[5], self.surface[4], self.surface[2]]
        if direction == "W":
            self.surface = [self.surface[2], self.surface[1], self.surface[5],
                            self.surface[0], self.surface[4], self.surface[3]]
        if direction == "S":
            self.surface = [self.surface[4], self.surface[0], self.surface[2],
                            self.surface[3], self.surface[5], self.surface[1]]
        if direction == "N":
            self.surface = [self.surface[1], self.surface[5], self.surface[2],
                            self.surface[3], self.surface[0], self.surface[4]]


dice1 = dice()
dice1.surface = list(map(int, input().split()))

for i in input():
    dice1.rota(i)
print(dice1.surface[0])



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

using namespace std; 
#define REP(i, n) for (int i = 0; i < (n); i++)

typedef long long ll;
int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    double L; cin >> L;
    double x = L/3;
    cout << fixed << setprecision(7) << x * x * x << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
    #include <vector>
    #include <algorithm>
    #include <numeric>
     
    using namespace std;
     
    int main() {
      int a1,b1;
      cin >> a1 >> b1;
      int a2,b2;
      cin >> a2 >> b2;
      int a3,b3;
      cin >> a3 >> b3;
     
      if (a1==a2 || a1==b2) {
        if(a1==a3 || a1 ==b3){
          cout << "NO" << endl;
          return 0;
        }
      }
      
      if (b1==a2 || b1==b2) {
        if(b1==a3 || b1 ==b3){
          cout << "NO" << endl;
          return 0;
        }
      }
      
      cout << "YES" << endl;
      return 0;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> PP;
int ast,game[4][4];

bool ex(int t){return game[t][t]>=0;}
bool eq(PP a,PP b){return a.f==b.f&&a.s.f==b.s.f;}

int score(int t){
  if(game[t][t]<0)return -1000;
  int res=0;
  for(int i=0;i<4;i++) {
    if(!ex(i))continue;
    int a=game[t][i],b=game[i][t];
    res+=(a>b)*3+(a==b);
  }    
  return res;
}

int goal(int t){
  int res=0;
  for(int i=0;i<4;i++)res+=game[t][i]*ex(i);
  return res;
}

int ngoal(int t){
  int res=0;
  for(int i=0;i<4;i++)res+=game[i][t]*ex(i);
  return res;
}

int nCr(int n,int r){
  int a=1,b=1;
  for(int i=0;i<r;i++)a*=(n-i),b*=(i+1);
  return a/b;
}
double calc(double p){return nCr(8,p)*pow(1.0/4,p)*pow(3.0/4,8-p);}

double check(int n){
  if(!ex(ast))return 0;
  PP p[4];
  for(int i=0;i<4;i++)
    p[i]=PP(P(score(i),goal(i)-ngoal(i)),P(goal(i),i));
  sort(p,p+4,greater<PP>());
  vector<int>er;

  if(eq(p[0],p[1])){
    double cnt=0;
    for(int i=0;i<4;i++){
      if(!eq(p[0],p[i])&&ex(p[i].s.s))er.push_back(p[i].s.s);
      cnt+=ex(i);
    }
    if(!er.size())return n/cnt;
  }
  else if(n==2&&eq(p[1],p[2])){
    if(p[0].s.s==ast)return 1;
    for(int i=0;i<4;i++)
      if(!eq(p[1],p[i])&&ex(p[i].s.s))er.push_back(p[i].s.s);
  }
  else return p[0].s.s==ast||(n==2&&p[1].s.s==ast);

  for(int i=0;i<er.size();i++)game[er[i]][er[i]]=-1;
  double res=check(n-!eq(p[0],p[1]));
  for(int i=0;i<er.size();i++)game[er[i]][er[i]]=0;
  return res;
}

vector<int> x,y;
double dfs(int idx){
  if(idx==4)return check(2);
  double res=0;
  for(int i=0;i<=8;i++){
    game[y[idx]][x[idx]]=i;
    res+=dfs(idx+1)*calc(i);
  }
  return res;
}

int main(){
  int T;
  cin>>T;
  while(T--){
    x.clear(),y.clear();
    memset(game,-1,sizeof(game));
    for(int i=0;i<4;i++) game[i][i]=0;

    string mp[5];
    for(int i=0;i<5;i++)cin>>mp[i];
    for(int i=0;i<4;i++)if(mp[0][5+5*i]=='*')ast=i;
    
    for(int i=0;i<4;i++)
      for(int j=i+1;j<4;j++) {
	int a=mp[i+1][5+5*j+1]-'0',b=mp[i+1][5+5*j+3]-'0';
	if(a=='_'-'0'){
	  x.push_back(i),y.push_back(j);
	  x.push_back(j),y.push_back(i);
	}
	else game[i][j]=a,game[j][i]=b;
      }
    printf("%.8f\n",dfs(0));
  }
  return 0;
}

Measured memory_bytes: 3300
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define EPS 1e-9
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {

    int h,w;
    cin >> h >> w;
    vs s(h);
    rep(i,h)cin >> s[i];
    int ans = 0;
    rep(a,h)rep(b,h)rep(c,w)rep(d,w){
        if(a > b && c > d)continue;
        if(s[a][c] == 'B' && s[b][d] == 'B'){
            //cout << a << " " << b << " " << c << " " << d << endl;
            ans = max(ans, abs(b-a)+abs(c-d));
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 3240
#include <stdio.h>
#include <vector>

using namespace std;

#define MAX_N (1000010)
int Array[MAX_N];
vector<int> G;

typedef long long int ll;

static
void
insertionSort( int A[], int n, int g );


static
void
shellSort( int A[], int n );


static
void
printArray( int A[], int n );

ll count = 0;

int main()
{
    int i;
    int N;
    scanf("%d", &N);
    for ( i = 0; i < N; i++ ) {
	scanf("%d", &Array[i]);
    }
    
    shellSort( Array, N );

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

    for ( i = G.size() - 1; i >= 0; i-- ) {
	printf("%d%c", G[i], ( i == 0 ) ? '\n' : ' ' );
    }
    
    printf("%lld\n", count);
    
    printArray( Array, N );

    return 0;
}



static
void
insertionSort( int A[], int n, int g )
{
    int i;

    for ( i = g; i < n; i++ ) {
	int v = A[i];
	int j = i - g;
	
	while ( j >= 0 && A[j] > v ) {
	    A[j+g] = A[j];
	    j = j - g;
	    count++;
	}

	A[j+g] = v;
    }
}


static
void
shellSort( int A[], int n )
{
    int i;
    int h = 1;
    while ( true ) {
	if ( h > n ) break;
	G.push_back( h );
	h = 3 * h + 1;
    }
    
    for ( i = G.size() - 1; i >= 0; i-- ) {
	insertionSort( A, n, G[i] );
    }
    
}

static
void
printArray( int A[], int n )
{
    int i;
    for ( i = 0; i < n; i++ ) {
	printf("%d\n", A[i] );
    }
}

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

int main() {
	int n,k;
	cin>>n>>k;
	long long ans, t = 1ll*n/k;
	ans = t*t*t;
	t = 0;
	if(k%2 == 0){
		for(int i = k/2; i<=n; i += k)	t++;
	}
	cout<<ans + t*t*t;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	void doIt() {
		Scanner stdIn = new Scanner(System.in);
		while(true) {
			int limit = stdIn.nextInt();
			if(limit == 0) break;
			limit++; //漏洩情報も格納する
			int[][] member = new int[limit][];
			for(int r = 0; r < limit; r++) {//入力
				int num = stdIn.nextInt();
				member[r] = new int[num];
				for(int c = 0; c < num; c++) {
					member[r][c] = stdIn.nextInt();
				}
			}
			int idx = -1;//出力される構成員番号
			int lastLen = member[member.length - 1].length; //漏洩情報の長さ取得が複雑なので変数にする
			boolean complete = false; //見終わった？
			for(int r = 0; r < member.length - 1; r++) {
				boolean[] check = new boolean[lastLen];//数字列のチェック
				boolean flag = false; //見つかった？
				for(int c = 0; c < member[r].length; c++) {
					for(int k = 0; k < lastLen; k++) {//漏洩走査
						if(member[member.length - 1][k] == member[r][c]) {//漏洩情報を持っているならば
							check[k] = true;//持っている事を記憶
						}
					}
				}
				for(int k = 0; k < lastLen; k++) {
					if(!check[k]) {//１個でも、見つからなかった値があったら
						flag = false;//flagをfalseに更新して
						break;//抜け出し
					}
					flag = true;//flagにtrueを入れ続ける
				}
				if(flag) { //もし漏洩情報と構成員の持つ情報が全て一致したら
					if(!complete) {//終わってないなら
						idx = r + 1;//構成員番号を登録
						complete = true; //終わった事を保持
					} else { //もう終わってるならば
						idx = -1;//2人以上の構成員が持つ事を許さないので-1に更新
					}
				}
			}
			System.out.println(idx);
		}
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new Main().doIt();
	}

}

Measured memory_bytes: 62688
n, a, b = map(int, raw_input().split())
s = raw_input()

ca = 0
cb = 0
ans = [0]*n
for i in xrange(n):
    if ca+cb == a+b:
        break
    if s[i] == 'a':
        ca += 1
        ans[i] = 1
    if s[i] == 'b' and cb < b:
        cb += 1
        ans[i] = 1
for i in xrange(n):
    if ans[i]:
        print "Yes"
    else:
        print "No"


Measured memory_bytes: 3844
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

void solve()
{
	vector<int> size(3);
	while(cin >> size[0] >> size[1] >> size[2], size[0] || size[1] || size[2])
	{
		sort(size.begin(), size.end());
		double diagonal = sqrt((double)size[0] * size[0] + size[1] * size[1]);
		int n;
		cin >> n;
		for(int i = 0; i < n; ++i)
		{
			int a;
			cin >> a;
			if(2 * a > diagonal)
			{
				cout << "OK" << endl;
			}
			else
			{
				cout << "NA" << endl;
			}
		}
	}
}

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

Measured memory_bytes: 1204
import bisect as bi
N=int(input())
L=list(map(int,input().split()))

count=0
l=sorted(L)
#print(l)
for i in range(N-2):
    for j in range(i+1,N-1):
        count+=bi.bisect_left(l,l[i]+l[j],j+1)-j-1
         
print(count)

Measured memory_bytes: 3188
n=int(input())
xy=[]
for _ in range(n):
	x,y=map(int,input().split())
	xy.append([x,y])
ans=0
for i in range(n):
	for j in range(n):
		ans+=((xy[i][0]-xy[j][0])**2+(xy[i][1]-xy[j][1])**2)**0.5
print(ans/n)


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

class RMQ{
public:
  typedef long long ll;
  ll INF = 1LL<<55;
  int n,n_;
  vector<ll> dat;
  int toMax;

  //初期化
  RMQ(){n=-1;}
  RMQ(int n_,int toMax = 0):n_(n_),toMax(toMax){
    n=1;
    while(n<n_)n*=2;
    dat.resize(2*n-1,INF);
  }
  
  //k番目の値をaに変更
  void update(int k,ll a){
    if(toMax) a *= -1;
    k+=n-1;
    dat[k]=a;
    while(k>0){
      k=(k-1)/2;
      dat[k]=min(dat[k*2+1],dat[k*2+2]);
    }
  }
  
  //[a,b)の最小値を求める query(a,b,0,0,n)
  ll find(int a,int b,int k,int l,int r){
    if(r<=a||b<=l)return INF;
    if(a<=l&&r<=b)return dat[k];
    ll vl = find(a,b,k*2+1,l,(l+r)/2);
    ll vr = find(a,b,k*2+2,(l+r)/2,r);
    return min(vl,vr);
  }

  ll find(int a,int b){
    assert(a <= b), assert(a <= n_ && b <= n_), assert(a >= 0 && a >= 0);
    return (toMax? -1:1) * find(a,b,0,0,n);
  }
};

int main(){
  int n,q;
  cin>>n>>q;
  RMQ A(n,1);
  for(int i=0;i<n;i++) A.update(i,-((1LL<<31)-1));

  while(q--){
    int com,x,y;
    cin>>com>>x>>y;
    if(com == 0) A.update(x,-y);
    if(com == 1) cout<<-A.find(x,y+1)<<endl;
  }

  return 0;
}




Measured memory_bytes: 4892
// ooooo      ooo                     
// `888b.     `8'                     
//  8 `88b.    8   .ooooo.   .oooo.   
//  8   `88b.  8  d88' `88b `P  )88b  
//  8     `88b.8  888   888  .oP"888  
//  8       `888  888   888 d8(  888  
// o8o        `8  `Y8bod8P' `Y888""8o 
// C++ Conpetitive Programming Template 
// Ver 2.0 (codename: Noa)
// Last Modified : 2019-06-07
// Created       : 2019-05-25
// Auther        : shirataki3
#include <bits/stdc++.h>
using namespace std;
// typename alias
template <class T> using vec = vector<T>;
template <class T, class U> using vep = vec<pair<T,U> >;
template <class T> using PQ = priority_queue<T>;
using ll = long long;
using vll = vec<ll>;
using pll = pair<ll, ll>;
using vpll = vec<pll>;
using str = string;
// あくまのちから
//#define int ll

// const
static const long long INF = 1LL<<59;
static const long long MOD = (ll)1e9+7;
static const double PI = 3.14159265358979323846;

// accelerate stdin, stdout
#define endl "\n"
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
// repeat macro
#define FOR(i, a, b) for(ll (i)=(a);(i)<=(b);i++)
#define rFOR(i, a, b) for(ll (i)=(b);(i)>=(a);i--)
#define REP(i, n) for(ll i=0;i<n;i++)
// vector macro
#define WHOLE(v) (v).begin(), (v).end()
#define ASC(v) sort(WHOLE(v))
#define DESC(v) sort((v).rbegin(), (v).rend())
#define INV(v) reverse(WHOLE(v))
#define FOLDL(src, dst, lambda) partial_sum(WHOLE(src), (dst).begin(), lambda)
#define FOLDR(src, dst, lambda) INV(src);partial_sum(WHOLE(src), (dst).begin(), lambda);INV(dst)
#define CUMSUML(src, dst) FOLDL(src, dst, [](auto a, auto b) {return a+b;})
#define CUMSUMR(src, dst) FOLDR(src, dst, [](auto a, auto b) {return a+b;})
#define ACCUM(v, d0, lambda) accumulate(WHOLE(v), d0, lambda)
#define SUM(v, d0) ACCUM(v, d0, [](auto a, auto b) {return a+b;})
#define ERASE(v, i) v.erase(v.begin() + i)
#define UNIQ(v) ASC(v);v.erase(unique(v.begin(), v.end()), v.end())

// io helper
template <typename T>void debug(T t) {cerr << t << endl;}
template <typename T, typename ...Args>void debug(T t, Args ...args) {cerr << t << " ";debug(args...);}
template <typename T>void out(T t) {cout << t << endl;}
template <typename T, typename ...Args>void out(T t, Args ...args) {cout << t << " ";out(args...);}
template <typename T>istream& operator>>(istream &is, vec<T> &v) {for(auto &a:v) is >> a; return is;}
template <typename T>ostream& operator<<(ostream &os, vec<T> &v) {os << "[";REP(i, v.size() - 1) os << v[i] <<", "; os << v[v.size()-1]<<"]";return os;}
template <typename T, typename U>ostream& operator<<(ostream &os, pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")";return os;}
template <typename T, typename U>ostream& operator<<(ostream &os, map<T, U> &mp) {os << "{ ";for(auto &p:mp) os << p.first << ": " << p.second << ", "; os << "}";return os;}

void solve() {
    str N;
    cin >> N;
    out("ABC" + N);
}

signed main() {
    fast_io;
    cout << setprecision(20) << fixed;
    solve();
    return 0;
}

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

int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll k;
    cin>>k;
    string s;
    cin>>s;
    if(s.size()<=k)
    cout<<s<<endl;
    else
    {
    	s=s.substr(0,k);
    	cout<<s<<"...";
    }
	return 0;
}

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

int main()
{
	ll A;
	double B;
	cin >> A >> B;
	ll B2 = ll((B+0.005) * 100 / 1);
	cout << A * B2 / 100 << endl;
	return 0;
}

Measured memory_bytes: 3720