akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#define MAXW 101
#define MAXH 101
int main(){
  int i,j;
  int n;
  int adj[MAXW][MAXH]={0};
  int deg;
  int u;
  int a;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d %d",&u,&deg);
    for(j=0;j<deg;j++){
      scanf("%d",&a);
      adj[u][a]=1;
    }
  }
  for(i=1;i<=n;i++){
    for(j=1;j<n;j++){
      printf("%d ",adj[i][j]);
    }
    printf("%d\n",adj[i][j]);
  }
  return 0;
}

Measured memory_bytes: 648
def main():
    h, w = map(int, input().split())
    s = [[i == "." for i in input()] for _ in range(h)]
    dp = [[10000] * w for _ in range(h)]
    dp[0][0] = 1 - s[0][0]
    for r in range(1, h):
        dp[r][0] = dp[r - 1][0] + (s[r - 1][0] and not s[r][0])
    for c in range(1, w):
        dp[0][c] = dp[0][c - 1] + (s[0][c - 1] and not s[0][c])
    for r in range(1, h):
        for c in range(1, w):
            dp[r][c] = min(dp[r - 1][c] + (s[r - 1][c] and not s[r][c]), dp[r][c - 1] + (s[r][c - 1] and not s[r][c]))
    print(dp[-1][-1])


if __name__ == '__main__':
    main()

Measured memory_bytes: 3188
from collections import deque
 
N,u,v=map(int,input().split())
G=[[] for _ in range(N)]
for _ in range(N-1):
  a,b = map(int,input().split())
  G[a-1].append(b-1)
  G[b-1].append(a-1)
 
def bfs(s):
    seen = [0]*N
    d = [0]*N
    todo = deque()
    seen[s]=1
    todo.append(s)
    while len(todo):
      a = todo.popleft()
      for b in G[a]:
        if seen[b] == 0:
          seen[b] = 1
          todo.append(b)
          d[b] += d[a] + 1
    return d
  
d1 = bfs(u-1)
d2 = bfs(v-1)
 
print(max([d2[i] for i in range(N) if d1[i]<=d2[i]])-1)

Measured memory_bytes: 34472
n, m, q = map(int, input().split())
image = [[0] * n for _ in range(n)]
for _ in range(m):
    l, r = map(int, input().split())
    image[l - 1][r - 1] += 1
for l in range(n - 1, -1, -1):
    for r in range(l + 1, n):
        image[l][r] += image[l + 1][r] + image[l][r - 1] - image[l + 1][r - 1]
for _ in range(q):
    a, b = map(int, input().split())
    c = image[a - 1][b - 1]
    print(c)

Measured memory_bytes: 57432
N = int(input())
data = []
for _ in range(N):
    M = int(input())
    XY = [list(map(int, input().split())) for _ in range(M)]
    data.append((M, XY))

ans = 0
for bit in range(2**N):
    ok = True
    P = [-1]*N
    c = 0
    for i in range(N):
        M, XY = data[i]
        if bit & (1<<i):
            c += 1
            if P[i] == 0:
                ok = False
                break
            P[i] = 1
            for x, y in XY:
                if P[x-1] == -1:
                    P[x-1] = y
                elif P[x-1] != y:
                    ok = False
                    break
        else:
            if P[i] == 1:
                ok = False
            P[i] = 0
    if ok:
        ans = max(ans, c)
print(ans)

Measured memory_bytes: 45660
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int h, w, k, ans = 0;
string s[6];

int main()
{
    cin >> h >> w >> k;
    for (int in = 0; in < h; in++)
    {
        cin >> s[in];
    }

    for (int i = 0; i < (1 << h); i++)
    {
        for (int j = 0; j < (1 << w); j++)
        {
            int cnt = 0;
            for (int x = 0; x < h; x++)
            {
                for (int y = 0; y < w; y++)
                {
                    if (s[x][y] == '#' && i >> x & 1 && j >> y & 1)
                    {
                        cnt++;
                    }
                }
            }

            ans += cnt == k;
        }
    }

    cout << ans << endl;
}

/*
#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
    int h, w, k, rows[6], columns[6], c[6][6], total = 0, ans = 0;
    cin >> h >> w >> k;
    for (int in = 0; in < h; in++)
    {
        int x = 0;
        for (int in2 = 0; in2 < w; in2++)
        {
            char y;
            cin >> y;
            c[in][in2] = y == '#';
            x += c[in][in2];
            total += c[in][in2];
        }
        rows[in] = x;
    }

    for (int i = 0; i < w; i++)
    {
        int x = 0;
        for (int j = 0; j < h; j++)
        {
            x += c[j][i];
        }
        columns[i] = x;
    }

    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if (rows[i] + columns[j] - (c[i][j] == '#') == k)
            {
                cout << i << " " << j << endl;
                ans++;
            }
        }
    }

    cout << ans << endl;
}
*/

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int gcd(int x, int y){
  if(y==0)return x;
  return gcd(y,x%y);
}

int cnter(int n){
  int cnt = 0;
  while(n&&n%2==0){
    cnt++;
    n/=2;
  }
  return cnt;
}

int main(){
  int n; cin >> n;
  ll i = 0;
  for(i = 0; i*i <= n; ++i);
  cout << (i-1)*(i-1) << endl;
} 


