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

int main()
{
  string s;
  cin >> s;
  if(s == "SAT") cout << 1 << endl;
  else if(s == "SAT") cout << 1 << endl;
  else if(s == "SUN") cout << 7 << endl;
  else if(s == "MON") cout << 6 << endl;
  else if(s == "TUE") cout << 5 << endl;
  else if(s == "WED") cout << 4 << endl;
  else if(s == "THU") cout << 3 << endl;
  else if(s == "FRI") cout << 2 << endl;

  return 0;
}

Measured memory_bytes: 256
using System;

namespace Rectangle
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine();
            var a_b = input.Split(new Char [] { ' ' });
            var a = decimal.Parse(a_b[0]);
            var b = decimal.Parse(a_b[1]);

            Console.WriteLine(string.Format("{0} {1}", a * b, a * 2 + b * 2));
        }
    }
}



Measured memory_bytes: 15936
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

N = int(input())
l = [int(i) for i in input().split()]
l.sort()

lset = set(l)

if N%3 == 0:
    if len(lset) == 1:
        if l[0] == 0:
            print("Yes")
        else:
            print("No")
            
    elif len(lset) == 2:
        k = list(lset)
        k.sort()
        if k[0]^k[1] == k[1] and l[int(N/3)] == k[1] and l[int(N/3 - 1)] == 0:
            print("Yes")
        else:
            print("No")
    
    elif len(lset) == 3:
        k = list(lset)
        k.sort()
        if k[0]^k[1] == k[2] or k[0]^k[2] == k[1]:
            c0 = 0
            c1 = 0
            for i in l:
                if i == k[0]:
                    c0 += 1
                elif i == k[1]:
                    c1 += 1
            if c0 == N/3 and c1 == N/3:
                print("Yes")
            else:
                print("No")
        else:
            print("No")
            
    else:
        print("No")

else:
    if len(lset) == 1:
        if l[0] == 0:
            print("Yes")
        else:
            print("No")
    else:
        print("No")

Measured memory_bytes: 14100
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;

struct mint {
  ll x;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
      mint a = pow(t>>1);
      a *= a;
    if (t&1) a *= *this;
      return a;
  }
   mint inv() const { return pow(MOD-2);}
   mint& operator/=(const mint a) { return *this *= a.inv();}
   mint operator/(const mint a) const { return mint(*this) /= a;}
};
typedef vector<mint> vm;
typedef vector<vm> vvm;
  
int main() {
  int N;
  cin >> N;
  vi A(N);
  rep(i,N) {
    cin >> A[i];
  }
  mint ans = 0;
  mint acc = 0;
  rep(i,N) {
    acc += A[i];
  }
  rep(i,N) {
    acc -= A[i];
    ans += acc*A[i];
  }
  cout << ans.x << endl;
  return 0;
}

Measured memory_bytes: 4044
macro_rules! input {
    ($ttype:ty) => {
        {
            let mut input = String::new();
            let _= std::io::stdin().read_line(&mut input);
            input.trim().parse::<$ttype>().unwrap()
        }
    };

    ($($ttype:ty),*) => {
        {
            use std::io::BufRead;
            let mut input = String::new();
            let stdin = std::io::stdin();
            let _ = stdin.lock().read_line(&mut input);
            let mut iter = input.trim().split_whitespace();
            (
                $(iter.next().unwrap().parse::<$ttype>().unwrap(),)*
            )
        }
    };

    ($ttype:ty; $x:expr) => {
        {
            use std::io::BufRead;
            let mut input = String::new();
            let stdin = std::io::stdin();
            let _ = stdin.lock().read_line(&mut input);
            let v: Vec<$ttype> = input
                .trim()
                .split_whitespace()
                .map(|x| x.parse().unwrap())
                .collect();
            v
        }
    };

    ($ttype:ty; $x:expr; $y:expr) => {
        {
            use std::io::BufRead;
            let mut matrix = Vec::with_capacity($y);
            for _ in 0..$y {
                let mut input = String::new();
                let stdin = std::io::stdin();
                let _ = stdin.lock().read_line(&mut input);
                let v: Vec<$ttype> = input
                    .trim()
                    .split_whitespace()
                    .map(|x| x.parse().unwrap())
                    .collect();
                matrix.push(v);
            }
            matrix
        }
    };
}

use std::collections::HashSet;

fn main() {
    let (n, m) = input!(i64, usize);
    let mut island_from_one: HashSet<_> = HashSet::new();
    let mut island_to_n: HashSet<_> = HashSet::new();
    for _ in 0..m {
        let (a, b) = input!(i64, i64);
        if a == 1 {
            island_from_one.insert(b);
        } else if b == n {
            island_to_n.insert(a);
        }
    }

    if island_from_one.intersection(&island_to_n).count() > 0 {
        println!("POSSIBLE");
    } else {
        println!("IMPOSSIBLE");
    }
}


Measured memory_bytes: 11076
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int a,b,i,n;
scanf("%d%d",&a,&b);
while(a!=0&&b!=0)
	{	
		for(n=0;n<a;n++)
		{
	
			
			if(n%2==0){
			for(i=0;i<b/2;i++){
				printf("#");
				printf(".");
				}
				if(b%2==1)printf("#");
			
			}
			
			else if(n%2==1)
			{
			
			for(i=0;i<b/2;i++){
				printf(".");
				printf("#");
				}
				if(b%2==1)printf(".");

			}

		puts("");
		}

		puts("");scanf("%d%d",&a,&b);
	}
