akhauriyash/Code-Regression huggingface dataset:
r, c = gets.split.map(&:to_i)

matrix = Array.new()

r.times do
    number = gets.split.map(&:to_i)
    number.push(number.inject(:+))
    matrix.push(number)
end

sum = Array.new(c + 1, 0)
matrix.each do |number|
    puts number.join "\s"
    sum = sum.zip(number).map { |a, b| a + b }
end

puts sum.join "\s"

Measured memory_bytes: 9028
#include<bits/stdc++.h>
using namespace std;
int n,x,minx=1e9,ans;
signed main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&x);
		if(minx>x)
		{
			ans++;
			minx=x;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
S = input()
tmp1 = '01' * (len(S) // 2 + 1)
tmp2 = '10' * (len(S) // 2 + 1)
C = {0 : 0, 1 : 0}
for i, s in enumerate(S):
    if s != tmp1[i] : C[0] += 1
    if s != tmp2[i] : C[1] += 1
print(min(C.values()))

Measured memory_bytes: 3316
import math
N, K = map(int, input().split())
a = list(map(int, input().split()))

tmp = a.index(min(a))
amri = ((tmp) % (K - 1))
if amri == 0:
    ans = math.ceil(tmp / (K - 1)) + math.ceil((N - tmp - 1) / (K - 1))
else:
    ans = math.floor(tmp / (K - 1)) + math.ceil((N - tmp - (K- amri)) / (K - 1)) + 1
print(ans)

Measured memory_bytes: 13812
using System;
using System.Linq;
using System.Numerics;

   class Program
    {
        static void Main()
        {
            var N = int.Parse(Console.ReadLine());
            var dp = Enumerable.Range(0, N + 1).Select(_ => Enumerable.Range(0, 3).ToList()).ToList();
            for (int i = 0; i < 3; i++) dp[0][i] = 0;

            for (int i = 1; i <= N; i++)
            {
                var line = Console.ReadLine().Split().Select(int.Parse).ToArray();
                for (int j = 0; j < 3; j++)
                {
                    for (int k = 0; k < 3; k++)
                    {
                        if (j == k) continue;
                        dp[i][k] = Math.Max(dp[i - 1][j] + line[k], dp[i][k]);
                    }
                }
            }
            Console.WriteLine(dp[N].Max());
        }
    }

Measured memory_bytes: 56212
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;
using lint = long long;

const lint MOD = 998244353;

lint power(lint n, lint p) {
    if (p == 0) {
        return 1;
    } else {
        lint res = 1;
        while (p > 0) {
            if (p%2 == 1) {
                res = res*n%MOD;
            }
            n = n*n%MOD;
            p /= 2;
        }
        return res;
    }
}

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

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

    lint ans = power(3, N);

    lint sum = 0;
    for (int i = 1; i <= N; i++) {
        sum += a[i];
    }

    vector<vector<lint>> num(N + 1, vector<lint>(sum + 1)), num2(N + 1, vector<lint>(sum + 1));
    num[0][0] = 1;
    for (int i = 1; i <= N; i++) {
        for (int j = 0; j <= sum; j++) {
            num[i][j] = (num[i][j] + num[i - 1][j]*2)%MOD;
            if (j - a[i] >= 0) {
                num[i][j] = (num[i][j] + num[i - 1][j - a[i]])%MOD;
            }
        }
    }

    for (int i = (sum + 1)/2; i <= sum; i++) {
        ans -= 3*num[N][i]%MOD;
        if (ans < 0) {
            ans += MOD;
        }
    }

    num2[0][0] = 1;
    for (int i = 1; i <= N; i++) {
        for (int j = 0; j <= sum; j++) {
            num2[i][j] = (num2[i][j] + num2[i - 1][j])%MOD;
            if (j - a[i] >= 0) {
                num2[i][j] = (num2[i][j] + num2[i - 1][j - a[i]])%MOD;
            }
        }
    }

    if (sum%2 == 0) {
        ans += 3*num2[N][sum/2]%MOD;
        ans %= MOD;
    }

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

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

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class ECountMedian {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n; cin >> n;
      vector<int> a(n), b(n);
      rep(i, n) {
        cin >> a[i] >> b[i];
      }
      sort(all(a));
      sort(all(b));
      if (n%2==1) {
        cout << b[n/2]-a[n/2]+1 << endl;
      } else {
        int p = b[n/2] + b[n/2-1];
        int q = a[n/2] + a[n/2-1];
        cout << p-q+1 << endl;
      }
    }
};

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

Measured memory_bytes: 4804
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	    }
	sort(a,a+n);
	for(int j=1;j<=a[0];j++){
		    if(n==2){
			  if(a[0]%j==0&&a[1]%j==0)cout<<j<<endl;
			  }
			else if(a[0]%j==0&&a[1]%j==0&&a[2]%j==0)cout<<j<<endl;
		    }
    return 0;
    }


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

