akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (1 << 30) - 1
#define LLINF (1LL << 61) - 1
// #define int ll
using namespace std;
const int MOD = 1000000007;
const int MAX = 510000;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,a[300010],ans=-LLINF;
    ll L[100010]={},R[100010]={};
    ll Lsum=0,Rsum=0;
    priority_queue<ll, vector<ll> ,greater<ll> > qL;
    priority_queue<ll> qR;
    cin>>n;
    rep(i,3*n){
        cin>>a[i];
        if(i<n){
            Lsum+=a[i];
            qL.push(a[i]);    
        }
        if(i>2*n-1){
            Rsum+=a[i];
            qR.push(a[i]);
        }
    }
    L[0]=Lsum;
    rep2(i,1,n+1){
        qL.push(a[n+i-1]);
        Lsum+=a[n+i-1];
        Lsum-=qL.top();
        L[i]=Lsum;
        qL.pop();
    }
    R[n]=Rsum;
    repr(i,n){
        qR.push(a[n+i]);
        Rsum+=a[n+i];
        Rsum-=qR.top();
        R[i]=Rsum;
        qR.pop();
    }
    rep(i,n+1){
        ans=max(ans,L[i]-R[i]);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 6388
#include <iostream>
#include <vector>
using namespace std;
#define MAX_N 10010
int p[MAX_N];

void Eratosthenes(){
    for(int i = 0; i < MAX_N; i++) p[i] = 1;
    p[0] = 0;
    p[1] = 0;
    for(int i = 2; i*i < MAX_N; i++){
        for(int j = 2; i*j < MAX_N; j++){
            p[i*j] = 0;
        }
    }
}

int main(){
    int n;
    cin >> n;
    int cnt = 0;
    Eratosthenes();
    vector<int> v;
    for(int i = 0; i < MAX_N; i++){
        if(p[i]) v.push_back(i);
    }
    for(int i = 0; i < n; i++){
        int x;
        int Isprime = 1;
        cin >> x;
        for(int j = 0; v[j]*v[j] <= x; j++){
            if(x % v[j] == 0) Isprime = 0; 
        }
        cnt += Isprime;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3204
import java.util.*;
public class Main {
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Byte[] daikeihen = new Byte[3];
        daikeihen[0] = sc.nextByte();
        daikeihen[1] = sc.nextByte();
        daikeihen[2] = sc.nextByte();
        System.out.println((daikeihen[0] + daikeihen[1]) * daikeihen[2] / 2);
    }
}

Measured memory_bytes: 21844
n=int(input())
*h,=map(int,input().split())

s=h[0]
c=0
ans=0
for i in range(1,n):
    if s>=h[i]:
        c+=1
        ans=max(c,ans)
    else:
        c=0
    s=h[i]

print(ans)
        

Measured memory_bytes: 63984
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
 
int main() {
  int n , m , c;
  int counter = 0 ;
  cin >> n >> m >> c ;
  vector<int> B(m);
  int A[m][n] ;
  rep(i,m) cin >> B.at(i) ;
  rep(i,n) rep(j,m) cin >> A[j][i] ;
  //rep(i,m) cout << B.at(i) ;
  //cout << endl;
  //rep(i,n) rep(j,m) cout << A[j][i] ;
  //cout << endl;
  rep(i,n){
    int ans = 0 ;
    rep(j,m){
	  ans = ans + A[j][i]*B.at(j);
    }
    //cout << ans << endl;
    if( ans + c > 0 ) counter++ ;
  }
  cout << counter << endl;
}

Measured memory_bytes: 256
n,k = map(int,input().split())

AS = list(map(int,input().split()))
balls = {}

for a in AS:
  if a in balls:
    balls[a] += 1
  else:
    balls[a] = 1

dic2 = sorted(balls.items(), key=lambda x:x[1])
amount = len(dic2) - k

count = 0
for i in range(amount):
  count += dic2[i][1]
print(count)

Measured memory_bytes: 38964
lis=list(map(int,input().split()))
taste=[]
for i in range(lis[0]):
    taste.append(lis[1]+i)
if 0 in taste:
    ans=sum(taste)
else:
    big=min(abs(taste[0]),abs(taste[-1]))
    if big==abs(taste[0]):
        ans=sum(taste)-taste[0]
    else:
        ans=sum(taste)-taste[-1]
print(ans)


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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

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

    vector<int> J(n,0), I(n,0);

    if(s[0]=='J') J[0]=1;
    for(int i=1; i<n; ++i) J[i]=J[i-1]+(s[i]=='J');

    if(s[n-1]=='I') I[n-1]=1;
    for(int i=n-2; i>=0; --i) I[i]=I[i+1]+(s[i]=='I');

    ll def=0;
    for(int i=1; i<n-1; ++i)
    {
        if(s[i]=='O') def+=(ll)J[i-1]*I[i+1];
    }

    ll add=0;
    ll t;
    string ss;

    // ?????????J
    t=0;
    ss = "J"+s;
    for(int i=1; i<n; ++i)
    {
        if(ss[i]=='O') t+=I[i];
    }
    add=max(add,t);

    // ?????????I
    t=0;
    ss = s+"I";
    for(int i=1; i<n; ++i)
    {
        if(ss[i]=='O') t+=J[i-1];
    }
    add=max(add,t);

    // O??????????????¨??¢?´¢
    rep(i,n-1) add=max(add,(ll)J[i]*I[i+1]);

    cout << def+add << '\n';
    return 0;
}

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

using lli = int64_t;

void g(lli h, lli w, lli& a1, lli& a2)
{
    lli a = h * w;

    a1 = a / 2;
    a1 -= a1 % w;
    a2 = a - a1;
}

lli f(lli h, lli w)
{
    lli ans = LLONG_MAX;

    for(lli i = 1; i < h; i++)
    {
        lli a1 = i * w;

        lli a2, a3;

        g(h - i, w, a2, a3);
        if(a2 && a3) ans = min(ans, max({a1, a2, a3}) - min({a1, a2, a3}));

        g(w, h - i, a2, a3);
        if(a2 && a3) ans = min(ans, max({a1, a2, a3}) - min({a1, a2, a3}));
    }

    return ans;
}

int main()
{
    lli h, w; cin >> h >> w;

    lli ans = min(f(h, w), f(w, h));

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

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#include <assert.h>
#include <bitset>
#define Endl endl
#define mp make_pair
#define ll long long 
#define ull unsinged long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define over(A) {cout<<A<<endl;exit(0);}
#define all(A) A.begin(),A.end()
#define ceil(a,b) ((a-1)/b+1)
#define srand() mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rand(l,r) uniform_int_distribution<int>(l,r)(rng)
template <typename T1,typename T2> inline void chmin(T1 &x,T2 b) {if(b<x) x=b;}
template <typename T1,typename T2> inline void chmax(T1 &x,T2 b) {if(b>x) x=b;}
const int inf=1039074182;
const ll llinf=1LL*inf*inf;
using namespace std;
int n;
vector <int> vec[200005];
int res[200005];
int s[2];
int tc[3];
int id[4];
vector <int> xorder;

void dfs(int x,int par,bool depth)
{
	s[depth]++;
	for(auto u:vec[x])
	{
		if(u==par) continue;
		dfs(u,x,!depth);
	}
}

void go(int x,int par,bool depth)
{
	if(id[tc[depth]]<=n)
	{
		res[x]=id[tc[depth]];
		id[tc[depth]]+=3;
	}
	else
	{
		for(auto tmpc:xorder)
		{
			if(id[tmpc]<=n)
			{
				res[x]=id[tmpc];
//				cout<<x<<' '<<tmpc<<endl;
				id[tmpc]+=3;
				break;
			}
		}
	}
	for(auto u:vec[x])
	{
		if(u==par) continue;
		go(u,x,!depth);
	}
}

int main()
{
//	freopen("input.txt","r",stdin);
	ios_base::sync_with_stdio(false);
	cin>>n;
	int r1,r2,r3;
	r1=r2=r3=n/3;
	if(n%3>=1) r1++;
	if(n%3>=2) r2++;
	int x,y;
	for(int i=0;i<n-1;i++)
	{
		cin>>x>>y;
		x--;
		y--;
		vec[x].push_back(y);
		vec[y].push_back(x);
	}
	dfs(0,-1,0);
	if(s[0]<r2)
	{
		tc[0]=3;
		tc[1]=2;
		xorder.push_back(1);
		xorder.push_back(2);
		xorder.push_back(3);
	}
	else if(s[1]<r2)
	{
		tc[1]=3;
		tc[0]=2;
		xorder.push_back(1);
		xorder.push_back(2);
		xorder.push_back(3);
	}
	else
	{
		tc[0]=1;
		tc[1]=2;
		xorder.push_back(3);
	}
	id[1]=1;
	id[2]=2;
	id[3]=3;
	go(0,-1,0);
	for(int i=0;i<n;i++)
	{
		cout<<res[i]<<' ';
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 18432
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

void read();
template<typename First, typename... Rest> void read(First& first, Rest&... rest);
void write();
template<typename First, typename... Rest> void write(First first, Rest... rest);
template<typename T> void write_vec(vector<T>& v, char divider);

int main(){
    int R;
    read(R);
    cout << fixed << setprecision(3) << 2 * M_PI * R;
    return 0;
}

//配列以外の入力を受け取る
void read(){

}
template<typename First, typename... Rest>
void read(First& first, Rest&... rest){
    cin >> first;
    read(rest...);
}
//
//配列以外を出力する
void write(){

}
template<typename First, typename... Rest>
void write(First first, Rest... rest){
    cout << first << " ";
    write(rest...);
}
//
//配列を区切って出力する
template<typename T>
void write_vec(vector<T>& v, char divider){
    for(size_t i = 0; i < v.size(); i++){
        cout << v[i] << divider;
    }
}
//

Measured memory_bytes: 3788
#include <iostream>
#include <iomanip>

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

	double ans = 0;
	for (int i = 0; i < n; ++i) {
		double b;
		std::cin >> b;

		ans += 1 / b;
	}

	std::cout << std::fixed << std::setprecision(5) << 1/ans << std::endl;
}

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

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define mod 1000000007
#define inf 100000000000010
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
#define all(x) (x).begin(), (x).end()

typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> pi;

bool isprime(ll n)
{
    if(n<=1)return false;
    if(n<=3)return true;
    if(n%2==0||n%3==0)return false;
    for(ll i=5;i*i<=n;i+=6)
    {
        if(n%i==0||n%(i+2)==0)return false;
    }
    return true;
}

ll modexp(ll a,ll b,ll m)
{
    ll r=1;
    a=a%m;
    while(b>0)
    {
        if(b&1)r=(r*a)%m;
        b = b>>1;
        a=(a*a)%m;
    }
    return r%m;
}

struct CustomCompare
{
    bool operator()(const int& lhs, const int& rhs)
    {
        return lhs < rhs;
    }
};

bool comp(pair<ll, ll>a,pair<ll,ll>b)
{
    return a.fi>=b.fi;
}

ll builtin_popcount(ll x)
{
    ll cnt = 0;
    for(ll i=60;i>=0;i--)
    {
        if((1LL<<i)&x)cnt++;
    }
    return cnt;
}

ll addmod(ll a,ll b)
{
    a%=mod;
    b%=mod;
    return (a+b)%mod;
}
ll mulmod(ll a,ll b)
{
    a%=mod;
    b%=mod;
    return (a*b)%mod;
}
/*
const int mxn = 5*(1e6) +10;
vi spf(mxn);
void sieve()
{
    for(ll i =0;i<mxn;i++)spf[i]  = i;
    for(ll i=2;i<mxn;i+=2)spf[i] = 2;
    for(ll i = 3;i*i<mxn;i++)
    {
        if(spf[i]==i)
        {
            for(ll j = i*i;j<mxn;j+=i)
            {
                if(spf[j]==j)spf[j] = i;
            }
        }
    }
}
*/


const int N = 1e3 + 10 ,M = 1e3 + 10;
ll n,m;
vector<string>arr;
ll dp[N][M];
bool check(ll x,ll y)
{
    if(x>=0&&x<n&&y<m&&y>=0&&arr[x][y]=='.')return true;
    return false;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
cin>>n>>m;
arr = vector<string>(n);
ll x,y,a,b; cin>>x>>y>>a>>b;
x--,y--,a--,b--;
rep(i,0,n)cin>>arr[i];

for(ll i=0;i<N;i++)
{
    for(ll j=0;j<M;j++)dp[i][j] = mod;
}
ll dx[] = {-1,0,0,1};
ll dy[] = {0,-1,1,0};
deque<pair<pi,ll> >q;
q.push_back({{x,y},0});
dp[x][y] = 0;
while(!q.empty())
{
    auto tp = q.front();
    q.pop_front();
    rep(i,0,4)
    {
        ll xx = dx[i]+tp.fi.fi,yy = tp.fi.se+dy[i];
        if(check(xx,yy))
        {
            if(dp[xx][yy]<=dp[tp.fi.fi][tp.fi.se])continue;
            dp[xx][yy] = tp.se;
            q.push_front({{xx,yy},tp.se});
        }
    }

    for(ll i=-2;i<=2;i++)
    {
        for(ll j=-2;j<=2;j++)
        {
            ll xx = tp.fi.fi+i, yy = tp.fi.se+j;
            if(check(xx,yy))
            {
                if(dp[xx][yy]<=dp[tp.fi.fi][tp.fi.se]+1)continue;
                dp[xx][yy] = tp.se+1;
                q.push_back({{xx,yy},tp.se+1});
            }
        }
    }
}
if(dp[a][b]==mod)cout<<-1<<endl;
else cout<<dp[a][b]<<endl;
return 0;

}
/*
1
4
1 2
2 3
3 4
2
2 2
*/


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

const ll MAXN = 200000;
const ll INF = 1001001001;

ll X, Y, ans=0, tmp=0;
vector<ll> A;

signed main(){
    cin >> X >> Y;
    if(Y%2==0) {
        if(Y>=2*X&&Y<=4*X) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

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

    int n, i;
    cin >> n >> i;

    cout << n - i + 1 << endl;

    return 0;
}

Measured memory_bytes: 896
import Control.Applicative ((<$>), (<*>))
import Data.Bool (bool)
import Data.Char (digitToInt)

main :: IO ()
main = solve <$> readLn >>= putStrLn

solve :: Int -> String
solve = bool "No" "Yes" . (== 0) . ((sum . map digitToInt . show) >>= flip mod)


Measured memory_bytes: 508
#include <iostream>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>

using ll = long long;
using namespace std;
typedef unsigned long long ull;
typedef pair<ll, ll>P;
const ll mod = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
bool fl = true;;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
struct edge { ll to, cost; };

int main() {
	ll n, p[30000], a[30000] = { 0 }, b[30000] = { 0 }, c[30000] = { 0 };
	cin >> n;
	for (int i = 1;i <= n;i++) {
		cin >> p[i];
		c[p[i]] = i;
	}
	
	for (int i = 1;i <= n;i++) {
		a[i] = 30000 * i;
		b[i] = 30000 * (n - i) + c[i];
	}
	for (int i = 1;i <= n;i++) {
		if(i!=n)cout << a[i] + 1 << ' ';
		else cout << a[i] + 1 << endl;
	}
	for (int i = 1;i <= n;i++) {
		if(i!=n)cout << b[i] + 1 << ' ';
		else cout << b[i] + 1 << endl;
	}
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
#define  vi vector<long long int>
#define  set1 set<long long int>
#define  pb push_back
#define  map1 map<long long int,long long int>
#define  ll    long long int
#define  mp make_pair
#define  inf 1e17
#define  minf INT_MIN
#define  setbits(x) __builtin_popcountll(x)
#define  pres(x,y) fixed<<setprecision(y)<<x
#define  pair1 pair<long long int,long long int>
#define  mk(arr,n,type) type *arr=new type[n];
#define  mod 1000000007
#define  pi  3.1415926535897932384626433832
#define  ins insert
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
//find_by_order() --> returns an iterator to the k-th largest element (counting from zero)
//order_of_key()  --> the number of items in a set that are strictly smaller than our item.
#define  w(t) long long int t;t=1;while(t--)

void solve() {


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

	ll dp[n + 1];

	dp[1] = 0;


	for (ll i = 2; i <= n; i++) {
		ll opt1 = abs(a[i - 1] - a[i]) + dp[i - 1];
		ll opt2 = (i == 2) ? inf : abs(a[i - 2] - a[i]) + dp[i - 2];
		dp[i] = min(opt1, opt2);
	}


	cout << dp[n] << " ";


}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("inp.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	w(t) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 5188
const main = (input: string) => {
  const lines = input.trim().split("\n")
  const N = parseInt(lines[0])
  const X = lines[1].split(" ").map(str => parseInt(str))
  const maxPoint = Math.max(...X)
  let consumptionList = [];

  for (let i = 1; i <= maxPoint; i++) {
    let consumption = 0;

    X.forEach(x => {
      consumption += Math.pow(i - x, 2)
    });

    consumptionList.push(consumption)
  }

  console.log(Math.min(...consumptionList))
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7500
#include <bits/stdc++.h>
#include <iterator>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(v) begin(v), end(v)
#define rreps(i, a, n) for (ll i = (a); i <= (ll)(n); ++i)
#define rrep(i, n) rreps(i, 0, n)
#define reps(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) reps(i, 0, n)
#define each(i, n) for (auto&& i : n)
#define fill(x, y) memset(x,y,sizeof(x))
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
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; }
template <typename T> inline void print(const T& x) {cout << x << '\n';}

int dp[3][110];

signed main()
{
  int n; cin>>n;
  vvi a=vvi(3,vi(n+1));
  reps(i,1,3) reps(j,1,n+1) cin>>a[i][j];
  rep(i,n+1) dp[0][i]=0;
  rep(i,3) dp[i][0]=0;
  rep(i,2) rep(j,n)
  {
    dp[i+1][j+1]=max(dp[i+1][j]+a[i+1][j+1], dp[i][j+1]+a[i+1][j+1]);
  }
  print(dp[2][n]);

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b,c,x,y,z;
    scanf("%d%d%d",&a,&b,&c);
    x=a+b;
    y=a+c;
    z=b+c;
    if(x<=y&&x<=z)
    {
        printf("%d",x);
    }
    else if(y<=x&&y<=z)
    {
        printf("%d",y);
    }
    else
    {
        printf("%d",z);
    }
    return 0;
}


Measured memory_bytes: 128
n,m=map(int,input().split())
x=1
s=1
while x**2<=m:
  a,b=divmod(m,x)
  if a>=n and b==0:
    s=max(x,s)
  if x>=n and b==0:
    s=max(a,s)
  x+=1

print(s)

Measured memory_bytes: 3060
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var raw = ReadLine().Split().Select(int.Parse).ToArray();
            var K = raw[0];
            var X = raw[1];

            var ans = "";
            Enumerable.Range(X - K + 1, K * 2 - 1).ToList().ForEach(x => ans += x.ToString() + " ");
            WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define lli long long int
#define MOD 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<int>
#define vvi vector<vector<int>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    string s, t, u;
    int a, b;
    cin >> s >> t >> a >> b >> u;
    if(s == u) a--;
    else b--;
    cout << a << " " << b << endl;
}

Measured memory_bytes: 256
N=int(input())

cnt=0
L=[]
def make_divisors(n):
    divisors = []
    for i in range(1,int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n//i:
                divisors.append(n//i)

    return divisors

for num in range(2,55555+1):
    l=make_divisors(num)
    if len(l)==2:
        pass
    else:
        continue 
    if num%5==1:
        L.append(num)
        cnt+=1
    if cnt==N:
        break

print(*L)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<long long, long long> pllll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int, int> > vii;
typedef vector< pair<long long, long long> > vllll;
typedef map<int, int> mii;
typedef map<long long, long long> mllll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0ll)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
#define bitsum(x) __builtin_popcount(x)
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a / gcd(a, b) * b;
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
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 argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  int ans = INF;
  // ll n;
  // cin >> n;
  int n, k;
  cin >> n >> k;
  // ll n, m, k;
  // cin >> n >> m >> k;
  vi plus, minus;
  fi(0, n) {
    int x;
    cin >> x;
    if(x < 0) {
      minus.push_back(-x);
    }
    else
      plus.push_back(x);
  }
  reverse(all(minus));
  int max_plus_num = min((int)plus.size(), k);
  int max_minus_num = min((int)minus.size(), k);
  if(max_plus_num == 0) {
    cout << minus[k - 1] << endl;
    return 0;
  }
  else if(max_minus_num == 0) {
    cout << plus[k - 1] << endl;
    return 0;
  }
  else {
    int i = max_minus_num - 1;
    int j = k - max_minus_num - 1;
    while(j < max_plus_num) {
      chmin(ans, minus[i] + plus[j] + min(minus[i], plus[j]));
      i--, j++;
    }
  }


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



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

using namespace std;

const double PI = 3.14159265358979323846;

double A(double R) {
	return 2 * PI * R;
}

int main() {
	double R;
	cin >> R;
	cout << fixed << setprecision(6) << A(R);
	return 0;
}

Measured memory_bytes: 3772
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
int F[2100010];

int Mul(int a, int b) {
	return ((a % mod) * (b % mod)) % mod;
}

void fact(void) {
	F[0] = 1;
	F[1] = 1;
	for (int i = 2; i <= 2100000; i++) {
		F[i] = Mul(i, F[i - 1]);
	}
}
int square(int x) {
	return (x * x) % mod;
}

int power(int x, int y) {
	if (y == 0) return 1;
	else if (y == 1) return x % mod;
	else if (y % 2 == 0) return square(power(x, y / 2)) % mod;
	else return square(power(x, y / 2)) * x % mod;
}

int Div(int a, int b) {
	return Mul(a, power(b, mod - 2));
}
int P(int n, int r) {
	if (n < r || n < 0 || r < 0) return 0;
	return Div(F[n], F[n - r]);
}

int C(int n, int r) {
	if (n < r || n < 0 || r < 0) return 0;
	int ret;
	ret = Div(F[n], Mul(F[n - r], F[r]));
	return ret;
}
int H(int n, int r) {
	if (n == 0 && r == 0) return 1;
	return C(n + r - 1, r);
}
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    //fact();
    int ans = 0;
    int sum = 0;
    rep(i, N + 1) sum += i + 1;
    REP(i, K, N + 1) {
        int lower = i * (i + 1) / 2;
        int cnt = N + 1 - i;
        int upper = sum - cnt * (cnt + 1) / 2;
        //cout << lower <<" " << upper << endl;
        ans = (ans + upper -lower + 1) % mod;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, begin, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    vector<int> P(3);
    rep(i, 0, 3)
    {
        cin >> P.at(i);
    }
    sort(all(P));
    cout << P.at(0) + P.at(1) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define dbg(x) cout << #x << ": " << (x) << '\n'
#define ff first
#define ss second
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;

const int idx = 1e5 + 10, sum = 101, tight = 2;
int mod = 1e9 + 7;

int dp[idx][sum][tight];

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

   string s;
   int d;
   cin >> s >> d;
   int n = s.length();
   vector <int> a;
   for (auto &i : s)
      a.push_back(i - '0');

   dp[n][0][0] = 1;
   dp[n][0][1] = 1;

   for (int i = n - 1; i >= 0; i--) {
      for (int m = 0; m < 2; m++) {
         for (int k = 0; k < d; k++) {
            for (int j = 0; j < 10; j++) {
               int x = (j + k) % d;
               if (m == 0) {
                  if (i == 0 && a[i] <= j)
                     continue;
                  dp[i][x][m] += dp[i + 1][k][m];
               } else {
                  if (j < a[i] && i != 0)
                     dp[i][x][m] += dp[i + 1][k][!m];
                  else if (j == a[i])
                     dp[i][x][m] += dp[i + 1][k][m];
               }
               dp[i][x][m] %= mod;
            }
         }
      }
   }

   cout << ((dp[0][0][1] + dp[0][0][0]) % mod + mod - 1) % mod << endl;

   return 0;
}

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

using namespace std;

typedef long long ll;

ll binoms[51][51];

ll binom(ll n, ll k) {
  if (binoms[n][k] == -1) {
    if (n < k) binoms[n][k] = 0;
    else if (n == k) binoms[n][k] = 1;
    else if (k == 0) binoms[n][k] = 1;
    else binoms[n][k] = binom(n - 1, k - 1) + binom(n - 1, k);
  }
  return binoms[n][k];
}

int main() {
  memset(binoms, -1, sizeof(binoms));
  for (ll i = 0; i <= 50; i++) {
    for (ll j = 0; j <= 50; j++) {
      binoms[i][j] = binom(i, j);
    }
  }

  ll n, p;
  cin >> n >> p;
  vector<ll> bis(n);
  ll odd = 0;
  ll even = 0;
  for (ll i = 0; i < n; i++) {
    cin >> bis[i];
    if (bis[i] & 1) odd++;
    else even++;
  }

  if (p == 1) {
    if (odd == 0) {
      cout << "0" << endl;
    } else {
      ll res = 0;
      for (ll i = 1; i <= odd; i += 2) {
        res += (1LL << even) * binoms[odd][i];
      }
      cout << res << endl;
    }
  } else {
    ll res = 0;
    for (ll i = 0; i <= odd; i += 2) {
      res += (1LL << even) * binoms[odd][i];
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 256
//Let's join Kaede Takagaki Fan Club !!
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define all(x) x.begin(),x.end()
template<class T>
void dmp(T a){
	rep(i,a.size()) cout << a[i] << " ";
	cout << endl;
}
template<class T>
bool chmax(T&a, T b){
	if(a < b){
		a = b;
		return 1;
	}
	return 0;
}
template<class T>
bool chmin(T&a, T b){
	if(a > b){
		a = b;
		return 1;
	}
	return 0;
}
template<class T>
void g(T &a){
	cin >> a;
}
template<class T>
void o(const T &a,bool space=false){
	cout << a << (space?' ':'\n');
}
//ios::sync_with_stdio(false);
const ll mod = 1000000007;//998244353
template<class T>
void add(T&a,T b){
	a+=b;
	if(a >= mod) a-=mod;
}

int main(){
	string s, t; cin >> s >> t;
	t.pop_back();
	puts(s==t?"Yes":"No");
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
    using namespace std;
    
    #define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    #include <ext/pb_ds/assoc_container.hpp> 
    #include <ext/pb_ds/tree_policy.hpp> 
    using namespace __gnu_pbds; 
    #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
    
    #define int long long 
    #define double long double
    
    #define all(a)      (a).begin(),(a).end()
    #define sz(x)       (int)x.size()
    
    #define ff first
    #define ss second
    #define mp make_pair
         
    #define pb push_back
    #define endl "\n" 
         
    #define f(i,l,r) for(int i=l;i<=r;i++)
    #define rf(i,r,l) for(int i=r;i>=l;i--)    

    #define bp __builtin_popcountll
    #define inf 1e18
    
    const int N=1e5+5; 
    const int MOD=1e9+7;
    void solve()
    {
        int n;
        cin>>n;
        int ans=0;
        f(i,1,n)
        f(j,1,n)
        f(k,1,n)
        {
        	ans+=__gcd(__gcd(i,j),k);
        }
        cout<<ans;
    }
    
    signed main()  
    {
        FAST
        int t=1;
        // cin>>t;
        while(t--)
        {
            solve();
        }
    }



Measured memory_bytes: 3652
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
    LL int a;
    LL int n,mymax=0,mymin=1000000000;

    cin >> n;
    FOR(i,0,n){
        cin >> a;
        if(a > mymax)mymax = a;
        if(a < mymin)mymin = a;
    }

    cout << mymax - mymin << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rrep(i, n, g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define dup(x, y) (((x) + (y)-1) / (y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  double a,b;
  cin >> a>>b;
  cout << a/b << endl;
}

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

int mod_count[2019]={};

int main(){
    string S;
    cin >> S;

    int N = (int) S.size();
    int Smod[N],Tenpow[N];

    for(int i=N-1; i>=0; i--){
        if(i==N-1){
            Smod[i] = (int) ( S[i] - '0' );
            Tenpow[i] = 1;
            mod_count[Smod[i]]++;
        }else{
            Tenpow[i] = Tenpow[i+1]*10 % 2019;
            Smod[i] = (Smod[i+1] + ( (int) ( S[i] - '0' ) )*Tenpow[i])%2019;
            mod_count[Smod[i]]++;
        }
    }
    mod_count[0]++;

    long ans=0;

    for(int i=0; i<2019; i++){
        //if(mod_count[i]!=0) cout << "i mod_count " << i << " " << mod_count[i] << endl;
        ans += ( (long) mod_count[i] )*( (long) mod_count[i] - 1l )/( 2l );
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5112
#include<bits/stdc++.h>
using namespace std;
#define SS 500000
int f[SS+10][30];
char str[SS+10];
int g[SS+10][30];
int main(){
	scanf("%s",str);
	int len=strlen(str);
	for(int i=0;i<=len+5;i++)
		for(int j=0;j<=28;j++)
			g[i][j]=len+2,f[i][j]=len+2;
	for(int i=len-1;i>=0;i--){
		int sr=str[i]-'a';
		f[i][sr]=i;
		for(int j=sr+1;j<=26;j++)f[i][j]=f[f[i][j-1]+1][j-1];
		g[i][0]=f[i][26];
	//	printf("%d %d\n",i,f[i][26]);
		for(int j=1;j<=18;j++)g[i][j]=g[g[i][j-1]+1][j-1];
		for (int j=0; j<sr; j++) f[i][j]=f[g[i][0]+1][j];
	}
	int q;scanf("%d",&q);
	while(q--){
		int l,r;scanf("%d%d",&l,&r);
		if(l==r){
			puts("No");
			continue;
		}
		l--;
	//	printf("%d %d\n",l,r);
		for (int i=18; i>=0; i--) {
		//	printf("%d %d %d\n",l,i,g[l][i]);
			if (g[l][i]<=r) l=g[l][i]+1;
		}
		//printf("%d\n",l);
		if(r==l)printf("Yes\n");
		else printf("No\n");
	}
}


Measured memory_bytes: 118272
#include <bits/stdc++.h>
using namespace std;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define FOR(i,k,n) for(ll i=(k);(k)<(n)?i<(n):i>(n);(k)<(n)?i+=1:i-=1)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const int INF = 1<<29;
typedef long long ll;
typedef unsigned long long ull;
typedef vector< ll > vi;
typedef vector< vi > vvi;
typedef pair< ll,ll > ii;
#define F first
#define S second
#define EB emplace_back
#define PB push_back
#define MP make_pair
#define sz(a) ll((a).size())
#define all(o) (o).begin(), (o).end()
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element) (find(all(container),element) != container.end())
#define TR(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
template<class T> T** arr2D(int n,int m,T init){
    T** mat=new T*[n];
    FOR(i,0,n){
        mat[i]=new T[m];
        FOR(j,0,m){
            mat[i][j]=init;
        }
    }
    return mat;
}
template<class T> void initialise(T** mat,T init,int n,int m){
    FOR(i,0,n){
        FOR(j,0,m){
            mat[i][j]=init;
        }
    }
}
template<class T> void destroy(T** mat,int n,int m){
    FOR(i,0,n){
        delete[] mat[i];
    }delete[] mat;
}
const int MOD = 1000000007;
ll fastpowMOD(ll a, ll p,ll MOD){ if(p==0) return 1; ll z = fastpowMOD(a,p/2,MOD); z = (z*z)%MOD; if(p%2) z = (z*a)%MOD; return z; }

/////////////////////////////////////////////////////////////////////
void solve(){
    int N,K;
    cin>>N>>K;
    vector<int> moves(N);
    FOR(i,0,N){
        cin>>moves[i];
    }
    vector<bool> player_wins(K+1,false);
    FOR(i,0,K+1){
        if(player_wins[i]==false){
            FOR(j,0,N){
                if(i+moves[j]<=K)
                    player_wins[i+moves[j]]=true;
            }
        }
    }
    if(player_wins[K]){
        cout<<"First\n";
    }else{
        cout<<"Second\n";
    }
}
int main()
{
    fastio
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    #endif
    solve();
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define debug(x) cerr<<#x<<" = "<<x
#define sp <<"  "
#define el <<endl
#define fgx cerr<<"-----------------------------------"<<endl
#define LL long long
#define DB double
using namespace std;
inline LL read(){
	LL nm=0; bool fh=1; char cw=getchar();
	for(;!isdigit(cw);cw=getchar()) fh^=(cw=='-');
	for(;isdigit(cw);cw=getchar()) nm=nm*10+(cw-'0');
	return fh?nm:-nm;
}
#define mod 998244353
namespace  CALC{
	inline int add(int x,int y){return (x+y>=mod)?(x+y-mod):(x+y);}
	inline int mns(int x,int y){return (x-y<0)?(x-y+mod):(x-y);}
	inline int mul(LL x,LL y){return x*y%mod;}
	inline void upd(int &x,int y){x=(x+y>=mod)?(x+y-mod):(x+y);}
	inline void dec(int &x,int y){x=(x-y<0)?(x-y+mod):(x-y);}
	inline int qpow(int x,int sq){LL res=1;for(;sq;sq>>=1,x=mul(x,x))if(sq&1)res=mul(res,x);return res;}
}using namespace CALC;
#define M 3010
int A,B,C,D,F[M][M][3],pw[M][M];
inline int DP(int n,int m,int top){
	if(A==n&&B==m){return top==0;}
	if(A==n){
		int now=pw[A][m-B],res;
		res=pw[A-1][m-B]; if(!top) return res; dec(now,res);
		res=mul(pw[A-1][m-B-1],m-B); if(top==1) return res; dec(now,res);
		return now;
	}
	if(B==m){
		if(top!=1) return 0;
		return pw[B][n-A];
	} if(!top) return 0;
	if(F[n][m][top]!=-1) return F[n][m][top];
	int &ret=F[n][m][top]; ret=0;
	if(top==1) ret=add(add(DP(n-1,m,0),DP(n-1,m,1)),DP(n-1,m,2)),ret=mul(ret,m);
	else ret=add(mul(n,DP(n,m-1,2)),DP(n,m-1,1));
	return ret;
}
int main(){
	A=read(),B=read(),C=read(),D=read();
	memset(F,-1,sizeof(F));
	for(int i=0;i<=max(C,D);i++){
		pw[i][0]=1;
		for(int j=1;j<=max(C,D);j++) pw[i][j]=mul(pw[i][j-1],i);
	}
	int ans=0;
	upd(ans,DP(C,D,0));
	upd(ans,DP(C,D,1));
	upd(ans,DP(C,D,2));
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 145512
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
using namespace std;

typedef long long ll;

int main() {
    vector< array<int, 3> > rects;
    for (int h = 1; h <= 150; h++) {
        for(int w = h + 1; w <= 150; w++) {
            rects.push_back({h*h + w*w, h, w});
        }
    }
    sort(rects.begin(), rects.end());
    while(true) {
        int h, w; cin >> h >> w;
        if(h == 0 && w == 0) break;
        auto ans = *upper_bound(rects.begin(), rects.end(), array<int, 3>{h*h + w*w, h, w});
        cout << ans[1] << ' ' << ans[2] << endl;
    }
}


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

int main() {
	int r, c, ans = 0;
	cin >> r >> c;
	int a[r][c];
	for (int i = 0; i < r; ++i) {
		for (int j = 0; j < c; ++j) {
			cin >> a[i][j];
		}
	}
	for (int i = 0; i < r; ++i) {
		for (int j = 0; j < c; ++j) {
			cout << a[i][j] << " ";
			ans += a[i][j];
		}
		cout << ans << endl;
		ans = 0;
	}
	int sum = 0;
	for (int i = 0; i < c; ++i) {
		for (int j = 0; j < r; ++j) {
			ans += a[j][i];
		}
		sum += ans;
		cout << ans << " ";
		ans = 0;
	}
	cout << sum << endl;
}

Measured memory_bytes: 3124
#include <stdio.h>

#define N 8
#define FREE -1
#define NOT_FREE 1

int row[N],col[N],dpos[2*N-1],dneg[2*N-1];
int X[N][N];

void initialize();
void recursive(int);
void PrintBord();

int main(){
  int i,j,k,r,c,n,R[N];
  initialize();
  for(i=0;i<N;i++)
    for(j=0;j<N;j++)
      X[i][j]=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%d",&r,&c);
    X[r][c]=1;
  }
  recursive(0);
  return 0;
}

void recursive(int i){
  int j;
  if(i==N)
    {
      PrintBord();
      return;
    }
  for(j=0;j<N;j++){
    if(NOT_FREE==col[j]||NOT_FREE==dpos[i+j]||NOT_FREE==dneg[i-j+N-1])
      continue;
    row[i]=j;
    col[j]=dpos[i+j]=dneg[i-j+N-1]=NOT_FREE;
    recursive(i+1);
    row[i]=col[j]=dpos[i+j]=dneg[i-j+N-1]=FREE;
  }
  return;
}

void initialize(){
  int i;
  for(i=0;i<N;i++){
    row[i]=FREE;
    col[i]=FREE;
  }
  for(i=0;i<2*N-1;i++){
    dpos[i]=FREE;
    dneg[i]=FREE;
  }
  return;
}

void PrintBord(){
  int i,j;
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(X[i][j]){
	if(row[i]!=j)
	  return;
      }
    }
  }
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(row[i]==j)
	printf("Q");
      else
	printf(".");
    }
    printf("\n");
  }
  
  return;
}

Measured memory_bytes: 572
S = input()

if S == "SAT":
    print("1")
elif S == "FRI":
    print("2")
elif S == "THU":
    print("3")
elif S == "WED":
    print("4")
elif S == "TUE":
    print("5")
elif S == "MON":
    print("6")
else:
    print("7")

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> p(m);
    vector<string> s(m);

    for (int i = 0; i < m; i++) {
        cin >> p[i] >> s[i];
    }

    vector<int> c(n, 0);
    vector<bool> f(n, false);

    int cnt = 0;

    for (int i = 0; i < m; i++) {
        if (!f[p[i] - 1]) {
            if (s[i] == "WA") {
                c[p[i] - 1]++;
            } else {
                f[p[i] - 1] = true;
                cnt += c[p[i] - 1];
            }
        }
    }

    int ac = 0;
    for (int i = 0; i < n; i++) {
        if (f[i]) {
            ac++;
        }
    }

    cout << ac << " " << cnt << endl;
}

Measured memory_bytes: 6528
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.xise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

ll f[2000005];
//int n,k とかしておく

ll pw(ll x, ll y){//euclidの互除法より
    ll a= 1;
    while(y){
        if(y&1){//奇数なら
            a = a*x%mod;
        }
        x = x*x%mod;
        y /= 2;
    }
    return a;
}

ll modinv(ll x){//逆元を求める
    return pw(x, mod - 2 );
}

ll comb(int n,int r){
    if(n<r){
        return 0;
    }
    return f[n] * modinv(f[r])%mod*modinv(f[n-r])%mod;
}//対combination//ただしfは用意してね

int main(){
    int x,y;
    cin >> x>> y;
    int a=0,b=0;
    while(x>y){
        b++;
        x-=2;
        y-=1;
    }
    while(y>x){
        a++;
        x-=1;
        y-=2;
    }
    if(x%3==0&&x>=0){
        a+=y/3;
        b+=x/3;
    }else{
        cout<<0<<endl;
        return 0;
    }
    cerr<<a<<' '<<b<<endl;
    f[0]=1;
    for(ll i=1;i<2000005;i++){
        f[i]=f[i-1]*i;
        f[i]%=mod;
        //cerr<<f[i];
    }
    /*
    rep(i,10){
        cerr<<f[i]<<endl;
    }
    */
    
    ll ans=comb(a+b,a);
    
    /*
    cerr<<a+b<<' '<<a<<endl;
    cerr<<f[a+b]<<' '<<f[a]<<endl;
    cerr<<ans<<endl;
    */
    ans%=mod;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 16000
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=b-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define MOD 1000000007
#define MAXN 52
#define MAXH 20
#define MAXM 52
#define INF 100000000
#define ll long long
#define ull unsigned long long
#define RNG rng mt19937(time(NULL))
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int main(){
	fast_io();
	int n,k;
	cin >> n >> k;
	vector<int> v(n);
	cu(i,0,n)cin >> v[i];
	vector<int> dp(n);
	cu(i,1,n){
		dp[i] = MOD;
		cu(j,max(i-k,0),i){
			dp[i] = min(dp[i], dp[j] + abs(v[i] - v[j]));
		}
	}
	cout << dp[n-1] << endl;
}


Measured memory_bytes: 1024
from collections import Counter
n=int(input())
a=list(map(int,input().split()))

cnt=Counter(a)
edge=[0,0]

for i in cnt:
    if cnt[i]>=4:
        edge.append(i)
    if cnt[i]>=2:
        edge.append(i)

edge.sort(reverse=True)
print(edge[0]*edge[1])

Measured memory_bytes: 100456
import copy

H, W, K = list(map(int,input().split()))
c = []
for i in range(H):
    c.append(input())
    
red = 0
cc = [[-1 for _ in range(W)] for j in range(H)]
for i in range(W):
    for j in range(H):
        if c[j][i] == ".":  cc[j][i] = 0
        else:  
            cc[j][i] = 1
            red += 1
            
def bit_all(red):
    ans = 0
    for x in range(2 ** W):
        for y in range(2 ** H):
            ccc = copy.deepcopy(cc)
            temp = 0
            b = str(format(x, '010b'))
            c = str(format(y, '010b'))
            
            for i in range(W):
                if b[-(i + 1)] == "1":
                    for ii in range(H):
                        if ccc[ii][i] == 1:
                            ccc[ii][i] = 0
                            temp += 1
                            
            for j in range(H):
                if c[-(j + 1)] == "1":
                    for ii in range(W):
                        if ccc[j][ii] == 1:
                            ccc[j][ii] = 0
                            temp += 1 
                            
            if red - temp == K:
                ans += 1
                
    return ans

ans = bit_all(red)
print(ans)

Measured memory_bytes: 77944
import sys
from collections import deque
def input(): return sys.stdin.readline().strip()


def main():
    """
    「数字の桁数の和に関する問題としては初見はキツいが割と典型らしい」

    全ての整数は1から出発して次の操作のいずれかを組み合わせて表現できる：
        a. 1を加える（ただし一の位が9の時はこの操作は許さない）
        b. 10倍する
    なぜこのような分解をしたかというと、整数をこのように表現することで
        （各桁の和）=（a.の操作を行った回数）+ 1
    と言い換えることができるから。

    そこで頂点を数字、辺を上の操作に当ててBFSすることを考える。
    このままでは頂点数が無限だが、辺の張られ方はmod Kをとっても同様の構造が出てくる。
    そこで無限グラフをmod Kで圧縮して有限グラフに直した上で頂点1から頂点0に移動するための
    最小コストが答え。

    ここでa.の操作で9->10のような遷移は許さなかったが、求めるのは最小コストであって
    1から10にたどり着くにはa.を10回するよりb.を1回する方がコストが低いので、a.の操作を
    一の位が9の場合に許容したとしても最短経路長は変化しない。
    """
    K = int(input())
    repn = [[] for _ in range(K)]
    for i in range(K):
        repn[i].append(10**6 + (i + 1) % K)
        repn[i].append((i * 10) % K)
    q = deque([])
    cost = [0] * K
    cost[1] = 1
    for val in repn[1]:
        type, toward = val // 10**6, val % 10**6
        # コスト0の辺は即popされるようにキューの左に入れる
        if type == 0:
            q.appendleft(1 * 10**6 + toward)
        else:
            q.append(10**12 + 1 * 10**6 + toward)

    while q:
        x = q.popleft()
        type, x = x // 10**12, x % 10**12
        pre, now = x // 10**6, x % 10**6
        if cost[now] != 0: continue
        cost[now] = cost[pre] + type
        for val in repn[now]:
            type, toward = val // 10**6, val % 10**6
            if type == 0:
                q.appendleft(now * 10**6 + toward)
            else:
                q.append(10**12 + now * 10**6 + toward)

    print(cost[0])


if __name__ == "__main__":
    main()


Measured memory_bytes: 88296