akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define max(a, b) (a > b ? a : b)
#define min(a, b) (a < b ? a : b)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) { rep(_, n) cout << a[_] << " "; cout << endl; }
#define outp(a, n) { cout << endl; rep(_, n) cout << a[_].F << " " << a[_].S << endl; }
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)
#define LB(v, n) (int)(lower_bound(all(v), n) - v.begin())
#define UB(v, n) (int)(upper_bound(all(v), n) - v.begin())

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    // ただの区間スケジューリングでは？
    
    int n, c, k;
    cin >> n >> c >> k;
    
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(all(a));
    
    int sum = 0, now = 0;
    while (1) {
        int leave = a[now] + k;
        // c的にかつ範囲外アクセス防ぐためupper_bound
        
        int it = UB(a, leave);
        chmin(it, now + c);
        sum++;
        now = it;
        if (now == n) break;
    }
    out(sum);
}



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

int main(){
  string s;cin >> s;
  int ans = 0;
  if(s[0]=='1')ans+=1;
  if(s[1]=='1')ans+=1;
  if(s[2]=='1')ans+=1;
  cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string.h>
#include <deque>
#include <stack>
#include <queue>
#define REP(i,j,n) for(int i=j;i<n;i++)
#define SORT(x) sort(x.begin(),x.end())

using namespace std;

class Proc {
public :
	int time;
	char name[10];
	Proc(const char *name, const int time);

};
Proc::Proc(const char *name, const int time) {
	this->time = time;
	strcpy(this->name, name);
}



int main() {
	queue<Proc> qq;
	int n, q,allcount=0;
	char na[10];
	int t;
	cin >> n >> q;
	for (int i = 0; i < n; i++) {
		scanf("%s %d", na, &t);
		qq.push(Proc(na, t));
	}

	while (!qq.empty()) {
		allcount += q;
		Proc proc = qq.front();
		qq.pop();
		proc.time -= q;
		if (proc.time <= 0) {
			allcount += proc.time;
			printf("%s %d\n", proc.name, allcount);
		}
		else {
			qq.push(proc);
			
		}
	}
	return 0;
}

Measured memory_bytes: 3796
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
// typedef long double ldouble;

using Graph = vector<vector<int>>;

// int ctoi(const char c){
//   if('0' <= c && c <= '9') return (c-'0');
//   return -1;
// }

// int gcd(int a, int b){
//   int ma = max(a,b);
//   int mi = min(a,b);
//   if(mi == 0) return ma;

//   return gcd(mi, ma%mi);
// }

// llong POW(llong a, llong b){
//   if(b == 0) return 1;
//   else{
//     if(b%2 == 0) return POW(a * a % MOD, b / 2) % MOD;
//     else return a * POW(a * a % MOD, b / 2) % MOD;
//   }
// }

int main(){
  int X;
  cin >> X;
  if(X<1200) cout << "ABC" << endl;
  else cout << "ARC" << endl;
}

Measured memory_bytes: 256
// वाह मोदी जी वाह!

#include<iostream>
#include<algorithm>
#include<bitset>

#include<cmath>
#include<cstring>
#include<climits>

#include<deque>
#include<vector>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>

#include<fstream>
#include<chrono>
using namespace std;

typedef long long LL;
typedef pair<LL,LL> p64;
typedef vector<LL> v64;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i,s,e) for(long long i=s;i<=e;i++)
#define brep(i,s,e) for(long long i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))
#define DANGER std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

int main()
{
    // DANGER;
    ofstream out("output.txt");

    auto start = chrono::high_resolution_clock::now();
    
    LL n;
    cin>>n;

    v64 b(n-1);
    for(auto &i:b) cin>>i;

    v64 a(n);
    for(auto &i:a) i = 100001;

    rep(i,0,n-2)
    {
        a[i] = min( a[i],b[i] );
        a[i+1] = min( a[i+1],b[i] );
    }

    LL ans = 0;
    for(auto i:a) ans += i;
    cout<<ans<<'\n';
    
    auto stop = chrono::high_resolution_clock::now();
    // auto duration = chrono::duration_cast<chrono::milliseconds>(stop - start); 
    // cout << "Time taken by function: " << duration.count() << " milliseconds" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
ll n,m;
cin >> n >> m;
vector<int> a(m);
int d = 0;
rep(i,m){
     cin >> a.at(i);
     d += a.at(i);
}
if(n >= d) cout << n-d << endl;
else cout << -1 << endl;

return 0;

}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define rep(i,f,n) for(ll i=(f); (i) < (n); i++)
#define repe(i,f,n) for(ll i=(f); (i) <= (n); i++)
using namespace std;

typedef long long ll;
ll INF = 1LL << 60;
ll MAX = 100010;
ll MOD = 2019;

int
main() 
{

  int N, K; cin >> N >> K;
  double ans = 0;
  double n = (double)(1.0 / N);

  repe(i, 1, N){
    int current = i;
    double coin = 1.0;
    while(current < K){
      current *= 2;
      coin /= 2;
    }
    ans += n * coin;
  }

  printf("%.13f\n", ans);

}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int n, a[100] = {0}, b[100] = {0}, c[100] = {0}, point = 0;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  for(int i = 0; i < n; i++){
    cin >> b[i];
  }
  for(int i = 0; i < n - 1; i++){
    cin >> c[i];
  }
  for(int i = 0; i < n; i++){
    point += b[a[i] - 1];
    if(i != 0){
      if(a[i] - 1 == a[i - 1]){
        point += c[a[i] - 1 - 1];
      }
    }
  }
  cout << point << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
//#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
const int N = 200005;
 
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	int n;
	cin>>n;
	int t = n%10;
	if(t == 3){
		cout<<"bon";
	}else{
		if(t == 0 || t == 1 || t == 6 || t == 8){
			cout<<"pon";
		}
		else{
			cout<<"hon";
		}
	}
	
	return 0;
}


