akhauriyash/Code-Regression huggingface dataset:
def nCk(n,k):
    ret=1
    if n<k or k<0 or n<0:return 0
    if n-k<k:
        k=n-k
    for i in xrange(n,n-k,-1):
        ret=ret*i
    fact=[1]*(k+1)
    for i in xrange(1,k+1):
        fact[i]=fact[i-1]*i
    return ret/fact[k]

n,a,b=map(int,raw_input().split())
v=map(int,raw_input().split())
v=sorted(v,reverse=True)
if a==n:
    print float(sum(v[0:a]))/a
    print 1
    exit()

num=0
l=0
if v[a]==v[a-1]:
    start=a-1
    for i in xrange(a-1,0,-1):
        if v[i]==v[i-1]:
            start=i-1
        else:
            break
    if start==0:
        cnt=1
        for i in xrange(n-1):
            if v[i]==v[i+1]:
                cnt+=1
        pt=0
        for i in xrange(a,b+1):
            if cnt<i:break
            pt+=nCk(cnt,i)
        print float(sum(v[0:a]))/a
        print pt
    else:
        cnt=1
        for i in xrange(start,n-1):
            if v[i]==v[i+1]:
                cnt+=1
        pt=0
        for i in xrange(a-start,b+1):
            if start+i<a:continue
            if start+i>a:break
            pt+=nCk(cnt,i)
        print float(sum(v[0:a]))/a
        print pt

else:
    print float(sum(v[0:a]))/a
    print 1


Measured memory_bytes: 28780
a = int(input())
b = int(input())
c = int(input())
x = int(input())
variation = 0

for na in range(a+1):
     for nb in range(b+1):
        for nc in range(c+1):
            if x == 500 * na + 100 * nb + 50 * nc: 
                variation += 1

print(variation)

Measured memory_bytes: 3060
h,w = gets.split.map(&:to_i)
s = h.times.map{gets.chomp}


dx = [0,1,0,-1]
dy = [1,0,-1,0]
f = h.times.map.all?{|i|
  w.times.map.all?{|j|
    ff = (s[i][j] == "#")? false : true
    4.times{|k|
      ni = i+dy[k]
      nj = j+dx[k]
      if 0<=ni && ni<h && 0<=nj && nj<w 
        if s[i][j] == "#" && s[ni][nj] == "#"
          ff = true
        end
      end
    }
    ff
  }
}

puts f ? "Yes" : "No"

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

#define rep(i,n) for(int i=0; i<n; i++)
double dp[16][9];

int main(){
	int n;
	char s, t, b;
	while( scanf("%d",&n), n ){
		scanf(" %c %c %c", &s, &t, &b);
		memset( dp, 0, sizeof(dp) );
		dp[0][s-'A'] = 1.0;
		rep(i,n){
			rep(j,9){
				if(j-3>=0 && b-'A'!=j-3)	dp[i+1][j-3] += dp[i][j]/4.0;
				else						dp[i+1][j]   += dp[i][j]/4.0;
				if(j%3!=0 && b-'A'!=j-1)	dp[i+1][j-1] += dp[i][j]/4.0;
				else						dp[i+1][j]   += dp[i][j]/4.0;
				if(j%3!=2 && b-'A'!=j+1)	dp[i+1][j+1] += dp[i][j]/4.0;
				else						dp[i+1][j]   += dp[i][j]/4.0;
				if(j+3< 9 && b-'A'!=j+3)	dp[i+1][j+3] += dp[i][j]/4.0;
				else						dp[i+1][j]   += dp[i][j]/4.0;
			}
		}
		printf("%.7lf\n",dp[n][t-'A']);
	}
	return 0;
}

Measured memory_bytes: 1068
#include <bits/stdc++.h>
using namespace std;
const int maxN = 2 * (int)1e5 + 10;
int n;
int a[maxN];
int nxt[maxN];
int main() {
    //freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(false);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    a[n + 1] = -1;
    for (int i = n; i >= 1; i--) {
        if (a[i + 1] != 0) nxt[i] = i + 1;
        else nxt[i] = nxt[i + 1];
    }
    long long ans = 0;
    for (int l = 1; l <= n; l++) {
        int ind = l;
        int curxor = a[l];
        int cursum = a[l];
        while (ind <= n) {
            ind = nxt[ind];
            if (ind > n) break;
            curxor ^= a[ind];
            cursum += a[ind];
            if (curxor != cursum) break;
        }
        ans += ind - l;
    }
    cout << ans;
	return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ls( s) (s&(-s))
#define ll long long
#define inf 0x3f3f3f3f
#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 2e5;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =    2019;

int main()
{  fast
ll x;
cin>>x;
for(ll i=-999;i<=1000;i++ )
{
	ll y=i*i*i*i*i;
	for(ll j=-1000;j<=i;j++)
	{
		ll z=j*j*j*j*j;
		if(y-z==x)
		{
			cout<<i<<" "<<j;
			return 0;
		}
	}
}
}


Measured memory_bytes: 3608
import java.io.IOException;
import java.util.Scanner;

public class Main
{
    public static void main(String arg[])
    {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        int c = Integer.parseInt(a);

        int num = c / 3600;

        int k = c - num*3600;

        int i = k / 60;

        int h = k-i*60;

        System.out.println(num+":"+i+":"+h);
    }

}



Measured memory_bytes: 26100
#include <iostream>
#include <cstdio>

using namespace std;

double round(double x)
{
	return (int)(x + 0.5 - (x < 0));
}

int main()
{
	int a,b,c,d,e,f;
	while(cin>>a>>b>>c>>d>>e>>f)
	{
		double x = (double)(c*e - b*f) / (a*e - b*d);
		double y = (double)(a*f - c*d) / (a*e - b*d);
		x = round(1000 * x) / 1000.0;
		y = round(1000 * y) / 1000.0;
		printf("%.3f %.3f\n", x, y);
	}
	return 0;
}

Measured memory_bytes: 0
/**
*    created: 20.06.2020 02:58:17
**/
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

signed main() {

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

    int n,k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    sort(h.begin(),h.end());
    int mn = 10000000000;
    rep(i,n-k+1) mn = min(mn,h[i+k-1]-h[i]);
    cout << mn << endl;
    return 0;
}

Measured memory_bytes: 3920
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int,int,int> T;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 0; i < n; i++)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define int long long
#define pb push_back
#define mp make_pair
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
//const int MOD = (998244353);
//const int INF = (1 << 30)-1;
const int INF = (1LL << 60)-1;
const double EPS = (1 >> 30);

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

