akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define ph push
#define f first
#define s second
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ll(x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return (rng() % (y+1-x)) + x; } //inclusivesss
string inline to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?llabs(b):gcd(b%a,a); }

typedef long long ll; 
typedef long double ld;
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
typedef pair<ll,ll>pi; typedef pair<ll,pi>spi; typedef pair<pi,pi>dpi;

#define LLINF ((long long) 1e18)//1234567890987654321
#define INF 1234567890ll
// #define cerr if(0)cout
#define MAXN (106)
ll n,m,grid[MAXN][MAXN],A[MAXN][MAXN],B[MAXN][MAXN];
vector<pi> v[MAXN];
int match[MAXN];//match[i]=index of edge from i
ll paired[MAXN];
bitset<MAXN>vis;
void bp() {
	mmst(match,-1);mmst(paired,-1);
	FOR(i,0,n-1)shuffle(all(v[i]),rng);
	FOR(i,0,n-1){
		FOR(j,0,siz(v[i])-1)if(paired[v[i][j].f]==-1){
			paired[v[i][j].f]=i;
			match[i]=j;
			break;
		}
	}
	function<ll(ll)>dfs=[&](ll x){
		if(vis[x])return 0;
		vis[x]=1;
		ll co=0;
		for(auto i:v[x]){
			if(paired[i.f]==-1 || dfs(paired[i.f])){
				paired[i.f]=x;
				match[x]=co;
				return 1;
			}
			++ co;
		}
		return 0;
	};
	FOR(i,0,n-1)if(match[i]==-1)vis.reset(),dfs(i);
}
int main(){
	FAST
	cin>>n>>m;
	auto which_row=[&](ll x){
		return x/m;
	};
	FOR(i,0,n-1)FOR(j,0,m-1)cin>>grid[i][j],--grid[i][j];
	FOR(i,0,n-1)FOR(j,0,m-1){ll k=which_row(grid[i][j]);v[i].eb(k,grid[i][j]);}
	FOR(j,0,m-1){
		bp();
		FOR(i,0,n-1){
			assert(match[i]!=-1&&siz(v[i])>match[i]);
			A[i][j]=v[i][match[i]].s;
			v[i].erase(v[i].begin()+match[i]);
		}
	}
	FOR(i,0,n-1)assert(v[i].empty());
	FOR(i,0,n-1)FOR(j,0,m-1)cout<<A[i][j]+1<<" \n"[j==m-1];
	FOR(j,0,m-1){
		set<int>s;
		FOR(i,0,n-1)s.ins(which_row(A[i][j]));
		assert(s.size()==n);
	}
	FOR(j,0,m-1){
		FOR(i,0,n-1){
			B[which_row(A[i][j])][j]=A[i][j];
		}
	}
	FOR(i,0,n-1)FOR(j,0,m-1)cout<<B[i][j]+1<<" \n"[j==m-1];
}


Measured memory_bytes: 816
import sys

N,M=map(int, raw_input().split())
dp=[ float("inf") for _ in range(2**N)]
dp[0]=0


for _ in range(M):
	a,b=map(int, raw_input().split())
	C=map(int, sys.stdin.readline().split())

	n=0
	for c in C:
		n+=2**(N-c)

	for k in range(2**N-1):
		dp[n|k]=min(dp[n|k],dp[k]+a)

if dp[2**N-1]==float("inf"):
	print -1
else:
	print dp[2**N-1]

Measured memory_bytes: 33640
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

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

  string ans = "No";
  if (S[2] == S[3] && S[4] == S[5]) {
    ans = "Yes";
  }

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


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

a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(a[K - 1])

Measured memory_bytes: 3060
#include<iostream>

