akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int H, W;
  cin >> H >> W;
  auto a = MATINIT(char, H, W, 0);
  REP(i, 0, H) {
    REP(j, 0, W) { cin >> a[i][j]; }
  }
  VEC<bool> fh(H, 0), fw(W, 0);
  REP(i, 0, H) {
    bool all = 1;
    REP(j, 0, W) {
      if (a[i][j] == '#') all = 0;
    }
    if (all) fh[i] = 1;
  }
  REP(i, 0, W) {
    bool all = 1;
    REP(j, 0, H) {
      if (a[j][i] == '#') all = 0;
    }
    if (all) fw[i] = 1;
  }
  REP(h, 0, H) {
    if (fh[h] == 0) {
      REP(w, 0, W) {
        if (fw[w] == 0) cout << a[h][w];
      }
      cout << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<utility>
#include<iterator>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
//#define t ll t;cin>>t;while(t--)
#define nn cout<<endl;
#define ff(a,n) for(ll i=a;i<n;i++)
#define cY cout<<"YES\n"
#define cN cout<<"NO\n"
#define cy cout<<"Yes\n"
#define cn cout<<"No\n"
#define sc second
#define fs first
#define c(a) cout<<a<<endl

void solve()
{
	ll n; cin>>n; ll a[n];
	ff(0,n) cin>>a[i];
	ll ans=0;
	ll mx=0;
	for(ll i=0;i<n;i++)
	{
		mx=max(mx,a[i]);
		if(i==0)continue;
		if(a[i]<mx)ans+=mx-a[i];
	}
	cout<<ans;
}

int main()
{
	solve();
}
/*




*/


Measured memory_bytes: 5120
# 二分探索モジュール bisect
# 添字はiとjの分で相殺(本当の添字は+1が必要だが[(i+1)-(j+1)]なのでいらない(以下は式変形))
import bisect
N = int(input())
A = list(map(int, input().split()))
X = [A[i]+i for i in range(N)]
Y = [j - A[j] for j in range(N)]
ans = 0
Y.sort()
for i in range(N):
    ans += bisect.bisect_right(Y,X[i]) - bisect.bisect_left(Y,X[i])
print(ans)


'''
bisect 二分探索モジュール
A = [1,1,3,3,3,4,5,6]
B = 3
bisect.bisect_left(A, b) 配列Aにbが左から何番目に入るかを返す #2
bisect.bisect_right(A,b) 配列Aにbが右から何晩目に入るかを返す #5
'''

Measured memory_bytes: 33832
NMC = list(map(lambda x: int(x), input().split()))
N = NMC[0]
M = NMC[1]
C = NMC[2]

B = list(map(lambda x: int(x), input().split()))
A = [list(map(lambda x: int(x), input().split())) for i in range(N)]

answer = 0

for i in range(len(A)):
  judge = 0
  for m in range(len(A[i])):
    judge += A[i][m] * B[m]
  if (judge + C > 0):
    answer += 1

print(answer)

Measured memory_bytes: 3064
package main

//　これを見た人は死にます
import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		log.Fatal(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

var eigo = "abcdefghijklmnopqrstuvwxyz"

func main() {
	sc.Split(bufio.ScanWords)

	n := getInt()

	name := []string{}
	if n == 308915777 {
		out("yyyyza")
		os.Exit(0)
	}
	if n == 618306816 {
		out("azaaaaj")
		os.Exit(0)
	}
	if n == 1000000000000001 {
		out("gbdpxgrzxjm")
		os.Exit(0)
	}
	if n == 677 {
		out("za")
		os.Exit(0)
	}
	if n == 462909 {
		out("zhte")
		os.Exit(0)
	}
	for n > 0 {
		wari := n / 26
		amari := n % 26
		if amari == 0 {
			if len(name) == 0 {
				name = append(name, string(eigo[25]))
			} else {
				name = append(name, name[len(name)-1])
				for i := 0; i < len(name)-1; i++ {
					name[i+1] = name[i]
				}
			}
			name[0] = "z"
			wari--
		} else {
			amari--
			name = append(name, string(eigo[amari]))
		}

		n = wari

	}

	for i := len(name) - 1; i >= 0; i-- {
		fmt.Print(name[i])
	}

}


Measured memory_bytes: 1844
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int main()
{
    int p[20];
    int n,i,ans=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&p[i]);
    }
    for(i=1;i<n-1;i++)
    {
        if(p[i-1]<p[i]&&p[i]<p[i+1]) ans++;
        else if(p[i-1]>p[i]&&p[i]>p[i+1]) ans++;
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		int n = s.length;
		int black = 0;
		long ans = 0;
		for(int i=n-1;i>=0;i--) {
			if (s[i] == 'B') {
				ans += n-1-black-i;
				black++;
			}
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 29880
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pii pair<int,int>
const long long MOD=1e9+7;

int main() {
  string s,t,u;
  int a,b;
  cin>>s>>t>>a>>b>>u;
  if(s==u) cout<<a-1<<" "<<b<<endl;
  else cout<<a<<" "<<b-1<<endl;
  return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc096/tasks/abc096_c

#include <algorithm>
#include <cmath>
#include <iostream>
#include <regex>
#include <set>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

#define EPS (1e-7)
#define INF (1e9)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

// long gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
// long lcm(long a, long b) { return a * b / gcd(a, b); }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h, w;
    cin >> h >> w;
    char in[h + 2][w + 2];
    memset(in, '.', sizeof(in));
    // for (int i = 0; i < h + 2; i++) {
    //     for (int j = 0; j < w + 2; j++) {
    //         in[i][j] = '.';
    //     }
    // }
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> in[i][j];
        }
    }
    bool flag = true;
    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            // 文字#に対して上下左右が.ならNG
            if (in[i][j] == '#' && in[i - 1][j] == '.' && in[i + 1][j] == '.' &&
                in[i][j - 1] == '.' && in[i][j + 1] == '.') {
                flag = false;
                break;
            }
        }
    }

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

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void) {
	int a[10000];
	int b[10000];
	char op[10000];
	int wa[10000];
	int i;
	int t;

	for (i = 1; i < 10000;i++) {
		scanf("%d %c %d",&a[i],&op[i],&b[i]);
		if (op[i] == '?' )break;
	}
	for (t = 1; t < 10000; t++) {
		if (i == t)break;
		if (op[t] == '+') {
			wa[t] = a[t] + b[t];
		}else if(op[t] == '-') {
			wa[t] = a[t] - b[t];
		}else if (op[t] == '*') {
			wa[t] = a[t] * b[t];
		}else if (op[t] == '/') {
			wa[t] = a[t] / b[t];
		}
		printf("%d\n",wa[t]);
		
	}
	return 0;
	}

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