Measured memory_bytes: 3592
#include<string>
#include<iostream>
using namespace std;
string x,y="KIHBR";
int cnt;
bool ok=1;
int main()
{
    cin>>x;
    if(x.size()>9) printf("NO\n");
    else
    {
        for(int i=0;i<x.size();i++)
        {
            if(i>=1 && (x[i]==x[i-1] || x[i]=='A' && (x[i-1]=='I' || x[i-1]=='K') ) ) 
            {
                ok=0;
                break;
            }
            if(x[i]=='A') continue;
            if(x[i]!=y[cnt])
            {
                ok = 0;
                break;
            }
            else 
            {
                cnt++;
            }
        }
       // printf("%d\n",cnt);
        if(cnt!=y.size()) ok = 0;
        printf("%s\n",ok?"YES":"NO");
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define s second
#define f first
#define mt make_tuple
#define foreach(it, a) for(__typeof(a.begin()) it=a.begin(); it!=a.end(); it++)
#define forn(i, a) for(int i=0; i<a; i++)
#define INF 1e9
#define all(x) x.begin(), x.end()
#define MOD 1e9+7 

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<pi,int> pii;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef unsigned int uint;

int N, par[100005], ranks[100005], a, b, cnt=0;
ll res=0;

struct town
{
	int x, y, id;
	town(int a, int b, int c)
	{
		x=a;
		y=b;
		id=c;
	}
	town(){}
}T[100005], rT[100005];

struct Node
{
	ll cost;
	int x;
	int y;
	Node(ll a, int b, int c)
	{
		cost=a;
		x=b;
		y=c;
	}
	Node(){}
}fin[300005];

inline bool cmp(const Node&a, const Node&b)
{
	return a.cost<b.cost;
}
inline bool cmpx(const town&a, const town&b)
{
	return a.x<b.x;
}
inline bool cmpy(const town&a, const town&b)
{
	return a.y<b.y;
}
void init()
{
	for(int i=0; i<N; i++)
		par[i]=i, ranks[i]=0;
}

inline int find(int x)
{
	return par[x]==x?x:par[x]=find(par[x]);
}

inline bool unite(int x, int y)
{
	x=find(x), y=find(y);
	if(x==y)
		return  false;
	if(ranks[x]<ranks[y])
		par[x]=y;
	else
	{
		par[y]=x;
		if(ranks[x]==ranks[y])
			ranks[x]++;
	}
	return true;
}

int main() 
{
	scanf("%d", &N);
	init();
	for(int i=0; i<N; i++)
	{
		scanf("%d %d", &a, &b);
		T[i]=town(a, b, i);
		rT[i]=T[i];
	}
	sort(T, T+N, cmpx);	
	sort(rT, rT+N, cmpy);	
	
	for(int i=0; i<N-1; i++)
	{
		fin[cnt++]=Node(min(abs(T[i].x-T[i+1].x), abs(T[i].y-T[i+1].y)), T[i].id, T[i+1].id);
		fin[cnt++]=Node(min(abs(rT[i].x-rT[i+1].x), abs(rT[i].y-rT[i+1].y)), rT[i].id, rT[i+1].id);
	}
	sort(fin, fin+cnt, cmp);
/*	for(int i=0; i<cnt; i++)
	{
		cout<<fin[i].cost<<" "<<fin[i].x<<" "<<fin[i].y<<endl;
	}*/
	for(int i=0; i<cnt; i++)
	{
		res+=unite(fin[i].x, fin[i].y)*fin[i].cost;
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 8064
<?php
fscanf(STDIN, "%d", $A);
fscanf(STDIN, "%d", $B);
fscanf(STDIN, "%d", $C);
fscanf(STDIN, "%d", $X);

$ans = 0;

$c500 = min($A, floor($X / 500));
for ($i = $c500; $i >= 0; $i--) {
    $rest1 = $X - $i * 500;
    $c100 = min($B, floor($rest1 / 100));
    for ($j = $c100; $j >= 0; $j--) {
        $rest2 = $rest1 - $j * 100;
        $c50 = $rest2 / 50;
        if ($c50 <= $C) {
            $ans++;
        }
    }
}

echo $ans . "\n";


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


string solve(string s){
  string ans = "";
  string pre = s.substr(0,1);
  int n=1,i;

  for(i=1; i<s.size(); i++){
    if(s.substr(i,1) == pre){
      n++;
      if(i != s.length()-1) continue;
    }
    else{
      ans += to_string(n) + pre;
      n=1;
      pre = s.substr(i,1);    
    }
  }
  ans += to_string(n) + pre;
  return ans;
}


int main(){

  while(1){
    int n; cin >> n;
    if(n == 0)break;
    string s; cin >> s;
    for(int i=0; i<n; i++) s = solve(s);
    cout << s << endl;
  }  

}

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

int main(){
  string S;
  cin>>S;
  unordered_set<int> A;
  for(char c:S)
    A.insert(c);
  for(char c='a';(int)c<='z';c=(char)((int)c+1))
    if(!A.count(c)){
      cout<<c<<endl;
      return 0;
    }
  cout<<"None"<<endl;
}

Measured memory_bytes: 512
a,b,c,k = (int(x) for x in input().split())
import sys 

if a >= k:
    print(k * 1)
    sys.exit()
elif k > a:
    if a + b >= k:
        print(a * 1)
        sys.exit()
    elif k > a + b:
        print(a * 1 + (k - a - b)* -1)
        sys.exit()



Measured memory_bytes: 9184
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    long long int a[200];
    a[0]=2;
    a[1]=1;
    int n;
    cin>>n;
    
    for(int i=2;i<n+1;i++){
        a[i]=a[i-1]+a[i-2];
    }
    cout<<a[n]<<endl;
    return 0;
}


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

using namespace std;
using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define rep(i, N) for (ll i = 0; i < (N); i++)
#define For(i, a, b) for (ll i = (a); i < (b); i++)
#define all(A) (A).begin(), (A).end()

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


int main(){
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    
    ll ansB = B / C + B / D;
    ll ansA = (A - 1) / C + (A - 1) / D;
    ll tmp = gcd(C, D);
    ll lcm = D / tmp * C;
    ansB -= B / lcm;
    ansA -= (A - 1) / lcm;
    ll ans = (B - ansB) - ((A - 1) - ansA);
    // cout << tmp << " " << lcm << endl;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
//abc064_d.cpp
//Sun Apr 21 13:42:38 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	int left = 0;
	int right = 0;
	int addleft = 0;
	int addright = 0;
	for (int j=0;j<s.length();j++){
		if (left==right && s[j]==')'){
			addleft++;
		}else if (s[j] == '('){
			left++;
		}else if (s[j] == ')'){
			right++;
		}
	}
	if (left>right){
		addright = left-right;
	}

	for (int i=0;i<addleft;i++){
		cout << '(';
	}
	cout << s;
	for (int i=0;i<addright;i++){
		cout << ')';
	}
	printf("\n");
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 256
N,M=map(int,input().split())
candi=["na"]*N
ans=0

for i in range(M):
    s,c=(map(int, input().split()))
    if candi[s-1]=="na":
        candi[s-1]=c
    elif candi[s-1]!=c:
        ans=-1



if ans==-1:
    pass
elif candi[0]==0:
    if N==1:
        ans=0
    else:
        ans=-1
elif N==1 and M==0:
    ans=0
else:
    for k,num in enumerate(candi):
        if k==0 and num=="na":
            ans+=1*10**(N-1)
        elif num=="na":
            ans+=0
        elif num!="na":
            ans+=int(num)*10**(N-k-1)

print(ans)

Measured memory_bytes: 3064
class Integer
  attr_accessor :mod
  @mod = nil
  def self.set_mod(mod = 10**9 + 7)
    @mod = mod
  end

  def combination(k = self) # 4C2 = 6
    return 1 if k.zero?
    if @mod.nil?
      (self - k + 1..self).inject(:*) / k.factorial
    else
      (self - k + 1..self).inject{|i,m|i * m % @mod} * k.factorial.modinv % @mod
    end
  end

  def permutation(k = self) # 4P2 = 12
    return 1 if k.zero?
    if @mod.nil?
      (self - k + 1..self).inject(:*)
    else
      (self - k + 1..self).inject{|i,m|i * m % @mod}
    end
  end

  def factorial(step = 1) # 4! = 24
    return 1 if self.zero?
    if @mod.nil?
      (1..self).inject(:*)
    else
      (1..self).inject{|i,m|i * m % @mod}
    end
  end

  def modinv # https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a
    mod = 10**9 + 7
    a = self; b = mod; u = 1; v = 0
    while b > 0
      t = a / b
      a -= t * b
      a, b = b, a
      u -= t * v
      u, v = v, u
    end
    u %= mod
    u += mod if u < 0
    u
  end

  # 繰り返し二乗法
  def repeat_squaring(p, mod = (10**9 + 7))
    return 1 if p == 0
    if p % 2 == 0
      t = repeat_squaring(p/2, mod)
      return t*t % mod
    end
    self * repeat_squaring(p - 1, mod) % mod
  end

  alias :C :combination
  alias :P :permutation
  alias :! :factorial
end

Integer.set_mod
n, a, b = gets.split.map(&:to_i)
mod = 10 ** 9 + 7


def nCk(n,k)
  mod = 10 ** 9 + 7
  (1..k).map{|x| n - x + 1}.inject{|m,i|i*m % mod} * (1..k).inject{|m,i|i*m % mod}.modinv
end

# x = (2.repeat_squaring(n) % mod) - n.C(a) - n.C(b) - 1
x = (2.repeat_squaring(n) % mod) - nCk(n,a) - nCk(n,b) - 1


p x % mod
# 7 34076506





Measured memory_bytes: 4988
#include <stdio.h>
#include <string.h>
typedef long long ll;

int main(void) {
  ll i, j, k, ans = 0, now = 0, cnt = 0;
  char s[500010];
  scanf("%s", s);
  ll a[strlen(s) + 1];
  for(i = 0; s[i]; ++i) if(s[i] == '<') {
    if(!i || s[i - 1] == '>') a[i] = 0;
    a[i + 1] = a[i] + 1;
  }
  for(--i; i >= 0; --i) if(s[i] == '>') {
    if(!s[i + 1] || s[i + 1] == '<') a[i + 1] = 0;
    if(!i || s[i - 1] == '>' || a[i] < a[i + 1] + 1) a[i] = a[i + 1] + 1;
  }
  for(i = 0; s[i]; ++i) ans += a[i];
  ans += a[i];
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 4608
import java.util.*;class Main{public static void main(String[]z){Scanner s=new Scanner(System.in);for(int h,w,i,j,c,u,v,o;(h=s.nextInt())>0;System.out.println(c)){char[][]x=new char[h][w=s.nextInt()];for(i=0;i<h;++i)x[i]=s.next().toCharArray();for(c=i=0;i<h;++i)for(j=0;j<w;++j)if(x[i][j]>0){Queue<int[]>l=new LinkedList<int[]>();for(l.add(new int[]{i,j,x[i][j]});!l.isEmpty();){int[]k=l.poll();u=k[0];v=k[1];o=k[2];if(0<=u&&u<h&&0<=v&&v<w&&x[u][v]==o){x[u][v]=0;for(int[]e:new int[][]{{u+1,v,o},{u-1,v,o},{u,v+1,o},{u,v-1,o}})l.add(e);}}++c;}}}}

Measured memory_bytes: 12000
n=int(input())
ans='Yes'
pt, px, py=0, 0, 0
for i in range(n):
  t, x, y=map(int, input().split())
  if t-pt<abs(x-px)+abs(y-py):
    ans='No'
    break
  elif (abs(x-px)+abs(y-py)-(t-pt))%2==1:
    ans='No'
    break
  pt, px, py=t, x, y
print(ans)

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


int main() {
	
	int N, a=0, b=0;
	cin >> N;
	vector<int> w(N);
	for(auto &i:w) {
		cin >> i;
		b += i;
	}
	int sup = b;
	for(int i=0; i<N-1; i++){
		a += w.at(i);
		b -= w.at(i);
		sup = min(sup,abs(a-b));
	}
	cout << sup << endl;
	
	
	return 0;
}

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

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

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}


int main() {
    ll N,D,A;
    cin >> N >> D >> A;
    // pos,life
    vector<pair<ll,ll>> monster(N);
    // モンスターの座標表(二分探索用)
    vector<ll> poss(N);
    REP(i,N) {
        int x,h;
        cin >> x >> h;
        monster[i] = make_pair(x,h);
        poss[i] = x;
    }

    // 座標ソート
    sort(ALL(monster));
    sort(ALL(poss));

    if (N==1) {
        cout << (monster[0].second+A-1)/A << endl;
        return 0;
    }

    // N体目で重なりが終わる線のかず それを含む
    vector<ll> end(N,0);

    ll ans = 0;
    ll kasanari = 0;
    REP(i,N) {

        // endに入っていた場合重なりを解除
        if (end[i] != 0) {
            kasanari -= end[i];
            end[i] = 0;
        }

        // ダメージ足りないなら爆弾の追加
        if ( kasanari * A < monster[i].second ) {
            ll need = (monster[i].second - (kasanari * A) + A -1)/ A ;
            kasanari += need;
            ans += need;
            // 二分探索でどこまで影響があるかを調べる。
            ll key = poss[i] + (2 * D);
            auto itr = upper_bound(ALL(poss),key);
            ll index;
            // 最後まで影響ある場合は無視で良い
            if (itr == poss.end()) {
                continue;
            }
            end[ itr - poss.begin()] += need;

            // cout << index << endl;
        }


        if (kasanari < 0) {
            cout << "Error " << endl;
            exit(1);
        }
    }

    cout << ans << endl;

    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> b(n - 1);
  for (int i = 0; i < n - 1; i++) cin >> b.at(i);

  int ans  = 0;
  for (int i = 0; i < n; i++) {
    if (i == 0) ans += b.at(0);
    else if (i == n - 1) ans += b.at(n - 2);
    else ans += min(b.at(i), b.at(i - 1));
  }
    
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    int n; cin >> n;
    vector<int> v(n);
    REP(i,n) cin >> v[i];
    sort(ALL(v));

    int ans = 0;
    REP(i,n-2) FOR(j,i+1,n-1) {
        auto it = lower_bound(ALL(v),v[i]+v[j]);
        auto d = distance(v.begin()+j,it);
        ans += d-1;
    }

    cout << ans << endl;

    return 0;
}

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

#ifdef LOCAL
#include "/home/shahraaz/bin/debug.h"
#else
#define db(...)
#endif

using ll = long long;
#define f first
#define s second
#define pb push_back
#define all(v) v.begin(), v.end()

const int NAX = 1e6 + 5, MOD = 1000000007;

struct Solution
{
    Solution() {}
    void solveCase();
};

int cnt[NAX];
bool isPrime[NAX];
vector<int> divisors[NAX];

void Solution::solveCase()
{
    for (size_t i = 2; i < NAX; i++)
        isPrime[i] = true;
    for (size_t i = 2; i < NAX; i++)
    {
        if (isPrime[i])
            for (size_t j = i; j < NAX; j += i)
            {
                if (j != i)
                    isPrime[j] = false;
                divisors[j].pb(i);
            }
    }
    int n;
    cin >> n;
    vector<int> a(n);
    ll curr_gcd = -1;
    bool ok = true;
    for (size_t i = 0; i < n; i++)
    {
        cin >> a[i];
        for (auto &x : divisors[a[i]])
        {
            if (cnt[x])
                ok = false;
            cnt[x]++;
        }
        if (curr_gcd == -1)
            curr_gcd = a[i];
        else
            curr_gcd = __gcd(curr_gcd, (ll)a[i]);
    }
    db(ok);
    if (ok)
        cout << "pairwise coprime";
    else if (curr_gcd == 1)
        cout
            << "setwise coprime";
    else
        cout << "not coprime";
}

int32_t main()
{
#ifndef LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
    int t = 1;
    // cin >> t;
    Solution mySolver;
    for (int i = 1; i <= t; ++i)
    {
        mySolver.solveCase();
#ifdef LOCAL
        cerr << "Case #" << i << ": Time " << chrono::duration<double>(chrono::steady_clock::now() - TimeStart).count() << " s.\n";
        TimeStart = chrono::steady_clock::now();
#endif
    }
    return 0;
}


Measured memory_bytes: 67376
package main

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

func main() {
	N := readInt()
	K := readInt()
	A := make([]int, N)
	for i := 0; i < N; i++ {
		A[i] = readInt()
	}
	F := make([]int, N)
	for i := 0; i < N; i++ {
		F[i] = readInt()
	}

	sort.Ints(A)
	sort.Sort(sort.Reverse(sort.IntSlice(F)))

	l := -1            // ng
	r := A[N-1] * F[0] // ok
	for r > l+1 {
		m := l + (r-l)/2
		isOk := func(x int) bool {
			result := 0
			for i := 0; i < N; i++ {
				t := A[i] - x/F[i]
				if t > 0 {
					result += t
				}
			}
			return result <= K
		}
		if isOk(m) {
			r = m
		} else {
			l = m
		}
	}
	fmt.Println(r)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}


Measured memory_bytes: 6656
n, k = map(int, input().split())
x = sorted([0] + list(map(int, input().split())))

ans = float("inf")
for i in range(n-k+1):
    ans = min(ans, min(abs(x[i]), abs(x[i+k])) + abs(x[i+k]-x[i]))

print(ans)

Measured memory_bytes: 14392
#include <iostream>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
string a;

int main(){
    cin >> a;
    int n;
    n = a.size();
    int ans = 0xE869120;
    for(int i = 0; i <= n - 3; i++){
        int num = (a[i] - '0') * 100 + (a[i + 1] - '0') * 10 + (a[i +2] - '0');
        ans = min(ans, abs(num - 753));
    }    
    cout << ans << endl;
}

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

using ll = long long;

// 各桁の数の和
int digitSum(ll x) {
  int sum = 0;
  while (x > 0) {
    sum += x % 10;
    x /= 10;
  }
  return sum;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int k;
  cin >> k;
  
  vector<ll> x;
  for (ll i = 0; i < 14; i++) {
    ll keep = pow(10, i);
    for (ll j = 1; j <= 9999; j++) {
      x.emplace_back(keep * j + keep - 1);
    }
  }
  
  sort(x.begin(), x.end());
  x.erase(unique(x.begin(), x.end()), x.end());
  
  vector<bool> judge(x.size(), true);
  for (int i = 0; i < x.size() - 1; i++) {
    for (int j = i + 1; j < x.size(); j++) {
      if ((double) x.at(i) / digitSum(x.at(i)) > (double) x.at(j) / digitSum(x.at(j))) {
        judge.at(i) = false;
        break;
      }
    }
  }
  
  int it = 0;
  for (int i = 0; i < k; i++) {
    while (!judge.at(it)) it++;
    cout << x.at(it) << '\n';
    it++;
  }
}

Measured memory_bytes: 5736
#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn=1e5+100;
int n, k;
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0);
    cin>>n>>k;
    cout<<(n%k!=0)<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define tezi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(c) c.begin(),c.end()
#define ll long long
#define ull unsigned long long
#define traverse(c,it) for(auto it=c.begin();it!=c.end();it++)
#define lowerb(v,a) lower_bound(v.begin(),v.end(),a)
#define lowerbarr(v,n,a) lower_bound(v,v+n,a)
#define upperb(v,a) upper_bound(v.begin(),v.end(),a)
#define upperbarr(v,n,a) upper_bound(v,v+n,a)
#define maxval(v) max_element(v.begin(),v.end())
#define maxarr(v,n) max_element(v,v+n)
#define minval(v) min_element(v.begin(),v.end())
#define minarr(v,n) min_element(v,v+n)
#define sz(a) (ll)a.size()
#define f first
#define s second
#define PI 3.1415926536
#define mem0(v) memset(v,0,sizeof(v))
#define memf(v) memset(v,false,sizeof(v))
#define memt(v) memset(v,true,sizeof(v))
#define mem(v,a) memset(v,a,sizeof(v))
#define npos string::npos
#define MAX 1000000
#define MOD 1000000007
                   /**************SIEVE****************/

bool prime[MAX+1];
vector<ll> v;
void sieve(){ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true.
   
    memset(prime, true, sizeof(prime)); 
  
    for (long p=2; p*p<=MAX; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (long i=p*p; i<=MAX; i += p) 
                prime[i] = false; 
        } 
    } 
  for(int i=0;i<=MAX;i++)if(prime[i])v.pb(i);
  
   
    
   
} 
 
                                        /**************gcd****************/

ll gcd(ll a,ll b) 
{ if(a>b)swap(a,b);
    if (a == 0) 
        return b; 
 return gcd(b%a, a); 
}
 
 
 
                                         /**************POWER****************/
 ull binpow(ll a, ll b) {
    if (b == 0)
        return 1;
    ll res = binpow(a, b / 2)%MOD;
    if (b % 2)
        return ((ull)res * (ull)res * (ull)a)%MOD;
    else
        return ((ull)res * (ull)res)%MOD;
}
   

 
 
 
 
                                     /**************MAIn****************/


int main()
{   tezi
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("put.txt","w",stdout);
  #endif

  int T=1;
  //cin>>T;
  while(T--)
  {vector<pair<int,int>> v;
    int n;
    cin>>n;
    loop(i,0,n)
    {
      int a,b;
      cin>>a>>b;
      v.pb({a,b});
    }
    loop(i,0,n-2)
    {
      if(v[i].f==v[i].s&&v[i+1].f==v[i+1].s&&v[i+2].f==v[i+2].s)
        {cout<<"Yes";return 0;}
    }
    cout<<"No";
    
  
 
    
  
}
 
 cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
}  
 
 
 
 
 
  
 
 

Measured memory_bytes: 3756
#include <algorithm>
#include <deque>
#include <iostream>
#include <map>
#include <math.h>
#include <string.h>
#include <vector>

using namespace std;
int main() {
    string S;
    int ans=0;
    cin >> S;
    for(char i : S){
        if(i=='+'){
            ans++;
        }else{
            ans--;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<52;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const vi emp;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,-0};
const int DX[8]={-1,-1,-1,0,0,1,1,1},DY[8]={1,0,-1,1,-1,1,0,-1};

string s;

int main(){
	cin>>s;
	int A=-1,Z;
	for(int i=0;i<s.size();i++){
		if(s[i]=='A'&&A==-1) A=i;
		if(s[i]=='Z') Z=i;
	}
	cout<<Z-A+1<<endl;
}

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

typedef long long ll;
typedef unsigned long long ull;

constexpr int MAXN = 1e5;

void solve() {
  int N;
  int K;
  scanf("%d%d", &N, &K);
  std::vector<int> rocks(N);
  for (auto& _ : rocks) {
    scanf("%d", &_);
  }
  int dp[MAXN] = {};
  dp[0] = 0;
  for (int i = 1; i < N; ++i) {
    int cost = INT32_MAX;
    for (int k_ = 1; k_ <= std::min(i, K); ++k_) {
      cost = std::min(cost, abs(rocks[i - k_] - rocks[i]) + dp[i - k_]);
    }
    dp[i] = cost;
    // 4 3
    // 10 30 40 20 45
    // 0  20 30 30
  }
  printf("%d\n", dp[N - 1]);
}

void warp() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);
  std::cout.tie(0);
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
}
int main() {
  warp();
  solve();
  return 0;
}


Measured memory_bytes: 4192
#include<iostream>
    #include<cstdio>
    #include<math.h>
    #include<string>
    #include<algorithm>
    #include<functional>
    #include<vector>
    #include<set>
    #include<map>
    #define INF 999999
    #define EPS 1.0e-6
     
    using namespace std;
     
    typedef long long ll;
    typedef pair<int, int> P;
    typedef pair<int, P> PP;
     
    int n;
    int a[15];
     
    int main()
    {
    	cin >> n;
    	int m = 0;
    	for (int i = 0; i < n; i++) {
    		cin >> a[i];
    		if (a[i] % 2 == 0)m++;
    	}
     
    	
     
    	int e = 1;
    	ll ans = 1;
    	for (int i = 0; i < n; i++) {
    		ans *= 3;
    		if (a[i] % 2 == 0)e *= 2;
    		else e *= 1;
    	}
    	cout << ans - e << endl;
     
    	return 0;
    }

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X, i) ((X>>i)&1)

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = (1<<30);
const ll INFL = (1L<<62);

int main() {
  int N; cin >> N;
  vii ans;
  int sum = N + (1-(N&1));
  for (int i = 1; i <= N; i++) {
    for (int j = i+1; j <= N; j++) {
      if (i + j != sum) {
        ans.pb(mp(i, j));
      }
    }
  }

  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i].ff << " " << ans[i].ss << endl;
  }
  return 0;
}