using namespace std;

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

  char S[N];
  cin >> S;
  
  int count = 0;

  for(int i=0; i<N; i++){
    if(S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C') count++; 
  }

  cout << count << endl;

  return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

template<typename T> vector<T> make_vector(size_t sz){
	return vector<T>(sz);
}

template<typename T,typename... Ts> 
auto make_vector(size_t sz, Ts... ts){
	return vector<decltype(make_vector<T>(ts...))>(sz, make_vector<T>(ts...));
}

template<typename T,typename U,typename... V> 
typename enable_if<is_same<T, U>::value!=0>::type 
fill_value(U &u, const V... v){
	u=U(v...);
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_value(U &u, const V... v){
	for(auto &e:u){
		fill_value<T>(e,v...);
	}
}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

const pid_t pid = getpid();
// Problem Specific Parameter:

int main(void){
	string s;
	cin >> s;
	const int n = s.size() + 1;
	vector<int> a(n, 0);

	rep(i, n - 1){
		if(s[i] == '<') {
			chmax(a[i + 1], a[i] + 1);
		}
	}

	rrep(i, n - 1){
		if(s[i] == '>') {
			chmax(a[i], a[i + 1] + 1);
		}
	}

	ll ans = 0LL;
	rep(i, n) ans += a[i];
	cout << ans << endl;

	return 0;
}

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

using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define ll long long
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define INF INT_MAX
#define cases(t) ll t; cin>>t; while(t--)
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int lcm(int a, int b) { return a * (b / gcd(a, b)); }

#define pb push_back
#define mp make_pair
#define ii pair<int,int>
#define msi map<string,int>

int main(){
	IOS
	int x,kyu;
	cin>>x;
	if(x>=1800)
		kyu = 1;
	else if(x>=1600)
		kyu = 2;
	else if(x>=1400)
		kyu = 3;
	else if(x>=1200)
		kyu = 4;
	else if(x>=1000)
		kyu = 5;
	else if(x>=800)
		kyu = 6;
	else if(x>=600)
		kyu = 7;
	else if(x>=400)
		kyu = 8;
	cout<<kyu;
return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

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

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

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

    vector<int> ans(n, -1);

    rep(i, m){
        int s, c;
        cin >> s >> c;
        if(ans[s-1]==-1){
            ans[s-1] = c;
        }else{
            if(ans[s-1]!=c){
                cout << -1 << endl;
                return 0;
            }
        }
    }

    if(ans[0]==0&&n!=1){
        cout << -1 << endl;
        return 0;
    }

    if(ans[0]!=-1){
        cout << ans[0];
    }else{
        cout << 1;
    }

    rep2(i, 1, n){
        if(ans[i]!=-1){
            cout << ans[i];
        }else{
            cout << 0;
        }
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
/*
ID: rchalam1
LANG: C++14
TASK:
*/
// For train.usaco.org, fill the template above.

// Competitive Coding Template

// GCC OPTIMIAZTION FLAGS
#ifdef ONLINE_JUDGE
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#endif

#include <bits/stdc++.h>

/*
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
*/
// All Includes for Competitive Coding Template

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

using vi = std::vector<int>;
using vll = std::vector<long long>;
using vull = std::vector<unsigned long long>;

#define FOR(i, a, b) for (auto i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (auto i = (a); i >= (b); --i)
#define R0F(i, a) ROF(i, a, 0)
#define ITR(a, x) for (auto& a: x)

#define FSRT(set) sort((set).begin(),(set).end())
#define RSRT(set) sort((set).rbegin(),(set).rend())
#define CSRT(set, function) sort((set).begin(),(set).end(), (function))
#define TRS(set) sort((set).begin(),(set).end(), greater<>())
#define REV(set) reverse((set).begin(),(set).end());

#define ALL(set) (set).begin(), (set).end()

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second

// For stdio, call setIO() or setIO("").
void setIO(std::ifstream &readFile, std::ofstream &writeFile, const std::string &name = "", bool stdIO = false)
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(nullptr);
	std::cout.tie(nullptr);
	if(!name.empty() && !stdIO)
	{
		readFile.open(name + ".in");
		if(readFile.fail()) return;
		writeFile.open(name + ".out");
		std::cin.rdbuf(readFile.rdbuf());
		std::cout.rdbuf(writeFile.rdbuf());
	}
}

// To time program, create object Timer  to start timing, and call Timer.elapsed().
#include <chrono>

class Timer
{
	std::chrono::time_point<std::chrono::high_resolution_clock> m_beg;
public:
	Timer() : m_beg(std::chrono::high_resolution_clock::now())
	{}

	void reset()
	{ m_beg = std::chrono::high_resolution_clock::now(); }

	[[nodiscard]] long double elapsed() const
	{
		return std::chrono::duration_cast<std::chrono::duration<long double, std::ratio<1> >>(
				std::chrono::high_resolution_clock::now() - m_beg).count();
	}
};

// Defines datatype
using dt = int;
// Defines MAXN value
constexpr dt MAXN = 1e5 + 1;
// Defines Modulus
constexpr dt MOD = 1e9 + 7;
// Defines Floating Point Correction
constexpr long double EPS = 1e-9;

//*****
//START CODE BELOW
//*****

int main(int argc, char *argv[])
{
	static std::ifstream readFile;
	static std::ofstream writeFile;
	setIO(readFile, writeFile);
	int n, d;
	cin >> n >> d;
	vector<vector<int>> points(n, vector<int>((d)));
	for(auto &point : points) for(auto &node : point) cin >> node;
	int answer = 0;
	for(int i = 0; i < n; ++i)
		for(int j = i + 1; j < n; ++j)
		{
			int result = 0;
			for(int k = 0; k < d; ++k) result += static_cast<int>(pow(points[i][k] - points[j][k], 2));
			answer += (floor(sqrt(result)) == ceil(sqrt(result)));
		}
	cout << answer << '\n';
}

Measured memory_bytes: 3656
/**************************
*                         *
*  Nothing Is Impossible  *
*                         *
**************************/
#include <algorithm>
#include <iostream>
#include <fstream>
#include <ctype.h>
#include <string>
#include <vector>
#include <math.h>
#include <stack>
#include <cmath>
#include <map>
#define GetRand(Min, Max) ((rand()%(int)(((Max) + 1)-(Min))) + (Min))
#define Rep(i, min, max) for (int i = min; i < max; ++i)
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef long double ld;
using namespace std;

int main()
{
   ios::sync_with_stdio(NULL);
   cin.tie(NULL); cout.tie(NULL);
   int a,b;    cin >> a >> b;
   string ans = "";
   Rep(i,0,max(a,b)){
      ans += to_string(min(a,b));
   }
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

ll func(vvl &DP, string &S, ll i, ll up, ll N) {
  if (i == N)
    return up;
  if (DP[i][up] != llINF)
    return DP[i][up];
  ll kouho1 = func(DP, S, i + 1, 0, N) + up + S[N - i - 1] - '0';
  ll kouho2 = func(DP, S, i + 1, 1, N) + 10 - (up + S[N - i - 1] - '0');
  DP[i][up] = min(kouho1, kouho2);
  return DP[i][up];
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string S;
  cin >> S;
  ll N = S.size();
  ll up = 0;
  ll ans = 0;
  vvl DP = VVL(N, 2, llINF);
  cout << func(DP, S, 0, 0, N) << endl;

  return 0;
}


Measured memory_bytes: 151708
#include <stdio.h>

/* 数字をn個残してそれが1からn迄昇順に並んでいればOK */

int main()
{
	int n;		/* ユーザー入力の配列の要素数 */
	int a[200000];	/* 最大200000の数値が入る配列 */
	int index;	/* 配列aのインデックス */

	scanf("%d", &n);
	for(index = 0; index < n; ++index)
		scanf("%d", &a[index]);

	/* 1を探索しその右に2,3...があるかを探す */
	
	int number;	/* 現在探索中の数値 */
	int counter;	/* 発見できた要素の数 */
	number = 1;
	counter = 0;
	index = 0;
	
	while(1){
      	if(index == n)
          break;
		if(a[index] == number){
			++counter;
			++number;
		}
      	++index;
	}

	int brick;	/* 砕くべきレンガの数 */
	brick = n - counter;

	if(number == 1)
		printf("-1\n");
	else
		printf("%d\n", brick);

	return 0;
}

Measured memory_bytes: 896
from itertools import product

#入力
N,M=map(int,input().split())
ks=[list(map(int,input().split())) for _ in range(M)]
p=[int(x) for x in input().split()]
#print(ks)

ans=0
for i in product([0,1],repeat=N):
    ok=True
    for j in range(M):
        j_on_cnt=0
        for k in ks[j][1:]:
            j_on_cnt+=i[k-1]
            
        if j_on_cnt%2 != p[j]:
            ok=False
            break
    if ok:
        ans+=1
print(ans)

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll N;
    cin >> N;

    vector<ll> A(N);
    vector<ll> B(N);

    ll start = 0;
    bool first = true;
    REP(i, N){
        cin >> A[i];
        if(first){
            if(A[i] != 0){
                // cout << i << " " << A[i] << endl;
                start = i;
                first = false;
            }
        }
        if(i==0){
            B[i] = A[i];
        }
        else{
            B[i] = A[i] + B[i-1];
        }
    }

    // REP(i, N){
    //     cout << B[i] << endl;
    // }
    ll ans1 = 0;
    ll total1 = 0;

    total1 = -1;

    if(start == 0){
        total1 = 0;
    }

    for(ll i=start; i<N; i++){
        if((i-start)%2==0){
            if(B[i] + total1 <= 0){
                ans1 += abs(B[i]+total1) + 1;
                total1 += abs(B[i]+total1) + 1;
            }
        }
        else{
            if(B[i] + total1 >= 0){
                ans1 += abs(B[i]+total1) + 1;
                total1 -= (abs(B[i]+total1) + 1);
            }
        }
        // cout << "total:" << total << endl;
        // cout << "ans:" << ans << endl;  
    }

    ll total2 = 1;
    ll ans2 = 0;

    if(start == 0){
        total2 = 0;
    }

    for(ll i=start; i<N; i++){
        if((i-start)%2==0){
            if(B[i] + total2 >= 0){
                ans2 += abs(B[i]+total2) + 1;
                total2 -= (abs(B[i]+total2) + 1);
            }
        }
        else{
            if(B[i] + total2 <= 0){
                ans2 += abs(B[i]+total2) + 1;
                total2 += (abs(B[i]+total2) + 1);
            }
        }
    }

    
    // cout << ans << endl;
    // cout << start << endl;
    ll ans = min(ans1, ans2);

    if(start != 0){
        ans += 2*start-1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
h,w =list(map(int,input().split()))
mod=10**9+7
a = [[i for i in input()] for j in range(h)]
dp=[[0]*w for i in range(h)]
dp[0][0]=1
for i in range(h):
	for j in range(w):
		if i==0 and j==0: pass
		elif a[i][j]!="#":
			if i==0 : dp[i][j]=dp[i][j-1]
			elif j==0: dp[i][j]=dp[i-1][j]
			else:dp[i][j]=dp[i-1][j]+dp[i][j-1]
		else: dp[i][j]=0
		dp[i][j]=dp[i][j]%mod
print(dp[h-1][w-1])
		


Measured memory_bytes: 90716
//Xcode main は一つまで
//競プロのデバッグにでも使おう
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int N,K;


int main() {
    //cout<<1<<endl;
    cin>>N>>K;
    int ans=1100000000;
    vector <int> h(N,0);
    for(int inp=0;inp<N;inp++) cin>>h[inp];
    sort(h.begin(),h.end());
  //  cout<<h[0]<<endl;
    for(int i=0;i<=N-K;i++){
        ans=min(ans,h[i+K-1]-h[i]);
        
    }
    
    cout<<ans<<endl;
    
    
    return 0;
}


Measured memory_bytes: 640
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using ll = long long;
using P = pair<ll,ll>;

int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
ll ans = 0;
ll n;
cin >> n;
for(ll i = 1; i <= n; i++){
    ll k = floor(n / i);
    ans += k * (k + 1) * i / 2;
}
cout << ans << endl;
}

Measured memory_bytes: 3660
#![allow(unused_imports)]
use std::io;
use std::cmp::*;
use std::collections::*;
#[allow(dead_code)]
const M: i64 = 1e9 as i64 + 7;

fn read_line() -> String {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).unwrap();
    buf
}
#[allow(dead_code)]
fn read<T>() -> T where T: std::str::FromStr, T::Err : std::fmt::Debug {
    read_line().trim().parse().unwrap()
}
#[allow(dead_code)]
fn readv<T>() -> Vec<T> where T: std::str::FromStr, T::Err : std::fmt::Debug {
    read_line().split(' ').map(|a| a.trim().parse().unwrap()).collect()
}

fn main() {
    let _: i32 = read();
    let s: String = read();
    let mut cnt = 0;
    let mut pre = 0;
    for c in s.as_bytes() {
        let c = *c as char;
        if c == '(' {
            cnt += 1;
        } else {
            if cnt == 0 {
                pre += 1;
            } else {
                cnt -= 1;
            }
        }
    }
    // println!("{}{}{}",
    //          String::from_utf8(vec!['(' as u8;pre]).unwrap(),
    //          s,
    //          String::from_utf8(vec![')' as u8;cnt as usize]).unwrap());
    let mut ans = String::new();
    for _ in 0..pre {
        ans.push('(');
    }
    ans += &s;
    for _ in 0..cnt {
        ans.push(')');
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
def solve(h, w, A, B):
    center = (h+w)*80
    C = [[abs(A[r][c]-B[r][c]) for c in range(w)] for r in range(h)]
    dp = [[0]*w for r in range(h)]
    dp[0][0] = (1 << (center + C[0][0])) | (1 << (center - C[0][0]))
    for r in range(h):
        for c in range(w):
            if r > 0:
                dp[r][c] |= (dp[r-1][c] << C[r][c]) | (dp[r-1][c] >> C[r][c])
            if c > 0:
                dp[r][c] |= (dp[r][c-1] << C[r][c]) | (dp[r][c-1] >> C[r][c])
    mask = bin(dp[-1][-1] >> center)
    return mask[::-1].find("1")

h, w = map(int, input().split())
A = [list(map(int, input().split())) for i in range(h)]
B = [list(map(int, input().split())) for i in range(h)]
print(solve(h, w, A, B))

Measured memory_bytes: 20340
#include <functional>
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

const ll MOD = 998244353;
const ll INF = 10000000000000;

ll modpow(ll x, ll n){
    ll res = 1, r = x;
    while(n){
        if(n % 2) res = res * r % MOD;
        r = r * r % MOD;
        n /= 2;
    }
    return res;
}

template<typename Monoid>
struct SegmentTree {
    using F = function<Monoid(Monoid, Monoid)>;

    int sz;
    vector<Monoid> seg;

    const F f;
    const Monoid M1;

    SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1) {
        sz = 1;
        while(sz < n) sz <<= 1;
        seg.assign(2 * sz, M1);
    }

    void set(int k, const Monoid &x) {
        seg[k + sz] = x;
    }

    void build() {
        for(int k = sz - 1; k > 0; k--) {
            seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
        }
    }

    void update(int k, const Monoid &x) {
        k += sz;
        seg[k] = x;
        while(k >>= 1) {
            seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
        }
    }

    Monoid query(int a, int b) {
        Monoid L = M1, R = M1;
        for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
            if(a & 1) L = f(L, seg[a++]);
            if(b & 1) R = f(seg[--b], R);
        }
        return f(L, R);
    }

    Monoid operator[](const int &k) const {
        return seg[k + sz];
    }
};

int main()
{
    int n;
    cin >> n;
    P p[200005];
    for(int i = 0; i < n; i++){
        ll x, d;
        cin >> x >> d;
        p[i] = P(x, d);
    }
    sort(p, p + n);
    p[n] = P(INF, INF);
    ll dp[200005];
    int right[200005];
    SegmentTree<int> seg(n + 1, [](int a, int b){return max(a, b);}, 0);
    dp[n] = 1;
    right[n] = n;
    seg.update(n, n);
    for(int i = n - 1; i >= 0; i--){
        int k = lower_bound(p, p + n + 1, P(p[i].first + p[i].second, 0)) - p - 1;
        if(k == i) right[i] = i + 1;
        else right[i] = seg.query(i, k + 1);
        seg.update(i, right[i]);
        dp[i] = (dp[i + 1] + dp[right[i]]) % MOD;
    }
    cout << dp[0] << endl;
}

Measured memory_bytes: 7040
//Volume1-0137
import java.util.*;

public class Main {

	public static void main(String[] args) {
		
		int n,a;
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		for(int i=0;i<n;i++){
			System.out.println("Case "+(i+1)+":");
			a = sc.nextInt();
			for(int j=0;j<10;j++){
				System.out.println(a = Integer.parseInt(
						String.format("%08d",(int)Math.pow(a,2)).substring(2,6)));
			}
		}
	}
}

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

using namespace std;

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

 int count = 0;
  for(int i = 0; i < N; i++){
    if(i + 1 >= 1 && i + 1 <= 9) count++;
    else if(i + 1 >= 100 && i + 1 <= 999) count++;
    else if(i + 1 >= 10000 && i + 1 <= 99999) count++;
   
  }

  cout << count << endl;
 return 0;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;

const int MAX_N=1e6;

vector<P> G[MAX_N];
priority_queue<P,vector<P>,greater<P>> que;
bool used[MAX_N];

    LL prim(){
        memset(used,false,sizeof(used));
        que.push(make_pair(0,0));
        LL ret=0;
        while(!que.empty()){
            P p=que.top();que.pop();
            LL cost=p.first;
            int v=p.second;
            if(used[v]) continue;
            used[v]=true;
            ret+=cost;
            for(int i=0;i<G[v].size();i++){
                que.push(make_pair(G[v][i].first,G[v][i].second));
            }
        }
        return ret;
    }

int main(){
    int N;
    cin >> N;
    vector<P> x,y;
    for(int i=0;i<N;i++){
        LL t,s;
        cin >> t >> s;
        x.push_back(make_pair(t,i));
        y.push_back(make_pair(s,i));
    }
    sort(x.begin(),x.end());
    sort(y.begin(),y.end());
    for(int i=0;i<N-1;i++){
        G[x[i].second].push_back(make_pair(x[i+1].first-x[i].first,x[i+1].second));
        G[x[i+1].second].push_back(make_pair(x[i+1].first-x[i].first,x[i].second));
        G[y[i].second].push_back(make_pair(y[i+1].first-y[i].first,y[i+1].second));
        G[y[i+1].second].push_back(make_pair(y[i+1].first-y[i].first,y[i].second));
    }
    cout << prim() << endl;
    return 0;
}

Measured memory_bytes: 42472
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX = 510000;
const int MOD = 1000000007;

/*long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}*/

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

 vector<pair<ll, ll>> v;
  for(int i = 0; i < N; i++) {
      ll a, b;
      cin >> a >> b;
      a *= -1;
      v.push_back({b, a});
    }


   
   sort(v.begin(), v.end());
    ll time = 0;
   for(auto i : v) {
       time += (i.second) * (-1);
       if(time > (i.first)) { cout << "No"; return 0; }

       //cout << i.first * (-1) << " " << i.second * (-1) << endl;
   }
    cout << "Yes";
    return 0;
}

Measured memory_bytes: 7384
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<cmath>
#define ll long long
#define rep(i,a,n) for(int i=(a);i<(n);i++)
using namespace std;

int main() {
	ll int n, m;
	cin >> n >> m;
	ll ans = pow(2, m) * (m * 1900 + (n - m) * 100);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import random

def is_prime(q,k=50):
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1
    for i in range(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        while t != q-1 and y != 1 and y != q-1: 
            y = pow(y,2,q)
            t <<= 1
        if y != q-1 and t&1 == 0:
            return False
    return True

n,m=(int(i) for i in input().split(' '))
for i in range(1,n):
  if m%i==0 and (is_prime(i) or i==1) and is_prime(m//i) and (i==1 or m//i<n):
    print('1')
    exit()
for i in range(n,m+1):
  if i==m:
    print(1)
    break
  if m%i==0:
    print(m//i)
    break
  if m-i-n>0 and m%(m-i-n)==0 and m//(m-i-n)>n:
    print(m-i-n)
    break


Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
template<class T> inline void dmin(T& x,T y){ y<x?x=y:0; }
template<class T> inline void dmax(T& x,T y){ y>x?x=y:0; }
template<class T> inline void dmin(T& x,vector<T> y){ 
	for(auto t:y) t<x?x=t:0;
}
template<class T> inline void dmax(T& x,vector<T> y){
	for(auto t:y) t>x?x=t:0;
}
int main(){
	int n,k; scanf("%d%d",&n,&k);
	vector<int> a(n);
	for(int i=0;i<a.size();++i)
		scanf("%d",&a[i]);
	while(k--){
		vector<int> b(n);
		for(int i=0;i<n;++i){
			b[max(i-a[i],0)]++;
			if(a[i]+i+1<n) b[i+a[i]+1]--;
		}
		for(int i=1;i<n;++i) b[i]+=b[i-1];
		a=b;
		bool flag=1;
		for(int i=0;i<n;++i)
			if(a[i]!=n) flag=0;
		if(flag) break;
	}
	for(int i=0;i<a.size();++i) printf("%d ",a[i]);
	return 0;
}

Measured memory_bytes: 4928
H, W = map(int, input().split())
grid = []

for _ in range(H):
  x = input()
  if x != "."*W:
    grid.append(x)

h = len(grid)
Flag = [True]*W

for j in range(W):
  if all(grid[i][j] == "." for i in range(h)):
    Flag[j] = False

for i in range(h):
  print("".join([grid[i][j] for j in range(W) if Flag[j]]))

Measured memory_bytes: 9032
// {{{ by unolight
#include <bits/stdc++.h>
#include <unistd.h>
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-function"
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x),end(x)
#define RALL(x) rbegin(x),rend(x)
#define REP(i,n) for ( int i=0; i<int(n); i++ )
#define REP1(i,a,b) for ( int i=(a); i<=int(b); i++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef pair<int,int> PII;
typedef vector<int> VI;

namespace { namespace unolight {
// Read Input
template<class T> void _R( T &x ) { cin>>x; }
void _R( int &x ) { scanf("%d",&x); }
void _R( int64_t &x ) { scanf("%" PRId64,&x); }
void _R( double &x ) { scanf("%lf",&x); }
void _R( char &x ) { scanf(" %c",&x); }
void _R( char *x ) { scanf("%s",x); }
void R() {}
template<class T, class... U> void R( T& head, U&... tail ) { _R(head); R(tail...); }
// Write Output
template<class T> void _W( const T &x ) { cout<<x; }
void _W( const int &x ) { printf("%d",x); }
void _W( const int64_t &x ) { printf("%" PRId64,x); }
void _W( const double &x ) { printf("%.16f\n",x); }
void _W( const char &x ) { putchar(x); }
void _W( const char *x ) { printf("%s",x); }
template<class T> void _W( const vector<T> &x ) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W( const T& head, const U&... tail ) { _W(head); putchar(sizeof...(tail)?' ':'\n'); W(tail...); }

#ifdef UNOLIGHT
#include "dump.hpp"
#else
#define dump(...)
#endif

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}
// }}}


void main() {
    int n=3;
    string s;
    cin >> s;
    int ans=0,res=0;
    for ( int i=0; i<n; i++ ) {
        if ( s[i]=='S' ) {
            res=0;
        } else {
            res++;
        }
        chmax(ans,res);
    }
    W(ans);
}

}} // {{{ main
int main() { unolight::main(); return 0; }
// }}}

Measured memory_bytes: 3716
#include <iostream>

using namespace std;

int main()
{
	int n;
	int a[10] = { 0 };

	for (int i = 0; i < 3; i++) {
		cin >> n;
		a[n - 1]++;
	}

	if (a[4] == 2 && a[6] == 1) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);

            int k;
            k = (a + b) / 2;

            int ans = Math.Abs(a - k) - Math.Abs(b - k);
            if (ans == 0)
            {
                Console.WriteLine(k.ToString());
            }
            else
            {
                Console.WriteLine("IMPOSSIBLE");
            }

        }
    }
}


Measured memory_bytes: 11220
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <set>
#include <numeric>
#include <map>
#include <math.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <bitset>
#include <math.h>

#define INF 100100100

typedef long long int llint;

using namespace std;

typedef pair<llint, llint>Pii;
typedef pair<double, double>Pdd;

#define pi 3.141592653589793)
#define mod 1000000007


int main() {
	string s;
	cin >> s;
	int a = 0, b = 0, c = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'a')a++;
		if (s[i] == 'b')b++;
		if (s[i] == 'c')c++;
	}
	if (a == 1 && b == 1 && c == 1)puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int i,j,k,N,A[100],count=0;
  
  scanf("%d",&N);
  
  for(i = 0; i < N; i++) scanf("%d",&A[i]);
  
  for(i = 0; i < N-1; i ++)
    {
      for(j = N-1; j > i; j--)
	{
	  if(A[j] < A[j-1])
	    {
	      k = A[j];
	      A[j] = A[j-1];
	      A[j-1] = k;
	      count++;
	    }
	}
    }
  for(i = 0; i < N; i ++)
    {
      if(i == N-1)
	{
	  printf("%d",A[i]);
	  break;
	}
      printf("%d ",A[i]);
    }
  printf("\n%d\n",count);
  return 0;
}