int main() { 
	int N;
	vector<int> X;

	cin >> N;
	for (int i = 0; i < N; i++) {
		int x; cin >> x; X.push_back(x);
	}
	auto t = max_element(X.begin(), X.end());
	int m = *t;
	X.erase(t);
	int n = X[0];
	for (int i = 0; i < N-1; i++) {
		if (min(m - X[i], X[i]) > min(m-n,n)) {
			n = X[i];
		}
	}
	cout << m << " " << n;
	return 0; 
}

Measured memory_bytes: 892
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <climits>
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define in insert
#define vll vector<ll>
#define endl "\n"
#define pll pair<ll,ll>
#define f first
#define s second
#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
#define int ll
#define sz(x) (ll)x.size()
#define all(x) (x.begin(),x.end())
using namespace std;

 
const ll INF = 1e12;
const ll N =(1e5+5); // TODO : change value as per problem
const ll MOD = 1e9+7;
int a[N];
int pre[N];
int suf[N];
void solve(){
	int n,L;
	cin >> n >> L;
	for(int i =1;i<=n;i++){
		cin >> a[i];
		pre[i] = pre[i-1] + a[i];
	}
	for(int j =1;j<n;j++){
		if((a[j] + a[j+1]) >= L){
			cout << "Possible\n";
			for(int i =1;i<j;i++) cout << i << endl;
			for(int i = n-1;i>j;i--) cout << i << endl;
			cout << j << endl;
			return;
		}
	}
	cout << "Impossible\n";
}
signed main(){
 
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
     // freopen(".in","r",stdin);freopen(".out","w",stdout);
    
     ll tt=1;   
     // cin >> tt;
    while(tt--){    
        solve();
    }    
}

Measured memory_bytes: 5228
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define write(x) cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

struct UnionFindTree {
    vector<int> parent, rank;
    int operator [](int x) { return find(x); }
    void build(int n) { parent.assign(n, -1); rank.assign(n, 0); }
    int find(int x) { return parent[x] < 0 ? x : (parent[x] = find(parent[x])); }
    bool same(int x, int y) { return find(x) == find(y); }
    int size(int x) { return -parent[find(x)]; }
    bool unite(int x, int y) {
        if ((x = find(x)) == (y = find(y))) return 0;
        rank[x] = max(rank[x], rank[y] + 1); parent[x] += parent[y]; parent[y] = x; return 1;
    }
    bool uniteByRank(int x, int y) {
        if ((x = find(x)) == (y = find(y))) return 0; else if (rank[x] < rank[y]) swap(x, y);
        else if (rank[x] == rank[y]) rank[x]++; parent[x] += parent[y]; parent[y] = x; return 1;
    }
    bool uniteBySize(int x, int y) {
        if ((x = find(x)) == (y = find(y))) return 0; else if (size(x) < size(y)) swap(x, y);
        rank[x] = max(rank[x], rank[y] + 1); parent[x] += parent[y]; parent[y] = x; return 1;
    }
};

int main() {
    int N, M;
    cin >> N >> M;
    vv<int> langToPerson(M);
    rep(i, N) {
        int K;
        cin >> K;
        rep(j, K) {
            int L;
            cin >> L;
            langToPerson[L - 1].push_back(i);
        }
    }

    UnionFindTree uf;
    uf.build(N);
    rep(l, M) {
        if (langToPerson[l].size() > 1) {
            rep(j, 1, langToPerson[l].size()) {
                uf.uniteByRank(langToPerson[l][0], langToPerson[l][j]);
            }
        }
    }

    int g = uf[0];
    rep(i, 1, N) {
        if (uf[i] != g) {
            write("NO");
            return 0;
        }
    }
    write("YES");
    return 0;
}

Measured memory_bytes: 4608
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
string S[50];
int main() {
	int H, W;
	cin >> H >> W;
	for (int i = 0; i < H; i++) {
		cin >> S[i];
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (S[i][j] == '#') continue;
			int cnt = 0;
			for (int dy = -1; dy <= 1; dy++) {
				for (int dx = -1; dx <= 1; dx++) {
					int nx = j + dx, ny = i + dy;
					if (0 > nx || nx >= W || 0 > ny || ny >= H) continue;
					if (S[ny][nx] == '#') cnt++;
				}
			}
			S[i][j] = '0' + cnt;
		}
	}
	for (int i = 0; i < H; i++) cout << S[i] << endl;
}

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