using Graph = vector<vector<pair<int, int>>>;
using Ki = vector<vector<int>>;
using vec = vector<int>;

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    //---------------------------------------------
    
    int h,w,n;
    cin>>h>>w>>n;
    int ans=0;
    while(true){
        if(ans>=min(h,w)){
            n-=min(h,w)-1;
        }
        else{
        n-=max(h,w);
        }
        ans++;
        if(n<=0) break;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));

#define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);
using namespace std;
char str[1100000];
int mod=1000000007;
int cur;
pair<int,int>expr();
pair<int,int>fact(){
	if(str[cur]=='~'){
		cur++;
		pair<int,int>ret=fact();
		swap(ret.first,ret.second);
		return ret;
	}
	if(str[cur]=='('){
		cur++;
		pair<int,int>ret=expr();
		cur++;
		return ret;
	}
	while(str[cur]=='x'||('0'<=str[cur]&&str[cur]<='9'))cur++;
	return make_pair(1,1);
}
pair<int,int>term(){
	pair<int,int>ret=fact();
	while(str[cur]=='&'){
		cur++;
		pair<int,int>tmp=fact();
		pair<int,int>to=make_pair((int)(((long long)ret.first*tmp.first)%mod),(int)(((long long)ret.second*tmp.second+(long long)ret.first*tmp.second+(long long)ret.second*tmp.first)%mod));
		ret=to;
	}
	return ret;
}
pair<int,int>expr(){
	pair<int,int>ret=term();
	while(str[cur]=='|'){
		cur++;
		pair<int,int>tmp=term();
		pair<int,int>to=make_pair((int)(((long long)ret.first*tmp.first+(long long)ret.first*tmp.second+(long long)ret.second*tmp.first)%mod),(int)(((long long)ret.second*tmp.second)%mod));
		ret=to;
	}
	return ret;
}
int main(){
	BEGIN_STACK_EXTEND(60*1024*1024);
	scanf("%s",str);
	printf("%d\n",expr().first);
	END_STACK_EXTEND;
}

Measured memory_bytes: 41192
#                         author:  kagemeka 
#                         created: 2019-11-09 16:39:51(JST)
### modules
## from standard library
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator
## from external libraries
# import scipy.special   
# import scipy.misc      
# import numpy as np 

def main():
    h, w = (int(x) for x in sys.stdin.readline().split())
    a = [list(sys.stdin.readline().rstrip()) for _ in range(h)]
    
    for i in range(len(a)-1, -1, -1):
        for j in range(len(a[0])-1, -1, -1):
            if a[i][j] == '#':
                break
        else:
            del a[i]

    for j in range(len(a[0])-1, -1, -1):
        for i in range(len(a)-1, -1, -1):
            if a[i][j] == '#':
                break
        else:
            for i in range(len(a)-1, -1, -1):
                del a[i][j]

    for i in range(len(a)):
        print(''.join(a[i]))
            
    

if __name__ == "__main__":
    # execute only if run as a script
    main()


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

typedef long double ld;
const ld eps = 1.0e-16; // 許容される誤差

ld mysqrtl(ld x)
{
  ld a = sqrt((double)x); // 近似値
  do {
    a = (a + x/a) / 2.0L;
  } while (fabsl(x - a*a) > eps);
  return a;
}

ld	mto2pi(int m)
{
  	return 3.14159265358979323846264338327950L * (long double)m / 30.0L;
}

ld	hto2pi(int h, int m)
{
	return 3.14159265358979323846264338327950L * ((long double)h * 30.0L + (long double)m / 2.0L) / 180.0L;
}

int main(void)
{
  	int a;
  	int b;
  	int h;
  	int m;
  	ld	t;
  	ld	l;
  	ld  aa;
  	ld  bb;
  	    
  	scanf("%d %d %d %d", &a, &b, &h, &m);
  
    aa = (long double)a;
    bb = (long double)b;
    
	t = hto2pi(h, m) - mto2pi(m);
    l = sqrtl((sin(t) * aa) * (sin(t) * aa) + (-1.0 * cos(t) * aa + bb) * (-1.0 * cos(t) * aa + bb) );
/*    l = sqrtl(aa * aa + bb * bb - 2.0L * aa * bb * cosl(t));
*/  	printf("%22.20Lf", l);
  
  	return (0);
}



Measured memory_bytes: 2444
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));



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



	int a, b,c;
	cin >> a >> b>>c;
	if (a + b >= c)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}



Measured memory_bytes: 256
/*
.   Bismillahir Rahmanir Rahim
.   Author - Marajul islam
.   created- Sun Apr 19 17:54:52 2020

*/ 
#include<bits/stdc++.h>
using namespace std;


 
int sc1() {int x; scanf("%d", &x); return x;}
long long sc2() {long long x; scanf("%lld", &x); return x;}

const int mod= 1e9 + 7;
inline int add(int a, int b) {a += b; return a >= mod ? a - mod : a;}
inline int sub(int a, int b) {a -= b; return a < 0 ? a + mod : a;}
inline int mul(int a, int b) {return (long long)a * b % mod;}
 
#define F               first
#define S               second 
#define mp              make_pair
#define pb              push_back
#define pf              push_front
#define speed_up        ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define sz(x)           (int)x.size()
#define all(x)          x.begin(), x.end()
#define debug           cerr << "OK\n";
#define ub              upper_bound
#define lb              lower_bound
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        (a*b)/gcd(a,b)
#define Int             sc1()
#define LL              sc2()
#define For(n)          for(int i=0;i<n;i++)
#define Forj(n)         for(int j=0;j<n;j++)
#define Fork(n)         for(int k=0;k<n;k++)
#define For1(n)         for(int i=1;i<=n;i++)