Measured memory_bytes: 600
#include<stdio.h>
#include<algorithm>
using namespace std;
#define N 3 
int main()
{
	int a[N];
	for(int i=0;i<N;i++)
		scanf("%d",&a[i]);
	sort(a,a+N);
	int ans;
	ans=(a[0]*a[1])/2;
	printf("%d",ans);
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		while (sc.hasNext()) {
			binary( sc.nextInt() );
		}
	}

	private static void binary(int nextInt) {
		StringBuilder sb = new StringBuilder();
		int n = nextInt;
		String bin_n =  Integer.toBinaryString(n);

				if (bin_n.length() <= 10) {
					for (int i = 0; i < 10 - bin_n.length(); i++) {
						sb.append("0");
					}
				}

		bin_n = sb.append(bin_n).toString();
		sb.delete(0, sb.length());

				for (int i = 0; i < bin_n.length(); i++) {

						if ( bin_n.charAt(9 - i) == '1' ) {
							sb.append( (int)Math.pow(2, i) ).append(" ");
						}

				}

				sb.delete(sb.length() - 1, sb.length());

		String result = sb.toString();
		System.out.println(result);
	}

}


Measured memory_bytes: 26272
#include <stdio.h>
#include <cctype>

int main(void){

	char word[11]="0000000000";
	char t[11]="0000000000";
	char end[]="END_OF_TEXT";
	int i=0;
	int j=0;
	int k;
	int ans=0;
	int count=0;
	int endcount=1;
	
	while(1){
		scanf("%c",&word[i]);
		
		if(word[i]=='\n'){
			break;
		}
		
		if(islower(word[i])){
			word[i]=toupper(word[i]);
		}
		
		i++;
	}
	
	while(1){
		while(1){
			scanf("%c",&t[j]);
			
			if(t[j]=='\n'||t[j]==' '){
				break;
			}

			j++;
		}
		
		for(k=0;k<11;k++){
			if(t[k]!=end[k]){
				endcount=0;
			}
		}
		
		if(endcount==1){
			break;
		}
		
		endcount=1;
		
		for(k=0;k<j;k++){
			if(islower(t[k])){
				t[k]=toupper(t[k]);
			}
			
			if(t[k]==word[k]){
				ans++;
			}else{
				ans=0;
			}
		}
		
		if(ans==i&&(t[j]=='\n'||t[j]==' ')){
			count++;
		}
		
		ans=0;
		
		j=0;
	}
	
	printf("%d\n",count);
	
	return 0;
}