Measured memory_bytes: 3652
from collections import deque

N = int(input())
g = [[] for _ in range(0,N+1)]
for i in range(0,N-1):
    a,b,c = map(int,input().split())
    g[a].append((b,c))
    g[b].append((a,c))
Q,K = map(int,input().split())
xy = []
for i in range(0,Q):
    x,y = map(int,input().split())
    xy.append((x,y))

d = [-1 for _ in range(0,N+1)]
d[K] = 0
queue = deque([[K,g[K]]])
while queue:
    start,edge = queue.popleft()
    for to,cost in edge:
        if d[to] != -1:
            continue
        d[to] = d[start] + cost
        queue.append((to,g[to]))

for x,y in xy:
    print(d[x] + d[y])


Measured memory_bytes: 60668
using System;
using System.Collections.Generic;
using System.Linq;

    class Program
    {
        static void Main(string[] args)
        {
            var logos = Console.ReadLine().Split(' ');
            var ML = new MaximizeLogo(logos);
            var max = ML.CalcMax();

            Console.WriteLine(max);
        }
    }

    public class MaximizeLogo
    {
        string[] logos;
        int max;

        public MaximizeLogo(string[] logos)
        {
            this.logos = logos;

        }

        public int CalcMax()
        {
            var logos_int = new List<int>();
            foreach (var logo in logos)
            {
                int p;
                if (!int.TryParse(logo, out p))
                {
                    return -1;
                }
                else
                {
                    logos_int.Add(p);
                }
            }

            logos_int = logos_int.OrderBy(v => v).ToList();

            return logos_int[0] + logos_int[1] + 10 * logos_int[2];
        }
}

Measured memory_bytes: 13396
#include<iostream>
#include<vector>
#include<cinttypes>
#include<numeric>


using ui32 = std::uint32_t;

class union_find {
public:
	using size_type = decltype(std::declval<std::vector<int>>().size());
private:
	std::vector<size_type> par;
	std::vector<size_type> size_;

public:
	union_find() :par{}, size_{} {}
	union_find(size_type s) :union_find{} {
		par.resize(s);
		std::iota(std::begin(par), std::end(par), 0);

		size_.resize(s, 1);
	}

	auto root(size_type index_)->size_type {
		if (par[index_] == index_)
			return
				par[index_];
		else
			return
				par[index_] = root(par[index_]);
	}

	auto size(size_type index_) {
		return size_[root(index_)];
	}

	auto same(size_type ai, size_type bi) {
		return root(ai) == root(bi);
	}

	auto unite(size_type ai, size_type bi) {
		auto ar = root(ai);
		auto br = root(bi);

		if (ar == br)
			return;

		const auto as = size(ar);
		const auto bs = size(br);

		if (as >= bs)
			std::swap(ar, br);

		par[br] = par[ar];

		if(as == bs)
			size_[ar] = size_[br] = as + bs + 1;

	}

};

int main() {

	ui32 n, m, q;

	std::cin >> n >> m;
	union_find uf(n);
	for (ui32 i{}; i < m; ++i) {
		ui32 s, t;
		std::cin >> s >> t;
		uf.unite(s, t);
	}

	std::cin >> q;
	for (ui32 i{}; i < q; ++i) {
		ui32 s, t; 
		std::cin >> s >> t;
		const auto ans = uf.same(s, t)?"yes":"no";
		std::cout << ans << "\n";
	}
	return 0;
}


Measured memory_bytes: 4588
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<ll, ll, ll> T;

int N;
vector<int> a(100001, 0);

int main(void){
    
    scanf("%d", &N);
    map<int, int> mp;
    for(int i = 0; i < N; ++i){
        scanf("%d", &a[i]);
        ++mp[a[i]];
    }
    
    ll ans = 1;
    if(N % 2){
        for(int i = 0; i < N; ++i) if(a[i] % 2){ printf("0\n"); return 0; }
        for(auto m : mp) if(m.first != 0 && m.second != 2){ printf("0\n"); return 0; }
        for(int i = 0; i < N / 2; ++i) ans *= 2, ans %= MOD;
    }
    else{
        for(int i = 0; i < N; ++i) if(a[i] % 2 == 0){ printf("0\n"); return 0; }
        for(auto m : mp) if(m.second != 2){ printf("0\n"); return 0; }
        for(int i = 0; i < N / 2; ++i) ans *= 2, ans %= MOD;
    }
    printf("%lld\n", ans);
    
    
    return 0;
}

Measured memory_bytes: 3584
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

#define iter(i, n) for (int i = 1; i <= n; ++i)
#define iter_d0(i, n) for (int i = n - 1; i >= 0; --i)

const int inf = 1e9;
const int NR = 2e5 + 10;

int n, X, Y, xa[NR], ya[NR], fa[NR], f[NR][20], dep[NR];
vector<int> Ta[NR], Tb[NR];

void dfs(int x) {
	f[x][0] = fa[x];
	for (int i = 1; (1 << i) <= dep[x]; ++i)
		f[x][i] = f[f[x][i - 1]][i - 1];
	for (int v : Tb[x]) if (v != fa[x]) {
		fa[v] = x, dep[v] = dep[x] + 1, dfs(v);
	}
}

int lca(int x, int y) {
	if (dep[x] < dep[y]) swap(x, y);
	iter_d0(i, 20) if (dep[f[x][i]] >= dep[y]) x = f[x][i];
	if (x == y) return x;
	iter_d0(i, 20) if (f[x][i] != f[y][i]) x = f[x][i], y = f[y][i];
	return fa[x];
}

int dist(int x, int y) {
	return dep[x] + dep[y] - 2 * dep[lca(x, y)];
}

int getans(int x, int fa, int d) {
	int res = dist(x, Y); //printf("!!%d\n", x);
	for (int v : Ta[x]) if (v != fa) {
		//printf("!%d %d\n", v, dist(v, Y));
		if (dist(x, v) >= 3) return inf;
		if (dep[v] > d + 1)
			res = max(res, getans(v, x, d + 1));
	}
	return res;
}