typedef long long       ll;
typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<pii>     vpii;
typedef set <int>       si;
typedef set <ll>        sll;
typedef multiset <int>  msi;
typedef multiset <ll>   msll;
typedef map <int, int>  mi;
typedef map <ll, ll>    mll;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl;}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << ", ";
    err(++it, args...);
}
  
const int inf           = (int)2e9 + 5;
const ll  Inf           = (ll)1e18 + 5;
const int N             = 5e6 + 5;
 
 
 
int solve() {
 
	ll n=Int;
	ll k=Int;
	ll ans=0;
	For(k){
		ll x;
		cin>>x;
		ans+=x;
	}
	if(ans>n) cout<<-1<<endl;
	else cout<<n-ans<<endl;

 
	return 0;
}
 
 
 
 
int main()
{
	//speed_up;
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
 
	int test = 1, tc = 0;
	//scanf("%d", &test);
	//cin >> test;
	while (test--) {
		//printf("Case %d: ", ++tc);
		solve();
	}
 
	return 0;
 
 
 
 
}




Measured memory_bytes: 3768
# 数字の文字列s
s = input()

# 非0桁の数
not_zero = int(input())

# 桁数
n = len(s)

# dp[決定済み桁数][未満フラグ][非0の桁数]
# 決定済み桁数: 0～n  今回の問題は 1<n<10の100乗 のため、nが最大100桁で多めに105桁を取る。
# 未満フラグ: 0:そこまでの桁がnと一致  1:そこまでの桁がnより小さい
# 非0の桁数: 0～k  1<=k<=3のため、多めに4を取る。
dp = [[[0] * 4 for i in range(2)] for j in range(105)]

# 初期化 空集合を作成
dp[0][0][0] = 1

for i in range(n):
    for j in range(2):
        for k in range(4):
            nd = int(s[i])
            for d in range(10):
                # 配る先
                ni = i + 1
                nj = j
                nk = k

                # 現在の桁が0でなければ、0の桁が一つ増えるため、配る先はnk += 1
                if d != 0:
                    nk += 1
                # 0の桁が指定より多い場合、配るのをやめる
                if nk > not_zero:
                    continue
                # 今までの桁と一致する場合
                if j == 0:
                    # 今までの桁が一致し、現在の桁がnの該当桁より大きい場合、配るのをやめる
                    if d > nd:
                        continue
                    # 今までの桁が一致し、現在の桁がnの該当桁より小さい場合、n未満に配る
                    if d < nd:
                        nj = 1
                dp[ni][nj][nk] += dp[i][j][k]

print(dp[n][0][not_zero] + dp[n][1][not_zero])


Measured memory_bytes: 41328
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <vector>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,b) FOR(i,0,b)
#define PB push_back
#define MP make_pair
int main(){
  double a;
  while(1){
    int data[12];
    cin>>a;
    if(a<0)break;
    double u=128.0;
    for(int i=0;i<12;i++){
      if(a>=u){
        data[i]=1;
        a-=u;
      }else data[i]=0;
      u/=2;
    }
    if(a!=0){
      cout<<"NA"<<endl;
      continue;
    }
    for(int i=0;i<12;i++){
      if(i==8)cout<<'.';
      cout<<data[i];
    }
    cout<<endl;
  }
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
#include <string>
#define INF 100000
using namespace std;
char x[1001][1001];
int cycle;
int tots;
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
typedef pair<int, int> P;
typedef long long ll ; 
int main(){
    ll X,Y;
    cin >> X >> Y;
    ll now=X;
    ll ans = 0;
    while(now <= Y){
        now = now*2;
        ans++;
    }
    cout << ans << endl;

}

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

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

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

ll INF = LLONG_MAX / 10;

int main() {
	int D, N; cin >> D >> N;
	if (N == 100) N = 101;
	while (D--) N *= 100;
	cout << N << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a  = sc.nextInt();
		int b  = sc.nextInt();
		int c  = sc.nextInt();
		boolean flag = false;
		for(int i = a; i <= a*b; i+=a) {
			if(i % b == c) {
				flag = true;
			}
		}
		if(flag) {
			System.out.println("YES");

		} else {
			System.out.println("NO");
		}
	}

}


Measured memory_bytes: 23124
/* AOJ 0034
 *
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0034
 */

#include<stdio.h>
#define DEBUG 0


#define true 1
#define false 0



int meetat(int* input, int v1, int v2){

  int total;
  int i;
  float fat;
  int d;

  total = 0;
  for(i=0;i<10;i++)
    total += input[i];

  fat = total*1.0 / (v1+v2) * v1;


  i = 0;
  d = 0;
  while(fat > d){
    d += input[i];
    i++;
  }
  return i;
}