main () {
  int n, m;
  scanf("%d %d", &n, &m);

  vector<bool> is_broken(n+1);
  fill(is_broken.begin(), is_broken.end(), false);
  rep(i,m) {
    int j;
    scanf("%d", &j);
    is_broken[j] = true;
  }

  vector<int> dp(n+1);
  dp[0] = 1;
  dp[1] = is_broken[1] ? 0 : 1;
  for (int i=2; i<=n; i++) {
    if(is_broken[i]) {
      dp[i] = 0;
    }
    else {
      dp[i] = dp[i-1] + dp[i-2];
      dp[i] %= MOD;
    }
  }

  printf("%d\n", dp[n]);

  return 0;
}


Measured memory_bytes: 640
//
//  main.cpp
//  programs
//
//  Created by Arunesh Sarker on 18/11/19.
//  Copyright © 2019 Arunesh Sarker. All rights reserved.
//

#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <unordered_set>
#include <unordered_map>
#include <cstdlib>
using namespace std;
vector<string> st;
typedef unsigned long long ll;
#define mod 1000000007
     
  // Function to return LCM of two numbers
int fact(int n)
{
    // single line to find factorial
    return (n==1 || n==0) ? 1: n * fact(n - 1);
}
 ll gcd(ll a, ll b)
 {
     if (a == 0)
         return b;
     return gcd(b % a, a);
 }
   
 // Function to find gcd of array of
 // numbers
 ll findGCD(ll arr[], ll n)
 {
     ll result = arr[0];
     for (ll i = 1; i < n; i++)
     {
         result = gcd(arr[i], result);
   
         if(result == 1)
         {
            return 1;
         }
     }
     return result;
 }
ll findlcm(ll arr[], ll n)
{
    // Initialize result
    ll ans = arr[0];
  
    // ans contains LCM of arr[0], ..arr[i]
    // after i'th iteration,
    for (ll i = 1; i < n; i++)
        ans = (((arr[i] * ans)) /
                (gcd(arr[i], ans)));
  
    return ans;
}
bool check(ll n)
{
    while(n>0)
    {
        ll t=n%10;
        if(t!=9)
            return false;
        n/=10;
    }
    return true;
}
ll f(ll h)
{
    if (h==1)
        return 1;
    return 2*(f(h/2))+1;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll h;
    cin>>h;
    cout<<f(h)<<"\n";
    
}






Measured memory_bytes: 256
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll N;
    cin >> N;
    ll ans = 0;
    ans += 1000 * (N / 500);
    N %= 500;
    ans += 5 * (N / 5);
    cout << ans << endl;
    return 0;
}

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

typedef long long int llint;

int main()
{
  int d, n;
  cin>> d >> n;
  
  if(d == 0) d = 1;
  else if(d == 1) d = 100;
  else if(d == 2) d = 10000;
  
  cout<< d * (n + n / 100) <<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include<vector>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int main()
{
    int n;
    cin >> n;
    vector<long> L(n);
    rep(i, n) cin >> L[i];

    long sum, maxL;
    int ans = 0;

    rep(p, n)
    {
        for (int q = p + 1; q < n; q++)
        {
            for (int r = q + 1; r < n; r++)
            {
                sum = L[p] + L[q] + L[r];
                maxL = max(L[p], max(L[q], L[r]));
                if (sum - maxL > maxL && L[p] != L[q] && L[q] != L[r] && L[p] != L[r])
                {
                    ans++;
                }

            }
        }
    }

    cout << ans << "\n";
    return 0;
}

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

using namespace std;

int main()
{
    vector<int> a(3);
    cin >> a[0] >> a[1] >> a[2];
    int ans = 0;
    int min = *min_element(a.begin(), a.end());
    int max = *max_element(a.begin(), a.end());

    cout << abs(min - max) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define M 20000000
#define L 14
int find(char str[L]);
int getChar(char ch);
long long getKey(char str[L]);
int insert(char str[L]);
  
char H[M][L]; 

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}


int find(char str[L]){
  if(H[getKey(str)][0]=='\0')return 0;
  else return 1;

}

int insert(char str[L]){

  strcpy(H[getKey(str)],str);

}

int main(){
    int i, n, h;
    char str[L], com[9];
    
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}

Measured memory_bytes: 118548
#include <cstdint>
#include <iostream>


#if defined(__GNUC__) && !defined(__clang__)
#  pragma GCC optimize("Ofast")
#  pragma GCC target("sse4.2", "tune=native")
#endif


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

  std::uint64_t a, b;
  std::cin >> a >> b;

  switch ((b - a) % 4) {
    case 0:
      std::cout << (a % 2 == 0 ? b : a) << std::endl;
      break;
    case 1:
      std::cout << (a % 2 == 0 ? 1 : (0x0ULL ^ a ^ b)) << std::endl;
      break;
    case 2:
      std::cout << (a % 2 == 0 ? (b + 1) : (a - 1)) << std::endl;
      break;
    case 3:
      std::cout << (a % 2 == 0 ? 0 : (0x01ULL ^ a ^ b)) << std::endl;
      break;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define MAXMIN(a,b,c) std::max(a,min(b,c))
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}

	return d;
}