Measured memory_bytes: 640
#!/usr/bin/perl
use POSIX qw(floor);

my ($a,$b,$n) = map { $_ - 0 } split(/\s+/,<STDIN>);

my $x = $b - 1;
$x = $n if $n < $x;

my $r = floor( $a * $x / $b ) - $a * floor( $x / $b );

print "$r\n";




Measured memory_bytes: 6596
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
from collections import Counter
import queue
import copy
import bisect
import heapq
import itertools


#sys.setrecursionlimit(10**7)
#N, Q = map(int, input().split())
#G = [list(input()) for i in range(H)]
#INF = V * 10001
#A = [int(i) for i in input().split()]
#AB = [list(map(int, input().split())) for _ in range(K)]


N, K = map(int, input().split())
Human = [0]*N
A = []
for i in range(K):
    d = int(input())
    A.append(list(map(int, input().split())))
    for j in range(d):
        Human[A[i][j]-1]=1

print(Human.count(0))


Measured memory_bytes: 70260
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

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

    if(N == 3){
        cout << "2 5 63" << endl;
        return 0;
    }

    N -= 4;
    int x = 2, y = 2, z = 0;

    if(N % 2 == 1){
        z += 1;
        N--;
    }

    x += min(9998, N);
    N = max(0, N - 9998);
    y += min(4998, N);
    N = max(0, N - 4998);
    z += N;

    //cout << x << " " << y << " " << z << endl;

    for(int i = 1; i <= 30000; i++){
        if(i % 6 == 0){
            if(z > 0){
                z--;
                cout << i << " ";
            }
        }
        else if(i % 3 == 0 && y > 0){
            if(y > 0){
                y--;
                cout << i << " ";
            }
        }
        else if(i % 2 == 0 && x > 0){
            if(x > 0){
                x--;
                cout << i << " ";
            }
        }
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
 
int N;
int A[200010];
 
bool judge(int mid)
{
    bool k[200020] = {0},f[200020] = {0},F = false;
    if(A[0] >= mid)k[0] = true;
    else k[0] = false;
 
    for(int i = 1; i < N * 2 - 1; i++)
    {
        if(A[i] >= mid)k[i] = true;
        else k[i] = false;
        if(k[i] == k[i - 1])
        {
            f[i] = f[i - 1] = true;
            F = true;
        }
    }
 
    if(!F)return k[N - 1] ^ (N % 2 == 0);
 
    for(int i = 0; i < N; i++)
    {
        if(f[N - 1 + i])return k[N - 1 + i];
        if(f[N - 1 - i])return k[N - 1 - i];
    }
    return false;
}
 
int main()
{
    scanf("%d",&N);
    for(int i = 0; i < N * 2 - 1; i++)scanf("%d",&A[i]);
 
    int l = 1,r = N * 2;
    while(r - l > 1)
    {
        int mid = (l + r) / 2;
        if(judge(mid))l = mid;
        else r = mid;
    }
    printf("%d\n",l);
    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std ;
 
/*                        [Template]                        */
#define async ios_base::sync_with_stdio(false); cin.tie(NULL);
#define int long long int
#define let auto
#define of :
#define all(y) y.begin(), y.end()
#define present( x, y ) x.find( y ) != x.end()
#define _matrix(T) vector<vector<T>>
template<class T>
auto matrix( int r, int c, T v ){
	return vector<vector<T>>( r, vector<T>( c, v ) ) ;
}
const int mod = (int)1e9 + 7 ;
const int inf = (int)1e9 ;
/************************************************************/

 
signed main(){
	int X, K, D ;
	cin >> X >> K >> D ;
	int n = min(abs(X) / D, K) ;
	int leftMoves = K - n ;
	// cerr << leftMoves << endl ;
	int curCord ;
	if( X <= 0 ){
		curCord = X + n*D ;
	}
	else{
		curCord = X - n*D ;
	}
	if( leftMoves % 2 == 0 ){
		cout << abs(curCord) ;
	}
	else{
		// cerr << curCord << endl ;
		cout << abs( D - abs(curCord) ) ;
	}

	return 0 ;
}
  


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

void Main() {
    // input
    int64_t S;
    cin >> S;
    int64_t mod = 1000000000 + 7;
    int64_t ans[2001];
    ans[1] = 0;
    ans[2] = 0;
    ans[3] = 1;
    for (int64_t i = 3; i <= S; i++) {
        ans[i] = 0;
        for (int64_t j = 0; j + 3 <= i; j++) {
            ans[i] += ans[j];
            ans[i] %= mod;
        }
        ans[i] += 1;
        ans[i] %= mod;
    }
 
    // process
    cout << ans[S] << endl;


    // output

}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3624
#include <atcoder/lazysegtree>
#include <atcoder/modint>
#include <iostream>
#include <vector>

using mint = atcoder::modint998244353;

struct S {
    int len;
    mint val;
};

using F = mint;
mint tens[1000010];
mint ones[1000010];

S op(S left, S right)
{
    return S {
        left.len + right.len,
        left.val * tens[right.len] + right.val
    };
}

S e() { return {0, 0}; }

S mapping(F f, S s)
{
    if (f == 0) { return s; }

    return {s.len, ones[s.len] * f};
}

F composition(F f, F g) { return (f == 0) ? g : f; }

F id() { return 0; }

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

    tens[0] = 1;
    for (int i = 1; i < 1000000; i++) {
        tens[i] = tens[i - 1] * 10;
    }
    ones[0] = 0;
    for (int i = 1; i < 1000000; i++) {
        ones[i] = (ones[i - 1] * 10 + 1);
    }

    int N, Q;
    std::cin >> N >> Q;

    S unit = {1, 1};
    std::vector<S> A(N, unit);
    atcoder::lazy_segtree<S, op, e, F, mapping, composition, id> seg(A);

    for (int i = 0; i < Q; i++) {
        int l, r, d;
        std::cin >> l >> r >> d;

        seg.apply(l - 1, r, d);

        std::cout << seg.prod(0, N).val.val() << '\n';
    }
}

Measured memory_bytes: 17736
import argparse
from sys import stdin

"""
parser = argparse.ArgumentParser()
# パーサーを作る
parser = argparse.ArgumentParser(
            prog='a', # プログラム名
            usage='Count paint number', #プログラムの利用方法
            description='Description', # 引数のヘルプの前に表示
            epilog='end', # 引数のヘルプの後で表示
            add_help=True, # -h/–help オプションの追加
            )
 
# 引数の追加
parser.add_argument('infile', help='inputfile',
                    type=argparse.FileType('r'))
 
# 引数を解析する
args = parser.parse_args()
 
message = args.infile.read()
args.infile.close();

parser.add_argument('arg1', help='input flie name')

a = message[0]
b = message[1]
c = message[2]
"""

a, b, c = [int(x) for x in stdin.readline().rstrip().split()]

if a==b==c:
    print(1)
elif a==b or b==c or a==c:
    print(2)
else:
    print(3)


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

using namespace std;

#define ll long long

int main(){
  queue<ll> q;
  for(ll i=1;i<10;i++){
    q.push(i);
  }
  ll k;
  cin>>k;
  for(int i=0;i<k;i++){
  	ll u = q.front();
    q.pop();
    if(i==k-1){
    	cout<<u;
      return 0;
    }
    ll v = u%10;
    if(v){
      q.push(10*u+v-1);
    }
    q.push(10*u+v);
    if(v<9){
      q.push(10*u+v+1);
    }
  }
  cout<<q.front();
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int n,temp,ans=1<<30;
int check(int ip)
{
	temp=0;
	while(ip>0)
	{
		temp+=ip%10;
		ip/=10;
	}
	return temp;
}
int main()
{
	cin>>n;
	for (int i=n-1;i>=n/2;i--)
	{
		ans=min(ans,check(i)+check(n-i));
	}
	cout<<ans;
} 

Measured memory_bytes: 256
from collections import deque


def BFS():
    point=0
    color=[["white" for _ in range(w)] for _ in range(h)]
    D=[[0 for _ in range(w)] for _ in range(h)]

    queue=deque([])
    for i in range(h):
        for j in range(w):
            if A[i][j]=="#":
                color[i][j]="gray"
                queue.append([i,j])
                D[i][j]=0

    while len(queue)>0:
        x,y=queue.popleft()
        for a,b in [[1,0],[-1,0],[0,1],[0,-1]]:
            X,Y=x+a,y+b
            if 0<=X<h and 0<=Y<w:
                if color[X][Y]=="white":
                    color[X][Y]="gray"
                    D[X][Y]=D[x][y]+1
                    point=max(point,D[X][Y])
                    queue.append([X,Y])
        color[x][y]="black"

    return point


h,w=map(int,input().split())
A=[list(input()) for _ in range(h)]
print(BFS())

Measured memory_bytes: 186716
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n-1); i >= 0; i--)
#define repi(i,a,b) for(int i=int(a);i<int(b);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; }