int main() {
	//freopen("5E.in", "r", stdin);
	scanf("%d%d%d", &n, &X, &Y); dep[0] = -1;
	iter(i, n - 1) {
		scanf("%d%d", &xa[i], &ya[i]);
		Ta[xa[i]].push_back(ya[i]);
		Ta[ya[i]].push_back(xa[i]);
	}
	iter(i, n - 1) {
		int x, y;
		scanf("%d%d", &x, &y);
		Tb[x].push_back(y);
		Tb[y].push_back(x);
	}

	dfs(Y);
	int tmp = getans(X, 0, 0);
	printf("%d\n", tmp == inf ? -1 : 2 * tmp);
	return 0;
}


Measured memory_bytes: 50688
a,d;int main(b){long long int t[21][2];for(scanf("%d%d",&a,&b);d<21;d++)t[d][a&1]=!(b-d);for(;--a-1&&scanf("%d",&b);)for(d=0;d<21;t[d++][a&1]=((b>d?0:t[d-b][!(a&1)])+((b<(21-d))?t[b+d][!(a&1)]:0)));scanf("%d",&b),a=!printf("%lld\n",t[b][0]);}

Measured memory_bytes: 0
def main():
    from itertools import product

    H, W, K = map(int, input().split())
    G = [input() for _ in range(H)]

    tot = 0

    rows = []
    for row in G:
        rows.append((cnt := row.count('#')))
        tot += cnt

    cols = []
    for col in zip(*G):
        cols.append(col.count('#'))

    ans = 0
    for row_conds in product([0, 1], repeat=H):
        t = tot
        for r, row_cond in enumerate(row_conds):
            if row_cond:
                t -= rows[r]
        for col_conds in product([0, 1], repeat=W):
            s = t
            for c, col_cond in enumerate(col_conds):
                if col_cond:
                    s -= cols[c]
                    for r2, row_cond2 in enumerate(row_conds):
                        if row_cond2 and G[r2][c] == '#':
                            s += 1
            if s == K:
                ans += 1
    print(ans)


if __name__ == '__main__':
    main()

# import sys
# input = sys.stdin.readline
# 
# sys.setrecursionlimit(10 ** 7)
# 
# (int(x)-1 for x in input().split())
# rstrip()
#
# def binary_search(*, ok, ng, func):
#     while abs(ok - ng) > 1:
#         mid = (ok + ng) // 2
#         if func(mid):
#             ok = mid
#         else:
#             ng = mid
#     return ok


Measured memory_bytes: 9236
#include <iostream>
#include <string.h>


using namespace std;

struct data{
	char buff[11];
	int time;
};


int main()
{
	data proc[100000];
	int n,q;
	cin>> n >> q;

	for(int i=0;i<n;i++){
		int t;
		char pname[11];
		cin >> pname >> t;
		strcpy((proc+i)->buff,pname);
		(proc+i)->time=t;
	}

	int head=0;
	int tail=n;
	int total_time=0;

	while(head!=tail){
		if((proc[head].time-q)<=0){
			cout<<proc[head].buff<<" "<<total_time+proc[head].time<<endl;
			total_time+=proc[head].time;
		}else{
			proc[head].time-=q;
			proc[tail]=proc[head];
			tail=(tail+1)%100000;
			total_time+=q;
		}
		head=(head+1)%100000;
	}


	return 0;
}



Measured memory_bytes: 4668
#include<bits/stdc++.h>
#define ll long long
#define ss second
#define ff first
#define pb push_back
using namespace std;

const int N = 1e6 + 6;

int main(){

        for(int i = 1;  i <= 5; i++){
                int x;
                cin >> x;
                if(x == 0){
                        cout << i << endl;
                }
        }
}


Measured memory_bytes: 3628
// DP

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n); for(ll i = 0; i < (ll)n; ++i)

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


ll A[100010][3];

int main() {
  int n; cin >> n;
  rep(i,n){ rep(j,3) cin >> A[i][j]; }
  
  ll dp[100010][3];
  rep(i,100010){  
    rep(j,3){ 
      dp[i][j] = 0;
    }
  }

  rep(i,n) {
    rep(j,3) {
      rep(k,3) {
        if(j == k) continue;
        chmax( dp[i+1][k], dp[i][j] + A[i][k] );
      }
    }
  }
  ll ans = 0;
  rep(j,3) chmax(ans, dp[n][j]);
  cout << ans << endl;
}

Measured memory_bytes: 8300
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = 1; i <= (int)(n); i++)
#define ll long long
#define umap unordered_map
using graph = vector<vector<int>>;
using graph2 = vector<vector<pair<int, int>>>;
#define oorret true //std::out_of_rangeが返された時
#define oor(x) [&](){try{x;} catch(const std::out_of_range& oor){return oorret;} return x;}()
double pi = 3.141592653589793238;
ll mod(ll x, ll y){if(x>=0||x%y==0) return x%y;return y+x%y;} //mod including minus
ll dv0(ll x, ll y){if(x>=0||x%y==0)return x/y;return x/y-1;} //rnd down
ll dv1(ll x, ll y){if(x%y==0) return dv0(x,y);return dv0(x,y)+1;} //rnd up
int D;
void calculate(vector<int> c, vector<vector<int>> s, int contest,int day, vector<int> &t, ll &score){
    ll p=0;
    int a[26];
    rep(i, 26){
        a[i]=0;
    }
    rep(i, D){
        rep(j, 26){
            p-=c[j]*(i+1-a[j]);
        }
        if(i!=day){
            p+=s[i].at(t[i])+c[t[i]]*(i+1-a[t[i]]);
            a[t[i]]=i+1;
        }else{
            p+=s[day].at(contest)+c[contest]*(day+1-a[contest]);
            a[contest]=i+1;
        }
        
    }
    if(score<p){
        score=p;
        t[day]=contest;
    }
}