Measured memory_bytes: 2736
#include <stdio.h>

int main(){
    int k, s, valores = 0;
    scanf("%d %d", &k, &s);
    for (int x = 0; x <= k; x++){
        for (int y = 0; y <= k; ++y){
            int z = s - x - y;
            if (0 <= z && z <= k)
                valores += 1;
        }
    }
    printf("%d\n", valores);
    return 0;
}

Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanRunes() []rune { return []rune(scanString()) }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	h := scanInt()
	w := scanInt()
	k := scanInt()

	ss := make([]string, h)
	for i := 0; i < h; i++ {
		ss[i] = scanString()
	}

	memo := make([]int, h)
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			if ss[i][j] == '1' {
				memo[i]++
			}
		}
	}

	ans := 1<<31-1
	bitExhaustiveSearch(h-1, func(a []bool) {
		cnt := make([]int, h)
		cut := 0
		for i := 0; i < h-1; i++ {
			if a[i] {
				cut++
			}
		}

		for i := 0; i < w; i++ {
			c := 0
			for j := 0; j < h; j++ {
				if ss[j][i] == '1' {
					cnt[c]++
				}

				if j < h-1 && a[j] {
					c++
				}
			}

			for j := 0; j < h; j++ {
				if cnt[j] > k {
					cut++
					cnt = make([]int, h)
					c := 0
					for k := 0; k < h; k++ {
						if ss[k][i] == '1' {
							cnt[c]++
						}

						if k<h-1 && a[k] {
							c++
						}
					}

					for l := 0; l < h; l++ {
						if cnt[l] > k {
							return
						}
					}
				}
			}
		}

		ans = min(ans, cut)
		// debug(cut)
	})

	fmt.Fprintln(wr, ans)
}

