akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>


int c[200],d[200];

int main(){
	int n,nn,m;
	scanf("%d %d",&n,&m);
	nn=n*2;
	for(int i=0;i<nn;i++){
		c[i]=i+1;
	}
	for(int i=0;i<m;i++){
		int a;
		scanf("%d",&a);
		if(a==0){
			for(int j=0;j<nn;j++){	
				d[j]=c[j];
			}
			for(int j=0;j<n;j++){	
				c[j*2]=d[j];
			}
			for(int j=0;j<n;j++){	
				c[j*2+1]=d[j+n];
			}
		}else{
			for(int j=0;j<nn;j++){	
				d[j]=c[j];
			}
			
			for(int j=0;j<nn-a;j++){	
				c[j]=d[j+a];
			}
			for(int j=0;j<a;j++){	
				c[j+nn-a]=d[j];
			}
		}
	}
	for(int i=0;i<nn;i++){
		printf("%d\n",c[i]);
	}
	return 0;
}

Measured memory_bytes: 1028
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <iterator>
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
 
#define FOR(i,n) for(int i = 0; i < (n); i++)
#define sz(c) ((int)c.size())

typedef unsigned long long ull;

int main(){
	int n; 
	while(cin>>n,n){
		vector<int> v(n-1);
		FOR(i,n-1){
			v[i] = (i+1)*(i+1) % n;
		}
		sort(v.begin(),v.end());
		v.erase(unique(v.begin(),v.end()),v.end());

		int n12 = (n-1)/2;
		vector<int> ans(n12+1);
		FOR(i,sz(v)) for(int j = i+1; j < sz(v); j++){
			int df = v[j]-v[i];
			if(df > n12) df = n - df;
			ans[df]++;
		}

		for(int i = 1; i < sz(ans); i++){
			cout << ans[i] * 2<< endl;
		}
	}
	return 0;
}

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

