akhauriyash/Code-Regression huggingface dataset:
#ifdef __APPLE__
#include <cassert>
#include <iostream>
#include <iomanip>
#include <ctime>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <string>
#include <cstring>
#include <sstream>
#include <map>
#include <set>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <cctype>
#include <list>
#include <cmath>
#include <limits>
#include <bitset>
#include <numeric>
#include <climits>
#include <complex>
#else
#include<bits/stdc++.h>
#endif // __APPLE__
using namespace std;
typedef pair<int,int>   II;
typedef vector<II>     VII;
typedef vector<int>     VI;
typedef vector< VI > 	VVI;
typedef long long int LL;
typedef  unsigned long long int ULL;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define SET(a,b) memset(a,b,sizeof(a))
#define LET(x,a) __typeof(a) x(a)
#define ALL(c) (c).begin(),(c).end()
#define si(n) scanf("%d",&n)
#define dout(n) printf("%d\n",n)
#define sll(n) scanf("%lld",&n)
#define lldout(n) printf("%lld\n",n)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
#define REP(i,a,b) for(int i = (int)a; i < (int)b; i++)
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1)	{
cerr << name << " : " << arg1 << std::endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
     const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);}
#else
#define trace(...)
#endif
//B




string a[55],b[55];
int n,m;
bool check(int x,int y)
{
    if(n-x<m || n-y<m)
        return false;
    
    bool ok=true;
    REP(i,0,m)
    {
        REP(j,0,m)
        {
            if(a[x+i][y+j]!=b[i][j])
                ok=false;
        }
    }
    return ok;
}
int main()
{
	//fr;fw;
	fast_io;
    cin>>n>>m;
    
    REP(i,0,n)
    {
        cin>>a[i];
    }
    REP(i,0,m)
    {
        cin>>b[i];
    }
    
    if(m>n)
    {
        cout<<"No"<<endl;
        return 0;
    }
    bool ok=false;
    REP(i,0,n)
    {
        REP(j,0,n)
        {
            if(check(i,j))
                ok=true;
        }
    }
    if(ok)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;



	return 0;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define SZ(v) ((int)(v).size())
#define zero(v) memset(v,0,sizeof(v))
#define rep(i,n) for(int i=0;i<(n);i++)
#define foreach(it,c) for(__typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define all(v) (v).begin(),(v).end()
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
typedef long long ll;
typedef unsigned uint;
const int INF=0x3f3f3f3f;
const double EPS=1e-10;
typedef pair<int,int>P;
int inline in(){int x=0,c;for(;(uint)((c=getchar())-'0')>=10;)
{if(c=='-')return -in();if(!~c)throw ~0;}do{x=(x<<3)+(x<<1)+(c-'0');}
while((uint)((c=getchar())-'0')<10);return x;}
int n,m,k;
const int Maxn=10;
const int Maxm=1000;
string s[Maxn];
int ans=INF;
int main(){
	cin>>n>>m>>k;
	rep(i,n){
		cin>>s[i];
		rep(j,m){
			s[i][j]-='0';
		}
	}
	vector<int>v;
	for(int mask=0;mask<(1<<(n-1));mask++){
		int cnt=0;
		bool ok=true;
		for(int j=0;j<m;j++){
			v.clear();
			v.push_back(0);
			for(int i=0;i<n;i++){
				v[SZ(v)-1]+=s[i][j];
				if(mask>>i&1)v.push_back(0);
			}
			for(int x:v){
				if(x>k){
					ok=false;break;
				}
			}
			if(!ok)break;
		}
		if(!ok)continue;
		v.clear();
		v.push_back(0);
//		cout<<"mask:"<<mask<<endl;
		
		for(int i=0;i<n;i++){
			v[SZ(v)-1]+=s[i][0];
			if(mask>>i&1)v.push_back(0);
		}
//		for(int x:v)cout<<x<<' ';cout<<endl;
		for(int j=1;j<m;j++){
			vector<int>tmp;
			tmp.push_back(0);
			for(int i=0;i<n;i++){
				tmp[SZ(tmp)-1]+=s[i][j];
				if(mask>>i&1)tmp.push_back(0);
			}
			bool change=false;
			for(int p=0;p<SZ(tmp);p++){
				if(v[p]+tmp[p]>k){
					cnt++;
					change=true;
					break;
				}
			}
			if(change)v=tmp;
			else{
				for(int p=0;p<SZ(tmp);p++){
					v[p]+=tmp[p];
				}
			}
		}
		cnt+=__builtin_popcount(mask);
		if(ans>cnt){
//			cout<<"mask:"<<mask<<endl;
//			cout<<"cnt:"<<cnt<<endl;
//			cout<<endl;
			ans=cnt;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

class UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<int> size;
    vector<vector<int>> group;
public:
    UnionFind(int n = 1) {
        par.resize(n + 1);
        rank.resize(n + 1);
        size.resize(n + 1);
        group.resize(n + 1);
        for (int i = 0; i <= n; ++i) {
            par[i] = i;
            rank[i] = 0;
            size[i] = 1;
            group[i].push_back(i);
        }
    }

    int find(int x) {
        if (par[x] == x) {
            return x;
        } else {
            int r = find(par[x]);
            return par[x] = r;
        }
    }

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

    bool unit(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) {
            return false;
        } else {
            if (rank[x] < rank[y]) {
                swap(x, y);
            }
            if (rank[x] == rank[y]) {
                ++rank[x];
            }
            par[y] = x;
            size[x] += size[y];
            return true;
        }
    }

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

    void merge(int x, int y) {
        x = find(x);
        y = find(y);
        if (group[x].size() > group[y].size()) {
            swap(x, y);
        }
        copy(group[y].begin(), group[y].end(), back_inserter(group[x]));
        group[y].clear();
        par[y] = x;
    }
};

void solve() {
    ll N, M;
    cin >> N >> M;
    UnionFind unionFind(N);
    rep(i, M) {
        ll x, y, z;
        cin >> x >> y >> z;
        x--;
        y--;
        unionFind.unit(x, y);
    }
    set<ll> root;
    rep(i, N) {
        root.insert(unionFind.find(i));
    }
    cout << root.size() << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 11648
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

#define M_PI       3.14159265358979323846

using namespace std;

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

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

std::string pad(int num)
{
    char buffer[4];
    std::snprintf(buffer, sizeof(buffer), "%03d", num);
    return buffer;
}

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

struct Hashing {
    ull seed, mod;
    vector <ull> hs, pw;

    Hashing(ull seed = 31, ull mod = 1000173169) :
        seed(seed),
        mod(mod) {}

    void build(int n, const string& s) {
        hs.assign(n + 1, 0);
        pw.assign(n + 1, 1);
        pw[0] = 1;

        for (int i = 1; i <= n; ++i)
            pw[i] = pw[i - 1] * seed % mod;
        for (int i = 1; i <= n; ++i)
            hs[i] = (hs[i - 1] * seed + s[i]) % mod;
    }

    ull hash(int l, int r) {
        return (hs[r] - hs[l - 1] * pw[r - l + 1] % mod + mod) % mod;
    }
};

int solve()
{
    int n, k;
    cin >> n >> k;

    vector<int> v = fetch_vec<int>(n);
    vector<double> tmp(n);

    for (int i = 0; i < n; ++i) {
        tmp[i] = static_cast<double>(v[i] * (v[i] + 1) / 2.0) / v[i];
    }

    double res = 0.0;
    
    for (int i = 0; i < k; ++i)
        res += tmp[i];

    double resMax = res;

    for (int i = k; i < n; ++i) {
        res = res + tmp[i] - tmp[i-k];

        resMax = std::max(resMax, res);
    }

    cout << std::fixed  << std::setprecision(12) << resMax << endl;

    return 0;
}

int main()
{
    solve();

    return 0;
}

Measured memory_bytes: 2560
def main():
    n = int(input())
    s = [int(input()) for _ in range(n)]
    print(solve(s))

def solve(s):
    t = sum(s)
    if t % 10 != 0:
        return t
    
    for c in sorted(s):
        if c % 10 != 0:
            return t - c
    
    return 0

main()


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

int main(){
    string s; cin >> s;
    int cnt = 0;
    rep(i,s.size()) if(s[i] == 'x') cnt++;
    if(cnt >= 8){
        cout << "NO" << endl;
    }else{
        cout << "YES" << endl;
    }
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define x first
#define y second
typedef long long LL;
typedef pair<int, int> PII;
int n, m, k, ans, x, y, z;

int main(){
	ios::sync_with_stdio(false); cin.tie(nullptr);
	cin >> n >> m >> k;
	vector<int> a(n), b(m);
	for(int i = 0; i < n; ++ i) cin >> a[i];
	for(int i = 0; i < m; ++ i) cin >> b[i];
	ans = *min_element(all(a)) + *min_element(all(b));
	while(k -- ){
		cin >> x >> y >> z;
		-- x, -- y;
		if(ans > max(0, a[x] + b[y] - z)) ans = max(0, a[x] + b[y] - z);
	}
	cout << ans << '\n';
	return 0;
}

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

signed main(void)
{
	char c;
	cin >> c;
	if (c == 'A') cout << 'T';
	else if (c == 'T') cout << 'A';
	else if (c == 'C') cout << 'G';
	else if (c == 'G') cout << 'C';
	cout << endl;
	return 0;
}


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

const int MOD = (int)1e9+7;

int main(){
  long long N,A,B,C;
  cin >> N >> A >> B >> C;
  vector<long long> l(N);
  for(int i=0;i<N;i++)  cin >> l.at(i);

  long long ans=1e18;
  for(int bit=0;bit<(1<<(N*2));bit++){
    long long cost=0;
    vector<long long> a;
    vector<long long> b;
    vector<long long> c;
    for(int i=0;i<N*2;i+=2){
      if((bit&(1<<i)) && (bit&(1<<(i+1))))  c.push_back(i/2);
      else if((!(bit&(1<<i))) && (bit&(1<<(i+1))))  b.push_back(i/2);
      else if((bit&(1<<i)) && (!(bit&(1<<(i+1)))))  a.push_back(i/2);
    }
    if(a.size()==0 || b.size()==0 || c.size()==0) continue;
    
    long long ax=0;
    long long bx=0;
    long long cx=0;
    for(int i=0;i<a.size();i++){
      ax+=l.at(a.at(i));
      if(i!=0)  cost+=10;
    }
    for(int i=0;i<b.size();i++){
      bx+=l.at(b.at(i));
      if(i!=0)  cost+=10;
    }
    for(int i=0;i<c.size();i++){
      cx+=l.at(c.at(i));
      if(i!=0)  cost+=10;
    }
    cost=cost+abs(ax-A)+abs(bx-B)+abs(cx-C);
    ans=min(ans,cost);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

		boolean bool = b-a < k * 2;
		if(bool){
			for(int i = a; i <=b;i++){
				System.out.println(i);
			}
		}else{
			for(int i = a; i < a+k;i++){
				System.out.println(i);
			}
			for(int i = b-k+1;i <= b;i++){
				System.out.println(i);
			}
		}
	}
}


Measured memory_bytes: 21972
#include<iostream>
using namespace std;
int N;
int main(){
    cin >> N;
    if(N < 1200){
        cout << "ABC" << endl;
    }else if(N >= 1200 && N < 2800){
        cout << "ARC" << endl;
    }else if(N >= 2800){
        cout << "AGC" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
//#define NDEBUG
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <utility>
#include <vector>

namespace n91 {

using i8 = std::int_fast8_t;
using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u8 = std::uint_fast8_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

struct rep {
  struct itr {
    usize i;
    constexpr itr(const usize i) noexcept : i(i) {}
    void operator++() noexcept { ++i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  const itr f, l;
  constexpr rep(const usize f, const usize l) noexcept
      : f(std::min(f, l)), l(l) {}
  constexpr auto begin() const noexcept { return f; }
  constexpr auto end() const noexcept { return l; }
};
struct revrep {
  struct itr {
    usize i;
    constexpr itr(const usize i) noexcept : i(i) {}
    void operator++() noexcept { --i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  const itr f, l;
  constexpr revrep(const usize f, const usize l) noexcept
      : f(l - 1), l(std::min(f, l) - 1) {}
  constexpr auto begin() const noexcept { return f; }
  constexpr auto end() const noexcept { return l; }
};
template <class T> auto md_vec(const usize n, const T &value) {
  return std::vector<T>(n, value);
}
template <class... Args> auto md_vec(const usize n, Args... args) {
  return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> constexpr T difference(const T &a, const T &b) noexcept {
  if (a < b) {
    return b - a;
  } else {
    return a - b;
  }
}
template <class T> void chmin(T &a, const T &b) noexcept {
  if (b < a) {
    a = b;
  }
}
template <class T> void chmax(T &a, const T &b) noexcept {
  if (a < b) {
    a = b;
  }
}
template <class F> class fix_point : private F {
public:
  explicit constexpr fix_point(F &&f) : F(std::forward<F>(f)) {}

  template <class... Args>
  constexpr decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, std::forward<Args>(args)...);
  }
};
template <class F> constexpr decltype(auto) make_fix(F &&f) {
  return fix_point<F>(std::forward<F>(f));
}
template <class T> T scan() {
  T ret;
  std::cin >> ret;
  return ret;
}

} // namespace n91

#include <algorithm>
#include <iostream>
#include <utility>

namespace n91 {

void main_() {
  /*
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  //*/
  const u32 n = scan<u32>();
  for (u32 i = 0; i <= n; i += 1) {
    if (i * 108 / 100 == n) {
      std::cout << i << std::endl;
      return;
    }
  }
  std::cout << ":(" << std::endl;
  return;
}

} // namespace n91

int main() {
  n91::main_();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
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);
  
  lint a,b,c,d; 
  cin >> a >> b >> c >>d;
  
  lint e;
  e = c*d/__gcd(c,d);
  
  lint kekka1;
  kekka1 = b-b/c-b/d+b/e;
  
  lint kekka2;
  if(a==1) kekka2=0;
  else kekka2 = (a-1)-(a-1)/c-(a-1)/d+(a-1)/e;
 
  cout << kekka1-kekka2 << '\n';
}

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

int main() {
  static int p[] = {64, 32, 16, 8, 4, 2, 1};
  int n, i = 0;
  cin >> n;

  while (n < p[i]) ++i;

  cout << p[i] << endl;

  return 0;
}

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

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

    int series[32] = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
                      1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    int idx;
    cin >> idx;
    cout << series[idx - 1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <iostream>

using namespace std;

struct Point {
    double x, y;
    Point() {}
    Point(double x, double y) : x(x), y(y) {}
    Point operator+(const Point& p) const { return Point(x + p.x, y + p.y); }
    Point operator-(const Point& p) const { return Point(x - p.x, y - p.y); }
    Point operator*(double k) const { return Point(k * x, k * y); }
    Point operator/(double k) const { return Point(x / k, y / k); }
};
double dot(const Point& a, const Point& b) { return a.x * b.x + a.y * b.y; }
double cross(const Point& a, const Point& b) { return a.x * b.y - a.y * b.x; }
double norm(const Point& a) { return sqrt(dot(a, a)); }
Point rot90(const Point& p) { return Point(p.y, -p.x); } // 時計回りに90度回転 
ostream& operator<<(ostream& os, const Point& p) { return os << "(" << p.x << "," << p.y << ")"; }

struct Line {
    Point a, b;
    Line() {}
    Line(const Point& a, const Point& b) : a(a), b(b) {}
};

Point projection(const Line& l, const Point& p) {
    Point u = (p - l.a), v = (l.b - l.a);
    return l.a + (v / norm(v)) * (dot(u, v) / norm(v));
}

int main() {
    Line l;
    scanf("%lf %lf %lf %lf\n", &l.a.x, &l.a.y, &l.b.x, &l.b.y);
    int Q; scanf("%d\n", &Q);
    for (int i = 0; i < Q; i++) {
        Point p; scanf("%lf %lf\n", &p.x, &p.y);
        Point x = projection(l, p);
        printf("%.12lf %.12lf\n", x.x, x.y);
    }
    return 0;
}

Measured memory_bytes: 1256
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 30;
const int MOD = 1e9 + 7;

int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  sort(a.begin(), a.end());
  int ret = 0;
  for (int i = 0, j, k; i < n; i = j) {
    for (j = i; j < n && a[j] == a[i]; ++j);
    for (k = j; k < n && a[k] <= a[i] + 2; ++k);
    ret = max(ret, k - i);
  }
  printf("%d\n", ret);
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

int main() {
    int n; cin >> n;
    vector<int> ar(1000000,0);
    repp(i,105,1) repp(j,105,1) repp(k,105,1){
        ar[i*j+j*k+k*i+i*i+j*j+k*k]++;
    }
    rep(i,n) cout << ar[i+1] << endl;
}

Measured memory_bytes: 7216
// AOJ 0587
#include <iostream>

using namespace std;

int main(void)
{
	int s, n, a, b;
	cin >> n >> s;

	int ret = s;
	for (int i = 0; i < n; i++){
		cin >> a >> b;
		s += a;
		s -= b;
		if (ret != -1) ret = max(ret, s);
		if (s < 0) ret = -1;
	}

	if (ret == -1) cout << 0 << endl;
	else cout << ret << endl;

	return 0;
}

Measured memory_bytes: 1160
{-# OPTIONS_GHC -Wall -Werror #-}

import Text.Printf
import System.IO

fixZero :: Float -> Float
fixZero x = if x == 0 then 0.0 else x

main :: IO ()
main = do
  end <- isEOF
  if end then return ()
         else do
           input <- getLine
           let a:b:c:d:e:f:_ = map read $ words input :: [Float]
               det = (a * e - d * b)
               x = fixZero $ (c * e - f * b) / det
               y = fixZero $ (a * f - d * c) / det
           printf "%.3f %.3f\n" x y
           main

Measured memory_bytes: 4464
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <bitset>
#include <vector>
#include <queue>
#include <map>

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define sort(vvv) sort(vvv.begin(),vvv.end())
#define rvs(vvv) reverse(vvv.begin(),vvv.end())

using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int s = a + b + c;
	if (s > 21) {
		cout << "bust" << endl;
	}
	else cout << "win" << endl;
	return 0;
}

Measured memory_bytes: 256
package main

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

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return &Scanner{sc}
}

func (sc *Scanner) NextInt() int {
	sc.sc.Scan()
	i, err := strconv.Atoi(sc.sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func main() {
	sc := NewScanner()

	n := sc.NextInt()
	m := sc.NextInt()

	mp := map[int]int{}
	for i := 0; i < n; i++ {
		mp[sc.NextInt()]++
	}
	for i := 0; i < m; i++ {
		mp[sc.NextInt()]++
	}
	var and, or []int
	for k, v := range mp {
		if v >= 1 {
			or = append(or, k)
		}
		if v == 2 {
			and = append(and, k)
		}
	}
	sort.Ints(and)
	sort.Ints(or)
	fmt.Println(len(and), len(or))
	for _, v := range and {
		fmt.Println(v)
	}
	for _, v := range or {
		fmt.Println(v)
	}
}



Measured memory_bytes: 27244
import java.awt.geom.Line2D;
import java.io.IOException;

public class Main {
	/**
	 * @param args
	 */
	static class Line extends Line2D.Double {
		public Line(int[] p1, int[] p2) {
			super(p1[0], p1[1], p2[0], p2[1]);
		}
	}

	static class Shape {
		public	int	x = 0;
		public	int	y = 0;
		public	int	r = 0;

		public Shape(int x, int y) {
			this.x = x;
			this.y = y;
		}

		public Shape(int x, int y, int r) {
			this.x = x;
			this.y = y;
			this.r = r;
		}
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int[][]	d = null;

		while((d = inp()) != null) {
			solve(d);
		}
	}

	private static void solve(int[][] d) {
		{
			int	rr = (d[3][2]*d[3][2]);
			int	d0 = distPow(d[3], d[0]);
			int	d1 = distPow(d[3], d[1]);
			int	d2 = distPow(d[3], d[2]);

			if (d0 <= rr && d1 <= rr && d2 <= rr) {
				System.out.println("b");
				return;
			}
		}

		{
			int		n1 = crossSign(d[0], d[1], d[3]);
			int		n2 = crossSign(d[1], d[2], d[3]);
			int		n3 = crossSign(d[2], d[0], d[3]);
			Line	l1 = new Line(d[0], d[1]);
			Line	l2 = new Line(d[1], d[2]);
			Line	l3 = new Line(d[2], d[0]);
			double	dr = (double)d[3][2];
			double	s1 = l1.ptSegDist(d[3][0], d[3][1]);
			double	s2 = l2.ptSegDist(d[3][0], d[3][1]);
			double	s3 = l3.ptSegDist(d[3][0], d[3][1]);

			if ((n1 == n2) && (n2 == n3)) {
				if (s1 >= dr && s2 >= dr && s3 >= dr) {
					System.out.println("a");
				} else {
					System.out.println("c");
				}
			} else {
				if (s1 > dr && s2 > dr && s3 > dr) {
					System.out.println("d");
				} else {
					System.out.println("c");
				}
			}
		}
	}

	private static int distPow(int[] p1, int[] p2) {
		return (p1[0]-p2[0])*(p1[0]-p2[0])+(p1[1]-p2[1])*(p1[1]-p2[1]);
	}

	private static int crossSign(int[] p1, int[] p2, int[] p3) {
		int[]	vab = { p2[0]-p1[0], p2[1]-p1[1] };
		int[]	vap = { p3[0]-p1[0], p3[1]-p1[1] };
		int		sgn = cross(vab, vap);
		return (sgn==0)?0:((sgn>0)?1:-1);
	}

	private static int cross(int[] va, int[] vb) {
		return va[0]*vb[1]-va[1]*vb[0];   // x1*x2 + y1*y2
	}

	private static int[][] inp() {
		int[][]	d = new int[4][];

		for (int i = 0; i < 4; i++) {
			if (i < 3) {
				int[]	p = { parseNum(), parseNum() };
				if (p[0] == 0 && p[1] == 0) return null;
				d[i] = p;
			} else {
				int[]	p = { parseNum(), parseNum(), parseNum() };
				d[i] = p;
			}
		}

		return d;
	}

	private static int parseNum() {
		try {
			int	buf = 0;
			int	num = 0;
			int	mns = 0;
			int	skp = 1;

			// -,0〜9以外は読み飛ばす
			while (true) {
				buf = System.in.read();
				if (buf == '-') {
					mns = 1;
					skp = 0;
				} else if (buf >= '0' && buf <= '9') {
					num = num * 10 + (buf - '0');
					skp = 0;
				} else if ((skp == 0 || buf == -1) && buf != '.') {
					return (mns == 0)?num:num*(-1);
				}
			}
		} catch (IOException e) {}
		return -1;
	}
}

Measured memory_bytes: 16888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  int n;
  cin >> n;
  string s;
  cin >> s;
  int ans=1;
  rep1(i,n-1){
    if(s[i]!=s[i-1]) ans++;
  }
  cout << ans << endl;
    



  
  return 0;
    

}


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

int main() {
	int n, k, r, s, p, a = 0; cin >> n >> k >> r >> s >> p;
	string S, T; cin >> S;
	for(int i = 0; i < n; i++) {
		if(S[i] == 'r') T += 'p';
		else if(S[i] == 'p') T += 's';
		else T += 'r';
	}
	for(int i = 0; i < k; i++)
		if(T[i] == 'r') a += r;
		else if(T[i] == 's') a += s;
		else a += p;
	for(int i = k; i < n; i++)
		if(S[i] != S[i - k]) {
			if(T[i] == 'r') a += r;
			else if(T[i] == 's') a += s;
			else a += p;
		} else {
			S[i] = 'x';
		}
	cout << a;
}


Measured memory_bytes: 512
#include<stdio.h>
int main(void){
  int k,a,b,i;
  scanf("%d%d%d",&k,&a,&b);
  for(i=a;i<=b;i++){
    if(i%k==0){
      printf("OK\n");
      return 0;
    }
  }
  printf("NG\n");
  return 0;
}


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

#define INF 2e9

#define REP(i,n) for(int i = 0; i < n;++i)
#define REPA(i,a,n) for(int i = a; i < n; ++i)
#define REPR(i,a) for(int i = a; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;

int gcd(int a, int b){ return b ? gcd(b, a % b) : a; }
template<typename A> void psn(A a){ cout << a << endl; }
template<typename A, typename... B> void psn(A a, B... b){ cout << a << ' '; psn(b...); }

int main(void) {
    
    int N;
    string S, T, ST = "";
    
    cin >> N >> S >> T;
    
    REP(i, N){
        ST.push_back(S[i]);
        ST.push_back(T[i]);
    }
    
    cout << ST << endl;
}

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

using namespace std;
typedef long long ll;

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

  ll n, m; cin >> n >> m;

  ll k; cin >> k;

  vector<ll> a(n), b(m);
  for(ll i = 0; i < n; i++) {
    cin >> a[i];
  }

  ll tot = 0;
  for(ll i = 0; i < m; i++) {
    cin >> b[i];
    tot += b[i];
  }

  ll ret = 0;
  for(ll i = 0; i <= n; i++) {
    while(tot > k && b.size()) {
      tot -= b.back();
      b.pop_back();
    }

    if(tot <= k)
      ret = max(ret, (ll)b.size() + i);

    if(i < n) {
      tot += a[i];
    }
  }

  cout << ret << "\n";

  return 0;
}


Measured memory_bytes: 6324
#include <bits/stdc++.h>
using namespace std;
using lint         = long long;
constexpr lint inf = 1LL << 60;
constexpr lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint n;
    cin >> n;
    string x;
    cin >> x;
    vector<lint> ret(n, 0);
    lint cnt = 0;
    for (int i = 0; i < n; ++i) {
        if (x[i] == '1')
            cnt++;
    }
    lint cntp1    = cnt + 1;
    lint cntm1    = cnt - 1;
    lint totmodp1 = 0;
    lint totmodm1 = 0;
    vector<lint> twop(n + 1, 0);
    vector<lint> twom(n + 1, 0);
    twop[n - 1] = 1;
    twom[n - 1] = 1;
    for (int i = 0; i < n; ++i) {
        totmodp1 = totmodp1 * 2 % cntp1;
        if (x[i] == '1') {
            totmodp1 = (totmodp1 + 1) % cntp1;
        }
    }
    for (int i = n - 2; i >= 0; --i) {
        twop[i] = twop[i + 1] * 2 % cntp1;
    }
    if (cntm1 > 0) {
        for (int i = 0; i < n; ++i) {
            totmodm1 = totmodm1 * 2 % cntm1;
            if (x[i] == '1') {
                totmodm1 = (totmodm1 + 1) % cntm1;
            }
        }
        for (int i = n - 2; i >= 0; --i) {
            twom[i] = twom[i + 1] * 2 % cntm1;
        }
    }
    for (int i = 0; i < n; ++i) {
        lint tot;
        if (x[i] == '1') {
            if (cntm1 == 0) {
                cout << 0 << "\n";
                continue;
            }
            tot = (totmodm1 - twom[i] + cntm1) % cntm1;
        } else
            tot = (totmodp1 + twop[i]) % cntp1;
        lint ret = 1;
        while (tot) {
            ret++;
            lint cnt  = 0;
            lint temp = tot;
            while (temp) {
                if (temp % 2 == 1)
                    cnt++;
                temp /= 2;
            }
            tot = tot % cnt;
        }
        cout << ret << "\n";
    }
    return 0;
}

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

int main()
{
  string s;
  cin >> s;
  
  int len = s.size();
  for (int i = 0; i < len; i ++)
  {
    if ((i + 1) % 2 == 0)
    {
      if (s.at(i) == 'R')
      {
        cout << "No" << endl;
        return 0;
      }
    }
    else
    {
      if (s.at(i) == 'L')
      {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  
  cout << "Yes" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int N,K;
  long long int P[10000],C[10000];
  long long int ans=-6000000000000000000LL;
  scanf("%d %d",&N,&K);
  for(int i=1;i<=N;i++)
    scanf("%lld",P+i);
  for(int i=1;i<=N;i++)
    scanf("%lld",C+i);

  for(int i=1;i<=N;i++){
    int next_i=P[i];
    int L=1;
    long long int S=C[next_i];
    if(S>ans) ans=S;
    while(L<K && next_i!=i){
      next_i=P[next_i];
      S+=C[next_i];
      if(S>ans) ans=S;
      L++;
    }
    if(S>=0LL && L<K){
      S*=(long long int)((K-L)/L);
      int T=K%L+L;
      while(T>0){
        next_i=P[next_i];
        S+=C[next_i];
        if(S>ans) ans=S;        
        T--;
      }
    }
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 1824
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;

int main(void)
{
  int n;
  LL c;
  cin >> n >> c;
  vector<LL> sp(n), rsp(n);
  vector<LL> sv(n);
  REP(i,n) cin >> sp[i] >> sv[i];
  REP(i,n) rsp[i] = c - sp[i];
  LL answer = 0ll;
  vector<LL> ssv(sv), rssv(sv);
  REP(i, n-1) ssv[i+1] += ssv[i];
  for(int i = n-1; i>0; --i) rssv[i-1] += rssv[i];
  REP(i, n) ssv[i] -= sp[i];
  REP(i, n) rssv[i] -= rsp[i];
  REP(i, n-1) ssv[i+1] = max(ssv[i+1], ssv[i]);
  for(int i = n-1; i>0; --i) rssv[i-1] = max(rssv[i-1], rssv[i]);
  answer = max(answer, ssv[n-1]);
  REP(i, n-1) answer = max(answer, ssv[i] - sp[i] + rssv[i+1]);
  answer = max(answer, rssv[0]);
  for(int i = n-1; i>1; --i) answer = max(answer, rssv[i] - rsp[i] + ssv[i-1]);
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 4224
def abc061_d():
    n, m = map(int, input().split())
    edges = [tuple(map(int, input().split())) for _ in range(m)]

    inf = float("inf")
    result = [inf] * n
    result[0] = 0

    for i in range(n - 1):
        for f, t, c in edges:
            result[t - 1] = min(result[t - 1], result[f - 1] - c)
    ans = result[n - 1]
    for f, t, c in edges:
        result[t - 1] = min(result[t - 1], result[f - 1] - c)
    print(-ans if ans == result[n - 1] else "inf")


if __name__ == '__main__':
    abc061_d()


Measured memory_bytes: 3316
// https://atcoder.jp/contests/abc109/tasks/abc109_d
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
inline int read() {
    int tmp = 0;
    char c = getchar(), f = 1;
    for (; c < '0' || '9' < c; c = getchar())
        if (c == '-')
            f = -1;
    for (; '0' <= c && c <= '9'; c = getchar())
        tmp = (tmp << 3) + (tmp << 1) + c - '0';
    return tmp * f;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h, w;
    h = read(), w = read();
    vector<vector<int>> v(h, vector<int>(w));
    REP(i, h) REP(j, w) v[i][j] = read();
    bool coin = false;
    vector<pii> ans, tmp;
    REP(i, h) REP(j, w) {
        int k = (i % 2 == 0 ? j : (w - j - 1));
        if (coin) {
            // ボールの合計が奇数の場合、ボールを持ったまま終わることを考慮
            tmp.push_back({i + 1, k + 1});
        }
        if (v[i][k] % 2 == 1) {
            if (coin) {
                coin = false;
                copy(ALL(tmp), back_inserter(ans));
                // ans.insert(ans.end(), ALL(tmp));
                tmp.clear();
            } else {
                coin = true;
            }
        }
        if (coin) {
            tmp.push_back({i + 1, k + 1});
        }
    }
    cout << ans.size() / 2 << "\n";
    REP(i, ans.size()) {
        cout << ans[i].first << " " << ans[i].second << (i % 2 ? "\n" : " ");
    }

    return 0;
}


Measured memory_bytes: 5236
n = int(input())
x = list(map(int,input().split()))

P = 10**9 + 7
mo = P
inv_t = [0]+[1]
for i in range(2,n):
  inv_t += [inv_t[P % i] * (P - int(P / i)) % P]


d = []
for i in range(n-1):
    d.append(x[i+1] - x[i])

kai = 1
for i in range(n-2):
    kai = kai*(i+2)
    kai = kai%mo 

rui = []
tmp = 0
for i in range(n-1):
    tmp += d[-i-1]
    tmp = tmp%mo
    rui.append(tmp)

#print(d)
#print(kai)
#print(rui)

ans = 0
for i in range(n-1):
    #print(kai/(n-i-1))
    fa = kai*inv_t[n-i-1]
    fa = ( (fa%mo)*(rui[i]%mo) )%mo
    ans += fa
    ans = ans%mo

print(ans%mo)



Measured memory_bytes: 67864
#include <iostream>
#include <string>
using namespace std;
int main(){
    int i,n,a,b,c=0,d,e=0;
    cin >> n >> a >>b;
    for(i=0;i<=n;i++){
        d = i;
        while(d!=0){
            c = c+d%10;
            d = d/10;
        }
        if(c>=a&&c<=b){
            e = e+i;
        }
        c = 0;
    }
    cout << e;
}


Measured memory_bytes: 256
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]
#a = [int(input()) for _ in range(n)]

a,b = map(str, input().split())

temp = int(a + b)

ans = "No"
for i in range(1, temp+1):
    if temp % i == 0:
        if temp // i == i:
            ans = "Yes"
            break
print(ans)



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

int main(){
	int n;
  	cin >> n;
  	vector<int> X(n);
  	rep(i, n) cin >> X[i];
  	
  	int near = 100;
    int far = 1;
  	rep(i, n){
    	near = min(X[i], near);
      	far = max(X[i], far);
    }
  
  	int mini = 1000000;
  	for(int i = near; i <= far; i++){
      	int a = 0;
    	rep(j, n){
 			a += (X[j] - i) * (X[j] - i);
        }
      	mini = min(a, mini);
    }
  	cout << mini << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
    cout << "Possible" << endl;
  } else {
    cout << "Impossible" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define inlld(x) scanf("%lld", &x)
#define ind(x) scanf("%d", &x)
#define inlld2(x, y) scanf("%lld%lld", &x, &y)
#define inlld3(x, y, z) scanf("%lld%lld%lld", &x, &y, &z)
#define ind2(x, y) scanf("%d%d", &x, &y)
#define ind3(x, y, z) scanf("%d%d%d", &x, &y, &z)

const int N=405;
const int MOD=1e9+7;

typedef long long ll;
typedef long double ld;

using namespace std;

ll n, dp[N][N], arr[N], pref[N];

ll solve(ll i, ll j)
{
    if(dp[i][j]!=-1)
        return dp[i][j];
    if(i==j)
        return 0;
    ll ret=1e18;
    for(ll a=i; a<j; a++)
        ret=min(ret, solve(i, a)+solve(a+1, j)-pref[i-1]+pref[j]);
    return dp[i][j]=ret;
}

int main()
{
    inlld(n);
    for(ll a=1; a<=n; a++)
        inlld(arr[a]);
    for(ll a=1; a<=n; a++)
        pref[a]=pref[a-1]+arr[a];
    memset(dp, -1, sizeof(dp));
    printf("%lld\n", solve(1, n));
    return 0;
}

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

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

  int wt = 0;
  int lt = -T;
  for (int i = 0; i < N; i++) {
    int t;
    cin >> t;
    if (t - lt < T) {
      wt -= T - (t - lt);
    }
    wt += T;
    lt = t;
  }

  cout << wt << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int n; cin >> n;
    int ans = 1e9;
    for(int i = 0; i < n; i++){
        int a; cin >> a;
        int cnt = 0;
        while(a%2 == 0){
            a /= 2;
            cnt++;
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
int count(std::vector<int>v2, bool f) {
	std::vector<int> v = v2;
	if (f)return pow(3, v2.size());
	else if (v.size() <= 1) { if (v[0] % 2 == 0)return 1; else return 2; }
	else {
		if (v2[0] % 2 == 0) { v.erase(v.begin()); return count(v, 1)+count(v,0)*2; }
		else { v.erase(v.begin()); return 2*count(v, 1)+count(v,0); }
	}
}
int main() {
	int n;
	std::cin >> n;
	std::vector<int>v(n);
	for (auto& i:v)std::cin >>i;
	std::cout << count(v, 0) << std::endl;
	 return 0;
}

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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
#define INIT(a,b) memset(a,b,sizeof(a))
using lint = long long int;

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

    vector<lint> L(N);
    for_(i,0,N) cin >> L[i];

    int ans = 0;
    for_(i,0,N) for_(j,i+1,N) for_(k,j+1,N) {
        lint x = L[i], y = L[j], z = L[k];
        if (x == y or y == z or x == z) continue;
        if (x + y <= z) continue;
        if (x + z <= y) continue;
        if (y + z <= x) continue;
        ++ans;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;
#define lint long long
#define ll long long
static const int INF = 1 << 22;
#define pii pair<long long,long long>
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
/*******source code below********/
int main(void) {
	int N, Y; cin >> N >> Y;
	Y /= 1000;

	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= N - i;j++) {
			if (10 * i + 5 * j + (N - i - j) == Y) {
				cout << i << " " << j << " " << N - i - j << endl;
				return 0;
			}
		}
	}
	cout << "-1 -1 -1" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <math.h>
#include <ctype.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
typedef long long ll;
constexpr ll INF = 1000000000;
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n; cin >> n; 
	map<string, int>mp;

	vector<string>s(n);
	rep(i, n)cin >> s[i];

	rep(i, n) {
		sort(s[i].begin(), s[i].end());
		mp[s[i]]++;
	}

	ll ans = 0;
	for(pair<string,int> p : mp) {
		ll m = p.second;
		ans += m * (m - 1) / 2;
	}
	cout << ans << endl;
	/*vector<int>vec = { 2,3,4,5,6,9 };
	for (auto i : vec)cout << i << endl;*/
}

Measured memory_bytes: 16640
package main
 
import (
	"sort"
	"bufio"
	"fmt"
	"os"
	"strconv"
)
 
var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)
 
func scanString() string { sc.Scan(); return sc.Text() }
func scanRunes() []rune { return []rune(scanString()) }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }
 
func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}
 
func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }
 
func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }
 
//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
 
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)
 
	n := scanInt()
	h := scanInt()
 
	a := make([]int, n)
	b := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = scanInt()
		b[i] = scanInt()
	}
 
	sort.Ints(a)
	sort.Ints(b)
 
	idx := n-sort.Search(n, func(idx int) bool {
		return a[n-1] <= b[idx]
	})

	c := 0
	for i := 0; i < idx; i++ {
		h -= b[n-1-i]
		c++

		if h <= 0 {
			h = 0
			break
		}
	}

	fmt.Fprintln(wr, c+(h+a[n-1]-1)/a[n-1])
 
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };

template< int mod >
struct ModInt {
  int x;

  ModInt() : x(0) {}

  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator*=(const ModInt &p) {
    x = (int) (1LL * x * p.x % mod);
    return *this;
  }

  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }

  ModInt operator-() const { return ModInt(-x); }

  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }

  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }

  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }

  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

  bool operator==(const ModInt &p) const { return x == p.x; }

  bool operator!=(const ModInt &p) const { return x != p.x; }

  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }

  ModInt pow(int64_t n) const {
    ModInt ret(1), mul(x);
    while(n > 0) {
      if(n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }

  friend ostream &operator<<(ostream &os, const ModInt &p) {
    return os << p.x;
  }

  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt< mod >(t);
    return (is);
  }

  static int get_mod() { return mod; }
};
const ll mod = 1e9+7;
using modint = ModInt< mod >;


int N,K;
void input(){
    fast_io();
    cin >> N >> K;
}

vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}
void chmax(int &a, int b){if(a<b) a=b;}
// これを高速化する。
int solve(){
	vector<int> div;
	for (int i = 1; i*i <= N; i++)
	{
		div.push_back(i);
		if(i*i!=N) div.push_back(N/i);
	}
	sort(div.begin(),div.end());
	int S = div.size();
	vector<vector<modint>> dp(K+1,vector<modint>(S,0));
	dp[0][0] = 1;
	for (int i = 0; i < K; i++)
	{
		for (int t = S-1; t>=0; t--)
		{
			dp[i+1][t] += dp[i][S-1-t];
		}
		for (int t = S-1; t>0; t--)
		{
			dp[i+1][t-1] += dp[i+1][t];
			dp[i+1][t] *= div[t]-div[t-1];
		}
	}
	modint ans = 0;
	for (int i = 0; i < S; i++)
	{
		ans += dp[K][i];
	}
	cout << ans << endl;
    return 0;
}

int test(){
    int M = 100;
    map<int,int> cnt;
    for (int i = 1; i < M; i++)
    {
        cout << (M/i) << endl;
        cnt[(M/i)]++;
    }
    for(auto p:cnt){
        cout << p.first << " " << p.second << endl;
    }
    
    return 0;
}

int main()
{
    input();
    solve();
    // test();
    return 0;
}

Measured memory_bytes: 28884
#include <bits/stdc++.h>
#include <vector>
#include <math.h>

using namespace std;
 int main(){

  long long a,b; cin>>a>>b;
  float avg = (a+b)/2.0;

  //cout<<avg<<endl;

  if(avg == int(avg))
  cout<<avg<<endl;
  else
    cout<<int(avg)+1<<endl;

 return 0;
 }







Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll n,k;
    cin>>n>>k;
    if(n>k)
    {
        n%=k;
    }
    ll ans = n;
    ans = min(n,abs(n-k));
    cout<<ans<<endl;
}


Measured memory_bytes: 256
S = input()
if S == 'SUN':
    print(7)
elif S == 'MON':
    print(6)
elif S == 'TUE':
    print(5)
elif S == 'WED':
    print(4)
elif S == 'THU':
    print(3)
elif S == 'FRI':
    print(2)
else:
    print(1)

Measured memory_bytes: 9112
def main():
    n=int(input())
    a=sorted(map(int,input().split()))
    aa=sorted(abs(i) for i in a)
    
    if sum(i<0 for i in a)%2==0:
        print(sum(aa))
    else:
        print(-aa[0]+sum(aa[1:]))

if __name__ == "__main__":
    main()

Measured memory_bytes: 20120