int main(){
  int i;
  int n;
  int input[11];
  int v1, v2;

  while(true){
    for(i=0; i< 10; i++){
      scanf("%d,", input+i);
    }
    scanf("%d,", &v1);
    if(scanf("%d", &v2)!=1)
      break;

    input[10] = 0;
    if(DEBUG){
      for(i=0; i< 10; i++){
        printf("%d,", input[i]);
      }
      printf("%d.",v1);
      printf("%d", v2);
      printf("\n");
    }

    printf("%d\n", meetat(input, v1,v2));
  }
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<iomanip>
#include<string.h>
#include<algorithm>
#include<map>
using namespace std;
#define ll long long
int main()
{
	int a1,a2,a3;
	cin>>a1>>a2>>a3;
	int sum=0;
	sum+=a1+a2+a3;
	if(sum>=22)
	{
		cout<<"bust"<<endl;
	}
	else
	{
		cout<<"win"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b float64
	var h, m float64
	fmt.Scanf("%f %f %f %f", &a, &b, &h, &m)
	rad := 30*h + 0.5*m - 6*m
	//if rad <= 0 {
	//	rad += 360
	//}
	//if rad >= 180 {
	//	rad -= 180
	//}
	cc := math.Pow(a, 2) + math.Pow(b, 2) - 2*a*b*math.Cos(2*math.Pi*rad/360)
	c := math.Sqrt(cc)
	fmt.Println(c)
}


Measured memory_bytes: 1820
from collections import deque
n,m = map(int, input().split())
if m == 0:
  print(1)
  exit()
g = [[] for i in range(n)]
for i in range(m):
  a, b = map(int, input().split())
  g[a-1].append(b-1)
  g[b-1].append(a-1)
v = [-1 for i in range(n)]
ans = []
for i in range(n):
  if v[i]!=-1:
    continue
  v[i]=0
  an=1
  d = deque([i])
  while len(d):
    x = d.popleft()
    for i in g[x]:
      if v[i] == -1:
        d.append(i)
        v[i]=1
        an+=1
  ans.append(an)
print(max(ans))

Measured memory_bytes: 118924
#include <stdio.h>
#include <math.h>

#define M_PI 3.141592653589793


int main(void) {

	int i, j, k;
	int sum, total = 0;
	int r,c;
	int table[100][100] = { 0 };

	scanf("%d %d", &r, &c);
	for (j = 0; j < r; j++) {
		for (i = 0; i < c; i++) {
			scanf("%d", &table[j][i]);
		}
	}



	for (j = 0; j < r; j++) {
		sum = 0;
		for (i = 0; i < c; i++) {
			printf("%d ", table[j][i]);
			sum += table[j][i];
		}
		printf("%d\n", sum);
	}
	for (i = 0; i < c; i++) {
		sum = 0;
		for (j = 0; j < r; j++) {
			sum += table[j][i];
		}
		printf("%d ", sum);
		total += sum;
	}
	printf("%d\n", total);
	

	return 0;

}

Measured memory_bytes: 2796
use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn is_palindrome(s: &str) -> bool {
// sが回文であるかどうかを判定する
	let mut flag = true;
	let v:Vec<char> = s.chars().collect();
	let L = v.len();
	for n in 0..(L/2) {
		if v[n] != v[L - 1 - n] {
			flag = false;
			break;
		};
	}
	flag
}

fn main() {
	let v:Vec<i32> = procon_read();
	let a = v[0];
	let b = v[1];
	let mut cnt = 0;
	for i in a..(b+1) {
		let s = i.to_string();
		if is_palindrome(&s[..]){
			cnt+=1;
		}
	}
	println!("{}", cnt);
}

Measured memory_bytes: 4352
n=int(input())
option=[3,5,7]
completed=[]
a=[3,5,7]
ans=0
while option:
    number=option.pop()
    completed.append(number)
    for add_number in a:
        new_number=number*10+add_number
        if new_number<=n:
            option.append(new_number)
for i in completed:
    i=list(str(i))
    i=set(i)
    if len(set(i))==3:
        ans+=1
print(ans)

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

int cnt[100007];

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

    for (int i = 1; i <= N; i++) {
        int tmp;
        scanf("%d", &tmp);
        cnt[tmp]++;
    }

    int ans = 0;
    for (int i = 0; i <= 1e5; i++) {
        ans = max(ans, cnt[i] + cnt[i+1] + cnt[i+2]);
    }

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


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



int main() {
    string str;
    cin >> str;
    string s1 = str.substr(0, str.length()/2);
    int flag = 1;
    int l = s1.length();
    for(int i = 0; i < l / 2; i++) {
        if(s1[i] != s1[l-i-1]) {
            flag = 0;
            break;
        }
    }
    string s2 = str.substr(str.length()/2 + 1, str.length()/2);
    if(s2 == s1 && flag == 1) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <queue>

using namespace std;

char S[6000];

int main() {
    int N;
    int ret = 0;
    scanf("%d%s", &N, &S);
    for(int i=0; i<N; ++i) {
        for(int j=i+ret+1; j+ret<N; ++j) {
            if(i+ret<j && S[i+ret]==S[j+ret]) {
                int k;
                for(k=0; k<ret && S[i+k]==S[j+k]; ++k);
                if(k==ret) {
                    for(; ret<j-i && j+ret<N && S[i+ret]==S[j+ret]; ++ret);
                }
            }
        }
    }
    printf("%d\n", ret);
    return 0;
}


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

int main(){
    int N,M;
    std::cin>>N>>M;
    std::vector<int> A(N);
    for(int i=0;i<N;++i) std::cin>>A[i];
    int sum = std::accumulate(A.begin(),A.end(),0);
    std::sort(A.rbegin(),A.rend());
    for(int i=0;i<M;++i) if(A[i]<(sum+4*M-1)/(4*M)){
        std::cout<<"No"<<std::endl;
        return 0;
    }
    std::cout<<"Yes"<<std::endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int b[10],
		cont[11] = {0},
		cont2[11] = {0};
	int n, i, x, y, count;
	
	scanf("%d", &n);
	
	for (; n > 0; n--){
		for (i = 0; i < 10; i++){
			scanf("%d", &b[i]);
		}
		x = 0;
		y = 0;
		count = 0;
		
		for (i = 0; i < 11; i++){
			cont[i] = 0;
			cont2[i] = 0;
		}
		
		for (i = 0; i < 10; i++){
			if (b[i] > cont[x] && b[i] > cont2[y]){
				if (cont[x] >= cont2[y]){
					x++;
					cont[x] = b[i];
					count++;
				}
				else {
					y++;
					cont2[y] = b[i];
					count++;
				}
			}
			else if(b[i] > cont[x]){
				x++;
				cont[x] = b[i];
				count++;
				
			}
			else if(b[i] > cont2[y]){
				y++;
				cont2[y] = b[i];
				count++;
			}
			else {
				count = 0;
				break;
			}
		}
		
		if (count == 0){
			printf("NO\n");
		}
		else {
			printf("YES\n");
		}
		
	}
	
	
	
	return (0);
}

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

int main() {
  int R, G;
  cin >> R >> G;
  if(0 <= R){
    if(4500 >= G){
      cout << (G - R) * 2 + R << endl;
    }else{
    cout << "Please input number (goal rating) under 4500." << endl;
    }
  }else{
  cout << "Please input number (rating) over 0." << endl;
  }
 }

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define fo(i,n) for(i=0;i<n;i++)
#define fok(i,k,n) for(i=k;i<n;i++)
#define ci(x) cin>>x;
#define ci2(x,y) cin>>x>>y;
#define co(x) cout<<x<<"\n";
#define co2(x,y) cout<<x<<" "<<y<<"\n";
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pll;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pll>		vpll;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
const int mod = 1000000007;
const int INF =1e9;

int main(){
	int n,x,y;
	cin>>n>>x>>y;
	vl ans(n+1,0);
	for(ll i = 1; i<= n-1; i++)
	{
		for(ll j = i+1; j <= n; j++)
		{
			ll dist = min( j-i, 
			min(1+abs(x-i)+abs(y-j),1+abs(x-j)+ abs(y-i)));
			ans[dist]++;		
		}
	}
	for(ll i = 1; i <= n-1; i++) cout << ans[i] << endl;
	
}


Measured memory_bytes: 256
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws FileNotFoundException {

		Scanner scan = new Scanner(System.in);
		// Scanner scan = new Scanner(new File("c:\\0509-input.txt"));

		int n = scan.nextInt();
		int[] c = new int[2 * n];
		for (int i = 0; i < c.length; i++)
			c[i] = i + 1;

		int m = scan.nextInt();
		for (int i = 0; i < m; i++) {
			int op = scan.nextInt();
			if (op == 0)
				refull(c);
			else
				cut(op, c);
		}
		for (int i = 0; i < c.length; i++)
			System.out.println(c[i]);

		scan.close();
		System.exit(0);
	}

	private static void cut(int op, int[] c) {
		int[] w = new int[c.length];
		for (int i = 0; i < c.length; i++)
			w[i] = c[i];
		for (int i = 0, j = op; i < c.length; i++, j++) {
			if (j >= c.length)
				j = 0;
			c[i] = w[j];
		}
	}

	private static void refull(int[] c) {
		int[] w = new int[c.length];
		for (int i = 0; i < c.length; i++)
			w[i] = c[i];
		for (int i = 0, j = 0, k = c.length / 2; i < c.length; i += 2, j++, k++) {
			c[i] = w[j];
			c[i + 1] = w[k];
		}
	}

}

Measured memory_bytes: 31092
#include<iostream>
#define max 100
using namespace std;


int main(){
	int cal[max];//?¨???????
	long long int num[21][max];//0???21?????°???
	int n;//????????\???????????????
	int i = 0;//?????????????????????
	int y = 0;//20?????§??????????¢??????????
	int sum = 0;

	cin >> n;

	while (n > i){
		cin >> cal[i];
		while (y < 21){
			num[y][i] = 0;
			y++;
		}
		i++;
		y = 0;
	}

	i = 0;

	num[cal[0]][0] = 1;

	while (n - 1 > i){
		y = 0;
		while (y < 21){
			if (num[y][i] >= 1){
				//cout << 5 << endl;
				if ((y + cal[i + 1]) <= 20){

					sum = y + cal[i + 1];
					num[sum][i + 1] = num[sum][i + 1] + num[y][i];

				}
				if ((y - cal[i + 1]) >= 0){

					sum = y - cal[i + 1];
					num[sum][i + 1] = num[sum][i + 1] + num[y][i];

				}
			}
			y++;
		}

		//cout << num[1][i] << endl;
		i++;

	}

	cout << num[cal[n - 1]][i - 1] << endl;

}

Measured memory_bytes: 1172
/*
auhtor:hbohra98
chandigarh univeristy
*/
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define VP vector < pair < ll , ll > >
#define VI vector< ll >
#define VS vector< string >
#define mk make_pair

template<typename T, typename U> inline void smin(T &a, U b) {if(a>b) a=b;}
template<typename T, typename U> inline void smax(T &a, U b) {if(a<b) a=b;}

using namespace std;
int main(){

ll a,b,c;

cin>>a>>b>>c;
if((a*b)>c){
  cout<<c<<endl;
}
else{
  cout<<a*b<<endl;
}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <cassert>
#include <random>
using ll = long long;


int main() {
	int n; std::cin >> n;
	long long ans = 0;
	for (int i = 1; i <= n; i++) {
		if (i % 3 == 0 || i % 5 == 0) continue;
		ans += i;
	}
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define eps 1e-2
using namespace std;

int GCD(int a, int b) {
	return b ? GCD(b, a % b) : a;
}

int main()
{
	int n, a, res;
	cin >> n;
	cin >> res;
	for (int i = 1; i < n; i++) {
		cin >> a;
		res = res / GCD(res, a) * a;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 3104
#include"bits/stdc++.h"

#define rep(i, N) for(int i = 0;i < N;i++)
#define ll long long

using namespace std;

int main(void) {
	ll X; cin >> X;
	ll A, B;
	ll A5, B5;
	bool finish = false;
	B = 0;

	while (true) {
		B5 = pow(B, 5);
		for (int sign : {1, -1}) {
			A5 = X + sign * B5;
			A = (ll)pow(A5, 1.0 / 5.0);
			for (int i = -1; i <= 1; i++) {
				ll A_ = A + i;
				A5 = pow(A_, 5);
				if (A5 - sign*B5 == X) {
					finish = true;
					A = A_;
					B = sign * B;
					break;
				}
			}
			if (finish)break;
		}
		if (finish)break;
		B++;
	}

	cout << A << " " << B << endl;

	return 0;
}

Measured memory_bytes: 4072
#include<stdio.h>
int main()
{
	while(1){
		int n,i;
		scanf("%d %d",&n,&i);
		if(n!=0 && i!=0){
		int j,c=-1,l,a[100000]={0},b[10000]={0},max=0;
		for(j=0;j<n;j++){
			scanf("%d",&a[j]);
		}
		for(j=0;j<n-i+1;j++){
			b[j]=0;
			c+=1;
			for(l=0;l<i;l++){
				b[j]+=a[l+c];
			}
			if(max<b[j]){
				max=b[j];
			}
		}
		printf("%d\n",max);
		}
		else if(n==0 || i==0){
			goto end;
		}
	}
	end:
	return 0;
}


Measured memory_bytes: 2132
import java.util.Scanner;

public class Main {

		public static void main(String[] args){
			Scanner sc = new Scanner(System.in);
			int A = sc.nextInt();
			int B = sc.nextInt();
			int C = sc.nextInt();
			int D = sc.nextInt(); 	
			int sum = 0;
			if(A < B)
				sum = sum + A;
			else sum = sum + B;
			if(C < D)
				sum = sum + C;
			else sum = sum + D;
			
				System.out.println(sum);
			}}

Measured memory_bytes: 21716
#include <stdio.h>
#include <cmath>
#include <bits/stdc++.h>



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main(void){

	int K; cin >> K;

	int ans = 0;
	FOR(i,1,K+1){
		FOR(j,1,K+1){
			if(i != j and i%2 != j%2) ans++;
		}
	}
	ans /= 2;
	cout << ans << endl;


	return 0;

}


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

int main(){
    string taro, hanako;
    int n, taro_point, hanako_point, i;

    cin >> n;
    taro_point = 0;
    hanako_point = 0;

    i = 0;
    while(i < n){
        cin >> taro >> hanako;
        if (taro == hanako) {
            taro_point++;
            hanako_point++;
        } 
        else if (taro > hanako) taro_point = taro_point + 3;
        else hanako_point = hanako_point + 3;
        i++;
    }
    cout << taro_point << ' ' << hanako_point << endl;
    return 0;
}


Measured memory_bytes: 3168
#include <stdio.h>
int main()
{   long long n;
    scanf("%lld",&n);
    if(n%2){
        printf("0");
        return 0;
    }
    long long ans=0;
    long long d=10;
    while(n>=d){
        ans+=n/d;
        d*=5;
    }
    printf("%lld",ans);
    
    
    return 0;
}


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

int main()
{
    int h, w;
    cin >> h >> w;
    vector<vector<string>> grid(h, vector<string>(w));
    vector<vector<int>> bom(h, vector<int>(w));
    queue<pair<int,int>> que;
    string a;
    for (int i = 0; i < h; i++)
    {
        cin >> a;
        for (int j = 0; j < w; j++)
        {
            grid.at(i).at(j) = a[j];
            if(a[j]=='#'){
                bom.at(i).at(j)=0;  //queueに座標追加
                que.push(pair<int,int>(i,j));
            }else{
                bom.at(i).at(j)=9999;
            }
        }
    }
    pair<int,int> p;
    int dx[4]={0,-1,1,0};
    int dy[4]={-1,0,0,1};
    int x,y,z;
    while(!que.empty()){
        p=que.front();
        que.pop();
        y=p.first;
        x=p.second;
        z=bom.at(y).at(x);
        for(int k=0;k<4;k++){
            if(y+dy[k]>=0&&y+dy[k]<h&&x+dx[k]>=0&&x+dx[k]<w&&bom.at(y+dy[k]).at(x+dx[k])>z+1){
                bom.at(y+dy[k]).at(x+dx[k])=z+1;
                que.push(pair<int,int>(y+dy[k],x+dx[k]));
            }
        }
    }
    int max=0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(bom.at(i).at(j)>max){
                max=bom.at(i).at(j);
            }
        }
    }
    cout << max <<endl;
    return 0;
}

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

long long f(long long b,long long n)
{
    if(n<b)
        return n;
    if(b==0)
    {
        cout<<-1;
        return 0;
    }
    return f(b,n/b)+n%b;
}

int main()
{
    /*cout<<f(100,87654)<<"\n";
    long long n=8,b;
    for(b=2;b<=30;b++)
        cout<<f(b,n)<<" ";
    */
    long long n,s,b;
    cin>>n>>s;
    for(int b=2;b<=1000000;b++)
    {
        if(f(b,n)==s)
        {
            cout<<b;
            return 0;
        }
    }
    b=-1;
    if(n==s)
        b=n+1;
    for(long long q=1;q<1000000;q++)
    {
        if(q>s)
            break;
        long long r=s-q,b1;

        b1=(n-r)/q;
        if(b1<2)
            continue;
        if(n%b1==r&&n/b1==q)
            {
                if(b==-1)
                    b=b1;
                else
                    b=min(b,b1);
            }
    }
    cout<<b;
    return 0;
}


Measured memory_bytes: 256
n=int(input())
h=[int(i) for i in input().split()]
hana=[0]*n
ans=0
left=right=0
while hana!=h:
    for i in range(n):
        right=i
        if hana[i]==h[i]:
            if left<right:
                for j in range(left,right):
                    hana[j]+=1
                ans+=1
            left=right+1
        elif i==n-1:
            if left<n:
                for j in range(left,n):
                    hana[j]+=1
                ans+=1
    left=right=0
print(ans)

Measured memory_bytes: 39664
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int lli;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
        a[i] -= i;
    }
    sort(a.begin(), a.end());
    int b = a[n/2];
    lli ans = 0;
    for(int i=0; i<n; i++){
        ans += abs(a[i] -b);
    }
    cout << ans << endl;
    return 0;
}


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

bool check(ll x, ll y) {
    if (x <= inf_l/y) return true;
    else return false;
}

int main() {
    int n; cin >> n;
    vll a(n);
    rep(i,n) {
        ll x; cin >> x;
        a[i] = x;
        if (x == 0) {cout << 0 << endl; return 0;}
    }
    ll sum = a[0];
    REP(i,n) {
        if (check(sum,a[i])) sum *= a[i];
        else {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << sum << endl;
}

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

int main() {
	int N, ans = 0;
	pair<int, int> A[100], B[100];
	bool R[100];
	for (int i = 0; i < 100; i++) {
		R[i] = true;
	}
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i].second >> A[i].first;
	}
	for (int i = 0; i < N; i++) {
		cin >> B[i].first >> B[i].second;
	}
	sort(A, A + N, greater<pair<int, int> >());
	sort(B, B + N);
	for (int i = 0; i < N; i++) {
		A[i].first = A[i].first ^ A[i].second;
		A[i].second = A[i].first ^ A[i].second;
		A[i].first = A[i].first ^ A[i].second;
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (R[j]) {
				if (B[i].first > A[j].first && B[i].second > A[j].second) {
					R[j] = false;
					ans++;
					goto LOOP;
				}
			}
		}
	LOOP:;
	}
	cout << ans;
}

Measured memory_bytes: 256
// C++ 14
#include <bits/stdc++.h>
using namespace std;
template <typename T>  ostream& operator<<(ostream& os, const vector<T>& v)  {  os << "[";  for (int i = 0; i < v.size(); ++i) {  os << v[i];  if (i != v.size() - 1)  os << ", ";  }  os << "]";  return os;  }
template <typename T> void print(T v, string s = "\n") { cout << v << s; }
template <typename T> void in(T &v) { cin >> v; }
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

int main() {
  ll x;in(x);
  print(lcm(x, 360L)/x);
  return 0;
}


Measured memory_bytes: 3532
a,n=map(int,input().split())
if a%2==0:
    print(*[a//2]+[a]*(n-1))
else:
    d=[(a+1)//2]*n
    for i in range(n//2):
        if d[-1]==1:
            d.pop()
        else:
            d[-1]-=1
            d.extend([a]*(n-len(d)))
    print(" ".join(str(i)for i in d))

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

class point {
public:
  int x, y;
  point(){};
  point(int a, int b) {
    x = a;
    y = b;
  }
};

int N;
vector<point> R, B;

bool compare_x(point p, point q) {
  if (p.x != q.x) {
    return p.x < q.x;
  }
  else {
    return p.y < q.y;
  }
}

bool compare_y(point p, point q) {
  if (p.y != q.y) {
    return p.y < q.y;
  }
  else {
    return p.x < q.x;
  }
}

bool search(point X) {
  for (int r = N - 1; r >= 0; r--) {
    if (R[r].x == -1 && R[r].y == -1) {
      continue;
    }
    if (R[r].x < X.x && R[r].y < X.y) {
      R[r] = point(-1, -1);
      return true;
    }
  }
  return false;
}

void abc091c() {
  sort(R.begin(), R.end(), compare_y);
  sort(B.begin(), B.end(), compare_x);
  int res = 0;
  for (int b = 0; b < N; b++) {
    if (search(B[b])) {
      res++;
    }
  }
  cout << res << "\n";
  return;
}

int main() {
  cin >> N;
  R.resize(N);
  B.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> R[i].x >> R[i].y;
  }
  for (int i = 0; i < N; i++) {
    cin >> B[i].x >> B[i].y;
  }
  abc091c();
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int a = stdIn.nextInt();
        int b = stdIn.nextInt();
        int c = stdIn.nextInt();

        if (a > b){
            int tmp = a;
            a = b;
            b = tmp;
        }
        if (b > c){
            int tmp = b;
            b = c;
            c = tmp;
        }
        if (a > b){
            int tmp = a;
            a = b;
            b = tmp;
        }

        System.out.println(a + " " + b + " " + c);
    }
}

Measured memory_bytes: 17224
#include <cmath>
#include <iostream>
#include <vector>

int main(int argc, char const* argv[]) {
    int H, W;
    std::cin >> H >> W;
    std::vector<std::vector<char>> v(2 * H, std::vector<char>(W, ' '));
    for (size_t i = 0; i < H; i++) {
        for (size_t j = 0; j < W; j++) {
            std::cin >> v.at(i).at(j);
        }
    }

    for (int i = H - 1; i > -1; i--) {
        for (int j = 0; j < W; j++) {
            v.at(2 * i + 1).at(j) = v.at(i).at(j);
            v.at(2 * i).at(j)     = v.at(i).at(j);
        }
    }

    for (size_t i = 0; i < 2 * H; i++) {
        for (size_t j = 0; j < W; j++) {
            std::cout << v.at(i).at(j);
        }
        std::cout << '\n';
    }
    return 0;
}


Measured memory_bytes: 256
def test(k,s)
  cnt = 0
  for x in 0..k
    for y in 0..k
      z = s - x - y
      if 0 <= z and z <= k
        cnt +=1
      end
    end
  end
  puts cnt
end

input = gets
k,s = input.split(' ').map{|n|n.to_i}
test(k,s)


Measured memory_bytes: 1788
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int n;
  cin >> n;

  vector<int> a(n);
  REP(i,n) cin >> a[i],a[i]--;

  vec id(n);

  REP(i,n){
    id[a[i]] = i;
  }

  REP(i,n){
    cout << id[i] + 1 << (i == n - 1 ? "\n" : " ");
  }
  
  return 0;
}

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

int main()
{
	int N;
	cin >> N;
	vector<ll> A(N + 2);
	ll sum = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i + 1];
		sum += abs(A[i + 1] - A[i]);
	}
	sum += abs(A[N]);
	for (int i = 0; i < N; i++) {
		ll tmp = sum - (abs(A[i + 1] - A[i]) + abs(A[i + 2] - A[i + 1]) - abs(A[i + 2] - A[i]));
		cout << tmp << endl;
	}
	return 0;
}


