akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
struct data
{
	int x,y,ox,oy;
};
int n,d1,d2;
bool c1[600][600],c2[600][600];
int cnt[4],tot;
void work(vector<data>&p,int d,bool c[600][600])
{
//	for(auto i:p)printf("%d %d\n",i.ox,i.oy);
//	printf("\n");
	if(d&1)
	{
		for(auto i:p)c[i.ox][i.oy]=(i.x+i.y)&1;
		return ;
	}
	vector<data>q;
	for(auto i:p)if((i.x+i.y)&1)q.push_back(data{(i.x-i.y+1)/2,(i.x+i.y+1)/2,i.ox,i.oy});
	work(q,d/2,c);
	q.clear();
	for(auto i:p)if((i.x+i.y+1)&1)q.push_back(data{(i.x-i.y)/2,(i.x+i.y)/2,i.ox,i.oy});
	work(q,d/2,c);
}
int main()
{
	scanf("%d %d %d",&n,&d1,&d2);
	vector<data>p;
	for(int i=0;i<2*n;++i)
		for(int j=0;j<2*n;++j)
			p.push_back({i,j,i,j});
	work(p,d1,c1);
	work(p,d2,c2);
/*	for(int i=0;i<2*n;++i)
	{
		for(int j=0;j<2*n;++j)printf("%d ",c1[i][j]);
		printf("\n");
	}
	for(int i=0;i<2*n;++i)
	{
		for(int j=0;j<2*n;++j)printf("%d ",c2[i][j]);
		printf("\n");
	}	*/
	for(int i=0;i<2*n;++i)
		for(int j=0;j<2*n;++j)
			++cnt[c1[i][j]<<1|c2[i][j]];
	for(int k=0;k<=3;++k)
		if(cnt[k]>=n*n)
			for(int i=0;i<2*n;++i)
				for(int j=0;j<2*n;++j)
					if((c1[i][j]<<1|c2[i][j])==k)
					{
						++tot;
						printf("%d %d\n",i,j);
						if(tot==n*n)return 0;
					}
	return 0;
}


Measured memory_bytes: 16404
use std::io;

#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

fn main() {
    let (n, d, x): (usize, usize, usize);
    input!(n);
    input!(d, x);
    let mut ans = 0;
    for _ in 0..n {
        let a: usize;
        input!(a);
        ans += 1 + (d - 1) / a;
    }
    p(x + ans);
}

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

#define sz(a) ((int)a.size())
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(i, a) for (auto &i : (a))
#define all(v) v.begin(), v.end()
#define mp(a, b) make_pair(a, b)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vl> vvvl;
typedef double T;
typedef vector<T> vt;
typedef vector<vt> vvt;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpi;
typedef tuple<ll, int, int> tlii;

const int MOD = 1e9+7; // 998244353;
const int INF = 1e9+1;