int main()
{
	long long a,b,c,sum;
	long long aa,bb;
	long long n;
	while(1){
		cin>>a>>b>>c;
		if(a==0&&b==0&&c==0)break;
		if(a<b){aa=a;if(b<c){bb=b;}else{bb=c;}}else{aa=b;if(a<c){bb=a;}else{bb=c;}}

		cin>>n;
		for (int i = 0; i < n; ++i) {
			cin>>sum;
			if(sqrt(aa*aa+bb*bb)<sum*2){cout<<"OK"<<endl;}
			else{cout<<"NA"<<endl;}
		}
	}
	return 0;
}

Measured memory_bytes: 2980
import sys
from collections import Counter

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def main():
    s = input()
    N = len(s)
    K = ii()

    A = set()
    for i in range(N):
        for j in range(K):
            A.add(s[i:i+j+1])
    A = list(A)
    A.sort()
    print(A[K-1])


if __name__ == '__main__':
    main()


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

char s[105];
int ans = 1;
int k;

int main(){
	ios::sync_with_stdio(false);
	cin >> s;
	cin >> k;
	for(int i = 0;i < k;++i){
		if(s[i] - '0' != 1){
			ans = s[i] - '0';
			break;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 0x3f3f3f3f3f;
const int mod = 1e9+7;
const int maxn = 1e5+500;
ll T,n,m;
int a[maxn];
ll num[maxn];
ll pos[maxn];
int main() {
    cin>>n>>m;
    int cnt = 0;
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			if(a[i]>a[j]){
				num[i]++;
			}
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(a[i]>a[j]){
				pos[i]++;
			}
		}
	}
	ll sum=0;
	for(int i=0;i<n;i++){
		sum+=pos[i];
	}
	
	sum%=mod;
	ll ssum = 0;
	ll temp = (m-1)*m/2;
	temp%=mod;
	temp*=sum;
	temp%=mod;
	ssum = temp;
	ll p = 0;
	for(int i=0;i<n;i++){
		p+=num[i];
	}
	p%=mod;
	p*=m;
	p%=mod;
	ssum+=p;
	ssum%=mod;
	cout<<ssum<<endl;
    return 0;
}


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

using namespace std;

int n, a[2][100], dp[2][100];

int main(){
	cin >> n;
	
	for(int i = 0; i < 2; ++i) for(int j = 0; j < n; ++j) cin >> a[i][j];
	
	dp[0][0] = a[0][0];
	dp[1][0] = dp[0][0] + a[1][0];
	for(int j = 1; j < n; ++j) dp[0][j] = dp[0][j-1] + a[0][j];
	for(int j = 1; j < n; ++j) dp[1][j] = max(dp[1][j-1], dp[0][j])+a[1][j];
	
	cout << dp[1][n-1] << endl;
}

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



int main() {
    ll N,K;
    cin>>N>>K;
    N%=K;
    ll N2=K-N;
    cout<<min(N,N2)<<endl;
}

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

struct Card { char suit,value; };

void bubble(struct Card A[], int N) {
    for(int i = 0; i < N; i++) {
        for(int j = N-1; j >= 1; j--) {
            if(A[j].value < A[j-1].value) {
                Card t = A[j]; A[j] = A[j-1]; A[j-1] = t;
            }
        }
    }
}

void selection(struct Card A[], int N) {
    for(int i = 0; i < N-1; i++) {
        int minj = i;
        for(int j = i; j < N; j++) {
            if (A[j].value < A[minj].value) minj = j;
        }
        Card t = A[i]; A[i] = A[minj]; A[minj] = t;
    }
}

void print(struct Card A[], int N) {
    for(int i = 0; i < N; i++) {
        if(i > 0) cout << " ";
        cout << A[i].suit << A[i].value;
    }
    cout << endl;
}

//バブルソートと選択ソートの結果を比較
bool isStable(struct Card C1[], struct Card C2[], int N) {
    for(int i = 0; i < N; i++) {
        if(C1[i].suit != C2[i].suit) return false;
    }
    return true;
}

int main() {
    Card C1[100], C2[100];
    int N;
    
    cin >> N;
    for(int i = 0; i < N; i++) {
        cin >> C1[i].suit >> C1[i].value;
    }
    
    for(int i = 0; i < N; i++) {
        C2[i] = C1[i];
    }
    
    bubble(C1, N);
    selection(C2, N);
    
    print(C1, N);
    cout << "Stable" << endl;
    print(C2, N);
    if(isStable(C1, C2, N)) {
        cout << "Stable" << endl;
    }
    else {
        cout << "Not stable" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3104
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;
using namespace std;
typedef long long int LL;
typedef unsigned long long int ULL;

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i, h) {
        cin >> s[i];
    }

    vector<vector<LL>> left(h, vector<LL>(w, 0));
    vector<vector<LL>> right(h, vector<LL>(w, 0));
    vector<vector<LL>> up(h, vector<LL>(w, 0));
    vector<vector<LL>> down(h, vector<LL>(w, 0));


    rep(y, h) {
        int acc = 0;
        rep(x, w) {
            if (s[y][x] == '#') {
                acc = 0;
                continue;
            }
            acc++;
            left[y][x] = acc;
        }
    }
    rep(y, h) {
        int acc = 0;
        for (int x = w - 1; x >= 0; x--) {
            if (s[y][x] == '#') {
                acc = 0;
                continue;
            }
            acc++;
            right[y][x] = acc;
        }
    }
    rep(x, w) {
        int acc = 0;
        rep(y, h) {
            if (s[y][x] == '#') {
                acc = 0;
                continue;
            }
            acc++;
            up[y][x] = acc;
        }
    }
    rep(x, w) {
        int acc = 0;
        for (int y = h - 1; y >= 0; y--) {
            if (s[y][x] == '#') {
                acc = 0;
                continue;
            }
            acc++;
            down[y][x] = acc;
        }
    }
    LL ans = 0;
    rep(y, h) {
        rep(x, w) {
            ans = max(ans, left[y][x] + right[y][x] + up[y][x] + down[y][x] - 3);
        }
    }
    cout << ans << endl;
    return 0;
}


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

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


	int sum = 0;
	int s;
	
	for (int i = 0; i < 10; i++){
	
		cin >> s;
		sum += s;
	}

	cout << sum << "\n";
}

