akhauriyash/Code-Regression huggingface dataset:
/*
          ,     \    /      ,
         / \    )\__/(     / \
        /   \  (_\  /_)   /   \
   ____/_____\__\@  @/___/_____\____
  |             |\../|              |
  |              \VV/               |
  |        ------hoi-------         |
  |_________________________________|
   |    /\ /      \\       \ /\    |
   |  /   V        ))       V   \  |
   |/     `       //        '     \|
   `              V                '
*/

#include <bits/stdc++.h>

#define ull unsigned long long
#define ll long long
#define pb push_back
#define f first
#define se second
#define mp make_pair
#define Speedforce boost();

using namespace std;

void boost(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

const int N = 1e6;
const int inf = 1e9 + 7;

int n;
ll a[N], L;

int main() {
    Speedforce
    cin >> n >> L;
    for(int i = 1;i <= n;i ++){
        cin >> a[i];
    }
    for(int i = 1;i < n;i ++){
        if(a[i] + a[i + 1] >= L){
            cout << "Possible" << endl;
            for(int j = 1;j < i;j ++){
                cout << j << endl;
            }
            for(int j = n - 1;j > i;j --){
                cout << j << endl;
            }
            cout << i;
            return 0;
        }
    }
    cout << "Impossible";
}

Measured memory_bytes: 1664
#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() {
    string s; cin >> s;

    int start = s.find('A');
    int end = s.rfind('Z');
    print(end - start + 1);
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int _I(){ int x ; scanf("%d", &x); return x; }
void solve()
{
    int n = _I();
    int a = _I();
    int ans = (n/a)+( n % a != 0 );
    cout<<ans<<"\n";
}
int main()
{
    solve();
    return 0;
}


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

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

void main()
{
    auto n = lread();
    auto a = aryread();
    auto check = new long[](n);
    auto box = new long[](n);
    foreach_reverse (i; iota(n))
    {
        if (a[i] == check[i])
        {
            continue;
        }
        else
        {
            box[i] = 1;
            auto factor = (i + 1).factorization();
            foreach (e; factor)
            {
                check[e - 1] = !check[e - 1];
            }
        }
        // box.writeln();
    }
    box.sum.writeln();
    foreach (i, e; box)
        if(e == 1)
            write(i + 1, " ");
    writeln();
}

auto factorization(long a)
{
    auto factor = new long[](0);
    auto limit = cast(long) sqrt(cast(float) a);
    foreach (i; iota(limit))
    {
        long tmp = i + 1;
        if (a % tmp == 0)
        {
            factor ~= tmp;
            if (tmp != a / tmp)
                factor ~= a / tmp;
        }
    }
    factor.sort();
    return factor;
}

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


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

template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char& ch) {
	string s = "";
	s += ch;
	return "'" + s + "', ";
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cout << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL_DEFINE
#define debug(...) cout << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
   
#define int long long
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
typedef pair<int, int> pii;
const int mod = (int) 1000000007; // 998244353;
const int inf = (int) 2e18;

const int maxn = 1e7 + 10;
int d[maxn];


int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(9);
	#ifdef LOCAL_DEFINE
		freopen("in.txt", "rt", stdin);
	#endif
	
	int n;
	cin >> n;
	for(int i = 1; i < maxn; ++ i)
	{
		for(int j = i; j < maxn; j += i)
		{
			++ d[j];
		}
	}
	
	int ans = 0;
	for(int i = 1; i <= n; ++ i)
	{
		ans += i * d[i];
	}
	
	cout << ans << '\n';
	
	return 0;
}