int main(){
    int N; cin >> N;
    string S; cin >> S;
    bool jud = true;

    if(N %2 == 1){
        cout << "No" << endl;
    }

    else{
        rep(i,N/2){

            if(S[i] != S[i+N/2]){
                jud = false;
            }

        }

        if(jud){
            cout << "Yes" << endl;
        }

        else{
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PI 3.14159265359

int main() {
    int a,b;
    cin >> a >> b;
    if(a == 1) a = 20;
    if(b == 1) b = 20;
    if(a > b) cout << "Alice" << endl;
    else if(a < b) cout << "Bob" << endl;
    else cout << "Draw" << endl; 
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> PP;
class UnionFind{
private:
    vector<int> p,s;
public:
	UnionFind(){}
	UnionFind(int N){
		p = s = vector<int>(N+1,0);
		for(int i=1;i<=N;i++){
			p[i] = i; s[i] = 1;
		}
	}
    void init(int N){
        for(int i=1;i<=N;i++){
			p[i] = i; s[i] = 1;
		}
    }
	int find(int x){
		if(p[x]==x) return x;
		else return p[x] = find(p[x]);
	}
	void unite(int x,int y){
		x = find(x); y = find(y);
		if(x==y) return;
		if(s[x]>s[y]){
			p[y] = x;
			s[x] += s[y];
		}else{
			p[x] = y;
			s[y] += s[x];
		}
	}
	bool is_same_set(int x,int y) {return find(x)==find(y);}
	int size(int x) {return s[find(x)];}
};


struct edge{
    int to,cost;
};


int N,M;
P H[210];
vector<PP> u;
int floating[210] = {0};


int main(){
    while(true){
        cin >> N >> M;
        if(N==0) break;
        int h;
        for(int i=1;i<=N;i++){
            cin >> h;
            H[i] = P(h,i);
            floating[i] = false;
        }
        sort(H+1,H+N+1,greater<P>());
        int a,b,c;
        UnionFind uf(N);
        u.clear();
        for(int i=1;i<=M;i++){
            cin >> a >> b >> c;
            u.push_back(PP(c,P(a,b)));
        }
        int ans = 0;
        sort(u.begin(),u.end());
        int i = 1;
        while(i<=N){
            while(i<N && H[i].first==H[i+1].first){
                floating[H[i].second] = true;
                i++;
            }
            if(i<=N){
                floating[H[i].second] = true;
                i++;
            }
            for(auto x:u){
                if(!floating[x.second.first] || !floating[x.second.second]) continue;
                if(!uf.is_same_set(x.second.first,x.second.second)){
                    ans += x.first;
                    uf.unite(x.second.first,x.second.second);
                }
            }
            if(uf.size(H[1].second)!=i-1){
                ans = 0;
                uf.init(N);
            }
        }
        cout << (uf.size(1)==N? ans:0) << endl;
    }
}


Measured memory_bytes: 3508
// Problem : A - Don't be late
// Contest : AtCoder - AtCoder Beginner Contest 177
// URL : https://atcoder.jp/contests/abc177/tasks/abc177_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
ordered_set;	

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, int> para;
const ll inf = 1e18 + 7;
const ll maxN = 1e6 + 5;
const ll MOD = 1e9 + 7;

// sprawdz MODULO!
int main() {
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int d, t, s;
	cin >> d >> t >> s;
	int x = (d + s - 1) / s;
	if (x > t) {
		cout << "No\n";
	} else {
		cout << "Yes\n";
	}
	return 0;
}
 


Measured memory_bytes: 3648
import math

a = list(str(input()))
b = list(str(input()))
c = list(str(input()))

r = a.pop(0)
while True:
  if r == 'a':
    if len(a) == 0:
      print('A')
      exit(0)
    r = a.pop(0)

  elif r == 'b':
    if len(b) == 0:
      print('B')
      exit(0)
    r = b.pop(0)
    
  elif r == 'c':
    if len(c) == 0:
      print('C')
      exit(0)
    r = c.pop(0)
  
  
    

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ll n,k; cin>>n>>k;
	if(n==k){cout<<0; return 0;}
	if(n<k)
	{
		ll f=abs(n-k);
		ll p=f;
		ll s=abs(p-k);
		cout<<min(f,s); return 0;
	}
	if(k==1)
	{
		cout<<0; return 0;
	}
	ll upar=n%k;
	ll y=k-upar;
	cout<<min(upar,y);
	
		
}

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

namespace AtCoder_solve
{
    class Program
    {
        public const ulong mod = 1000000007;

        static void Main(string[] args)

        {
            var n = int.Parse(Console.ReadLine());
            var takoyaki = Console.ReadLine().Split();
            var ans = 0;
            
            for(int i = 0; i < n; i++)
            {
                for(int j = i + 1; j < n; j++)
                {
                    ans += int.Parse(takoyaki[i]) * int.Parse(takoyaki[j]);
                }
            }
           



            Console.WriteLine(ans);
        
            
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
int a[123456], n, t, l, r;
signed main() {
	cin >> n >> t;
	for1(i, n) { cin >> l >> r; a[l]++; a[r]--; }
	int ans = a[0];
	for1(i, t) { a[i] += a[i - 1]; ans = max(ans, a[i]); }
	cout << ans << endl;
}


Measured memory_bytes: 3500
H, W, K = map(int, input().split())
S = [input() for _ in range(H)]
ans = [[0] * W for _ in range(H)]
cur = 1
for i in range(H):
    has_st = []
    for j in range(W):
        if S[i][j] == "#":
            has_st.append(j)
    if not has_st:
        continue
    elif len(has_st) == 1:
        ans[i] = [cur] * W
        cur += 1
    else:
        for j in range(has_st[-1] + 1):
            ans[i][j] = cur
            if S[i][j] == "#":
                cur += 1
        ans[i][has_st[-1] + 1 :] = [cur - 1] * (W - has_st[-1] - 1)

for i in range(H - 1):
    if ans[i + 1] == [0] * W:
        ans[i + 1] = ans[i][:]
for i in range(H - 1, 0, -1):
    if ans[i - 1] == [0] * W:
        ans[i - 1] = ans[i][:]
[print(" ".join(map(str, row))) for row in ans]


Measured memory_bytes: 12788
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<cstring>//memset()
#include<algorithm>
#include<sstream>
#include<stack>
#include<bitset>
#include<queue>
#include<cmath>
#include<set>
#include<unordered_map>
#define ll long long
#define PI 3.14159265358979323846
#define IO ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define rep(i,start,end) for(int i=start;i<end;i++)
#define per(i,start,end) for (int i=end-1;i>=start;i--)
//memset(dp,33,sizeof dp);
using namespace std;
    
const ll mod=1000000007;
const ll inf=1e18;
int cox[]={1,-1,0,0};
int coy[]={0,0,-1,1};

    
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) { return a*b/gcd(a,b);}
ll leastbit(ll a) { return a&(-a);}
ll C(int a,int b) { ll res=1;rep(i,0,b)res=res*(a-i)/(i+1);return res;}
ll powmod( ll a, ll  b) { if(b==0)return 1;ll cnt=powmod(a,b/2);if(abs(cnt)>=sqrt(mod))return -1;(cnt*=cnt);if(b&1){(cnt*=a);if(abs(cnt)>=mod)return -1;}return cnt;}    




int main()
{IO
#ifndef ONLINE_JUDGE
    freopen("output.txt","w",stdout);
#else
#endif
    
    int a,b;
    scanf("%d %d",&a,&b);
    printf("%d",(a+b)%24);
    

    return 0;
}

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

int main(){
  int ans[2];
  char str[10001];
  while( scanf("%s", str) != EOF){
    ans[0] = ans[1] = 0;

    for(int i = 0; str[i + 2] != '\0'; i++){
      if(str[i] == 'J'){
	if(str[i + 1] == 'O'){
	  if(str[i + 2] == 'I'){
	    ans[0]++;
	  }
	}
      }
      else if(str[i] == 'I'){
	if(str[i + 1] == 'O'){
	  if(str[i + 2] == 'I'){
	    ans[1]++;
	  }
	}
      }
    }
    printf("%d\n%d\n", ans[0], ans[1]);
  }
  
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
const int N = 200205, _6 = 1000006;
#define pb push_back
typedef  long long ll;
ll gcd(ll f , ll s){if(s==0)return f;else return gcd(s,f%s);}
int arr[N];
int start[N];
int startR[N];
int main(){
		
	int n;scanf("%d",&n);
	for(int i = 0; i < n ; i++)scanf("%d",arr+i);
	for(int i = 0 ; i < n ; i++){
		startR[arr[i]] = 1;
		startR[arr[i]]+=startR[arr[i]-1];
	}	
	for(int i = n-1 ; i >= 0 ; i--){
		start[arr[i]] = 1;
		start[arr[i]]+=start[arr[i]+1];
	}
	
	int best = 1e9;
	for(int i = 1 ; i <= n ; i++){
		best = min(best,(i-1)+(n-(start[i]+(i-1))));
	}
	for(int i = n ; i >= 1 ; i--){
		best = min(best,(n-i)+(n-(startR[i]+(n-i))));
	}
	printf("%d\n",best);
	return 0 ;
}

Measured memory_bytes: 2560
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;
public class Main {
	public static void main(final String[] args){
    
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    
    System.out.println(a*b);

    
    
    


    


    
    


    
	}
}

Measured memory_bytes: 35824
#include<bits/stdc++.h>
#define pb push_back
#define vl vector
#define ll long long
#define ff first
#define ss second
#define fast std::ios::sync_with_stdio(false)
using namespace std;

ll ras(ll a)
{
    return a*a*a*a*a;
}

int main()
{
    fast;
    ll x;
    cin>>x;
    ll i,j;
    for(i=-200;i<=200;i++)
    {
        for(j=-200;j<=200;j++)
        {
            if(ras(i)-ras(j)==x)
            {
                cout<<i<<" "<<j;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3644
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		Map<Integer, List<Integer>> map = new HashMap<Integer, List<Integer>>();
		for (int i = 0; i < m; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			if (map.containsKey(a)) {
				map.get(a).add(b);
			} else {
				List<Integer> list = new ArrayList<Integer>();
				list.add(b);
				map.put(a, list);
			}
			if (map.containsKey(b)) {
				map.get(b).add(a);
			} else {
				List<Integer> list = new ArrayList<Integer>();
				list.add(a);
				map.put(b, list);
			}
		}
		sc.close();

		int ans = 0;
		for (int a : map.keySet()) {
			for (int b : map.get(a)) {
				if (a < b) {
					boolean[] flg = new boolean[n + 1];
					dfs(flg, 1, map, a, b);
					for (int i = 1; i < n + 1; i++) {
						if (!flg[i]) {
							ans++;
							break;
						}
					}
				}
			}
		}
		System.out.println(ans);
	}

	static void dfs(boolean[] flg, int num, Map<Integer, List<Integer>> map, int ngA, int ngB) {
		if (flg[num]) {
			return;
		}
		flg[num] = true;
		List<Integer> list = map.get(num);
		if (list == null) {
			return;
		}
		for (int b : list) {
			if (num == ngA && b == ngB || num == ngB && b == ngA) {
				continue;
			}
			dfs(flg, b, map, ngA, ngB);
		}
	}
}


Measured memory_bytes: 23892
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    
    if(a == b && b == c)cout <<"Yes"<<endl;
    else cout << "No" << endl;


    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <stdio.h>
using namespace std;
int H, W;
int map[1403][1403];
int main() {
	cin >> H >> W;
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			scanf("%d", &map[i][j]);
		}
	}
	int max = 0;
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			if (map[i][j] == 1) {
				map[i][j] = 0;
			}
			else {
				map[i][j] = min(map[i - 1][j], min(map[i][j - 1], map[i - 1][j - 1])) + 1;
				if (map[i][j] > max) {
					max = map[i][j];
				}
			}
		}
	}
	cout << (max*max) << endl;
}


Measured memory_bytes: 10808
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(),x.end()
#define ln '\n'
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////

template<typename T>
struct edge {
    int src,to;
    T cost;

    edge() = default;
    edge(int to, T cost) : src(-1), to(to), cost(cost) {}
    edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
    bool operator<(const edge &e) const {
        return cost < e.cost;
    }
};

vector<vector<edge<ll>>> G;
vector<ll> dist;
void dfs(int v, int p = -1) {
    for (auto e : G[v]) {
        if (p == e.to) continue;
        dist[e.to] = dist[v] + e.cost;
        dfs(e.to,v);
    }
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    G.resize(N);
    rep(i,N-1) {
        ll u,v,w; cin >> u >> v >> w;
        --u; --v;
        G[u].emplace_back(v,w);
        G[v].emplace_back(u,w);
    }

    dist.resize(N);
    dfs(0);
    rep(i,N) {
        cout << ((dist[i]&1) ? 1 : 0) << ln;
    }
}


Measured memory_bytes: 9216
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <sstream>
#include <numeric>
#include <string>
#include <vector>
#include <cstdio>
#include <bitset>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;

#define pll pair < long long, long long>
#define all(a) a.begin(), a.end()
#define ull unsigned long long
#define pii pair < int, int >
#define sz(a) (int)a.size()
#define vi vector <int>
#define pb push_back
#define ll long long
#define f first
#define s second

const int inf = (int)1e9;
const int mod = (int)1e9 + 7;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int N = 100;
const int M = 100;

vector<pii> p, q;
int A, B;
int a, b = 1;
int g[111][111];
int K = 50;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    cin >> A >> B;
	
	for (int i = 1; i <= K; i++)
		for (int j = 1; j <= 2 * K; j++)
			g[i][j] = 1;

	A--, B--;

	for (int i = 1; i < K; i++) {
		for (int j = 1; j <= 2 * K; j++) {
			if (i % 2 && j % 2 && A) {
				g[i][j] = 0;
				A--;
			}
		}
	}

	for (int i = K + 2; i <= 2 * K; i++) {
		for (int j = 1; j <= 2 * K; j++) {
			if (i % 2 == 0 && j % 2 && B) {
				g[i][j] = 1;
				B--;
			}
		}
	}

	cout << K + K << " " << K + K << "\n";
	for (int i = 1; i <= 2 * K; i++) {
		for (int j = 1; j <= 2 * K; j++) {
			if (g[i][j]) cout << '#';
			else cout << '.';
		}
		cout << "\n";
	}

	return 0;                                                                 
}


Measured memory_bytes: 256
from fractions import gcd
def lcm(a,b):
	return a*b/gcd(a,b)
	
while 1:
	a1,m1,a2,m2,a3,m3=map(int,raw_input().split())
	if a1==0:break
	x,y,z=a1%m1,a2%m2,a3%m3
	cx=cy=cz=1
	while x!=1:
		x=a1*x%m1
		cx+=1
	while y!=1:
		y=a2*y%m2
		cy+=1
	while z!=1:
		z=a3*z%m3
		cz+=1
	print reduce(lcm,[cx,cy,cz])

Measured memory_bytes: 5880
#include <cstdio>

float x1,y1,x2,y2,x3,y3,xp,yp;
float X1,Y1,X2,Y2,XP,YP;
float d,s,t;

int main(){
  while(~scanf("%f%f%f%f%f%f%f%f",&x1,&y1,&x2,&y2,&x3,&y3,&xp,&yp)){
    X1=x2-x1;
    Y1=y2-y1;
    X2=x3-x1;
    Y2=y3-y1;
    XP=xp-x1;
    YP=yp-y1;
    d=X1*Y2-X2*Y1;
    t=(XP*Y2-X2*YP)/d;
    s=(-XP*Y1+X1*YP)/d;
    if(0<t&&t<1&&0<s&&s<1&&s+t<1){
      puts("YES");
    }else{
      puts("NO");
    }
  }
}

Measured memory_bytes: 0
import java.util.*;
import java.io.*;

public class Main{

     public static void main(String []args){
        Scanner scanner = new Scanner(System.in);
        String s= scanner.next();
        boolean bool = true;
        List<Character> list = new ArrayList<>();
        
        for(int i=0;i<s.length();i++)
        list.add(s.charAt(i));
        
        int [] arr = new int[26];
        
        Collections.sort(list);
        
        char temp = list.get(0);
        int counter=0;
        
         for(int i=0;i<s.length();i++)
         {
             
             int index =(int)(s.charAt(i)-'a');
             
             arr[index]++;
             
         }
         
          for(int i=0;i<26;i++)
          {
              if(arr[i]%2!=0)
              {
                  bool = false;
                  break;
              }
          }
             
           if(bool)
            System.out.println("Yes");
           else
         System.out.println("No");
       
        
        //for(int i=0;i<n;i++)
        
        //System.out.println();
     }
}

Measured memory_bytes: 35764
// Problem : A - Poisonous Cookies
// Contest : AtCoder Grand Contest 030
// URL : https://atcoder.jp/contests/agc030/tasks/agc030_a
// Memory Limit : 1024.000000 MB 
// Time Limit : 2000.000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor2)

//Dragon_warrior7(IITK)
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 1000000000000000000
#define deb(x) cout << #x << " " << x << "\n"
#define pll pair<ll, ll> 
#define vll vector<ll> 
#define rub cout << "\n------------------------------------\n"
void read(vector<ll> &v)
{
	for (int i = 0; i < v.size(); i++)
		cin >> v[i];
}

void print(vector<ll> v)
{
	for (int i = 0; i < v.size(); i++)
		cout << v[i] << " ";
}
ll n,m,a,b,temp,x,y;
string str;
set<ll> s;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
 ll c,d;
 cin>>a>>b>>c>>d;
 cin>>n;
 if(b>2*a)
 b=2*a;
 if(c>2*b)
 c=2*b;
 if(d>2*c)
 d=2*c;
ll ans=(n/2)*d;
if(n%2==1)
ans+=c;
cout<<ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int dp[100005];
bool vis[100005];
int dfs(int src , list<int> adj[]){
  if(vis[src]==true) return dp[src];
	vis[src]=true;
  int len=0;
  for (auto u=adj[src].begin();u!=adj[src].end();u++){
  	len=max(1+dfs(*u,adj),len);
  }
  dp[src]=len;
    return dp[src];

}
int main(){
  int v,e;
  cin>>v>>e;
  int x,y;
  list< int> adj[v+1];
  for(int i=0;i<e;i++){
  	cin>>x>>y;
    adj[x].push_back(y);
  }
  
  //memset(vis, false, sizeof vis);
  for(int i=0;i<=v;i++) vis[i]=false;
  int len=0;
  for(int i=1;i<=v;i++){
  	len=max(len,dfs(i,adj));
  //  memset(vis,false, sizeof vis);
  }
  
  cout<<len<<endl;
}


Measured memory_bytes: 7424
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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

char c[55][55];
int h, w, cnt;

int main () {
  cin >> h >> w;
  rep(i,h)rep(j,w) cin >> c[i][j];
  rep(i,h) {
    rep(j,w) {
      if (c[i][j]=='#' && c[i][j-1]!='#' && c[i-1][j]!='#' && c[i][j+1]!='#' && c[i+1][j]!='#') {
        cnt++;
      }
    }
  }
  cout << (cnt==0?"Yes":"No") << endl;
  return 0;
}

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

using namespace std;

//using Matrix = vector< vector<int> >;
typedef long long ll;
typedef pair<int, int> P;
#define fir first
#define sec second

const int INF = 1e9 + 10;
//const ll INF = 1e18 + 10LL;
int dx[5] = {0, 0, 1, -1, 0}, dy[5] = {1, -1, 0, 0, 0};
const double EPS = 1e-10;
bool cmp(P a, P b) { return a.second < b.second; } //End sort (Interval scheduling problem)
ll MOD = 1e9 + 7;

int n;
int a[100010];

void solve() {
	ll S = 0;
	for (int i = 0; i < n; i++) S += abs(a[i]);

	int neg = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] < 0) neg++;
		if (a[i] == 0) {
			printf("%lld\n", S);
			return;
		}
	}
	if (neg % 2 == 0) {
		printf("%lld\n", S);
		return;
	}

	int minv = INF;
	for (int i = 0; i < n; i++) minv = min(minv, abs(a[i]));
	S = S - (2 * minv);
	printf("%lld\n", S);

	return;
}