func bitExhaustiveSearch(n int, fn func(a []bool)) {
	all := 1 << uint(n)
	a := make([]bool, n)
	for i := 0; i < all; i++ {
		for j := 0; j < n; j++ {
			if i >> uint(j) & 1 == 1 { a[j] = true } else { a[j] = false }
		}
		fn(a)
	}
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; ++i)
using ll = long long;
const ll MOD = 1000000007;//998244353;
int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   int h, w, k; cin >> h >> w >> k;
   vector<vector<bool>> v(h);
   rep(i,h){
      string s; cin >> s;
      rep(j,w){
         v[i].push_back(s[j]=='#');
      }
   }
   int x=0, y=0;
   int ans = 0;
   while(x < (1<<h)){
      y=0;
      while(y < (1<<w)){
         int z = 0;
         rep(i,h){
            rep(j,w){
               if (1&(x>>i)||1&(y>>j)||(!v[i][j]))continue;
               z++;
            }
         }
         ans += (z==k);
         y++;
      }
      x++;
   }
   cout << ans << endl;
}

Measured memory_bytes: 3604
n,m=map(int,input().split())
a=[True for i in range(n)]
for i in range(m):
    a[int(input())-1]=False

num=[0 for i in range(n+2)]
num[0]=0
num[1]=1
mod=10**9+7
for i in range(n):
    if a[i]:
        num[i+2]=(num[i+1]+num[i])%mod