Measured memory_bytes: 2048
iipt=lambda:int(input())
miipt=lambda:list(map(int,input().split(" ")))

dp=list(range(51234)) # 最小枚数
n,m = miipt()
C=miipt()
for c in C:
    for i in range(c, n+1):
        dp[i]=min(dp[i], dp[i-c]+1)
print(dp[n])


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

int main(){
  int n, d;
  cin >> n >> d;
  vector<vector<int>> x(n, vector<int>(d));
  
  for(int i = 0; i < n; i++) {
  for(int j = 0; j < d; j++) {
  	cin >> x.at(i).at(j);
  }
  }
  
  int ans = 0;
  
  for(int i = 0; i < n-1; i++) {
  for(int j = i+1; j < n; j++) {
  	int dist = 0;
    for(int k = 0; k < d; k++) {
    	int diff = x.at(i).at(k) - x.at(j).at(k);
    	dist += diff*diff;
    }
  for(int k = 1; k <= dist; k++) {
  	if(k*k == dist) {
    	ans++;
    }
  }
  }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
const ll mod = 1000000007;
const ll INF = 9223372036854775807;
#define Sort(a) sort(a.begin(), a.end())
#define Bsort(a) sort(a.begin(), a.end(), greater<ll>())
#define Pi acos(-1)

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  char a;
  cin >> a;
  if (isupper(a)) {
    cout << 'A' << '\n';
  }
  else {
    cout << 'a' << '\n';
  }
}

Measured memory_bytes: 3632
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

MOD = 10 ** 4 + 7

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

if (B - A) % 2 == 0:
    print((B - A) // 2)
else:
    # print(min(A - 1, N - B) + 1 + (B - A - 1) // 2)
    ans = []
    l = (A - 1)
    r = B - l - 1
    x = l + 1 + (r - 1) // 2
    ans.append(x)
    r = (N - B)
    l = A + r + 1
    x = r + 1 + (N - l) // 2
    ans.append(x)
    print(min(ans))


Measured memory_bytes: 9420
s= input()
t= input()

if s == t:
	print("No")
	exit()



ss = sorted(s)
tt = sorted(t, reverse=True)

sss = "".join(ss)
ttt = "".join(tt)


A = [sss, ttt]
A.sort()

if A[0] == sss:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 3064
/*
 *  Author : Jun_SH
 *  Solution for ABC 145 E
 */
#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read(){
    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*10+ch-'0';ch=getchar();}
    return f*x;
}
int dp[3010]={};
struct node{
    int v,c;
}a[3010];
bool cmp(node a,node b){
    if(a.v==b.v){
        return a.c>b.c;
    }
    return a.v>b.v;
}
bool cmpx(node a,node b){
    return a.c>b.c;
}
bool cmpxx(node a,node b){
    return a.v*b.c>b.v*a.c;
}
bool cmpxxx(node a,node b){
    return a.v*b.c<b.v*a.c;
}
main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,T;
    cin>>n>>T;
    for(int i=0;i<n;++i){
        cin>>a[i].c>>a[i].v;
    }
    sort(a,a+n,cmp);
    int ans=-1;
    for(int k=0;k<min(100ll,n);++k){
        int mx=-1;
        memset(dp,0ll,sizeof(dp));
        for(int i=0;i<n;++i){
            if(i==k)continue;
            for(int j=T-1;j>=0;--j){
                if(j>=a[i].c)
                dp[j]=max(dp[j],dp[j-a[i].c]+a[i].v);
            }
        }
        for(int i=0;i<=T-1;++i)
            mx=max(mx,dp[i]);
        ans=max(ans,mx+a[k].v);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>

using namespace std;

const int bill[3] = { 10000, 5000, 1000 };

int main()
{
    int N, Y;
    if (scanf("%d%d", &N, &Y) < 2) return 0;

    bool flg = false;

    int i = 0;
    int j;
    int k;
    for (; i <= N; i++)
    {
        j = 0;
        k = 0;
        for (; j <= N; j++)
        {
            if (N < i + j) continue;

            k = N - i - j;

            if (bill[0] * i + bill[1] * j + bill[2] * k == Y)
            {
                flg = true;
                break;
            }
        }
        if (flg) break;
    }

    if (N < i || N < j || N < k)
    {
        printf("%d %d %d\n", -1, -1, -1);
    }
    else
    {
        printf("%d %d %d\n", i, j, k);
    }
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main()
{
int N,max=0,total=0;
int *p;
cin >> N;
int a[N];
for(int i = 0;i < N;i++){
cin >> a[i];
if(max < a[i]){
max = a[i];
p = &a[i];
}
}
*p /= 2;
for(int i = 0;i < N;i++){
total += a[i];
}

cout << total;
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long int ll;
int main(){
  int n,k;
  cin >> n>>k;
  ll h[n];
  for(int i=0;i<n;i++) cin >>h[i];
  sort(h,h+n);
  ll m=1e10;
  for(ll i=0;i<n;i++){
    if(i+k-1<0||i+k-1>=n)  break;
    m=min(h[i+k-1]-h[i],m);
  }
 cout <<m<<endl;
}


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

char field[10][10];
char tmp[10][10];

void rotate(){
	for(int i=0; i < 8; i++){
		for(int j=0; j < 8; j++){
			tmp[i][j] = field[i][j];
		}
	}

	for(int i=0; i < 8; i++){
		for(int j=0; j < 8; j++){
			field[i][j] = tmp[7-j][i];
		}
	}
}

void output(){
	for(int i=0; i < 8; i++){
		for(int j=0; j < 8; j++){
			cout << field[i][j];
		}
		cout << endl;
	}
}

int main(){
	for(int i=0; i < 8; i++){
		for(int j=0; j < 8; j++){
			cin >> field[i][j];
		}
	}


	cout << 90 << endl;
	rotate();
	output();

	cout << 180 << endl;
	rotate();
	output();

	cout << 270 << endl;
	rotate();
	output();
}

Measured memory_bytes: 1140
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define pb push_back
#define nl cout<<"\n"
#define db(x) cout<<x<<" "
#define fi(a,b) for(int i=a;i<b;i++)
#define fj(a,b) for(int j=a;j<b;j++)
#define fk(a,b) for(int k=a;k<b;k++)
#define F first
#define S second
#define UM unordered_map<int,int>
#define MP map<int,int>
#define mxsize (int)1e6
void fun(){
    int n,k;
    cin>>n>>k;
    int h[n];
    fi(0,n) cin>>h[i];
    int dp[n];
    dp[0]=0;
    fi(1,n){
        dp[i]=INT_MAX;
        fj(max(0,i-k),i){
            dp[i]=min(dp[i],dp[j]+abs(h[j]-h[i]));
        }
    }
    cout<<dp[n-1]<<"\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("/ATOM/input.txt", "r", stdin);
        freopen("/ATOM/output.txt", "w", stdout);
    #endif
    int t=1;
    // cin>>t;
    while(t--){
        fun();
    }
}

Measured memory_bytes: 4360