int main(void){
	cin>>n;
	for (int i = 0; i < n; i++) cin>>a[i];

	solve();
	
	return 0;
}

Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>




int main() {

		int a, b, c, dd = 0;


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

		if (a == b)dd++;

		if (a == c)dd++;

		if (b == c)dd++;

		if (dd == 3) dd = 2;

		printf("%d", 3 - dd);






		return 0;
	

}

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

int main() {
  int n,a,b,c;
  cin >> n;
  a = n / 100;
  b = (n - a*100) / 10;
  c = n - a*100 - b*10 ;
  cout << a + b + c  <<endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		//外部入力取り込んだ借金をしている期間（週単位）
		int week = Integer.parseInt(in.readLine());
		//借金
		double debt = 100000;
		//利子
		double interest = 1.05;

		//借金の計算
		for (int i = 0; i < week; i++) {
			//一週間ごとに 借金に5% の利子を借金に加える
			debt = debt * interest;
			//借金の 1,000 円未満を切り上げ
			debt = Math.ceil(debt/1000);
			debt = debt * 1000;
		}
		//計算後の借金を整数として外部出力
		System.out.println((int)debt);
	}
}

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

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

const char lf = '\n';

namespace ae86
{
	const int bufl = 1 << 15;

	char buf[bufl],*s=buf,*t=buf;

	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}

	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return a;
	}
}
using ae86::ty;

