akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main()
{
	while (true)
	{
		int n;
		cin >> n;
		if (n == 0) break;
		vector<string> motions(n);
		for (int i = 0; i < n; i++)
		{
			cin >> motions[i];
		}
		if (n <= 1)
		{
			cout << 0 << endl;
		}
		else {
			int state = 0;
			int lstate = 0;
			int rstate = 0;
			int count = 0;
			for (auto motion : motions)
			{
				if (motion == "lu")
				{
					lstate = 1;
				}
				else if (motion == "ld")
				{
					lstate = 0;
				}
				else if (motion == "ru")
				{
					rstate = 1;
				}
				else if (motion == "rd")
				{
					rstate = 0;
				}
				if (lstate == 1 && rstate == 1)
				{
					if (state == 0)
					{
						count++;
					}
					state = 1;
				}
				else if (lstate == 0 && rstate == 0)
				{
					if (state == 1)
					{
						count++;
					}
					state = 0;
				}
			}
			cout << count << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3116
import java.util.*;

public class Main{

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();

    int wa = a + b;
    int sa = a - b;
    int seki = a*b;
    int max = wa;

    int[] data = {wa,sa,seki};

    for(int i = 0;i < data.length;i++){
      max = Math.max(data[i],max);
    }

    System.out.println(max);

  }

}


Measured memory_bytes: 21844
#include<stdio.h>

long long int counter[41];
long long int add[41];
int main(){
  int i,ans,n,j;
  int ope[100];
  scanf("%d",&n);
  for(i=0;i<n-1;i++) scanf("%d ",ope+i);
  scanf("%d",&ans);
  counter[ope[0]+10]=1;
  for(i=1;i<n-1;i++){
    for(j=10;j<31;j++){
      if(counter[j]){
	add[j+ope[i]]+=counter[j];
	add[j-ope[i]]+=counter[j];
	counter[j]=0;
      }
    }
    for(j=10;j<31;j++){
      counter[j]+=add[j];
      add[j]=0;
    }
  }    
  printf("%lld\n",counter[ans+10]);
  return 0;
}
  
  

Measured memory_bytes: 0
a = list(map(int,input().split()))
a = sorted(a)
counter = 0

x = (a[1]-a[0])//2
y = (a[1]-a[0])%2
if y == 1:
    a[2]+=1
counter +=x+y
z = (a[2]-a[1])//2
s = (a[2]-a[1])%2
counter += (z*2)+s

print(int(counter))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define fori(i,n) for(int i =0;i<n;i++)
#define pb push_back
#define ll long long
#define int long long
#define F first
#define S second
#define mp make_pair
#define rev(a) reverse(a.begin(),a.end())
#define srt(a) sort(a.begin(),a.end())
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cout.precision(15);
 
 
int mod = 1e9+7;
 
int pow(int a, int b) {
    int ans = 1;
    a %= mod;
    while(b) {
        if(b%2) {
            ans *= a;
            ans %= mod;
        }
        b /= 2;
        a *= a;
        a %= mod;
    }
    return ans;
}

int inv(int a) {
    return pow(a,mod-2);
}

int mul (int a,int b) {
    return ((a%mod)*(b%mod))% mod;
}

struct cmp {
    bool operator() (pair<int,int> a, pair<int,int> b) const {
        int x = a.F;
        int y = b.F;
        return x>=y;
    }
};


int32_t main() {
    FAST;
    int t;
    // cin>>t;
    t = 1;
    while(t--) {
        int n;
        cin>>n;
        int a[n],b[n+2],c[n+2];
        b[0]=c[0]=c[n-1]=b[n+1] = 0;
        int ans[n+1];
        fori(i,n) cin>>a[i];
        fori(i,n) {
            b[i+1] = b[i] ^ a[i];
        }
        for(int i = n-2;i>=0;i--) {
            c[i] = c[i+1] ^ a[i+1];
        }
        fori(i,n) {
            ans[i] = b[i]^c[i];
        }
        fori(i,n) cout<<ans[i]<<" ";
    }
    
    return 0;
}

Measured memory_bytes: 9804
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)


void solve(long long N, std::vector<long long> a){
    ll ans=0;
    ll s=0, t=0;
    while(1){
        while( t < N){
            if(a[t] != a[s])
                break;
            else t++;
        }
        ll tmp = t-s;
        ans += tmp/2;
        if(t >=N) break;
        s = t;
    }
    cout<<ans<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, std::move(a));
    return 0;
}


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

typedef long long ll;
typedef pair<int,int> P;

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

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

const char newl = '\n';

int main() {
    int h,w;
    cin >> h >> w;
    string s[500],r[500],b[500];
    for (int i = 0;i < h;++i) cin >> s[i];
    for (int i = 0;i < h;++i) r[i] = string(w,'.');
    for (int i = 0;i < h;++i) b[i] = string(w,'.');
    for (int i = 0;i < h;++i) r[i][0] = '#';
    for (int i = 0;i < h;++i) b[i][w-1] = '#';
    for (int i = 0;i < h;++i) {
        if (i&1) for (int j = 0;j < w-1;++j) r[i][j] = '#';
        else for (int j = 1;j < w;++j) b[i][j] = '#';
    }
    for (int i = 0;i < h;++i) for (int j = 0;j < w;++j) if (s[i][j] == '#') r[i][j] = b[i][j] = '#';
    for (int i = 0;i < h;++i) cout << r[i] << newl;
    cout << newl;
    for (int i = 0;i < h;++i) cout << b[i] << newl;
}