int main(){
cin>>D;
vector<int> c(26);
rep(i, 26){
    cin>>c[i];
}
vector<vector<int>> s(D);
int r;
rep(i, D){
    rep(j, 26){
        cin>>r;
        s[i].push_back(r);
    }
}
int M[26];
rep(i, 26){
    M[i]=0;
}
vector<vector<int>> m(D);
rep(i, D){
    rep(j, 26){
        m[i].push_back(0);
    }
}
vector<int> a(26);

rep(i, 26){
    a[i]=0;
}
rep(i, D){
}
vector<int> t(D);
ll score=0;
rep(i, D){
    rep(j, 26){
        M[j]=0;
    }
    rep(j, 26){
        score-=c[j]*(i+1-a[j]);
        rep(k, j+1){
            if(s[i].at(j)+c[j]*(i+1-a[j])>M[k]){
                rep(l, j-k){
                    M[j-l]=M[j-l-1];
                    m[i].at(j-l)=m[i].at(j-l-1);
                }
                M[k]=s[i].at(j)+c[j]*(i+1-a[j]);
                m[i].at(k)=j;
            }
        }
    }
    score+=M[0];
    a[m[i].at(0)]=i+1;
    t[i]=m[i].at(0);
}
rep(j, 20){
    rep(i, j+2){
        rep(k, D){
            calculate(c, s, m[k].at(j+1-i),k, t, score);
        }
    }
}
rep(i, D){
    cout<<t[i]+1<<endl;
}
}


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

int main(void){
   int S, h, m, s;
   cin >> S;
   m=S/60;
   s=S%60;
   h=m/60;
   m=m%60;
   cout << h;
   cout << ":";
   cout << m;
   cout << ":";
   cout << s;
   cout << endl;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  ll a, v, b, w;
  cin >> a >> v >> b >> w;
  ll t;
  cin >> t;
  if (abs(a-b)+w*t <= v*t) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 3628
N=int(input())

P=[i*2+3 for i in range(700)]
ans=[]
for i in P:
    n=2
    while i*n <= 1400:
        if i*n in P:
            P.remove(i*n)
        n += 1

for j in P:
    if j % 5 == 2:
        ans.append(j)
        
print(*ans[:N])

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

using namespace std;

const long long MAXN = 2e6+5;
const long long MOD = 1e9+7;
long long dp[MAXN];
long long pref[MAXN];
int main(){
    long long n;
    cin>>n;
    dp[1] = n;
    pref[1] = n;
    dp[2] = 1LL*n*n;
    pref[2] = dp[1]+dp[2];
    for(long long i=3;i<=n;i++){
        dp[i] = dp[i-1];
        dp[i]+=1LL*(n-1)*(n-1);
        dp[i]%=MOD;
        dp[i]+=pref[i-3];
        dp[i]%=MOD;
        dp[i]+=(n-i+2);
        dp[i]%=MOD;
        pref[i] = pref[i-1]+dp[i];
        pref[i]%=MOD;

    }
    cout<<dp[n]<<endl;
}

Measured memory_bytes: 18688
package main

import (
	"fmt"
	//"math"
	"strings"
)

func main() {
	var s string
	fmt.Scan(&s)
	str := strings.Split(s, "")
	for x, v := range str {
		if v == "9" {
			str[x] = "1"
		}
		if v == "1" {
			str[x] = "9"
		}
	}
	fmt.Println(strings.Join(str, ""))
}

Measured memory_bytes: 640
n,d = map(int,input().split())
ans = 1
a = d+1
if a+d >= n:
    print(ans)
    exit(0)
while(True):
    a += (2*d)+1
    if a > n:
        if a-d-1<n:
            ans+=1
        print(ans)
        exit(0)
    ans+=1

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void print(const vector<int> &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
}

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int four = 0;
  bool two = false;
  int one = 0;
  rep(i, n) {
    int a;
    cin >> a;
    if(a % 4 == 0) four++;
    else if(a % 2 == 0) two = true;
    else one++;
  }
  one += two;
  four + 1 >= one ? out("Yes") : out("No");
  return 0;
}


Measured memory_bytes: 256
using System;

namespace ConsoleApplicationSample
{
    class Program
    {
        static void Main(string[] args)
        {
            int height, weight;
            string[] str = new string[2];

            while (true)
            {
                str = Console.ReadLine().Split(' ');
                height = int.Parse(str[0]);
                weight = int.Parse(str[1]);

                if (0 == height && 0 == weight) break;

                for (int i = 0; i < height; i++)
                {
                    for (int j = 0; j < weight; j++)
                    {
                        if (0 == (i + j) % 2)
                        {
                            Console.Write("#");
                        }
                        else
                        {
                            Console.Write(".");
                        }
                    }
                    Console.WriteLine("");
                }
                Console.WriteLine("");
            }
        }
    }

}

Measured memory_bytes: 5300
#include<bits/stdc++.h>
#define pb push_back 
#define mp make_pair
using namespace std;

const int maxn=6007;
typedef long long ll;

int n,m,ans1,ans2;
int f1[maxn],f2[maxn];
int a,b,c,d,e,f;

double now;