Measured memory_bytes: 81764
// {{{ by shik
#include <bits/stdc++.h>
#include <unistd.h>
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x),end(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 FOR(it,c) for ( auto it=(c).begin(); it!=(c).end(); it++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
typedef vector<int> VI;

#ifdef SHIK
template<typename T>
void _dump( const char* s, T&& head ) { cerr<<s<<"="<<head<<endl; }

template<typename T, typename... Args>
void _dump( const char* s, T&& head, Args&&... tail ) {
    int c=0;
    while ( *s!=',' || c!=0 ) {
        if ( *s=='(' || *s=='[' || *s=='{' ) c++;
        if ( *s==')' || *s==']' || *s=='}' ) c--;
        cerr<<*s++;
    }
    cerr<<"="<<head<<", ";
    _dump(s+1,tail...);
}

#define dump(...) do { \
    fprintf(stderr, "%s:%d - ", __PRETTY_FUNCTION__, __LINE__); \
    _dump(#__VA_ARGS__, __VA_ARGS__); \
} while (0)

template<typename Iter>
ostream& _out( ostream &s, Iter b, Iter e ) {
    s<<"[";
    for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
    s<<"]";
    return s;
}

template<typename A, typename B>
ostream& operator <<( ostream &s, const pair<A,B> &p ) { return s<<"("<<p.first<<","<<p.second<<")"; }
template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) { return _out(s,ALL(c)); }
template<typename T, size_t N>
ostream& operator <<( ostream &s, const array<T,N> &c ) { return _out(s,ALL(c)); }
template<typename T>
ostream& operator <<( ostream &s, const set<T> &c ) { return _out(s,ALL(c)); }
template<typename A, typename B>
ostream& operator <<( ostream &s, const map<A,B> &c ) { return _out(s,ALL(c)); }
#else
#define dump(...)
#endif

template<typename T>
void _R( T &x ) { cin>>x; }
void _R( int &x ) { scanf("%d",&x); }
void _R( long long &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<typename T, typename... U>
void R( T& head, U&... tail ) {
    _R(head);
    R(tail...);
}

template<typename T>
void _W( const T &x ) { cout<<x; }
void _W( const int &x ) { printf("%d",x); }
template<typename T>
void _W( const vector<T> &x ) {
    for ( auto i=x.cbegin(); i!=x.cend(); i++ ) {
        if ( i!=x.cbegin() ) putchar(' ');
        _W(*i);
    }
}

void W() {}
template<typename T, typename... U>
void W( const T& head, const U&... tail ) {
    _W(head);
    putchar(sizeof...(tail)?' ':'\n');
    W(tail...);
}

#ifdef SHIK
#define FILEIO(...)
#else
#define FILEIO(name) do {\
    freopen(name ".in","r",stdin); \
    freopen(name ".out","w",stdout); \
} while (0)
#endif

// }}}

int main() {
    string t="CODEFESTIVAL2016";
    string s;
    cin>>s;
    int ans=0;
    REP(i,SZ(s)) {
        if ( s[i]!=t[i] ) ans++;
    }
    W(ans);
    return 0;
}


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

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

#ifdef _DEBUG
#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
#else
#define dbg(...) 0
#endif

#define ar array
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define all(x) (x).begin(), (x).end()
#define en '\n'
#define FILL(x, v) memset(x, v, sizeof(x))
#define pb push_back
#define fast                     \
	ios::sync_with_stdio(false); \
	cin.tie(NULL);               \
	cout.tie(NULL);
#define F_OR(i, a, b, s) for (int i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...)       \
	F_ORC(__VA_ARGS__) \
	(__VA_ARGS__)

#define E_ACH2(x, a) for (auto &x : a)
#define E_ACH3(x, y, a) for (auto &[x, y] : a)
#define E_ACH4(x, y, z, a) for (auto &[x, y, z] : a)
#define E_ACHC(...) GET5(__VA_ARGS__, E_ACH4, E_ACH3, E_ACH2)
#define EACH(...)       \
	E_ACHC(__VA_ARGS__) \
	(__VA_ARGS__)

template <typename A, typename B>
inline void chmin(A &a, B b)
{
	if (a > b)
		a = b;
}
template <typename A, typename B>
inline void chmax(A &a, B b)
{
	if (a < b)
		a = b;
}

struct UnionFind
{
	vector<int> d;
	UnionFind(int n = 0) : d(n, -1) {}

	int find(int x)
	{
		if (d[x] < 0)
			return x;
		return d[x] = find(d[x]);
	}

	bool unite(int x, int y)
	{
		x = find(x);
		y = find(y);
		if (x == y)
			return false;
		if (d[x] > d[y])
			swap(x, y);
		d[x] += d[y];
		d[y] = x;
		return true;
	}

	bool same(int x, int y) { return find(x) == find(y); }

	int size(int x) { return -d[find(x)]; }
};

int main()
{
	fast;
	int n, m, k;
	cin >> n >> m >> k;
	vvi fr(n), bl(n);
	UnionFind uf(n);
	FOR(m)
	{
		int x, y;
		cin >> x >> y;
		x--;
		y--;
		fr[x].pb(y);
		fr[y].pb(x);
		uf.unite(x, y);
	}
	FOR(k)
	{
		int x, y;
		cin >> x >> y;
		x--;
		y--;
		bl[x].pb(y);
		bl[y].pb(x);
	}
	FOR(n)
	{
		// total connected - self node - edges
		int ans = uf.size(i) - 1 - fr[i].size();
		for (auto &x : bl[i])
			if (uf.same(i, x))
				ans--;
		cout << ans << " ";
	}
	cout << en;
}

Measured memory_bytes: 14464
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n=STR()
    if n[0]=='9' or n[1] == '9':
        print('Yes')
    else:
        print('No')
if __name__ == '__main__':
    do()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
//Made with <3 by MinumCoklatPanas
typedef long long ll;
const int INF = 1e9;
const ll INFF = 1e18;
const int MAXN = 510;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
const double INFD = 1E9;
const double EPS = 1e-9;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	double r;
	cin >> r;
	double ans = PI * r * 2.0;
	cout << setprecision(7) << fixed;
	cout << ans << endl;
	// cout << fixed;
	return 0;
}

Measured memory_bytes: 3828
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
typedef long long int ll;
typedef long double ld;
#define MOD 1000000007
#define ALL(obj) (obj).begin(),(obj).end()
template<class T>inline bool chmax(T& a,T b){if (a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T& a,T b){if (a>b){a=b;return 1;}return 0;}
const long long INF = 1LL << 60;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
//四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

struct edge{//グラフに使うヤツ
    ll from,to,cost;
};

typedef vector<vector<edge> > G;
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}

int main(){
    ll n;
    cin >> n;
    ll ans[n+10];
    fill(ans,ans+n+10,0);
    for (ll i=1;i<110;i++){
        for (ll j=1;j<110;j++){
            for (ll k=1;k<110;k++){
                if ((i*i)+(j*j)+(k*k)+(i*j)+(j*k)+(k*i)<=n){
                    ans[(i*i)+(j*j)+(k*k)+(i*j)+(j*k)+(k*i)]++;
                }
            }
        }
    }
    for (ll i=1;i<=n;i++){
        cout << ans[i] << endl;
    }
    return 0;
}


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

void IOinit() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
}