return 0;
}

Measured memory_bytes: 588
#import<iostream>
using namespace std;long N,M,c,n=1,i,o=1e9+7;long m(long a){long g=1,h=2*o-4;while(h/=2){if(h&1)g=g*a%o;a=a*a%o;}return g;}long C(long b){long r=1,d=1;for(;b;--b){r=r*(N-1+b)%o;d=d*b%o;}return r*m(d)%o;}main(){cin>>N>>M;for(i=2;i*i<=M;++i){c=0;while(!(M%i)){++c;M/=i;}n=n*C(c)%o;}cout<<n*(M^1?N:1)%o<<endl;}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

bool rec(int p, vint no)
{
	if(p == 9)
	{
		rep(i, 9)
		{
			if(no[i]) return false;
			else if(i == 8) return true;
		}
	}

	int res = rec(p + 1, no);
	if(3 <= no[p])
	{
		vint v = no;
		v[p] -= 3;
		res |= rec(p + 1, v);
		if(v[p] == 1)
		{
			
			if(p < 7 && (v[p] <= v[p+1] && v[p] <= v[p+2]))
			{
				v[p+1] -= v[p];
				v[p+2] -= v[p];
				v[p]	= 0;

				res |= rec(p + 1, v);
			}
		}
	}

	if(p < 7)
	{
		if(no[p] <= no[p+1] && no[p] <= no[p+2])
		{
			no[p+1] -= no[p];
			no[p+2] -= no[p];
			no[p]	= 0;

			res |= rec(p + 1, no);
		}
	}

	return res;
}