int main()
{
	int i,j,k,T;
	cin>>a>>b>>c>>d>>e>>f;
	a*=100;
	b*=100;
	
	ans1=a;
	
	f1[0]=1;
	f2[0]=1;
	for(i=0;i<=f-a;++i)
	{
		if(f1[i])
		{
			f1[i+a]=1;
		}
	}
	for(i=0;i<=f-b;++i)
	{
		if(f1[i])
		{
			f1[i+b]=1;
		}
	}
	for(i=0;i<=f-c;++i)
	{
		if(f2[i])
		{
			f2[i+c]=1;
		}
	}
	for(i=0;i<=f-d;++i)
	{
		if(f2[i])
		{
			f2[i+d]=1;
		}
	}
	
	for(i=0;i<=f;++i)
	{
		if(f2[i])
		{
			for(j=1;j<=f;++j)
			{
				if(f1[j])
				{
					if(i+j<=f&&100*i<=e*j)
					{
						if(now<=1.0*i/j)
						{
							ans1=i+j;
							ans2=i;
							now=1.0*i/j;
						}
					}
				}
			}
		}
	}
	
	cout<<ans1<<" "<<ans2<<endl;
	
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
long int ans;
int main() {
  for(;;) {
    scanf("%d", &n);
    if(n == 0) break;
    vector<int> v(n);
    for(int i = 0; i < n; ++i) scanf("%d", &v[i]);
    sort(begin(v), end(v));
    v[n - 1] = 0, v[0] = 0;
    for(int i = 0; i < n; ++i) ans+=v[i];
    ans /= n - 2;
    printf("%ld\n", ans);
    n = 0, ans = 0;
    v.clear();
  }
  return 0;
}

Measured memory_bytes: 3212
import java.util.*;

public class Main {
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n == 0) break;
			int col = sc.nextInt();
			int width = sc.nextInt();
			int space = sc.nextInt();
			sc.nextLine();
			ArrayList<String> list = new ArrayList<String>();
			while(true){
				String str = sc.nextLine();
				if(str.equals("?")) break;
				if(str.equals("")){
					StringBuilder sb = new StringBuilder();
					for(int i = 0; i < width; i++){
						sb.append(".");
					}
					list.add(sb.toString());
					continue;
				}
				for(int i = 0; i < str.length(); i+= width){
					String data = str.substring(i, Math.min(i + width, str.length()));
					StringBuilder sb = new StringBuilder(data);
					for(int j = data.length(); j < width; j++){
						sb.append(".");
					}
					list.add(sb.toString());
				}
			}
			
			StringBuilder emptystr = new StringBuilder();
			for(int i = 0; i < width; i++){
				emptystr.append(".");
			}
			StringBuilder spacestr = new StringBuilder();
			for(int i = 0; i < space; i++){
				spacestr.append(".");
			}
			
			for(int i = 0; i < list.size(); i+= n * col){
				for(int j = 0; j < n; j++){
					for(int k = 0; k < col; k++){
						int ind = i + j + k * n;
						if(ind >= list.size()){
							System.out.print(emptystr.toString());
						}
						else{
							String print = list.get(ind);
							System.out.print(print);
						}
						if(k != col - 1){
							System.out.print(spacestr);
						}
					}
					System.out.println();
				}
				System.out.println("#");
			}
			System.out.println("?");
		}
	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().doit();
	}
}

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

int main(){
  int n, m;
  map<int, int> problems;
  vector<int> yosen(m);
  cin >> n;
  for(int i=0; i<n; i++){
    int num;
    cin >> num;
    problems[num]++;
  }
  cin >> m;
  for(int i=0; i<m; i++){
    int num;
    cin >> num;
    if(problems[num] == 0){
      cout << "NO" << endl;
      return 0;
    }else{
      problems[num]--;
    }
  }
  cout << "YES" << endl;
  return 0;
}
  
  


Measured memory_bytes: 9728
n, k = map(int, input().split())
data = list(map(int, input().split()))
visited = [False for _ in range(n)]
nex = 0
visited[0] = True
while True:
    nex = data[nex]-1
    if visited[nex] is True:
        break
    else:
        visited[nex] = True
start = nex
cycle = 1
c = [start]
while True:
    nex = data[nex]-1
    if nex == start:
        break
    else:
        cycle += 1
        c.append(nex)
nex = 0
before = 1
while True:
    nex = data[nex]-1
    if nex == start:
        break
    else:
        before += 1

if k < before:
    nex = 0
    n = 0
    while n < k:
        nex = data[nex]-1
        n += 1
    print(nex+1)
elif start != 0:
    print(c[(k-before)%cycle]+1)
else:
    print(c[k%cycle]+1)


Measured memory_bytes: 33404
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
int n, d[55], ans;
int main(){
	scanf("%d", &n);
	rep(i,n) scanf("%d", d+i);
	rep(i,n) rep(j,i) ans += d[i] * d[j];
	printf("%d\n", ans);
}

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

#define vec              vector<int>
#define vecll            vector<ll>
#define vecd             vector<double>
#define vecst            vector<string>
#define vecb             vector<bool>
#define v2(v,n,m,init)   vector<vector<int>>  v(n, vector<int>(m, init))
#define vb2(v,n,m,init)  vector<vector<bool>> v(n, vector<bool>(m, init))
#define vll2(v,n,m,init) vector<vector<ll>>   v(n, vector<ll>(m, init))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
template <typename T>
bool chmax(T &a, const T& b){if(a<b){a=b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a>b){a=b; return true;} return false;}
//----------------------------------------------------------------

int main(void) {
  int h, w;
  cin >> h >> w;
  vll2(cost, 10, 10, 0);
  rep(i,10){
    rep(j,10){
      cin >> cost[i][j];
    }
  }
  v2(a, h, w, 0);
  rep(i,h){
    rep(j,w){
      cin >> a[i][j];
    }
  }

  rep(k,10){
    rep(i,10){
      rep(j,10){
        chmin(cost[i][j], cost[i][k]+cost[k][j]);
      }
    }
  }
  vecll best(10);
  rep(i,10){
    best[i]=cost[i][1];
  }

  ll ans=0;
  rep(i,h){
    rep(j,w){
      if(a[i][j]!=-1) ans+=best[a[i][j]];
    }
  }

  prt(ans);

}


Measured memory_bytes: 3720
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>
using namespace std;

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

const int MAXN = 17, X = 0, Y = 1;

int dp[MAXN][MAXN];
bool mat[MAXN][MAXN][2];

