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

int main(void){
    int N;
    cin >> N;
    vector<int> L(N);
    for(int i=0;i<N;i++) cin >> L.at(i);
    sort(L.begin(), L.end());

    int ans = 0;

    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            if(L.at(i) == L.at(j)) continue;
            for(int k=j+1;k<N;k++){
                if(L.at(i) == L.at(k) || L.at(j) == L.at(k)) continue;
                if( 
//                    (L.at(i) + L.at(j) > L.at(k)) && (abs(L.at(i) - L.at(j)) < L.at(k)) && 
//                    (L.at(j) + L.at(k) > L.at(i)) && (abs(L.at(j) - L.at(k)) < L.at(i)) && 
                    (L.at(k) + L.at(i) > L.at(j)) && (abs(L.at(k) - L.at(i)) < L.at(j))
                ){
//                        cout << L.at(i) << " " << L.at(j) << " " << L.at(k) << endl;
//                        cout << i+1 << " " << j+1 << " " << k+1 << endl;
//                        cout << "----------------------" << endl;
                        ans++;
                    }
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3616
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
using namespace std;

const int Maxn = 2005;

int R, C;
char B[Maxn][Maxn];
int best[Maxn][Maxn][2];
vector <int> proc[Maxn];
int par[Maxn], siz[Maxn], mx;
int res;

int getPar(int x) { return par[x] == x? x: par[x] = getPar(par[x]); }

void unionSet(int a, int b)
{
	a = getPar(a), b = getPar(b);
	if (a == b) return;
	if (siz[a] >= siz[b]) { siz[a] += siz[b]; par[b] = a; mx = max(mx, siz[a]); }
	else { siz[b] += siz[a]; par[a] = b; mx = max(mx, siz[b]); }
}

int main()
{
	scanf("%d %d", &R, &C);
	for (int i = 0; i < R; i++)
		scanf("%s", B[i]);
	for (int i = R - 1; i >= 0; i--)
		for (int j = 0; j + 1 < C; j++) {
			best[i][j][0] = B[i][j] == B[i][j + 1]? 1 + best[i + 1][j][0]: 0;
			best[i][j][1] = B[i][j] != B[i][j + 1]? 1 + best[i + 1][j][1]: 0;
		}
	res = R;
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < Maxn; j++)
			proc[j].clear();
		for (int j = 0; j + 1 < C; j++)
			if (B[i][j] == B[i][j + 1]) proc[best[i][j][0]].push_back(j);
			else proc[best[i][j][1]].push_back(j);
		for (int j = 0; j < C; j++) {
			par[j] = j; siz[j] = 1;
		}
		mx = 1;
		for (int j = Maxn - 1; j > 0; j--) if (!proc[j].empty()) {
			for (int k = 0; k < proc[j].size(); k++)
				unionSet(proc[j][k], proc[j][k] + 1);
			res = max(res, mx * j);
		}
	}
	printf("%d\n", res);
	return 0;
}

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

int main(){
	while(1){
		int n,k,m;
		cin >> n >> k >> m;
		if(n==0) break;
		
		vector<int> stone(n);
		for(int i=0; i<n; i++){ stone[i]=i+1; }
		int now=(m+n-1)%n;
		for(int i=0; i<n-1; i++){
			stone.erase(stone.begin()+now);
			now = (now+k-1)%stone.size();
		}
		cout << stone[0] << endl;
	}
	return 0;
}

Measured memory_bytes: 3048
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

A,B,C=get_i.sort{|x,y| y<=>x}
ab=A-B
ac=A-C
if (ab+ac).even?
  puts (ab+ac)/2
else
  puts (ab+ac+1)/2+1
end


Measured memory_bytes: 1788
import java.util.Arrays;
import java.util.Scanner;

class B {
    public static void main(String...args) {
        final Scanner sc = new Scanner(System.in);
        final int[] cnt = new int[4];
        for(int i = 0; i < 3; i++) {
            cnt[sc.nextInt() - 1] ++;
            cnt[sc.nextInt() - 1]++;
        }
        Arrays.sort(cnt);
        System.out.println(Arrays.equals(cnt, new int[]{1, 1, 2, 2}) ? "YES" : "NO");
    }
}
public class Main {
    public static void main(String...args) {
        B.main();
    }
}


Measured memory_bytes: 23124
#include <iostream>
#include <vector>
#include <deque>
#include <math.h>
#include <set>
#include <iomanip>
#include <time.h>
#include <list>
#include <stdio.h>
#include <queue>
#include <map>
#include <algorithm>
#include <assert.h>
#include <memory.h>

#define mk make_pair
#define sc second
#define fr first
#define pb emplace_back
#define all(s) s.begin(), s.end()
#define sz(s) ( (int)s.size() )

using namespace std;

const int N = 55;

int n, ar[N], cnt[15], pw[N], res;