int main()
{
	string str;
	while(cin >> str)
	{
		vint res;
		vint v(9, 0);

		rep(i, str.size())
			v[str[i] - '0' - 1]++;

		rep(num, 9) 
		{
			if(4 <= v[num]) continue;
			vint no = v;
			no[num]++;
			rep(i, 9)
			{
				if(2 <= no[i])
				{
					vint nn = no;
					nn[i] -= 2;
					if(rec(0, nn))
						res.push_back(num);
				}
			}
		}

		res.erase(unique(ALL(res)), res.end());

		if(res.size() == 0)
			cout << 0 << endl;
		else
		rep(i, res.size())
		{
			cout << res[i] + 1;
			if(i == res.size()-1)
				cout << endl;
			else
				cout << " ";
		}
	}
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int mod = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  vector<ll> a(3);
  REP(i,3)
    cin >> a[i];
  
  sort(a.begin(), a.end());
  ll c1 = a[2] - a[1];
  ll c2 = a[1] - a[0];
  if(c2 % 2 == 1)
    cout << c1+c2/2+2 << endl;
  else
    cout << c1+c2/2 << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define rev(i,s,e) for(i64 (i) = (s);(i) --> (e);)
#define all(x) x.begin(),x.end()

int main() {
  i64 n;
  cin >> n;
  vector<i64> w(n);
  rep(i,0,n) cin >> w[i];
  i64 ans = 1e18;
  w.push_back(0);
  rev(i,n,0) w[i] += w[i + 1];
  rep(i,1,n) {
    ans = min(ans, abs((w[0] - w[i]) - (w[i] - w[n])));
  }
  cout << ans << endl;
}


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

using namespace std;

struct DATA{
  char Team;
  int Win;
  int Lose;
};

bool compare(const DATA&, const DATA&);

int main(){
  int i, j, n, score, win, lose;
  char c;
  DATA one;
  vector<DATA> data;

  while(1){
    cin >> n;
    if(n == 0) break;

    for(i=0; i<n; ++i){
      cin >> c;

      win = 0;
      lose = 0;
      for(j=0; j<n-1; ++j){
	cin >> score;
	if(score == 0) win++;
	else if(score == 1) lose++;
      }
      one.Team = c;
      one.Win = win;
      one.Lose = lose;
      data.push_back(one);
    }

    sort(data.begin(), data.end(), compare);
    for(i=0; i != data.size(); ++i)
      cout << data[i].Team << endl;
    data.clear();
  }

  return 0;
}

bool compare(const DATA& x, const DATA& y){
  if(x.Win == y.Win)
    return x.Lose < y.Lose;
  else
    return x.Win > y.Win;
}

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

using namespace std;

// 素因数分解, overflow に注意
std::map<int, int> prime_factorization(int n)
{
    std::map<int, int> ret;
    int ntmp = n;
    for (int i = 2; i * i <= n; i++)
    {
        if (ntmp % i)
            continue;
        while (ntmp % i == 0)
        {
            ret[i]++;
            ntmp /= i;
        }
    }
    if (ntmp != 1)
    {
        ret[ntmp]++;
    }
    return ret;
}

int main()
{
    int n;
    cin >> n;
    auto ret = prime_factorization(n);
    cout << n << ":";
    for (auto p : ret)
    {
        for (int i = 0; i < p.second; i++)
            cout << " " << p.first;
    }
    cout << endl;
}


Measured memory_bytes: 3104
n = int(input())
dp = [0] * 60005
for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            dp[x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x] += 1

for i in range(1, n + 1):
    print(dp[i])


Measured memory_bytes: 9688
N,K= map(int, input().split())
p = 10**9+7
f=[1]
for i in range(1,N+1):
  f.append(f[-1]*i % p)

def nCk(n,k):
  return f[n]*pow(f[n-k], p-2, p)*pow(f[k], p-2, p)

a = list(map(int, input().split()))
a.sort()

ans = 0
for i in range(N-K+1):
  ans -= (a[i] * nCk(N-i-1, K-1)) % p
  ans += (a[N-i-1] * nCk(N-i-1, K-1)) % p
print(ans % p)

Measured memory_bytes: 24064
#include <iostream>

using namespace std;
int main() {
    int N, A, B;
    cin >> N >> A >> B;
    int c = A + B;
    if ( c < N ) {
        cout << (A < B ? A : B) << " " << 0 << endl;
    } else {
        cout << (A < B ? A : B) << " " << c - N << endl;
    }

    return 0;
}

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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

typedef long long ll;

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

int main(){
  int N, M;
  cin >> N >> M;
  string S, T;
  cin >> S >> T;
  int G = gcd(N, M);
  ll lcm = (ll)N* M/G;

  vector<ll> Si(N), Ti(M);
  REP(i, N){
    Si[i] = i*lcm/N +1;
  } 
  REP(i, M){
    Ti[i] = i*lcm/M + 1;
    //cout << Ti[i] << " ";
  }
  //cout << endl;
  REP(i, N){
    int ite = lower_bound(Ti.begin(), Ti.end(), Si[i]) - Ti.begin();
    if(ite != Ti.size() && Si[i] != Ti[ite]){
      ite = Ti.size();
    }
    //cout << "Si: " << Si[i] << " ite: " << ite << endl;
    if(ite != Ti.size() && S[i] != T[ite]){
      cout << -1 << endl;
      return 0;
    }
  }
  cout << lcm << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

int main() {
  int n;
  scanf("%d", &n);
  
  long long int array[n], max = 1e18, product = 1, mark = 0, zero = 0;
  for (int i = 0; i < n; i++) {
    scanf("%lld", &array[i]);
    mark = (array[i] > max) ? 1 : mark;
    product *= array[i];
    (array[i]) ? max /= array[i] : zero = 1;
  }

  (zero) ? puts("0") : ((mark) ? puts("-1") : printf("%lld\n", product));
  return 0;
}

Measured memory_bytes: 2480
n = int(input())

top = 0
div = 10**16
digi = 17
while div >= 1:
  if n // div >= 1:
    top = n // div
    break
  div //= 10
  digi -= 1

res = 0
nine = div - 1
if n % div == nine:
  res = 9 * (digi - 1) + top
else:
  res = 9 * (digi - 1) + top - 1

print(res)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define x first
#define y second
#define int int long long // 2e9 & 9e18
using namespace std; const int inf = numeric_limits<int>::max();
struct __io{__io(){ios_base::Init i; ios_base::sync_with_stdio(0); cin.tie(0);}} __io; // fast I/O
#ifdef LOCAL // setting up print debugging (yes lol)
template<class K, class V>ostream& operator<<(ostream&s,const pair<K,V>&p){s<<'<'<<p.x<<','<<p.y<<'>';return s;}
template<class T, class=typename T::value_type, class=typename enable_if<!is_same<T,string>::value>::type>
ostream& operator<<(ostream&s,const T&v){s<<'[';for(auto&x:v){s<<x<<", ";}if(!v.empty()){s<<"\b\b";}s<<']';return s;}
void __prnt(){cerr<<endl;} template<class T, class...Ts>void __prnt(T&&a,Ts&&...etc){cerr<<a<<' ';__prnt(etc...);}
#define print(...) __prnt(__VA_ARGS__)
#else
#define print(...)
#endif

int n;
vector<vector<int>> g;
vector<int> vis;
vector<int> parent;

void bfs(int v) {
    queue<int> q;
    vis[v] = 1;
    q.push(v);
    while (!q.empty()) {
        v = q.front(); q.pop();
        for (int u : g[v]) {
            if (!vis[u]) {
                vis[u] = 1;
                parent[u] = v;
                q.push(u);
            }
        }
    }
}

signed main() {
    int m;
    cin >> n >> m;
    g.assign(n, {});
    vis.assign(n, 0);
    parent.assign(n, 0);
    int u, v;
    for (int i = 0; i < m; ++i) {
        cin >> u >> v;
        u--, v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }

    bfs(0);

    cout << "Yes\n";
    for (int i = 1; i < n; ++i) {
        cout << parent[i] + 1 << '\n';
    }
}


Measured memory_bytes: 13668
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 998244353
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
const double inf=1e10;
struct D {
  vector<double> l,r;
  D():l(3,inf),r(3,-inf) {}
  void add(double x, int v){
    v++;
    mins(l[v],x);
    maxs(r[v],x);
  }
  double get(double t){
    double nl = inf,nr = -inf;
    rep(i,3){
      mins(nl, l[i]+i*t);
      maxs(nr, r[i]+i*t);
    }
    return nr-nl;
  }
  vector<double> events(){
    vector<double> ts;
    rep(i,3)rep(j,i){//j<i
      {
      double t=(l[j]-l[i])/(i-j);
      if(t>0) ts.push_back(t);
      }
      {
      double t=(r[j]-r[i])/(i-j);
      if(t > 0) ts.push_back(t);
      }
    }
      return ts;
  }
};
int main(){
 int N;cin>>N;
 D xd,yd;
 rep(i,N){
   int x,y;
   char d;
   cin>>x>>y>>d;
   if(d=='L') xd.add(x,-1),yd.add(y,0);
   if(d=='R') xd.add(x,1),yd.add(y,0);
   if(d=='U') xd.add(x,0),yd.add(y,1);
   if(d=='D') xd.add(x,0),yd.add(y,-1);
 }
 vector<double> ts;
 ts.push_back(0);
 ts.push_back(inf);
 {
   auto nts = xd.events();
   ts.insert(ts.end(),nts.begin(),nts.end());
 }
 {
   auto nts = yd.events();
   ts.insert(ts.end(),nts.begin(),nts.end());
 }
 sort(ts.begin(),ts.end());
 double ans= 1e18;
 for(double t:ts){
   double now = xd.get(t)*yd.get(t);
   // cout<<now<<endl;
   mins(ans,now);
 }
 printf("%.10f\n",ans);
 return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int x[5];
    int i;
    int n;
    cin>>x[1]>>x[2]>>x[3]>>x[4]>>x[5];
    for(i=1;i<=5;i++){
        if(x[i]!=i) n=i;
    }
    cout<<n;
}

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

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

int tansaku(int i, int j, int &N, vector<int> &L);

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

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

  sort(L.begin(),L.end());
  int64_t ans = 0;

  for(int i=N-1; i>1; i--){
    for(int j=i-1; j>0; j--){
      ans += max(0, j-tansaku(i, j, N, L));
    }
  }

  cout << ans; 
}

int tansaku(int i, int j, int &N, vector<int> &L){
  int key = L.at(i)-L.at(j);
  auto Iter = lower_bound(L.begin(), L.end(), key+1);
  return Iter - L.begin();
}

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

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

    if(s.at(s.size()-1)=='s') cout << s << "es" << endl;
    else cout << s << "s" << endl;
    
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<P> VP;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define dbgmint(n,arr) rep(i,n){cerr<<arr[i].x<<" ";}cerr<<endl;
#define Uniq(v) v.erase(unique(v.begin(), v.end()), v.end())
#define fi first
#define se second

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,v.size())i>>v[j];return i;}

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