int main() {
  IOinit();
  int a,b,c;
  cin >> a >> b >> c;
  int ans = max({a,b,c}) - min({a,b,c});
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 3656
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount
           
#define rep(i, n) for (int i = 0; i < n; ++i)

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

const double EPS = 1e-10;
typedef long long ll;
typedef pair<int, int> pint;


string s[128];
string buf;
int lines;
void delete_line(int y)
{
    for (int i = y; i < lines; ++i)
	s[i] = s[i + 1];

    if (lines > 1)
	--lines;
    s[lines] = "";
}
void add_line(int y)
{
    for (int i = lines++; i > y; --i)
	s[i] = s[i - 1];
    s[y] = "";
}
int main()
{
    while (true)
    {
	string t;
	getline(cin, t);
	if (t == "END_OF_TEXT")
	    break;
	s[lines++] = t;
    }
    if (lines == 0)
	lines = 1;

    int x, y;
    x = y = 0;
    while (true)
    {
	char c;
	cin >> c;
	if (c == '-')
	    break;

	switch (c)
	{
	case 'a':
	{
	    x = 0;
	    break;
	}
	case 'e':
	{
	    x = s[y].size();
	    break;
	}
	case 'p':
	{
	    y = max(0, --y);
	    x = 0;
	    break;
	}
	case 'n':
	{
	    y = min(lines - 1, ++y);
	    x = 0;
	    break;
	}
	case 'f':
	{
	    if (x != s[y].size())
		++x;
	    else if (y + 1 < lines)
		x = 0, ++y;
	    break;
	}
	case 'b':
	{
	    if (x != 0)
		--x;
	    else if (y != 0)
	    {
		--y;
		x = s[y].size();
	    }
	    break;
	}
	case 'd':
	{
	    if (x != s[y].size())
		s[y].erase(x, 1);
	    else if (y + 1 < lines)
	    {
		s[y] += s[y + 1];
		delete_line(y + 1);
	    }
	    break;
	}
	case 'k':
	{
	    if (x != s[y].size())
	    {
		buf = s[y].substr(x);
		s[y].erase(x);
	    }
	    else if (y + 1 < lines)
	    {
		s[y] += s[y + 1];
		delete_line(y + 1);
		buf = "\n";
	    }
	    break;
	}
	case 'y':
	{
	    if (buf == "\n")
	    {
		add_line(y + 1);
		s[y + 1] = s[y].substr(x);
		s[y].erase(x);
		x = 0, ++y;
	    }
	    else
	    {
		s[y].insert(x, buf);
		x += buf.size();
	    }
	    break;
	}
	}
    }

    for (int i = 0; i < lines; ++i)
	cout << s[i] << endl;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair
#define fst first
#define snd second
#define fr(i, a, b) for(int i=a; i<b; i++)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
    int a, b; cin >> a >> b;
    cout << max(0, a-2*b) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>
#include <queue>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBAG = false;


int main(){

    string s;
    cin >> s;


    for(int i = 0; i < s.size() - 1; i++){
        /*
        if(s[i] == s[i+1] || s[i] == s[i+2] || s[i+1] == s[i+2]){
            if(i == s.size() - 2 && i > 0){
                cout << i  << " " << i + 2 << endl;
                return 0;
            }
            else{
                cout << i + 1 << " " << i + 3 << endl;
                return 0;
            }
        }
        */
        if(s[i] == s[i+1] ){
            cout << i + 1 << " " << i + 2 << endl;
            return 0;
        }
        if(i < s.size() - 2){
            if(s[i] == s[i+2]){
                cout << i + 1 << " " << i + 3 << endl;
                return 0;
            }
        }


    }
    cout << -1 << " " << -1 << endl;
}

Measured memory_bytes: 512
import bisect

N = int(input())
Ls = list(map(int, input().split()))

Ls.sort()
S = 0
for i in range(N - 2):
    A = Ls[i]
    for j in range(i + 1, N - 1):
        B = Ls[j]
        k = bisect.bisect_left(Ls, A + B, j + 1)
        S += k - j - 1
print(S)

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

int main(){
    string s;
    cin >> s;
    int n = s.size();
    int p = 0;
    for(int i = 0; i < n; i++){
        if(s[i] == 'p') p++;
    }
    cout << n / 2 - p << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <time.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P  = pair<ll,ll>;
using vi = vector<ll>;
using vv = vector<vi>;
const ll INF = 1001001001001001;
const ll NUM = 1<<10;

//1<=K<=NなるすべてのKに対して答える

vector<ll> prime;
vector<ll> p(1000001,0);
vector<ll> f(10000001,0);

void sieve(ll n){
    if(n<2)return;
    for(ll i=2; i<=n; i++){
        if(p[i])continue;
        prime.push_back(i);
        p[i] = i;
        
        for(ll j=i*i; j<=n; j+=i){
            if(!p[j])p[j] = i;
        }
    }
}

ll powmod(ll a, ll n, ll k){
    ll rtn = 1LL;
    
    while(n>0){
        
        if(n&1LL)
            rtn = rtn * a % k;
        a = a * a % k;
        n >>= 1;
    }
    
    return rtn;
}

ll phi_p(ll q, ll a){
    
    //if(q==3) a += 2;
    a--;
    ll rtn = q-1;
    for(ll i=0; i<a; i++){
        rtn *= q;
    }
    return rtn;
}


void cal_f(ll n){
    for(int i=0; i<prime.size(); i++){
        
        if(prime[i]==2 || prime[i]==5)continue;
        
        ll q = prime[i];
        ll a = 1;
        ll phi = prime[i]-1;
        
        {
            ll buf = INF;
            for(ll j=1; j*j<=phi; j++){
                if(phi%j)continue;
                
                if(powmod(10, j, q)==1LL){
                    f[q] = j;
                    break;
                }
                if(powmod(10, phi/j, q)==1LL){
                    buf = phi/j;
                }
            }
            if(!f[q]) f[q] = buf;
            q *= prime[i];
        }
        
        while(q<=n || (prime[i]==3 && q<=10*n)){
            
            if(powmod(10, f[q/prime[i]], q)==1LL)
                f[q] = f[q/prime[i]];
            else
                f[q] = prime[i] * f[q/prime[i]];
            
            q *= prime[i];
        }
    }
    return;
}

ll gcd(ll a, ll b){
    
    if(a<b)
        swap(a,b);
    while(a%b!=0){
        a %= b;
        swap(a,b);
    }
    return b;
}

//O(logN)で素因数分解
ll solve(ll n){
    
    ll ans = 1;
    
    while(n!=1){
        ll minp = p[n];
        ll a = 1;
        
        while(p[n]==minp){
            n /= minp;
            a *= minp;
        }
        
        if(minp==3) a*= 9;
        ans = ans / gcd(ans, f[a]) * f[a];
    }
    return ans;
}



int main(){
    
    ll n; cin>>n;
    
    sieve(1000000);
    cal_f(1000000);
    
    for(ll i=1; i<=1000000; i++){
        if(i==1 || i==7){
            if(i==n)printf("1\n");
            //cout<<i<<" "<<1<<endl;
            continue;
        }
        if(i%2==0 || i%5==0){
            if(i==n)printf("-1\n");
            //cout<<i<<" "<<-1<<endl;
            continue;
        }
        
        ll k = i;
        if(k%7==0)k/=7;
        //k*=9;
        int so = solve(k);
        if(i==n)printf("%d\n",so);
        //cout<<i<<" "<<ans<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 90188
N = int(input())
ans = 0

for n in range(1, N+1):
    cnt = 0
    if n%2 == 0:
        continue
    for yaku in range(1, n+1):
        if n%yaku == 0:
            cnt += 1
    if cnt == 8:
        ans += 1
        
print(ans)

Measured memory_bytes: 63752
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
const long long mod = 1000000007;
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
bool dbg = false;
long long gcd(long long a, long long b){
   if (a % b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a % b));
   }
}
long long lcm(long long a, long long b){
   return (a / gcd(a, b))* b;
}
//---------------------------------------------------------------------------------------------------
/*ここからいじる*/
//---------------------------------------------------------------------------------------------------

void solve(){
}
int main(){
    int n, m;
    cin >> n >> m;
    vector<pair<int, string> >data(m);
    vector<int>ac(n);
    vector<int>wa(n);
    for(int i = 0; i < m; i++){
        cin >> data.at(i).first >> data.at(i).second;
    }
    for(int i = 0; i < m; i++){
        if(data.at(i).second == "AC"){
            if(ac.at(data.at(i).first - 1) == 0){
                ac.at(data.at(i).first - 1)++;//初めてのAACなら加算
            }
        }
        else if(data.at(i).second == "WA"){
            if(ac.at(data.at(i).first - 1) == 0){
                wa.at(data.at(i).first - 1)++;//まだACしてなければ加算
            }
        }
    }
    for(int i = 0; i < n; i++){
        if(ac.at(i) == 0){
            wa.at(i) = 0;//結局ACできてなかったらリセット
        }
    }
    int allac = 0, allwa = 0;
    for(int i = 0; i < n; i++){
        allac += ac.at(i);
        allwa += wa.at(i);
    }
    cout << allac << " " << allwa << endl;
    solve();
    return 0;
}



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

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

// ax+by=1の解
ll extgcd(ll a, ll b, ll& x, ll& y){
	ll d = a;
	if (b != 0){
		d = extgcd(b, a%b, y, x);
		y -= (a / b)*x;
	}
	else{
		x = 1; y = 0;
	}
	return d;
}
// mod mでのaの逆数
ll mod_inverse(ll a, ll m){
	ll x, y;
	extgcd(a, m, x, y);
	return (m + x%m) % m;
}
// nの階乗 mod p
ll factorial(int n, int p){
	ll r = 1;
	for (int i = 1; i <= n; i++)
		r = (r*i) % p;
	return r;
}
// nPr mod p
ll permutation(int n, int r, int p){
	ll a = 1;
	for (int i = n - r + 1; i <= n; i++)
		a = (a*i) % p;
	return a;
}
// nCr mod p
ll combination(int n, int r, int p){
	if (r == 0 || r == n) return 1;
	if (r<0 || r>n) return 0;
	if (r > n / 2) r = n - r;
	ll numerator = permutation(n, r, p);
	ll denominator = factorial(r, p) % p;
	ll inv = mod_inverse(denominator, p);
	return (numerator * inv) % p;
}

int c[123456];
signed main(){

	int N;
	cin >> N;
	vector<int> a(N + 1);
	rep(i, N + 1){
		cin >> a[i];
		c[a[i]] ++;
	}
	int two;
	rep(i, N + 1){
		if (c[i] == 2){
			two = i; break;
		}
	}
	int l[3], m = 0;
	rep(i, N + 1){
		if (a[i] == two){
			l[0] = i; break;
		}
	}
	for (int i = l[0] + 1; i < N + 1; i++){
		if (a[i] == two){
			l[1] = i - l[0] - 1; break;
		}
	}
	l[2] = N + 1 - 2 - l[0] - l[1];

	// n!のtable
	int fac_table[123456];
	fac_table[0] = fac_table[1] = 1;
	for (int i = 2; i <= 100002; i++){
		fac_table[i] = (fac_table[i - 1] * i) % mod;
	}

	// k=1
	cout << N << endl;
	for (int k = 2; k <= N + 1; k++){

//		int ans = combination(N + 1, k, mod)
//			- combination(l[0] + l[2], k - 1, mod);

		int ans = ((fac_table[N + 1] * mod_inverse(fac_table[k], mod))%mod) * mod_inverse(fac_table[N + 1 - k], mod) % mod;
		if (l[0] + l[2]>=k-1)
			ans -= ((fac_table[l[0] + l[2]] * mod_inverse(fac_table[k - 1], mod))%mod) * mod_inverse(fac_table[l[0] + l[2] - (k - 1)], mod) % mod;

//		cerr << fac_table[N + 1] * mod_inverse(fac_table[k], mod) * mod_inverse(fac_table[N + 1 - k], mod) % mod << " ";
//		cerr << fac_table[l[0] + l[2]] * mod_inverse(fac_table[k - 1], mod) * mod_inverse(fac_table[max(0LL,l[0] + l[2] - (k - 1))], mod) % mod << endl;

		cout << (ans + mod) % mod << endl;

	}

	return 0;
}

Measured memory_bytes: 3584
n = int(input());
s = [0]*n;
t = [0]*n;
t_sum = 0;
for i in range(n) :
	si = input().split(' ');
	s[i] = si[0];
	t[i] = int(si[1]);
	t_sum += t[i];

x = input().rstrip('\n');

for i in range(n) :
	t_sum -= t[i];
	if s[i] == x :
		break;

print(t_sum);

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



int main(){
  string s;
  cin >> s;
  int n = 0;
  n = s.length();
  rep(i,n) cout << 'x';


}

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

int main(){
    char S;
    int max_count = 0;
    int count = 0;
    for(int i=0; i<3; i++){
        cin >> S;
        if(S=='R') count++;
        else if(count!=0) count=0;
        if(count>max_count) max_count=count;
    }
    cout << max_count << endl;
}

Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int sumA = 0;
		int sumB = 0;
		
		String[] strArray = br.readLine().split(" ");
		
		for(int i = 0; i < 4; i++){
			sumA += Integer.parseInt(strArray[i]);
		}
		strArray = br.readLine().split(" ");
		
		for(int i = 0; i < 4; i++){
			sumB += Integer.parseInt(strArray[i]);
		}
		
		System.out.println(Math.max(sumA, sumB));
	
	}

}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=acos(-1);
const ll MOD=1e9+7;
const ll INF=(1LL<<60);

int main() {
    int n;
    cin>>n;
    int d[n+1][n];
    int c[n+1];
    rep(i,n)rep(j,n-1)cin>>d[i+1][j+1];
    rep(i,n)c[i+1]=1;
    int bb[n+1];
    int ans=0;
    int b=1;
    while(b){
        b=0;
        ans++;
        memset(bb,0,sizeof(bb));
        for (int i=1;i<n+1;i++){
            if (bb[i]==1 || c[i]==n)continue;
            int num=d[i][c[i]];//闘う相手
            if (d[num][c[num]]==i && bb[num]==0){
                c[num]++;
                c[i]++;
                bb[num]=1;
                bb[i]=1;
                b=1;
            }
        }
    }
    //cout<<c[1]<<" "<<c[2]<<" "<<c[3]<<endl;
    rep(i,n){
        if (c[i+1]!=n){
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<ans-1<<endl;

    return 0;
}

Measured memory_bytes: 4224
import os, sys, re, math

lines = sys.stdin.readlines()

n = lines[0]
aa = lines[1].split()

result = 0
n = int(n)
for a in aa:
    a = int(a)
    while (a % 2 == 0):
        a /= 2
        result += 1

print (result)


Measured memory_bytes: 3956
#include<stdio.h>
#include<string>
#include<algorithm>
#include<vector>
#include<iostream>
using namespace std;
//pair<long long, long long>c[2000001];
int n, a[2000001], i, j, t = 0, c[200001];
int  main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cout << "ACL";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a);i<(b);++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
#define INF 1000000000000000
#define MOD 1000000007
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a:A) cin >> a;} 