Measured memory_bytes: 1536
H, W = map(int, input().split())

S = [input() for _ in range(H)]

jdg = True
for i in range(H):
    for j in range(W):
        ans = 0
        if S[i][j] == '#':
            ans += 1
            for x, y in [[1, 0], [-1, 0], [0, 1], [0, -1]]:
                if 0 <= i + y <= H - 1 and 0 <= j + x <= W - 1:
                    if S[i + y][j + x] == '#':
                        ans += 1
            if ans == 1:
                jdg = False
                break
    if not jdg:break
print('Yes' if jdg else 'No')

Measured memory_bytes: 9160
#include <stdio.h>
#include <stdlib.h>
int n, l, j, u, k, tmp;
int list[100][100];
int lengthlist[100];

void search(int y, int length){
  int i;
  length++;
  lengthlist[y] = length;


  for( i = 0 ; i < n ; i++){
    if( list[y][i] == 1 ){
      if( lengthlist[i] <= length && lengthlist[i] >= 0 ){
        continue;
      }
      search(i, length);
    }
  }
}

int main(){
  scanf("%d", &n);
  for(l = 0 ; l < n ; l++){
    scanf("%d", &u);
    scanf("%d", &k);
    for( j = 0 ; j < k ; j++){
      scanf("%d", &tmp);
      list[u-1][tmp-1] = 1;
    }
  }
  for( l = 0 ; l < n ; l++){
    lengthlist[l] = -1;
  }
  search(0, -1);

  for(j = 0 ; j < n ; j++){
    printf("%d %d\n", j+1, lengthlist[j]);
  }

  return 0;
}



Measured memory_bytes: 2056
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define pb push_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define chmin(x,y) if(x>y)x=y
#define chmax(x,y) if(x<y)x=y
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll,vector<ll>,greater<ll>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
using vc=vector<char>;
using vvc=vector<vector<char>>;
const ll inf=1001001001001001;
const int Inf=1001001001;
const int mod=1000000007;
int main(){
    int n,k;cin>>n>>k;
    vector<P> v(n);
    rep(i,n){
        int a,b;
        cin>>a>>b;
        v[i]=P(a,b);
    }
    sort(all(v));
    ll i=0,ans=0;
    while(k>0){
        if(v[i].second>k)ans+=k*v[i].first;
        else ans+=v[i].second*v[i].first;
        k-=v[i].second;
        i++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7


#############
# Main Code #
#############

N = getN()
cnt = 0
for i in range(1, N + 1):
    opt = N // i
    cnt += i * (opt + 1) * opt //2
print(cnt)


Measured memory_bytes: 78056
function main()
  n = parse(Int, readline())
  s = chomp(readline())

  # # 3文字未満の場合、条件を満たす組は存在しない
  if n < 3
    println(0)
    exit()
  end

  # 間隔が等しい場合の数を先に求める
  cnt = 0
  for d in 1:div(n-1,2)
    for i in 1:(n-2*d)
      j = i + d
      k = j + d
      if s[i] != s[j] && s[j] != s[k] && s[k] != s[i]
        cnt += 1
      end
    end
  end

  r = 0
  g = 0
  b = 0
  ans = 0
  for i in 1:n
    if s[i] == 'R'
      ans += g * b
      r += 1
    elseif s[i] == 'G'
      ans += r * b
      g += 1
    elseif s[i] == 'B'
      ans += r * g
      b += 1
    end
  end

  println(ans - cnt)
end

main()

Measured memory_bytes: 159656
#include <iostream>
#include <vector>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <regex>

using namespace std;

using ull = unsigned long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vull = vector<ull>;
using vpii = vector<pii>;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define rFOR(i,a,b) for(int i=(b);i>=(a);i--)
#define SORT(a) sort((a).begin(),(a).end());
#define rSORT(a) sort((a).rbegin(),(a).rend());
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;

//sankou
//vvi = vector<vector<int>>(20, vector<int>(10, 0));

//seiki
//#include <regex>
/*bubun*/
//regex_search("u32", regex("[0-9]"));      // true
/*kanzen*/
//regex_match("u32", regex("(i|u)\\d+"));   // true

int isP(int n) {
    if(n<=1) return 0;
    FOR(i,2,(int)sqrt(n)) {
        if(n%i==0) return 0;
    }
    return 1;
}

int main() {

    int a,b,c;
    cin >>a>>b;
    
    c=(b-a-1);
    
    cout <<(((c*(c+1))/2)-a);

    return 0;
}

Measured memory_bytes: 256
import itertools

N, M, Q = map(int, input().split())
abcd = [list(map(int, input().split())) for i in range(Q)]

nCr = list(itertools.combinations_with_replacement(range(1, M + 1), N))
ans = 0

for A in nCr:
    tmp = 0
    for a, b, c, d in abcd:
        if A[b - 1] - A[a - 1] == c:
            tmp += d
    ans = max(ans, tmp)

print(ans)


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

int gcd(vector<int> a) {
    int ans = a[0];
    for (int i = 1; i < a.size(); i++) {
        ans = __gcd(a[i], ans);
    }
    return ans;
}
int main() {
    int n; cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int ans = gcd(a);

    cout << ans << endl;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  string s;
  cin >> s;
  int n = s.size();
  i64 ans = (i64) n * (n - 1) / 2;
  map<char, int> ma;
  rep(i, n) ma[s[i]]++;
  each(m, ma) {
    i64 x = m.second;
    ans -= x * (x - 1) / 2;
  }
  cout << ans + 1 << '\n';
}


Measured memory_bytes: 720
#include<bits/stdc++.h>
	using namespace std;
	#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	#include <ext/pb_ds/assoc_container.hpp> 
	#include <ext/pb_ds/tree_policy.hpp> 
	using namespace __gnu_pbds; 
	#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
	
	#define all(a)      (a).begin(),(a).end()
	#define sz(x)       (int)x.size()
	
	#define ff first
	#define ss second
	#define mp make_pair
		 
	#define pb push_back
	#define endl "\n"
		 
	#define int long long 
	#define double long double
		 
	#define bp __builtin_popcountll
	#define inf 1e16
	
	const int N=1e5+5;
	const int M=1e6+6;
	const int MOD=1e9+7;
	void solve()
	{	
		int n,m;
		cin>>n>>m;
		int ans=(n*(n-1))/2;
		ans+=(m*(m-1))/2;
		cout<<ans<<endl;
	}

	signed main()  
	{
		FAST
		int t=1;
		//cin>>t;
		while(t--)
		{
			solve();
		}
	}
		


Measured memory_bytes: 256
import java.util.*;

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

        long health = Long.parseLong(scan.next());
        health = Recursive(health);
        System.out.println(health);
    }

    public static long Recursive(long health){
        if(health == 1){
            return health;
        }else{
            long returnNum = Recursive(health/2);
            return 2*returnNum + 1;
        }
    }
}

