akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <numeric>
#include <vector>

template <int MOD>
struct ModInt {
    using lint = long long;
    int val;

    // constructor
    ModInt(lint v = 0) : val(v % MOD) {
        if (val < 0) val += MOD;
    };

    // unary operator
    ModInt operator+() const { return ModInt(val); }
    ModInt operator-() const { return ModInt(MOD - val); }
    ModInt inv() const { return this->pow(MOD - 2); }

    // arithmetic
    ModInt operator+(const ModInt& x) const { return ModInt(*this) += x; }
    ModInt operator-(const ModInt& x) const { return ModInt(*this) -= x; }
    ModInt operator*(const ModInt& x) const { return ModInt(*this) *= x; }
    ModInt operator/(const ModInt& x) const { return ModInt(*this) /= x; }
    ModInt pow(lint n) const {
        auto x = ModInt(1);
        auto b = *this;
        while (n > 0) {
            if (n & 1) x *= b;
            n >>= 1;
            b *= b;
        }
        return x;
    }

    // compound assignment
    ModInt& operator+=(const ModInt& x) {
        if ((val += x.val) >= MOD) val -= MOD;
        return *this;
    }
    ModInt& operator-=(const ModInt& x) {
        if ((val -= x.val) < 0) val += MOD;
        return *this;
    }
    ModInt& operator*=(const ModInt& x) {
        val = lint(val) * x.val % MOD;
        return *this;
    }
    ModInt& operator/=(const ModInt& x) { return *this *= x.inv(); }

    // compare
    bool operator==(const ModInt& b) const { return val == b.val; }
    bool operator!=(const ModInt& b) const { return val != b.val; }

    // I/O
    friend std::istream& operator>>(std::istream& is, ModInt& x) noexcept { return is >> x.val; }
    friend std::ostream& operator<<(std::ostream& os, const ModInt& x) noexcept { return os << x.val; }
};

constexpr int MOD = 1e9 + 7;
using mint = ModInt<MOD>;

void solve() {
    int n, m;
    std::cin >> n >> m;

    std::vector<int> cnts(n + 1, 0);
    for (int i = 1; i <= n; ++i) {
        cnts[i] = cnts[i - 1];
        char c;
        std::cin >> c;
        if (c == '1') ++cnts[i];
    }

    std::vector<int> to(n + 1);
    std::iota(to.begin(), to.end(), 0);
    while (m--) {
        int l, r;
        std::cin >> l >> r;
        to[l] = std::max(to[l], r);
    }

    for (int i = 1; i <= n; ++i) {
        to[i] = std::max(to[i], to[i - 1]);
    }

    std::vector<mint> dp(n + 1, 0);
    dp[0] = 1;
    // 1を何個使ったか
    auto ndp = dp;

    for (int i = 1; i <= n; ++i) {
        std::fill(ndp.begin(), ndp.end(), 0);

        for (int one = 0; one < i; ++one) {
            if (cnts[to[i]] - one) {
                ndp[one + 1] += dp[one];
            }
            if ((to[i] - cnts[to[i]]) - ((i - 1) - one)) {
                ndp[one] += dp[one];
            }
        }
        std::swap(dp, ndp);
    }

    std::cout << dp[cnts[n]] << std::endl;
}

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

    solve();

    return 0;
}


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

typedef long long ll;