#include <boost/multiprecision/integer.hpp>
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
template <typename T>
unordered_map<T, int> count_prime(T N){
    unordered_map<T, int> num; // N の素因数の個数
    T n = N;
    for(T j = 2; j * j <= N; ++j)
        while (n % j == 0) {
            ++num[j];
            n /= j;
        }

    if (n != 1) ++num[n];
    return num;
}

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

int N; cin >> N;
VI A(N); invec(A);

i64 maxA = *max_element(ALL(A));
VI cntp(maxA+1, 0);
for(i64 a: A){
    unordered_map<i64, int> cnta = count_prime(a);
    for (pair<i64, int> p: cnta)
        cntp[p.first] = max(cntp[p.first], (i64)p.second);
}

i64 L = 1;
rep(i, 2, maxA+1) if (cntp[i] > 0)
    (L *= boost::multiprecision::powm(i, cntp[i], MOD)) %= MOD;

i64 ans = 0;
for(i64 a: A) 
    (ans += L * modinv(a, MOD) %MOD) %= MOD;

cout << ans % MOD << "\n";

return 0;
}
// コンテスト前はtemplate振り返り。
// 書いて考える．場合分け．情報整理．
// 単純に分かる量から．愚直解を実装して研究．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP(小さい問題から大きな問題)
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性→二分探索
// 存在判定：構成方法，入力の特徴
// 構築問題。極端解を試す。
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// コーナーケース。境界値。数表出力プログラム作る
// 実行エラー：vector添え字超え．0割り．