using Cost = int;
int main() {
  cin.sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<Cost> costs(n);
  for (int i = 0; i < n; ++i) {
    cin >> costs[i];
  }
  vector<int> dp(n, INF);
  dp[0] = 0;
  dp[1] = abs(costs[1] - costs[0]);

  for (int i = 2; i < n; ++i) { 
    dp[i] = min(dp[i - 1] + abs(costs[i] - costs[i - 1]),
                dp[i - 2] + abs(costs[i] - costs[i - 2]));
  }
  cout << dp.back() << endl;
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = RInt();
            int[] vs = RArInt();
            int[] cs = RArInt();

            int value = 0;
            for (int i = 0; i < n; i++)
            {
                if (vs[i] >= cs[i])
                {
                    value += vs[i] - cs[i];
                }
            }
            Console.WriteLine(value);
        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RArSt(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RArInt(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RArLong(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RArDouble(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(void){
    int p;
    int a[30];
    cin >> p;
    
    for(int i=0;i<p;i++) cin >> a[i]; 
    
    int count = 0;
    for(int i=0;i<p-2;i++){
        if((a[i]<=a[i+1] and a[i+1]<=a[i+2]) or (a[i]>=a[i+1] and a[i+1]>=a[i+2])) count++;
    }
    
    cout << count;

    return 0;
    
}


Measured memory_bytes: 3644
#%%
n = int(input())
a = int(n/1.08)


b = int(1.08 * a)
if b == n:
	print(a)
else:
	a += 1
	b = int(1.08 * a)
	if b == n:
		print(a)
	else:
		a += 1
		b = int(1.08 * a)
		if b == n:
			print(a)
		else:
			print(':(')

Measured memory_bytes: 3064
#include <stdio.h>

int main (){
  int x,w,i;
  double y;
  scanf("%d",&x);

  y=(x/1.08);
  w=y;
  i=w*1.08;

  if (i == x)
  {
    printf("%d\n", w);
    return 0;
  }

  w=y+1;
  i=w*1.08;
  if (i == x)
  {
    printf("%d\n", w);
    return 0;
  }
  else
    printf(":(\n");

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
using namespace std;
int kaijo(int n){
	int ans = 1;
	if (n != 0){
		for (int i = 0; i < n; i++){
			ans *= (n - i);
		}
	}
	else{
		ans = 1;
	}
	return ans;
}

int main(){
	double n, m;
	double a;
	double b;
	double p;
	double ansd = 0.0;
	cin >> n >> m;
	a = m;
	b = n - m;
	p = pow(0.5, a);
	int x = 1;
	while (x < 10000){
		ansd += (a*1900.0 + b * 100.0)*x*pow(1.0 - p, x - 1)*p;
		x++;
		//cout << ansd << endl;
	}
	cout << ansd << endl;
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define MAXN 100010

using namespace std;

int v[MAXN], dp[MAXN];

int res(int i, int n){
	if(i == n-1) return 0;
	if(i+2 == n) return fabs(v[n-1]-v[i]);
	if(dp[i] != -1) return dp[i];
	return dp[i] = min(fabs(v[i+1]-v[i]) +res(i+1, n), fabs(v[i+2]-v[i]) + res(i+2, n));
}

int main(){
	int n;
	cin >> n;
	memset(dp, -1, sizeof(dp));
	for(int i = 0;i < n;++i){
		cin >> v[i];
	}
	cout << res(0, n) << endl;
}

Measured memory_bytes: 4096
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#define ll long long
#define out(a) printf("%d",a)
#define rep(i,a,b) for (int i=a;i<=b;i++)
using namespace std;
int n,a,b,x;
int ans=0;
int read()
{
	int s=0,t=1; char c;
	while (c<'0'||c>'9') {if (c=='-') t=-1; c=getchar();}
	while (c>='0'&&c<='9') {s=s*10+c-'0'; c=getchar();}
	return s*t;
}
int main()
{
	n=read(); a=read(); b=read(); x=read();
    rep(i,0,n)
      rep(j,0,a)
        rep(k,0,b)
          if (i*500+j*100+k*50==x) ans++;
    out(ans);
    return 0;
 }

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <ctype.h>
#include <functional>
#include <iostream>
#include <cassert>
#include <cfloat>
#include <climits>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
int main() {
	string s;
	cin >> s;
	int n = s.size();
	int a;
	long long res=0;
	for (int i = 0; i < n; i++) {
		for (int j = i; j < n; j++) {
			a = n - 1 - (j - i + 2);
			if (i == 0) {
				a++;
			}
			if (j == n - 1) {
				a++;
			}
			res+=(1<<a)* stoll(s.substr(i, j - i + 1));
			cerr << (1 << a) << " " << stoll(s.substr(i, j - i + 1)) << endl;
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
/**********************************************************************
   File hoge.cpp
   Author  harunaya
   Date   2020-06-27(Sat)
   note   
**********************************************************************/

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) for (int i = 1; i <= (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int N; cin >> N;
  vector<string> S(N);
  rep(i,N) {
    cin >> S.at(i);
  }

  int count_AC = 0, count_WA = 0, count_TLE = 0, count_RE = 0;
  rep(i,N) {
    if (S.at(i) == "AC") count_AC++;
    else if (S.at(i) == "WA") count_WA++;
    else if (S.at(i) == "TLE") count_TLE++;
    else if (S.at(i) == "RE") count_RE++;
  }

  cout << "AC x " << count_AC << endl;
  cout << "WA x " << count_WA << endl;
  cout << "TLE x " << count_TLE << endl;
  cout << "RE x " << count_RE << endl;
  return 0; 
}

Measured memory_bytes: 6348
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

ll calc(ll n, ll k)
{
	assert(k > 0);
	if (n < k) return n;
	else return n % k + calc(n / k, k);
}

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	ll n, s;
	cin >> n >> s;
	if (n == s)
	{
		cout << s + 1 << endl;
		return 0;
	}
	int rt = sqrt(n) + 1;
	FOR(i, 2, rt)
	{
		if (calc(n, i) == s)
		{
			cout << i << endl;
			return 0;
		}
	}
	for (int i = rt; i >= 1; i--)
	{
		if (n / i < 2) continue;
		ll a = calc(n, n / i);
		if (s - a < 0) continue;
		if ((s - a) % i == 0)
		{
			ll t = n / i - (s - a) / i;
			if (t > 1 && calc(n, t) == s)
			{
				cout << t << endl;
				return 0;
			}
		}
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define hell 1000000007
#define PI 3.14159265358979323846
using namespace std;
ll fact(ll x)
{
    ll ans=1;
    for(ll i=1;i<=x;i++)
        ans*=i;
    return ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;

   // cin>>t;
    while(t--)
    {
       ll n,i;
       cin>>n;
       ll arr[n+1];
       set<ll> st;
       for(i=0;i<n;i++)
        {
            cin>>arr[i];
            st.insert(arr[i]);
        }
        ll a=1;
       for(i=0;i<n;i++)
       {
           ll x=arr[i];
           int c=distance(st.begin(),st.lower_bound(x));
           a+=c*fact(n-1-i);
           st.erase(x);
       }
       st.clear();
       for(i=0;i<n;i++)
        {
            cin>>arr[i];
            st.insert(arr[i]);
        }
        ll b=1;
       for(i=0;i<n;i++)
       {
           ll x=arr[i];
           ll c=distance(st.begin(),st.lower_bound(x));
           b+=c*fact(n-1-i);
           st.erase(x);
       }
       cout<<abs(a-b);
    }
}


Measured memory_bytes: 3620
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
using namespace std;

int digitSum(int x) {
    int sum = 0;
    while(x != 0) {
        sum += x % 10;
        x /= 10;
    }
    return sum;
}

int main() {
    int n, fn;
    cin>>n;
    fn = digitSum(n);
    if(n%fn==0)
        cout<<"Yes";
    else
        cout<<"No";



    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())

tmp_dict = {} # 作業辞書
result_dict = {} # 結果辞書

for _ in range(M):
  quiz, res = input().split()	
  
  if quiz not in tmp_dict:
    # 作業辞書になければ作成
      tmp_dict[quiz] = 0
      
  # 正解、結果辞書にもなければ  
  if res == "AC" and quiz not in result_dict: 
    wa_count = tmp_dict.pop(quiz)
    result_dict[quiz] = wa_count

  # 間違い、結果辞書にもなければ
  if res == "WA" and quiz not in result_dict: 
    tmp_dict[quiz] += 1


print(len(result_dict), sum(result_dict.values()))

Measured memory_bytes: 17116
n = gets.chomp.to_i
arr = gets.chomp.split.map(&:to_i)
cnt = 0

l = arr.index{|a| a > 0}
if l == nil
	puts 0
	exit
end

while l != nil
	while l < n && arr[l] > 0
		arr[l] -= 1
		l += 1
	end
	cnt += 1
	l = arr.index{|a| a > 0}
end
puts cnt


Measured memory_bytes: 14280
#include <bits/stdc++.h>
#define rep(i,s,n) for (int i=s;i<n;++i)
#define drep(i,s,n) for (int i=n;i>=s;--i)
#define all(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define print(x) cout<<(x)<<endl
using namespace std;
typedef long long ll;

int gcd(int a,int b)
{if (a%b == 0) return(b);
 else          return(gcd(b,a%b));}
int lcm(int a,int b)
{return a*b/gcd(a,b);}
void printv(vector<auto> v) {cout<<'[';rep(i,0,v.size()){cout<<v[i]<<',';}cout<<']'<<endl;}
void printvv(vector<vector<auto>> vv)
{cout<<'['<<endl;
  rep(q,0,vv.size()){cout<<'[';rep(p,0,vv.at(q).size())cout<<vv.at(q).at(p)<<',';cout <<']'<<endl;}
  cout<<']'<<endl;}
void solve(); int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}
int step_x[] = {-1,0,0,1};
int step_y[] = {0,-1,1,0};
ll INF=1e18;
//------------------------------------------------------------
int N;
ll ans=1;
bool bl=true;

void solve() {
  cin>>N;
  vector<ll> A(N);

  rep(i,0,N)
  {
    ll a; cin>>a;
    if(a==0) bl = false;
    A[i]=a;
  }

  if(!bl) {print(0);return;}

  long double check=1;

  rep(i,0,N)
  {
    ans *=A[i];
    check *=A[i];
    if(check>INF){print(-1);return;}
  }

  print(ans);
  return;
}

Measured memory_bytes: 3980
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;

using namespace std;



int main(){
    ll n,h,a,max_slash=0;
    cin>>n>>h;
    vector<ll>t(n);
    rep(i,n) {
        cin >>a;
        max_slash=max(a,max_slash);
        cin >> t[i];
    }
    sort(t.rbegin(),t.rend());
    rep(i,n){
        if(max_slash<t[i])h-=t[i];
        else{
            h-=max_slash;

        }
        if(h<1){
            cout<<i+1<<endl;
            return 0;
        }
    }
    ll ans=n;
    while(h>0){
        ans++;
        h-=max_slash;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <stdio.h>

#define NUMBER 1000

int main(void){
  int m[NUMBER], f[NUMBER], r[NUMBER];
  int total[NUMBER];
  int i=0, j=0;

  while(1){
    scanf("%d %d %d", &m[i], &f[i], &r[i]);
    if(m[i]==-1 && f[i]==-1 && r[i]==-1)
      break;
    if(m[i]>50 || f[i]>50 || r[i]>100){
      printf("?????°?????????????¶????????????????\n");
      scanf("%d %d %d", &m[i], &f[i], &r[i]);
    }
    total[i]=m[i]+f[i];
    i++;
    j=i;
  }

  for(i=0; i<j; i++){
    if(m[i]==-1 || f[i]==-1){
      printf("F\n");
    }else if(total[i]>=80){
      printf("A\n");
    }else if(total[i]>=65 && total[i]<80){
      printf("B\n");
    }else if(total[i]>=50 && total[i]<65){
      printf("C\n");
    }else if(total[i]>=30 && total[i]<50 && r[i]>=50){
      printf("C\n");
    }else if(total[i]>=30 && total[i]<50){
	printf("D\n");
    }else if(total[i]<30){
      printf("F\n");
    }
  }
  return 0;
}

Measured memory_bytes: 1812
n = int(input())
from collections  import Counter
s= []

for i in range(n):
    s.append((input()))

c = Counter(s)
t = c.most_common()[0][1]
l = []
for i in c.most_common():
    if t == i[1]: 
        l.append(i[0])
l.sort()
for i in l:
    print(i)

Measured memory_bytes: 45052
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>

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

int main() {
	char S[810];

	scanf("%s", S);

	S[3] = '8';
	printf("%s\n", S);

	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <set>
#include <string>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
using namespace std;

typedef long long int64;
typedef unsigned long long uint64;
typedef pair<int, int> ii;
typedef pair<int64, int64> int64int64;
typedef vector<int> vint;
typedef vector<int64> vint64;
typedef vector<uint64> vuint64;
typedef vector<vint> vvint;
typedef vector<vint64> vvint64;
typedef vector<vuint64> vvuint64;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;

#define mp make_pair
#define pb push_back
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define fori(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)

template<typename T>
void prinMatrix(string txt, vector<vector<T>> &a){
	cout << txt;
	fori(a.size()){
		forj(a[i].size())
			cout << a[i][j] << ' ';

		cout << endl;
	}
}

template<typename T>
void printVector(string txt, vector<T> &a){
	cout << txt;
	for (int i = 0; i < a.size(); ++i)
		cout << a[i] << ' ';
	cout << endl;
}


int main(){

	ios_base::sync_with_stdio(0);
	cin.tie();
	
	int n, k;
	vint h;

	cin >> n >> k;
	h.resize(n);
	int ans = 0;
	fori(n){
		cin >> h[i];
		if (h[i] >= k)
			++ans;
	} 

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 640
/******************************************************************************

                            Online C Compiler.
                Code, Compile, Run and Debug C program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include<stdio.h>
#include<string.h>
#include<math.h>
#include<ctype.h>
#include<stdlib.h>

struct dice {
	int f[6];
} ;

void change(struct dice *p, char c)//構造体diceのポインタ変数と、方角を入力
{
	int temp = p->f[0];//真上の面
	if (c == 'N') {
		p->f[0] = p->f[1];//新[0](Topのとこ)に,旧[1](真正面のとこ)入れる
		p->f[1] = p->f[5];
		p->f[5] = p->f[4];
		p->f[4] = temp;
	}
	else if (c == 'E') {
		p->f[0] = p->f[3];
		p->f[3] = p->f[5];
		p->f[5] = p->f[2];
		p->f[2] = temp;
	}
	else if (c == 'S') {
		p->f[0] = p->f[4];
		p->f[4] = p->f[5];
		p->f[5] = p->f[1];
		p->f[1] = temp;
	}
	else if (c == 'W') {
		p->f[0] = p->f[2];
		p->f[2] = p->f[5];
		p->f[5] = p->f[3];
		p->f[3] = temp;
	}
}

int main()
{
	int i;
	struct dice s;//構造体を使って、型diceの 変数sを定義
	char str[100];//転がす方角を入力する部分
	
	for (i=0; i <6; i++)
	    scanf("%d", &s.f[i]);
    scanf("%s",str);
    
	for (i = 0; i<strlen(str); i++) {
	    change(&s,str[i]);//　&s→変数sのアドレス、str[i]は方角
	}
	printf("%d\n",s.f[0]);//f[0]がTopの部分なので、最後の状態を出力
	
	return 0;
}


Measured memory_bytes: 2144
import sys
import math

from collections import defaultdict
from collections import deque
def load(vtype=int):
    return vtype(input().strip())
def load_list(seplator=" ", vtype=int):
    return [vtype(v) for v in input().strip().split(seplator)]
def exit():
    import sys
    sys.exit(0)
def perm_sub(li, used):
    if len(li) == len(used):
        return [deque()]
    k = []
    for i in range(len(li)):
        if i in used:
            continue
        used.add(i)
        sub_list = perm_sub(li, used)
        for sub in sub_list:
            sub.appendleft(li[i])
        k.extend(sub_list)
        used.discard(i)
    return k
def perm_li(li):
    return perm_sub(li, set())
def perm_n(n):
    return perm_sub(list(range(n)), set())
def join_i(li, sep=""):
    return sep.join([str(e) for e in li])
def li2n(li):
    n, base = 0, 1
    for i in range(len(li)-1, -1, -1):
        n += li[i] * base
        base *= 10
    return n
def sli2ili(li):
    return [int(s) for s in li] 
def prime_list(n):
    li = [i for i in range(2, n+1)]
    for i in range(len(li)):
        if li[i] >= int(math.sqrt(n)):
            break
        if li[i] == -1:
            continue
        for j in range(i+1, len(li)):
            if li[j] % li[i] == 0:
                li[j] = -1
    return [n for n in li if n != -1]
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while True:
        r = a % b
        if r == 0: return b
        a, b = b, r
def lcm(a, b):
    return int(a * b / gcd(a,b))
def all_subset(li):
    s = []
    n = len(li)
    for bit in range(0, (1<<(n+1))):
        ss = set()
        for i in range(0, n):
            if (bit & (1 << i)):
                ss.add(li[i])
        s.append(ss)
    return s
def factorial(n):
    if n == 1:
        return 1
    return n * factorial(n-1)
def mCn(m, n):
    def factorial_ntimes(m, n):
        r = 1
        while n:
            r *= m
            m -= 1
            n -= 1
        return r
    return int(factorial_ntimes(m, n) / factorial(n))


n, k = load_list()


print( min(n % k, abs((n%k) - k)) )

Measured memory_bytes: 38408
s = gets.chomp.chars
ans = 'Yes'
s.each_with_index do |x, index|
  if index % 2 == 1 && x == 'R'
    ans = 'No'
    break
  end
  if index % 2 == 0 && x == 'L'
    ans = 'No'
    break
  end
end
puts ans


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

int main() {
  int n, m, k;
  cin >> n >> m >> k;
  vector<int64_t> a(n+1, 0), b(m+1, 0);
  for(int i = 1; i <= n; i++) {
    int c;
    cin >> c;
    a.at(i) = a.at(i-1) + c;
  }
  for(int i = 1; i <= m; i++) {
    int d;
    cin >> d;
    b.at(i) = b.at(i-1) + d;
  }
  
  int jbest = 0;
  bool judge = true;
  while(judge) {
    if(k >= b.at(jbest+1)) {
      jbest++;
    } else {
      judge = false;
    }
    if(jbest == m) {
      judge = false;
    }
  }
  //cout << jbest << endl;
  
  int ans = jbest;
  for(int i = 1; i <= n; i++) {
    if(a.at(i) > k) {
      break;
    }
    int j = jbest;
    while(b.at(j) > k - a.at(i)) {
      j--;
    }
    ans = max(ans, i + j);
    jbest = j;
  }
  
  
  
  /*for(int j = jbest; j >= 0; j--) {
    for(int i = 1; i <= n; i++) {
      if(a.at(i) <= k - b.at(j) && ans < i + j) {
        ans = i + j;
      }
      if(a.at(i) > k - b.at(j)) {
        break;
      }
    }
  }*/
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6400
/*
    Author: Alam Khan
    AUST CSE 40th Batch

*/

#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef deque<ll> dl;
typedef stack<ll> stl;
typedef set<ll> sl;
typedef map<string, ll> msl;
typedef map<ll,ll> mll;
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
#define sf(n)     scanf("%lld",&n)
#define sff(n,m)     scanf("%lld %lld",&n,&m)
#define sfff(n,m,r)     scanf("%lld %lld %lld",&n,&m,&r)
#define sfs(n)     scanf("%s",n)
#define pf(n)     printf("%lld\n",n)
#define pff(n,m)     printf("%lld %lld\n",n,m)
#define pfff(n,m,r)     printf("%lld %lld %lld\n",n,m,r)
#define pfs(n)     printf("%s\n",n)
#define pfcs(i,n)     printf("Case %lld: %lld\n",i,n)
#define pb     push_back
#define prf     printf
#define inf     2e18
#define low     -1000000000000
#define PI        acos(-1.0)
#define rep1(i,n) for(i=1;i<n;i++)
#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,a,n) for(i=a;i<n;i++)
#define repe1(i,n) for(i=1;i<=n;i++)
#define repe0(i,n) for(i=0;i<=n;i++)
#define repe(i,a,n) for(i=a;i<=n;i++)
#define endl  "\n"
#define FAST  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fr freopen("input.txt","r",stdin)
#define fw freopen("output.txt","w",stdout)
ll a[200009],lvl[200009];
int main()
{
    ll i,n,t,k,j,x=0,y=0,m;
    cin>>n>>k;
    unordered_set <ll> s;
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    y = 1;
    i = 1;
    while(x!=k)
    {
        x++;
        lvl[y]  = i++;
        s.insert(y);
        y = a[y];
        if(s.find(y)!=s.end())
            break;

    }
    if(x==k)
    {
        cout<<y<<endl;
        return 0;
    }
    ll dis = i-lvl[y];
    k-= x;
    k = k%dis;
    for(i=1;i<=k;i++)
        y = a[y];
    cout<<y<<endl;
    return 0;
}



Measured memory_bytes: 13412
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;

int main() {
    int n,_y; cin >> n >> _y;
    int y = _y / 1000;

    bool flag = false;

    int a = 0,b = 0,c = 0;

    for (int i = 0; i <= n; ++i) {
        for (int j = 0; j <= n; ++j) {
            if((9 * i + 4 * j == y - n) && (n - i - j >= 0)){
                a = i;
                b = j;
                c = n - i - j;
                flag = true;
            }
        }
    }

    if(flag)cout << a << " " << b << " " << c;
    else cout << -1 << " " << -1 << " " << -1;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }

struct Tmp
{
public:

  int mH, mW;

  vector<vector<char>> table;
  vector<vector<int>> memo;
  int res;

  Tmp(int H, int W);
  void query(int h, int w);
  void reset();
  void rec(int h, int w, int x);
};

Tmp::Tmp(int H, int W)
  : mH(H)
  , mW(W)
  , table(H, vector<char>(W))
  , memo(H, vector<int>(W, -1))
  , res(-1)
{}

void Tmp::query(int h, int w)
{
  rec(h, w, 0);
  int ret{};
  for (auto& r : memo) {
    for (auto& c : r) {
      chmax(ret, c);
    }
  }
  chmax(res, ret);
  // reset();
  memo = vector<vector<int>>(mH, vector<int>(mW, -1));
}

void Tmp::rec(int h, int w, int x)
{
  if (h < 0 || w < 0 || h >= mH || w >= mW) {
    return;
  }
  if (table[h][w] == '#') {
    return;
  }
  if (memo[h][w] == -1) {
    memo[h][w] = x;
  }
  else {
    if (!chmin(memo[h][w], x)) {
      return;
    }
  }
  auto r = memo[h][w];

  rec(h-1, w, r+1);
  rec(h+1, w, r+1);
  rec(h, w-1, r+1);
  rec(h, w+1, r+1);
}

void Tmp::reset()
{
  for (auto& row : memo) {
    std::fill(row.begin(), row.end(), -1);
  }
}


void solve(void)
{
  int H, W; cin >> H >> W;
  Tmp t(H, W);
  for (auto& row : t.table) {
    for (auto& cell : row) {
      cin >> cell;
    }
  }
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      t.query(i, j);
    }
  }
  auto res = t.res;
  auto ans = res;
  cout << ans << CRLF;
  return;
}

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

  solve();

  return 0;
}


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

typedef tuple<string,unsigned short,unsigned short> P;

bool tupleCompar(const P& firstElof, const P& secondElof)
{
  if(get<0>(firstElof) < get<0>(secondElof))
  {
    return true;
  }
  else if(get<0>(firstElof) > get<0>(secondElof))
  {
    return false;
  }
  else if(get<1>(firstElof) > get<1>(secondElof))
  {
    return true;
  }
  else
  {
    return false;
  }
}
      
int main() {
  int N;
  cin >> N;
  
  vector<P> vpss;
  string s;
  unsigned short sh;
  
  for(unsigned short i = 0;i < N;i ++){
    cin >> s >> sh;
    vpss.push_back(make_tuple(s,sh,i + 1));
  }
  sort(vpss.begin(),vpss.end(),tupleCompar);
  for(auto p : vpss){
    cout << get<2>(p) << endl;
  }
  
}

Measured memory_bytes: 256
import numpy as np
import scipy
from scipy.spatial import distance_matrix

N = int(input())

cords = []
for _ in range(N):
  sp = input().split()
  x, y = float(sp[0]), float(sp[1])
  cords.append([x, y])

cords = np.array(cords)
d = distance_matrix(cords, cords)
np.fill_diagonal(d, 0)
print(d.sum()/cords.size*2)


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

#define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* short */
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define ALL(v) begin(v), end(v)

/* REPmacro */
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define RFOR(i, s, n) for (int i = (s); i >= (n); i--)
#define rep(i, n) FOR(i, 0, n)
#define repi(i, n) FOR(i, 1, n + 1)
#define rrep(i, n) RFOR(i, n - 1, 0)
#define rrepi(i, n) RFOR(i, n, 1)

/* debug */
#define pp(v) cerr << #v "=" << (v) << endl;

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using vs = vector<string>;
using Graph = vvi;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* iostream */
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
#define UNIQUE(v) v.erase( unique(ALL(v)), v.end() );
#define TIME system("date +%M:%S.%N")
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }
template<class T> T div_ceil(const T &a, const T &b) { return (a + b - 1) / b; }

signed main() {
  int n;cin>>n;
  vi a(n);cin>>a;
  map<int,int> cnt;
  int ans = 0;
  rep(i,n) {
    int d = a[i];
    if (d <= cnt[d]) ans++;
    else cnt[d]++;
  }
  for (auto v: cnt) {
    if (v.snd < v.fst) ans += v.snd;
  }
  cout << ans << endl;
}


Measured memory_bytes: 7040
#!/usr/bin/env python3
#ABC62 D

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
a = LI()
frontheap,backheap = [],[]
front,back = [],[]
f,b = 0,0
for i in range(n):
    heappush(frontheap,a[i])
    f += a[i]
    heappush(backheap,-a[-i-1])
    b += a[-i-1]
front.append(f)
back.append(b)
for i in range(n):
    x = heappop(frontheap)
    heappush(frontheap,max(x,a[n+i]))
    front.append(front[-1] - x + max(x,a[i+n]))
    y = heappop(backheap)
    heappush(backheap,-min(-y,a[2*n-i-1]))
    back.append(back[-1] + y + min(-y,a[2*n-i-1]))
ans = -inf
for i in range(n+1):
    ans = max(ans,front[i] - back[-i-1])
print(ans)

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

using namespace std;

typedef long long int ll;

const ll MAXN = 1e5 + 5;

vector < vector < ll > > adj(MAXN, vector < ll > ()), bs(MAXN, vector < ll > ());
vector < bool > used(MAXN, false);
set < ll > comp;

void dfs(ll u){
  used[u] = true;
  for(auto to : adj[u]){
    if(!used[to]) dfs(to);
  }
  comp.insert(u);
}

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

  ll n, m, k;
  cin >> n >> m >> k;
  for(int i = 0; i < m; i++){
    ll u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  for(int i = 0; i < k; i++){
    ll u, v;
    cin >> u >> v;
    bs[u].push_back(v);
    bs[v].push_back(u);
  }

  vector < ll > ans(n + 1, 0);
  for(int i = 1; i <= n; i++){
    if(!used[i]){
      comp.clear();
      dfs(i);

      for(auto j : comp){
        ans[j] += comp.size() - 1 - adj[j].size();
        for(auto to : bs[j]){
          if(comp.count(to)){
            ans[to]--;
          }
        }
      }
    }
  }

  for(int i = 1; i <= n; i++) cout << ans[i] << " ";
  cout << endl;
}


Measured memory_bytes: 18420
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <functional>
#include <stack>
#include <fstream>
#include <bitset>

using namespace std;

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

const int N = 3e2 + 7;
const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;

const vector<int> dx = { 0, -1, -1, -1, 0, 1, 1, 1, 0 };
const vector<int> dy = { -1, -1, 0, 1, 1, 1, 0, -1, -1 };

int a[N][N];

int main() {

	int n, m;
	cin >> n >> m;

	if (m == 1) {
		cout << n << endl;
		return 0;
	}

	forn(i, n)
		forn(j, m)
			cin >> a[i][j], a[i][j]--;

	set<int> s;
	forn(i, m)
		s.insert(i);

	vector<int> pos(n, 0);
	vector<int> cnt(m, 0);
	forn(i, n)
		cnt[a[i][pos[i]]]++;

	int ans = INF;
	while(s.size() > 1) {
		int maxVal = -1, id = -1;
		forn(i, m)
			if (cnt[i] > maxVal)
				maxVal = cnt[i], id = i;

		ans = min(ans, maxVal);

		s.erase(id);

		//cout << id + 1 << endl;
		forn(i, n)
			while (s.find(a[i][pos[i]]) == s.end())	
				cnt[a[i][pos[i]]]--, pos[i]++, cnt[a[i][pos[i]]]++;
	}

	cout << ans << endl;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<bits/stdc++.h>
#include<limits.h>
#include<iostream>
#include <cstring>

#define ll long long

using namespace std;

int main(){
    int a,b;
    cin>>a>>b;
    if(a==b) cout<<0<<"\n";
    else if((a-b)%2==0){
      if((a-b)>0) cout<<b+(int)((a-b)/2)<<"\n";
      else{
        cout<<a+(int)((b-a)/2)<<"\n";
      }
    }
    else cout<<"IMPOSSIBLE"<<"\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define endl "\n"
#define debug(x) cout << #x << " = " << (x) << endl;
const ll MOD = 1000000007;

template<class T>
ostream& operator<<(ostream& os, vector<T> v) {
    cout << "[";
    for(auto &i: v) cout << i << ", ";
    cout << "]" << endl;
    return os;
}
template <typename K, typename V>
ostream& operator<<(ostream& os, pair<K, V> p) {
    os << "{" << p.first << ", " << p.second << "} ";
    return os;
}

int main() {
    ios::sync_with_stdio(false); 
    cin.tie(0); cout.tie(0); 
    
    int n; cin >> n;
    ll ans = 0;
    for(int i = 1; i <= n; ++i) {
        if (i % 3 and i % 5) ans += i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3688
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#if __cplusplus >= 201103L
#include <chrono>
using namespace std::chrono;
#endif
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pb push_back
#define fi first
#define se second
#ifdef LOCAL
#define prln(x) (cout << #x << ' ' << x << endl)
#define pr(x) (cout << #x << ' ' << x << ' ' )
#define prv(x) (cout << x << ' ')
#else
#define prln(x) 
#define pr(x)
#define prv(x)
#endif
#define clr(x) memset((x), 0, sizeof((x)))
#define clr1(x) memset((x), -1, sizeof((x)))
#define endl "\n"
#define pi acos(-1)
#define rep(i, st, ed) for (int i = (st); i <= (ed); ++i)
#define rep0(i, st, ed) for (int i = (st); i < (ed); ++i)
#define per0(i, st, ed) for (int i = (st); i > ed; --i)
#define per(i, st, ed) for (int i = (st); i >= ed; --i)
#define chmin(a, b) (a = a > b ? b : a)
#define chmax(a, b) (a = a < b ? b : a)
template<class T> void _sf(T &x) {cin >> x;}
void _sf(int &x) {scanf("%d", &x);}
void _sf(ll &x) {scanf("%lld", &x);}
void _sf(double &x) {scanf("%lf", &x);}
void _sf(char &x) {scanf(" %c", &x);}
void _sf(char *x) {scanf("%s", x);}
void sf() {}
template <class T, class...U> void sf(T & head, U&... tail) { _sf(head); sf(tail...);}
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;

int read() {
    int x = 0, f = 1;
    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 x * f;
}

int mp[25][25];
int dp[1 << 22];
int main(){
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
        #if __cplusplus >= 201103L
        auto start = steady_clock::now();
        #endif
    #endif
    int n = read();
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            cin >> mp[i][j];
        }
    }
    dp[0] = 1;
    for (int i = 1; i < (1 << n); ++i) {
        int now = __builtin_popcount(i) - 1;
        for (int j = 0; j < n; ++j) {
            if (i & ( 1 << j) && mp[now][j]) {
                dp[i] = (dp[i] + dp[i ^ (1 << j)]) % mod;
            }
        }
    }
    cout << dp[(1 << n) - 1] << endl;
    #ifdef LOCAL
        #if __cplusplus >= 201103L
        auto end = steady_clock::now();
        duration<double> time_span = duration_cast<duration<double>>(end - start);;
        printf("Total time: %.6fs\n", time_span.count());
        #endif
    #endif
    return 0;
}

Measured memory_bytes: 10624
r,c = map(int,input().split())
ss = [[int(i) for i in input().split()]for j in range(r)]
sum_ss = [0 for i in range(c + 1)]
for row in ss:
    row.append(sum(row))
    sum_ss = [x+y for (x, y) in zip(sum_ss, row)]
    print(' '.join(map(str, row)))
print(' '.join(map(str, sum_ss)))

Measured memory_bytes: 7732
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#include <iomanip>
#include <sstream>
#include <numeric>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
#define sym cout<<"---------"<<endl;
#define ll long long
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl
#define WHITE 0
#define BLACK 2
#define GRAY 1
#define RE return 0
#define int ll

int ans[105];

signed main(){
  int n;
  cin>>n;
  int nn=n;
  if(n%4==0||n%7==0){
    cout<<"Yes"<<en;
    RE;
  }
  while(nn>0){
    nn-=4;
    if(nn%7==0){
      cout<<"Yes"<<en;
      RE;
    }
  }
  while(nn>0){
    nn-=7;
    if(nn%4==0){
      cout<<"Yes"<<en;
      RE;
    }
  }
  cout<<"No"<<en;
}



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


int main(){
    int n;
    cin >> n;
    vector<pair<int, int>> pairs(n);
    rep(i, n){
        cin >> pairs[i].first;
        pairs[i].second = i + 1;
    }
    sort(pairs.begin(), pairs.end());

    rep(i, n) 
        printf("%d ", pairs[i].second); 
    printf("\n");
    return 0;
}

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

int main(){
	int a,b,c;scanf("%d/%d/%d",&a,&b,&c);
	if(a>2019) cout<<"TBD"<<endl;
	else {
        if(b>4) cout<<"TBD"<<endl;
        else {
            if(c>30) cout<<"TBD"<<endl;
            else cout<<"Heisei"<<endl;
        }
	}
	return 0;
}





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

#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

class Dice
{
private:
	int tmp;
public:
	int lab[6];
	void rE(){
		tmp = lab[0];
		lab[0] = lab[3];
		lab[3] = lab[5];
		lab[5] = lab[2];
		lab[2] = tmp;
	}
	void rN(){
		tmp = lab[0];
		lab[0] = lab[1];
		lab[1] = lab[5];
		lab[5] = lab[4];
		lab[4] = tmp;
	}
	void rS() {
		tmp = lab[0];
		lab[0] = lab[4];
		lab[4] = lab[5];
		lab[5] = lab[1];
		lab[1] = tmp;
	}
	void rW() {
		tmp = lab[0];
		lab[0] = lab[2];
		lab[2] = lab[5];
		lab[5] = lab[3];
		lab[3] = tmp;
	}
	void rR() {
		tmp = lab[1];
		lab[1] = lab[2];
		lab[2] = lab[4];
		lab[4] = lab[3];
		lab[3] = tmp;
	}
	int get3(int top, int front) {
		int i;
		rep(i,3) {
			rN();
			if (top == lab[0]) break;
			rW();
			if (top == lab[0]) break;
		}
		rep(i,3) {
			if (front == lab[1]) break;
			rR();
		}
		return lab[2];
	}
	bool check(Dice &D) {
		int i;
		rep(i,6) if (lab[i] != D.lab[i]) return false;
		return true;
	}
	bool equal(Dice &D) {
		int i;
		rep(i,3) {
			rN();
			if (lab[0] == D.lab[0]) break;
			rW();
			if (lab[0] == D.lab[0]) break;
		}
		rep(i,4) {
			if (check(D)) return true;
			rR();
		}
		return false;
	}
};


int main() {
	Dice dice1, dice2;
	int i;
	rep(i,6) cin >> dice1.lab[i];
	rep(i,6) cin >> dice2.lab[i];

	//process
	cout << (dice1.equal(dice2) ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define substr(s,f,t) (s.substr(f-1,t-f+1))
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
struct Grid{int x,y,t;};
struct Edge{int to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  const ll Inf = llINF;const int MAX_V=1010;vector<ll>d;
  Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;}
  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}
  void add_edge(int from,int to,int cost){E[from-1].pb({to-1,cost});}
};
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int h,w;cin>>h>>w;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      string s;cin>>s;
      if(s=="snuke"){
	cout<<(char)('A'+j)<<i+1<<endl;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

const double pi = acos(-1.0);

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int sx, sy, gx, gy; cin >> sx >> sy >> gx >> gy, gx -= sx, gy -= sy;
  int n; cin >> n;
  V<> x, y;
  for (int i = 0; i < n; i++) {
    int a, b; cin >> a >> b, a-= sx, b -= sy;
    if (gx < 0) a *= -1;
    if (gy < 0) b *= -1;
    if (a < 0 or a > abs(gx) or b < 0 or b > abs(gy)) continue;
    x.push_back(a);
    y.push_back(b);
  }
  n = x.size();
  sx = sy = 0;
  int dx = gx = abs(gx), dy = gy = abs(gy);
  V<> t = x; t.push_back(sx); t.push_back(gx);
  sort(t.begin(), t.end());
  t.erase(unique(t.begin(), t.end()), t.end());
  sx = lower_bound(t.begin(), t.end(), sx) - t.begin(), gx = lower_bound(t.begin(), t.end(), gx) - t.begin();
  for (auto&& i : x) i = lower_bound(t.begin(), t.end(), i) - t.begin();
  t = y; t.push_back(sy); t.push_back(gy);
  sort(t.begin(), t.end());
  t.erase(unique(t.begin(), t.end()), t.end());
  sy = lower_bound(t.begin(), t.end(), sy) - t.begin(), gy = lower_bound(t.begin(), t.end(), gy) - t.begin();
  for (auto&& i : y) i = lower_bound(t.begin(), t.end(), i) - t.begin();

  V<> a(gx + 1); a[0] = gy + 1, a[gx] = -1;
  for (int i = 0; i < n; i++) a[x[i]] = y[i];
  V<> dp(n + 1, 1e9);
  dp[0] = -1e9;
  for (int i = 0; i < gx + 1; i++) *lower_bound(dp.begin(), dp.end(), a[i]) = a[i];
  int m = lower_bound(dp.begin(), dp.end(), 1e9) - dp.begin() - 1;

  double res = 100.0 * (dx + dy);
  if (min(dx, dy) + 1 == m) {
    res += 10 * pi - 20;
    res += (m - 1) * (5 * pi - 20);
  } else {
    res += m * (5 * pi - 20);
  }
  cout << fixed << setprecision(15) << res << '\n';
}

Measured memory_bytes: 4188
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf pop_front()
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define inf 1000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define vll vector<lli>
#define stp setprecision(15)
#define eps 0.000001
#define endl '\n'
#define ll lli
 
using namespace std ;
 
#define N 10000000 
#define lg 19
 
typedef tree<lli,null_type,less<lli>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

int main() 
{ 
 
/////////////////////////////////////
    
    fastio;
 
/////////////////////////////////////    
    
    lli n;
    string s;
    cin>>n>>s;

    lli dp[n][n];

    memset(dp,0,sizeof(dp));

    lli ans=0;
    loopl(i,0,n-1)
    {
        if(s[i] == s[n-1]) 
            {
                dp[i][n-1] = 1;
                ans = max(ans , dp[i][n-1]);
            }
    }    

    for(lli j=n-2;j>=0;j--)
    {
        loopl(i,0,j)
        {
            if(s[i] == s[j])
                dp[i][j] = min(j-i,1+dp[i+1][j+1]);
            
            ans = max(ans , dp[i][j]);
        }
    }
    cout<<ans;


}   

Measured memory_bytes: 195584
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string a,b="CODEFESTIVAL2016";
    int ans=0;
    cin>>a;
    for(int i=0;i<b.size();i++)
    {
        if(a[i]!=b[i])
        {
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256