Measured memory_bytes: 21844
import sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,W = LI()
wv = [LI() for _ in range(N)]
V = N*10**3
dp = [[float('INF')]*(V+1) for _ in range(N+1)]
dp[0][0] = 0
for i in range(1,N+1):
    w,v = wv[i-1]
    for j in range(V+1):
        if j-v>=0:
            dp[i][j] = min(dp[i][j],dp[i-1][j-v]+w)
        dp[i][j] = min(dp[i][j],dp[i-1][j])
print(max([i for i in range(V+1) if dp[-1][i]<=W]))


Measured memory_bytes: 312040
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
int n, k;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll ans = 0;
    cin >> n >> k;
    /*if (k == 0)
    {
        cout << n * n << "\n";
        return 0;
    }*/
    for (int i = k + 1; i <= n; i++)
    {
        ll a;
        a = i - k;
        //ans += a;
        ll b = n / i;
        if (n % i >= k)
            ans += n % i - max(0, k - 1);
        ans += ll(a * b);
    }
    cout << ans << "\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    string s;
    cin>>s;
    cout<<s[0]<<s[1]<<s[2]<<endl;
}

Measured memory_bytes: 3612
#include<iostream>
#include<vector>
#include<set>
using namespace std;

#define MAX 100000

vector<int> G[MAX];
int N;
bool visited[MAX];
int prenum[MAX], parent[MAX], lowest[MAX], timer;

void dfs( int current, int prev ) {
  prenum[current] = lowest[current] = timer;
  timer++;

  visited[current] = true;

  int next;

  for ( int i = 0; i < G[current].size(); i++ ) {
    next = G[current][i];
    if ( !visited[next] ) {
      parent[next] = current;

      dfs( next, current );

      lowest[current] = min( lowest[current], lowest[next] );
    } else if ( next != prev ) {
      lowest[current] = min( lowest[current], prenum[next] );
    }
  }
}

void art_points() {
  for ( int i = 0; i < N; i++ ) visited[i] = false;
  timer = 1;
  dfs(0, -1);

  set<int> ap;
  int np = 0;
  for ( int i = 1; i < N; i++ ) {
    int p = parent[i];
    if ( p == 0 ) np++;
    else if ( prenum[p] <= lowest[i] ) ap.insert(p);
  }
  if ( np > 1 ) ap.insert(0);
  for ( set<int>::iterator it = ap.begin(); it != ap.end(); it++ )
    cout << *it << endl;
}

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

  for ( int i = 0; i < m; i++ ) {
    int s, t;
    cin >> s >> t;
    G[s].push_back(t);
    G[t].push_back(s);
  }
  art_points();

  return 0;
}


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


public class Main {

  class Pair implements Comparable<Pair> {
    int first;
    int second;

    public Pair(int first, int second) {
      this.first = first;
      this.second = second;
    }

    @Override
    public int compareTo(Pair o) {
      return first - o.first;
    }
  }