const int _ = 100007 , __ = 200007 , inf = 1e9;
const int _e = __ << 1;

int to[_e],ne[_e],ev[_e],he[_]={0},ecnt=1;
inline void adde(int a,int b,int c){to[++ecnt]=b,ev[ecnt]=c,ne[ecnt]=he[a],he[a]=ecnt;}
inline void addde(int a,int b,int c){adde(a,b,c),adde(b,a,c);}

int n,m,ned[_]={0},ea[__],eb[__],eva[__]={0};
int col[_]={0};

struct cxk
{
	int x,d;
	cxk(int x_=0,int d_=0){x=x_,d=d_;}
	friend bool operator < (cxk a,cxk b){return a.d<b.d;}
};
priority_queue<cxk> dlq;

void failure()
{
	cout<<-1<<lf;
	exit(0);
}

int main()
{
	ios::sync_with_stdio(0),cout.tie(nullptr);

	n=ty(),m=ty();
	for(int i=1;i<=n;i++)ned[i]=ty();
	for(int i=1;i<=m;i++)ea[i]=ty(),eb[i]=ty(),addde(ea[i],eb[i],i);

	int got=0,spc=0;
	for(int i=1;i<=m;i++)
	{
		int a=ea[i],b=eb[i];
		if(ned[a]==ned[b] && !col[a] && !col[b])
		{
			dlq.emplace(a,ned[a]),dlq.emplace(b,ned[b]);
			col[a]=1,col[b]=2,spc+=2;
			eva[i]=ned[a],got=1;
		}
	}

	if(!got)failure();

	while(!dlq.empty())
	{
		int a=dlq.top().x;dlq.pop();
		for(int i=he[a];i;i=ne[i])
		{
			int b=to[i];
			if(col[b] || ned[b]<ned[a])continue;
			col[b]=3-col[a],eva[ev[i]]=ned[b],spc++;
			dlq.emplace(b,ned[b]);
		}
	}

	if(spc<n)failure();
	for(int i=1;i<=n;i++)cout<<"BW"[col[i]-1];
	cout<<lf;
	for(int i=1;i<=m;i++)
	{
		if(!eva[i])eva[i]=inf;
		cout<<eva[i]<<lf;
	}

	return 0;
}

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

