akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

const long long MOD = 1000000007;
const long long INF = 1LL << 60;

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;
}

int main()
{
  int N;
  cin >> N;
  static int dp[400];
  int s, l, p;
  for (int i = 1; i <= N; i++)
  {
    cin >> s >> l >> p;
    for (int j = 1; j <= 400; j++)
    {
      for (int k = s; j - k >= 0 && k <= l; k++)
      {
        dp[j] = max(dp[j], dp[j - k] + p);
      }
    }
  }

  int m;
  cin >> m;

  int w;
  vector<int> ans;
  for (int i = 0; i < m; i++)
  {
    cin >> w;
    if (dp[w] == 0)
    {
      cout << -1 << endl;
      return 0;
    }
    ans.push_back(dp[w]);
  }
  for (int x : ans)
    cout << x << endl;
  return 0;
}


Measured memory_bytes: 3172
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
using namespace std;

const int MAX_N = 102;
const int INF = 1<<27;
int N;
int G[MAX_N][MAX_N];

void init() {
  fill(G[0], G[MAX_N], INF);
}

int solve(int a, int b) {
  priority_queue<pair<int,int> > que;
  bool vis[MAX_N];
  fill(vis,vis+MAX_N,false);
  que.push(make_pair(0,a));
  while(!que.empty()) {
    int cost = -que.top().first;
    int p = que.top().second;
    que.pop();
    if(vis[p]) continue;
    vis[p] = true;
    if(p == b) return cost;
    for(int i = 0; i < N; ++i) {
      if(vis[i]) continue;
      if(G[p][i] == INF) continue;
      que.push(make_pair(-cost-G[p][i],i));
    }
  }
  return -1;
}

int main() {
  int k;
  while(cin >> N >> k && (N|k)) {
    init();
    for(int i = 0; i < k; ++i) {
      int t;
      cin >> t;
      if(t == 0) {
	int a, b;
	cin >> a >> b;
	--a; --b;
	cout << solve(a,b) << endl;
      } else {
	int c, d, e;
	cin >> c >> d >> e;
	--c; --d;
	G[c][d] = G[d][c] = min(G[c][d], e);
      } 
    }
  }
  return 0;
}

Measured memory_bytes: 964
import java.util.*;

public class Main{
	
	public static void main(String[] args){
		Scanner sc= new Scanner(System.in);
        int num = sc.nextInt();
        int cut = sc.nextInt();
        int tmp, ans;
		
		for(int i=0; i<num; i++){
			tmp = sc.nextInt();
        }

        ans = (num-cut)/(cut-1) + 1;
        if((num-cut)%(cut-1) != 0) ans++;

        System.out.println(ans);

	}

}

Measured memory_bytes: 46476
#include <cstdio>
using namespace std;
const int N = 1e6 + 5, Mod = 1e9 + 7;
int ml(int x, int y) { return 1ll * x * y % Mod; }
int dc(int x, int y) { return (x - y < 0) ? (x - y + Mod) : (x - y); }
int ad(int x, int y) { return (x + y > Mod) ? (x + y - Mod) : (x + y); }
int n, f[N], fac[N], inv[N];
int ksm(int x, int y) {
	int ret = 1;
	for (; y; y >>= 1, x = ml(x, x))
		if (y & 1) ret = ml(ret, x);
	return ret;
}
void Prepare() {
	fac[0] = 1;
	for (int i = 1; i <= n; ++i) fac[i] = ml(fac[i - 1], i);
	inv[n] = ksm(fac[n], Mod - 2);
	for (int i = n - 1; i >= 0; --i) inv[i] = ml(inv[i + 1], i + 1);
}
int binom(int u, int d) {
	if (u < 0 || d < 0) return 0;
	if (u < d) return 0;
	return ml(fac[u], ml(inv[d], inv[u - d]));
}
int main() {
	scanf("%d", &n);
	Prepare();
	for (int i = 1; i <= n - 1; ++i)
		f[i] = ml(binom(i - 1, n - i - 1), ml(fac[i], fac[n - i - 1]));
	for (int i = n - 1; i >= 1; --i) f[i] = dc(f[i], f[i - 1]);
	int ans = 0;
	for (int i = 1; i <= n - 1; ++i) ans = ad(ans, ml(f[i], i));
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 14812
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  string s, t;std::cin >> s >> t;
  sort(all(s));
  sort(all(t));
  reverse(all(t));
  std::cout << (s<t?"Yes":"No") << '\n';
}


Measured memory_bytes: 256
/*
ID: espr1t
TASK: 
KEYWORDS: 
*/

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;
FILE* in = stdin; FILE* out = stdout;

const int MAX = 100001;

int n;
int a[MAX], b[MAX];