  void solve() throws IOException {
    int n = nextInt();
    int d = nextInt();
    int a = nextInt();
    Pair[] m = new Pair[n];
    for (int i = 0; i < n; i++) {
      m[i] = new Pair(nextInt(), nextInt());
    }
    Arrays.sort(m);
    PriorityQueue<Pair> toDecCount = new PriorityQueue<>();
    int x = 0;
    long ans = 0;
    long damage = 0;
    while (x < n) {
      int pos = m[x].first + d;
      while (!toDecCount.isEmpty() && m[x].first > toDecCount.peek().first) {
        damage -= toDecCount.poll().second;
      }
      m[x].second -= damage * a;
      if (m[x].second > 0) {
        int count = (m[x].second - 1) / a + 1;
        damage += count;
        m[x].second = 0;
        ans += count;
        toDecCount.add(new Pair(pos + d, count));
      }
      x++;
    }
    out.println(ans);
  }

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

  void run() throws IOException {
    reader = new BufferedReader(new InputStreamReader(System.in));
//		reader = new BufferedReader(new FileReader("input.txt"));
    tokenizer = null;
    out = new PrintWriter(new OutputStreamWriter(System.out));
//		out = new PrintWriter(new FileWriter("output.txt"));
    solve();
    reader.close();
    out.flush();

  }

  BufferedReader reader;
  StringTokenizer tokenizer;
  PrintWriter out;

  int nextInt() throws IOException {
    return Integer.parseInt(nextToken());
  }

  long nextLong() throws IOException {
    return Long.parseLong(nextToken());
  }

  double nextDouble() throws IOException {
    return Double.parseDouble(nextToken());
  }

  String nextToken() throws IOException {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine());
    }
    return tokenizer.nextToken();
  }
}


Measured memory_bytes: 62856
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

struct Solver {
	void solve() {
		int n;
		cin >> n;
		vector<int> a( n );
		for( int i = 0; i < n; ++i ) { cin >> a[i]; }

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

		vector<int> c;
		set_difference(
			a.begin(), a.end(),
			b.begin(),b.end(),
			back_inserter( c ) );

		for( int i = 0; i < (int)c.size(); ++i ) {
			cout << c[i] << '\n';
		}
	}
};

int main() {
	ios::sync_with_stdio( false );
	cout << fixed << setprecision( 10 );
	Solver().solve();
	return 0;
}



Measured memory_bytes: 5536
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n,sum=0;
	cin>>n;
	int p=n;
	while(n>0){
		sum+=n%10;
		n=n/10;
	}
	if(p%sum==0)
	  cout<<"Yes"<<endl;
	else
	  cout<<"No"<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
//絶対値
long long int change_plus(long long int a) {
	if (a < 0) { return -a; }
	if (a >= 0) { return a; }
}
//大小比較(大)
long long int big(long long int a, long long int b) {
	if (a >= b) {
		return a;
	}
	else {
		return b;
	}
}

//大小比較(小)
long long int small(long long int a, long long int b) {
	if (a >= b) {
		return b;
	}
	else {
		return a;
	}
}

int main() {
	long long int n,s,t,w, m, k,p,q,r=0;
	char str[60],str2[60],str3[15];
	int num[1200];
	scanf("%s", str);
	if (str[0] == '1') { r++; }

	if (str[1] == '1') { r++; }
	if (str[2] == '1') { r++; }
	if (str[3] == '1') { r++; }
	if (str[4] == '1') { r++; }
	if (str[5] == '1') { r++; }
	printf("%lld", r);
}

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