typedef long long ll;

using namespace std;

long long modpow(long long x,long long n,long long mod)
{
  if(n==0)return 1;
  long long res=modpow(x*x%mod,n/2,mod);
  if(n&1)res=res*x%mod;
  return res;
}
long long modinv(long long a,long long mod)
{
  return modpow(a,mod-2,mod);
}
vector<long long> fact,inv;
long long mod=1e9+7;
void init(int n){
  fact.resize(n);
  inv.resize(n);
  fact[0]=1LL;
  rep(i,n-1){
    fact[i+1]=(long long)fact[i]*(i+1)%mod;
  }
  inv[n-1]=modinv(fact[n-1],mod);
  rrep(i,n-1){
    inv[i]=(long long)inv[i+1]*(i+1)%mod;
  }
}
long long comb(ll a,ll b){
  return fact[a]*inv[b]%mod*inv[a-b]%mod;;
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,m,k;cin>>n>>m>>k;
  ll res=0;
  init(2e5+7);
  ll com=comb(n*m-2,k-2);
  rep(d,m){
    res+=n*n%mod*(m-d)%mod*com%mod*d%mod;
  }
  rep(d,n){
    res+=m*m%mod*(n-d)%mod*com%mod*d%mod;
  }
  cout<<res%mod<<endl;

  return 0;

}


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