int main(void) {
	// in = fopen("C.in", "rt");
	
	fscanf(in, "%d", &n);
	for (int i = 0; i < n; i++)
	    fscanf(in, "%d", &a[i]);
	for (int i = 0; i < n; i++)
	    fscanf(in, "%d", &b[i]);
	
	int cntLess = 0;
	long long sumLess = 0;
	vector <int> more;
	for (int i = 0; i < n; i++) {
	    if (a[i] > b[i]) {
	        more.push_back(a[i] - b[i]);
        } else if (a[i] < b[i]) {
            cntLess++;
            sumLess += b[i] - a[i];
        }
    }
    sort(more.rbegin(), more.rend());
    
    int ans = cntLess;
    for (int i = 0; i < (int)more.size(); i++) {
        if (sumLess <= 0)
            break;
        sumLess -= more[i];
        ans++;
    }
    
    if (sumLess > 0) {
        fprintf(out, "-1\n");
    } else {
        fprintf(out, "%d\n", ans);
    }
 	
	return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
#include<bitset>
using namespace std;

int main() {

	long long N;
	cin >> N;

	vector<long long> A(N, 0);

	for (long long i = 0; i < N; i++) {
		cin >> A[i];
	}

	sort(A.begin(), A.end(), greater<long long>());
	
	long long ans = A[0];

	for (long long j = 1; j < N / 2; j++) {
		ans += 2 * A[j];
	}

	if (N % 2 == 1) {
		ans += A[N / 2];
	}

	cout << ans << endl;

	return 0;
}

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

const ll mod = 1000000007;

static const ll INF = 1e15;


int main(void)
{
	ll n,k;
	cin >> n >> k;
	vector<ll> vs(n);
	rep(i, n) cin >> vs[i];
	sort(vs.begin(), vs.end());
	ll st = -2e18;
	ll ed = 2e18;
	while (ed - st > 1) {
		ll mid = st + ed;
		mid /= 2;
		ll c = 0;
		rep(i, n) {
			if (vs[i] < 0)
			{
				int l = i; int r = n;
				while (r - l > 1) {
					ll m = (l + r) / 2;
					if (vs[i] * vs[m] <= mid) {
						r = m;
					}
					else {
						l = m;
					}
				}
				c += n - r;
			}
			else {
				int l = i; int r = n;
				while (r - l > 1) {
					int m = (l + r) / 2;
					if (vs[i] * vs[m] <= mid) {
						l = m;
					}
					else {
						r = m;
					}
				}
				c += l - i;
			}
		}
		if (c < k) st = mid;
		else ed = mid;
	}
	cout << ed << endl;
	return 0;
}



Measured memory_bytes: 1792
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cctype>
#include<complex>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<functional>
#include<utility>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<set>
 
using namespace std;
const int dx[2][6] = {{-1,-1,1,0,-1,0},{1,1,1,0,-1,0}},dy[] = {1,-1,0,1,0,-1};
#define INF 1e+9
#define EPS 1e-9
#define P pair<int,int>
#define rep(i,j) for(int i = 0; i < (j); i++)
#define reps(i,j,k) for(int i = j; i < (k); i++)
typedef long long ll;
int stage[128][128];
bool vis[128][128];
int main(){
    int w,h;
    int ans = 0;
    queue<P> Q;
    scanf("%d%d",&w,&h);
    rep(i,h)rep(j,w)scanf("%d",&stage[i+1][j+1]);
    Q.push(P(0,0));
    while( !Q.empty() ){
        int x = Q.front().second;
        int y = Q.front().first; 
        Q.pop();
        if(x < 0 || y < 0 || x > 110 || y > 110)continue;
        if(stage[y][x] == 1){ans++;continue;}
        if( vis[y][x]++ )continue;
        rep(i,6){
            int nx = x + dx[y%2][i];
            int ny = y + dy[i];
            Q.push(P(ny,nx));
        }
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1288
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD 1000000007

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n,k;
  cin>>n>>k;
  vector<ll> a(n);
  for(int i=0;i<n;i++){
      cin>>a[i];
  }
  vector<vector<ll>> dp(n+1,vector<ll>(k+1,0));
  for(int i=0;i<=n;i++){
      dp[i][0] = 1;
  }
  for(int i=1;i<=n;i++){
      for(int j=1;j<=k;j++){
          if(a[i-1]>=j){
              dp[i][j] = (dp[i-1][j] + dp[i][j-1])%MOD;
          }
          else{
              dp[i][j] = (((dp[i][j-1] + dp[i-1][j]))%MOD -  dp[i-1][j-a[i-1]-1]+MOD)%MOD;

              
          }
          
      }
  }
  cout<<dp[n][k]%MOD;
  
}

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

int main() {
  int N, K;
  cin >> N >> K;
  
  int sum = 1;
  for (int i = 0; i < N; i++) {
    if(sum >= K){
      sum += K;
    }
    else{
      sum *= 2;
    }
  }
  cout << sum << endl;    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる




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

  vector<int> p(n);
  rep(i,n){
    cin>>p[i];
  }

  sort(all(p));

  ll ans=0;
  rep(i,n){
    rep(j,n){
      if(i+1>=j) continue;
      auto x=ub(all(p),p[j]-p[i]);
      if(x<p.begin()+j) {
        int z=x-p.begin();
        ans+=j-max(i+1,z);
      }
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 384
// 26
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define fors(_, x, n, s) \
  for (int _ = x; _ < n; _ += s)
#define forn(_, x, n) fors(_, x, n, 1)
#define rep(_, n) forn(_, 0, n)
#define forrs(_, x, n, s) \
  for (int _ = x; _ > n; _ -= s)
#define forrn(_, x, n) forrs(_, x, n, 1)
#define rrep(_, n) forrn(_, n - 1, -1)
#define fi first
#define se second
#define pb push_back
#define pairii pair<int, int>
#define all(x) x.begin(), x.end()
#define lli __int128_t
#define li long long int
#define ld long double
#ifdef LOCAL
#define debug(e)                             \
  cerr << "\033[48;5;196m\033[38;5;15m" << e \
       << "\033[0m";
#else
#define debug(e)
#endif
// 4
template <class A, class B>
ostream &operator<<(ostream &os, pair<A, B> &p) {
  return os << "(" << p.fi << " " << p.se << ")";
}
// 8
template <class T>
ostream &operator<<(ostream &os, vector<T> &v) {
  rep(i, (int)v.size()) os << setw(7) << left << v[i];
  return os << endl;
}
// 5
template <class A, class B>
ostream &operator<<(ostream &os, map<A, B> &m) {
  for (auto &kv : m) os << kv;
  return os;
}
// 3
const li inf = 1e18;
void _main(int tc) {
  int n;
  cin >> n;
  vector<li> v(n);
  rep(i, n) cin >> v[i];
  vector<vector<li>> mem(n, vector<li>(n, -inf));
  function<li(int, int)> f = [&](int l, int r) -> li {
    if (r == l) return v[l];
    if (mem[l][r] != -inf) return mem[l][r];
    return mem[l][r] = max(v[l] - f(l + 1, r), v[r] - f(l, r - 1));
  };
  cout << f(0, n - 1) << endl;
}
// 7
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  _main(0), exit(0);
  int tc;
  cin >> tc;
  rep(i, tc) _main(i + 1);
}

Measured memory_bytes: 70912
import heapq

n, m = map(int, input().split())
a = list(map(lambda x: int(x)*(-1), input().split()))
heapq.heapify(a)

for i in range(m):
    tmp_min = heapq.heappop(a)
    #print(a)
    heapq.heappush(a, (-1)*(-tmp_min//2))  
print(-sum(a))


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

using namespace std;

int main() {
	string s;
	cin >> s;
	while(true) {
		s.pop_back();
		if(s.size() & 1) continue;
		string a = s.substr(0, s.size() / 2);
		a += a;
		if(a == s) return cout << s.size(), 0;
	}
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll              long long
#define pb              push_back
#define ppb             pop_back
#define endl            '\n'
#define mii             map<ll,ll>
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define vs              vector<string>
#define all(a)          (a).begin(),(a).end()
#define F               first
#define S               second
#define sz(x)           (ll)x.size()
#define hell            1000000007
#define inf             (ll)1e18 + 5
#define PI              3.14159265358979323844
#define rep(i,a,b)      for (ll i=a;i<b;i++)
#define repr(i,a,b)     for (ll i=a-1;i>=b;i--)
#define lbnd            lower_bound
#define ubnd            upper_bound
#define mp              make_pair
#define ios             ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ordered_set     tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define trace(...)      __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

using namespace std;
using namespace __gnu_pbds;

/*----------------------Graph Moves----------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

//primes for hashing 937,991,1013,1409,1741
ll n,x,y;
ll vis[2005];
vi a[2005];
ll level[2005][2005];

void bfs(ll source, ll meow ) {
	vis[source]=true;
	queue <ll> q;
	q.push(source);
	while(!q.empty())
	{
		ll p=q.front();
		q.pop();
		for(ll i=0;i<a[p].size();i++)
		{
			if(vis[a[p][i]] == false)
			{
				vis[a[p][i]] = true;
				q.push(a[p][i]);
				level[meow][a[p][i]] = level[meow][p] + 1;
			}
		}
	}
}

void solve() {
    cin>>n>>x>>y;
    rep(i,0,n-1){
    	a[i+1].pb(i+2);
    	a[i+2].pb(i+1);
    }
    a[x].pb(y);
    a[y].pb(x);
    rep(i,0,n){
    	bfs(i+1,i+1);
    	memset(vis,0,sizeof vis);
    }
    // bfs(1,1);
    // rep(i,0,n){
    // 	cout<<level[1][i+1]<<" ";
    // }
    // rep(i,0,n){
    // 	rep(j,0,n){
    // 		cout<<level[i+1][j+1]<<" ";
    // 	}
    // 	cout<<endl;
    // }
    ll temp[n]={0};
    rep(i,2,n+1){
    	rep(j,0,i-1){
    		//cout<<level[i][j]<<" ";
    		temp[level[i][j+1]]++;
    	}
    	//cout<<endl;
    }
    rep(i,0,n-1){
    	cout<<temp[i+1]<<endl;
    }

}

signed main() {
    ios
    ll test=1;
    //cin>>test;
    while (test--) solve();
    return 0;
}

Measured memory_bytes: 31744
N, M = map(int, input().split())
# 隣接するマスの数が偶数→裏
# 隣接するマスの数が奇数→表
# 隣接するマスの数が偶数のマスの数が答え

# 2*2以上なら辺上にないマスが全てそう
if N == 1 and M == 1:
    print(1)
elif N == 1:
    print(M - 2)
elif M == 1:
    print(N - 2)
else:
    print(N*M - 2*N - 2*M + 4)


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

int map[5][5];

bool all(int x, int y, int l){
    int s = 0;
    for(int i = y; i <= y+l; i++){
        s += map[x][i];
    }
    return s == l+1;
}

int main(){
    int n;
    int max_area;
    string dummy;
    cin >> n;
    while( n-- > 0 ){
        for(int i = 0; i < 25; i++){
            cin >> map[i/5][i%5];
        }
        max_area = 0;
        for(int x = 0; x < 5; x++){
            for(int y = 0; y < 5; y++){
                for(int i = 0; i+y < 5; i++){
                    for(int j = 0; j+x < 5; j++){
                        if( !all( x+j, y, i ) ) break;
                        max_area = max(max_area, (i+1)*(j+1));
                    }
                }
            }
        }
        cout << max_area << endl;
        getline(cin, dummy);
    }
    return 0;
}

Measured memory_bytes: 1168
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;


int inputValue(){
    int a;
    cin >> a;
    return a;
};

long inputValueLong(){
    long a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

int main(int argc, const char * argv[]) {
    
    // source code
    long N = inputValueLong();
    char S[N];
    scanf("%s", S);
    int sum = 1;
    int i;
    char tmp = S[0];
    for(i=1;i<N;i++){
        if(S[i]!=tmp){
            sum++;
            tmp = S[i];
        }
    }
    cout << sum << endl;
    
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <set>
using namespace std;
const int MAXN = 1005;
const int inf = 0x3f3f3f3f;
typedef long long LL;
set<string>st;
int main()
{
    string s;
    int k;
    cin>>s>>k;
    int len = s.size();
    for(int i=0;i<len;++i)
    {
        string tmp="";
        for(int j=i;j<len&&j<=i+5;++j)
        {
            tmp+=s[j];
            st.insert(tmp);
        }
    }
    set<string>::iterator it;
    int c=1;
    for(it=st.begin();it!=st.end()&&c<k;++it,c++);
    cout<<*it<<endl;
    return 0;
}




Measured memory_bytes: 2176
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 1_000_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "begin", long, "end");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

void main()
{
    long h, w;
    scan(h, w);
    auto n = lread();
    auto a = aryread();
    auto table = new long[][](h, w);
    ulong h_iter, w_iter;
    foreach (i; iota(n))
    {
        while(a[i] > 0)
        {
            if((w_iter / w) % 2)
                table[h_iter][w  - 1 - (w_iter % w)] = i + 1;
            else
                table[h_iter][(w_iter % w)] = i + 1;
            
            w_iter++;
            if(w_iter % w == 0)
                h_iter++;
            a[i]--;
        }
    }
    foreach (e; table)
    {
        foreach (f; e)
            writef("%s ", f);
        writeln();
    }
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  ll n; cin>>n; n--;
  ll base = 26LL;
  int len=1;
  while(true){
    if(n<base)break;

    len++;
    n-=base;
    base*=26LL;
  }

  vector<char>result;
  rep(i, len){
    result.push_back( (char)('a'+(int)(n%26LL)) );
    n/=26LL;
  }
  rrep(i, len)cout<<result[i];

  return 0;
}

Measured memory_bytes: 3628
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
#pragma GCC target ("sse4")
#pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

#define deb(x) cout << #x << " is " << x << "\n";

using namespace std;
using namespace __gnu_pbds;

const double PI = 2 * acos(0.0);
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	long long n;
	cin >>n;
	vector<long long> arr(n);
	for(long long i = 0; i < n; i++)
		cin >>arr[i];
	unordered_map<long long, long long> mp;
	for(auto ele : arr)
		mp[ele]++;
	long long ans = 0LL;	
	for(auto x : mp) {
		if(x.second >= 2) {
			ans += ((x.second * (x.second - 1)) / 2);
		}
	}
	for(auto ele : arr) {
		long long temp = ans;
		if(mp[ele] >= 2) {
			temp -= (mp[ele] * (mp[ele] - 1) / 2);
		}
		if(mp[ele] - 1 >= 2) {
			if(mp[ele] - 1 == 2) {
				temp += 1;
			} 
			else {
				temp += ((mp[ele] - 1) * (mp[ele] - 2) / 2);
			}
		}
		cout <<temp <<"\n";
	}
	return 0;
}


Measured memory_bytes: 9160
#https://note.nkmk.me/python-gcd-lcm/
#lcm(a, b) = a * b / gcd(a, b)
import fractions

a, b = map(int, input().split(' '))

def lcm(a, b):
    return a * b / fractions.gcd(a, b)

print(int(lcm(a, b)))

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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    int a;cin >> a;
    if(a<1000)cout << "ABC" << endl;
    else cout << "ABD" << endl;
}


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

int main(){
	int X, Y, W, H, x, y, n, T;
	scanf("%d", &T);
	while(T--){
		scanf("%d%d%d%d%d", &X, &Y, &W, &H, &n);
		int ans = 0;
		for(int i = 0; i < n; ++i){
			scanf("%d%d", &x, &y);
			if(x >= X && x <= X + W && y >= Y && y <= Y + H){
				++ans;
			}
		}
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 1028
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();

            System.out.println(Integer.toString(n, k).length());
        }

    }
}



Measured memory_bytes: 21716
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef unsigned long long u64;

#define N (62500)

u64 dp[N + 1000];

int main(void) {
  int n;
  scanf("%d", &n);
  
  dp[0] = 1;

  int s = 0;
  while (n--) {
    int a;
    scanf("%d", &a);

    s += a;

    int H = a / 64;
    int L = a % 64;

    if (L == 0) {
      for (int i = N; i >= 0; i--) {
        dp[i + H] |= dp[i];
      }
    } else {
      for (int i = N; i >= 0; i--) {
        dp[i + H + 1] |= dp[i] >> (64 - L);
        dp[i + H] |= dp[i] << L;
      }
    }
  }

  s = (s + 1) / 2;
  while (~dp[s / 64] >> s % 64 & 1) s++;

  printf("%d\n", s);

  return 0;
}


Measured memory_bytes: 640
n,q = [ int(s) for s in input().split() ]
  
queue = []
for i in range(n):
    name, time = input().split()
    queue.append( (name, int(time)) )

total = 0

while len(queue) > 0:
    name, time = queue.pop(0)
    if time > q:
        total += q
        queue.append((name, time - q))
    else:
        total += time
        print(name, total)


Measured memory_bytes: 12244
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <queue>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair <int,ll> pii;
typedef vector<int> vi;
vi charcnt(3);
string s;
int main(void)
{
  cin >> s;
  for(int i=0;i<s.size();i++)
    {
      if(s[i]=='a') charcnt[0]++;
      else if(s[i]=='b') charcnt[1]++;
      else charcnt[2]++;
    }
  if(abs(charcnt[0]-charcnt[1])<=1 && abs(charcnt[1]-charcnt[2])<=1 && abs(charcnt[0]-charcnt[2])<=1)
    {
      cout << "YES" << endl;
      return 0;
    }
  else 
    {
      cout << "NO" << endl;
      return 0;
    }
}




Measured memory_bytes: 512
# coding=utf-8


def main():
    def sub():
        n = input()
        i = 1
        s = ''
        # ---------------------------------------------------------------------
        # CHECK_NUM
        while True:
            x = i
            if x % 3 == 0:
                s += ' '+str(i)
                # -----------------------
                # END_CHECK_NUM
                i += 1
                if i <= n:
                    # goto CHECK_NUM
                    continue
                else:
                    # END!!
                    break
                # -----------------------
            # -----------------------------------------------------
            # INCLUDE3
            while True:
                if x % 10 == 3:
                    s += ' '+str(i)
                    # -----------------------
                    # END_CHECK_NUM
                    i += 1
                    if i <= n:
                        # goto INCLUDE3
                        break
                    else:
                        # END!!
                        return s
                    # -----------------------
                else:
                    x /= 10
                    if x:
                        # goto INCLUDE3
                        continue
                    else:
                        # -----------------------
                        # END_CHECK_NUM
                        i += 1
                        if i <= n:
                            # goto CHECK_NUM
                            break
                        else:
                            # END!!
                            return s
                        # -----------------------
            # -----------------------------------------------------
        # ---------------------------------------------------------------------
        return s
    print sub()

if __name__ == '__main__':
    main()

Measured memory_bytes: 4260
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;


int N;
vector<double> x,y;
double ans = 0.0;
double nn = 0;

void dfs(int n, vector<bool> ff, double dd){
    int ss = 0;
    rep(i,N) if(!ff[i]) ss++;
    if(ss == N){
        ans += dd;
        nn++;
       // cout << nn << " " << dd << endl;
        return;
    }
    
    rep(i,N){
        if(ff[i]){
            vector<bool> fff = ff;
            fff[i] = false;
            dfs(i,fff,dd+sqrt((x[n]-x[i])*(x[n]-x[i])+(y[n]-y[i])*(y[n]-y[i])));
        }
    }
    
}


int main()
{
    cin >> N;
    x.resize(N);
    y.resize(N);
    rep(i,N) cin >> x[i] >> y[i];
    
    vector<bool> f(N,true);
    
    rep(i,N){
        vector<bool> f(N,true);
        f[i] = false;
        double aa = 0.0;
        dfs(i,f,aa);
    }
    cout << fixed << setprecision(15);
    cout << ans/nn << endl;
    
    return 0;
}



Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CVacation solver = new CVacation();
        solver.solve(1, in, out);
        out.close();
    }

    static class CVacation {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int days = in.nextInt();
            int[][] dayvals = new int[days][3];
            for (int r = 0; r < days; r++) {
                for (int c = 0; c < 3; c++) {
                    dayvals[r][c] = in.nextInt();
                }
            }
            int[][] dp = new int[days + 1][3];
            for (int r = 1; r <= days; r++) {
                for (int c = 0; c < 3; c++) {
                    int max = Integer.MIN_VALUE;
                    for (int ct = 0; ct < 3; ct++) {
                        if (ct != c) max = Math.max(dayvals[r - 1][ct] + dp[r - 1][ct], max);
                    }
                    dp[r][c] = max;
                }
            }
            int max = 0;
            for (int c : dp[dp.length - 1]) max = Math.max(max, c);
            out.println(max);
        }

    }
}



Measured memory_bytes: 100592
#include <cstdio>
#include <cstring>
//#include <cmath>
//#include <iostream>
//#include <algorithm>
#include <queue>
/*#include <set>
#include <vector>
#include <stack>
#include <map>
#include <bitset>*/
#define ri register
#define inf 0x7fffffff
#define E (1)
#define mk make_pair
#define int long long
//#define double long double
using namespace std; const int N=2000010, Mod=1e9+7;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch-'0'), ch=getchar();
    return s*w;
}
void print(int x) { if(x<0) x=-x, putchar('-'); if(x>9) print(x/10); putchar(x%10+'0'); }
int h,w,k,x1,x2,y1,y2,dis[N],book[N]; char s[N],c[N];
const int step[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
struct Node{ int x,y; };
queue<Node> Q;
signed main()
{
    h=read(), w=read(), k=read();
    x1=read(), y1=read(), x2=read(), y2=read();
    x1--, x2--, y1--, y2--;
    for(ri int i=0;i<h;i++)
    {
        scanf("%s",s);
        for(ri int j=0;j<w;j++) c[i*w+j]=s[j];
    }
    memset(dis,0x3f,sizeof(dis));
    dis[x1*w+y1]=0; book[x1*w+y1]=1;
    Q.push((Node){x1,y1});
    while(!Q.empty())
    {
        Node now=Q.front(); Q.pop();
        int nx=now.x, ny=now.y;
        book[nx*w+ny]=0;
        if(nx==x2 && ny==y2) { printf("%lld\n",dis[x2*w+y2]); return 0; }
        for(ri int i=0;i<4;i++)
        for(ri int j=1;j<=k;j++)
        {
            int u=nx+j*step[i][0];
            int v=ny+j*step[i][1];
            if(u<0||u>=h||v<0||v>=w) break;
            if(c[u*w+v]=='@' || dis[nx*w+ny]>=dis[u*w+v]) break;
            if(dis[nx*w+ny]+1<=dis[u*w+v])
            {
                dis[u*w+v]=dis[nx*w+ny]+1;
                if(!book[u*w+v])
                {
                    book[u*w+v]=1;
                    Q.push((Node){u,v});
                }
            }
        }
    }
    puts("-1");
    return 0;
}

Measured memory_bytes: 26520
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <iostream>
using namespace std;

int main()
{
	char a[5], b[5];
	cin >>a + 1;
	cin >>b + 1;
	if (a[1] == b[3] && a[2] == b[2] && a[3] == b[1])
		cout <<"YES" <<endl;
	else cout <<"NO" <<endl;
	return 0;
}

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

int main(){
  ll a;
  cin>>a;
  cout<<fixed<<setprecision(10);
  cout<<(a*a*a+0.0)/27<<endl;
}

Measured memory_bytes: 256
n = int(input())
tasks = []
for i in range(n):
    a,b = map(int, input().split())
    tasks.append((a,b))

tasks.sort(key=lambda x:x[1])
#print(tasks)

cur = 0
c = True
for i in range(n):
    cur += tasks[i][0]
    if cur > tasks[i][1]:
        c = False

print("Yes" if c else "No")

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

vector<int> arr[100010] = {};
int f[100010] = {};
int f2[100010] = {};

int n;

int dfs(int i,int j){
    
    if(i == n){
        f2[i] = 2;
        return f[i] = j;
    }
    
    if(f[i])
        return 0;
    
    //cout << i << " " << j << endl;
    
    f[i] = j;
    int res = 0;
    
    for( int next : arr[i] ){
        res = dfs(next,j+1);
        if(res){
            //cout << (res+1)/2 << " " << j << endl;
            if((res+1)/2 >= j){
                f2[i] = 1;
            }else{
                f2[i] = 2;
            }
        
            return res;
        }
    }
    
    return res;
}

int dfs2(int i,int j){
    
    if( f2[i] != 0 ){
        return 0;
    }
    
    f2[i] = j;
    
    for( int next : arr[i] ){
        dfs2(next,j);
    }
    return 0;
}

int main(void){
    
    cin >> n;
    
    for(int i = 0; i < n-1; i++){
        int a,b;
        scanf("%d %d",&a,&b);
        
        arr[a].push_back(b);
        arr[b].push_back(a);
        
    }
    
    int res = dfs(1,1);
    
    for(int i = 1; i <= n; i++){
        if(f2[i] != 0){
            for(int next : arr[i]){
                dfs2(next,f2[i]);
            }
        }
    }
    
    res = 0;
    
    for(int i = 1; i <= n; i++){
        //cout << f2[i] << " ";
        if( 1 == f2[i]){
            res++;
        }
    }
    //cout << endl;
    
    if(res > n-res){
        puts("Fennec");
    }else{
        puts("Snuke");
    }
    
}


Measured memory_bytes: 11136
#include<stdio.h>
int main(){
    int n,m,i,j;
    int L[100001];
    int R[100001];
    int count = 0;
    
    scanf("%d %d",&n,&m);
    for(i = 1 ; i <= m ; i++) scanf("%d %d",&L[i],&R[i]);
    int tmp1 = L[1];
    int tmp2 = R[1];
    
    for(i = 1 ; i <= m ; i++){
        if(L[i] > tmp1){
            tmp1 = L[i];
        }
        if(R[i] < tmp2){
            tmp2 = R[i];
        }
    }
    
//    for(i = 1 ; i <= n ; i++) printf("%d ",flag[i]);
    if(tmp1 <= tmp2) printf("%d\n",tmp2-tmp1+1);
    else printf("0\n");
    return 0;
}


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

#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<
#define sz(x) ((int) x.size())
#define pb(x) push_back(x)

typedef long long ll;
typedef pair<int, int> point;

const int MAXN = 2e5 + 5;

struct event{
    int pos = 0, tip = 0, id = 0;
    event(){};
    event(int _pos, int _tip, int _id){
        pos = _pos; tip = _tip; id = _id;
    }

    friend bool operator < (const event A, const event B){
        if(A.pos != B.pos) return A.pos < B.pos;
        return A.tip < B.tip;
    }
};

int n, m;
vector <event> v;
bool bio[MAXN];

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

    cin >> n >> m;
    REP(i, m){
        int a, b; cin >> a >> b;

        if(a > b) swap(a, b);
        v.pb(event(a, 1, i));
        v.pb(event(b, -1, i));
    }
    sort(v.begin(), v.end());

    int sol = 0;
    vector <int> curr;

    for(auto it : v){
        if(it.tip == 1){
            curr.pb(it.id);
        }
        else{
            if(bio[it.id]) continue;

            for(auto it2 : curr)
                bio[it2] = true;
            curr.clear();

            sol ++;
        }
    }
    cout << sol;
}


Measured memory_bytes: 4980
#include<stdio.h>

#define MAX 1000000

int main(){
  int n,A[MAX];
  int i,j;
  int x,a,b,c;

  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);
  
  x=A[n-1];
  i=-1;
  for(j=0;j<=n-1;j++){
    if(A[j]<=x){
      i=i+1;
      a=A[i];
      A[i]=A[j];
      A[j]=a;
    }
  }
  for(j=0;j<n-1;j++){
    if(j==i)printf("[",A[j]);
    printf("%d",A[j]);
    if(j==i)printf("]",A[j]);
    printf(" ");
  }
  printf("%d",A[j]);
  printf("\n");
  return 0;
}



Measured memory_bytes: 2148
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int k, n; cin>>k>>n;
  k--;
  int a[n], diff[n-1]; 
  for(int i = 0 ; i < n; i++)cin>>a[i];
  sort(a,a+n);
  int net = a[n-1] - a[0];
  if(n>1&&(k<n))
  {
  for(int i = 0 ; i<n-1; i++)diff[i] = a[i+1] - a[i];
  sort(diff,diff+n-1);
   int j = n-2;
  while(k--){net-=diff[j]; j--;}
  }
  else if(k>=n) net = 0;
  cout<<net<<endl;
  
}


Measured memory_bytes: 1024
using System;
class Code_01
{
    public static void Main()
    {

        string Datas = Console.ReadLine();
        string Weapons = Console.ReadLine();
        int EnemyHP = int.Parse(Datas.Split(' ')[0]);
        int Weapon_Num = int.Parse(Datas.Split(' ')[1]);
        string[] WeP = Weapons.Split(' ');
        int Total_Power = 0;
      //  int[] Powers = new int[Weapon_Num];
        bool OK = false;
        for (int i = 0; i < Weapon_Num; i++)
        {
            Total_Power += int.Parse(WeP[i]);
            if (Total_Power >= EnemyHP)
            {
                Console.WriteLine("Yes");
                OK = true;
                break;
            }
        }
        if (OK == false)
        {
            Console.WriteLine("No");
        }

    }
}


Measured memory_bytes: 18016
//81
#include <iostream>
using namespace std;
int main () {
	int n;	cin >> n;
	for (int i = 1; i <= 9; i++) {
		for (int j = 1; j <= 9; j++) {
			if (n == i * j) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MAX 3004
#define rrep(i,n) for(int i = 1;i <= n;i++)

int a[MAX], b[MAX], res[MAX];
int dp1[MAX][MAX], dp2[MAX][MAX];//店,時間
int main(){
	int n, t, s;
	scanf("%d%d%d", &n, &t, &s);
	rrep(i,n)scanf("%d%d", &a[i], &b[i]);
	
	for(int i = 1;i <= n;i++){
		for(int j = s;j >= 0;j--){
			dp1[i][j] = max(dp1[i][j], dp1[i-1][j]);
			if(b[i] <= j)
			dp1[i][j] = max(dp1[i][j], dp1[i-1][j-b[i]]+a[i]);
		}
	}
	
	for(int i = 1;i <= n;i++){
		int m = n-i+1;
		for(int j = t-s;j >= 0;j--){
			dp2[i][j] = max(dp2[i][j], dp2[i-1][j]);
			if(b[m] <= j)
			dp2[i][j] = max(dp2[i][j], dp2[i-1][j-b[m]]+a[m]);
		}
	}
	
	int ans = 0;
	for(int i = 1;i <= n;i++)res[i] = max(res[i-1], dp2[i][t-s]);
	for(int i = 0;i <= n;i++){
		ans = max(ans, dp1[i][s]+res[n-i]);
	}
	
	printf("%d\n", ans);
	return 0;
}


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

#pragma GCC optimize(2)

#define rep(i, l, r) for (int i = (l); i <= (r); ++i)
#define per(i, r, l) for (int i = (r); i >= (l); --i)
using namespace std;

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

int gi() {
	int f = 1, x = 0;
	char ch = getchar();
	while (ch < '0' || ch > '9') {
		if (ch == '-') f = -1;
		ch = getchar();
	}
	while (ch >= '0' && ch <= '9') {
		x = (x << 1) + (x << 3) + ch - '0';
		ch = getchar();
	}
	return f * x;
}

int main() {
	int n = gi();
	vi v(n);
	for (int i = 0; i < n; i++) v[i] = gi();
	int Mx = 0x3f3f3f3f, cnt = 0;
	for (int i = 0; i < n; i++) {
		Mx = min(Mx, v[i]);
		if (Mx >= v[i]) ++cnt;
	}
	cout << cnt << endl; 
  return 0;
}


Measured memory_bytes: 1024
n = int(input())
Cards = []
S = [0,1,2,3,4,5,6,7,8,9,10,11,12,13]
H = [0,1,2,3,4,5,6,7,8,9,10,11,12,13]
C = [0,1,2,3,4,5,6,7,8,9,10,11,12,13]
D = [0,1,2,3,4,5,6,7,8,9,10,11,12,13]
for i in range(n):
    Suit,Rank = map(str, input().split())
    Cards.append([Suit,Rank])
for j in range(len(Cards)):
    if Cards[j][0] == 'S':
        for k in range(1,13+1):
            if int(Cards[j][1]) == k:
                S[k] = 0
    elif Cards[j][0] == 'H':
        for k in range(1,13+1):
            if int(Cards[j][1]) == k:
                H[k] = 0
    elif Cards[j][0] == 'C':
        for k in range(1,13+1):
            if int(Cards[j][1]) == k:
                C[k] = 0
    elif Cards[j][0] == 'D':
        for k in range(1,13+1):
            if int(Cards[j][1]) == k:
                D[k] = 0
for a in S:
    if S[a] != 0:
        print('S',S[a])
for a in H:
    if H[a] != 0:
        print('H',H[a])
for a in C:
    if C[a] != 0:
        print('C',C[a])
for a in D:
    if D[a] != 0:
        print('D',D[a])


Measured memory_bytes: 5612
import java.util.*;

public class Main {

	public static void main(String[] args) {

		// A 以上 B 以下の整数の中で、小さい方から K 番目以内であるか、大きい方から K 番目以内である
		Scanner sc = new Scanner(System.in);

		// 1≤A≤B≤109
		// 1≤K≤100
		int A = sc.nextInt();
		int B = sc.nextInt();
		int K = sc.nextInt();

		int i;
		for (i = A; i < A + K && i <= B; i++) {
			System.out.println(i);
		}

		int t = B - K + 1;
		if (i >= t) {
			t = i;
		}
		for (i = t; i <= B; i++) {
			System.out.println(i);
		}

	}
}


Measured memory_bytes: 22996
import sys
if sys.version_info[0]>=3: raw_input=input

n=int(raw_input())
for i in range(0,n):
	a=[int(e) for e in raw_input().split()]
	a[0]-=1;a[1]-=1
	print(196471-a[0]*195-a[0]//3*5-a[1]*20+(a[1]//2 if a[0]%3!=2 else 0)-a[2])

Measured memory_bytes: 6724
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>
#include <cstdio>
#include <iomanip>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>()>
#define pb push_back
#define vec vector<int>
#define vecvec vector<vector<int>>
#define vecll vector<ll>
#define vecvecll vector<vector<ll>>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
#define mp make_pair
using namespace std;
int in(){int x;scanf("%d",&x);return x;}
string stin(){string s;cin>>s;return s;}
ll lin(){ll x;scanf("%lld",&x);return x;}
int main(){
    int m=in(),k=in();
    if(k>=1<<m||k==1&m==1){
        cout<<-1<<endl;
        return 0;
    }
    if(k!=0){
        rep3(i,(1<<m)-1,1){
            if(i==k)continue;
            cout<<i<<" ";
        }
        cout<<"0 "<<k<<" ";
        rep2(i,1,(1<<m)-1){
            if(i==k)continue;
            cout<<i<<" ";
        }
        cout<<k<<" 0"<<endl;
    }
    if(k==0){
        rep(i,1<<m)cout<<i<<" ";
        rep3(i,(1<<m)-1,0)cout<<i<<" ";
        cout<<endl;
    }
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		long k = sc.nextLong();

		long tempA = a;
		long tempB = b;
		long tempC = c;

		if(a-b > 1000000000000000000L || b-a>1000000000000000000L) {
			System.out.println("Unfair");
		}else {
			if(k%2==0) {
				System.out.println(a-b);
			}else {
				System.out.println(b-a);
			}
			}
		}

}


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

/*ソートの時に使う
int sort(const void *a, const void *b){
    return *(int*)a-*(int*)b ;
}
    qsort (data,sizeof(data),sizeof(int),sort); 
*/

int main(void){
    int n;
    scanf("%d",&n);
    int t[n],x[n],y[n];
    for (int i=0; i<n; i++){
        scanf("%d%d%d",&t[i],&x[i],&y[i]);
    }
    
    for (int i=0; i<n; i++){
        if(i==0 && t[i]>=(x[i]+y[i]) && (t[i]-(x[i]+y[i]))%2==0 ){
            
        } else if ( (t[i]-t[i-1]) >= (abs(x[i]-x[i-1])+abs(y[i]-y[i-1])) && ( (t[i]-t[i-1])-( abs(x[i]-x[i-1])+abs(y[i]-y[i-1]) ) )%2==0 ){
            
        } else {
            printf("No\n");
            exit (0) ;
        }
    }
    printf ("Yes\n");
	return 0 ;
}

Measured memory_bytes: 1280
#include<stdio.h>

int main(){
  int i,j,tmp;
  int mon[9];
  for(i=0;i<10;i++){
    scanf("%d\n",&mon[i]);
  }
  for (i=0; i<10; ++i) {
    for (j=i+1; j<10; ++j) {
      if (mon[i] < mon[j]) {
        tmp =  mon[i];
        mon[i] = mon[j];
        mon[j] = tmp;
      }
    }
  }

  for(i=0;i<3;i++){
    printf("%d\n",mon[i]);
  }

  return 0;
}

Measured memory_bytes: 604
open System

let f () = stdin.ReadLine() |> int

let a = f ()
let b = f ()
let c = f ()
let t = f ()

[for i in [0..a] do
    for j in [0..b] do
        for k in [0..c] do
            yield 500 * i + 100 * j + 50 * k]
|> List.sumBy (fun x -> if x = t then 1 else 0)
|> printfn "%d"

Measured memory_bytes: 38608
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
  int i,sb=0;
  string s;
  cin >> s;
  for (i=0;i<s.size();i++) if (s[i]-'0'==i%2) sb++;
  cout << min(sb,(int)s.size()-sb) << endl;
  return 0;
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main(){
    int N,M;
    cin >> N >> M;
    int ans = 0;
    int t = 0;
    if(N > 1) t = N * (N - 1);
    ans += t / 2,t = 0;
    if(M > 1) t = M * (M - 1);
    ans += t / 2;

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

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
using namespace std;

int main(void)
{
  int n,k,m,j;
  double x[1001], y[1001], z[5];

  cin >> n;
  for(k = 1; k <= n; k++){
    cin >> x[k];
  }
  for(k = 1; k <= n; k++){
    cin >> y[k];
  }
  for(m = 1; m <= 4; m++){
    z[m] = 0;
    for(k = 1; k <= n; k++){
      j = m;
      if(j != 4)
        z[m]=z[m]+pow(abs(x[k]-y[k]),j);
      else
        {j=1; z[m]=max(z[m],abs(x[k]-y[k]));}
    }
    z[m]=pow(z[m],1.0/j);
    cout << fixed << setprecision(6) << z[m] << endl;
  }     
  return 0;
}

Measured memory_bytes: 3440
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

ll n,m;
vector<string> A(50),B(50);

bool isok(ll i, ll j) {
	ll x,y;
	for(x=0;x<m;x++) {
		for(y=0;y<m;y++) {
			if (A[i+x][j+y] != B[x][y] ) return false;
		}
	}
	return true;
}
int main() {
	ll		a,b,c,h,i,j,k,l,x,y;
	ll		ans = 0;
	string	s;
	cin >> n >> m;

	for(i=0;i<n;i++) cin >> A[i];
	for(i=0;i<m;i++) cin >> B[i];

	bool ok;
	for(i=0;i<=(n-m);i++) {
		for(j=0;j<=(n-m);j++) {
			ok = isok(i,j);
			if (ok) break;
		}
		if (ok) break;
	}
	//vector<ll>	aa(n);
	//for(i=0;i<n;i++) cin >> aa[i];
	//vector<ll>	dp(n+1,INFL);
	//vector<vector<ll>>	dp2(x , vector<ll>(y,INFL));

	if (ok) {
		cout << "Yes" << endl;
	}	else {
		cout << "No" << endl;
	}
	return 0;
}


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

using namespace std;

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

  for (int i = 0; i < (1 << 3); i++) {
    int sum = s[0] - '0';
    for (int j = 0; j < 3; j++) {
      if ((i >> j) & 1) {
        sum += s[j + 1] - '0';
      } else {
        sum -= s[j + 1] - '0';
      }
    }
    if (sum == 7) {
      cout << s[0];
      for (int j = 0; j < 3; j++) {
        if ((i >> j) & 1) {
          cout << "+";
        } else {
          cout << "-";
        }
        cout << s[j + 1];
      }
      cout << "=7\n";
      break;
    }
  }

  return 0;
}

Measured memory_bytes: 256