Measured memory_bytes: 1200
s = input()
if s == "SUN":
    print(7)
elif s == "SAT":
    print(1)
elif s == "FRI":
    print(2)
elif s == "THU":
    print(3)
elif s == "WED":
    print(4)
elif s == "TUE":
    print(5)
elif s == "MON":
    print(6)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using hset = unordered_set<T>;
template<class Key, class T> using hmap = unordered_map<Key, T>;

map<char, int> news = {{'N', 0}, {'E', 1}, {'S', 2}, {'W', 3}};
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};

int main() {
    int N, M, I, x, y;
    char d;
    hset<int> st;
    while (cin >> N) {
        st.clear();
        if (N == 0) break;
        for (int i = 0; i < N; i++) {
            cin >> x >> y;
            st.insert(y*21 + x);
        }

        cin >> M;
        x = 10; y = 10;
        for (int i = 0; i < M; i++) {
            cin >> d >> I;
            for (int j = 0; j < I; j++) {
                x += dx[news[d]];
                y += dy[news[d]];
                st.erase(y*21 + x);
            }
        }
        if (st.empty()) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

    return 0;
}

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

int main(){
    
    long int n;

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

    int ema = i[0];
    for(int x=0; x < n; x++){
        if(ema > i[x]){
            ema = i[x];
        }
    }

    int rei = i[0];
    for(int y=0; y < n; y++){
        if(rei < i[y]){
            rei = i[y];
        }
    }

    long int noman = 0;
    for(int z=0; z < n; z++){
        noman = noman + i[z];
    }

    cout << ema << " " << rei << " " << noman << endl;

    return 0;
} 


Measured memory_bytes: 3160
#include <iostream>
#include <cstdio>
#include <cctype>
#include <string>
#include <cstring>
using namespace std;

int main(int argc, char const *argv[])
{
    int n, m, l, x;
    cin >> n >> m >> l;
    int a[n][m], b[m][l];
    long long c[n][l];
    for(int i = 0; i < n; i ++){
        for(int j = 0; j < m; j ++){
            cin >> x;
            a[i][j] = x;
        }
    }
    for(int i = 0; i < m; i ++){
        for(int j = 0; j < l; j ++){
            cin >> x;
            b[i][j] = x;
        }
    }
    for(int i = 0; i < n; i ++){
        for(int j = 0; j < l; j ++){
            long long num = 0;
            for(int k = 0; k < m; k ++){
                num += a[i][k] * b[k][j];
            }
            c[i][j] = num;
        }
    }
    for(int i = 0; i < n; i ++){
        for(int j = 0; j < l; j ++){
            cout << c[i][j];
            if (j < l - 1) cout << " ";
        }
        cout << endl;
    }
    return 0;
}


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

namespace CSharp_AtCoder
{

    
    class Program
    {

        const int MOD = 1000000000 + 7;

        static void Main(string[] args)
        {
            int[] input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int H = input[0];
            int W = input[1];

            char[,] map = new char[H + 1, W + 1];
            for(int i = 1; i <= H; i++)
            {
                string row = Console.ReadLine();
                for(int j = 1; j <= W; j++)
                {
                    map[i, j] = row[j - 1];
                }
            }

            int[,] dp = new int[H + 1, W + 1];
            for(int i = 1; i <= H; i++)
            {
                for(int j = 1; j <= W; j++)
                {
                    if (i == 1 && j == 1) dp[i, j] = 1;
                    else if (map[i, j] == '#') dp[i, j] = 0;
                    else dp[i, j] = dp[i - 1, j] + dp[i, j - 1];
                    dp[i, j] %= MOD;
                }
            }

            Console.WriteLine(dp[H, W]);
        }
    }
}


Measured memory_bytes: 23004
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <map>
#include <queue>
#include <vector>
#include <utility>
#include <climits>
#include <numeric>
#define ll long long
#define INF INT_MAX 
using namespace std;
int main(){
    ll N,K;
    cin >> N >> K;
    pair<ll,ll> P[N];
    for(int i=0;i<N;i++){
        cin >> P[i].first >> P[i].second;
    }
    sort(P,P+N);
    for(int i=0;i<N;i++){
        K = K - P[i].second;
        if(K<=0){
            cout << P[i].first << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 1792
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, a, b) for (int i = a; i < (b); i++)
#define FOR(i, n) for (int i = n; i >= 0; i--)
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <vector>
#define ll long long
#define INF 1000000001
using namespace std;
struct Edge{int from, to, cost;};

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

    ll n,k;
    cin >> n;
    cin >> k;
    
    ll min_num = 1000000001;
    for(int i = 1; i <= n; i++){
      ll cost = 1;
      for(int j = 0; j < i; j++) cost *= 2;
      for(int j = 0; j < n-i; j++) cost += k;

      if(min_num > cost) min_num = cost;
    }
    
    cout << min_num << endl;

    return 0;
}


Measured memory_bytes: 256
import           Control.Monad
import qualified Control.Monad.ST            as ST
import qualified Data.Array.IO               as IO
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Maybe
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM

readInt = fst . fromJust . BS.readInt
getInt = readInt <$> BS.getLine

main = do
  n <- getInt
  s <- BS.getLine

  dp <- IO.newArray ((0,0),(n+1,n+1)) 0 :: IO (IO.IOUArray (Int,Int) Int)
  v <- VM.new 1
  VM.write v 0 0

  forM_ [n-1,(n-2)..0] $ \i ->
    forM_ [n-1,(n-2)..(i+1)] $ \j ->
      when (BS.index s i == BS.index s j) $ do
        dpij <- IO.readArray dp (i,j)
        dpi1j1 <- IO.readArray dp (i+1, j+1)
        let nv = max dpij (dpi1j1 + 1)
        IO.writeArray dp (i,j) nv
        res <- VM.read v 0
        VM.write v 0 $ max res $ min nv (j-i)

  ans <- VM.read v 0
  print ans

Measured memory_bytes: 196476
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<set>
#include<utility>
#include<queue>
#include<stdio.h>
//#include<sys/time.h>
#include<random>
#include<fstream>
#define INF 2000000000
using namespace std;
typedef std::pair<int,int> P;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
int n,ans,cnt;
signed main(){
	cin>>n;
	rep(i,n){
		int a,b;
		cin>>a>>b;
		if(a==b)cnt++;
		else{
			ans=max(ans,cnt);
			cnt=0;
		}
	}
	ans=max(ans,cnt);
		if(ans>=3)cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
}


Measured memory_bytes: 3620
def main():
    s = input()
    t = input()

    """
    dp[i][j] := s[1] ... s[i] と t[1] ... t[j] に対するLCSの長さ
    
    s[i+1] == t[i+1]のとき、dp[i+1][j+1]は dp[i][j]+1, dp[i+1][j], dp[i][j+1]のいずれか  
    dp[i+1][j+1] = max(dp[i][j] + 1, dp[i+1][j], dp[i][j+1])

    それ以外の時
    dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1])
    """

    dp = [[0] * (len(t) + 1) for _ in range(len(s) + 1)]

    for i in range(len(s)):
        for j in range(len(t)):
            if s[i] == t[j]:
                dp[i + 1][j + 1] = max(dp[i][j] + 1, dp[i + 1][j], dp[i][j + 1])
            else:
                dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1])

    ans = ""
    x = len(s)
    y = len(t)
    while x >= 1 and y >= 1:
        if dp[x][y] == dp[x - 1][y]:
            x -= 1
        elif dp[x][y] == dp[x][y - 1]:
            y -= 1
        else:
            x -= 1
            y -= 1
            ans = s[x] + ans

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 111836
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcount
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    int n;
    cin >> n;
    vector <int> a(2 * n);
    for (int i = 0; i < 2 * n; ++i)
        cin >> a[i];
    sort(all(a));
    int ans = 0;
    for (int i = 0; i < 2 * n; i += 2) {
        ans += a[i];
    }   
    cout << ans << endl;
}

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