ll atama(ll n){
    while(n > 9){
        n /= 10;
    }
    return n;
}
ll keta(ll n){
    string s = to_string(n);
    return s.size();
}

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

    ll n;
    cin>>n;
    ll ans=0;

    VV vv(10,Vec(10));

    REP(x,1,n+1){
        ll last = x%10;
        ll start = atama(x);
        vv[start][last]++;
    }

    REP(i,1,10){
        REP(j,1,10){
            ans += vv[i][j]*vv[j][i];
        }
    }

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


Measured memory_bytes: 256
import java.util.*;

class Main {
    private static final Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        // ??\????????????
        // ??¬??\??§????????°???????????§????????´???????????????????????°???????????°?????????????????\????????????
        int[] a = new int[3];
        for (int i = 0;i < 3;i++) {
            a[i] = sc.nextInt();
        }
        // ?????????
        Arrays.sort(a);
        // ??????
        for (int i = 0;i < 3;i++) {
            // ?????????
            System.out.print(a[i]);
            // ?????????????°???????????§??????????????????\?????????
            if (i==2) break;
            // ????§???????????????\??????
            System.out.print(" ");
        }
        // ??????
        System.out.println("");
    }
}

Measured memory_bytes: 26064
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

using namespace std;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N,M;
	cin >> N >> M;
	int ans = N;
	vector<vector<int>> A(N,vector<int>(M));
	vector<bool> h(M,1);
	rep(i,N)rep(j,M){
		cin >> A[i][j];
		A[i][j]--;
	}
	int cnt = M;
	while(cnt){
		vector<int> p(M);
		rep(i,N){
			rep(j,M){
				int now = A[i][j];
				if(h[now]){
					p[now]++;
					break;
				}
			}
		}
		int t = 0;
		int next = 0;
		rep(j,M){
			if(t<p[j]){
				t = p[j];
				next = j;
			}
		}
		ans = min(ans,t);
		h[next] = 0;
		cnt--;
	}
	cout << ans << endl;
}


Measured memory_bytes: 640
a,b=map(int,input().split())
if b<=9:
    c=10*a+b
elif 10<=b<100:
    c=100*a+b
else:
    c=1000*a+b
