akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
typedef pair<int,int> P;
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define rep(i, n) for (lint i = 0; i < (n); i++)
#define INF LLONG_MAX
#define all(x) (x).begin(),(x).end()
#define pb push_back
int main(){
    int d,n;
    cin>>d>>n;
    if(n==100){
        cout<<int(pow(100,d+1)+1*pow(100,d))<<endl;
    }else{
        cout<<int(pow(100,d)*n)<<endl;
    }
    return 0;
}


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

int main(){
    int k;cin>>k;
    int x;cin>>x;
    if(x<=k*500){
        cout<<"Yes";
    }else{
        cout<<"No";
    }

    
}

Measured memory_bytes: 3596
import sys
# from collections import Counter, deque
# from collections import defaultdict
# from itertools import combinations, permutations, accumulate, groupby, product
# from bisect import bisect_left,bisect_right
# from heapq import heapify, heappop, heappush
# from math import floor, ceil,pi,factorial
# from operator import itemgetter
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
inf = 10**17
mod = 10**9 + 7


n = int(input())
def f(n): return n*(n+1)//2
ans = 0
for i in range(1,n+1):
    x=n//i
    ans+=i*f(x)

print(ans)


Measured memory_bytes: 63656
#include <iostream>
#include <map>
#include <utility>
using namespace std;
typedef pair<int,int> ii;

int n;
int arr[10005];

map<int,int> m;
const int MOD=1000000007;
long long qexp(long long b,long long p,int m){
    long long res=1;
    while (p){
        if (p&1) res=(res*b)%m;
        b=(b*b)%m;
        p>>=1;
    }
    return res;
}



int main(){
    cin>>n;
    
    for (int x=0;x<n;x++) cin>>arr[x];
    
    int temp;
    int d;
    for (int x=0;x<n;x++){
        temp=arr[x];
        
        for (int x=2;x<=1000;x++){
            if (temp%x==0){
                d=0;
                while (temp%x==0){
                    temp/=x;
                    d++;
                }
                m[x]=max(m[x],d);
            }
        }
        
        if (temp>1) m[temp]=1;
    }
    
    long long b=1;
    
    for (auto &it:m){
        b=(b*qexp(it.first,it.second,MOD))%MOD;
    }
    
    long long ans=0;
    
    for (int x=0;x<n;x++) ans+=(b*qexp(arr[x],MOD-2,MOD))%MOD,ans%=MOD;
    
    cout<<ans;
}

Measured memory_bytes: 768
n = int(input())
d = [int(i) for i in input().split()]

sorted_d = sorted(d)
h = n // 2
mid_left = sorted_d[h-1]
mid_right = sorted_d[h]

if mid_left == mid_right:
    print(0)
else:
    print(mid_right - mid_left)

Measured memory_bytes: 14396
A,B,M = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
xyc = [list(map(int,input().split())) for _ in range(M)]
ans = min(a)+min(b)
for x,y,c in xyc:
  ans = min(ans,a[x-1]+b[y-1]-c)
print(ans)