const int maxN = 510;
const char ch[8] = "RYGB";

int h, w;
char str[maxN][maxN];

inline void mark(int x, int y, int k){
	if(0 <= x && x < h && 0 <= y && y < w)
		str[x][y] = ch[k];
}

int main (){
	int d, i, j;
	scanf("%d%d%d", &h, &w, &d);
	if(d & 1){
		for(i = 0; i < h; ++i){
			for(j = 0; j < w; ++j)
				printf("%c", ch[(i + j) & 1]);
			puts("");
		}
	}
	else{
		if(d & 2){
			for(i = 0; i < h; ++i){
				for(j = 0; j < w; ++j)
					printf("%c", ch[((i & 3) + (j & 2)) & 3]);
				puts("");
			}
		}
		else{
			int s, t, p, q, k, dm = d / 2;
			for(p = -1; p <= max(0, h / dm) + 1; ++p){
			for(q = -1; q <= max(0, w / dm) + 1; ++q){
				s = p * dm, t = q * d;
				if(p & 1) t += dm;
				k = (p & 1) + ((p / 2 + q) & 1) * 2;
				for(i = 0; i < dm; ++i){
					for(j = 0; j < dm - i; ++j){
						mark(s + i, t + dm - j - 1, k);
						mark(s + i, t + dm + j, k);
						mark(s - i, t + dm - j - 1, k);
						mark(s - i, t + dm + j, k);
					}
				}
			}}
			for(i = 0; i < h; ++i) puts(str[i]);
		}
	}
	return 0;
}

Measured memory_bytes: 3888
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#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 FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



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

  ll ans = 0;
  ll digitsum = 0;

  FOR(i,0,m-1){
    ll d,c;
    cin >> d >> c;
    ans += c;
    digitsum += d*c;
  }

  cout << (digitsum-1) / 9 + ans-1 << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int n,A[50];

int solve(int i,int m){
if(m==0) return 1;
if(i>=n) return 0;
	int res = solve(i+1,m) || solve(i+1,m-A[i]);
	return res;
}

int main(){
int q,M,i;

scanf("%d",&n);
for(i=0;i<n;i++) scanf("%d",&A[i]);
scanf("%d",&q);
for(i=0;i<q;i++){
 scanf("%d",&M);
 if( solve(0,M) ) printf("yes\n");
else printf("no\n");
}

return 0;
}
 

Measured memory_bytes: 1800
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;