using namespace std;

const int INF = 0x3f3f3f3f;

unordered_map<int, int> cnt[2];

int main() {
  int n;
  scanf("%d", &n);

  int ans = INF;
  int n_odd = n / 2 + (n & 1), n_even = n / 2;

  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);

    cnt[i & 1][x]++;
  }

  vector<pair<int, int> > v1, v2;
  for (auto it : cnt[1])
    v1.push_back(it);
  for (auto it : cnt[0])
    v2.push_back(it);

  sort(v1.begin(), v1.end());
  sort(v2.begin(), v2.end());

  reverse(v1.begin(), v1.end());
  reverse(v2.begin(), v2.end());

  int t = n_even;
  for (int i = 0, j = 0; i < (int)v1.size(); i++) {
    while (j < (int)v2.size() && v2[j].first > v1[i].first) {
      t = min(t, n_even - v2[j++].second);
    }

    ans = min(ans, n_odd - v1[i].second + t);
  }

  t = n_odd;
  for (int i = 0, j = 0; i < (int)v2.size(); i++) {
    while (j < (int)v1.size() && v1[j].first > v2[i].first) {
      t = min(t, n_odd - v1[j++].second);
    }

    ans = min(ans, n_even - v2[i].second + t);
  }

  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 5524
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <algorithm>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <thread>///////////////////