vector <int> vec, q;

main ()
{
    vec.pb(0);
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &ar[i]);
        cnt[ ar[i] ]++;
    }
    if (cnt[0])
    {
        cout << 0;
        return 0;
    }
    for (int i = 1; i <= 12; i++)
    {
        if(cnt[i] > 2)
        {
            cout << 0;
            return 0;
        }
        if (cnt[i] == 2)
        {
            vec.pb( i );
            vec.pb( 24 - i );
        }
    }
    for (int i = 0; i < n; i++)
        if ( cnt[ ar[i] ] == 1 )
            q.pb( ar[i] );

    n = sz(q);
    for (int i = 0; i < n; i++)
        ar[i] = q[i];

    q = vec;

    pw[0] = 1;
    for (int i = 1; i <= 25; i++)
        pw[i] = pw[i - 1] * 2;

    for (int i = 0; i < pw[n]; i++)
    {
        vec = q;
        for (int j = 0; j < n; j++)
        {
            if ( i & pw[j] )
                vec.pb( 24 - ar[j] );
            else
                vec.pb( ar[j] );
        }

        int ans = 1e9 + 7;

        for (int j = 0; j < sz(vec); j++)
        {
            for (int k = 0; k < sz(vec); k++)
            {
                if (j == k) continue;
                ans =  min(ans, min(abs(vec[j] - vec[k]), 24 - abs(vec[j] - vec[k])) );
            }
        }
//        if (ans != 1e9 +7)
        res = max(res, ans);
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
LL ans = 0;
void solve(int k, auto &Q, auto &A, int n, int m) {
    if (A.size() == n) {
        LL sum = 0;
        for (auto &q : Q) {
            if (A[q.F.S - 1] - A[q.F.F - 1] == q.S.F)
                sum += q.S.S;
        }
        ans = max(sum, ans);
        return ;
    }
    for (int i = k ; i <= m ; i++) {
        A.push_back(i);
        solve(i, Q, A, n, m);
        A.pop_back();
    }
}
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, m, q; cin >> n >> m >> q;
    vector<pair<pii, pii> > Q(q);
    for (auto &p : Q)
        cin >> p.F.F >> p.F.S >> p.S.F >> p.S.S;
    vector<int> A;
    solve(1, Q, A, n, m);
    cout << ans << '\n';
    
}

Measured memory_bytes: 3668
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    for (int i = 0; i < n; i++) {
      a[i] = sc.nextInt();
    }
    Arrays.sort(a);
    double min = 1000000000;
    int target = 0;
    int an = a[n - 1];
    int h = an / 2;
    for (int i = n - 2; i >= 0; i--) {
      if (min > Math.abs((double)h - (double)a[i])) {
        min = Math.abs((double)h - (double)a[i]);
        target = a[i];
      }
    }
    System.out.println(String.format("%d %d", an, target));
  }
}


Measured memory_bytes: 50600
n, money = map(int, input().split())

x = 0
y = 0
z = int(money/1000)

if z < n:
    print("-1 -1 -1")
elif z == n:
    print(x, y, z)
else:
    div1000 = min(int((z-n)/4), int(z/5))
    z = z - (5 * div1000)
    y += div1000
    if y + z == n:
        print(x, y, z)
    else:
        if int(y/2) >= y + z - n:
            x += y + z - n
            y -= (y+z-n)*2
            print(x, y, z)
        else:
            print("-1 -1 -1")


Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;