int main(){
  int H,W;cin>>H>>W;
  bool fin = false;
  for(int i=1;i<=H;++i){
    for(char c='A';c<'A'+W;++c){
      string s; cin>>s;
      if(s=="snuke"){ cout<<c<<i;fin=true;break;}
    }
    if(fin){break;}
  }
}

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

int ans = INF;
int bf[3][31];
int best_colors[3][3];

int main()
{
    int n, c, i, j, k;
    cin >> n >> c;

    int wrong[c + 1][c + 1];
    int squares[n + 1][n + 1];

    for (i = 1; i <= c; i++)
    {
        for (j = 1; j <= c; j++)
        {
            cin >> wrong[i][j];
        }
    }

    for (i = 1; i <= n; i++)
    {
        for (j = 1; j <= n; j++)
        {
            cin >> squares[i][j];
        }
    }

    memset(bf, 0, sizeof(bf));

    for (int mod = 0; mod < 3; mod++)
    {
        for (int color = 1; color <= c; color++)
        {
            for (i = 1; i <= n; i++)
            {
                for (j = 1; j <= n; j++)
                {
                    if ((i + j) % 3 == mod)
                    {
                        bf[mod][color] += wrong[squares[i][j]][color];
                    }
                }
            }
        }
    }
	int ans = INF;
	for (i = 1; i <= c; i++)
	{
		for (j = 1; j <= c; j++)
		{
			if (j != i)
			{
				for (k = 1; k <= c; k++)
				{
					if (k != j && k != i)
					{
						ans = min(ans, bf[0][i] + bf[1][j] + bf[2][k]);
					}
				}
			}
		}
	}
    cout << ans << endl;

    return 0;
}

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

int n,k,t,ans=0;
int visited[1000005]; 