Measured memory_bytes: 8192
#include<bits/stdc++.h>
using  namespace  std;
int sr,flag;
int main()
{
	cin>>sr;
	if(sr/10==9)flag=1;
	if(sr%10==9)flag=1;
	if(flag==1)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

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

int main(){
  int N =19;
  vector<char> X(N);
  for(int i=0;i<N;i++){
    cin >> X.at(i);
  }
  
  X.at(5) = ' ';
  X.at(13) = ' ';
  
  for(int i=0;i<N;i++){
    cout << X.at(i);
  }
}

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

using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) {
  if (a < b) return gcd(b, a);
  if (b == 0) return a;
  return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
  return (a / gcd(a, b)) * b;
}

ll two(ll n) {
  ll c = 0;
  while (n % (0x01 << (c+1)) == 0) {
    c++;
  }
  return c;
}

ll solve() {
  int N;
  ll M;
  cin >> N >> M;

  vector<ll> a(N);

  for (int i = 0; i < N; i++) {
    cin >> a[i];
    a[i] = a[i] / 2;
  }

  ll lc = a[0];
  ll nt = two(a[0]);
  for (int i = 1; i < N; i++) {
    if (two(a[i]) != nt) {
      return 0;
    }
    lc = lcm(lc, a[i]);
    if (lc > M) {
      return 0;
    }
  }

  ll d = M / lc;
  return (d / 2) + (d % 2);
}