int main(){
    int H,W;
    cin >>H>>W;
    char map[W][H];

    queue<int> que;
    int dist[W][H];
    fill(dist[0],dist[W],-1);


    for(int y=0;y<H;y++){
        for(int x=0;x<W;x++){
            cin >> map[x][y];
            if(map[x][y]=='#'){
                que.push(x+y*W);
                dist[x][y]=0;
            }
        }
    }

    int dx[4]={1,0,-1,0};
    int dy[4]={0,1,0,-1};

    while(!que.empty()){
        int x=que.front()%W;
        int y=que.front()/W;
        que.pop();
        for(int i=0;i<4;i++){
            if(((x+dx[i])>=W)||((x+dx[i])<0)){
                continue;
            }
            if(((y+dy[i])>=H)||((y+dy[i])<0)){
                continue;
            }

            if((map[x+dx[i]][y+dy[i]]=='.')&&(dist[x+dx[i]][y+dy[i]]==-1)){
                dist[x+dx[i]][y+dy[i]]=dist[x][y]+1;
                que.push(x+dx[i]+W*(y+dy[i]));
            }

        }
    }
    int max=0;
    for(int y=0;y<H;y++){
        for(int x=0;x<W;x++){
            if(max<dist[x][y]){
                max=dist[x][y];
            }
        }
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 9216
#include<bits/stdc++.h>
#define show(x) cout<<#x" = "<<x<<endl;
#define INF 0x3f3f3f3f
using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<unsigned,unsigned> uupair;
typedef pair<int,int> iipair;
typedef vector<int> vec;
typedef vector<ll> llvec;
typedef vector<unsigned> uvec;
typedef vector<ull> ullvec;
typedef vector<uvec> grid;
typedef vector<vec> igrid;
typedef vector<string> svec;
typedef vector<bool> bvec;
typedef vector<bvec> bgrid;
typedef vector<char> cvec;
typedef vector<uupair> uupvec;
typedef vector<iipair> iipvec;
typedef unordered_map<unsigned,unsigned> uuhmap;
typedef unordered_map<ll,ll> llllhmap;
typedef map<unsigned,unsigned> uumap;
typedef map<int ,unsigned> iumap;
typedef map<int,int> iimap;
typedef unordered_map<int ,unsigned> iuhmap;
typedef unordered_map<int,int> iihmap;
typedef unordered_map<unsigned,uvec> uuvechmap;
typedef unordered_map<ull,ull> ullullhmap;
typedef map<char,cvec> ccvecmap;
typedef unordered_set<unsigned> uhset;
typedef set<unsigned> uset;

// ll dp[101][100001];

struct item
{
    unsigned wt,val;
};

const unsigned LIMIT=1e5;

int main()
{
    // memset(dp,0,sizeof dp);
    vector<item> items;
    unsigned n;
    unsigned W;
    cin>>n>>W;
    items.resize(n);
    for(unsigned i=0;i<n;++i)
    {
        cin>>items[i].wt>>items[i].val;
    }
    uvec dp(LIMIT+1,INF),ndp(LIMIT+1);
    // show(dp[1]);
    dp[0]=ndp[0]=0;
    for(unsigned i=0;i<n;++i)
    {
        for(unsigned j=1;j<=LIMIT;++j)
        {
            ndp[j]=dp[j];
            if(j >= items[i].val) ndp[j]=min(dp[j],dp[j-items[i].val]+items[i].wt);
        }
        dp=ndp;
    }
    unsigned result=0;
    for(unsigned j=LIMIT;j>0;--j)
    {
        if(dp[j]<=W) 
        {
            result=j;
            break;
        }
    }
    cout<<result;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
#include <set>

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}


signed main(void) {
	string s, t;
	cin >> s >> t;
	int ans = 0;
	rep(i, s.size()) {
		if (s[i] != t[i])ans++;
	}
	print(ans);
}

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

int main(){
    int a,b,c,x,y;
    cin>>a>>b>>c>>x>>y;
    
    int min=INT_MAX;

    rep(i,200000){
        int z=i*c+a*max(0,x-(i/2))+b*max(0,y-(i/2));
        if(z<min)min=z;
    }
    
    cout<<min;
    return 0;
    }


Measured memory_bytes: 3612
#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <stdio.h>
using namespace std;

int main() {
    string s;
    cin >> s;
    int my_min = 1000000;
    int ans;
    //int a[10]; 
    for(int i = 0; i < s.size() - 2; i++) {
        string tmp_s;
        for (int j = 0; j< 3; j++) {
            tmp_s += s[i+j];
        }

        if (abs(stoi(tmp_s) - 753) < my_min) {
           my_min = abs(stoi(tmp_s) - 753);  
           ans = my_min;
       }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 760
#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>;
const int MAX = 100;
const int INF = 1e9;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
#define PI 3.14159265358979323846264338327950L

int main() {
	string s;

	cin >> s;
	if (s[2] == s[3] && s[4] == s[5]) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}

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

int main(){
    int n,m;
    cin>>n>>m;
    bool a1[n+1]={};
    bool an[n+1]={};
    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        if(x==1)a1[y]=true;
        if(y==n)an[x]=true;
        }
    bool flag=false;
    for(int i=0;i<n;i++){
        if(a1[i]&&an[i]){
            flag=true;
            break;
        }
    }
    if(flag) cout<<"POSSIBLE"<<endl;
    else cout<<"IMPOSSIBLE"<<endl;
    return 0;
}

Measured memory_bytes: 4028
#include<bits/stdc++.h>
//#pragma GCC optimize("O3")
//#pragma GCC target ("sse4")
using namespace std;
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define MEM(x,a) memset((x),a,sizeof((x)))
#define F first
#define S second
#define L (idx*2)
#define R ((idx*2)+1)
#define imx INT_MAX
const long long MOD = (long long)(1e9+7);
const long long MMX = (long long)(1e18);
typedef long long LL;
typedef pair<int,int> pii;
int n,x[200005],ap,bp,ss,ee;
pii seq[800005][2];
priority_queue<pair<int,pair<pii,pii> > >pq;
void up(int st,int ed,int idx,int pos,int val)
{
    int mid=(st+ed)/2;
    if(st>pos||ed<pos)return;
    if(st==ed)
    {
        seq[idx][pos%2]={val,pos};
        return;
    }
    up(st,mid,L,pos,val);
    up(mid+1,ed,R,pos,val);
    if(seq[L][0].F>seq[R][0].F)
    {
        seq[idx][0]=seq[R][0];
    }
    else
    {
        seq[idx][0]=seq[L][0];
    }
    if(seq[L][1].F>seq[R][1].F)
    {
        seq[idx][1]=seq[R][1];
    }
    else
    {
        seq[idx][1]=seq[L][1];
    }
    return;
}
pii mx(int st,int ed,int idx,int l,int r,int tp)
{
    int mid=(st+ed)/2;
    if(st>r||ed<l)return {imx,imx};
    if(l<=st&&r>=ed)return seq[idx][tp];
    pii a,b;
    a=mx(st,mid,L,l,r,tp);
    b=mx(mid+1,ed,R,l,r,tp);
    if(a.F>b.F)
    {
        return b;
    }
    else
    {
        return a;
    }
}
void pq_push(int st,int ed)
{
    //printf("%d %d\n",st,ed);
    if(ed-st+1<2)return;
    //printf("%d %d\n",st,ed);
    pii a=mx(1,n,1,st,ed,st%2);
    pii b=mx(1,n,1,a.S+1,ed,(st+1)%2);
    pq.push({-a.F,{{st,ed},{a.S,b.S}}});
    return;
}
int main()
{
    for(int i=0;i<800005;i++)seq[i][0]={imx,imx},seq[i][1]={imx,imx};
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&x[i]);
        up(1,n,1,i,x[i]);
    }
    pq_push(1,n);
    while(!pq.empty())
    {
        ap=pq.top().S.S.F;
        bp=pq.top().S.S.S;
        ss=pq.top().S.F.F;
        ee=pq.top().S.F.S;
        pq.pop();
        printf("%d %d ",x[ap],x[bp]);
        pq_push(ss,ap-1);
        pq_push(ap+1,bp-1);
        pq_push(bp+1,ee);
    }
}


Measured memory_bytes: 18012
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <string>
#include <math.h>
#include <map>
#include <numeric>
#include <stack>
#include <queue>
#include <functional>
#include <stdio.h>
#define ll long long
#define pl pair<ll,ll>
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vvvl vector<vector<vector<ll> > >
#define vd vector<double>
#define vvd vector<vector<double> >
#define vvvd vector<vector<vector<double> > >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define vvvb vector<vector<vector<bool> > >
#define rep(i,a) for(ll i = 0;i<a;++i)
#define rep1(i,a) for(ll i = 1;i<a;++i)
#define rrep(i,a) for(ll i = a;i>=0;--i)
#define mod 1000000007
#define inf 10010010010
using namespace std;

int main(){
	ll a, b; cin >> a >> b;
	rep1(i, 10000001){
		if ((i * 8) / 100 == a && i / 10 == b){
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 256
#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<iostream>
#include<algorithm>//next_permutation
#include<complex>
#include<math.h>
#include<sstream>
#include<stdio.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define rep2(i, j, n) for (int i = j; i < (int)(n); i++)
using ll = long long int;
int main() {
	string t, s;
	cin >> t >> s;
	t += s.at(s.size() - 1);
	if (s == t) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
}


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

int main(){
  int A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z;
  cin >> A;
  
  cout << A*A << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
main(){
  int a,b,c,tmp;
  scanf("%d %d %d",&a,&b,&c);
  if(a>b){
    tmp=a;
    a=b;
    b=tmp;
  }
  if(b>c){
    tmp=b;
    b=c;
    c=tmp;
  }
  if(a>b){
    tmp=a;
    a=b;
    b=tmp;
  }
  printf("%d %d %d\n",a,b,c);
  return 0;
}


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

class Combination {
public:
    Combination(int64_t max_num, int64_t mod) {
        fact_.resize(max_num + 1, 1);
        inv_fact_.resize(max_num + 1, 1);
        mod_ = mod;
        for (int64_t i = 2; i <= max_num; i++) {
            fact_[i] = i * fact_[i - 1] % mod_;
            inv_fact_[i] = MODpow(fact_[i], mod_ - 2);
            assert(fact_[i] * inv_fact_[i] % mod_ == 1);
        }
    }
    int64_t operator()(int64_t n, int64_t m) const {
        if (m < 0 || m > n) return 0;
        return fact_[n] * inv_fact_[n - m] % mod_ * inv_fact_[m] % mod_;
    }

    int64_t fact(int64_t i) {
        return fact_[i];
    }
private:
    int64_t MODpow(int64_t n, int64_t m) const {
        int64_t result = 1;
        while (m) {
            if (m % 2 == 1) {
                result *= n;
                result %= mod_;
            }

            m /= 2;
            n *= n;
            n %= mod_;
        }

        return result;
    }

    vector<int64_t> fact_, inv_fact_;
    int64_t mod_;
};

int main() {
    int64_t N;
    cin >> N;
    vector<int64_t> x(N);
    for (int64_t i = 0; i < N; i++) {
        cin >> x[i];
    }

    constexpr int64_t MOD = 1e9 + 7;

    vector<int64_t> sum(N + 1, 0);
    for (int64_t i = 0; i < N; i++) {
        (sum[i + 1] = sum[i] + x[i]) %= MOD;
    }

    Combination comb(N, MOD);

    int64_t ans = 0;
    for (int64_t i = 1; i < N; i++) {
        //インデックスの差がi個のところへ到達するような移動の仕方の和
        int64_t f = comb(N - 1, i + 1) * comb.fact(i - 1) % MOD * comb.fact(N - i - 2) % MOD;

        int64_t num = ((sum[N - 1] - sum[N - 1 - i] + MOD) % MOD - sum[i] + MOD) % MOD;

        (ans += f * num) %= MOD;
        (ans += (x[N - 1] - x[N - 1 - i]) * comb(N - 1, i) % MOD * comb.fact(N - 1 - i) % MOD * comb.fact(i - 1)) %= MOD;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3328
# Digits Sum
import sys
import math
N = int(input())

def getValue(wk) :
    ret = 0
    while wk > 0 :
        ret = ret + wk % 10
        wk = wk // 10
    return ret

def getAns(n) :
    minV = 999999
    B = n
    l = math.log10(n)
    if int(l) == l :
        return 10
    for A in range(1, n + 1) :
        B = B - 1
        if A + B == n :
            waA = getValue(A)
            waB = getValue(B)
            if minV > waA + waB :
                minV = waA + waB
    return minV

print(getAns(N))

Measured memory_bytes: 3064
#include <cstdio>
#include <algorithm>
const int N = 2e5 + 10;
typedef long long ll;
typedef std::pair<ll, int> pa;
int n, a[N], k;
ll f[N], g[N], ans;
void solve(int l, int r) {
	if (l == r) {
		ans += a[l] >= 0;
		return;
	}
	int mid = (l + r) >> 1;
	solve(l, mid), solve(mid + 1, r);
	f[mid] = -a[mid];
	for (int i = mid - 1; i >= l; i--) f[i] = f[i + 1] - a[i];
	std::sort(f + l, f + mid + 1);
	g[mid] = 0;
	for (int i = mid + 1; i <= r; i++) {
		g[i] = g[i - 1] + a[i];
		ans += std::upper_bound(f + l, f + mid + 1, g[i]) - (f + l);
	}
}
int main() {
//	freopen("input", "r", stdin);
	scanf("%d%d", &n, &k);
	for (int i = 1; i <= n; i++) scanf("%d", a + i), a[i] -= k;
	solve(1, n);
	printf("%lld\n", ans);
}

Measured memory_bytes: 4096
#include <iostream>
using namespace std;
int pos[305][305]={0};
int ans[305][305]={0};
int num[305]={0};
int same[305]={0};
bool b=0;int top=0;
int main(){
  int h,w,k;
  cin>>h>>w>>k;
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      char c;
      cin>>c;
      if(c=='#'){
        pos[i][j]=1;num[i]++;
        if(!b){
          b=1;
          top=i;
        }
      }
    }
  }
  int z=1;
  for(int i=1;i<=h;i++){
    if(num[i]!=0){
      int t=0;
      for(int j=1;j<=w;j++){
        if(pos[i][j]!=0&&t==0){
          t++;
        }
        else if(pos[i][j]!=0){
          z++;
          t++;
        }
        ans[i][j]=z;
      }
      z++;
    }
  }
  int p=top;
  for(int i=1;i<=h;i++){
    if(i<=top)num[i]=top;
    else if(num[i]==0)num[i]=p;
    else {
      p=i;
      num[i]=p;
    }
  }
  //cout<<num[1]<<num[2]<<num[3]<<endl;
  for(int i=1;i<=h;i++){
    if(num[i]!=i){
      for(int j=1;j<=w;j++){
        ans[i][j]=ans[num[i]][j];
      }
    }
  }
  for(int i=1;i<=h;i++){

    for(int j=1;j<=w;j++){
        cout<<ans[i][j]<<" ";
    }
    cout<<endl;
  }
}

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

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

    bool ok = false;
    if (s.at(2) == s.at(3) && s.at(4) == s.at(5)) {
        ok = true;
    }

    if (ok) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(void){
    int n,m,k; cin>>n>>m>>k;
    ll ans = 0, ans2=0;
    COMinit();
    for(int i=1;i<n;i++){
        ll tmp=0;
        ll pattern = (n-i)*m*m;
        tmp += pattern * i;
        tmp %= MOD;
        tmp *= COM(n*m-2, k-2);
        tmp %= MOD;
        ans+=tmp; ans%=MOD;
    }
    //ans *= COM(n*m-2, k-2);
    //cout<<ans%MOD<<endl;
    ans %= MOD;
    for(int i=0;i<m;i++){
        ll pattern = (m-i)*n*n;
        ll tmp=0;
        tmp += pattern * i;
        tmp%= MOD;
        tmp *= COM(n*m-2, k-2);
        tmp%= MOD;
        ans2+=tmp; ans2%= MOD;
    }
    ans2%= MOD;
    //ans *= COM(n*m-2, k-2);
    cout<<(ans+ans2) %MOD<<endl;
}


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

using namespace std;

struct Panel {
    string name;
    int x1, y1, x2, y2;
    vector<Panel> child;
    
    Panel(){}    
    Panel(string name, int x1, int y1, int x2, int y2) :
        name(name), x1(x1), y1(y1), x2(x2), y2(y2) {}
};

string s;
int idx;

string get_name()
{
    string name;
    ++idx;
    while (s[idx] != '>') {
        name += s[idx];
        ++idx;
    }
    ++idx;
    return name;
}

int s2i(string &str)
{
    stringstream ss(str);
    int num;
    ss >> num;
    return num;
}

int get_val()
{
    string val;
    while (isdigit(s[idx])) {
        val += s[idx];
        ++idx;
    }
    return s2i(val);
}

void parse(Panel &p)
{
    while (s[idx] == '<' && s[idx+1] != '/') {
        string name = get_name();
        int x1 = get_val(); ++idx;
        int y1 = get_val(); ++idx;
        int x2 = get_val(); ++idx;
        int y2 = get_val();
        Panel panel(name, x1, y1, x2, y2);
        parse(panel);
        p.child.push_back(panel);
        while (s[idx] != '>') {
            idx++;
        }
        idx++;
    }    
}

bool get_panel(int x, int y, const Panel &p)
{
    for (int i = 0; i < (int)p.child.size(); i++) {
        Panel np = p.child[i];
        if (np.x1 <= x && x <= np.x2 && np.y1 <= y && y <= np.y2) {
            if (!get_panel(x, y, np)) {
                cout << np.name << " " << np.child.size() << endl;
            }
            return 1;
        }
    }
    return 0;
}

int main()
{
    int n, x, y;
    while (cin >> n >> s, n) {
        Panel p;
        p.name = "#"; p.x1 = p.y1 = -1; p.x2 = p.y2 = 10001;
        idx = 0;
        parse(p);
        for (int i = 0; i < n; i++) {
            cin >> x >> y;
            if (!get_panel(x, y, p)) {
                cout << "OUT OF MAIN PANEL 1" << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1256
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  int r;
  cin >> r;
  cout << 3 * r * r;


  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
 
int main() {
int N;
  int K;
  string S;
  cin >> N>> K>> S;
  
  char c;
  c= S.at(K-1)+0x20;
if (K==1) {
  string s1;
  for(int i=1; i<N;i++) {
s1 += S.at(i);
 
  }
  cout << c << s1 << endl;
}
  else {
    string s2;
    string s3;
    for (int i=0; i<K-1; i++) {
   s2 +=S.at(i);
    }
    for (int i=K;i<N;i++) {
      s3 +=S.at(i);
    }
    cout << s2 << c <<s3 << endl;
  }
      
    
  
  
  
  
  
              }

Measured memory_bytes: 256
using System;
namespace csharptest
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] h = new int[100000];
            int[] w = new int[100000];
            int count;
            string[] str = Console.ReadLine().Split(' ');
            for (count = 0; str[0] != "0" && str[1] != "0"; count++)
            {
                h[count] = int.Parse(str[0]);
                w[count] = int.Parse(str[1]);
                str = Console.ReadLine().Split(' ');
            }
            for (int n = 0; n < count; n++)
            {
                for (int W = 0; W < w[n]; W++)
                {
                    Console.Write("#");
                }
                Console.WriteLine();
                for (int H = 1; H < h[n] - 1; H++)
                {
                    Console.Write("#");
                    for (int W = 1; W < w[n] - 1; W++)
                    {
                        Console.Write(".");
                    }
                    Console.Write("#");
                    Console.WriteLine();
                }
                for (int W = 0; W < w[n]; W++)
                {
                    Console.Write("#");
                }
                Console.WriteLine();
                Console.WriteLine();
            }
        }
    }
}

Measured memory_bytes: 6104
#!/usr/bin/env python3
def main():
    S = input()

    lst = set(['A', 'C', 'G', 'T'])
    cnt = 0
    ans = 0
    for s in S:
        if s in lst:
            cnt += 1
        else:
            ans = max(ans, cnt)
            cnt = 0
    ans = max(ans, cnt)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9056
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
typedef long long ll;
#define  rep(i,a,b)for(long long i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
const ll INF=1000000000000LL;
const ll r197=1000000007;
typedef pair<ll,ll>P;
typedef pair<P,P>Pa;
bool Inframe(int a,int b,int c,int d,int h,int w){
	if(a+b>=0&&a+b<h&&c+d>=0&&c+d<w)return true;
	return false;
}
vector<int> v[100005];
ll dp[530005]={};
ll h[200005];
ll a[200005];
int n;
int m=1;
void update(int k,ll a){
	k+=m-1;
	dp[k]=a;
	while(k>0){
		k=(k-1)/2;
		dp[k]=max(dp[k*2+1],dp[k*2+2]);
	}
}
ll query(int a,int b,int k,int l,int r){
	if(b<=l||r<=a)return 0;
	if(a<=l&&r<=b)return dp[k];
	else{
		ll vl=query(a,b,k*2+1,l,(l+r)/2);
		ll vr=query(a,b,k*2+2,(l+r)/2,r);
		return max(vl,vr);
	}
}

int main() {
	cin>>n;
	rep(i,0,n){
		cin>>h[i];
		h[i]--;
	}
	rep(i,0,n)cin>>a[i];
	while(m<n)m*=2;
	rep(i,0,n){
		update(h[i],query(0,h[i],0,0,m)+a[i]);
//		rep(i,0,2*n-1){
//			cout<<dp[i]<<endl;
//		}
//		cout<<endl;
	}
	cout<<dp[0]<<endl;
	return 0;
}


Measured memory_bytes: 9856
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a[10],n,b[10];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
    b[i]=a[i];
  }
  if(prev_permutation(a,a+n)==false) 1;
  else{
    for(int i=0;i<n;i++){
      if(i!=0) cout<<" ";
      cout<<a[i];
    }
    cout<<endl;
  }
  for(int i=0;i<n;i++){
    if(i!=0) cout<<" ";
    cout<<b[i];
  }
  cout<<endl;
  if(next_permutation(b,b+n)==true){
    for(int i=0;i<n;i++){
      if(i!=0) cout<<" ";
      cout<<b[i];
    }
    cout<<endl;
  }
  return 0;
}


Measured memory_bytes: 3052