int main()
{
    int n, gx, gy, p, mx[2], my[2];
    cin >> n;
    while(n--)
    {
        cin >> gx >> gy;
        memset(dp, 0, sizeof(dp));
        memset(mat, 0, sizeof(mat));

        dp[0][0] = 1;
        cin >> p;
        REP(p)
        {
            cin >> mx[0] >> my[0] >> mx[1] >> my[1];
            if(mx[0] == mx[1]) mat[mx[0]][ min(my[0], my[1])][Y] = true;
            else mat[min(mx[0], mx[1])][my[0]][X] = true;
        }

        REP(gx + 1)rep(j,gy + 1)
        {
            if(!mat[i][j][Y])dp[i][j+1] += dp[i][j];
            if(!mat[i][j][X])dp[i+1][j] += dp[i][j];
        }
        if(dp[gx][gy] == 0) cout << "Miserable Hokusai!" << endl;
        else cout << dp[gx][gy] << endl;
    }

    return 0;
}

Measured memory_bytes: 0
#include<cstdio>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<algorithm>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<iostream>
#include<fstream>
#include<numeric>
#include<string>
#include<assert.h>
//#include<unordered_map>
//#include<unordered_set>
#include<vector>
#include<cstring>
#include<map>
#include<iterator>
#include <iomanip>
#include<bits/stdc++.h>

using namespace std;
#define lead_zero(x)    __builtin_clzll(x)
#define trail_zero(x)   __builtin_ctz(x)
#define total_1s(x)     __builtin_popcount(x)
#define ll long long int
#define pi 3.14159265358979323846
#define filein freopen("input.txt", "r", stdin)
#define forn(i,n) for(int i=0;i<n;i++)
#define maxx 1000000005
#define nullptr NULL

int main()
{
    ll t;


        int n;
        cin>>n;
        int sum=1;
        string s;
        cin>>s;
        char p=s[0];
        for(int i=1;i<n;i++)
        {
            //cout<<s[i]<<" "<<p<<endl;
            if(s[i]!=p)
            {
                sum++;
                    p=s[i];
            }

        }
        cout<<sum<<endl;



    return 0;

}


Measured memory_bytes: 3688
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <queue>
#include <iomanip>

using namespace std;
int A, B, C, D, E, F;
int dp[3001];
int main() {
  cin >> A >> B >> C >> D >> E >> F;
  for (int i=0; i<=F; i++) {
    dp[i] = INT_MIN;
  }
  dp[0] = 0;
  for (int i=1; i<=F; i++) {
    int a,b,c,d;
    a=b=c=d=INT_MIN;
    if (i >= 100*A && (dp[i-100*A]!=INT_MIN)) {
      a = dp[i-100*A];
    }
    if (i >= 100*B && (dp[i-100*B]!=INT_MIN)) {
      b = dp[i-100*B];
    }
    if (i >= C && (dp[i-C]+C)*100 <= E*(i-C-dp[i-C]) && (dp[i-C]!=INT_MIN)) {
      c = dp[i-C] + C;
    }
    if (i >= D && (dp[i-D]+D)*100 <= E*(i-D-dp[i-D]) && (dp[i-D]!=INT_MIN)) {
      d = dp[i-D] + D;
    }
    dp[i] = max(max(max(a,b),c),d);
    if (dp[i] >= 0) {
      // cout << "dp[" << i << "]: " << dp[i] << endl;
    }
  }
  int water = 0;
  int sugar = 0;
  double percent = 0;
  for (int i=0; i<=F; i++) {
    if (dp[i] <= 0) {
      continue;
    }
    double tmp = (double)dp[i]/(double)(i-dp[i]);
    if (tmp > percent) {
      water = i;
      sugar = dp[i];
      percent = tmp;
    }
  }
  if (water == 0) {
    water = A*100;
  }
  cout << water << ' ' << sugar << endl;
}


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

#define ll long long
#define INF 99999999
#define INF_LL 1LL << 60
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n); i >= 0; i--)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define RREP(i, a, n) for(int i = (int)(n); i >= a; i--)
#define all(x) (x).begin(),(x).end()

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

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

struct UnionFind {
    // 親ノードの番号を持つメンバ変数
    // ただし自分が親の時は-x(xは自身を含めた子ノードの数)
    vector<int> par;
    
    //　コンストラクタでの初期化1(初期値-1を持つn次元配列)
    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }
    
    // 与えられたノードの親ノードの番号を返すメンバ関数
    int root(int x) {
        // もしも親ノードが0以下なら、それは初期値なので自身が親
        if (par[x] < 0) return x;
        // 親ノードを再帰的に一番上までたどって返す
        // 単にroot(par[x])ではなく代入してるのは、根に直接張り直すため
        else return par[x] = root(par[x]);
    }
    
    // もし根が同じかどうかの判定
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    
    // ２つの根をマージする処理
    bool unite(int x, int y) {
        // 根をたどって、同じなら何もしない
        x = root(x); y = root(y);
        if (x == y) return false;
 
        // xもyも今は親ノードなので、子の数を比べる
        if (par[x] > par[y]) swap(x, y); // merge technique
 
        // 小さい方を親ノードにする
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    // 親ノードに入っている番号*-1 = この木のノード数を返す。
    int size(int x) {
        return -par[root(x)];
    }
};

int main()
{
    int N,M,K;
    cin >> N >> M >> K;
    UnionFind friends(N);
    vector<set<int> > direct(N);
    
    rep(i,M)
    {
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        friends.unite(a,b);
        direct[a].insert(b);
        direct[b].insert(a);
    }
    rep(i,K)
    {
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        if( !friends.same(a,b) ) continue;
        direct[a].insert(b);
        direct[b].insert(a);
    }
    rep(i,N)
    {
        cout << friends.size(i) - direct[i].size()-1;
        if(i+1 != N ) cout << " ";
    }
    cout << endl;
    //rep(i,N) cout << ans[i] << " " << direct_friends[i] << endl;
    //rep(i,N) cout << friends.size(i) << endl;
}


Measured memory_bytes: 24704
#include <iostream>