#define rep(i,m,n) for(int i=(m);i<(n);i++)
#define rem(i,m,n) for(int i=(m);i>(n);--i)

#define MOD 1000000007
//#define MOD 998244353

using namespace std;

using ll = long long int;
using std::swap;

vector<int> v;
vector<int> w;
vector<long long int> vll;
vector<long long int> wll;
//vector<vector<int>> vec(50, vector<int>(4, 0));
vector<vector<int>> vv;
vector<vector<int>> ww;


int main() {
	int A, B, H, M;
	double da, db;
	double rad;
	double ans;
	cin >> A >> B >> H >> M;
	da = H * 30. + M / 60.0 * 30.0;
	db = M * 6;
	rad = abs(db - da);
	if (rad > 180)rad = 360 - rad;
	rad = M_PI * (rad / 180.0);
	ans = pow(double(A), 2) + pow(double(B), 2) - 2 * A*B*cos(rad);
	ans = sqrt(ans);
	cout << fixed << setprecision(20)<< ans << '\n';
	return 0;
}

Measured memory_bytes: 4232
(r, p)=[int(n) for n in input().split()]
route_list=[[] for i in range(r)]
for i in range(p):
  (x, y)=[int(n)-1 for n in input().split()]
  route_list[x].append(y)
  route_list[y].append(x)