int main(void) {

	lli n,count = 0;
	cin >> n;

	for (int i = 2; i <= sqrt(n); i++) {

		if (n % i == 0) {
			lli tmp = 0;
			lli t = 1;
			while (n % i == 0) {
				n /= i;
				t--;
				if (t == 0) {
					tmp++;
					t = tmp + 1;
				}
			}
			count += tmp;
		}

	}

	if (n != 1) {
		count++;
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 3656
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
const long long mod = 1e9 + 7;
typedef long long ll;
typedef priority_queue<int> PQ;
typedef vector<long long> VL; // VL a(n);
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VL> VLL; // VII a(n,VI(m)) n * m
typedef pair<ll, ll> PL;
typedef map<ll, ll> MP; // MP a;
typedef vector<pair<ll, ll>> PS; // PS a(n);

template <class T, class U>
bool chmax(T &a, U b) {
  if (a <= b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}

// g++ -std=c++11 prac.cpp
// operator << (cout,a);
// chmin(min,a)

int main() {
  ll n,k,m,x=0,y=0,z = 0,cnt=0,h=0,w=0,ans=0,sum = 0, Max = -1, Min = 3e9+1;
  string s;
  cin >> n;
  VS a(n);
  VL b(5);
  rep(i,n) {
    cin >> a[i];
    if(a[i][0] == 'M'){ b[0]++; }
    if(a[i][0] == 'A'){ b[1]++; }
    if(a[i][0] == 'R'){ b[2]++; }
    if(a[i][0] == 'C'){ b[3]++; }
    if(a[i][0] == 'H'){ b[4]++; }
  }
  rep(i,5){
    for(int j=i+1; j<4;j++){
      for(int k=j+1; k<5; k++){
        ans += b[i]*b[j]*b[k];
      }
    }
  }
  pri(ans);
  return 0;
}

Measured memory_bytes: 6316
#include<cstdio>
#include<algorithm>
using namespace std;
int n,x;
int a[2005];
int Min[2005],pos[2005];
int main(){
  scanf("%d%d",&n,&x);
  for(int i=1;i<=n;++i)scanf("%d",a+i),Min[i]=a[i],pos[i]=i;
  long long ans=1ll<<60;
  for(int i=0;i<n;++i){
    long long tmp=i*1ll*x;
    for(int j=1;j<=n;++j){
      tmp+=Min[j];
    }
    for(int j=1;j<=n;++j){
      if(pos[j]>1){
	--pos[j];
      }else{
	pos[j]=n;
      }
      Min[j]=min(Min[j],a[pos[j]]);
    }
    ans=min(ans,tmp);
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 128
N = int(input())
*W, = map(int, input().split())
C = {w: i for i, w in enumerate(W)}
W.sort()

ans = 0
S = []
used = [0]*N
for i in range(N):
    if used[i]:
        continue
    sq = []
    w = W[i]
    p = i; j = None
    while j != i:
        j = C[w]; w = W[j]
        used[j] = 1
        sq.append(w)
        p = j
    mi = min(sq); ln = len(sq)
    if ln >= 2:
        ans += sum(sq)
    S.append((mi, ln))
S.sort()
m, ln = S[0]
if ln >= 2:
    ans += (ln-2)*m
for mi, ln in S[1:]:
    if ln <= 2:
        continue
    ans += min(m+mi+ln*m, (ln-2)*mi)
print(ans)



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

#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(),(x).end()
#define MSG(x) cout << x << endl;
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
using ll = long long;

int main(int argc, char *argv[]) {
    ll n, k;
    cin >> n >> k;

    if (k == 1) MSG(0)

    else {
        MSG(n - (k-1) - 1)
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}

ll dp[30][10] = {0};

int main()
{
    int k;
    cin >> k;
    rep(i, 10) dp[0][i] = 1;

    rep(i, 30-1)rep(j, 10){
        dp[i+1][j] += dp[i][j];
        if (j != 9) dp[i+1][j] += dp[i][j+1];
        if (j != 0) dp[i+1][j] += dp[i][j-1];
    }


    // rep(i, 10){
    //     rep(j, 10){
    //     cout << dp[i][j] << " ";
    //     }
    //     cout << endl; 
    // }

    int it, jt;
    //k++; //0をテーブル上カウントしているため
    ll sum = 0;
    int rem = 0;
    rep(i, 29){
        int ok = false;
        rep(j, 10){
            if (j == 0) continue;
            sum += dp[i][j];
            if (sum >= k){
                it=i; jt=j; ok = true;
                rem = k-(sum-dp[i][j]);
                break;
            }
        }
        if (ok) break;
    }
    //cout << it << ":"<< jt << ":" << rem << endl;

    vector<int> ans;
    ans.push_back(jt);
    for(int i = it-1; i >= 0; i--){
        int tmprem = 0;
        if (jt != 0) tmprem += dp[i][jt-1];
        if (tmprem >= rem){
            //rem = rem;
            jt--; ans.push_back(jt); continue;
        }
        tmprem += dp[i][jt];
        if (tmprem >= rem){
            rem = rem - (tmprem - dp[i][jt]);
            ans.push_back(jt);continue;
        }
        if (jt != 9) tmprem += dp[i][jt+1];
        if (tmprem >= rem){
            rem = rem - (tmprem - dp[i][jt+1]);
            jt++; ans.push_back(jt);
        }
    }

    rep(i, ans.size()){
        cout << ans[i];
    }
    cout << endl;
}



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

typedef long long ll;

ll N, P;

int main() {
	scanf("%lld%lld", &N, &P);

	ll ans = 1;	
	for (ll i = 2; i * i <= P; i++) {
		if (P % i)
			continue;
		int ex = 0;
		for (; !(P % i); P /= i)
			ex++;
		ex /= N;
		while (ex--)
			ans *= i;
	}
	if (P > 1 && N == 1)
		ans *= P;
	
	printf("%lld\n", ans);
	
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    static class Task {
        void solve(InputReader in, PrintWriter out) {
            int N = in.nextInt();
            int A = in.nextInt();

            int ans = (int) Math.pow(N, 2) - A;
            out.println(ans);
        }
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
    }
}

Measured memory_bytes: 22996
# Author: cr4zjh0bp
# Created: Fri Mar  6 03:27:57 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

x = ni()

ans = 1
i = 2
while i * i <= x:
    t = i * i
    while t <= x:
        ans = max(ans, t)
        t *= i
    i += 1

print(ans)

Measured memory_bytes: 3064
import math
N, D = map(int, input().split())
x = []
for i in range(N):
  t = list(map(int, input().split()))
  x.append(t)

ans = 0
for i in range(N):
  for j in range(i+1, N):
    d = 0
    for k in range(D):
      d += (x[i][k] - x[j][k]) ** 2
    if round(math.sqrt(d)) ** 2 == d:
      ans += 1
print(ans)


Measured memory_bytes: 38256
function MainB(input){
    const [a,b,c,d] = input.split(' ').map(BigInt);
    let answer = 0;
    const ac = a*c;
    const ad = a*d;
    const bc = b*c;
    const bd = b*d;
    // log({ac,ad,bc,bd})
    const acVSbc = ac > bc ? ac : bc;
    const adVSbd = ad > bd ? ad : bd;
    // log({acVSbc, adVSbd});
    console.log(acVSbc > adVSbd ? String(acVSbc).split('n')[0] : String(adVSbd).split('n')[0]);
}
MainB(require("fs").readFileSync("/dev/stdin", "utf8").trim());


Measured memory_bytes: 29680
#pragma region RegionDefs
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,l,r) for(int i=(l),i##_len=(r);i<i##_len;++i)
#define all(x) begin(x),end(x)
using namespace std;
typedef long long ll;
const ll INF = 1e9;
template<class T=ll> using V = vector<T>;
template<class T=ll> using PQ = priority_queue<T>;
template<class T=ll> using PQG = priority_queue<T, V<T>, greater<T>>;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail)
{
    cin >> head;
    in(move(tail)...);
}
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
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 (a>b) {a=b; return 1;} return 0;}
#define y0 y__0
#define y1 y__1
#define j0 j__0
#define j1 j__1
#define YN(e) cout << ((e) ? "YES" : "NO") << endl
#define yn(e) cout << ((e) ? "Yes" : "No") << endl
#pragma endregion RegionDefs

void solve()
{
    IN(a);
    string s; cin >> s;
    cout << a*(s[0]-'0')+a*((s[2]-'0')*10+s[3]-'0')/100 << endl;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 3656
# sys.stdin.readline
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        N, Y = map(int, input().split())

        for a in range(N + 1):
            for b in range(N + 1 - a):
                c = N - a - b
                if Y == 10000 * a + 5000 * b + 1000 * c:
                    print(*[a, b, c], sep=' ')
                    exit()
        print(*[-1] * 3, sep=' ')


# Run main
if __name__ == '__main__':
    AtCoder().main()

Measured memory_bytes: 38768
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007


void solve()
{
	string s;
	cin>>s;
	string t;
	cin>>t;
	reverse(t.begin(),t.end());
	if(s==t)
		cout<<"YES";
	else
		cout<<"NO";
	
    return;
}

int main()
{
        fast;
        ll q;
        q=1;
        // cin>>q;
        while(q--)
        	solve();
        
        return 0;
}

Measured memory_bytes: 3656
/*
	submission # - User: herp_sy
	https://atcoder.jp/contests/
*/

import java.util.*;
import java.util.Collections; // sorting use
import java.io.*;
import static java.lang.System.*;

public class Main{
	public static void main(String[] args){
		int n;
		Scanner sc = new Scanner(System.in);
		
		n = sc.nextInt();
		out.println(800 * n - 200 * (n / 15));
	}
}


Measured memory_bytes: 21332
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 1000000007;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;
		
	void doIt() {
		int n = sc.nextInt();
		Res[] rs = new Res[n];
		for(int i = 0; i < n; i++) {
			rs[i] = new Res(sc.next(), sc.nextInt(), i + 1);
		}
		Arrays.sort(rs);
		for(int i = 0; i < n; i++) {
			System.out.println(rs[i].i);
		}
	}

	class Res implements Comparable<Res>{
		int p, i;
		String s;
		Res(String s, int p, int i){
			this.s = s; this. p = p; this.i = i;
		}
		@Override
		public int compareTo(Res arg0) {
			if(this.s.compareTo(arg0.s) > 0) {
				return 1;
			}
			else if(this.s.compareTo(arg0.s) < 0) {
				return -1;
			}
			else if(this.p < arg0.p){
				return 1;
			}
			else if(this.p > arg0.p){
				return -1;
			}
			return 0;
		}
		
	}
	
	public static void main(String[] args) {
		new Main().doIt();
	}
}


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

int main() {
    ll H, W;
    cin >> H >> W;
    ll X = H * W;
    if(W==1||H==1){
        cout << 1 << endl;
        return 0;
    }
    if (X % 2 == 0) {
        cout << X / 2 << endl;
    } else {
        cout << (X / 2) + 1 << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int main()


{


int a,b,c,x,y,z;


scanf("%d%d%d",&a,&b,&c);


if(a > b){


x = a;


a = b;


b = x;


}


if(b > c){


y = b;


b = c;


c = y;


}


if(a > b){


z = a;


a = b;


b = z;


}


printf("%d %d %d\n",a,b,c);


return 0;


}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(NAME, NUM) for (int NAME = 0; NAME < (NUM); ++NAME)
#define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; --NAME)
#define ALL(NAME) (NAME).begin(), (NAME).end()

int main()
{
	ull a,b;
	cin >> a>>b;
	cout << a-b+1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>

using ll = long long;

int main() {
    int R;
    std::cin >> R;
    if (R < 1200) {
        std::cout << "ABC" << std::endl;
    }
    else if (R < 2800) {
        std::cout << "ARC" << std::endl;
    }
    else {
        std::cout << "AGC" << std::endl;
    }
    return 0;
}


Measured memory_bytes: 256
n = int(input())
s = list(map(int, input().split()))
inf = 10 ** 8
dp = [inf] * n
dp[0] = 0

for i in range(0, n - 1):
    if dp[i] != inf:
        dp[i+1] = min(dp[i]+abs(s[i+1]-s[i]), dp[i-1]+abs(s[i+1]-s[i-1]))
print(dp[-1])

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

int main() {
  int N;
  cin>>N;
  vector<int> A(N);
  
  rep(i,N){cin >> A.at(i);}
  sort(A.begin(),A.end());
  reverse(A.begin(),A.end());
  
  long long Ans=A.at(0);
  
  if(N!=2){rep(i,N-2){Ans+=A.at((i+2)/2);}}
  cout<<Ans<<endl;                               
}

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

using namespace std;
using ll = long long;

int simul[1000020];

vector<int> zero;

ll res;

int main()
{
    fill(simul, simul + 1000020, -3);
    string s;
    cin >> s;
    
    int idx = 1;

    for (int i = 0; i < s.size(); ++i)
    {
        if (s[i] == '<')
            simul[idx] = -1;
        else
            simul[idx] = -2;
        
        idx += 2;
    }
    
    for (int j = 0; j < s.size() * 2 + 1; j += 2)
    {
        bool ispush(false);
    
        if (!j && simul[j + 1] == -1)
            ispush = true;
        else if (j == s.size() * 2 && simul[j - 1] == -2)
            ispush = true;
        else if (j > 0 && j < s.size() * 2 && simul[j - 1] == -2 && simul[j + 1] == -1)
            ispush = true;
        
        if (ispush)
            zero.push_back(j);
    }
    
    for (int k = 0; k < zero.size(); ++k)
    {
        int pivot = zero[k];
        int increase = 0;
        simul[pivot] = 0;
        
        while (pivot >= 0)
        {
            if (pivot > 0 && simul[pivot - 1] == -1)
            {
                simul[pivot] = max(simul[pivot], increase);
                break;
            }

            simul[pivot] = increase++;
            
            pivot -= 2;
        }
        increase = 0;
        pivot = zero[k];
        
        while (pivot < s.size() * 2 + 1)
        {
            if (pivot < s.size() * 2 && simul[pivot + 1] == -2)
            {
                simul[pivot] = max(simul[pivot], increase);
                break;
            }

            simul[pivot] = increase++;

            pivot += 2;
        }
    }
    
    for (int x = 0; x < s.size() * 2 + 1; x += 2)
        res += simul[x];
    cout << res;
}

Measured memory_bytes: 5380
/**
 *      purpose : ABC 117 B
 *      author  : kyomukyomupurin
 *      created : 
**/

// in, out
#include <iostream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cctype>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias templates
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define fi first
#define se second

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n; cin >> n;
    int l[n];
    rep(i, n) cin >> l[i];

    sort(l, l + n);
    if (accumulate(l, l + n - 1, int()) > l[n - 1]) print("Yes");
    else print("No");
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

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

    ll ans = 1LL;
    while(ans*ans <= N) ans++;

    ans--;
    cout << ans*ans << endl;
}

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

public class Main{
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String[] mark = { "S", "H", "C", "D" };
		String[] allCard = new String[52];
		for (int x = 0; x < 4; x += 1) {
			for (int y = 0; y < 13; y += 1) {
				for (int z = 0; z < 52; z += 1) {
					allCard[13 * x + y] = (mark[x] + " " + Integer
							.toString(y + 1));
				}
			}
		}
		int n = Integer.parseInt(in.readLine());
		String[] myCard = new String[n];
		for (int i = 0; i < n; i += 1) {
			String[] inputMyCard = in.readLine().split(" ");
			String thisMark = inputMyCard[0];
			int num = Integer.parseInt(inputMyCard[1]);
			myCard[i] = thisMark + " " + Integer.toString(num);
		}
		Boolean[] existCard = new Boolean[52];
		for (int p = 0; p < n; p += 1) {
			for (int q = 0; q < 52; q += 1) {
				if (myCard[p].equals(allCard[q])) {
					existCard[q] = true;
				} else {
					continue;
				}
			}
		}
		for (int s = 0; s < 52; s += 1) {
			if (existCard[s] == null) {
				System.out.println(allCard[s]);
			}
		}
	}
}

Measured memory_bytes: 17476
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0);
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ll long long
#define INF 100000000
#define FOR(i,a,n) for(i=(a);i<(n);i++)
void fill(int a[],int b,int c){
	int i;
	FOR(i,0,b) a[i]=c;
	return;
}
int a[100000];
int main(void)
{
	int n,l,max=0,num,i;
	scanf("%d%d",&n,&l);
	FOR(i,0,n) scanf("%d",&a[i]);
	FOR(i,0,n-1){
		if(a[i]+a[i+1]>max){
			max=a[i]+a[i+1];
			num=i+1;
		}
	}
	if(max<l) puts("Impossible");
	else{
		puts("Possible");
		FOR(i,1,num) printf("%d\n",i);
		FOR(i,1,n-num+1) printf("%d\n",n-i);
	}
	return 0;
}
    
    


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

int main() {
    int N,M;
    cin >> N >> M;
    vector<bool> C(N, true);
    for(int i=0; i<M; ++i) {
        int a,b;
        cin >> a >> b;
        C[a - 1] = !C[a - 1];
        C[b - 1] = !C[b - 1];
    }

    for(int i=0; i<N; ++i) {
        if(!C[i]) {
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<char>> G(h, vector<char>(w));
  for(int i=0;i<h;i++) for(int j=0;j<w;j++) cin >> G[i][j];
  vector<vector<int>> dp(h, vector<int>(w));
  for(int i=0;i<w;i++) {
    if(i == 0) {
      if(G[0][i] == '#') dp[0][i] = 1;
    }
    else {
      if(G[0][i] == '.') dp[0][i] = dp[0][i-1];
      else if(G[0][i-1] == '#') dp[0][i] = dp[0][i-1];
      else dp[0][i] = dp[0][i-1] + 1;
    }
  }
  for(int i=0;i<h;i++) {
    if(i == 0) continue;
    if(G[i][0] == '.') dp[i][0] = dp[i-1][0];
    else if(G[i-1][0] == '#') dp[i][0] = dp[i-1][0];
    else dp[i][0] = dp[i-1][0] + 1;
  }
  for(int i=1;i<h;i++) {
    for(int j=1;j<w;j++) {
      if(G[i][j] == '.') dp[i][j] = min(dp[i-1][j], dp[i][j-1]);
      else {
        int up = dp[i-1][j];
        int left = dp[i][j-1];
        int upc = G[i-1][j];
        int leftc = G[i][j-1];
        int candi_1 = 0, candi_2 = 0;
        if(upc == '.') candi_1 = up + 1;
        else candi_1 = up;
        if(leftc == '.') candi_2 = left + 1;
        else candi_2 = left;
        dp[i][j] = min(candi_1, candi_2);
      }
    }
  }
  cout << dp[h-1][w-1] << endl;
}
    


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long int
#define ld long double
using namespace std;
const int N = 1e6 + 5;
const int MOD = 1e9 + 7;

int main(){
	fast;
	ll a, b;
	cin >> a >> b;
	if(abs(a - b) <= 1) cout << "Yay!";
	else cout << ":(";
	return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
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(a>b){a=b;return 1;}return 0;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}
template <class T>T gcd(T &a, T &b){if(a<b){swap(a,b);} T r = a%b; while(r!=0){a=b;b=r;r=a%b;} return b;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    debug("debug test\n");
    string s,t;cin>>s>>t;
    int ans = 0;
    rep(i, 3){
        if(s[i]==t[i])ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#define MAX_LEN 1000

char w[MAX_LEN + 1];
char t[MAX_LEN + 1];


void initArray(char *array)
{
	for (int i = 0; i < MAX_LEN + 1; i++)
	{
		array[i] = 0;
	}
}

int getLength(char *w)
{
	int len = 0;
	for (int i = 0; i < MAX_LEN + 1; i++)
	{
		if (w[i] != 0)len++;
	}
	return len;
}

void print(char *array, int a, int b)
{
	for (int i = a; i <= b; i++)
	{
		std::cout << array[i];
	}
	std::cout << std::endl;
}

void reverse(char *array, int a, int b)
{
	for (int i = a, j = 0; i <= b; i++, j++)
	{
		t[j] = array[i];
	}
	for (int i = b, j = 0; i >= a; i--, j++)
	{
		array[i] = t[j];
	}
}

void replace(char *array, int a, int b, char *v)
{
	for (int i = a, j = 0; i <= b; i++, j++)
	{
		array[i] = v[j];
	}
}


int main()
{
	scanf("%s", w);

	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		char command[10];
		scanf("%s", command);
		if (command[2] == 'i')
		{
			int a, b;
			scanf("%d %d", &a, &b);
			print(w, a, b);
		}
		else if (command[2] == 'v')
		{
			int a, b;
			scanf("%d %d", &a, &b);
			reverse(w, a, b);
		}
		else
		{
			int a, b;
			scanf("%d %d %s", &a, &b, t);
			replace(w, a, b, t);
		}
	}
}


Measured memory_bytes: 3208
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

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

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

    string S;
    cin >> S;
    Rep (i, S.length()) {
        cout << 'x';
    }
    cout << "\n";
}

Measured memory_bytes: 384
N = int(input())
a = {i+1: int(input()) for i in range(N)}

on = 1
history = {1}
ans = -1
count = 0
while True:
    on = a[on]
    count += 1
    if on == 2:
        ans = count
        break
    if on in history:
        break
    history.add(on)
print(ans)


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

#define int long long

signed main(){

  const int MAX = 11;
  int N, M;
  int q;
  vector<vector<int>> G;
  vector<vector<pair<int,int>>> col;

  cin>>N>>M;

  G.resize(N);
  col.resize(N,vector<pair<int,int>>(MAX,{0ll,-1ll}));


  for(int i = 0; i < M; i++){
    int a, b;

    cin>>a>>b;

    a--, b--;

    G[a].push_back(b);
    G[b].push_back(a);
  }

  cin>>q;

  for(int i = 0; i < q; i++){
    int u, d, c;

    cin>>u>>d>>c;

    u--;

    // col[u][d] = {c, i};

    for(int j = d; j >= 0; j--){
      col[u][j] = {c, i};
    }
  }

  for(int i = 0; i < MAX; i++){
    for(int j = 0; j < N; j++){

      for(int next : G[j]){
        for(int k = MAX-2; k >= 0; k--){
          if(col[j][k+1].second > col[next][k].second) {
            col[next][k] = col[j][k+1];
          }
          if(col[next][k+1].second > col[next][k].second) {
            col[next][k] = col[next][k+1];
          }
        }
      }
      /*
      cout<<"i = "<<i<<" j = "<<j<<endl;

      for(int k = 0; k < MAX; k++){
        cout<<"k = "<<k<<" col = "<<col[j][k].second<<" "<<col[j][k].first<<endl;
      }
      cout<<endl;
      */
    }
  }

  for(int i = 0; i < N; i++){
    cout<<col[i][0].first<<endl;
  }


  return 0;
}


Measured memory_bytes: 28020
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}



///////////////////////////




int main() {

	ll N;
	ll D, X;
	cin >> N >> D >> X;
	vector<ll> A(N + 1);
	repn(i, N) cin >> A[i];

	repn(i, N) X += (D-1) / A[i]+1;

	cout << X;

	system("PAUSE");

}


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

int main() {
	int n;
	cin >> n;
	multiset<string> A;
	while(n--) {
		string S;
		cin >> S;
		A.insert(S);
	}
	int m;
	cin >> m;
	multiset<string> B;
	int ans = 0;
	while(m--) {
		string S;
		cin >> S;
		B.insert(S);
	}
	for(auto X : A) {
		ans = max(ans, (int)A.count(X) - (int)B.count(X));
	}
	cout << ans << endl;
	return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;
/* --------------------------------------------------- */


int main() {
    int n, d;
    cin >> n >> d;
    vector<vector<int>> x(n, vector<int>(d));
    rep(i, n) {
        rep(j, d) {
            cin >> x[i][j];
        }
    }

    int ans = 0;
    rep(i, n - 1) {
        forr(j, i + 1, n) {
            int sum = 0;
            rep(k, d) {
                sum += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
            }
            rrep(k, sum) {
                if(k * k == sum) {
                    ans++;
                    break;
                }
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <set>

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

using namespace std;

typedef long long ll;


int main(){

    string S;
    string T;
    int count=0;

    cin>>S>>T;
    for(int i=0;i!=S.size();++i){
        if(S[i]!=T[i]){
            ++count;
        }
    }

    cout<<count<<endl;
}



Measured memory_bytes: 3844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

int main() {
    string O, E;  cin >> O >> E;

    if (O.size() == E.size()) {
        rep(i, O.size()) {
            cout << O[i] << E[i];
        }
    } else {
        rep(i, O.size() - 1) {
            cout << O[i] << E[i];
        }
        cout << O[O.size() - 1];
    }
}




Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <functional>
using namespace std;

int su[100001];

int main(){
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&su[i]);
        su[i] *= 2;
    }
    sort(su, su+n, greater<int>());
    int target = su[0]/2;
    int mn = su[0]+2, mnn = -1;
    for(int i=1;i<n;i++){
        if(-mn < su[i]-target && su[i]-target < mn){
            mnn = i;
            mn = su[i]-target;
            if(mn < 0) mn = -mn;
        }
    }
    printf("%d %d\n", su[0]/2, su[mnn]/2);
}

Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
int main(){
  char buf[20];
  int i=0;
  fgets(buf, sizeof(buf), stdin);
  for(i=0;i<19;i++){if(buf[i]==','){buf[i]=' ';}}
  printf("%s",buf);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  int count=0;
  string S[N];
  map<string,int> map;
  for(int i=0;i<N;i++){
    cin >> S[i];
    if(map.count(S[i])==0){
      map[S[i]]=1;
      count++;
    }
  }
  cout << count;
}


Measured memory_bytes: 25448
/*
Author : Xinyuan
*/
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef long long int ll;
const int INF = 1e9 + 7;
const int mod = 1e9 + 7;
ll powmod(ll a, ll b) {
    ll res = 1;
    a %= mod;
    assert(b >= 0);
    for (; b; b >>= 1) {
        if (b & 1) res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}
int nxt() {
    int x;
    scanf("%d", &x);
    return x;
}
vector<ll> dp, pre;

void rec(int i, const vector<int> &not_taken, ll score_so_far, int mask, int group) {
    if (i == (int)not_taken.size()) {
        dp[mask] = max(dp[mask], score_so_far + pre[group]);
        return;
    }
    rec(i + 1, not_taken, score_so_far, mask, group);
    rec(i + 1, not_taken, score_so_far, mask ^ (1 << not_taken[i]),
        group ^ (1 << not_taken[i]));
}

int main() {
    int n = nxt();
    vector<vector<ll>> in(n, vector<ll>(n));
    REP(i, n)
    REP(j, n)
    cin >> in[i][j];
    pre.resize(1 << n);
    for (int mask = 0; mask < (1 << n); mask++) {
        REP(i, n) {
            if (mask & (1 << i)) {
                for (int j = i + 1; j < n; j++)
                    if (mask & (1 << j)) pre[mask] += in[i][j];
            }
        }
    }
    dp.resize(1 << n, -INF);
    dp[0] = 0;
    for (int mask = 0; mask < (1 << n); ++mask) {
        vector<int> not_taken;
        for (int i = 0; i < n; i++) {
            if (!(mask & (1 << i))) {
                not_taken.push_back(i);
            }
        }
        rec(0, not_taken, dp[mask], mask, 0);
    }
    printf("%lld", dp[(1 << n) - 1]);
    return 0;
}

Measured memory_bytes: 4376
import collections
import math

def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N = int(input())
A = list(map(int,input().split()))

S = [A[0]] + [0] * (N-1)
for i in range(N):
  S[i] = S[i-1] + A[i]
#print(S)
C = collections.Counter(S)

ans = 0
for i in C.keys():
  if i == 0:
    ans += C[i]
  if C[i] > 1:
    ans += comb(C[i],2)
print(ans)

Measured memory_bytes: 41912
#include <stdio.h>

int main(void)
{
	int a;
	int b;
	int c;
	int d;
	
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	
	d = a - b;
	
	if (c > d){
		printf("%d",c-d);
	}
	
	else {
		printf("0");
	}
	
	return (0);
}

Measured memory_bytes: 128
n=int(input())

c0=0
c1=0
c2=0
c3=0
for i in range(n):
    s=input()
    if s=="AC":
        c0+=1
    elif s=="WA":
        c1+=1
    elif s=="TLE":
        c2+=1
    else:
        c3+=1

print("AC x", c0)
print("WA x",c1)
print("TLE x",c2)
print("RE x",c3)

Measured memory_bytes: 9144