int main() {
  cout << solve() << endl;
  return 0;
}


Measured memory_bytes: 1024
#!/usr/bin/env python

from collections import deque, defaultdict
import itertools as ite
import sys
import math
from decimal import *

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

N, M = map(int, raw_input().split())
if N == M:
    print "Yes"
else:
    print "No"

Measured memory_bytes: 4396
s = input()
N = len(s)+1
res = []
ans = 0
i = 0
while i < N-1:
    seq = 1
    while i < N - 2 and s[i] == s[i + 1]:
        i += 1
        seq += 1
    res.append(seq)
    i += 1

if s[0] == '>':
    ans += res[0] * (res[0] + 1) // 2
    res = res[1:]
if s[-1] == '<':
    ans += res[-1] * (res[-1]+1)//2
    res = res[:-1]

for i in range(len(res) // 2):
    tmp = max(res[2 * i], res[2 * i + 1])
    tmp2 = min(res[2 * i], res[2 * i + 1])
    ans += tmp * (tmp + 1) // 2
    ans += tmp2 * (tmp2-1) //2
print(ans)

Measured memory_bytes: 13896
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));
signed main(){
	int N, M; cin >> N >> M;
	priority_queue<int> L;
	priority_queue<int, vector<int>, greater<int> > R;
	REP(i, M){
		int tmp1, tmp2;
		cin >> tmp1 >> tmp2;
		L.push(tmp1);
		R.push(tmp2);
	}
	int ans = R.top()-L.top()+1;
	cout << (ans > 0 ? ans : 0) << endl;
}

Measured memory_bytes: 1276
function main(tmp) {
    var i=0;
    while(tmp[i]!=0){
        console.log("Case " + (i+1) + ": " + tmp[i]);
        i = i + 1;
    }
}
var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', function (line) {
  lines.push(line);
  if(line==0){
  	main(lines);
  	lines='';
  }
});
process.stdin.on('end', function () {
});

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