print(num[n+1])

Measured memory_bytes: 7816
from collections import defaultdict

n, a = map(int, input().split())
arr = [x-a for x in list(map(int, input().split()))]

dct = defaultdict(int)
dct[0] = 1

for x in arr:
    for k, v in list(dct.items()):
        dct[k+x] += v

print(dct[0]-1)

Measured memory_bytes: 3564
import scala.io.StdIn

object Main extends App {
  val Array(h,w) = StdIn.readLine.split(" ").map(_.toInt)

  val sqr = Iterator.continually(StdIn.readLine)
    .takeWhile(_ != null)
    .filter(_.contains('#'))
    .map(_.toCharArray)
    .toArray
    .transpose
    .filter(_.contains('#'))
    .transpose
    .toArray
    .foreach(ch => println(ch.mkString))
}

Measured memory_bytes: 29332
from collections import deque
D1 = {i:chr(i+96) for i in range(1,27)}
D2 = {val:key for key,val in D1.items()}
N = int(input())
que = deque([("a",1)])
A = []
while que:
    x,n = que.popleft()
    if n<N:
        imax = 0
        for i in range(len(x)):
            imax = max(imax,D2[x[i]])
        for j in range(1,min(imax+1,26)+1):
            que.append((x+D1[j],n+1))
    else:
        A.append(x)