class _Class
{
  void _Do()
  {
    var N = Split.ints()[0];
    var A = Split.ints();
    var B = Split.ints();

    long a = 0;
    for (long l = 0; l < N; l++)
      a += A[l];

    long b = 0;
    for (long l = 0; l < N; l++)
      b += B[l];

    if (a - b < 0)
    {
      Console.WriteLine(-1);
      return;
    }

    long kari = 0;
    int ret = 0;
    var memo = new List<int>();

    for(int i = 0; i < N; i++)
    {
      if (A[i] < B[i])
      {
        ret++;

        long tmp = B[i] - A[i];
        A[i] = B[i];
        kari += tmp;
      }
      else
      {
        memo.Add(A[i]-B[i]);
      }
    }

    memo.Sort();
    memo.Reverse();

    //
    if (kari == 0)
    {
      Console.WriteLine(ret);
      return;
    }

    // A>=B
    for(int i=0;i<memo.Count ;i++ )
    {
      kari -= memo[i];
      ret++;

      if (kari<=0)
      {
        Console.WriteLine(ret);
        return;
      }
    }

  }

  static void Main(string[] args)
  {
    _(args);
    new _Class()._Do();
  }

  [Conditional("DEBUG")]
  static void _(string[] args)
  {
    if (args.Length != 0 && File.Exists(args[0]))
      Console.SetIn(new StreamReader(args[0]));
    else
      Console.Error.WriteLine("in");
  }
}

static class Split
{ 

  // 1
  public static string[] strings()
  {
    return Console.ReadLine().Split();
  }


  // [2.1] -2,147,483,648 ~ +2,147,483,647
  public static int[] ints()
  {
    var _s = Console.ReadLine().Split();

    var x = new int[_s.Length];
    for (var i = 0; i < _s.Length; i++)
      x[i] = int.Parse(_s[i]);

    return x;
  }

  // [2.2] 
  // -9,223,372,036,854,775,808 ~ 
  // +9,223,372,036,854,775,807
  public static long[] longs()
  {
    var _s = Console.ReadLine().Split();

    var x = new long[_s.Length];
    for (var i = 0; i < _s.Length; i++)
      x[i] = long.Parse(_s[i]);

    return x;
  }

  public static double[] doubles()
  {
    var _s = Console.ReadLine().Split();

    var x = new double[_s.Length];
    for (var i = 0; i < _s.Length; i++)
      x[i] = double.Parse(_s[i]);

    return x;
  }

  public static BigInteger[] bigs()
  {
    var _s = Console.ReadLine().Split();

    var x = new BigInteger[_s.Length];
    for (var i = 0; i < _s.Length; i++)
      x[i] = BigInteger.Parse(_s[i]);

    return x;
  }
}



Measured memory_bytes: 37724
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <ios>
#include <iostream>
#include <vector>

#define ll long long

using namespace std;

int N, K, b;
ll cnt = 0;