int main(){
    int k, a, b;
    cin >> k >> a >> b;
    if (b - a <= 2) cout << k + 1 << endl;
    else cout << (long long)(b - a) * max(0, (k - a + 1) / 2) + min(a - 1, k) + 1 + (k - a + 1 >= 0 && (k - a + 1) % 2) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>
#include<numeric>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,x,y) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define SUM(a) accumulate(all(a),0LL)
#define scan(x) scanf("%lld",&x)
#define print(x) printf("%lld\n",x)
#define print2(x) printf("%lld ",x)
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;

ll n = 0, m = 0, ans = 0, cnt = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok = true, flag = false;
ll dx[5] = { 1,-1,0,0,0 }, dy[5] = { 0,0,1,-1,0 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 333333



int main(void) {
  ll x, y;
  cin >> n >> m >> x >> y;
  ll X, Y;
  rep(i, n) {
	scan(tmp);
	ma = max(ma, tmp);
  }
  X = ma;
  rep(i, m) {
	scan(tmp);
	mi = min(mi, tmp);
  }
  Y = mi;
  ok = false;
  FOR(i, x + 1, y) {
	if (i > X&&i <= Y) ok = true;
  }

  if (ok) cout << "No War" << endl;
  else cout << "War" << endl;


  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int gcd(int u, int v) {
  int r;
  while (0 != v) {
    r = u % v; u = v; v = r; /* swap */
  }
  return u;
}
int main(){
  // get input
  int N;
  int M;
  scanf("%d",&N);
  scanf("%d",&M);
  char S[1000000];
  char T[1000000];
  
  scanf("%s", S);
  scanf("%s", T);
  
  //puts(S);
  //puts(T);
  
  // get gcd of N,M
  int C = gcd(N, M);
  int n = N/C;
  int m = M/C;
  // test
  int test = 1;
  for(int i = 0; i < C; i++){
    if(S[n*i] != T[m*i]){
      test = 0;
      break;
    }
  }
  // print result
  if(test == 1){
    printf("%ld", (long)N*(long)M/(long)C);
  }
  else printf("-1");
  
  return 0;
}

Measured memory_bytes: 384
n = int(input())
x = input()

popcount = x.count('1')
p = int(x, 2) % (popcount + 1)
q = int(x, 2) % (popcount - 1) if popcount != 1 else 0
for i in range(n):
    if x[i] == '0':
        y = (p + pow(2, n-i-1, popcount+1)) % (popcount + 1)
    else:
        if popcount != 1:
            y = (q - pow(2, n-i-1, popcount-1)) % (popcount - 1)
        else:
            print(0)
            continue
    cnt = 1
    while y != 0:
        y %= bin(y).count('1')
        cnt += 1
    print(cnt)


Measured memory_bytes: 9536
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const int INF=1e9;
const int MOD=1e9+7;
const double pi=acos(-1);

int main(){
  int n;
  cin >> n;
  vector<int>l(n);
  rep(i,n)cin >> l[i];
  sort(l.begin(),l.end());
  
  int sum=0;
  rep(i,n-1){
    sum+=l[i];
  }
  if(sum>l[l.size()-1])cout<<"Yes"<<endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<time.h>
#include<string.h>
#include<stdlib.h>
#include<stdio.h> 
int main()
{
	int a[110][110],r,c,i,j;
	scanf("%d %d",&r,&c);
	for(i=1;i<=r;i++)
		for(j=1;j<=c;j++)
			scanf("%d",&a[i][j]);
	for(i=1;i<=r;i++)
	{
		a[i][c+1]=0;
		for(j=1;j<=c;j++)
			a[i][c+1]+=a[i][j];
	}
	for(i=1;i<=c+1;i++)
	{
		a[r+1][i]=0;
		for(j=1;j<=r;j++)
			a[r+1][i]+=a[j][i];
	}
	for(i=1;i<=r+1;i++)
		for(j=1;j<=c+1;j++)
		{
			printf("%d",a[i][j]);
			if (j!=c+1)
				printf(" ");
			else
				printf("\n");
		}
	return 0;
}


Measured memory_bytes: 2048
#!/usr/bin/env python

from sys import stdin, stderr

def check(M, A):
   A.sort()
   A = A[::-1]
   total = sum(A)
   for i in xrange(M):
      x = A[i]
      if x * 4*M < total:
         return False
   return True

def main():
   N, M = map(int, stdin.readline().split())
   A = map(int, stdin.readline().split())

   print('Yes' if check(M, A) else 'No')

   return 0

if __name__ == '__main__': main()


Measured memory_bytes: 2568
#include<bits/stdc++.h>
#define il inline
#define vd void
#define mod 1000000007
typedef long long ll;
il ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
il int pow(int x,int y){
	int ret=1;
	while(y){
		if(y&1)ret=1ll*ret*x%mod;
		x=1ll*x*x%mod;y>>=1;
	}
	return ret;
}
int ans=1,n,k;
int fir[100010],dis[200010],nxt[200010],id,fact[100010],ifact[100010];
il int P(int n,int m){if(n<0||m<0||n<m)return 0;return 1ll*fact[n]*ifact[n-m]%mod;}
il vd link(int a,int b){nxt[++id]=fir[a],fir[a]=id,dis[id]=b;}
il vd dfs(int x,int fa=-1){
	int son=0,s=(x!=1)+1;
	for(int i=fir[x];i;i=nxt[i]){
		if(fa==dis[i])continue;
		dfs(dis[i],x);
		++son;
	}
	ans=1ll*ans*P(k-s,son)%mod;
}
int main(){
#ifdef XZZSB
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	n=gi(),k=gi();int a,b;
	fact[0]=1;for(int i=1;i<=k;++i)fact[i]=1ll*fact[i-1]*i%mod;
	ifact[k]=pow(fact[k],mod-2);for(int i=k;i;--i)ifact[i-1]=1ll*ifact[i]*i%mod;
	for(int i=1;i<n;++i)a=gi(),b=gi(),link(a,b),link(b,a);
	dfs(1);
	printf("%d\n",1ll*ans*k%mod);
	return 0;
}


Measured memory_bytes: 3968
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
	string S;
    int res = 0;
    stack<char> Sstack;
	cin >> S;
    int Ssize = S.size();
    for (int i = 0; i < Ssize; i++){
        if (Sstack.size() == 0) {
            Sstack.push(S[i]);
        }else{
            if (S[i] == Sstack.top()) {
                Sstack.pop();
                res++;
            }else{
                Sstack.push(S[i]);
            }
        }
    }
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
int main(){
    int S,h,m,s;
    scanf("%d",&S);
    h=S/3600;
    m=(S-h*3600)/60;
    s=S-h*3600-m*60; 
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}


Measured memory_bytes: 2132
#include <algorithm>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
const int MOD = 1E9 + 9;
const int INF = 1 << 29;

int main() {
  int n, tmp;
  cin >> n;
  vector<ll> a(n);
  vector<ll> b(n);
  rep(i, n) a[i] = 0;
  rep(i, n) {
    cin >> tmp;
    a[tmp - 1] += 1;  // nの数をカウントし、n-1に保存
    b[i] = tmp;       // 入力のn
  }
  ll sum = 0;
  rep(i, n) { sum += (a[i] * (a[i] - 1)) / 2; }
  rep(i, n) {
    ll ans = sum - a[b[i] - 1] + 1;
    cout << ans << endl;
  }
}

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

using namespace std;
using ll = long long;

int main() {
  string s, t;
  cin >> s >> t;
  vector<vector<int> > dp(s.size() + 1, vector<int>(t.size() + 1, 0));
  for (int i = 1; i <= s.size(); i++) {
    for (int j = 1; j <= t.size(); j++) {
      if (s[i - 1] == t[j - 1]) {
        dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + 1);
      }
      dp[i][j] = max(dp[i][j], dp[i - 1][j]);
      dp[i][j] = max(dp[i][j], dp[i][j - 1]);
    }
  }

  string ans = "";
  int i = (int)s.size();
  int j = (int)t.size();
  while (i > 0 && j > 0) {
    if (dp[i][j] == dp[i - 1][j]) {
      i--;
    } else if (dp[i][j] == dp[i][j - 1]) {
      j--;
    } else {
      ans = s[i - 1] + ans;
      i--;
      j--;
    }
  }
  cout << ans << endl;
  return 0;
}


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

const int MAXN = 2.1e5;
int N, K;
int P[MAXN];

const int S = 1 << 18;
pair<int, int> seg[2*S];
pair<int, int> merge(pair<int, int> a, pair<int, int> b) {
	return {min(a.first, b.first), max(a.second, b.second)};
}
// inclusive
pair<int, int> query(int a, int b) {
	pair<int, int> ans(int(1e9), -int(1e9));
	for (int l = a+S, r = b+1+S; l < r; l /= 2, r /= 2) {
		if (l & 1) {
			ans = merge(ans, seg[l]);
			l++;
		}
		if (r & 1) {
			r--;
			ans = merge(ans, seg[r]);
		}
	}
	return ans;
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		cin >> P[i];
		seg[S+i] = {P[i], P[i]};
	}
	for (int i = S-1; i > 0; i--) {
		seg[i] = merge(seg[2*i], seg[2*i+1]);
	}
	int ans = 1;
	for (int i = 0; i + K < N; i++) {
		if (query(i, i + K) == pair<int,int>(P[i], P[i+K])) {
		} else {
			ans++;
		}
	}

	int totSorted = 0;
	int numSorted = 1;
	for (int i = 1; i < N; i++) {
		if (P[i] > P[i-1]) {
			numSorted++;
		} else {
			numSorted = 1;
		}
		if (numSorted == K) {
			totSorted++;
		}
	}

	if (totSorted) ans -= totSorted - 1;
	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 5120
#include <iostream>
#include <string>

using namespace std;

int main(int argc, char* argv[]) {
  string s;
  cin >> s;

  bool is_c_done = false;
  for (int i = 0; i < s.size(); ++i) {
    if (i > 0 && s[i] >= 'A' && s[i] <= 'Z') {
      if (!(i > 1 && i < s.size() - 1 && s[i] == 'C' && !is_c_done)) {
        cout << "WA" << endl;
        return 0;
      }
    }
    if (i == 0 && s[i] != 'A') {
      cout << "WA" << endl;
      return 0;
    } else if ((i > 1 && i < s.size() - 1)) {
      if (is_c_done && s[i] == 'C') {
        cout << "WA" << endl;
        return 0;
      } else if (!is_c_done && s[i] == 'C'){
        is_c_done = true;
      }
    }
  }

  if (is_c_done)
    cout << "AC" << endl;
  else
    cout << "WA" << endl;

  return 0;
}

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

int main() {
    map<string, int> ans;
    string s;
    int n; cin >> n;
    while (n--) {
        cin >> s;
        ++ans[s];
    }
    cout << "AC x " << ans["AC"] << endl;
    cout << "WA x " << ans["WA"] << endl;
    cout << "TLE x " << ans["TLE"] << endl;
    cout << "RE x " << ans["RE"] << endl;
}



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

int main(){
    ll N,L; cin>>N>>L;
    ll sum=(2*L+N-1)*N/2;
    if(L>=0){
        cout<<sum-L<<endl;
    }else if(L<0&&L+N-1<0){
        cout<<sum-(L+N-1)<<endl;
    }else{
        cout<<sum<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int s[128]={0},i,n,x,d,res=0;
	scanf("%d",&n);
	scanf("%d",&x);
	for(i = 1;i <= x;i++){
		scanf("%d",&d);s[d]++;
	}
	scanf("%d",&x);
	for(i = 1;i <= x;i++){
		scanf("%d",&d);s[d]+=2;
	}
	scanf("%d",&x);
	for(i = 1;i <= x;i++){
		scanf("%d",&d);s[d]+=4;
	}
	for(i = 1;i <= n;i++){
		if(s[i] == 4 || s[i] == 6 || s[i] == 7){
			res++;
		}
	}
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 1824
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <unordered_map>

using namespace std;

typedef long long ll;

template <class T> struct fenwick_tree {

public:
    fenwick_tree() : _n(0) {}
    fenwick_tree(int n) : _n(n), data(n) {}

    void add(int pos, T val) {
        for (; pos < _n; pos = (pos | (pos + 1)))
            data[pos] += val;
    }

    T sum(int l, int r) {
        assert(l <= r && r < _n);
        if (l <= 0)
            return sum(r);
        return sum(r) - sum(l - 1);
    }

private:
    int _n;
    std::vector<T> data;

    T sum(int pos) {
        T res = 0;
        for (; pos >= 0; pos = (pos & (pos + 1)) - 1)
            res += data[pos];
        return res;
    }
};

void solve() {
    int n, q;
    cin >> n >> q;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    fenwick_tree<ll> fenv(n);
    for (int i = 0; i < n; i++)
        fenv.add(i, a[i]);
    for (int i = 0; i < q; i++) {
        int type;
        cin >> type;
        if (type == 0) {
            int pos, val;
            cin >> pos >> val;
            fenv.add(pos, val);
        }
        else {
            int l, r;
            cin >> l >> r;
            cout << fenv.sum(l, r - 1) << '\n';
        }
    }
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int q = 1;
	//cin >> q;
	for (; q > 0; q--) {
		solve();
		//cout << endl;
	}
}

Measured memory_bytes: 12168