A = sorted(list(set(A)))
for i in range(len(A)):
    print(A[i])

Measured memory_bytes: 110152
#include<stdio.h>
#include<string.h>
typedef struct {
	char direction[100];
	int num1,num2,num3,num4,num5,num6;
}DICE_t;
int main(){
	DICE_t a;
	scanf("%d %d %d %d %d %d",&a.num1,&a.num2,&a.num3,&a.num4,&a.num5,&a.num6);
	int n,x,y,dummy;
	scanf("%d",&n);
	for(int times=0;times<n;times++){
	    int turn=0;
		scanf("%d %d",&x,&y);
	    while(1){
		    if(a.num1!=x){
		    	strcpy(a.direction,(turn%2==0 ?"N":"E"));
	    	}
    		else if(a.num1==x&&a.num2!=y){
    			strcpy(a.direction,"SEN");
    		}
    		else if(a.num1==x&&a.num2==y)break;
    	    for(int i=0;a.direction[i]!=0;i++){
    	        if(a.direction[i]=='N'){
		            dummy=a.num5;
	            	a.num5=a.num1;
	            	a.num1=a.num2;
	            	a.num2=a.num6;
	        	    a.num6=dummy;
	            }
	            else if(a.direction[i]=='S'){
		             dummy=a.num6;
	            	a.num6=a.num2;
	            	a.num2=a.num1;
	            	a.num1=a.num5;
	            	a.num5=dummy;
	            }
    	        else if(a.direction[i]=='E'){
		            dummy=a.num4;
	        	    a.num4=a.num6;
	        	    a.num6=a.num3;
	        	    a.num3=a.num1;
	        	    a.num1=dummy;
	            }
	            else if(a.direction[i]=='W'){
	                dummy=a.num1;
	            	a.num1=a.num3;
	            	a.num3=a.num6;
	            	a.num6=a.num4;
	            	a.num4=dummy;
	            }	
    	    }
	    	turn++;
	    }
		printf("%d\n",a.num3);
	}
	
	return 0;
}