Measured memory_bytes: 38560
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		//入力された内容を変数に格納
		int W = sc.nextInt();
		int H = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int r = sc.nextInt();

		//円が長方形を出ないときの条件
		if(x >= r && y >= r &&
				x + r <= W && y + r <= H){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 26360
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

template <long long mod>
struct modular {
    long long value;
    modular(long long x = 0) {
        value = x % mod;
        if (value < 0) value += mod;
    }
    modular& operator+=(modular other) {
        if ((value += other.value) >= mod) value -= mod;
        return *this;
    }
    modular& operator-=(modular other) {
        if ((value -= other.value) < 0) value += mod;
        return *this;
    }
    modular& operator*=(modular other) {
        value = value * other.value % mod;
        return *this;
    }
    modular& operator/=(modular other) {
        long long a = 0, b = 1, c = other.value, m = mod;
        while (c != 0) {
            long long t = m / c;
            m -= t * c;
            swap(c, m);
            a -= t * b;
            swap(a, b);
        }
        a %= mod;
        if (a < 0) a += mod;
        value = value * a % mod;
        return *this;
    }
    modular operator-() { return modular(-value); }
    modular operator+(modular rhs) { return modular(*this) += rhs; }
    modular operator-(modular rhs) { return modular(*this) -= rhs; }
    modular operator*(modular rhs) { return modular(*this) *= rhs; }
    modular operator/(modular rhs) { return modular(*this) /= rhs; }
    bool operator==(modular rhs) { return value == rhs.value; }
    bool operator!=(modular rhs) { return value != rhs.value; }
    bool operator<(modular rhs) { return value < rhs.value; }
};
template <long long mod>
string to_string(modular<mod> x) {
    return to_string(x.value);
}
template <long long mod>
ostream& operator<<(ostream& stream, modular<mod> x) {
    x.value %= mod;
    if (x.value < 0) x.value += mod;
    return stream << x.value;
}
template <long long mod>
istream& operator>>(istream& stream, modular<mod>& x) {
    stream >> x.value;
    x.value %= mod;
    if (x.value < 0) x.value += mod;
    return stream;
};
const long long mod = (long long)1e9 + 7;
using mint = modular<mod>;

inline mint pw(mint a, long long n) {
    mint res = 1;
    while (n > 0) {
        if (n & 1) {
            res *= a;
        }
        a *= a;
        n >>= 1;
    }
    return res;
}
vector<mint> fact, finv;
inline void cinit(int n) {
    fact.resize(n, 1);
    finv.resize(n, 1);
    for (int i = 2; i < n; i++) {
        fact[i] = fact[i - 1] * i;
    }
    finv[n - 1] /= fact[n - 1];
    for (int i = n - 2; i >= 2; i--) {
        finv[i] = finv[i + 1] * (i + 1);
    }
}
inline mint C(int n, int k) {
    if (n < k || k < 0 || n < 0) return 0;
    return fact[n] * finv[k] * finv[n - k];
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int k;
    string s;
    cin >> k >> s;
    int n = s.size();
    int a = n + k;
    cinit(a + 1);
    mint ans = 0;
    for (int i = n; i <= a; i++) {
        ans += C(a, i) * pw(25, a - i);
    }
    cout << ans << '\n';
    return 0;
}


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

int w[2], h[2], l[2][500][500], sx[2], sy[2], r;
int dx[]{ 1,-1,0,0 }, dy[]{ 0,0,1,-1 };
int ans[2][100001], d[250000];
bool vis[500][500], used[500][500];
vector<P>que[250000];
int compress(int k) {
	vector<int>x;
	rep(i, h[k])rep(j, w[k])x.push_back(l[k][i][j]);
	sort(x.begin(), x.end());
	x.erase(unique(x.begin(), x.end()), x.end());
	rep(i, x.size())d[i] = x[i];
	rep(i, h[k])rep(j, w[k])
		l[k][i][j] = lower_bound(x.begin(), x.end(), l[k][i][j]) - x.begin();
	return x.size();
}
void solve(int k) {
	ans[k][0] = 0;
	queue<P>Q;
	int n = compress(k);
	rep(i, n)que[i].clear();
	memset(vis, 0, sizeof(vis));
	memset(used, 0, sizeof(used));
	Q.push(P(sx[k], sy[k]));
	vis[sx[k]][sy[k]] = true;
	int cnt = 0, Max = 0;
	while (1) {
		while (!Q.empty()) {
			P p = Q.front(); Q.pop();
			if (used[p.first][p.second])continue;
			used[p.first][p.second] = true;
			cnt++; if (cnt >= r)break;
			rep(i, 4) {
				int nx = p.first + dx[i], ny = p.second + dy[i];
				if (0 <= nx&&nx < h[k] && 0 <= ny&&ny < w[k] && !vis[nx][ny]) {
					vis[nx][ny] = true;
					if (l[k][nx][ny] <= Max)Q.push(P(nx, ny));
					else que[l[k][nx][ny]].push_back(P(nx, ny));
				}
			}
		}
		ans[k][cnt] = min(ans[k][cnt], d[Max]);
		for (int i = Max; i < n; i++) {
			if (!que[i].empty()) {
				Max = i;
				for (P p : que[i])Q.push(p);
				que[i].clear();
				break;
			}
		}
		if (cnt >= r || Q.empty())break;
	}
	for (int i = r - 1; i >= 1; i--)ans[k][i] = min(ans[k][i], ans[k][i + 1]);
}
int main() {
	while (scanf("%d", &r), r) {
		rep(k, 2) {
			scanf("%d%d%d%d", &w[k], &h[k], &sy[k], &sx[k]); sx[k]--; sy[k]--;
			rep(i, h[k])rep(j, w[k])scanf("%d", &l[k][i][j]);
		}
		fill(ans[0], ans[2], INT_MAX);
		rep(k, 2)solve(k);
		int Min = INT_MAX;
		for (int i = 0; i <= r; i++) {
			if (ans[0][i] == INT_MAX || ans[1][r - i] == INT_MAX)continue;
			Min = min(Min, ans[0][i] + ans[1][r - i]);
		}
		printf("%d\n", Min);
	}
}

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

#define rep(i, n) for (int i=0; i<(n); ++i)
using ll = long long;
using P = pair<int, int>;

int main() {
  string s, t;
  cin >> s >> t;
  int a, b;
  cin >> a >> b;
  string u;
  cin >> u;

  if (u == s) {
    a--;
  } else if (u == t) {
    b--;
  }
  cout << a << ' ' <<  b << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alp = "abcdefghijklmnopqrstuvwxyz";
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << -1 << endl;}

//bit全探索
//引数は処理に応じて適宜追加
void bit_search(ll n, vll &a, vector<vector<vll>> &testim, priority_queue<ll> &cnt) {
  string bits;
  for (ll i = 0; i < n; i++) bits.push_back('0');
  for (ll i = 0; i < pow(2, n); i++) {
    ll right = 0;
    for (ll j = 0; j < n; j++) {
      if (bits.at(j) == '1') {
        for (ll k = 0; k < a.at(j); k++) {
          ll x = testim.at(j).at(k).at(0), y = testim.at(j).at(k).at(1);
          if (bits.at(x - 1) != y + '0') {
            right = 1;
            break;
          }
        }
      }
      if (right == 1) break;
      if (j == n - 1) {
        ll honest = 0;
        for (ll k = 0; k < n; k++)
          if (bits.at(k) == '1') honest++;
        cnt.push(honest);
      }
    }
    if (i == pow(2, n) - 1) return;
    ll x = 0;
    while (bits.at(n - 1 - x) == '1') {
      bits.at(n - 1 - x) = '0';
      x++;
    }
    bits.at(n - 1 - x) = '1';
  }
}

int main() {
  ll n;
  cin >> n;
  vll a(n);
  vector<vector<vll>> testim(n);
  for (ll i = 0; i < n; i++) {
    cin >> a.at(i);
    for (ll j = 0; j < a.at(i); j++) {
      ll x, y;
      cin >> x >> y;
      testim.at(i).push_back({x, y});
    }
  }
  priority_queue<ll> cnt;
  bit_search(n, a, testim, cnt);
  cout << cnt.top() << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;

int main() {
	long long N;
	cin >> N;
	long long ans = N - 1;
	for (long long i = 2; i <= (long long)sqrt(N)+1; i++) {
		if (N % i == 0) {
			ans = min(ans, N / i + i - 2);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

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

	for(i=0;i<n;i++){
		int a=0,b=0,num,r=1;
		for(o=0;o<10;o++){
			scanf("%d",&num);
			if(a < num)
				a=num;
			else if(b<num)
				b=num;
			else	r=0;
		}if(r == 0)printf("NO\n");
		else printf("YES\n");
	}
	return 0;
}

Measured memory_bytes: 580
from math import gcd
n = int(input())
a = list(map(int, input().split()))

t = a[0]
for i in range(1,n):
  t = t*a[i]//gcd(t,a[i])
  
ans = 0
for i in a:
  ans += (t-1)%i
print(ans)

Measured memory_bytes: 9344
#include <bits/stdc++.h>
#define int long long
using namespace std;
int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

signed main(){
    string a,b;
    cin >> a >> b;
    
    if(a>=b){
        for(int i=0;i<stoi(a);i++){
            cout << b;
        }
    }else{
        for(int i=0;i<stoi(b);i++){
            cout << a;
        }
    }
    
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string a;
  cin >> a;
  if(a.at(0) == a.at(1) && a.at(2) == a.at(3) && a.at(1) == a.at(2))
    cout << "No" << endl;
  else if(a.at(0) == a.at(1) && a.at(2) == a.at(3))
    cout << "Yes" << endl;
  else if(a.at(0) == a.at(2) && a.at(1) == a.at(3))
    cout << "Yes" << endl;
  else if(a.at(0) == a.at(3) && a.at(1) == a.at(2))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python

if __name__=='__main__':
    a, b, c, x, y = list(map(int, input().split()))
    half = c/2
    pizza = 0

    if a + b < 2*c:
        pizza = a*x + b*y
    else:
        m = min(x, y)
        n = max(x, y)
        pizza = 2*c*m

        if x > y:
            pizza += min(a*(n - m), 2*c*(n - m))
        else:
            pizza += min(b*(n - m), 2*c*(n - m))

    print(pizza)


Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(){
    int K , ar[33]={1,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cin>>K;
    cout<<K[ar];
return 0 ;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	int n = sc.nextInt();
      	int[] a = new int[n];
      	int max = 0;
      	for(int i=0; i<n; i++){
        	a[i] = sc.nextInt();
        }
      	for(int j=0; j<n; j++){
        	for(int k=0; k<=j; k++){
            	if(Math.abs(a[j]-a[k])>max){
                	max = Math.abs(a[j]-a[k]);
                }
            }
        }
      	System.out.println(max);
    }
}

Measured memory_bytes: 23764
n = int(input())
otosidama = float(0)

for i in range(n):
    x,y = map(str,input().split())
    x = float(x)
    if y == "JPY" :
        otosidama = otosidama + x
    else:
        otosidama = otosidama + x * 380000.0

print(otosidama)


Measured memory_bytes: 2940
#include <iostream>//cout<<right で右揃え
#include <iomanip>//cout<<setw(数字) で空白による桁揃え
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <cstdlib>//abs()で整数絶対値
#include <cmath>//abs()かfabs()で少数絶対値
#include <functional>//sort第三引数greater<型名>()で降順
#include <map>

using namespace std;
using ll = long long int;

ll power_mod(ll a,ll index,ll divider){
    ll ret = 1;
    for(;index>0;index/=2,a=a*a%divider){
        if(index%2==1){
            ret = ret * a % divider;
        }
    }
    return ret;
}

const int M = 1000000007;

int main(){
    ll N;cin>>N;
    if(N==1) cout << 0 << endl;
    else if(N==2) cout << 2 << endl;
    else{
        ll ans = power_mod(10,N,M) - 2 * power_mod(9,N,M) % M ;
        ans = ans + power_mod(8,N,M);
        if(ans < 0) ans += M;
        cout << ans % M << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
#define range(i, a, b) for (int i = a; i < b; ++i)
#define rep(i, n) range(i, 0, n)
const ll INF = 1e10;
#define pb push_back

struct edge {
    int cost, to;
};

int main() {
    int n, m, r;
    cin >> n >> m >> r;
    vector<vector<edge>> G(n);
    vll d(n, INF);
    rep(i, m) {
        int s;
        edge e;
        cin >> s >> e.to >> e.cost;
        G[s].pb(e);
    }

    priority_queue<pint, vector<pint>, greater<pint>> Q;  //距離,点
    d[r] = 0;
    Q.push(pint(0, r));

    while (!Q.empty()) {
        pint p = Q.top();
        Q.pop();
        int v = p.second;
        if (d[v] < p.first)
            continue;
        rep(i, G[v].size()) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                Q.push(pint(d[e.to], e.to));
            }
        }
    }

    rep(i, n) {
        if (d[i] == INF) {
            cout << "INF" << endl;
        } else {
            cout << d[i] << endl;
        }
    }
}



Measured memory_bytes: 13284
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
typedef long long ll;
long long MOD = 1e9 + 7;
const long long INF = 1LL << 60;
using namespace std;

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;
}

int main() {
  int a[3][3];
  rep(i, 3) {
    rep(j, 3) {
      int d;
      cin >> d;
      a[i][j] = d;
    }
  }

  int n;
  cin >> n;

  bool a2[3][3];

  rep(i, 3) {
    rep(j, 3) { a2[i][j] = false; }
  }

  rep(k, n) {
    int b;
    cin >> b;

    rep(i, 3) {
      rep(j, 3) {
        if (a[i][j] == b) {
          a2[i][j] = true;
        }
      };
    }
  }

  bool ans = false;

  rep(i, 3) {
    if (a2[i][0] == true && a2[i][1] == true && a2[i][2] == true) {
      ans = true;
    }
  }

  rep(i, 3) {
    if (a2[0][i] == true && a2[1][i] == true && a2[2][i] == true) {
      ans = true;
    }
  }

  if (a2[0][0] == true && a2[1][1] == true && a2[2][2] == true) {
    ans = true;
  }

  if (a2[0][2] == true && a2[1][1] == true && a2[2][0] == true) {
    ans = true;
  }

  if (ans) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    set<int> se;
    rep(i, 3) {
        int tmp;
        cin >> tmp;
        se.insert(tmp);
    }
    cout << (se.size() == 2 ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

const ll mod=1e9+7;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(ll n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (ll i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (ll i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(ll n, ll k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
  mint p(ll n, ll k) {
    return fact[n]*ifact[n-k];
  }
} c(1000005);


int main(){
    ll n,m,k;
    cin >> n >> m >> k;
    mint ans=0;
    mint pat=c(n*m-2,k-2);
    rep(i,n){
        ans+=i*(n-i)*m*m;
    }
    rep(i,m){
        ans+=i*(m-i)*n*n;
    }
    
    ans*=pat;
    cout << ans << endl;
    return 0;
}

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

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

    int s1 = s / 100;
    int s2 = s % 100; 

    if (0 < s1 && s1 < 13) {
        if(0 < s2 && s2 < 13) cout << "AMBIGUOUS" << endl;
        else cout << "MMYY" << endl;
    }
    else { 
        if(0 < s2 && s2 < 13) cout << "YYMM" << endl;
        else cout << "NA" << endl;
    }

}

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

vector<ll> adj[100005];
vector<vector<ll> > dp(100005,vector<ll> (2));

ll sum(ll node){
    return (dp[node][0]+dp[node][1])%mod;
}

void foo(ll node, ll parent){
    ll a1,zero=1,one=1;
    for(a1=0;a1<(ll)adj[node].size();++a1){
        if(adj[node][a1]==parent) continue;
        foo(adj[node][a1],node);
        one=(one*dp[adj[node][a1]][0])%mod;
        zero=(zero*sum(adj[node][a1]))%mod;
    }
    dp[node][0]=zero;
    dp[node][1]=one;
}

int main(){
    ll n,a1;
    cin>>n;
    for(a1=0;a1<n-1;++a1){
        ll x,y;
        cin>>x>>y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    foo(1,0);
    cout<<sum(1);
    // cout<<"\n";
    // for(a1=1;a1<=n;++a1)
        // cout<<dp[a1][0]<<" "<<dp[a1][1]<<"\n";
    
    return 0;
}

Measured memory_bytes: 18176
#include <stdio.h>

int main(void)
{
	int a[4];
	int e[4];
	int z, zz;
	int hit, blow;
	
	while (scanf("%d %d %d %d", &a[0], &a[1], &a[2], &a[3]) != EOF){
		hit = 0;
		blow = 0;
		scanf("%d %d %d %d", &e[0], &e[1], &e[2], &e[3]);
		for (z = 0; z < 4; z++) {
			for (zz = 0; zz < 4; zz++) {
				if (a[z] == e[zz]) {
					if (z == zz) {
						blow++;
					}
					else {
						hit++;
					}
				}
			}
		}
		
		printf("%d %d\n", blow, hit);
	}
	
	return (0);
}	

Measured memory_bytes: 596
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // fixed, setprecision 
#include <math.h> // double sqrt
#define rep(i,n) for(int i=0;i<(n);++i)
#define ll long long
using namespace std;

int f(int n){
    if(n%2==0)return n/2;
    else return 3*n+1;
}

int main(){
    vector<int>a(100000005);
    set<int>s;
    int i=0;
    cin>>a[0];
    s.insert(a[0]);
    while(1){
        a[i+1]=f(a[i]);
        if(s.count(a[i+1])){cout<<i+2;return 0;}
        s.insert(a[i+1]);
        i++;
    }
}

Measured memory_bytes: 393288
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class A_168_Therefore
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数の入力
            long n = long.Parse(Console.ReadLine());

            switch (n % 10)
            {
                // 3 "bon"
                case 3:
                    Console.WriteLine("bon");
                    break;

                // 0.1.6.8 "pon"
                case 0:
                case 1:
                case 6:
                case 8:
                    Console.WriteLine("pon");
                    break;
                    // 2.4.5.7.9 "hon"
                default:
                    Console.WriteLine("hon");
                    break;
            }

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 27492
#include<bits/stdc++.h>
using namespace std;
int ans;
int main()
{
	string s1;
	string s2;
	cin>>s1>>s2;
	for(int i=0;i<s1.length();i++)
	{
		if(s1[i]==s2[i]) ans++;
	}
	cout<<ans;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AACOrWA solver = new AACOrWA();
        solver.solve(1, in, out);
        out.close();
    }

    static class AACOrWA {
        public void solve(int testNumber, FastReader s, PrintWriter out) {
            int n = s.nextInt(), m = s.nextInt();
            if (n == m) {
                out.println("Yes");
            } else {
                out.println("No");
            }
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 21460
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>

using namespace std;


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

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

	int max = 0;

	int steps = 0;
	for (int i = 0; i < h.size() - 1; i++) {
		if (h[i + 1] <= h[i]) {
			steps++;

			//cout << "Steps walked: " << steps << endl;
		}
		else {
			if (steps > max) {
				max = steps;
			}
			steps = 0;
		}

		// Last element
		if (i == h.size() - 2) {
			//cout << i << endl;
			if (steps > max)max = steps;
		}
	}

	cout << max;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <map>
#include <vector>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
using namespace std;

typedef long long ll;

int as[10000+10];
int bs[10000+10];

int main(void) {
  int n;
  scanf("%d", &n);
  REP(i, n) {
    scanf("%d", &as[i]);
  }
  REP(i, n) {
    scanf("%d", &bs[i]);
  }

  ll sumA = 0;
  ll sumB = 0;
  REP(i, n) {
    sumA += as[i];
    sumB += bs[i];
  }
  bool possible = true;
  ll diff = sumB - sumA;
  if(diff < 0) {
    possible = false;
  } else {
    ll needA = 0;
    ll needB = 0;
    REP(i, n) {
      if(as[i] > bs[i]) {
        needB += as[i] - bs[i];
      } else {
        needA += (bs[i] - as[i] + 1) / 2;
        if((as[i] ^ bs[i]) & 1) {
          needB += 1;
        }
      }
    }
    if(needA > diff || needB > diff) {
      possible = false;
    }
  }

  puts(possible ? "Yes" : "No");
  
  return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <queue>
#include <map>
#include <set>
#include <stack>
using namespace std;
#define ll long long
#define ull unsigned long long
#define up(i, a, b) for (int i = (a); i <= (b); i++)
#define down(i, a, b) for (int i = (a); i >= (b); i--)
#define mem(x, y) memset(x, (y), sizeof x)
#define ff first
#define ss second
#define mp(x, y) make_pair(x, y)
#define pb(x) push_back(x)
#define sc(a) scanf("%d", &a)
#define scl(a) scanf("%lld", &a)
#define scs(a) scanf("%s", a)
#define pr(a, b) printf("%d%c", a, b)
#define prl(a, b) printf("%lld%c", a, b)
#define PQ priority_queue
#define ld long double
#define all(v) v.begin(), v.end()
#define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)

typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> V;

set<int>s;
int c[400010];
struct node {
	int s,t,x;
};
node a[400010];
bool cmp(node a,node b) {
	return a.x<b.x;
}
int ans[400010];
inline int read() {
	int x=0;
	char c=getchar();
	for(; isdigit(c); c=getchar()) x=x*10+c-'0';
	return x;
}
int main() {
	int n=read(),q=read();
	up(i,1,n) {
		a[i].s=read();
		a[i].t=read();
		a[i].x=read();
	}
	sort(a+1,a+1+n,cmp);
	up(i,1,q) {
		int x=read();
		s.insert(x);
		c[i]=x;
	}

	up(i,1,n) {
		auto l=s.lower_bound(a[i].s-a[i].x);
		auto r=s.lower_bound(a[i].t-a[i].x);

		for(auto o=l; o!=r; o++)ans[lower_bound(c+1,c+1+q,*o)-c]=a[i].x;
		for(auto o=l; o!=r;){
			auto it=o;
			o++;
			s.erase(it);
		}
		//s.erase(l,r);

		if(s.empty())break;
	}
	up(i,1,q)
	if(ans[i]==0)pr(-1,'\n');
	else pr(ans[i],'\n');
}


Measured memory_bytes: 15360
#include <bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	char str[n];
	cin>>str;
	if(n%2!=0){
		cout<<"No"<<endl;
		return 0; 
	}
	for(int i=0;i<n/2;i++){
		if(str[i]!=str[i+n/2]){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def read():
    s = input().strip()
    return s,


def solve(s):
    a, z = 0, len(s)-1
    while s[a] != "A":
        a += 1
    while s[z] != "Z":
        z -= 1
    return z-a+1


if __name__ == '__main__':
    inputs = read()
    print(solve(*inputs))


Measured memory_bytes: 9156
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <climits>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

#define INF INT_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)

int main(){
	vi ab;
	ab.resize(3);
	cin>>ab[0]>>ab[1]>>ab[2];

	sort(ab.begin(),ab.end());
	
	cout<<10 * ab[2] + ab[0] + ab[1]<<endl;
	return 0;	
}



Measured memory_bytes: 256
n, x, m = map(int, input().split())
check = [False] * (10**5 + 10)
check_list = [x]
a = x
check[a] = True
# ループを見つける
for i in range(n):
    # print('A' + str(i + 1), a)
    a = (a * a) % m
    if check[a]:
        break
    check[a] = True
    check_list.append(a)
# print(ans)

# ループの長さを算出
index = check_list.index(a)
# print(index)
roop_bef = check_list[0:index]
roop = check_list[index:]

# print(roop_bef, roop)

roop_bef_num = len(roop_bef)
roop_num = (n - len(roop_bef)) // len(roop)
roop_after_num = (n - len(roop_bef)) % len(roop)

ans = sum(roop_bef) + sum(roop) * roop_num + sum(roop[:roop_after_num])
# print(roop[:roop_after_num])

# print(rooplen)
print(ans)


Measured memory_bytes: 12488
import java.util.Scanner;

/**
 * 
 * @author DemonSong
 * 
 *         0033.Ball
 * 
 *         ???????????????????????????????????????????????¨??????????????????1 ?????? 10 ?????§???????????????????????????10 ?????????????????¨????????£??¨ A ???????????¨??????????????? B
 *         ???????????? C ???????????\??????????????? D ????????? E ??????????????????????????¢??§???????????§?????? D ?????????????????¨??§??? B ??¨??? C
 *         ?????????????????\??????????±????????????¨?????§????????????
 * 
 *         ?????£??¨ A ???????????¨????????????????????????????????????????????????????????? B ????????? C?????\?????????????????????????????¨????????? B ??¨??? C
 *         ??????????????????????????¨?????????????°?????????????????????§?????????????????????????????´?????? YES???????????????????????´?????? NO
 *         ??¨????????????????????°?????????????????????????????????????????????????????¨????????§?????????????????\?????????????????¨?????§?????????????????¨??????????????????????¶?????????????????????\???????????¨?????§??????????????¨?????????
 *         B, C ??¨?????? 10 ???????????????????????\????????????????£??????????????????¨????????????
 * 
 *         Input ?????°?????????????????????????????????????????????????????????????????????????????° N ?????????????????????????????\?????????N
 *         ???????????????????????????????????????????????????????????????????????? 10 ??????????????????????????????????????????????????§?????????????????????
 * 
 *         Output ????????????????????????????????????YES ????????? NO ????????????????????????????????????
 * 
 *         Sample Input 2 3 1 4 2 5 6 7 8 9 10 10 9 8 7 6 5 4 3 2 1 Output for
 *         the Sample Input YES NO
 *
 */
public class Main {
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] ball = new int[10];
		for (int i = 0; i < n; i++){
			for(int j = 0; j < 10; j++){
				ball[j] = in.nextInt();
			}
			System.out.println(solve(ball));
		}
		in.close();
	}
	
	private static String solve(int[] ball){
		int[] dp = new int[ball.length];
		
		int max = 0;
		for (int i = 0; i < ball.length; i++){
			dp[i] = 1;
			for (int j = 0; j < i; j++){
				if (ball[i] <= ball[j]){
					dp[i] = Math.max(dp[i], dp[j]+1);
				}
				max = Math.max(max, dp[i]);
			}
		}
		return max <= 2 ? "YES":"NO";
	}

}

Measured memory_bytes: 26188
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <utility>
#include <queue>

using namespace std;

typedef pair<int, int> pii;

#define fi first
#define se second

const int INF = 1 << 30;
const int MAXN = 705;
const int MAXM = 705 * 705;

struct Edge
{
	int to, next;
}e[MAXM];
int head[MAXN], te = 1;

inline void addE(int u, int v)
{
	e[++te] = (Edge){v, head[u]}, head[u] = te;
}

int w[MAXN][MAXN], c[MAXN];

bool f[MAXN][2 * MAXN];

int n, m, x, y, N, D, A, B, res;

vector<pii> vt;

bool bfs(int s)
{
	static queue<int> q;
	int g[2] = {0, 0};
	c[s] = 0;
	q.push(s);
	while (!q.empty())
	{
		int u = q.front();
		g[c[u]]++;
		q.pop();
		for (int j = head[u]; j != 0; j = e[j].next)
		{
			int v = e[j].to;
			if (c[v] == -1)
			{
				c[v] = c[u] ^ 1;
				q.push(v);
			}
			else if (c[v] != (c[u] ^ 1))
				return 0;
		}
	}
	vt.push_back(pii(g[0], g[1]));
	return 1;
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> n >> m;
	for (int i = 1; i <= m; i++)
	{
		cin >> x >> y;
		w[x][y] = w[y][x] = 1;	
	}
	for (int i = 1; i <= n; i++)
		for (int j = i + 1; j <= n; j++)
			if (w[i][j] == 0)
				addE(i, j), addE(j, i);
	for (int i = 1; i <= n; i++)
		c[i] = -1;
	vt.push_back(pii(0, 0));
	for (int i = 1; i <= n; i++)
	{
		if (c[i] == -1)
		{
			bool ch = bfs(i);
			if (!ch)
			{
				cout << -1 << endl;
				exit(0);	
			}
		}
	}
	N = vt.size() - 1;
	f[0][MAXN] = 1;
	for (int i = 1; i <= N; i++)
	{
		int a = vt[i].fi, b = vt[i].se;
		for (int j = MAXN - n; j <= MAXN + n; j++)	
		{
			if (f[i - 1][j])
			{
				f[i][j + a - b] = 1;
				f[i][j + b - a] = 1;
			}
		}
	}
	D = INF;
	for (int i = MAXN - n; i <= MAXN + n; i++)
		if (f[N][i])
			D = min(D, abs(i - MAXN));
	A = (n - D) / 2, B = A + D;
	res = A * (A - 1) / 2 + B * (B - 1) / 2;
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 4992
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);


struct B{
  int n[8];
  int p;

  void dup(const B& rhs){
	REP(i,8) n[i] = rhs.n[i];
	p = rhs.p;
  }
  
  int encode(){
	int p = 1, res = 0;
	for(int i=0;i<8;++i){
	  res += p * n[i];
	  p *= 8;
	}
	return res;
  }
};

map<int,int> mem;
void calc(){
  B b;
  REP(i,8) b.n[i] = i;
  b.p = 0;
  queue<B> q;
  q.push(b);
  mem[b.encode()] = 0;

  while(!q.empty()){
	B pazz = q.front(); q.pop();
	int en = pazz.encode();

	if(pazz.p < 4){
	  B after; after.dup(pazz);
	  swap(after.n[after.p], after.n[after.p+4]);
	  after.p += 4;
	  if(mem.find(after.encode()) == mem.end()){
		mem[after.encode()] = mem[en] + 1;
		q.push(after);
	  }
	}
	else{
	  B after; after.dup(pazz);
	  swap(after.n[after.p], after.n[after.p-4]);
	  after.p -= 4;
	  if(mem.find(after.encode()) == mem.end()){
		mem[after.encode()] = mem[en] + 1;
		q.push(after);
	  }
	}
	if(pazz.p != 0 && pazz.p != 4){
	  B after; after.dup(pazz);
	  swap(after.n[after.p], after.n[after.p-1]);
	  after.p--;
	  if(mem.find(after.encode()) == mem.end()){
		mem[after.encode()] = mem[en] + 1;
		q.push(after);
	  }
	}
	if(pazz.p != 3 && pazz.p != 7){
	  B after; after.dup(pazz);
	  swap(after.n[after.p], after.n[after.p+1]);
	  after.p++;
	  if(mem.find(after.encode()) == mem.end()){
		mem[after.encode()] = mem[en] + 1;
		q.push(after);
	  }
	}
  }
}

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

  calc();
  while(true){
	B b;
	REP(i,8){
	  if(!(cin >> b.n[i])) return 0;
	  if(b.n[i] == 0) b.p = i;
	}
	cout << mem[b.encode()] << endl;
  }

  return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> h(N);
  for (int i = 0; i < N; i++) cin >> h[i];
  sort(h.begin(), h.end());
  int ans = 1000000000;
  for (int i = 0; i < N - K + 1; i++)
    ans = min(h[i + K - 1] - h[i], ans);
  cout << ans << endl;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 10000000000000000
#define int long long
int N;
int dp[1<<16];
int a[16][16];

int f(int S) {
    
    if (dp[S] != -INF2) return dp[S];
    int sum = 0;
    rep(i, N) {
        REP(j, i + 1, N - 1) {
            if ((S & (1 << i)) && (S & (1 << j)) ) sum += a[i][j];
        }
    }
    for(int T = (S - 1) & S; T > 0; T=(T - 1) & S) {
        dp[S] = max(dp[S], f(T) + f(S^T));
    }
    dp[S] = max(sum, dp[S]);
    //cout << bitset<4>(S) << " " << dp[S] << endl;
    return dp[S];
}


signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    rep(i, N) {
        rep(j, N) {
            cin >> a[i][j];
        }
    }
    rep(i, (1<<N)) dp[i] = -INF2;
    cout << f((1<<N) - 1) << endl;

    return 0;
}


Measured memory_bytes: 896
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstdio>
#include<map>
#include<set>
#include<queue>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;

int main(){

    string s;
    cin >> s;
    ll mini = INF;
    for(int i = 0;i < s.length()-2;i++){

        string t = s.substr(i,3);
        ll tmp = stoi(t);
        mini = min(mini,abs(753LL -tmp));
    }
    cout << mini << endl;


    return 0;
}

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

vector<int> ans;
int binary_search(int x){
    int ok = ans.size();
    int ng = - 1;
    while (abs(ok - ng) > 1){
        int mid = (ok + ng) / 2;
        if (ans[mid] < x) ok = mid;
        else ng = mid;
    }
    return ok;
}

int main(){
    int n;
    cin >> n;
    for (int i = 0; i < n; i++){
        int a;
        cin >> a;
        if (binary_search(a) == ans.size()) ans.push_back(a);
        else ans[binary_search(a)] = a;
    }
    cout << ans.size() << endl;
}

Measured memory_bytes: 892
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;

const int maxn = 5005;
bool pre[maxn][maxn], suf[maxn][maxn];
int presuf[maxn][maxn];
int a[maxn];
int n, k;
int main(){
    cin >> n >> k;
    for(int i = 1;i <= n;i++){
        scanf("%d", &a[i]);
        a[i] = min(a[i], k);
    }
    pre[0][0] = 1;
    suf[n + 1][0] = 1;
    for(int i = 1;i <= n;i++){
        for(int j = 0;j <= k;j++){
            pre[i][j] |= pre[i - 1][j];
            if(j >= a[i]){
                pre[i][j] |= pre[i - 1][j - a[i]];
            }
            //cout << i << " " << j << " " << pre[i][j] << endl;
        }
    }
    for(int i = n;i >= 1;i--){
        for(int j = 0;j <= k;j++){
            suf[i][j] |= suf[i + 1][j];
            if(j >= a[i]){
                suf[i][j] |= suf[i + 1][j - a[i]];
            }
            //cout << i << " " << j << " " << suf[i][j] << endl;
        }
    }
    for(int i = n + 1;i >= 1;i--){
        presuf[i][0] = suf[i][0];
        for(int j = 1;j <= k;j++){
            presuf[i][j] = presuf[i][j - 1] + suf[i][j];
        }
    }
    int ans = 0;
    for(int i = 1;i <= n;i++){
        bool flag = false;
        for(int j = 0;j <= k;j++){
            if(pre[i - 1][j] == false)
                continue;
            int lower;
            if(k - j - a[i] - 1 < 0)
              lower = 0;
            else
              lower = presuf[i + 1][k - j - a[i] - 1];  
            int upper;
            if(k - j - 1 < 0)
                upper = 0;
            else
                upper = presuf[i + 1][k - j - 1];
            if(upper - lower > 0){
                //cout << i << " " << j << endl;
                flag = true;
                break;
            }
        }
        //cout << i << " " << flag << endl;
        ans += (flag == false);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 147072
// Sasageyo! Sasageyo! Shinzou wo Sasageyo !
// https://goo.gl/IwJzbx

#include<bits/stdc++.h>

using namespace std;

typedef pair<int,int> II;
typedef vector<II> VII;
typedef vector<int> VI;
typedef vector< VI > VVI;

typedef long long int LL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))
#define si(n) scanf("%d",&n)
#define dout(n) printf("%d\n",n)
#define sll(n) scanf("%lld",&n)
#define lldout(n) printf("%lld\n",n)

#define TRACE

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

#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)

#define endl '\n'
const int N = 100010;
LL costflat[N];
LL decrAdd[N];
LL decrMark[N];
int n, m, last;
void addflat(int st, int en, int val) {
  costflat[st] += val;
  costflat[en+1] -= val;
}
void addecr(int st, int en, int val) {
  decrAdd[st] += val;
  decrMark[st] -= 1;
  decrMark[en] += 1;
}
int main()
{
	fast_io;
  cin >> n >> m;
  cin >> last;
  for(int i=1;i<n;i++) {
    int cur;
    cin >> cur;
    if(cur > last) {
      addflat(cur+1, m, cur - last);
      addflat(1, last, cur - last);
      addecr(last+1, cur+1, cur - last);
    }
    else if(cur < last) {
      addflat(cur+1, last, m - last + cur);
      addecr(last+1, m, m - last + cur);
      addecr(1, cur+1,cur);
    }
    last = cur;
  }
  LL dec_turn = 0;
  LL dec_sum = 0;
  LL add_flat = 0;
  LL ans = LLONG_MAX;
  for(int i=1;i<=m;i++) {
    add_flat += costflat[i];
    dec_sum += dec_turn;
    dec_sum += decrAdd[i];
    dec_turn += decrMark[i];
    LL tans = dec_sum + add_flat;
    ans = min(tans, ans);
  }
  cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560