signed main()
{
	cin>>n>>k;
	for (int i=1;i<=k;i++)
	{
		cin>>t;
		for (int i=1;i<=t;i++)
		{
			int tmp;
			cin>>tmp;
			visited[tmp]=1;
		}
	}
	for (int i=1;i<=n;i++)
	{
		if (visited[i]==0)  ans++;
	}
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mod 1000000007
#define fi first
#define se second
int main()
{
    string t;
    cin>>t;
    int i;
    for(i=0;i<t.size();i++)
        if(t[i]=='?')
            t[i]='D';
    int ans = 0;
    for(i=0;i<t.size()-1;i++)
    {
        if(t[i]=='D')
            ans++;
        if(t[i]=='P' && t[i+1]=='D')
            ans++;
    }
    if(t[i]=='D')
        ans++;
    cout<<t;
}   


Measured memory_bytes: 3752
n, m, x = list(map(int, input().split()))
a = list(map(int, input().split()))

left_cost = 0
for toleft in range(x-1, 0, -1):
    if toleft in a:
        left_cost += 1

right_cost = 0
for toright in range(x, n+1):
    if toright in a:
        right_cost += 1

print(min(left_cost, right_cost))

Measured memory_bytes: 3060
//#pragma optimization_level 3
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordset;
*/

#define fr first
#define sc second
#define vec vector
#define pb push_back
#define pii pair<int, int>
#define fo(x,y) for(int x = 1 ; x <= y ; ++x)
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;

typedef long long ll;
typedef unsigned int uint;
const int nmax = 200005;
const ll linf = LLONG_MAX;
const ll mod = 1e9+7;
const int inf = INT_MAX;

ll n, a, b;

ll pw(ll x , ll y){
	ll sq = x;
	ll ret = 1;
	for(ll k = 0 ; (1<<k) <= y ; k++){
		if((1<<k)&(y)){
			ret *= sq;
			ret %= mod;
		}
		sq *= sq;
		sq %= mod;
	}
	return ret;
}

ll co( ll x ){
	ll ret = n;
	for(int i = 2 ; i <= x ; i++){
		ret *= pw(i,mod-2);
		ret %= mod;
		ret *= (n-i+1);
		ret %= mod;
	}
	return ret;
	// n!/ (a)! (n-a)!
	// n!/ (a-1)! (n-a+1)!
}


int main(){
	cin >> n >> a >> b;
	// 2 ^ n - n choose a - n choose b
	cout << (pw(2,n) - co(a) - co(b) - 1 + 2*mod)%mod << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<long>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 998244353
#define all(vec) vec.begin(), vec.end()

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

Measured memory_bytes: 3648
d, g = map(int, input().split())
pc = [list(map(int, input().split())) for _ in range(d)]

ans = float('inf')

for i in range(1 << d):
  count = 0
  sum = 0
  nokori = set(range(1, d+1))
  
  for j in range(d):
    if i & (1<<j):
      sum += pc[j][0] * (j+1) * 100 + pc[j][1]
      count += pc[j][0]
      nokori.discard(j+1)
      
  if sum < g:
    use = max(nokori)
    n = min(pc[use-1][0], -(-(g-sum)//(use*100)))
    count += n
    sum += n*use*100
    
  if sum >= g:
    ans = min(ans, count)

print(ans)

Measured memory_bytes: 9160
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <queue>
#include <iomanip>
#include <set>
//#include <bits/stdc++.h>
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
using namespace std;
#define ALL(X) X.begin(),X.end()
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
const int MOD=1000000007;
//const int MOD=998244353;
const int INTMAX=2147483647;
const ll LLMAX=9223372036854775807;

bool comp(vll a,vll b){
    return a[1]>b[1];
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll N,M;
    cin>>N>>M;
    vll H(N),A(M),B(M);
    for(ll i=0;i<N;i++)cin>>H[i];
    
    vll MAX(N,0);
    for(ll i=0;i<M;i++){
        cin>>A[i]>>B[i];
        A[i]--;B[i]--;
        chmax(MAX[A[i]],H[B[i]]);
        chmax(MAX[B[i]],H[A[i]]);
    }
    
    ll ans=0;
    for(ll i=0;i<N;i++){
        if(H[i]>MAX[i])ans++;
    }
    cout<<ans<<endl;
    
    
    
    return 0;
}


Measured memory_bytes: 6368
import java.util.Arrays;
import java.util.Scanner;

public class Main
{
	public static void main(String arg[])
	{
		Scanner sc = new Scanner(System.in);

		while(sc.hasNext())
		{
			int n = sc.nextInt();
			boolean a[] = new boolean[n+n+1];
			Arrays.fill(a, true);
			a[0]=a[1]=false;
			for(int i =2; i*i<=n+n; i++)
			{
				if(!a[i])
					continue;
				for(int j=i+i; j<=n+n;j+=i)
				{
					a[j] = false;
				}
			}

			for(int i=n-1; i>=0; i--)
			{
				if(a[i])
				{
					System.out.print(i);
					break;
				}
			}
			for(int i =n+1; i<=n+n; i++)
			{
				if(a[i])
				{
					System.out.println(" "+i);
					break;
				}
			}
		}
	}

}

Measured memory_bytes: 12000
#include <string>
#include <iostream>
using namespace std;
string s; int dp[80000][11];
int main() {
	while (cin >> s) {
		if (s == "0") break;
		for (int i = 0; i < s.size(); i++) {
			for (int j = 0; j < 11; j++) {
				dp[i][j] = 0;
			}
		}
		dp[0][s[0] - 48] = 1;
		for (int i = 1; i < s.size(); i++) {
			if (s[i] != '0') {
				if (i % 2 == 0) {
					dp[i][s[i] - 48] = 1;
				}
				else {
					dp[i][(-s[i] + 59) % 11] = 1;
				}
			}
			for (int j = 0; j < 11; j++) {
				if (i % 2 == 0) {
					dp[i][j] += dp[i - 1][(j - s[i] + 59) % 11];
				}
				else {
					dp[i][j] += dp[i - 1][(j + s[i] - 48) % 11];
				}
			}
		}
		int ret = 0;
		for (int i = 0; i < s.size(); i++) {
			ret += dp[i][0];
		}
		printf("%d\n", ret);
	}
	return 0;
}

Measured memory_bytes: 6696
#include<bits/stdc++.h>
#include<ext/rope>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define mst(a,b) memset(a,b,sizeof(a))
#define ALL(x) x.begin(),x.end()
#define pii pair<int,int>
#define mp make_pair
#define lowbit(x) (x&(-x))
#define X first
#define Y second
using namespace __gnu_pbds;
using namespace __gnu_cxx;
using namespace std;
typedef long long ll;
typedef long long LL;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<ll, ll> pll;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const long double eps = 1e-8;
const long double pi = acos(-1.0);
const int N = 1e6 + 5;
const int mod = 1e9 + 21;
const int maxn = 1e7 + 5;
ll solve(ll k,ll a,ll b){
    if(k < a - 1)return 0;
    k -= a - 1;
    ll c = a,d = 0;
    ll ans = a + (b - a) * (k / 2);
    if(k&1)ans++;
    return ans;
}
int main() {
#ifdef local
    freopen("input", "r", stdin);
//    freopen("out.txt","w",stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll k,a,b;
    cin>>k>>a>>b;
    ll ans = max(1 + k,solve(k,a,b));
    cout<<ans<<endl;
}


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

int mod=1000000007;

int main()
{
    int n;
    cin>>n;
    long long int a=1,b=1,c=1,ans;
    for (size_t i = 0; i < n; i++)
    {
        a=(a*10)%mod;
        b=(b*9)%mod;
        c=(c*8)%mod;
    }
    ans=(a-2*b+c)%mod;
    ans=(ans+mod)%mod;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3532
N=int(input())#入力回数を決める
data = input().split() 
list_count = []
for num in data:
    count = 0
    while int(num) % 2 == 0:
        num = int(num) / 2
        count += 1
    list_count.append(count) 

print(min(list_count))

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;
const int mo = 1e9 + 7;
const int maxn = 200002;

int n, c[maxn];
vector<int> pos[maxn];

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin >> n;
	vector<int> idx(n, -1);

	for (int i = 0; i < n; ++i)
	{
		cin >> c[i];
		if (i == 0 || c[i] != c[i-1]) {
			idx[i] = pos[c[i]].size();
			pos[c[i]].push_back(i);
		}
	}

	vector<long long> f(n);
	f[0] = 1;
	for (int i = 1; i < n; ++i) {
		f[i] = f[i-1];
		if (idx[i] > 0) {
			int t = pos[c[i]][idx[i]-1];
			
			f[i] += f[t];

			f[i] %= mo;
		} 
	}

	cout << f[n-1] << endl;

	return 0;
}

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

using namespace std;

int main() {
    int N; cin >> N;
    vector<int> L(2*N); for(int i = 0; i < 2*N; ++i) cin >> L[i];

    sort(L.begin(), L.end(), greater<int>());
    int count = 0;
    int result = 0;
    for(auto hoge : L) {
        if(count % 2 == 1) result += hoge;
        count++;
    }
    cout << result << endl;
    return 0; 
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const ll N = 4e5 + 5;
int n,m,k;
const int MOD = 1e9 + 7;
 
ll fact[N], invfact[N];
 
ll pow(ll a, ll b, ll m)
{
  ll ans=1;
  while(b)
  {
    if(b&1)
      ans=(ans*a)%m;
    b/=2;
    a=(a*a)%m;
  }
  return ans;
}
 
ll modinv(ll k)
{
  return pow(k, MOD-2, MOD);
}
 
void precompute()
{
  fact[0]=fact[1]=1;
  for(int i=2;i<N;i++)
  {
    fact[i]=fact[i-1]*i;
    fact[i]%=MOD;
  }
  invfact[N-1]=modinv(fact[N-1]);
  for(int i=N-2;i>=0;i--)
  {
    invfact[i]=invfact[i+1]*(i+1);
    invfact[i]%=MOD;
  }
}
 
ll nCr(ll x, ll y)
{
  if(y>x)
    return 0;
  ll num=fact[x];
  num*=invfact[y];
  num%=MOD;
  num*=invfact[x-y];
  num%=MOD;
  return num;
}

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

  cin>>n>>m>>k;
  precompute();

  ll always = nCr(n*m - 2, k-2);
  ll ans = 0;
  for (ll dist=1; dist<=n-1; dist++) {
    ll ways = n-dist;
    ll cur = 1LL*dist*ways*m*m*always;
    cur %= MOD;
    ans += cur;
    ans %= MOD;
  }
  for (ll dist=1; dist<=m-1; dist++) {
    ll ways = m-dist;
    ll cur = 1LL*dist*ways*n*n*always;
    cur %= MOD;
    ans += cur;
    ans %= MOD;
  }
  cout<<ans<<endl;
  
  return 0;
}



Measured memory_bytes: 6528
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

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

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  string S;

  cin >> S;

  if (S[0] != S[1] && S[1] != S[2] && S[2] != S[3]) {
    cout << "Good" << endl;
  } else {
    cout << "Bad" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
n, m, l = map(int,input().split())

a = [list(map(int,input().split())) for _ in range(n)]
b = [list(map(int,input().split())) for _ in range(m)]
c = [[0]*l for _ in range(n)]
for i in range(n):
    for j in range(l):
        for k in range(m):
            c[i][j] += a[i][k] * b[k][j]
for q in range(n):
    print(*c[q])


Measured memory_bytes: 7044
import java.awt.print.Printable;
import java.util.Arrays;
import java.util.Scanner;
import javax.sound.midi.SysexMessage;
  
public class Main{      
    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);

        for(int i=0;i<20;i++){
            if(sc.hasNext()){
            int n = sc.nextInt();
            if(n>2){
            int points[] = new int[n];

            for(int j=0;j<n;j++){
                points[j]=sc.nextInt();
            }
            Arrays.sort(points);
        
            points[0]=0;
            points[n-1]=0;

            double sum=0.0;
            double ave=0.0;
            for(int j=0;j<n;j++){
                sum += points[j];
            }
            ave = sum/(double)(n-2);

            int ave2 = (int)Math.floor(ave);

            System.out.println(ave2);
        }
    }
        }
        sc.close();
        
    }   
}


Measured memory_bytes: 28776
#include <iostream>
#include <string>

using namespace std;

int a(const string& s, const int max = 100000)
{
    int count = 0;
    for (string::size_type i = 0; i < s.size(); ++i) {
        if (s[i] == 'S') ++count;
        if (s[i] == 'T' and count > 0) --count;
    }
    int op = s.size()/2 - count;
    if (op > max) op = max;
    return s.size() - op*2;
}

int main()
{
    string s;
    cin >> s;
    cout << a(s) << endl;
    return 0;
}


Measured memory_bytes: 768
#include <iostream>
using namespace std;
int main() {
    string S;
    cin>>S;
    if (S[0]==S[1]&&S[1]==S[2]&&S[0]==S[2]) {
        cout<<"No"<<endl;
        
    }else{
        cout<<"Yes"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>

int main(){
int a,res=0;
char x[20],y[40],z[20];
scanf("%s",&x);
scanf("%d",&a);
for(int i=0;i<a;i++){
scanf("%s",&y);
strcpy(z,y);
strcat(y,z);
if(strstr(y,x)){
 res++;
}
}
printf("%d\n",res);
return 0;
}

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


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

using namespace std;

const int Nmax = 1e5 + 5;

int n, i, j, t[Nmax];
char a[Nmax];

int main()
{
   /// freopen("input", "r", stdin);
    cin.sync_with_stdio(false);

    cin >> (a+1); a[0] = '0';
    n = strlen(a+1);

    for(i=1; i<=n; ++i)
        if(a[i] != a[n-i] || a[1] == '0')
        {
            cout << "-1\n";
            return 0;
        }

    int last = 1;

    a[n] = '1';
    for(i=2; i<=n; ++i)
        if(a[i] == '1')
        {
            for(j=last; j<i; ++j) t[j] = i;
            last = i;
        }

    for(i=1; i<n; ++i)
        cout << i << ' ' << t[i] << '\n';
    return 0;
}


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

int main(void){
    int n ;
    long long ans=0 ;
    cin >> n ;
    vector<int> a,b ;
    for (int i=0; i<n+1; i++){
        int x ;
        cin >> x ;
        ans+=x ;
        a.push_back(x) ;
    }
    for (int i=0; i<n; i++){
        int x ;
        cin >> x ;
        if (a[i]>x){
            a[i]=a[i]-x ;
        } else {
            a[i+1]=max(0,a[i+1]-x+a[i]);
            a[i]=0 ;
        }
    }
    for (int i=0; i<n+1; i++){
        ans-=a[i] ;
    }
    cout << ans << endl ;
}

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

int main() {

	    ll int n;
	    cin>>n;
	    ll int arr[n];
	    for(ll int i = 0;i<n;i++){
	        cin>>arr[i];
	    }
	    pair<ll int,ll int> dp[n][n];
	    for(ll int i = 0;i<n;i++){
	        dp[i][i].first   = arr[i];
	        dp[i][i].second  = 0;
	    }
	    for(ll int diff = 1;diff<n;diff++){
	        for(ll int i = 0;i<n-diff;i++){
	            int j = i+diff;
	            dp[i][j].first = 0;
	            dp[i][j].second = 0;

	            if(arr[j]+dp[i][j-1].second > dp[i][j].first){
	                dp[i][j].first  = arr[j]+dp[i][j-1].second;
	                dp[i][j].second = dp[i][j-1].first;
	            }
	            if(arr[i]+dp[i+1][j].second > dp[i][j].first){
	                dp[i][j].first  = arr[i]+dp[i+1][j].second;
	                dp[i][j].second = dp[i+1][j].first;
	            }

	        }
	    }
	    cout<<dp[0][n-1].first - dp[0][n-1].second<<endl;
}


Measured memory_bytes: 140928
#include<bits/stdc++.h>
using namespace std;
int N,Q,f[100010];
string S;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> N >> Q >> S;
	for(int i = 0; i < S.size(); i++){
		if(S[i]=='C' && S[i-1]=='A') f[i+1] = f[i] + 1;
			else f[i+1] = f[i];
	}
	for(int i = 0; i < Q; i++){
		int l,r;
		cin >> l >> r;
		cout << f[r]-f[l] << "\n";
	}
	return 0;
}

Measured memory_bytes: 1488
#include<bits/stdc++.h>
#define pi 3.1415926535897932384626
using namespace std;
      
struct P{
  int x,y;
  bool operator < (const P &a )const{
    //if(y!=a.y)
    return y>a.y;
  };
};

int a,b,c,d,i,k,n,m,e[333],dx[10]={1,0,-1,0,1,1,-1,-1},dy[10]={0,1,0,-1,1,-1,1,-1};
int o[310];
int l[10000001];
int j[331];

long long x,y,z,mod=1000000007;
//string r;
char r[2];

P u[1];
queue<int> q;
//stack<int> s;
set<int> s;
map<int,int> p;

vector<int> v1;
struct S{
  int x,l,r;
};
vector<S> v[444];

bool as(P a,P b)
{
  return a.x<b.x;
}

void mk(int n,int m)
{
  v[n].push_back({m,1,(int)v[m].size()});
  v[m].push_back({n,0,(int)v[n].size()-1});
}

void dfs()
{
  memset(j,-1,sizeof(j));
  j[205]=0;
  q.push(205);
  for(;q.size();q.pop())
  for(int h=0;h<v[q.front()].size();h++)
  if(v[q.front()][h].l&&j[v[q.front()][h].x]<0)
  {
    j[v[q.front()][h].x]=j[q.front()]+1;
    q.push(v[q.front()][h].x);
  }
}

int f(int n,int m,int l)
{
  if(n==m) return l;
  for(;e[n]<v[n].size();e[n]++)
  if(v[n][e[n]].l&&j[v[n][e[n]].x]==j[n]+1)
  {
    int k=f(v[n][e[n]].x,m,min(l,v[n][e[n]].l));
    if(k)
    {
      v[n][e[n]].l-=k;
      v[v[n][e[n]].x][v[n][e[n]].r].l+=k;
      return k;
    }
  }
  return 0;
}

int main()
{
  l[1]=l[2]=1;
  for(int t=3;t<=10000000;t+=2)
  if(l[t]==0)
  {
    //v.push_back(t);
    for(long long i=(long long)t*t;i<=10000000;i+=t)
    l[i]=1;
  }
  scanf("%d",&a);
  for(int t=1;t<=a;t++)
    scanf("%d",&o[t]);
  o[0]=-1;
  for(int t=1;t<=a;t++)
  {
    if(o[t-1]+1!=o[t]) v1.push_back(o[t]);
    if(o[t]+1!=o[t+1]) v1.push_back(o[t]+1);
  }
  for(int h=0;h<v1.size();h++)
  if(v1[h]%2) n++,mk(205,h);
  else m++,mk(h,210);
  for(int i=0;i<v1.size();i++)
  if(v1[i]%2)
  for(int j=0;j<v1.size();j++)
  if(v1[j]%2==0&&l[abs(v1[i]-v1[j])]==0)
  {
    mk(i,j);
  }
  for(;;)
  {
    dfs();
    if(j[210]<0) break;
    memset(e,0,sizeof(e));
    d=f(205,210,555);
    if(!d) break;
    else k+=d;
  }
  //printf("%d %d %d",n,m,k);
  printf("%d",k+(n-k)/2*2+(m-k)/2*2+abs(n-k)%2*3);
}
//664579



//3


Measured memory_bytes: 39552