upstair=[0]
ans=[-1]*r
while upstair:
  tmp=[]
  for i in upstair:
    for j in route_list[i]:
      if ans[j] == -1:
        ans[j] = i + 1
        tmp.append(j)
  upstair=tmp

if -1 in ans:
  print("No")
else:
  print("Yes")
  for i in ans[1:]:
    print(i)

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

typedef long long ll;

ll a, b, c, d;

int main()
{
	scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
	if (a >= 0 && b >= 0 && c >= 0 && d >= 0)
			printf("%lld\n", b * d);
		else if (a >= 0 && b >= 0 && c <= 0 && d >= 0)
			printf("%lld\n", b * d);
		else if (a >= 0 && b >= 0 && c <= 0 && d <= 0)
			printf("%lld\n", (d == 0) ? 0 : a * d);
		else if (a <= 0 && b >= 0 && c >= 0 && d >= 0)
			printf("%lld\n", b * d);
		else if (a <= 0 && b >= 0 && c <= 0 && d >= 0)
			printf("%lld\n", max(a * c, b * d));
		else if (a <= 0 && b >= 0 && c <= 0 && d <= 0)
		 	printf("%lld\n", a * c);
		else if (a <= 0 && b <= 0 && c >= 0 && d >= 0)
			printf("%lld\n", (b == 0) ? 0 : b * c);
		else if (a <= 0 && b <= 0 && c <= 0 && d >= 0)
			printf("%lld\n", (c == 0) ? 0 : c * a);
		else if (a <= 0 && b <= 0 && c <= 0 && d <= 0)
			printf("%lld\n", a * c);
	return 0;
}