using namespace std;

using ll = long long;
const int MAX_A = 100000;

int main() {
    int N;
    ll K;
    ll cnt[MAX_A + 1];
    for (int i = 0; i < MAX_A + 1; ++i) {
        cnt[i] = 0;
    }
    cin >> N >> K;

    for (int i = 0; i < N; ++i) {
        int a, b;
        cin >> a >> b;
        cnt[a] += b;
    }

    for (int ans = 1; ans <= MAX_A; ++ans) {
        if (K <= cnt[ans]) {
            cout << ans << endl;
            break;
        }
        K -= cnt[ans];
    }
    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int flag = 0;
		String[] W = new String[N];
		for(int i = 0; i < N; i++) {
			W[i] = sc.next();
		}

		for(int i = 0; i < N-1; i++) {
			if(W[i].charAt(W[i].length() -1) != W[i+1].charAt(0)) {
				flag = 1;
				System.out.println("No");
				break;
			}
		}

		if(flag == 0) {
			for(int i = 0; i < N-1; i++) {
				for(int j = i+1; j < N; j++) {
					if(W[i].equals(W[j])) {
						flag = 1;
						System.out.println("No");
						break;
					}
				}
				if(flag != 0) {
					break;
				}
			}
		}

		if(flag == 0) {
			System.out.println("Yes");
		}
	}
}


Measured memory_bytes: 21844
N=int(input())
A=list(map(int,input().split()))
S,D=[0]*N,[0]*N

for i in range(N):
    if A[i]+i<N:S[A[i]+i] +=1
    if i-A[i]>0:D[i-A[i]] += 1

ans=0
for l in range(N):
    ans += S[l]*D[l]

print(ans)

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

struct edge{int to, id;};

vector<vector<edge>> g;
vector<int> ans;
void dfs(int x,int pre = -1,int pre_c = 0){
  int k = 1;
  for(auto nx : g[x]){
    if(nx.to == pre) continue;
    if(pre_c == k) k++;
    ans[nx.id] = k;
    dfs(nx.to,x,k);
    k++; 
  }
}