map<ll,int> ma;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	ll ans = 0;
	for (int i = 1; i <= n; i++)
	{
		ll v;
		cin >> v;
		ans += ma[i-v];
		ma[i+v] ++;
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 25828
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL;
  typedef pair<ll,char> PLC;
  typedef pair<char,ll> PCL;

int main(void){
  int X;cin >> X;
  int ans = 1;
  for(int i = 2; i<=sqrt(X); i++){
    int x = i;
    while(x*i<=X)x*=i;
    if(x>ans) ans = x;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
inp = list(map(int, input().split()))

N = inp[0]
L = inp[1]

start = L
sum = 0
max_min = 99999999999
for i in range(N):
    x = start + i
    sum += x
    max_min = min(abs(x), max_min)

if sum < 0:
    sum += max_min
else:
    sum -= max_min

print(sum)
# print(max_min)


Measured memory_bytes: 3064
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

x = inn()
s = x//500
x -= s*500
print(s*1000+(x//5)*5)


Measured memory_bytes: 38256
#include<stdio.h>
#define MAX 101
#define WHITE 0
#define GRAY 1
#define BLACK 2

void dfs();
void visit(int );

int n, G[MAX][MAX], d[MAX], f[MAX], color[MAX], time=0;

int main()
{
  int i, j, u, k, v;

  scanf("%d", &n);
  for(i=0; i<=n; i++)
    {
      for(j=0; j<=n; j++)
	{
	  G[i][j] = 0;
	}
    }
  for(i=1; i<=n; i++)
    {
      scanf("%d %d", &u, &k);
      for(j=1; j<=k; j++)
	{
	  scanf("%d", &v);
	  G[u][v] = 1;
	}
      color[u] = WHITE;
    }

  dfs();

  for(i=1; i<=n; i++) printf("%d %d %d\n", i, d[i], f[i]);

  return 0;
}

void dfs()
{
  int i; 

  for(i=1; i<=n; i++)
    {
      if(color[i] == WHITE) visit(i);
    }
}

void visit(int u)
{
  int i;

  color[u] = GRAY;
  d[u] = ++time;

  for(i=1; i<=n; i++)
    {
      if(G[u][i] == 1 && color[i] == WHITE) 
	{
	  visit(i);
	}
    }
  color[u] = BLACK;
  f[u] = ++time;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793

int main(){
 double n,k;
 cin >> n >> k;
 double ans=0;
 for(double i=1;i<=n;i++){
  int a=0;
  int b=i;
  while(b<k){
    b*=2;
    a++;
  }
  ans+=1/pow(2,a);
 }
 ans/=n;
 cout << fixed << setprecision(12) << ans << endl;

}

Measured memory_bytes: 4092
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    for(int i=1;i<10;i++){
        for(int j=1;j<10;j++){
            if(n==j*i){
                cout << "Yes";
                return 0;
            }
        }
    }
    cout << "No";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvb std::vector<std::vector<bool> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  int N, S=0, ans;
  std::cin >> N;
  std::vector<int> A(N);
  for(int i=0;i<N;i++) {
    std::cin >> A[i];
    S += A[i];
  }
  ans = S;
  bitset<4000001> dp;
  dp.set(0);
  for(int i=0;i<N;i++){
    bitset<4000001> pd;
    pd = dp;
    pd |= dp << A[i];  //dp + A[i] || dp
    swap(dp, pd);
  }
  for(int i=(S+1)/2;i<4000001;i++) if(dp[i]){
    std::cout << i << '\n';
    return 0;
  }
  return 0;
}


Measured memory_bytes: 2296
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, A, B = mapint()
from collections import deque
if A+B-1>N or N>A*B:
    print(-1)
else:
    blocks = []
    blocks.append(' '.join(map(str, range(B, 0, -1))))
    now = B+1
    rest = N-A+2

    while now:
        if now>=rest:
            break
        if now+B>rest:
            blocks.append(' '.join(map(str, range(rest, now-1, -1))))
            rest += 1
            break
        blocks.append(' '.join(map(str, range(now+B-1, now-1, -1))))
        now = now+B
        rest += 1
    blocks.append(' '.join(map(str, range(rest, N+1))))
    print(' '.join(blocks))

Measured memory_bytes: 105872
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <stack>
#include <cmath>
#include <queue>
#include <numeric>



int main()
{
	std::string s, t;

	std::cin >> s >> t;

	std::vector<std::string> v;

	if (s.length() < t.length()) {
		std::cout << "UNRESTORABLE" << std::endl;
		return 0;
	}

	int count = 0;

	for (size_t i = 0; i <= s.length() - t.length(); i++)
	{
		std::string u = s;
		bool flag = true;
		for (size_t j = 0; j < t.length(); j++)
		{
			if (s[i + j] != '?' && s[i + j] != t[j]) {
				flag = false;
				break;
			}
			u[i + j] = t[j];
		}

		if (flag) {
			for (size_t j = 0; j < u.size(); j++)
			{
				if (u[j] == '?') {
					u[j] = 'a';
				}
			}
			v.push_back(u);
			count++;
		}
	}

	if (v.size() == 0) {
		std::cout << "UNRESTORABLE" << std::endl;
		return 0;
	}

	std::sort(v.begin(), v.end());

	std::cout << v[0] << std::endl;

	return 0;
}


Measured memory_bytes: 256
n = int(input())
a = [int(item) for item in input().split()]
b = [int(item) for item in input().split()]
c = [int(item) for item in input().split()]

ans = sum(b)
for p, q in zip(a, a[1:]):
    if p+1 == q:
        ans += c[p-1]
print(ans)

Measured memory_bytes: 3064
import sys
from math import factorial
from fractions import Fraction
import heapq, bisect
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
MOD = 10**9 + 7

n = INT()
s, t = input().split()

s = list(s)
t = list(t)

res = []
for i in range(n):
    res.append(s[i])
    res.append(t[i])
mojiretu = ''
for x in res:
    mojiretu += x

print(mojiretu)



Measured memory_bytes: 66028
//#pragma 03
//#pragma GCC optimization ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define ll long long
#define eb emplace_back
#define ef emplace_front
#define rep(i, x, n) for (int i = x; i < n; ++i)
#define mp make_pair
#define fi first
#define se second
#define ii pair<int, int>
#define endl '\n'
#define vi vector<int>
#define vii vector<pair<int, int>>
#define reverse(s) reverse(s.begin(), s.end())
#define ld long double
#define vs vector<string>
#define inf INT_MAX
#define vc vector<char>
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define vb vector<bool>
#define lb(a, x) lower_bound(a.begin(), a.end(), x)
#define ub(a, x) upper_bound(a.begin(), a.end(), x) 
#define vvi vector<vi>
#define mine(a) min_element(a.begin(),a.end())
#define maxe(a) max_element(a.begin(), a.end())
#define iota(a,i) iota(a.begin(),a.end(),i)
#define fileopen(filename) if (fopen(filename".INP", "r")) {freopen(filename".INP", "r", stdin);freopen(filename".OUT", "w", stdout);}
int n, root = 1;
vi a;
vvi adj;
void dfs(int x, int p) {
    if (adj[x].size() == 1) return;
    int sum = 0;
    for (int i : adj[x]) {
        if (i != p) {
            dfs(i, x);
            sum += a[i];
            if (a[i] > a[x]) {
                cout << "NO";
                exit(0);
            }
        }
    }
    int u = sum - a[x], v = a[x] - u;
    if (u < 0 || v < 0) {
        cout << "NO";
        exit(0);
    }
    a[x] = v;
}
signed main() {
    fastio;
    cin >> n;
    a.resize(n + 1);
    adj.resize(n + 1);
    rep(i, 1, n + 1) cin >> a[i];
    if (n == 2) {
        if (a[1] == a[2]) cout << "YES";
        else cout << "NO";
        return 0;
    }
    rep(i, 0, n - 1) {
        int x, y;
        cin >> x >> y;
        adj[x].emplace_back(y);
        adj[y].emplace_back(x);
        if (root == 1) {
            if (adj[x].size() > 1) root = x;
            if (adj[y].size() > 1) root = y;
        }
    }
    dfs(root, root);
    if (a[root]) cout << "NO";
    else cout << "YES";
}

Measured memory_bytes: 16900
#include <iostream>

using namespace std;

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

  int a_i, m;
  cin >> m;
  m &= (-m);
  for (int i = 1; i < N; ++i) {
    cin >> a_i;
    a_i &= (-a_i);
    if (a_i < m) m = a_i;
  }

  int res = 0;
  while (1 < m) {
    ++res;
    m >>= 1;
  }

  cout << res << endl;

  return 0;
}


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

int main()
{
	int n;
    cin>>n;
    int flag=0;
    while(n){
        int rem=n%10;
        if(rem==7) {
            flag=1;
            break;
        }
        n=n/10;
    }
    if(flag) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
	return 0;
}

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


int main()
{
    int n, k;
    scanf("%d %d", &n, &k);
    ll sum = 0;
    ll ans = 0;
    int ara[n];
    for(int i = 0; i<n; i++)
        scanf("%d", &ara[i]), ans += ara[i];

    for(int i = 0; i<k; i++)
        sum += ara[i];
    ll nwRest = 0;
    for(int i = k; i<n; i++)
        if(ara[i] > 0)nwRest += ara[i];
    ans = max(ans, nwRest);
    ans = max(ans, nwRest+sum);
    for(int i = k; i<n; i++)
    {
        sum -= ara[i-k] - ara[i];
        if(ara[i] > 0) nwRest -= ara[i];
        if(ara[i-k] > 0) nwRest += ara[i-k];
        ans = max(ans, nwRest);
        ans = max(ans, nwRest+sum);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N=0;
  cin>>N;
  vector<int>L(N);
  for(int i=0;i<N;i++){
    cin>>L.at(i);
  }
  int ans=0;
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      for(int k=j+1;k<N;k++){
        if(L.at(i)!=L.at(j)&&L.at(j)!=L.at(k)&&L.at(i)!=L.at(k)){
          ans++;
        int big;
        big=max(max(L.at(i),L.at(j)),L.at(k));
        if(big>=L.at(i)+L.at(j)+L.at(k)-big){
          ans--;
        }
        }
      }
    }
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
    using namespace std;
    template <typename T> void read(T &t) {
    	t=0; char ch=getchar(); int f=1;
    	while ('0'>ch||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
    	do {(t*=10)+=ch-'0';ch=getchar();} while ('0'<=ch&&ch<='9'); t*=f;
    }
    const int maxn=610;
    int n,m,x,lg;
    bool c[maxn][maxn];
    void solve() {
    	lg=0;
    	read(x);
    	while (x%4==0)
    		x/=4,lg++;
    	if (x%2==1) {
    		for (int i=0;i<2*n;i++)
    		for (int j=0;j<2*n;j++)
    			c[i][j]|=((i>>lg)+(j>>lg))&1;
    	} else {
    		for (int i=0;i<2*n;i++)
    			if (i&(1<<lg))
    				for (int j=0;j<2*n;j++) c[i][j]=1;
    	}
    }
    int main() {
    	//freopen("1.txt","r",stdin);
    	read(n);
    	solve();
    	solve();
    	int tot=0;
    	for (int i=0;i<2*n;i++)
    	for (int j=0;j<2*n;j++)
    		if (!c[i][j]) {
    			printf("%d %d\n",i,j);
    			tot++;
    			if (tot==n*n) return 0;
    		}
        return 0;
    }

Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <deque>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <iomanip>
using namespace std;

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

    array<int, 100010> pro;

    for(int i=0;i<num;i++){
        cin >> pro[i];
    }

    sort(pro.begin(),pro.begin()+num);

    cout << pro[num/2] - pro[num/2 -1] << endl;

    return 0;
}

Measured memory_bytes: 640
package main

import (
	"fmt"
	"math"
)

var N, ans int

func main() {
	fmt.Scan(&N)
	var i int = 1

	for i*i <= N {
		ans = i * i
		i++
	}
	fmt.Println(ans)
}

/*  ----------------------------------------  */

func combination(x, y int) int {
	return permutation(x, y) / permutation(y, y)
}

func permutation(x, y int) int {
	var ans int = 1
	for i := x - y; 0 < i; i-- {
		ans *= i
	}
	return ans
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }

type XY struct {
	x int
	y int
}
type SortBy []XY

func (a SortBy) Len() int      { return len(a) }
func (a SortBy) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool {
	if a[i].x == a[j].x {
		return a[i].y > a[j].y
	}
	return a[i].x > a[j].x
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using psi=pair<string,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define MOD (1e9+7)
void get(){}template<class H,class...T>void get(H&h,T&...t){cin>>h;get(t...);}
template<class T>void geti(T&a){for(auto&_:a)cin>>_;}
template<class T>void getii(T&a){for(auto&_:a)geti(_);}
void put(string d){}template<class H,class...T>void put(string d,H&h,T&...t){cout<<h;if(sizeof...(t))cout<<d;put(d,t...);}
template<class T>void puti(T&a,string d=" "){bool f=1;for(auto&_:a)cout<<(exchange(f,0)?"":d)<<_;cout<<endl;}
template<class T>void putii(T&a,string d=" "){for(auto&_:a)puti(_,d);}
#define dcl(...) ll __VA_ARGS__;get(__VA_ARGS__)
#define dclt(t,...) t __VA_ARGS__;get(__VA_ARGS__)

 
constexpr int gcd(int a,int b){return b?gcd(b,a%b):a;}
constexpr int lcm(int a,int b){return a*b/gcd(a,b);}


int main(){
	dclt(string,s);
	int ans=0;
	rep(i,s.size()-1){
	    ans+=s[i]!=s[i+1]?1:0;
	}
	cout<<ans<<endl;
}


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



long long dp[100][3000];

int main(){
	int n,x,a;
	cin >> n >> x;

	dp[0][0]=1;
	for(int i=0;i<n;i++){
		cin >> a;
		
		for(int j=i;j>=0;j--){
			for(int k=0;k<=50*j;k++){
				dp[j+1][k+a] += dp[j][k];
			}
		}
	}
	
	long long ans=0;
	for(int i=1;i<=n;i++) ans += dp[i][i*x];

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

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14 100兆
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

int main() {
  ll A, B, N;
  cin >> A >> B >> N;
  cout << floor(A*min(B-1, N)/B) << endl;
}

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

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

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

int main(){

    int n;

    cin >> n;

    vector<ll> a(n);

    for(int i=0;i<n;i++){
        cin>> a[i];
    }
    ll ans=a[0];
    
    for(int i=1;i<a.size();i++){
        ans=gcd(a[i],ans);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <climits>
using namespace std;
#define MOD int(1e9 + 7)
#define INF (long long)(1e18)

int main()
{
    long long N;
    vector<long long> A;
    map<long long, long long> c;

    cin >> N;
    A.push_back(0);
    c[0]++;
    for (long long i = 0; i < N; i++)
    {
        long long t;
        cin >> t;
        A.push_back(A[i] + t);
        c[A[i + 1]]++;
    }

    long long total = 0;
    for (auto x : c)
    {
        total += x.second * (x.second - 1);
    }

    cout << total / 2 << endl;
}

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

int main(){

  int N,M;

  cin>>N>>M;

  int l[100001],r[100001];

  int maxl=0;
  int minr=100001;
  
  for(int i=0;i<M;i++){
	cin>>l[i]>>r[i];

	maxl=max(l[i],maxl);
	minr=min(r[i],minr);
	
	
  }

  if(minr-maxl+1>=0){
	cout<<minr-maxl+1<<endl;
  }else{
	cout<<0<<endl;
  }
  
  return 0;
}


Measured memory_bytes: 1024
n, a, b = map(int, raw_input().split())

M = 10**9+7

F = [0]*(2*10**5+1)
F[0] = 1
for i in range(1, 2*10**5+1):
  F[i] = F[i-1]*i%M

def C(x, y):
  ans = 1
  for i in range(y):
    ans = ans*(x-i)%M
  return ans*pow(F[y], M-2, M)%M

ans = pow(2, n, M)-1
ans -= C(n, a)
ans -= C(n, b)

print ans%M


Measured memory_bytes: 15364
#include <bits/stdc++.h>
using namespace std;
int k,dis[100005];
int main() {
    cin>>k;
    deque<pair<int,int> > dq;
    for(int i=0;i<k;i++) dis[i]=1000000007;
    dis[1]=1;
    dq.push_back(make_pair(1,1));
    while (!dq.empty()) {
        pair<int,int> p=dq.front();dq.pop_front();
        if (p.first!=dis[p.second]) continue;
        int x=p.second;
        if (dis[x]<dis[(x*10)%k]) {
            dis[(x*10)%k]=dis[x];
            dq.push_front(make_pair(dis[(x*10)%k],(x*10)%k));
        }
        if (dis[x]+1<dis[(x+1)%k]) {
            dis[(x+1)%k]=dis[x]+1;
            dq.push_back(make_pair(dis[(x+1)%k],(x+1)%k));
        }
    }
    printf("%d\n",dis[0]);
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pp;

int main() {
    int N, M;
    cin >> N >> M;
    queue<int> A[300];
    for(int i=0; i<N; ++i) {
        for(int j=0; j<M; ++j) {
            int a;
            cin >> a;
            A[i].push(a - 1);
        }
    }

    vector<bool> K(M, true);
    int res = 1001001001;
    for(int j=M; j>0; ) {
        vector<int> S(M, 0);
        for(int i=0; i<N; ++i) {
            while(!K[A[i].front()]) A[i].pop();
            ++S[A[i].front()];
        }

        int tmp = *max_element(S.begin(), S.end());
        res = min(res, tmp);
        for(int k=0; k<M; ++k) {
            if(S[k] == tmp) {
                K[k] = false;
                --j;
            }
        }
    }

    cout << res << endl;
}

Measured memory_bytes: 768
local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})
read.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end
string.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end
string.split = function(s) local t={} for w in string.gmatch(s, "[^%s]+") do table.insert(t, w) end return (table.unpack or unpack)(t) end
local function array(dimension, default_val) assert(type(default_val) ~= 'table') local n=dimension local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end
----
local A = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j"}
local N = read.n()

local ans = {}
local build = {}
local function dfs(i, mx)
    if i == N then
        table.insert(ans, table.concat(build, ""))
    else
        for j=1,mx+1 do
            build[i+1] = A[j]
            dfs(i+1, math.max(j,mx))
        end
    end
end
dfs(0, 0, nil)
for i=1,#ans do
    print(ans[i])
end

Measured memory_bytes: 10104
use proconio::fastout;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
        a: usize,
        b: usize,
        c: usize,
        d: usize,
    }
    let taka = (a + d - 1) / d;
    let ao = (c + b - 1) / b;
    println!("{}", if taka >= ao { "Yes" } else { "No" });
}


Measured memory_bytes: 2172
#include "bits/stdc++.h"
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define int ll
//#define slld(t) scanf("%lld",&t)
//#define sd(t) scanf("%d",&t)
//#define pd(t) printf("%d\n",t)
//#define plld(t) printf("%lld\n",t)
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define pii pair < int , int >
#define pll pair < ll , ll > 
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define mod  1000000007
#define N   200005
#define MAX 300005
#define mod1 1000000007
#define mod2 998244353
#define bitcnt __builtin_popcount
#define PI acos(-1)
//#define endl "\n"
 
const int inf = (int)1e18 + 10;


signed main(){
  fast;
  

  int n;
  double ans  = 0.0, x;
  cin >> n;
  for(int i = 0 ; i < n ; i++){
        cin >> x;
        ans += (1.0 / x);
  }
  ans = 1.0 / ans;
  cout << fixed << setprecision(9) << ans << endl;


 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//#define int long long  
#define mod 1000000007
#define am 998244353
#define INFi 2147483647
#define INFl 9223372036854775807LL
#define fi first
#define se second
#define be begin()
#define en end()
int abs(int a,int b){ 
  int c=max(a,b)-min(a,b);
  return c;
}
int gcd(int a,int b){//最大公約数
  int c=a%b;
  while(true){
    if(c==0) break;
    a=b;
    b=c;
    c=a%b;
  }
  return b;
}
bool IsPrime(int num){
  if (num < 2) return false;
  else if (num == 2) return true;
  else if (num % 2 == 0) return false;
  double sqrtNum = sqrt(num);
  for(int i=3;i<=sqrtNum;i+=2){
    if(num%i==0){
      return false;
    }
  }
}
int lcm(int a,int b){//最小公倍数
    return (a*b)/gcd(a,b);
}	    
signed main(){
// __builtin_ctz(N);      Nを２で何回割り切れるかを返す
//(n+1)*n/2;              １からNまでの総和を求める式
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c,d;
    
    cin>>a>>b>>c>>d;
    if(a==c) cout<<"0";
    else cout<<"1";
    cout<<"\n";
    
}



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

using namespace std;

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

    int n;
    cin >> n;
    vector<int> h(n), dp(n);

    for (int i = 0; i < n; ++i) {
        cin >> h[i];
    }

    dp[0] = 0;
    dp[1] = abs(h[0] - h[1]);

    for (int i = 2; i < n; ++i) {
        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
    }

    cout << dp[n - 1] << '\n';

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long int ll;

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

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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

int main() {
  int n, m, c;
  cin >> n >> m >> c;
  int b[m];
  rep (j, m) {
    cin >> b[j];
  }
  int ans = 0;
  rep (i, n) {
    int sum = 0;
    rep (j, m) {
      int tmp;
      cin >> tmp;
      sum += tmp * b[j];
    }
    if (sum + c > 0) ans++;
  }
  P(ans);
  return 0;

}

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

int main()
{
  string b;
  cin >> b;
  if(b=="A") 	  cout << "T";
  else if(b=="T") cout << "A";
  else if(b=="G") cout << "C";
  else if(b=="C") cout << "G";
  
  return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use proconio::{fastout, input, marker::*};

#[fastout]
fn main() {
    input! {
        s: Chars,
        t: Chars,
    }
    let mut ans = 0;

    for i in 0..s.len() {
        if s[i] == t[i] {
            continue;
        }
        ans += 1;
    }

    println!("{}", ans);
}


Measured memory_bytes: 4052
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(num,init,name) vector<int> name((num),(init));
int d,g;
vec(10,0,bin);
vec(10,0,p);
vec(10,0,c);
int ans=INT_MAX;

void calc(){
    int tmp=0;
    int Tmp=0;
    rep(i,d){
        if(bin[i]==1){
            tmp+=p[i]*(i+1)*100+c[i];
            Tmp+=p[i];
        }
    }
    if(tmp>=g){
        ans=min(ans,Tmp);
    }else{
        for(int i=d-1;i>=0;i--){
            if(bin[i]==0){
                if(ceil((g-tmp)/(double)((i+1)*100))<p[i]){
                    Tmp+=ceil((g-tmp)/(double)((i+1)*100));
                    ans=min(ans,Tmp);
                }
                break;
            }
        }
    }
}

void dfs(int dep){
    if(dep==d){
        calc();
        return;
    }
    rep(j,2){
        bin[dep]=j;
        dfs(dep+1);
    }
}

int main(){
    
    cin>>d>>g;
    
    rep(i,d){
        cin>>p[i]>>c[i];
    }
    
    dfs(0);
    cout<<ans<<endl;
    return 0;


}



Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

//std::cout << std::fixed << std::setprecision(10)
constexpr long long MOD = 1000000007;

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

int N;
std::vector<std::string> ans;
void dfs(int n, char m, std::string& cur)
{
  if (n == N)
  {
    ans.push_back(cur);
    return;
  }
  for (char c = 'a'; c <= m; ++c)
  {
    cur[n] = c;
    dfs(n + 1, c == m ? m + 1 : m, cur);
  }
  return;
}

int main()
{
  std::cin >> N;
  std::string cur(N, 'a');
  dfs(0, 'a', cur);
  for (auto& val: ans)
    std::cout << val << "\n";
  std::cout << std::flush;
  return 0;
}



Measured memory_bytes: 7796
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		int h = sc.nextInt();
		int w = sc.nextInt();
		
		int x = H * W - (h * W + H * w - h * w);
		
		System.out.println(x);
		
	}
}


Measured memory_bytes: 23124
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int[] a = new int[5];
		
		for(int i = 0; i < 5; i++) a[i]=Integer.parseInt(sc.next());
		
		int k = Integer.parseInt(sc.next());

		System.out.println(a[a.length-1] - a[0] <= k ? "Yay!" : ":(");
		
	}
}


Measured memory_bytes: 23636
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef unsigned int uint;
typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 19;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

const int MX = 3005;

ll D[MX][MX], C[MX][MX];
int N, M;

ll pw(ll a, ll b, ll M){
	ll r = 1;
	while(b){
		if(b&1) r = r*a % M;
		a = a*a % M; b /= 2;
	}
	return r;
}

int main()
{
	scanf("%d%d", &N, &M);
	C[0][0] = 1;
	for(int i = 1; i < MX; i++){
		C[i][0] = 1;
		for(int j = 1; j <= i; j++) C[i][j] = (C[i-1][j-1] + C[i-1][j]) % M;
	}
	D[0][0] = 1;
	for(int i = 1; i <= N; i++){
		D[i][0] = 1;
		for(int j = 1; j <= i; j++){
			D[i][j] = (D[i-1][j-1] + D[i-1][j] * (1+j)) % M;
		}
	}
	ll ans = 0;
	for(int i = 0; i <= N; i++){
		ll tot = 0;
		for(int j = 0; j <= i; j++){
			ll m = pw(pw(2, N-i, M), j, M) * D[i][j] % M;
			tot = (tot + m) % M;
		}
		tot = tot * C[N][i] % M * pw(2, pw(2, N-i, M-1), M) % M;
		if(i%2 == 1) ans = (ans - tot + M) % M;
		else ans = (ans + tot) % M;
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 139520
n = int(input())
s = [input() for _ in range(n)]
d = {}

for i in s:
    d[i] = d.get(i, 0) + 1

d = sorted(d.items(), key=lambda x: x[1], reverse=True)
maxv = d[0][1]
ans = []
for s in d:
    if s[1] == maxv:
        ans.append(s[0])
    else:
        break

for p in sorted(ans):
    print(p)


Measured memory_bytes: 49184
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    string N;
    cin >> N;
    ll sum = 0;
    for(int i = 0; i < N.size(); i++) {
        sum += stoi(N.substr(i, 1));
    }
    if(sum % 9 == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3752
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner scan = new Scanner(System.in);

	/* 入力 */
	String s = scan.next();
	s = s.substring(0,s.length()-1);

	while(true){
	    if(s.length() % 2 == 1){
		s = s.substring(0,s.length()-1);
	    }else{
		String sub1 = s.substring(0,s.length()/2);
		String sub2 = s.substring(s.length()/2, s.length());
		if(sub1.equals(sub2)){
		    break;
		}else{
		    s = s.substring(0,s.length()-2);
		}
	    }
	}

	System.out.println(s.length());
    }
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
#define MD 1000000007
#define INF 1000000000
typedef long long int ll;
typedef pair<ll,ll> P;
template <typename T> std::string tostr(const T& t){std::ostringstream os; os<<t; return os.str();}
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
 
int main(){ 
    string s,ans="First";
    cin>>s;
    if((s.length()%2==0) != (s[0]==s[s.length()-1])){
        ans="Second";
    } 
    cout<< ans <<endl;
    return 0;
}

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

const int N =1e6;
bool prime[N];

int main()
{
    int n;
    cin>>n;
    int arr[n+5];

    bool tr=false;
    bool kp=false;

   // memset(prime,false,sizeof prime);
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        if(arr[i]>0)tr=true;
        if(arr[i]==0)kp=true;
       if(!prime[arr[i]]) prime[arr[i]]=true;
       else if(prime[arr[i]]&&arr[i]>1)tr=false;
    }

   for(int i=0;i<=N;i++)
   {
       if(i==1||i==0)continue;
      int cnt=0;
      for(int j=i;j<=N;j+=i)
      {
          if(prime[j])cnt++;
      }
      if(cnt>=2)tr=false;
   }

   if(tr&&!kp)
   {
       cout<<"pairwise coprime"<<endl;
       return 0;
   }

   int k=arr[0];

   for(int i=0;i<n;i++)
   {
       k=__gcd(k,arr[i]);
   }

   if(k==1)
   {
       cout<<"setwise coprime"<<endl;
   }
   else
   {
       cout<<"not coprime"<<endl;
   }

}


Measured memory_bytes: 8348
/*
 * Aizu Online Judge 2015
 *   Square Route
 *
 * author : Yohei Ito
 * date : 2010/06/04
 * time : 20:27
 * memo :
 *   Å, ðàPDFÅ¾íêÄ¢éÆ±ëÌWOUOÌð@ÅâÁÄÝ½ª,
 *   å«¢ÉÏ¦çê¸, ^C~bgÅøÁ©©Á½.
 *   ðàPDFÅÅàI[_[ª¬³¢àÌðIñÅ,
 *   JjOµÈªçð­`ÆÈÁ½.
 */
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		while(true){
			int n = sc.nextInt(), m = sc.nextInt();
			if(n == 0 && m == 0) break;

			int[] x = new int[n+1], y = new int[m+1];
			x[0] = y[0] = 0;

			for(int i=0;i<n;i++){
				int h = sc.nextInt();
				x[i+1] = x[i] + h;
			}
			for(int i=0;i<m;i++){
				int w = sc.nextInt();
				y[i+1] = y[i] + w;
			}

			HashMap<Integer,Integer> map = new HashMap<Integer,Integer>();

			for(int i=0;i<n+1;i++){
				for(int j=0;j<m+1;j++){
					Integer value = map.get(y[j] - x[i]);
					map.put(y[j]-x[i], value==null ? 1 : value+1);
				}
			}

			int count = 0;
			for(Integer key : map.keySet()){
				int value = map.get(key);
				count += value * (value - 1) / 2;
			}
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 44000
// AOJ 2501: Grid Mori
// 2017.10.13 bal4u@uu

#include <stdio.h>
//#include <stdlib.h>
#include <math.h>

#define ABS(a) ((a)>=0?(a):-(a))

int main()
{
	int n, a, b, c, d, ans;
	int t, w, r1, c1, r2, c2;

	scanf("%d%d%d%d%d", &n, &a, &b, &c, &d);
	ans = ABS(a-b) + ABS(c-d); a--, b--, c--, d--;
	for (w = 2; w < n; w++) {
		r1 = a/w, c1 = a%w;
		r2 = b/w, c2 = b%w;
		if ((t = ABS(r2-r1) + ABS(c2-c1)) > ans) continue;
		r1 = c/w, c1 = c%w;
		r2 = d/w, c2 = d%w;
		t += ABS(r2-r1) + ABS(c2-c1);
		if (t < ans) ans = t;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1828
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
#define si short int
#define MAX 101
si f[MAX][MAX][MAX][MAX],s[MAX][MAX];
si sum(int a,int b,int c,int d)
{
	if(a>c)swap(a,c);if(b>d)swap(b,d);
	return s[c][d]-s[a-1][d]-s[c][b-1]+s[a-1][b-1];
}
si n,m,X,Y,ans;
char g[MAX][MAX];
void upd(si &x,si y){if(x<y)x=y;}
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;++i)scanf("%s",g[i]+1);
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
			if(g[i][j]=='E')X=i,Y=j;
			else if(g[i][j]=='o')s[i][j]=1;
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
			s[i][j]+=s[i-1][j]+s[i][j-1]-s[i-1][j-1];
	for(int a=X;a;--a)
		for(int b=Y;b;--b)
			for(int c=X;c<=n;++c)
				for(int d=Y;d<=m;++d)
				{
					ans=max(ans,f[a][b][c][d]);
					int L=d-Y+1,R=m-Y+b,U=c-X+1,D=n-X+a;
					if(a>U)upd(f[a-1][b][c][d],f[a][b][c][d]+sum(a-1,max(b,L),a-1,min(d,R)));
					if(b>L)upd(f[a][b-1][c][d],f[a][b][c][d]+sum(max(a,U),b-1,min(c,D),b-1));
					if(c<D)upd(f[a][b][c+1][d],f[a][b][c][d]+sum(c+1,max(b,L),c+1,min(d,R)));
					if(d<R)upd(f[a][b][c][d+1],f[a][b][c][d]+sum(max(a,U),d+1,min(c,D),d+1));
				}
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using ld = long double;
using pll = pair<ll, ll>;


int main() {
#ifdef LOCAL
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    cout.setf(ios::fixed);
    cout.precision(12);
    int H, W, h, w;
    cin >> H >> W >> h >> w; 
    ll mul = (ll)1e9 / (w * h);
    vector<vector<ll>> ans(H, vector<ll>(W, mul));
    for (int i = h - 1; i < H; i += h)
        for (int j = w - 1; j < W; j += w)
            ans[i][j] = -(w * h - 1) * mul - 1;
    ll sum = 0;
    for (int i = 0; i < H; i++)
        sum += accumulate(ans[i].begin(), ans[i].end(), 0ll);
    if (sum <= 0) {
        cout << "No\n";
        return 0;
    }
    cout << "Yes\n";
    for (auto row : ans) {
        for (int x : row)
            cout << x << " ";
        cout << "\n";
    }
}

Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
const int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<typename T >inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }


void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);

    int T;
    // cin >> T;
    T = 1;

    while (T--) {
        solve();
    }
}

void solve() {
  vector<ll> x;
  rep3(i, 1, 100000) {
    x.eb(1LL * i * i);
  }
  int n;
  cin >> n;
  
  int it = ub(x, n);
  it--;
  cout << x[it] << endl;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A , B , C , D , E , F , G , H , I , N;
  cin >> A >> B >> C >> D >> E >> F >> G >> H >> I >> N;
  int O , P , Q , R , S , T , U , V , W;
  O = 0;
  P = 0;
  Q = 0;
  R = 0;
  S = 0;
  T = 0;
  U = 0;
  V = 0;
  W = 0;
  for ( int i = 0 ; i < N ; i++ ) {
    int J;
    cin >> J;
    if ( A == J ) {
      O = 1;
    }
    if ( B == J ) {
      P = 1;
    }
    if ( C == J ) {
      Q = 1;
    }
    if ( D == J ) {
      R = 1;
    }
    if ( E == J ) {
      S = 1;
    }
    if ( F == J ) {
      T = 1;
    }
    if ( G == J ) {
      U = 1;
    }
    if ( H == J ) {
      V = 1;
    }
    if ( I == J ) {
      W = 1;
    }
  }
  int answer;
  answer = 0;
  if ( O == 1 && P == 1 && Q == 1 ) {
    answer = 1;
  }
  if ( R == 1 && S == 1 && T == 1 ) {
    answer = 1;
  }
  if ( U == 1 && V == 1 && W == 1 ) {
    answer = 1;
  }
  if ( O == 1 && R == 1 && U == 1 ) {
    answer = 1;
  }
  if ( P == 1 && S == 1 && V == 1 ) {
    answer = 1;
  }
  if ( Q == 1 && T == 1 && W == 1 ) {
    answer = 1;
  }
  if ( O == 1 && S == 1 && W == 1 ) {
    answer = 1;
  }
  if ( Q == 1 && S == 1 && U == 1 ) {
    answer = 1;
  }
  if ( answer == 0 ) {
    cout << "No" << endl;
  }
  if ( answer == 1 ) {
    cout << "Yes" << endl;
  }
}

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

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

int main() {
    int x, y; cin >> x >> y;
    if(x == 2 && y == 2){
        cout << "Yes" << endl;
        return 0;
    }
    int a[] = {4, 6, 9, 11};
    bool xf = false, yf = false;
    for(int i = 0; i < 4; i++){
        if(x == a[i]) xf = true;
        if(y == a[i]) yf = true;
    }
    if(xf && yf){
        cout << "Yes" << endl;
        return 0;
    }
    int b[] = {1, 3, 5, 7, 8, 10, 12};
    xf = false, yf = false;
    for(int i = 0; i < 7; i++){
        if(x == b[i]) xf = true;
        if(y == b[i]) yf = true;
    }
    if(xf && yf){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
//#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;

int  main(){
  int k,t;
  cin>>k>>t;
  vector<int> a(t);
  rep(i,t)cin>>a[i];
  sort(all(a));
  cout<<max(a[t-1]*2-1-k,0)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define INF 1000000000
#define MOD 1000000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
int main(void){
    int n,a,b;
    cin>>n>>a>>b;
    int p[n];
    for(int i=0;i<n;i++){
        cin>>p[i];
    }
    int x=0,y=0,z=0;
    for(int i=0;i<n;i++){
        if(p[i]<=a){
            x++;
        }else if(a<p[i] and p[i]<=b){
            y++;
        }else{
            z++;
        }
    }
    cout<<min(x,min(y,z))<<endl;
 return 0;   
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	private Scanner sc;
	
	public static void main(String[] args) {
		new Main();
	}
	
	public Main() {
		sc = new Scanner(System.in);

		while (sc.hasNext() == true) {
			String line = sc.nextLine();
			
			int tmp = 0;
			int state = 0;

			int number = 0;
			for (int i = 0; i < line.length(); i++) {
				switch (line.charAt(i)) {
				case 'I':
					tmp = 1;
					break;
				case 'V':
					tmp = 5;
					break;
				case 'X':
					tmp = 10;
					break;
				case 'L':
					tmp = 50;
					break;
				case 'C':
					tmp = 100;
					break;
				case 'D':
					tmp = 500;
					break;
				case 'M':
					tmp = 1000;
					break;
				}
				
				if ((state != 0) && (tmp > state)) {
					number = number + tmp - state * 2;
					state = 0;
				} else {
					number = number + tmp;
					if ((tmp == 1) || (tmp == 10) || (tmp == 100) || (tmp == 1000)) state = tmp;
				}
			}
			
			System.out.println(number);
		}
	}
}

Measured memory_bytes: 25912
#include<cstdio>
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
typedef long long ll;
const int maxn=100000+10,mo=1000000007;
ll a[maxn],A,B;
int tree[maxn*4],f[maxn];
int i,j,k,l,r,t,n,m,ans;
void change(int p,int l,int r,int a,int b){
	if (l==r){(tree[p]+=b)%=mo;return;}
	int mid=(l+r)/2;
	if (a<=mid) change(p*2,l,mid,a,b);
	else change(p*2+1,mid+1,r,a,b);
	tree[p]=(tree[p*2]+tree[p*2+1])%mo;
}
int query(int p,int l,int r,int a,int b){
	if (a>b) return 0;
	if (l==a&&r==b) return tree[p];
	int mid=(l+r)/2;
	if (b<=mid) return query(p*2,l,mid,a,b);
	else if (a>mid) return query(p*2+1,mid+1,r,a,b);
	else return (query(p*2,l,mid,a,mid)+query(p*2+1,mid+1,r,mid+1,b))%mo;
}
int main(){
	scanf("%d%lld%lld",&n,&A,&B);
	if (A<B) swap(A,B);
	fo(i,1,n)scanf("%lld",&a[i]);
	a[0]=-A;a[n+1]=a[n]+A;f[0]=1;
	change(1,0,n,0,f[0]);l=0;r=0;
	fo(i,1,n+1){
		while (a[i]-a[r+1]>=A) r++;
		if (i>=2&&a[i-1]-a[i-2]<B) l=i-2;
		if (a[i]-a[i-1]>=A) f[i]=f[i-1];
		(f[i]+=query(1,0,n,l,min(i-2,r)))%=mo;
		if (i<=n&&a[i+1]-a[i-1]>=B) change(1,0,n,i,f[i]);
	}
	ans=f[n+1];
	(ans+=mo)%=mo;
	printf("%d\n",ans);
}

Measured memory_bytes: 2304
#include <iostream>
using namespace std;
int main()
{
	int a,b,num=0;
	cin>>a>>b;
	for(int i=a;i<=b;i++)
		if(i/10000==i%10 && (i/1000)%10==(i%100)/10)
			num++;
	cout<<num<<endl;
	return 0;
}

Measured memory_bytes: 256