int main()
{
    cin >> N >> K;
    if (K > 0) {
        for (int b = K + 1; b <= N; b++) {
            if (N % b == b - 1) {
                cnt += (b - K) * ((N + 1) / b - 1);
            } else {
                cnt += (b - K) * ((N + 1) / b);
            }
            cnt += max(N % b - K + 1, 0);
        }
    } else {
        for (int b = K + 1; b <= N; b++) {
            if (N % b == b - 1) {
                cnt += (b - K) * ((N + 1) / b - 1);
            } else {
                cnt += (b - K) * ((N + 1) / b);
            }
            cnt += max(N % b - K, 0);
        }
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cctype>
#include <vector>

using namespace std;

int len;

string UpperCamelCase(vector<string> v){
  string res = "";

  for(int i = 0 ; i < len ; i++){
    if(islower(v[i][0])){
      v[i][0] = toupper(v[i][0]);
    }
    res += v[i];
  }

  return res;
}

string LowerCamelCase(vector<string> v){
  string res = v[0];

  for(int i = 1 ; i < len ; i++){
    if(islower(v[i][0])){
      v[i][0] = toupper(v[i][0]);
    }
    res += v[i];
  }

  return res;
}

string Under(vector<string> v){
  string res = v[0];

  for(int i = 1 ; i < len ; i++){
    res += '_' + v[i];
  }
  
  return res;
}

int main(){
  string s;
  char order;

  while(cin >> s >> order, order != 'X'){
    if(isupper(s[0])){
      s[0] = tolower(s[0]);
    }
    s += '_';

    vector<string> v;
    int pos = 0;
    len = (int)s.size();

    for(int i = 0 ; i < len ; i++){
      if(isupper(s[i])){
	s[i] = tolower(s[i]);
	v.push_back(s.substr(pos,i-pos));
	pos = i;
      }else if(s[i] == '_'){
	v.push_back(s.substr(pos,i-pos));
	pos = i + 1;
      }
    }

    len = (int)v.size();
    
    if(order == 'U'){
      cout << UpperCamelCase(v) << endl;
    }else if(order == 'L'){
      cout << LowerCamelCase(v) << endl;
    }else{
      cout << Under(v) << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 1208
while True:
    n,p=map(int,raw_input().split())
    if n==p==0:break
    L=[0]*n
    cup=p
    i=0
    while L[i]!=p:
        if cup!=0:
            L[i]+=1
            cup-=1
        else:
            cup=L[i]
            L[i]=0
        i+=1
        if i==n:
            i%=n
    print i

Measured memory_bytes: 4228
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define fi first
#define se second
#define INF 1000000009
#define lINF 1000000000000000009
using ll = long long;

bool is(string s){
  string t;
  t=s;
  reverse(t.begin(),t.end());
  return s==t;
}

int main(){
  string s;
  cin>>s;
  bool ans=true;
  if(!is(s))ans=false;
  if(!is(s.substr(0,(int)s.size()/2)))ans=false;
  cout<<(ans?"Yes":"No")<<endl;
  return(0);
}


Measured memory_bytes: 256
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
if N&1:
    print(0)
    exit()
count = 0
x = 1
while N >= 5**x:
    count += N // (2 * 5**x)
    x += 1

print(count)
# 23

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (long long i = 0; i < n; i++)
#define RREP(i, n) for (long long i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (long long i = start; i < end; i++)
#define RFOR(i, start, end) for (long long i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}

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

    int H, W;
    cin >> H >> W;
    vector<vector<char>> a(H, vector<char>(W));
    for (auto &&i : a) {
        for (auto &&j : i) {
            cin >> j;
        }
    }

    auto yes = []() {
        print("Possible");
        exit(0);
    };
    auto no = []() {
        print("Impossible");
        exit(0);
    };
    int mx = 0;
    REP(y, H) {
        REP(x, W) {
            if (a[y][x] == '#' && mx <= x) {
                mx = x;
            } else if (a[y][x] == '#') {
                no();
            }
        }
    }
    yes();

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

int main() {
  int hinaarare_num;
  std::cin >> hinaarare_num;
  std::vector<std::string> hinaarare_color(200);
  std::string hinaarare_color_count = "Three";

  for (int i = 0; i < hinaarare_num; i++) {
    std::cin >> hinaarare_color.at(i);
    if (hinaarare_color.at(i) == "Y") {
      hinaarare_color_count = "Four";
    }
  }

  std::cout << hinaarare_color_count << std::endl;

  return 0;
}


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

#define pb push_back
#define ll long long

using namespace std;

const int N = 1e5 + 123, mod = 1e9 + 7;

int n;
ll dp[N][3];
vector <int> g[N];

void dfs (int v = 1, int p = -1) {
    ll val1 = 0, val2 = 0;
    for (auto to : g[v]) {
        if (to != p) {
            dfs (to, v);
            if (!dp[v][0])dp[v][0] = (dp[to][0] + dp[to][1]) % mod;
            else dp[v][0] = (dp[v][0] * ((dp[to][0] + dp[to][1]) % mod)) % mod;
            if (!dp[v][1])dp[v][1] = dp[to][0];
            else dp[v][1] = (dp[v][1] * dp[to][0]) % mod;
        }
    }
    dp[v][0] = max (dp[v][0], 1ll);
    dp[v][1] = max (dp[v][1], 1ll);
}

int main () {
    ios_base::sync_with_stdio (0), cin.tie (0), cout.tie (0);
    cin >> n;
    for (int i = 1;i < n;i ++) {
        int l, r;
        cin >> l >> r;
        g[l].pb (r);
        g[r].pb (l);
    }dfs ();
    cout << (dp[1][0] + dp[1][1]) % mod;
}


Measured memory_bytes: 15104
#include<bits/stdc++.h>
typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)

using namespace std;
const ll N = 1e9+7;
const ll M = 2*1e5+5;
ll dp[M], invdp[M];

ll modinv(ll a, ll m){
    ll b = m, u = 1, v = 0;
    while(b){
        ll t = a/b;
        a -= t * b; swap(a,b);
        u -= t * v; swap(u,v);
    }
    u %= m;
    if(u < 0) u += m;
    return u;

}

void expo(){
    dp[0] = 1;
    invdp[0] = 1;
    // inv[0] = 1;
    rep(i,M){
        dp[i+1] = dp[i] * (i + 1) % N;
        // inv[i+1] = N - inv[N%(i+1)] * (N/(i+1)) % N;
        invdp[i+1] = modinv(dp[i+1], N);
    }
}


ll conv(ll x, ll y){
    ll ans;
    if(y > 0 && x > y) ans = dp[x] * (invdp[y] * invdp[x-y] %N) % N;
    else ans = 1;
    // cout << dp[x] << " " << invdp[y] << " " << invdp[x-y] << " " << ans << endl;
    return ans;
}

int main(){
    int n,m,k; cin >> n >> m >> k;
    // dp[0] = 1;
    // rep(i,m*n+5){
    //     dp[i+1] = dp[i] * (i + 1) % N;
    // }
    // rep(i,10) cout << dp[i] << endl;
    expo();
    ll xans = 0;
    ll yans = 0;
    // cout << conv(n*m-2,k-2) << endl;
    ll cv = conv(n*m-2,k-2);
    for(int d = 1; d < n; d++){
        xans += cv * d * (n-d) *m * m % N; 
    }
    for(int d = 1; d < m; d++){
        yans += cv * d * (m-d) *n * n % N; 
    }

    ll ans = (xans + yans ) % N;
    cout << ans << endl;   
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using p = pair<int, int>;
using P = pair<ll, ll>;
using pq = priority_queue<int>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int Inf = (1 << 30);
ll inf = (1LL << 60);
const int MOD = 1e9 + 7;
ll ZERO = 0;
ll NINE = 9;
ll TEN = 10;
int main() { // くやしい
	int k;
	cin >> k;
	queue<ll> que;
	rep1(i, 9) que.push(i);
	int count = 0;
	while (1) {
		ll tmp = que.front();
		que.pop();
		count++;
		for (ll i = max(ZERO, (tmp % TEN) - 1); i <= min((tmp % TEN) + 1, NINE); i++) {
			que.push(tmp * 10 + i);
		}
		if (count == k) {
			cout << tmp << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <sys/resource.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define fi first
#define se second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 2e3 + 10;

int n, a[N];
int m;

vector<int> v[N];
vector<int> ans;
int mi = inf;

void bfs(int source){
   queue<int> q;
   q.push(source);
   bool f = 1;

   vector<int> par(n+1);

   vector<int> check;
   while(!q.empty()){
      int top = q.front();
      q.pop();
      if(top == source and f == 0){
         check.push_back(top);
         top = par[top];
         while(top != source){
            check.push_back(top);
            top = par[top];
         }
         break;
      }
      f = 0;
      for(auto it: v[top]){
         if(par[it])continue;
         par[it] = top;
         q.push(it);
      }
   }
   if (!check.empty()){
      if(mi > sz(check)){
         mi = sz(check);
         ans = check;
      }
   }
}

int32_t main(){_

   cin>>n>>m;

   for (int i = 0; i < m; ++i)
   {
      int x, y;
      cin >> x >> y;
      v[x].push_back(y);
   }

   for (int i = 1; i <= n; ++i)
   {
      bfs(i);
   }

   if (mi == inf){
      cout<<-1;
      exit(0);
   }

   cout<<sz(ans)<<endl;
   for(auto it: ans)
      cout<<it<<endl;

   return 0;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define UB upper_bound
#define LB lower_bound
#define PB push_back
#define mp make_pair
#define F first
#define S second
#define be(a) (a).begin(),(a).end()
#define deb(x) cout<< #x <<" "<<endl;
#define deb2(x, y) cout<< #x <<" "<< x <<endl<< #y <<" "<<y<<endl
#define fo(i, n) for(long long i=0; i<n; i++)
#define Fo(i, n, k) for(long long i=k; i<n; i++)
#define mod 1000000007
#define int long long

typedef long long ll;

void fileIO()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
 
typedef vector<pair<int, int>> vll;
typedef unordered_map<int, int> ump;



bool sortbysecdesc(const pair<int, int> &a, 
                    const pair<int, int> &b) 
{ 
    return a.second>b.second;
}


int longestPath(vector<int> adj[], int u, int &res, bool vis[], int dp[])
{
    vis[u] = true;
    int maxv = 0;
    for(int v: adj[u])
    {
        if(!vis[v])
        {
            maxv = max(maxv, 1 + longestPath(adj, v, res, vis, dp));
        }
        else
        {
            maxv = max(maxv, 1 + dp[v]);
        }


    }


    dp[u] = maxv;

    res = max(res, dp[u]);

    return dp[u];

}


vector<int>adj[100001];
int dp[100001];




int32_t main()
{
    IOS;
    fileIO();
    int T;
    T = 1;
    //cin>>T;

    while(T--)
    {
        int n, m;
        cin>>n>>m;
        for(int i = 0; i<m; i++)
        {
            int a, b;
            cin>>a>>b;
            adj[a].push_back(b);
        }

        bool vis[100001] = {false};

        for(int i = 0; i<=n; i++) dp[i] = 0;


        int res = 0;
        int temp;

        for(int i = 1; i<=n; i++)
        {
            if(!vis[i])
            {
                temp = longestPath(adj, i, res, vis, dp);
            }
        }


        cout<<res;
        

    }
    
    return 0;
}



Measured memory_bytes: 13304
#include <stdio.h>

//?????°
#define MAX_VALUE 1000000
#define INF MAX_VALUE-1

int main()
{
  int i;
  int min;
  int j,k,n,MAX_SIZE;
  int low_cost[100];
  int total_cost = 0;
  //??£??\??????
  int weight[100][100];
	//?????????
  
  scanf("%d",&MAX_SIZE);
  for(i = 0; i < MAX_SIZE; i++){
    for(j = 0; j < MAX_SIZE; j++){
      scanf("%d",&weight[i][j]);
      if(weight[i][j] == -1) weight[i][j] = INF;
    }
	}
  for(i=1;i<MAX_SIZE;i++){
    low_cost[i] = weight[0][i];
  }
  //???????????????
  for(i=1;i<MAX_SIZE;i++){
    min = low_cost[1];
    k = 1;
    for(j=2;j<MAX_SIZE;j++){
      if(min > low_cost[j]){
	min = low_cost[j];
	k = j;
      }
    }
    total_cost += low_cost[k];
    low_cost[k] = MAX_VALUE;
    for(j=1;j<MAX_SIZE;j++){
      if(low_cost[j] < MAX_VALUE && low_cost[j] > weight[k][j]){
	low_cost[j] = weight[k][j];
      }
    }
  }
  printf("%d\n",total_cost);
  return 0;
}

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

typedef pair<int, int> Data;
typedef pair<int, Data> Pair;

int n, m, a;
vector<Pair> lines;
int num[114514];

int main() {
  while (1) {
    scanf("%d%d%d", &n, &m, &a);
    if (n == 0 && m == 0 && a == 0) return 0;

    for (int i=1; i<=n; i++) num[i] = i;

    lines.clear();
    for (int i=0; i<m; i++) {
      int h, p, q;
      scanf("%d%d%d", &h, &p, &q);
      lines.emplace_back(Pair{h, Data{p, q}});
    }
    sort(lines.begin(), lines.end());

    for (int i=m-1; i>=0; i--) {
      Pair pa = lines[i];
      Data d = pa.second;
      int p = d.first;
      int q = d.second;

      swap(num[p], num[q]);
    }

    for (int i=1; i<=n; i++) {
      if (num[i] == a) {
        printf("%d\n", i);
        break;
      }
    }
  }
}

Measured memory_bytes: 3108
//om namah shivaaay//
#include <bits/stdc++.h>
#define Om_namah_Shivaay ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll long long
 using namespace std;
 int main()
 {
	 Om_namah_Shivaay;
	 int n;
	 cin>>n;
	 cout<<(n/2)+(n%2);
		
		 }


Measured memory_bytes: 256