int main()
{
	int x, y;
	cin >> x >> y;

	string ans = "No";
	for (int i = 0; i <= x; i++) {
		int ashi = i * 2 + (x - i) * 4;
		if (ashi == y) {
			ans = "Yes";
			break;
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll mod=1000000007;
ll MOD=998244353;
int inf=1000001000;
ll INF=100000000000000000;


int main() {
    int v,E;
    cin >> v >> E;
    vector<vector<pp>> e(v+1,vector<pp>(0));
    rep(i,E){
        int f,g,h;
        cin >> f >> g >> h;
        e[f].push_back(mk(g,h));
        e[g].push_back(mk(f,h));
    } 
    rep(i,v) {
        int f;
        cin >> f;
    }
    int t;
    cin >> t;
    rep(i,30){
        cout << -1 << endl;
        t--;
        if (t==0) return 0;
    }
    queue<int> q;
    q.push(1);
    while(true){
        int f=q.front();
        int u=rand()%e[f].size();
        q.pop();
        q.push(e[f][u].first);
        rep(i,e[f][u].second){
            cout << e[f][u].first << endl;
            t--;
            if (t==0) return 0;
        }
    }
}


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

using namespace std;

#define roop(i, n) for(int i = 0;i < n;i++)
#define ll long long int

int main(void){

    vector<int> h, w;

    int count = 0;
    while(1){
        int a, b;
        cin >> a >> b;
        if(a == 0 && b == 0) break;
        h.push_back(a);
        w.push_back(b);
        count++;
    }

    for(int i = 0;i < count;i++){
        for(int j = 0;j < h[i];j++){
            for(int k = 0;k < w[i];k++){
                cout << '#';
            }
            cout << endl;
        }
        cout << endl;
    }



    return 0;
}


Measured memory_bytes: 3164
fun main(args: Array<String>) {
    val (A, B) = readLine()!!.split(" ").map(String::toInt)
    val sum = readLine()!!.split(" ").map(String::toInt).sum()
    if (A - sum <= 0) {
        println("Yes")
    } else {
        println("No")
    }
}



Measured memory_bytes: 47896
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

int main() {
  int n;
  string s;
  cin >> n >> s; 
  if(n%2 != 0) {
    cout << "No" << endl;
  } 
  else {
    string l = s.substr(0, n/2);
    string r = s.substr(n/2);
    if(l == r) {
      cout << "Yes" <<endl;
    } 
    else {
      cout << "No" << endl;
    }
  }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include <cassert>
    #include <cmath>
    #include<cstdint>

    #define INF 1e7
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))

    using namespace std;
    using ll = long long;
    using Graph = vector<vector<int>>;
    using P = pair<int,int>;

    int main(){
       int n;string s;cin>>n>>s;
       string s1 = s.substr(n/2),s2 = s.erase(n/2);
       if(n%2==1 || s1!=s2)cout<<"No";
       else if(s1==s2)cout<<"Yes";
    }
    


Measured memory_bytes: 256
#include <iostream>
#include <string>
int main()
{
	int a, b, c;
	std::cin >> a;
	std::cin >> b;
	std::cin >> c;

	std::string output;

	if (a < b && b < c)
	{
		output = "Yes";
	}
	else
	{
		output = "No";
	}

	std::cout << output << std::endl;
	return 0;
}

Measured memory_bytes: 3176
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
const int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;

signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int N, M;
  cin >> N >> M;
  int A[N];
  rep(i,N) cin >> A[i];
  int ans = 0;
  if(A[0] > M){
    ans += A[0] - M;
    A[0] = M;
  }
  for(int i=1;i<N;i++){
    int W = A[i] + A[i-1];
    if(W > M){
      ans += W - M;
      A[i] -= W-M;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
while True:
    try:
        n = list(map(int, input().split(',')))
        v2, v1 = n.pop(), n.pop()
        dist = sum(n) * (v1 / (v1 + v2))
        total = 0
        ans = 0
        while total < dist:
            total += n[ans]
            ans += 1
        print(ans)
    except:
        break

Measured memory_bytes: 6736
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

bool dp[100005][6][6][6];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n, a, b, c;
	cin >> n >> a >> b >> c;
	vector<string> s(n + 1);
	repn(i, 1, n + 1) cin >> s[i];
	a = min(a, 4);
	b = min(b, 4);
	c = min(c, 4);
	dp[0][a][b][c] = 1;
	repn(i, 1, n + 1) rep(j, 6) rep(k, 6) rep(l, 6){
		if(s[i] == "AB"){
			if(j > 0 && k < 5) dp[i][j - 1][k + 1][l] |= dp[i - 1][j][k][l];
			if(j < 5 && k > 0) dp[i][j + 1][k - 1][l] |= dp[i - 1][j][k][l];
		}
		else if(s[i] == "BC"){
			if(k > 0 && l < 5) dp[i][j][k - 1][l + 1] |= dp[i - 1][j][k][l];
			if(k < 5 && l > 0) dp[i][j][k + 1][l - 1] |= dp[i - 1][j][k][l];
		}
		else{
			if(j > 0 && l < 5) dp[i][j - 1][k][l + 1] |= dp[i - 1][j][k][l];
			if(j < 5 && l > 0) dp[i][j + 1][k][l - 1] |= dp[i - 1][j][k][l];
		}
	}
	int pos = 0;
	pair<pi, int> st;
	rep(i, 6) rep(j, 6) rep(k, 6){
		if(dp[n][i][j][k]) st = mp(mp(i, j), k);
		pos |= dp[n][i][j][k];
	}
	if(pos){
		string ans = "";
		int j = st.fi.fi, k = st.fi.se, l = st.se;
		for(int i = n - 1; i >= 0; i--){
			if(s[i + 1] == "AB"){
				if(j > 0 && k < 5 && dp[i][j - 1][k + 1][l]) ans += 'A', j--, k++;
				else if(j < 5 && k > 0 && dp[i][j + 1][k - 1][l]) ans += 'B', j++, k--;
			}
			else if(s[i + 1] == "BC"){
				if(k > 0 && l < 5 && dp[i][j][k - 1][l + 1]) ans += 'B', k--, l++;
				else if(k < 5 && l > 0 && dp[i][j][k + 1][l - 1]) ans += 'C', k++, l--;
			}
			else{
				if(j > 0 && l < 5 && dp[i][j - 1][k][l + 1]) ans += 'A', l++, j--;
				else if(j < 5 && l > 0 && dp[i][j + 1][k][l - 1]) ans += 'C', j++, l--;
			}
		}
		cout << "Yes" << endl;
		reverse(all(ans));
		rep(i, ans.size()) cout << ans[i] << endl;
	}
	else cout << "No" << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/



Measured memory_bytes: 27788
<?php
  fscanf(STDIN, "%d%d%d", $w,$h,$n);
  $x2 = $w;
  $y2 = $h;
  $x1 = 0;
  $y1 = 0;
  for($i=0; $i<$n; $i++){
      fscanf(STDIN, "%d%d%d", $x,$y,$a);
      if($a == 1){
          $x1 = max($x1, $x);
      }else if($a == 2){
          $x2 = min($x2, $x);
      }else if($a == 3){
          $y1 = max($y1, $y);
      }else{
          $y2 = min($y2, $y);
      }
  }
  if($x2<=$x1 || $y2<=$y1){
      echo "0";
  }
  else echo ($x2-$x1)*($y2-$y1);

Measured memory_bytes: 4604
#include <iostream>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <map>
#include <queue>
#include <string>
#include <vector>
#include <ostream>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

template<typename T, typename U>
std::ostream& operator << (std::ostream& os, std::pair<T, U> p) {
  os << "(" << p.first << ", " << p.second << ")";

  return os;
}

template<typename T>
std::ostream& operator << (std::ostream& os, std::vector<T> v) {
  os << "[";
  for (int i = 0; i < int(v.size()); ++i) {
    os << v[i] << (i + 1 == int(v.size()) ? "" : " ");
  }
  os << "]";

  return os;
}

inline void init() {
  cin.tie(0);
  std::ios::sync_with_stdio(false);
}

int main() {
  init();

  int n;
  cin >> n;

  if (n <= 999) {
    cout << "ABC\n";
  }
  else {
    cout << "ABD\n";
  }

  system("pause");
  return 0;
}


Measured memory_bytes: 896
import java.util.Scanner;


public class Main {
  public static void main (String[] args) {
    Scanner reader = new Scanner(System.in);
    int A = reader.nextInt();
    int previous = reader.nextInt();
    int tmp =  reader.nextInt();
    int result = Math.abs(tmp - previous);
   	for(int i = 1; i < A; i++) {
      previous = tmp;
      tmp = reader.nextInt();
    	result = gcd(Math.abs(tmp - previous), result);
    }
    System.out.print(result);
    
}
  
 private static int gcd(int x, int y) {
   
   if (y > x) {
   	int tmp = y;
     y = x;
     x = tmp;
   }
   int next;
   while ((next = x % y) != 0) {
     x = y;
     y = next;
     
   }
   return y;
 }
  
}

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

using vi = vector<int>;
using vll = vector<long long>;

constexpr long long mod = 1000000007;

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

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

    int h, w;
    cin >> h >> w;

    vector<vector<char>> s(h, vector<char>(w));
    rep(i, h) rep(j, w) cin >> s[i][j];

    vector<vector<int>> c(h, vector<int>(w, 0));
    vector<vector<int>> c2(h, vector<int>(w, 0));

    rep(i, h) {
        int t = 0;
        rep(j, w) {
            if (s[i][j] == '.') {
                t++;

                if (j == w - 1) {
                    for (int k = 0; k < t; k++) {
                        c[i][j - k] = t;
                    }
                }
            } else {
                if (t > 0) {
                    for (int k = 0; k < t; k++) {
                        c[i][j - k - 1] = t;
                    }
                }
                t = 0;
            }
        }
    }

    rep(j, w) {
        int t = 0;
        rep(i, h) {
            if (s[i][j] == '.') {
                t++;

                

                if (i == h - 1) {
                    for (int k = 0; k < t; k++) {
                        c2[i - k][j] = t;
                    }
                }
            } else {
                if (t > 0) {
                    for (int k = 0; k < t; k++) {
                        c2[i - k - 1][j] = t;
                    }
                }
                t = 0;
            }
        }
    }

    int ans = 0;
    rep(i, h) {
        rep(j, w) {
            ans = max(ans, c[i][j] + c2[i][j] - 1);
        }
    }

    cout << ans << endl;
}

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

using namespace std;

int main()
{
   int n,k;
   cin>>n>>k;
   vector<int> v;
   
  for(int i=0;i<n;i++)
  {
      int j;
      cin>>j;
     v.push_back(j);
      
      
      
  }
  sort(v.begin(),v.end());
 int sum=0;
 for(int i=0;i<k;i++)
 {
     
     sum+=v[i];
 }
   
 cout<<sum<<endl;
   return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define debugP int debug_point; cin>>debug_point;
const ll MOD= 1e9 + 7;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}


template <class T>
vector<T> getv(ll n){
	vector<T> Vector_temp;
	rep(i,n){
		T input;
		cin >> input;
		Vector_temp.emplace_back(input);
	}
	return Vector_temp;
}
ll gcd(ll c,ll b){
    while(1){
        if(c%b!=0){
        ll tmp=b;
        b=c%b;
        c=tmp;
        }else{
            return b;
        }
    }
}
/* <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3*/

int main(){
    ll n,a;
    cin>>n;
    vec(x,n);
    ll ans=LLONG_MAX;
    rep(i,n){
        cin>>x[i];
    }
    ll tmp=0;
    for(int i=-100;i<=100;i++){
        rep(j,n){
        tmp+=(i-x[j])*(i-x[j]);
        }
        ans=min(ans,tmp);
        tmp=0;
    }
    op(ans);
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
//#define _USE_MATH_DEFINES
#include<stdio.h>
//#include<stdlib.h>
//#include<math.h>
//#include<string.h>
//#include<time.h>
#define P(type,x) fprintf(stdout,"%"#type"\n",x)
int main() {
	int n, m, ans, t;
	for (; ~fscanf(stdin, "%d", &n), n; P(d, ans)) {
		fscanf(stdin, "%d", &m);
		ans = 0;
		for (; n <= m; n++) {
			t = n;
			for (; t % 2 == 0; t /= 2);
			for (; t % 3 == 0; t /= 3);
			for (; t % 5 == 0; t /= 5);
			if (t == 1) ans++;
		}
	}
	return 0;
}

Measured memory_bytes: 604
H,W=gets.split.map(&:to_i)

q = []
map = H.times.map { |y|
    s = gets.chomp
    s.each_char.with_index.map {|c,x|
        if c == '#'
            q << [x,y]
            1
        else
            0
        end
    }
}

n = 0
until q.empty?
    x,y = q.shift
    n = map[y][x] + 1
    q << [x-1,y] if 0 < x && map[y][x-1] == 0 && map[y][x-1] = n
    q << [x+1,y] if x < W-1 && map[y][x+1] == 0 && map[y][x+1] = n
    q << [x,y-1] if 0 < y && map[y-1][x] == 0 && map[y-1][x] = n
    q << [x,y+1] if y < H-1 && map[y+1][x] == 0 && map[y+1][x] = n
end

puts n - 2

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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
const int INF = 0x3f3f3f3f;
const int maxn = 1100000;

void run_case()
{
    ll x;
    cin >> x;
    int ans = 0;
    for (ll i = 2; i * i <= x; i++)
    {
        //int cnt = 0;
        if (x % i == 0)
        {
            int cnt = 0;
            while (x % i == 0)
            {
                x /= i;
                cnt++;
            }
            //DBG(cnt);
            for (int k = 1;; k++)
            {
                cnt -= k;
                ans++;
                if (cnt <= k)
                    break;
                //ans++;
            }
        }
    }
    if (x > 1)
        ans++;
    cout << ans << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    run_case();
    cout.flush();
    return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>
int main(void){
  int A[3],B[3],C[4],p=0,i;
  for(i=0;i<4;i++)C[i]=0;
  for(i=0;i<3;i++)scanf("%d%d",&A[i],&B[i]);
  for(i=0;i<3;i++){
    C[A[i]-1]++;
    C[B[i]-1]++;
  }
  for(i=0;i<4;i++){if(C[i]==0)p=-10;if(C[i]%2==1)p++;}
  if(p==0||p==2)printf("YES");
  else printf("NO");
}

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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int side1 = a * b;
    int side2 = c * d;
    if(side1 > side2)
        cout << side1 << endl;
    else
        cout << side2 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    string s, t;
    int sLength, tLength;
    int offset = 0;
    int diff = INT16_MAX;

    cin >> s >> t;
    sLength = s.length();
    tLength = t.length();

    for(int i=0; i < sLength-tLength+1; i++){
        int tmp_diff = 0;

        for(int j=0; j<tLength; j++){
            if(s[i+j] != t[j]){
                tmp_diff++;
            }
        }

        diff = min(diff, tmp_diff);
        tmp_diff = 0;
    }

    cout << diff << endl;
}


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

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

    int N;
    cin >> N;

    vector<pair<int, int>> P;

    int sum;
    sum = (N / 2) * 2+1;
    for(int i = 1; i <= (N/2)*2; i++){
        for(int j = i + 1; j <= (N/2)*2; j++){
            if((i+j) != sum){
                P.push_back(make_pair(i, j));
            }
        }
    }

    if(N % 2 == 1){
        for(int i = 1; i < N; i++){
            P.push_back(make_pair(i, N));
        }
    }

    cout << P.size() << endl;
    for(int i = 0; i < P.size(); i++){
        cout << P[i].first << " " << P[i].second << endl;
    }

    return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
#define int long long
#pragma GCC optimize("O3")

#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define mp make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int(v.size())
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= (m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (m); --i)

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

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  int n; cin >> n;
  int ans = 1000;

  vi a(n);
  rep(i, n) cin >> a[i];

  rep(i, n-1) {
    if (a[i] >= a[i+1]) continue;

    int tmp = ans / a[i];
    ans += (a[i+1] - a[i]) * tmp;
  }

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

Measured memory_bytes: 3668
import java.util.Scanner;
public class Main{
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int[][] a = new int[4][13];
        
        int n = sc.nextInt();
        for( int i = 0; i < n; i++){
            String s = sc.next();
            int r = sc.nextInt();
            if(s.equals("S")){
                a[0][r-1] = 1;
            }
            else if(s.equals("H")){
            a[1][r-1] = 1;
            }
            else if(s.equals("C")){
            a[2][r-1] = 1;
            }
            else {
            a[3][r-1] = 1;
            }
        }
        for( int i = 0; i < 4; i++ ) {
        	for( int j = 0; j < 13; j++ ) {
        		if( a[i][j] == 0 ) {
        			if( i == 0 ) {
        				System.out.println( "S " + (j+1) );
        			}
        			else if( i == 1 ) {
        				System.out.println( "H " + (j+1) );
        			}
        			else if( i == 2 ) {
        				System.out.println( "C " + (j+1) );
        			}
        			else {
        				System.out.println( "D " + (j+1) );
        			}
        		}
        	}
        }
        //System.out.println();
        sc.close();
    }
}


Measured memory_bytes: 26292
#include <iostream>
#include <map>
#include <algorithm>

using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    map<int, int> RS;
    int a, b;
    for(int i = 0; i < M; i++){
        cin >> a >> b;
        if(a == 1){
            RS[b]++;
        }
        if(b == N){
            RS[a]++;
        }
    }

    bool F = false;
    for(auto p : RS){
        if(p.second >= 2){
            F = true;
            break;
        }
    }

    if(F == true){
        cout << "POSSIBLE" << endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }


    return 0;
}

Measured memory_bytes: 9600
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	sc.Split(bufio.ScanWords)
	a, b, c := readInt(), readInt(), readInt()
	x, y := readInt(), readInt()

	min := 2 * 100000 * 5000
	for k := 0; k <= x+y; k++ {
		price := 2*c*k + max(x-k, 0)*a + max(y-k, 0)*b
		if price < min {
			min = price
		}
	}
	fmt.Println(min)
}

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


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  string s;cin>>s;
  int n=s.size();
  int ans=0;
  for(int i=0;i<n;i++){
    for(int j=i;j<n;j++){
      int c=0;
      for(int k=i;k<=j;k++){
        if(s[k]=='A'||s[k]=='T'||s[k]=='C'||s[k]=='G')continue;
        else{
          c=1;
          break;
        }
      }
      if(c==0)ans=max(ans,j-i+1);
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    ll x; cin >> x;

    // 6, 5を往復させるのが最速であり、それ以外を選択する必要はない
    // 1 2 3 4 5 ...
    // 6 5 6 5 6 ...
    if (x <= 6) {
        cout << 1 << endl;
    } else if (x <= 11) {
        cout << 2 << endl;
    } else {
        if (x % 11 == 0) {
            cout << (x/11) * 2 << endl;
        } else if (x % 11 <= 6) {
            cout << (x/11) * 2 + 1 << endl;
        } else {
            cout << (x/11) * 2 + 2 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3556
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
using std::swap;

// priceをキーに降順でソート
//sort(fruits.begin(), fruits.end(),
//     [](const fruit& x, const fruit& y) { return x.price > y.price;});

/*
int main() {
    int A, B;
    std::cin >> A >> B;
    std::cout << max(A-2*B, 0);

    return 0;
}
 */

int main(){
    int N;
    std::cin >> N;
    int a[N];
    int heal=0;
    for(int i=0; i<N; i++){
        std::cin >> a[i];
    }
    for(int i=0; i<N; i++){
        for(int j=0; j<i; j++){
            heal+= a[i]*a[j];
        }
    }
    std::cout << heal << std::endl;
    return 0;
}


Measured memory_bytes: 256
while True:
    l = input().split()
    h = int(l[0])
    w = int(l[1])
    if h == 0 and w == 0:
        break
    for i in range(h):
        if i % 2 == 0:
            for j in range(w):
                if j % 2 == 0:
                    print("#", end="")
                else:
                    print(".", end="")
        else:
            for j in range(w):
                if j % 2 != 0:
                    print("#", end="")
                else:
                    print(".", end="")
        print()
    print()

Measured memory_bytes: 7004
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#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)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

char ba[30][30];
int h,w,n;

bool del[30][30];
const int dx[] = {1,0};
const int dy[] = {0,1};

bool visited[30][30];
void dfs(int i, int j, int d, vector<pii> &v) {
  visited[i][j]=0;
  v.push_back(pii(i,j));
  int ii=i+dy[d];
  int jj=j+dx[d];
  if (ii>=h||jj>=w) return;
  if (ba[i][j]==ba[ii][jj]) dfs(ii,jj,d,v);
}
bool solve() {
  bool update2=1;
  while(update2) {
    update2 = 0;
    // 落とす
    bool update = 1;
    while(update) {
      update = 0;
      REP(i,h-1) REP(j,w) {
        if (ba[i][j]=='.') continue;
        if (ba[i+1][j]=='.') {
          swap(ba[i][j],ba[i+1][j]);
          update = 1;
        }
      }
    }
    
    // 消す
    memset(del,0,sizeof(del));
    REP(d,2) {
      memset(visited,0,sizeof(visited));
      REP(i,h) {
        REP(j,w) {
          if (ba[i][j]=='.') continue;
          if (visited[i][j]) continue;
          vector<pii> v;
          dfs(i,j,d,v);
          if (v.size() >= n) {
            FOR(it,v) del[it->first][it->second]=1;
          }
        }
      }
    }
    REP(i,h)REP(j,w) if (del[i][j]) ba[i][j]='.',update2=1;
    // REP(i,h) {
    //   REP(j,w) cout << ba[i][j];cout << endl;
    // }
    // cout << endl;
  }
  REP(i,h)REP(j,w){
    if (ba[i][j]!='.') return 0;
  }
  return 1;
}

char in[30][30];
int main() {
  cin>>h>>w>>n;
  REP(i,h)REP(j,w)cin>>in[i][j];
  REP(y,h) REP(x,w-1) {
    memcpy(ba,in,sizeof(in));
    swap(ba[y][x],ba[y][x+1]);
    if (solve()) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
}

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

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

	ll n, D;
	cin >> n >> D;
	vector<ll> a(n);
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	vector<ll> b = a;
	for (int i = 1; i < n; ++i)
		b[i] = min(b[i], b[i - 1] + D);
	for (int i = n - 2; i >= 0; --i)
		b[i] = min(b[i], b[i + 1] + D);

	ll ans = accumulate(a.begin(), a.end(), 0LL) + (n - 1LL) * D;
	if (n >= 3)
		ans += accumulate(b.begin() + 1, b.end() - 1, 0LL);
	cout << ans;
	return 0;
}


Measured memory_bytes: 3456
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

ll calc(ll x){
    if (x <= 0) return 0;
    ll ret = ((x + 1) / 2) % 2;
    FOR(b,1,45){
        ll y = (1LL << b);
        ll z = x % (2 * y);
        if (z >= y){
            z -= y;
            if (z % 2 == 0) ret |= y;
        }
    }
    return ret;
}

int main() {
    ll a, b;
    cin >> a >> b;
    cout << (calc(b) ^ calc(a - 1)) << endl;
    return 0;
}

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

int main(){
    int n, i;
    cin >> n;
    vector <string> w(n);
    for (i = 0; i < n; i++){
        cin >> w[i];
    }

    for (i = 0; i < n-1; i++){
        string w1 = w[i];
        string w2 = w[i+1];
        if(w1[w1.size()-1] != w2[0]){
            cout << "No" << endl;
            // cout << i << w1[w1.size()-1] << w2[0] << endl;
            return 0;
        }

        for (int j = i+1; j < n; j++){
            if(w[i] == w[j]){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
using System;

namespace AtcoderPractice
{
    class Program
    {
        static void Main(string[] args)
        {
            string ns = Console.ReadLine();
            string s = Console.ReadLine();
            int n = int.Parse(ns);
            int x = 0;
            int xMax = 0;
            for(int i = 0; i < n; i++)
            {
                if(s[i] == 'I')
                {
                    x++;
                    if(xMax < x)
                    {
                        xMax = x;
                    }
                }
                else
                {
                    x--;
                }
            }
            Console.WriteLine(xMax);
        }
    }
}


Measured memory_bytes: 11092
# -*- coding: utf-8 -*-
import numpy as np
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect
from scipy.special import comb
import copy
sys.setrecursionlimit(10**6)


def zz():
    return list(map(int, sys.stdin.readline().split()))


def z():
    return int(sys.stdin.readline())


def S():
    return sys.stdin.readline()[:-1]


def C(line):
    return [sys.stdin.readline() for _ in range(line)]


H, W = zz()
table = []
for i in range(H):
    table.append(input())
ans_table = [[0]*W for _ in range(H)]
dx = [-1, 0, 1, -1, 1, -1, 0, 1]
dy = [-1, -1, -1, 0, 0, 1, 1, 1]
for i in range(H):
    for j in range(W):
        tmp = 0
        if (table[i][j] == '.'):
            for x, y in zip(dx, dy):
                if (i + x >= H or j+y >= W or i + x < 0 or j+y < 0):
                    continue
                if (table[i + x][j + y] == '#'):
                    tmp += 1
            ans_table[i][j] = tmp
        else:
            ans_table[i][j] = '#'


for _table in ans_table:
    print(*_table, sep='')


Measured memory_bytes: 42312
#include<bits/stdc++.h>
using namespace std;
int main(){
int arr[4];
for(int i=0; i<4; i++){
    cin>>arr[i];
}
if(arr[0] == 2){
    if(arr[1] == 28){
        cout<<"1"<<endl;
    }
    else    
        cout<<"0";    
}
else if(arr[0] == 2 or arr[0] == 4 or arr[0] == 6 or  arr[0] == 9 or arr[0] == 11){
    if(arr[1]==30){
        cout<<"1";
    }
    else
    cout<<"0";
}
else if(arr[0] == 1 or arr[0] == 3 or arr[0] == 5 or arr[0] == 7 or arr[0] == 8 or arr[0] == 10 or arr[0] == 12)
    if(arr[1]==31){
        cout<<"1";
    }
    else
    cout<<"0";


    return 0;
}

Measured memory_bytes: 3664
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <iterator>
#include <math.h>
#include <cmath>
#include <stdlib.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <regex>
#include <stdexcept>
#include <unordered_set>
#include <string>
#include <map>
#include <iomanip>
#include <sstream>
#include <cassert>
#include <time.h>
#include <numeric>
#include <complex>
  
using namespace std;
using ull = unsigned long long;
using ll = long long;
using ld = long double;
using D = double;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
  
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define fill(x, y) memset(x, y, sizeof(x))
#define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin())
#define rep(i, x)  for(int i = 0; i < (x); i++)
#define rrep(i, x) for(int i = (x - 1); i >= 0; i--)
#define y1 y1_1234413
#define j1 j1_235
#define y0 y0_235
#define j0 j0_256
#define fi first
#define se second
#define itn int
#define re return
#define prev PREV
#define next NEXT
  
#define sz(x) ((int)x.size())
  
const int inf = 2e9;
const ld st = 0.000001;
const ld pi = acos((ld)-1);
const int MAXN = 1e5;
#define FILENAME ""
const double eps = 1e-6;
const int maxn = 1001;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    //freopen("unionday.in", "r", stdin);
    //freopen("unionday.out", "w", stdout);
    int n, m;
    cin >> n >> m;
    vector <string> a;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        a.pb(s);
    }
    sort(all(a));
    for (int i = 0; i < a.size(); i++) {
        cout << a[i];
    }
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18
# ----------------------------------------------------------- #

n, k = Is()
a = n//k
ans = a**3
if k % 2 != 0:
    print(ans)
    exit()

count = 0
for i in range(n+1):
    if i % k == k//2:
        count += 1
ans += count**3
print(ans)

Measured memory_bytes: 63596
#include <iostream>
#include <vector>
#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(){
    int n;
    cin >> n;
  
  cout << 3*pow(n,2) <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, n, a, b);
    int pab = 0, pb = 0;
    Rep(n){
        Cin(char, c);
        if(c == 'a'){
            if(pab < a+b){
                Cout("Yes"); pab ++;
            }
            else{
                Cout("No");
            }
        }
        else if(c == 'b'){
            if(pab < a+b && pb < b){
                Cout("Yes"); pab ++; pb ++;
            }
            else{
                Cout("No");
            }
        }
        else{
            Cout("No");
        }
    }
}





Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int N, Ma, Mb;
int a[40], b[40], c[40];
int cost[404040];
int cost2[404040];
int main()
{
    scanf("%d%d%d", &N, &Ma, &Mb);
    for(int i=0; i<N; ++i)
        scanf("%d%d%d", a+i, b+i, c+i);
    memset(cost, 0x3f, sizeof(cost));
    int* p = cost + 202020;
    int* q = cost2 + 202020;   
    for(int i=0; i<N; ++i)
    {
        int x = b[i]*Ma - a[i]*Mb;
        for(int j= -5000; j<=5000; ++j)
            q[j] = min(p[j], p[j-x] + c[i]);
        q[x] = min(q[x], c[i]);
        for(int j=-5000; j<=5000; ++j)
            p[j] = q[j];
            
    }
    if(p[0] > 0x3f3f3f3) p[0] = -1;
    printf("%d\n", p[0]);
    return 0;
}

Measured memory_bytes: 1920