int main(){
  int n;
  cin>>n;
  g.resize(n);
  rep(i,n-1){
    int a,b;
    cin>>a>>b; 
    a--; b--;
    g[a].pb({b,i});
    g[b].pb({a,i});
  }
  ans.resize(n-1);
  dfs(0);
  int color = 0;
  rep(i,n){
    color = max(color,(int)g[i].size());
  }
  cout << color << endl;
  rep(i,n-1){
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 8320
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>


#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define DOUT(obj,n) cout << fixed << setprecision(n) << obj << endl

#define PI 3.14159265359

using namespace std;
typedef long long unsigned int ll;

int main() {
	ll l;
	cin >> l;
	DOUT(pow((l/3.0), 3), 12);
	return 0;
}

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

int main() {
 int X , x, A , B ;
  A = 0 ;
  cin >> X ;
  x = X;
    while (X> 0 ){
    B = X ;
    B %= 10 ;
    A += B ;
    X /=10 ;
  }
 //cout << A<< endl ;
  if ( x % A == 0)
    cout << " Yes" << endl;
  else 
     cout << "No" << endl ;
  }

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

money = 1000

buy = A[0]
sell = A[0]

for i in range(N - 1):
    if A[i] > A[i + 1]:
        if sell != 0:
            money += (money // buy) * (sell - buy)
        buy = A[i + 1]
        sell = 0
    else:
        sell = A[i + 1]

if sell != 0:
    money += (money // buy) * (sell - buy)

print(money)


Measured memory_bytes: 9192
import java.util.Scanner;

public class Main 
{
	public static void main(String[] args)
	{
	Scanner sc = new Scanner(System.in);
	long N = sc.nextInt();
	long D = sc.nextInt();
	
	long X,Y,D1,F=0;
	for (long i =0 ;i<N;i++)
	{
		X=sc.nextInt();
		Y=sc.nextInt();
		D1=X*X +Y*Y;
		if(D1<=(D*D))
		{
		F++;	
		}
	}
	System.out.println(F);
	}
}


Measured memory_bytes: 48972
using System;
using System.Linq;

namespace _165_a
{
    internal class WeLoveGolf
    {
        private static void Main(string[] args)
        {
            var k = int.Parse(Console.ReadLine() ?? throw new InvalidOperationException());
            var ab = Console.ReadLine()?.Split(' ').Select(int.Parse).ToArray();
            if (ab == null) return;
            var a = ab[0];
            var b = ab[1];

            for (var i = a; i <= b; i++)
            {
                if (i % k == 0)
                {
                    Console.WriteLine("OK");
                    return;
                }
            }

            Console.WriteLine("NG");
        }
    }
}

Measured memory_bytes: 28300
N=int(input())
def Calc(N):
    for h in range(1,3501):
        for n in range(h,3501):
            A=4*h*n-N*(h+n);B=N*h*n;
            if A<=0 or B<=0:
                continue
            if B%A==0:
                print(h,n,B//A)
                return
Calc(N)

Measured memory_bytes: 2940
/*PM1　問題１２*/
#include <stdio.h>
int main()
{
	int i = 0;
	int j = 0;
	int a, b, c;

	scanf("%d %d %d",&a,&b,&c);

	

	for (i = a; i <= b; i++)
	{
		if (c%i == 0)
		{
			j = j + 1;
		 }
	}
	
	printf("%d\n", j);
	return 0;
}


Measured memory_bytes: 2148
def comb(n, k):
    x, y = 1, 1
    k = min(k, n-k)
    for i in range(k):
        x *= n - i
        x %= MOD
        y *= i + 1
        y %= MOD
    return x*modinv(y) % MOD

def modinv(a):
    b=MOD
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return lastx%MOD

MOD=10**9+7
N,M,K=map(int,input().split())


x=0
for i in range(1,N):
   x=x+i*(N-i)
x=(x*M*M)%MOD

y=0
for j in range(1,M):
    y=y+j*(M-j)
y=(y*N*N)%MOD
    
ans=comb(N*M-2,K-2)*(x+y)%MOD
print(ans)

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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

template<typename T>
void print1(T begin, T end) {
	while (begin != end) {
		cerr << (*begin) << " ";
		*begin++;
	}
	cerr << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
	for (int i = 0; i < height; i++) {
		for (int j = 0; j < width; j++) {
			cerr << " " << Array[i][j];
		}
		cerr << endl;
	}
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
	std::cerr << head << " ";
	print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

// ------------------------------------------------------------------------------------------

signed main() {
	int n;
	cin >> n;
	cout << (180*(n-2)) << endl;

	return 0;
}

Measured memory_bytes: 256
mod = 1000000007
n, m = list(map(int, input().split()))
dp = [0]*(n+1)
dp[0] = 1
dp[1] = 1
for _ in range(m):
    ai = int(input())
    dp[ai] = -1

for i in range(2,n+1):
    if dp[i] == -1:
        continue
    if dp[i-1] == -1:
        pre1 = 0
    else:
        pre1 = dp[i-1]
    if dp[i-2] == -1:
        pre2 = 0
    else:
        pre2 = dp[i-2]
    dp[i] = (pre1 + pre2) % mod
    
print(dp[n])

Measured memory_bytes: 6900
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl '\n'
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define TOUPPER(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define TOLOWER(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define FILLZERO(s, n)                      \
    do {                                    \
        ostringstream os;                   \
        os << setw(n) << setfill('0') << s; \
        s = os.str();                       \
    } while (0);
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
#define INIT                               \
    std::cin.tie(nullptr);                 \
    std::ios_base::sync_with_stdio(false); \
    cout << std::fixed << std::setprecision(10);

template <typename T>
vector<T> make_vec(size_t a, T n) { return vector<T>(a, n); }
template <typename T, typename... Ts>
auto make_vec(size_t a, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...)); }
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;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
T intceil(T a, T b) {
    return (a + (b - 1)) / b;
}

signed main() {
    INIT;
    cin >> S;
    N = S.size() - 1;
    REP(bit, (1 << N)) {
        vi v;
        v.push_back(0);
        REP(i, N) {
            if ((bit >> i) & 1) {
                v.push_back(i + 1);
            }
        }
        v.push_back(N + 1);
        dump(v);
        REP(i, v.size() - 1) {
            T = S.substr(v[i], v[i + 1] - v[i]);
            ans += stoll(T);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3656
#[allow(unused_imports)]
use itertools::Itertools;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn main() {
    input! {
        n: usize,
        k: usize,
        mut a: [i64; n],
    }
    a.sort();
    println!("{}", a[0..k].iter().sum::<i64>());
}


Measured memory_bytes: 2148
#include <stdio.h>
#include <math.h>

int main(){
	int N;
	int x[8];
	int y[8];

	scanf("%d", &N)+1;

	for (int i = 0; i < N; i++) {
		scanf("%d %d", &x[i], &y[i])+1;
	}
	double sum = 0;
	for (int i = 0; i < N-1; i++) {
		for (int j = i + 1; j < N; j++) {
			sum += sqrt(((double)x[i] - (double)x[j]) * ((double)x[i] - (double)x[j]) + ((double)y[i] - (double)y[j]) * ((double)y[i] - (double)y[j]));
		}
	}

	printf("%.20f", sum * 2 / N);

	return 0;
}

Measured memory_bytes: 128
d,_ = gets.chomp.split(" ").map(&:to_i)
a = gets.chomp.split(" ").map(&:to_i)

able = true

a.each{|e|
  d -= e
  if d < 0
    able = false
    break
  end
}

if able
  puts("#{d}")
else
  puts("#{-1}")
end

Measured memory_bytes: 14724
let n=read_int()open Array;;let a=init n(fun _->Scanf.scanf"%d "(fun e->e))and b=make n 0and c=make 10001 0;;iter(fun e->c.(e)<-c.(e)+1)a;iteri(fun i _->if i<>0then c.(i)<-c.(i)+c.(i-1))c;for i=n-1downto 0do b.(c.(a.(i))-1)<-a.(i);c.(a.(i))<-c.(a.(i))-1;done;print_int b.(0);for i=1to n-1do print_string" ";print_int b.(i);done;print_newline()

Measured memory_bytes: 36128
//kid_kb//

#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define ull unsigned long long int
#define lower(str) transform(str.begin(),str.end(),str.begin(),::tolower);
#define upper(str) transform(str.begin(),str.end(),str.begin(),::toupper);
#define mod 1000000007
#define SORT(vec) sort(vec.begin(),vec.end());
#define pb push_back
#define csb __builtin_popcount
#define msb(n) (ll)(log2(n))
#define DIG(n) floor(log10(n))+1
#define kb ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ptr(arr) for(auto i:arr)cout<<i<<" ";
#define ptr2(vec) for(auto i:vec){for(auto j: i){cout<<j<<" ";}cout<<endl;}
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define mem(a,val) memset(a,val,sizeof(a))
//cout<<fixed<<setprecision(8)<<endl;

int main()
{
    kb
    //                                            Let's Fight !!!!!!!
    ll t;
//    cin>>t;
    t=1;
    while(t--){
        int n;
        cin>>n;
        string s;
        cin>>s;
        int w=0,r=0;
        rep(i,0,s.length()){
            if(s[i]=='W')w++;
            else r++;
        }
        if(w==s.length() or r==s.length())cout<<0<<endl;
        else{
            string temp="";
            rep(i,0,r)temp+='R';
            rep(i,0,w)temp+='W';
            int c=0;
            rep(i,0,s.length()){
                if(temp[i]!=s[i])c++;
            }
            cout<<c/2<<endl;
        }
        
        
        
    }
    
    return 0;
}


Measured memory_bytes: 3868