for i in range(c//2):
    if i*i==c:
        print("Yes")
        exit()
print("No")      



Measured memory_bytes: 2940
#include<iostream>
#include<stdio.h>
using namespace std;

int main () {
	int n,q;
	scanf("%d",&n);
	int a[n];
	int sum = 0;
	for(int i = 0;i < n;i++)
	{
		scanf("%d",&a[i]);
	}
	scanf("%d",&q);
	int b[q];
	for(int i = 0;i < q;i++)
	{
		scanf("%d",&b[i]);
		int left = 0;
		int right = n;
		int mid;
		while(left < right)
		{
			mid = (left + right) / 2;
			if(b[i] > a[mid])
			{
				left = mid + 1;
			 } 
			else if (b[i] < a[mid])
			{
				right = mid;
			}
			else
			{
				sum++;
				break;
			}
		}
	}
	
	printf("%d\n",sum);
	return 0;
}



Measured memory_bytes: 3744
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using namespace std;
typedef pair<ll, ll> pint;

const int MOD = 1000000007;
void yesno(bool b) {
    if (b) {
        cout << "Yes" << endl;
    }     else {
        cout << "No" << endl;
    }
}
int n, m, q;
vector<int> a, b, c, d;
int ans;
void dfs(vector<int> A) {
    if (A.size() == n+1) {
        int now = 0;
        rep(i, q) {
            if (A[b[i]] - A[a[i]] == c[i]) now += d[i];
        }
        ans = max(ans, now);
        return ;
    }

    A.push_back(A.back());
    while(A.back() <= m) {
        dfs(A);
        A.back()++;
    }
}

int main() {
    cin >> n >> m >> q;
    a = b = c = d = vector<int>(q);
    rep(i, q) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    dfs(vector<int>(1, 1));
    cout << ans << endl;


}


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

signed main() {
  int a,b;
  string s;
  int k=0;
  cin>>a>>b>>s;
  for(int i=0;i<a+b+1;i++){
    if(i==a){if(s[i]!='-')k++;}
    else{if((int)s[i]<48||(int)s[i]>57)k++;}
  }
  if(k)cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
X, Y = map(int,input().split())

if (X+Y)%3 != 0 or abs(X-Y) > (X+Y)//3:
    print(0)
    exit(0)
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result
MOD = 10**9 + 7

print(cmb((X+Y)//3,min(X,Y)-(X+Y)//3)%MOD)


Measured memory_bytes: 102028
import math

def main():
    n, = map(int, open(0).read().split())

    digit = math.floor(math.log10(n)) + 1

    ans = 0
    for i in range(1, digit + 1, 2):
        if i == digit:
            ans += n - 10**(i-1) + 1
        else:
            ans += 10**i - 10**(i-1)
    print(ans)
    return()

if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include<stdio.h>
#define MAX_NUM 100
#define INF 2000000000


int min(int a, int b){
  if(a<b) return a;
  else return b;
}

void MatrixChainOrder(int *p,int len){
  int i,j,k,l;
  int m[MAX_NUM][MAX_NUM];

  for(i=1; i<=len; i++) m[i][i]=0;

  for(l=2; l<=len; l++){
    for(i=1; i<=len-l+1; i++){
      j=i+l-1;
      m[i][j]=INF;
      for(k=i; k<=j; k++){
        m[i][j]=min(m[i][j],m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]);
      }
    }
  }
  
  printf("%d\n",m[1][len]);
}

int main(){
  int n,i;
  int p[MAX_NUM +1]; 
  
  scanf("%d",&n);
  for(i=1; i<=n; ++i){
    scanf("%d%d",&p[i-1],&p[i]);
  }
  MatrixChainOrder(p,n);
  return 0;
}
    



Measured memory_bytes: 2056
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<long int> fact(N+1);
    fill(fact.begin(), fact.end(), 0);
    
    for(int h=2; h<=N; h++){
        int tmp=2, n=h;
        while(n>=2){
        int counter=0;
            while(n%tmp==0){
                counter++;
                n/=tmp;
            }
            fact[tmp]+=counter;
            tmp++;
        }
    }
    
    long int ans=1, mod=1000000007;
    for(int i=2; i<=N; i++){
        ans*=fact[i]+1;
        ans%=mod;
    }
    cout << ans << 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 REP(i,n)   FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define LL long long
string s;
int main(){
  cin>>s;
  int n = s.size();
  LL cnt=0;
  LL ret=0;
  int idx=0;
  while(idx < n-1){
    if(s[idx]=='A'){
      cnt++;
      idx++;
    }else if(s[idx]=='B' && s[idx+1]=='C'){
      ret+=(LL)cnt;
      idx+=2;
    }else{
      cnt=0;
      idx++;
    }
  }
  cout<<ret<<endl;
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const int maxn=200009;
const int P=1000000007;

int T,K;
int n,m;
int a[maxn];
int b[maxn];

void work1(){
	long long ans=1;
	for(int i=1;i<=n;++i)ans=ans*a[i]%P;
	for(int i=1;i<=m;++i)ans=ans*b[i]%P;
	if(m&1)ans=(P-ans)%P;
	cout<<ans<<endl;
}
void work2(){
	long long ans=1;
	for(int i=1;i<=K;++i)ans=ans*b[i]%P;
	ans=(P-ans)%P;
	cout<<ans<<endl;
}

int main(){
	cin>>T>>K;
	
	for(int i=1;i<=T;++i){
		int x;cin>>x;
		if(x>=0){
			a[++n]=x;
		}else{
			b[++m]=-x;
		}
	}
	sort(a+1,a+1+n);
	sort(b+1,b+1+m);
	if(T==K){
		work1();return 0;
	}
	if(n==0&&K%2==1){
		work2();return 0;
	}
	long long ans=1;
	if(K&1){
		--K;ans=a[n--];
	}
	while(K){
		long long x=-1,y=-1;
		if(n>=2){
			x=1LL*a[n]*a[n-1];
		}
		if(m>=2){
			y=1LL*b[m]*b[m-1];
		}
		if(x>y){
			ans=x%P*ans%P;n-=2;
		}else{
			ans=y%P*ans%P;m-=2;
		}
		K-=2;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 4516
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<iomanip>
#include<cmath>
using namespace std;
int m,n,a[105][105],ans[105][105];
int main(){
    int i,j,k;
    char x;
    cin>>m>>n;
    for(i=1;i<=m;i++)
        for(j=1;j<=n;j++){
            cin>>x;
            if(x=='#')
            a[i][j]=1;
        }
    for(i=1;i<=m;i++)
    for(j=1;j<=n;j++)
    ans[i][j]=a[i][j-1]+a[i-1][j-1]+a[i-1][j]+a[i+1][j]+a[i][j+1]+a[i+1][j+1]+a[i-1][j+1]+a[i+1][j-1];
    for(i=1;i<=m;i++){
        for(j=1;j<=n;j++){
            if(!a[i][j]){
                cout<<ans[i][j];
            }
            else{
                cout<<"#";
            }
        }
    cout<<endl;           
    }
       return 0;    
    }

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

int main() {
    // 読み込み
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    cout << (h2-h1)*60 +(m2-m1)-k << endl;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1234567890

int main(){
    ll i,j,k;
    ll n,a,b;
    cin>>n>>a>>b;
    ll comb[51][51];
    for(i=0;i<51;i++) comb[i][0]=1;
    for(j=1;j<51;j++){
        for(i=1;i<51;i++){
            comb[i][j]=comb[i-1][j]+comb[i-1][j-1];
        }
    }

    VI v(n);
    for(i=0;i<n;i++) cin>>v[i];
    sort(v.begin(),v.end());
    ll m=v[n-a];
    ll kosuu=upper_bound(v.begin(),v.end(),m)-lower_bound(v.begin(),v.end(),m);
    ll sum=0;
    ll mini=0;
    for(i=1;i<=a;i++) {
        sum+=v[n-i];
        if(m==v[n-i]) mini++;
    }
    double val=(double)sum/a;

    if(v[n-1]==m){
        ll ans=0;
        for(j=a;j<=b;j++){
            if(j<=kosuu) ans+=comb[kosuu][j];
        }
        printf("%.10lf\n",val);
        cout<<ans<<endl;
        return 0;
    }
    printf("%.10lf\n",val);
    cout<<comb[kosuu][mini]<<endl;

    return 0;
}

Measured memory_bytes: 384
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

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

fn is_reachable(af: &[(u64, u64, u64)], k: u64, goal_time: u64) -> bool{
    let mut diff_sum = 0;
    for afi in af{
        if afi.0 <= goal_time{
            continue;
        }
        diff_sum += (afi.0 - goal_time+afi.2-1)/afi.2;
    }

    if diff_sum <= k{
        return true;
    }else{
        return false;
    }
}

//return training goal
fn bin_search(af: &[(u64, u64, u64)], left: u64, right: u64, k: u64) -> u64{

    let mut l = left;
    let mut r = right;
    while l < r{
        let mid = (l + r)/2;
        //println!("mid = {}, isreach = {}", mid, is_reachable(af, k, mid));
        if !is_reachable(af, k, mid){
            l = mid+1;
        }else{
            r = mid;
        }
    }
    return l;

}
fn main(){
    let line = read_as_vec::<usize>();
    let (n, k) = (line[0], line[1] as u64);

    let mut a = read_as_vec::<u64>();
    let mut f = read_as_vec::<u64>();

    a.sort();
    f.sort();
    f.reverse();
    let mut af: Vec<(u64, u64, u64)> = vec![(0, 0, 0);n];
    for i in 0..n{
        af[i] = (a[i] * f[i], a[i], f[i]);
    }

    let time = bin_search(&af, 0, a.iter().max().unwrap() * f.iter().max().unwrap(), k);
    println!("{}", time);

 }


Measured memory_bytes: 15072
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if (x < y) x = y; }

int main() {
	int x; int y;
	while (~scanf("%d%d", &x, &y)) {
		ll ans = INFL;
		rep(s, 2) rep(t, 2) for (int p : {0, x, -x, y, -y}) {
			ll a = x, cost = 0;
			if (s == 1) a = -a, ++cost;
			if (p < a) continue;
			cost += p - a;
			a = p;
			if (t == 1) a = -a, ++cost;
			if (y < a) continue;
			cost += y - a;
			amin(ans, cost);
		}
		printf("%lld\n", ans);
	}
	return 0;
}


Measured memory_bytes: 764
#include <cstdio>

using namespace std;

int N, M;
#define M_MAX 10000
int A[M_MAX];

int main() {
  scanf("%d %d", &N, &M);
  for (int i = 0; i < M; i++) scanf("%d", &A[i]);

  int sum = 0;
  for (int i = 0; i < M; i++) sum += A[i];
  if (sum > N) printf("-1\n");
  else printf("%d\n", N-sum);
}



Measured memory_bytes: 1716
N,A,B,C,D=map(int,input().split())
if N%A>0:
    S=(N//A+1)*B
else:
    S=N//A*B
if N%C>0:
    T=(N//C+1)*D
else:
    T=N//C*D
if T>=S:
    print(S)
else:
    print(T)


Measured memory_bytes: 5596
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate, product
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


def MI(): return map(int, input().split())


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def debug(table, *args):
    ret = []
    for name, val in table.items():
        if val in args:
            ret.append('{}: {}'.format(name, val))
    print(' | '.join(ret), file=sys.stderr)


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True


def main():
    R = I()
    print(2 * R * math.pi)


if __name__ == '__main__':
    main()


Measured memory_bytes: 68508
import sys
from collections import deque

def main():
    n = int(sys.stdin.readline().rstrip())
    ab = map(int, sys.stdin.read().split())
    ab = list(zip(ab, ab))

    G = [[] for _ in range(n + 1)]
    for a, b in ab:
        G[a].append(b)
        G[b].append(a)
    
    q = deque([1]) # root = 1
    parent = [None] * (n + 1)
    color = [0] * (n + 1) # color of the edge(parent[y], y)

    while q:
        x = q.popleft()
        ng = color[x]
        c = 1
        for y in G[x]:
            if y == parent[x]:
                continue
            parent[y] = x
            if c == ng:
                c += 1
            color[y] = c
            q.append(y)
            c += 1
            
    print(max(color))

    for a, b in ab:
        if a == parent[b]:
            print(color[b])
        else:
            print(color[a])

if __name__ == '__main__':
    main()

Measured memory_bytes: 33444
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
long long factorial[1000001];
long long modpow(long long base, long long ex) {
	if (ex == 0) return 1;
	long long ans = modpow(base, ex / 2);
	ans = (ans * ans) % 1000000007;
	if (ex % 2) ans = (ans * base) % 1000000007;
	return ans;
}
int main() {
	long long X, Y;
	scanf("%lld %lld", &X, &Y);
	if ((2 * X - Y) % 3) printf("0");
	else if ((2 * Y - X) % 3) printf("0");
  	else if ((2 * X - Y) < 0) printf("0");
  	else if ((2 * Y - X) < 0) printf("0");
	else {
		long long A = (2 * X - Y) / 3, B = (2 * Y - X) / 3;
		factorial[0] = 1;
		for (int i = 1; i <= 1000000; ++i) factorial[i] = (i * factorial[i - 1]) % 1000000007;
		printf("%lld", ((factorial[A + B] * modpow(factorial[A], 1000000005) % 1000000007) * modpow(factorial[B], 1000000005)) % 1000000007);
	}
	return 0;
}

Measured memory_bytes: 8064
N = int(input())
score = 0
ans = 0
if N == 1:
    print(1)
else:
    for i in range(N,0,-1):
        s = i
        c=0
        while (i % 2 == 0) :
            i /= 2
            c += 1
        if score < c:
            score = c
            ans = s
        #カウントが更新されたらスコア配列に格納
    print(ans)
        
        
    
    

Measured memory_bytes: 2940
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#include <algorithm>
#include <cctype>
#include <iostream>
#include <string>

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

using namespace std;
typedef long long ll;

int f(int n)
{
    if (n == 1)
        return 1;

    int count = 2;
    for (int p = 2; p < n; p++)
    {
        if (n % p == 0)
            count++;
    }

    return count;
}

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

    int N;
    cin >> N;

    vector<ll> fs(N);
    fill(fs.begin(), fs.end(), 2);
    fs[0] = 1;

    int len = sqrt(N) + 1;
    for (int i = 2; i <= N; i++)
    {
        for (int v = i * 2; v <= N; v += i)
        {
            fs[v - 1]++;
        }
    }

    ll result = 0;
    for (int i = 1; i <= N; i++)
    {
        result += i * fs[i - 1];
    }

    cout << result << endl;

    /*
    int result = 0;
    for (int i = 1; i <= N; i++)
        result += i * f(i);

    cout << result << endl;
    */
}


Measured memory_bytes: 80936
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e9;
const ll MOD = 1e9 + 7;


int main(){
    int h, w;
    cin >> h >> w;
    const int n = 10;
    vector<vector<int>> c(n, vector<int>(n, INF));
    rep(i, n){
        rep(j, n){
            cin >> c[i][j];
        }
    }

    rep(k, n){
        rep(i, n){
            rep(j, n) chmin(c[i][j], c[i][k] + c[k][j]);
        }
    }

    int ans = 0;
    rep(i, h){
        rep(j, w){
            int x;
            cin >> x;
            if(x == -1) continue;
            ans += c[x][1];
        }
    }

    cout << ans << endl;
}

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

long long f(long long a) {
    return a * a * a * a * a;
}

void find(long long a, long long b) {
    cout << a << ' ' << b << '\n';
}

int main() {
    long long X; cin >> X;
    for(long long a=0; a<=1000; ++a) {
        for(long long b=0; b<=1000; ++b) {
            if(f(a) - f(b) == X) {
                find(a, b); return 0;
            } else if(f(a) + f(b) == X) {
                find(a, -b); return 0;
            } else if(-f(a) - f(b) == X) {
                find(-a, b); return 0;
            } else if(-f(a) + f(b) == X) {
                find(-a, -b); return 0;
            }
        }
    }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using ll = long long;
using itn = int;
using namespace std;
using Graph = vector<vector<int>>;
static const long double GRATIO=(long double)(1+sqrt(5))/2;
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 p[2][3]={
        {1,2,0},{2,0,1}
    };
    int N;
    cin>>N;
    vector<vector<int>> happy(N,vector<int>(3));
    rep(i,N) rep(j,3) cin>>happy[i][j];
    vector<vector<int>> dp(N+1,vector<int>(3,0));
    rep(i,3) dp[0][i]=0;
    //dp[i][j]:=jを行った時の,i日目までに得られる幸福度の最大値
    for(int i=0; i<N; i++){
        for(int j=0; j<3; j++){
            dp[i+1][j] = max(dp[i][p[0][j]]+happy[i][j],dp[i+1][j]);
            dp[i+1][j] = max(dp[i][p[1][j]]+happy[i][j],dp[i+1][j]);
        }
    }
    cout<<max(dp[N][0],max(dp[N][1],dp[N][2]));
}

Measured memory_bytes: 11136
import std.stdio, std.conv, std.string;
import std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

int DEBUG_LEVEL = 0;
void print()(){ writeln(""); }
void print(T, A ...)(T t, lazy A a){ write(t), print(a); }
void print(int level, T, A ...)(T t, lazy A a){ if(level <= DEBUG_LEVEL) print(t, a); }

void main(string[] args){
	if(args.length > 1 && args[1] == "-debug"){
		if(args.length > 2 && args[2].isNumeric) DEBUG_LEVEL = args[2].to!int;
		else DEBUG_LEVEL = 1;
	}
	
	long r = read.to!long;
	long g = read.to!long;
	long b = read.to!long;
	long n = read.to!long;
	
	long ans;
	foreach(i; 0 .. n / r + 1){
		foreach(j; 0 .. n / g + 1){
			long k = (n - (i * r + j * g)) / b;
			if(k < 0) continue;
			if(i * r + j * g + k * b != n) continue;
			print!1("i:", i, " j:", j, " k:", k);
			ans += 1;
		}
	}
	
	ans.writeln;
	
	
}


Measured memory_bytes: 256
import math

a, b, h, m = map(int, input().split())
h_theta = 2*math.pi * (60*h + m) / (60*12)
m_theta = 2*math.pi * m / 60
delta = h_theta-m_theta if h_theta>m_theta else m_theta-h_theta
l2 = a**2 + b**2 - 2*a*b*math.cos(delta)
print(math.sqrt(l2))

Measured memory_bytes: 9456
#include <iostream>
#include<string>
using namespace std;
int main(void){
    string num;
    cin>>num;
    long long N=num.size();
    int S[N];
    for (long long i = 0; i < N; ++i)
    {
        S[i]=(int)(num[i]-'0');
        //cout << S[i]<<endl;
    }
    long long count1=0;
    long long count2=0;
    for (long long i = 0; i < N; i++)
    {
        if (i%2==0)
        {
            if (S[i]==0)
            {
                count1++;
            }else
            {
                count2++;
            }
            
            
        }else
        {
            if (S[i]==1)
            {
                count1++;
            }else
            {
                count2++;
            }
            
            
        }
        
        
    }
    if (count1>count2)
    {
        count1=count2;
    }
    
    cout<<count1<<endl;
    
    return 0;
}


Measured memory_bytes: 896
#include <iostream>
using namespace std;
int main(void){
    int w;
    while(true){
        cin >> w;
        if(w == -1){
            break;
        }
 
        int waterbill;
        int base = 1150;
        if(w <= 10){
            waterbill = base;
        }
        if(w > 10){
            if(w < 20){
                waterbill = base + (w % 10)*125;
            }
            else if(w == 20){
                waterbill = base + 1250;
            }
            else if(20 < w && w < 30){
                waterbill = base + 1250 + (w % 10)*140;
            }
            else if(w == 30){
                waterbill = base + 1250 + 1400;
            }
            else{
                waterbill = base + 1250 + 1400 + (w - 30)*160;
            }
        }
 
        int save = 4280 - waterbill;
        cout << save << endl;
    }
}


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

 
int main() {
   string s;
   cin>>s;
   rep(i,3){
       if(s[i]==s[i+1]){
           cout<<"Bad"<<endl;
           return 0;
       }
       
   }
   cout<<"Good"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int gcd(int x, int y){
    return y?gcd(y,x%y):x;
}

int lcm(int x, int y){
    return x/gcd(x,y)*y;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n, m; cin >> n >> m;
    
    int ans = 1;
    for(int i = 1; i*i <= m; i++) {
        if(m%i!=0) continue;
        int b = m / i;
        if((ll)i * n <= m) ans = max(ans, i);
        if((ll)b * n <= m) ans = max(ans, b);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iterator>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <string>
#include <vector>
#include <limits>
#include <queue>
#include <cmath>
#include <map>
#include <set>

using namespace std;

using ll = long long;

int main()
{
    int a;
    cin >> a;
    string s;
    cin >> s;

    if(a >= 3200)
        cout << s << endl;
    else
        cout << "red" << endl;

    return 0;
}


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

int main() {
    int n;
    cin >> n;
    multiset< int> st;
    while (n--) {
        int x; cin >> x;
        st.emplace(x);
    }
    int res = 0;
    while (!st.empty()) {
        int x = *st.begin();
        int y = st.count(x);
        if (y > x) res += y - x;
        else if (y < x) res += y;
        st.erase(x);
    }
    cout << res << endl;
}

Measured memory_bytes: 4992