Measured memory_bytes: 2660
#include <bits/stdc++.h>
using namespace std;
#define Sz(a) ((int)(a).size())
const int maxn = 200009;
const int MOD = 1e9 + 7;
int main(){
#ifdef LOCAL
  freopen("a.in", "r", stdin);
#endif
  ios_base::sync_with_stdio(false),cout.tie(0),cin.tie(0);
  int a,b,c,d,e;
  cin>>a>>b>>c>>d>>e;
  if(a==0)cout<<1;
  else if(b==0)cout<<2;
  else if(c==0)cout<<3;
  else if(d==0)cout<<4;
  else cout<<5;
  
  return 0;
}
//2020.06.14 20:24:08


Measured memory_bytes: 3608
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
int x,y;
inline int min(R int x,R int y){return x<y?x:y;}
inline int min(R int a,R int b,R int c,R int d){
	return min(min(a,b),min(c,d));
}
inline int calc(R int x,R int y){return y>=x?y-x:x-y+2;}
int main(){
	scanf("%d%d",&x,&y);
	printf("%d\n",min(calc(x,y),1+calc(-x,y),1+calc(x,-y),2+calc(-x,-y)));
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws IOException {
        Scanner scan = new Scanner(System.in);
        String s1 = scan.next(), s2 = scan.next();
        int a = scan.nextInt(), b = scan.nextInt();
        String s3 = scan.next();
        if (s3.equals(s1))
            a --;
        else
            b --;
        System.out.println(a + " " + b);
    }
}


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

int main() {
  int a, b;
  cin >> a >> b;
  if (b % a == 0) {
    cout << a + b << endl;
  } else {
    cout << b - a << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<map>

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

using namespace std;

int main() {

	string s;
	cin >> s;
	int i = 0;
	int j = s.size() - 1;

	while (s[i] != 'A') i++;
		
	while (s[j] != 'Z')j--;

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


	return 0;
}

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

template<typename T>
void comp(const T& a, const T& b)
{
    if(a < b){
        cout << "a < b" << endl;
    }else
    if(a > b){
        cout << "a > b" << endl;
    }else{
        cout << "a == b" << endl;
    }

}
int main(void){
    int x, y;
    cin >> x >> y;
    comp(x, y);
    return 0;
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, m, d;
	cin >> n >> m >> d;
	double res = 0;
	if(d == 0){
		res = 1.0 / n;
	} else {
		res = 1.0 * (2 * (n - d)) / n / n;
	}
	cout << fixed << setprecision(10) << res * (m - 1) << endl;
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
 
int main()
{
    
        int n;
        int flag = 0;
        cin>>n;
        while(n != 0)
        {
            if(n%10 == 7)
            {
                flag =1 ;
                break;
            }
            n /= 10;
        }
        if(flag == 1)
        cout << "Yes" <<  endl;
         
        else
        cout << "No"<<endl;
         
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define llong long long
#define INF (__INT32_MAX__ / 2)
#define EPS 10e-8
#define MAX_N 100000
#define MAX_ABIT 42

using namespace std;
typedef pair<int, int> ipair;
llong modulo(llong left, llong right) { return (left % right + right) % right; }

int N;
unsigned llong K, A[MAX_N], A_bitsum[MAX_ABIT];
int main(int argc, char **argv) {
    cin >> N >> K;
    for(int i = 0; i < N; ++i) {
        cin >> A[i];
    
        llong a = A[i];
        for(int j = 0; a > 0; ++j) {
            A_bitsum[j] += a % 2;
            a /= 2;
        }
    }

    unsigned llong best_X = 0;
    for(int i = MAX_ABIT - 1; i >= 0; --i) {
        best_X *= 2;

        if(A_bitsum[i] * 2 < N)
            best_X++;
    }


    bool sw = false;
    llong res = INT64_MIN;
    for(int i = MAX_ABIT - 1; i >= 0; --i) {
        unsigned llong cur_bit = pow(2, i) + EPS;
        unsigned llong mask_right = cur_bit - 1;
        unsigned llong mask_left = ((unsigned llong) -1) - cur_bit - mask_right;

        if((K + 1 & cur_bit) == 0) continue;

        unsigned llong X = (K + 1 & mask_left) + (best_X & mask_right);

        llong cur = 0;
        for(int j = 0; j < N; ++j)
            cur += X ^ A[j];
        res = max(res, cur);
    }
    cout << res << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int MAX = 2e5 ;
const int INF = 1e9 + 1e5 + 2;
const int mod= 1e9+7;
#define eps 1e-15
typedef long long ll;
int main()
{
    string s;

    cin>>s;

    if (s[2]==s[3] && s[4]==s[5])
        cout<<"Yes";
    else
        cout<<"No";






}


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

using ll=long long;

int main(){

int a,b;

cin >> a >> b;

char c='0'+a;
char d='0'+b;

string S,T;

for(int i=0;i<b;++i){
S.push_back(c);
}

for(int i=0;i<a;++i){
T.push_back(d);
}

if(S<=T){cout << S << endl;}
else{cout<< T << endl;}

}

Measured memory_bytes: 256