Measured memory_bytes: 3832
#include <iostream>
#include <list>
#include <vector>
#include <ctime>
#include <unordered_set>
#include <string>
#include <map>
#include <unordered_map>
#include <random>
#include <set>
#include <cassert>
#include <string.h>
#include <limits.h>
#include <stack>
#include <functional>
#include <queue>
#include <numeric>
#include <bitset>
#include <iterator>
#include <algorithm>
#include <sstream>
 
 
#define inf 0x3f3f3f3f
#define sup_inf 2e18
#define pb push_back	
#define ii pair<int,int>
#define f first
#define s second
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define iii pair<int, ii >
#define in freopen("arquivoentrada","r",stdin);
#define out freopen("myfile.txt", "w", stdout);	
#define eps 1e-9
#define pi 3.14159265359
const int mod = 1e9 +7  ;
 
using namespace std;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef long long ll;

using namespace std;

const int maxn = 3e5 + 100;
const int MAX = 1e3 + 10;


int dp[maxn] , n;

void calc(){
	dp[0] = 1;
	for(int j = 1; j <= 100;j++){
		if ( j>=4)
			if ( dp[j-4]) dp[j] = 1;
		if(j>=7)
			if(dp[j-7])dp[j] = 1;
	}
}

signed main (){
	calc();
	cin >> n;
	
	if(dp[n])	cout<< "Yes\n";
	else cout<<"No\n";
}



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

int main()
{
  long long n, a, b;
  cin >> n >> a >> b;
  if(a + b == 0)
  {
    cout << 0 << endl;
    return 0;
  }
  
  long long cnt = (n / (a + b)) * a;
  cnt += (n % (a + b) >= a) ? a : n % (a + b);
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define maxn 2005
#define maxl 1000000000

using namespace std;

#define st first
#define nd second
#define ALL(x) (x).begin(), (x).end()

template <class T>
void mini(T& l, T r) {
  l = min(l, r);
}
template <class T>
void maxi(T& l, T r) {
  l = max(l, r);
}

using LL = long long;
using LD = long double;
using ULL = unsigned long long;
const int dx[] = {0, -1, 1, 0, -1, -1, 1, 1},
          dy[] = {-1, 0, 0, 1, -1, 1, -1, 1};
const int INF = 1e9;
const LL MOD = 1e9 + 7;

int t, T;

void Solve() {
  // TODO
  string s, t;
  cin >> s >> t;
  t += s;
  cout << t << '\n';
}

void Prepare() {
  // TODO
  return;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  // Prepare();
  // cin >> T;
  // for (t = 1; t <= T; t++) {
  //   printf("Case #%d: ", t);
  Solve();
  //}
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int a[200000],q,query,x,p;
    int n=0;
    scanf("%d",&q);
    for(int i=0;i<q;i++){
        scanf("%d",&query);
        switch(query){
            case 0:
             scanf("%d",&x);
             a[n]=x;
             n++;
             break;
            case 1:
             scanf("%d",&p);
             printf("%d\n",a[p]);
             break;
            case 2:
             a[n]=0;
             n--;
        }
    }
    return 0;
}


Measured memory_bytes: 2620
#include<stdio.h>
#include<string.h>
int main(void)
{
    char s[11],t[11],u[11];
    int a,b;
    scanf("%s%s",s,t);
    scanf("%d%d",&a,&b);
    scanf("%s",u);
    if(strcmp(s,u)==0) a--;
    else b--;
    printf("%d %d\n",a,b);
    return 0;
}

Measured memory_bytes: 1696